@anuma/sdk 6.4.2 → 6.6.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-WYARTNEN.mjs → chunk-4M6W7QLZ.mjs} +233 -8
- package/dist/{react/chunk-ILAWDQDE.mjs → expo/chunk-B5UPJRCU.mjs} +16 -1
- package/dist/expo/{chunk-DT6QNRZL.mjs → chunk-VOMDHMKH.mjs} +1 -1
- package/dist/{react/consolidate-AMPKH6YJ.mjs → expo/consolidate-TWE6OSSZ.mjs} +2 -2
- package/dist/expo/index.cjs +306 -156
- package/dist/expo/index.d.mts +163 -7
- package/dist/expo/index.d.ts +163 -7
- package/dist/expo/index.mjs +33 -154
- package/dist/expo/{recall-7FOWWX5T.mjs → recall-EZIHN5VU.mjs} +2 -2
- package/dist/index.cjs +71 -0
- package/dist/index.d.mts +121 -1
- package/dist/index.d.ts +121 -1
- package/dist/index.mjs +67 -0
- package/dist/react/{chunk-VMI74IUX.mjs → chunk-2ARMO2NN.mjs} +1 -1
- package/dist/{expo/chunk-ILAWDQDE.mjs → react/chunk-B5UPJRCU.mjs} +16 -1
- package/dist/react/{chunk-IO4ZCPK2.mjs → chunk-S6WPXD5N.mjs} +254 -8
- package/dist/{expo/consolidate-3MEWQNM3.mjs → react/consolidate-ZCGS7QUA.mjs} +2 -2
- package/dist/react/index.cjs +331 -206
- package/dist/react/index.d.mts +163 -7
- package/dist/react/index.d.ts +163 -7
- package/dist/react/index.mjs +36 -202
- package/dist/react/{recall-2J2755WC.mjs → recall-ROEK55FJ.mjs} +2 -2
- package/dist/server/{chunk-KF4HV3QE.mjs → chunk-CR5P3YIK.mjs} +1 -1
- package/dist/server/{chunk-EKYGWD5N.mjs → chunk-TD7SMY7C.mjs} +98 -8
- package/dist/server/{chunk-OBDRKQQI.mjs → chunk-VHWLLYKO.mjs} +16 -1
- package/dist/server/{consolidate-I6TOH7CB.mjs → consolidate-FWYK5KXB.mjs} +2 -2
- package/dist/server/index.cjs +158 -48
- package/dist/server/index.d.mts +54 -6
- package/dist/server/index.d.ts +54 -6
- package/dist/server/index.mjs +24 -43
- package/dist/server/{recall-IVV6EILK.mjs → recall-CGDEW2LQ.mjs} +2 -2
- package/package.json +1 -1
package/dist/expo/index.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CHUNKS_DISCARDED_ORIGIN,
|
|
2
3
|
DEFAULT_API_EMBEDDING_MODEL,
|
|
3
4
|
DEFAULT_CHUNK_OVERLAP,
|
|
4
5
|
DEFAULT_CHUNK_SIZE,
|
|
5
6
|
DEFAULT_MIN_CHUNK_SIZE,
|
|
6
7
|
DEFAULT_MIN_CONTENT_LENGTH,
|
|
7
8
|
DEFAULT_VAULT_CACHE_SIZE,
|
|
9
|
+
DISPLAY_CARD_PLACEHOLDER,
|
|
8
10
|
EMBEDDINGS_DEGRADED_EMPTY,
|
|
9
11
|
ENTITY_FANOUT,
|
|
10
12
|
ENTITY_KINDS,
|
|
@@ -15,6 +17,7 @@ import {
|
|
|
15
17
|
RECALL_MAX_LIMIT,
|
|
16
18
|
RECALL_TOOL_NAME,
|
|
17
19
|
RerankerUnavailableError,
|
|
20
|
+
TOOL_RESULT_ORIGIN,
|
|
18
21
|
TOPICS_EXTRACTION_VERSION,
|
|
19
22
|
TREND_RECENT_WINDOW_DAYS,
|
|
20
23
|
TREND_STALE_WINDOW_DAYS,
|
|
@@ -22,6 +25,7 @@ import {
|
|
|
22
25
|
archiveVaultMemoryOp,
|
|
23
26
|
assertVaultScopeForSweep,
|
|
24
27
|
backfillMemoryTopicsOp,
|
|
28
|
+
buildToolResultContent,
|
|
25
29
|
capHopsForDensity,
|
|
26
30
|
chunkAndEmbedAllMessages,
|
|
27
31
|
chunkAndEmbedMessage,
|
|
@@ -42,6 +46,7 @@ import {
|
|
|
42
46
|
createVaultEmbeddingCache,
|
|
43
47
|
createVaultMemoriesBatchOp,
|
|
44
48
|
createVaultMemoryOp,
|
|
49
|
+
decodeChunkVector,
|
|
45
50
|
decomposeQuery,
|
|
46
51
|
decryptField,
|
|
47
52
|
decryptJsonField,
|
|
@@ -51,6 +56,7 @@ import {
|
|
|
51
56
|
eagerEmbedContent,
|
|
52
57
|
embedAllMessages,
|
|
53
58
|
embedMessage,
|
|
59
|
+
encodeChunkVector,
|
|
54
60
|
encryptField,
|
|
55
61
|
encryptJsonField,
|
|
56
62
|
encryptVaultMemoryContent,
|
|
@@ -94,6 +100,7 @@ import {
|
|
|
94
100
|
parseMedia,
|
|
95
101
|
postApiV1CreditsPurchase,
|
|
96
102
|
preEmbedVaultMemories,
|
|
103
|
+
prepareToolResultsForReplay,
|
|
97
104
|
prepareVaultCandidates,
|
|
98
105
|
rankPreparedVaultCandidates,
|
|
99
106
|
recall,
|
|
@@ -123,7 +130,7 @@ import {
|
|
|
123
130
|
upsertMessageOp,
|
|
124
131
|
useEncryption,
|
|
125
132
|
vaultMemoryToStored
|
|
126
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-4M6W7QLZ.mjs";
|
|
127
134
|
import {
|
|
128
135
|
PII_PATTERNS,
|
|
129
136
|
PiiRedactor,
|
|
@@ -131,8 +138,9 @@ import {
|
|
|
131
138
|
isPiiRedactor,
|
|
132
139
|
notifyConsolidationFallback,
|
|
133
140
|
resolvePiiRedactor
|
|
134
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-VOMDHMKH.mjs";
|
|
135
142
|
import {
|
|
143
|
+
INTERNAL_FLOW_MARKER,
|
|
136
144
|
callPortalJsonCompletion,
|
|
137
145
|
consoleLogger,
|
|
138
146
|
extractJsonCandidate,
|
|
@@ -141,8 +149,9 @@ import {
|
|
|
141
149
|
resolvePortalAuthHeaders,
|
|
142
150
|
setLogger,
|
|
143
151
|
supportsResponseFormat,
|
|
144
|
-
validateEndpointOverride
|
|
145
|
-
|
|
152
|
+
validateEndpointOverride,
|
|
153
|
+
withInternalFlowMarker
|
|
154
|
+
} from "./chunk-B5UPJRCU.mjs";
|
|
146
155
|
import {
|
|
147
156
|
BASE_URL,
|
|
148
157
|
MCP_R2_DOMAIN,
|
|
@@ -4782,7 +4791,17 @@ async function callSummarizationLlm(prompt, model, token, baseUrl) {
|
|
|
4782
4791
|
body: JSON.stringify({
|
|
4783
4792
|
model,
|
|
4784
4793
|
stream: false,
|
|
4785
|
-
|
|
4794
|
+
// The marker rides a system message because this call has no other
|
|
4795
|
+
// provenance: it posts to the MAIN chat endpoint (not /utility/*), carries no
|
|
4796
|
+
// conversationId, and its prompt is neither the app's chat base prompt nor any
|
|
4797
|
+
// registered flow fingerprint — so without this it reads as markerless, i.e.
|
|
4798
|
+
// as a scripted abuser. Progressive summarization runs for every free-tier
|
|
4799
|
+
// long conversation, so at the PORTAL_DETECTION_REJECT_MARKERLESS flip it
|
|
4800
|
+
// would 403 and silently fall back to verbatim history (context bloat + cost).
|
|
4801
|
+
messages: [
|
|
4802
|
+
{ role: "system", content: INTERNAL_FLOW_MARKER },
|
|
4803
|
+
{ role: "user", content: prompt }
|
|
4804
|
+
]
|
|
4786
4805
|
}),
|
|
4787
4806
|
signal: controller.signal
|
|
4788
4807
|
});
|
|
@@ -4986,153 +5005,6 @@ async function cleanupConversationSummary(database, conversationId) {
|
|
|
4986
5005
|
}
|
|
4987
5006
|
}
|
|
4988
5007
|
|
|
4989
|
-
// src/lib/chat/toolResultMessage.ts
|
|
4990
|
-
var HEADER = "[Tool Execution Results]\n\n";
|
|
4991
|
-
var FOOTER = "\n\nBased on these results, continue with the task.";
|
|
4992
|
-
var ENTRY_SEPARATOR = "\n\n";
|
|
4993
|
-
var TOOL_RESULT_FOOTER_LINE = FOOTER.trim();
|
|
4994
|
-
var MAX_PERSISTED_TOOL_RESULT_CHARS = 1e5;
|
|
4995
|
-
function buildToolResultContent(results) {
|
|
4996
|
-
const entries = results.map((r) => `Tool "${r.name}" returned: ${JSON.stringify(r.result)}`);
|
|
4997
|
-
const framing = HEADER.length + FOOTER.length + ENTRY_SEPARATOR.length * Math.max(0, entries.length - 1);
|
|
4998
|
-
const summary = capEntries(entries, MAX_PERSISTED_TOOL_RESULT_CHARS - framing).join(
|
|
4999
|
-
ENTRY_SEPARATOR
|
|
5000
|
-
);
|
|
5001
|
-
return `${HEADER}${summary}${FOOTER}`;
|
|
5002
|
-
}
|
|
5003
|
-
function capToolResultEntries(entries, budget) {
|
|
5004
|
-
return capEntries(entries, budget);
|
|
5005
|
-
}
|
|
5006
|
-
function capEntries(entries, budget) {
|
|
5007
|
-
const smallestFirst = entries.map((_, index) => index).sort((a, b) => entries[a].length - entries[b].length);
|
|
5008
|
-
const capped = [...entries];
|
|
5009
|
-
let remaining = budget;
|
|
5010
|
-
let unassigned = entries.length;
|
|
5011
|
-
for (const index of smallestFirst) {
|
|
5012
|
-
capped[index] = truncateEntry(entries[index], Math.floor(remaining / unassigned));
|
|
5013
|
-
remaining -= capped[index].length;
|
|
5014
|
-
unassigned--;
|
|
5015
|
-
}
|
|
5016
|
-
return capped;
|
|
5017
|
-
}
|
|
5018
|
-
function truncateEntry(entry, allowance) {
|
|
5019
|
-
if (entry.length <= allowance) return entry;
|
|
5020
|
-
const keep = allowance - truncationMarker(entry.length).length;
|
|
5021
|
-
if (keep <= 0) return entry.slice(0, Math.max(0, allowance));
|
|
5022
|
-
return `${entry.slice(0, keep)}${truncationMarker(entry.length - keep)}`;
|
|
5023
|
-
}
|
|
5024
|
-
function truncationMarker(omitted) {
|
|
5025
|
-
return `
|
|
5026
|
-
|
|
5027
|
-
... (tool output truncated, ${omitted} characters omitted)`;
|
|
5028
|
-
}
|
|
5029
|
-
|
|
5030
|
-
// src/lib/chat/toolResults.ts
|
|
5031
|
-
var TOOL_RESULTS_PREFIX = "[Tool Execution Results]";
|
|
5032
|
-
var DISPLAY_CARD_PLACEHOLDER = "[displayed a card to the user with the tool result]";
|
|
5033
|
-
var TOOL_LINE = /^Tool "([^"]+)" returned: (.*)$/;
|
|
5034
|
-
var TOOL_RESULT_ORIGIN = "tool_result";
|
|
5035
|
-
function isToolResultsRow(row) {
|
|
5036
|
-
if (row.origin === TOOL_RESULT_ORIGIN) return true;
|
|
5037
|
-
if (typeof row.origin === "string") return false;
|
|
5038
|
-
if (row.role !== "user" || !row.content.startsWith(TOOL_RESULTS_PREFIX)) return false;
|
|
5039
|
-
return parseToolResultSegments(row.content).length > 0;
|
|
5040
|
-
}
|
|
5041
|
-
function parseToolResultSegments(content) {
|
|
5042
|
-
const segments = [];
|
|
5043
|
-
for (const raw of content.split("\n")) {
|
|
5044
|
-
const line = raw.trim();
|
|
5045
|
-
const match = TOOL_LINE.exec(line);
|
|
5046
|
-
if (match) {
|
|
5047
|
-
segments.push({ name: match[1], line });
|
|
5048
|
-
continue;
|
|
5049
|
-
}
|
|
5050
|
-
const current = segments[segments.length - 1];
|
|
5051
|
-
if (!current || line === "" || line === TOOL_RESULT_FOOTER_LINE) continue;
|
|
5052
|
-
if (line === TOOL_RESULTS_PREFIX) continue;
|
|
5053
|
-
current.line = `${current.line}
|
|
5054
|
-
${line}`;
|
|
5055
|
-
}
|
|
5056
|
-
return segments;
|
|
5057
|
-
}
|
|
5058
|
-
function prepareToolResultsForReplay(rows, options) {
|
|
5059
|
-
if (options.fold) {
|
|
5060
|
-
return foldToolResultsRows(rows, {
|
|
5061
|
-
exclude: options.exclude,
|
|
5062
|
-
placeholder: options.placeholder
|
|
5063
|
-
});
|
|
5064
|
-
}
|
|
5065
|
-
return rows.filter((row) => !isToolResultsRow(row));
|
|
5066
|
-
}
|
|
5067
|
-
function foldToolResultsRows(rows, options) {
|
|
5068
|
-
const exclude = new Set(options?.exclude ?? []);
|
|
5069
|
-
const out = [];
|
|
5070
|
-
const pending = [];
|
|
5071
|
-
const assistantIndexById = /* @__PURE__ */ new Map();
|
|
5072
|
-
for (const row of rows) {
|
|
5073
|
-
if (isToolResultsRow(row)) {
|
|
5074
|
-
pending.push({ row, insertionPoint: out.length });
|
|
5075
|
-
continue;
|
|
5076
|
-
}
|
|
5077
|
-
out.push(row);
|
|
5078
|
-
if (row.role === "assistant" && row.uniqueId) {
|
|
5079
|
-
assistantIndexById.set(row.uniqueId, out.length - 1);
|
|
5080
|
-
}
|
|
5081
|
-
}
|
|
5082
|
-
const byTarget = /* @__PURE__ */ new Map();
|
|
5083
|
-
for (const { row, insertionPoint } of pending) {
|
|
5084
|
-
const target = resolveFoldTarget(out, row, insertionPoint, assistantIndexById);
|
|
5085
|
-
if (target === void 0) continue;
|
|
5086
|
-
const group = byTarget.get(target);
|
|
5087
|
-
if (group) group.push(row);
|
|
5088
|
-
else byTarget.set(target, [row]);
|
|
5089
|
-
}
|
|
5090
|
-
for (const [target, groupedRows] of byTarget) {
|
|
5091
|
-
const assistant = out[target];
|
|
5092
|
-
const kept = groupedRows.flatMap((row) => parseToolResultSegments(row.content)).filter((segment) => !exclude.has(segment.name));
|
|
5093
|
-
if (kept.length > 0) {
|
|
5094
|
-
out[target] = { ...assistant, content: appendToolResults(assistant.content, kept) };
|
|
5095
|
-
} else if (!assistant.content.trim() && options?.placeholder) {
|
|
5096
|
-
out[target] = { ...assistant, content: options.placeholder };
|
|
5097
|
-
}
|
|
5098
|
-
}
|
|
5099
|
-
return out;
|
|
5100
|
-
}
|
|
5101
|
-
function resolveFoldTarget(out, row, insertionPoint, assistantIndexById) {
|
|
5102
|
-
const linked = row.parentMessageId ? assistantIndexById.get(row.parentMessageId) : void 0;
|
|
5103
|
-
if (linked !== void 0) return linked;
|
|
5104
|
-
let previous;
|
|
5105
|
-
for (let i = insertionPoint - 1; i >= 0; i--) {
|
|
5106
|
-
if (out[i].role === "assistant") {
|
|
5107
|
-
previous = i;
|
|
5108
|
-
break;
|
|
5109
|
-
}
|
|
5110
|
-
}
|
|
5111
|
-
let next;
|
|
5112
|
-
for (let i = insertionPoint; i < out.length; i++) {
|
|
5113
|
-
if (out[i].role === "assistant") {
|
|
5114
|
-
next = i;
|
|
5115
|
-
break;
|
|
5116
|
-
}
|
|
5117
|
-
}
|
|
5118
|
-
if (previous === void 0) return next;
|
|
5119
|
-
if (next === void 0) return previous;
|
|
5120
|
-
return next - insertionPoint < insertionPoint - previous ? next : previous;
|
|
5121
|
-
}
|
|
5122
|
-
var MAX_FOLDED_APPENDIX_CHARS = 2e4;
|
|
5123
|
-
function appendToolResults(assistantContent, kept) {
|
|
5124
|
-
const framing = TOOL_RESULTS_PREFIX.length + 1 + (kept.length - 1);
|
|
5125
|
-
const capped = capToolResultEntries(
|
|
5126
|
-
kept.map((segment) => segment.line),
|
|
5127
|
-
MAX_FOLDED_APPENDIX_CHARS - framing
|
|
5128
|
-
);
|
|
5129
|
-
const appendix = `${TOOL_RESULTS_PREFIX}
|
|
5130
|
-
${capped.join("\n")}`;
|
|
5131
|
-
return assistantContent.trim() ? `${assistantContent}
|
|
5132
|
-
|
|
5133
|
-
${appendix}` : appendix;
|
|
5134
|
-
}
|
|
5135
|
-
|
|
5136
5008
|
// src/lib/db/chat/lazyDecrypt.ts
|
|
5137
5009
|
var LRU_CAPACITY = 256;
|
|
5138
5010
|
var titleCache = /* @__PURE__ */ new Map();
|
|
@@ -6987,7 +6859,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
6987
6859
|
content: m.content,
|
|
6988
6860
|
similarity: m.similarity
|
|
6989
6861
|
}));
|
|
6990
|
-
const { consolidateMemory: doConsolidate } = await import("./consolidate-
|
|
6862
|
+
const { consolidateMemory: doConsolidate } = await import("./consolidate-TWE6OSSZ.mjs");
|
|
6991
6863
|
const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
|
|
6992
6864
|
if (decision.action === "create") return null;
|
|
6993
6865
|
if (decision.action === "supersede" && decision.content) {
|
|
@@ -8689,7 +8561,10 @@ async function synthesizeFacet(facet, ctx, options, prior) {
|
|
|
8689
8561
|
limit,
|
|
8690
8562
|
types: ["fact"],
|
|
8691
8563
|
maxTokens: DEFAULT_FACET_MAX_TOKENS,
|
|
8692
|
-
|
|
8564
|
+
// Profile-facet synthesis is a background op, so it marks its own prompt.
|
|
8565
|
+
// reflect() itself must NOT mark — it also serves the user's own questions,
|
|
8566
|
+
// and that traffic is chat, not an internal flow. See ../internalFlowMarker.
|
|
8567
|
+
systemPrompt: withInternalFlowMarker(buildFacetSystemPrompt(facet)),
|
|
8693
8568
|
responseSchema: facetResponseSchema(facet.key),
|
|
8694
8569
|
memories
|
|
8695
8570
|
});
|
|
@@ -14856,6 +14731,7 @@ function createNotionTools(getAccessToken, requestNotionAccess) {
|
|
|
14856
14731
|
];
|
|
14857
14732
|
}
|
|
14858
14733
|
export {
|
|
14734
|
+
CHUNKS_DISCARDED_ORIGIN,
|
|
14859
14735
|
Conversation as ChatConversation,
|
|
14860
14736
|
Message as ChatMessage,
|
|
14861
14737
|
ConversationMemory as ConversationMemoryModel,
|
|
@@ -14896,6 +14772,7 @@ export {
|
|
|
14896
14772
|
VaultFolder as StoredVaultFolderModel,
|
|
14897
14773
|
VaultMemory as StoredVaultMemoryModel,
|
|
14898
14774
|
StreamExpiredError,
|
|
14775
|
+
TOOL_RESULT_ORIGIN,
|
|
14899
14776
|
TOPICS_EXTRACTION_VERSION,
|
|
14900
14777
|
TOPIC_EXTRACTION_BATCH_SIZE,
|
|
14901
14778
|
TREND_RECENT_WINDOW_DAYS,
|
|
@@ -14953,6 +14830,7 @@ export {
|
|
|
14953
14830
|
createVaultMemoryOp,
|
|
14954
14831
|
createWeatherPreProcessor,
|
|
14955
14832
|
createWebSearchPreProcessor,
|
|
14833
|
+
decodeChunkVector,
|
|
14956
14834
|
decryptConversationTitle,
|
|
14957
14835
|
deleteAllVaultMemoriesForUserOp,
|
|
14958
14836
|
deleteVaultFolderOp,
|
|
@@ -14962,6 +14840,7 @@ export {
|
|
|
14962
14840
|
eagerEmbedContent,
|
|
14963
14841
|
embedAllMessages,
|
|
14964
14842
|
embedMessage,
|
|
14843
|
+
encodeChunkVector,
|
|
14965
14844
|
ensureDefaultFoldersOp,
|
|
14966
14845
|
exchangeNotionCode,
|
|
14967
14846
|
extractAndLinkEntitiesForMemoriesOp,
|
package/dist/index.cjs
CHANGED
|
@@ -61,6 +61,7 @@ var init_clientConfig = __esm({
|
|
|
61
61
|
var index_exports = {};
|
|
62
62
|
__export(index_exports, {
|
|
63
63
|
BUILT_IN_TOOL_SETS: () => BUILT_IN_TOOL_SETS,
|
|
64
|
+
CHUNKS_DISCARDED_ORIGIN: () => CHUNKS_DISCARDED_ORIGIN,
|
|
64
65
|
DEFAULT_ANALYSIS_PROMPT: () => DEFAULT_ANALYSIS_PROMPT,
|
|
65
66
|
DEFAULT_ANALYZE_AFTER_MESSAGES: () => DEFAULT_ANALYZE_AFTER_MESSAGES,
|
|
66
67
|
DEFAULT_DOCUMENT_PATTERN: () => DEFAULT_DOCUMENT_PATTERN,
|
|
@@ -76,6 +77,7 @@ __export(index_exports, {
|
|
|
76
77
|
PiiRedactor: () => PiiRedactor,
|
|
77
78
|
SseIdleTimeoutError: () => SseIdleTimeoutError,
|
|
78
79
|
TOOL_CATALOG: () => TOOL_CATALOG,
|
|
80
|
+
TOOL_RESULT_ORIGIN: () => TOOL_RESULT_ORIGIN,
|
|
79
81
|
activatedToolSetNames: () => activatedToolSetNames,
|
|
80
82
|
analyzeStyle: () => analyzeStyle,
|
|
81
83
|
applyToolSets: () => applyToolSets,
|
|
@@ -87,6 +89,7 @@ __export(index_exports, {
|
|
|
87
89
|
cosineInt8: () => cosineInt8,
|
|
88
90
|
createServerToolsFilter: () => createServerToolsFilter,
|
|
89
91
|
createStreamingDeAnonymizer: () => createStreamingDeAnonymizer,
|
|
92
|
+
decodeChunkVector: () => decodeChunkVector,
|
|
90
93
|
decryptConversationTitle: () => decryptConversationTitle,
|
|
91
94
|
defaultServerToolsFilter: () => defaultServerToolsFilter,
|
|
92
95
|
deleteApiV1Account: () => deleteApiV1Account,
|
|
@@ -101,6 +104,7 @@ __export(index_exports, {
|
|
|
101
104
|
deleteApiV1UserApiKeysByKeyId: () => deleteApiV1UserApiKeysByKeyId,
|
|
102
105
|
deleteApiV1WalletsBindingByAddress: () => deleteApiV1WalletsBindingByAddress,
|
|
103
106
|
dequantizeEmbedding: () => dequantizeEmbedding,
|
|
107
|
+
encodeChunkVector: () => encodeChunkVector,
|
|
104
108
|
expandToolSetsAdditive: () => expandToolSetsAdditive,
|
|
105
109
|
getApiV1AdminApps: () => getApiV1AdminApps,
|
|
106
110
|
getApiV1AdminAppsByAppIdApiKeys: () => getApiV1AdminAppsByAppIdApiKeys,
|
|
@@ -2829,6 +2833,9 @@ function buildSystemPrompt(ctx, options) {
|
|
|
2829
2833
|
return { prompt, activeSections };
|
|
2830
2834
|
}
|
|
2831
2835
|
|
|
2836
|
+
// src/lib/chat/toolResults.ts
|
|
2837
|
+
var TOOL_RESULT_ORIGIN = "tool_result";
|
|
2838
|
+
|
|
2832
2839
|
// src/react/useEncryption.ts
|
|
2833
2840
|
var EncryptionKeyMissingError = class extends Error {
|
|
2834
2841
|
constructor(address, version) {
|
|
@@ -2908,6 +2915,63 @@ async function decryptDataWithKey(encryptedHex, key) {
|
|
|
2908
2915
|
return SHARED_TEXT_DECODER.decode(decryptedData);
|
|
2909
2916
|
}
|
|
2910
2917
|
|
|
2918
|
+
// src/lib/processors/encoding.ts
|
|
2919
|
+
var B64_ENCODE_CHUNK = 32768 * 3;
|
|
2920
|
+
function uint8ArrayToBase64(data) {
|
|
2921
|
+
if (typeof Buffer !== "undefined") {
|
|
2922
|
+
return Buffer.from(data).toString("base64");
|
|
2923
|
+
}
|
|
2924
|
+
let base64 = "";
|
|
2925
|
+
for (let i = 0; i < data.length; i += B64_ENCODE_CHUNK) {
|
|
2926
|
+
const slice = data.subarray(i, i + B64_ENCODE_CHUNK);
|
|
2927
|
+
let binary = "";
|
|
2928
|
+
for (let j = 0; j < slice.length; j++) {
|
|
2929
|
+
binary += String.fromCharCode(slice[j]);
|
|
2930
|
+
}
|
|
2931
|
+
base64 += btoa(binary);
|
|
2932
|
+
}
|
|
2933
|
+
return base64;
|
|
2934
|
+
}
|
|
2935
|
+
function base64ToUint8Array(base64) {
|
|
2936
|
+
if (typeof Buffer !== "undefined") {
|
|
2937
|
+
const buf = Buffer.from(base64, "base64");
|
|
2938
|
+
return new Uint8Array(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength));
|
|
2939
|
+
}
|
|
2940
|
+
const binary = atob(base64);
|
|
2941
|
+
const bytes = new Uint8Array(binary.length);
|
|
2942
|
+
for (let i = 0; i < binary.length; i++) {
|
|
2943
|
+
bytes[i] = binary.charCodeAt(i);
|
|
2944
|
+
}
|
|
2945
|
+
return bytes;
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2948
|
+
// src/lib/memoryEngine/vectorEncoding.ts
|
|
2949
|
+
var BYTES_PER_FLOAT32 = 4;
|
|
2950
|
+
var CANONICAL_BASE64 = /^[A-Za-z0-9+/]+={0,2}$/;
|
|
2951
|
+
function encodeChunkVector(vector) {
|
|
2952
|
+
const f32 = vector instanceof Float32Array ? vector : Float32Array.from(vector);
|
|
2953
|
+
return uint8ArrayToBase64(new Uint8Array(f32.buffer, f32.byteOffset, f32.byteLength));
|
|
2954
|
+
}
|
|
2955
|
+
function decodeChunkVector(vector, onMalformed) {
|
|
2956
|
+
if (!vector || vector.length === 0) return new Float32Array(0);
|
|
2957
|
+
if (typeof vector !== "string") return Float32Array.from(vector);
|
|
2958
|
+
if (vector.length % 4 !== 0 || !CANONICAL_BASE64.test(vector)) {
|
|
2959
|
+
onMalformed?.();
|
|
2960
|
+
return new Float32Array(0);
|
|
2961
|
+
}
|
|
2962
|
+
try {
|
|
2963
|
+
const bytes = base64ToUint8Array(vector);
|
|
2964
|
+
if (bytes.byteLength === 0 || bytes.byteLength % BYTES_PER_FLOAT32 !== 0) {
|
|
2965
|
+
onMalformed?.();
|
|
2966
|
+
return new Float32Array(0);
|
|
2967
|
+
}
|
|
2968
|
+
return new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / BYTES_PER_FLOAT32);
|
|
2969
|
+
} catch {
|
|
2970
|
+
onMalformed?.();
|
|
2971
|
+
return new Float32Array(0);
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2911
2975
|
// src/lib/db/encryption-utils.ts
|
|
2912
2976
|
function isEncrypted(value) {
|
|
2913
2977
|
const prefix = value.startsWith("enc:v3:") ? "enc:v3:" : value.startsWith("enc:v2:") ? "enc:v2:" : null;
|
|
@@ -2979,6 +3043,9 @@ function getImageModel(r) {
|
|
|
2979
3043
|
return r.image_model;
|
|
2980
3044
|
}
|
|
2981
3045
|
|
|
3046
|
+
// src/lib/memoryEngine/embeddings.ts
|
|
3047
|
+
var CHUNKS_DISCARDED_ORIGIN = "chunks_discarded";
|
|
3048
|
+
|
|
2982
3049
|
// src/lib/memoryEngine/quantization.ts
|
|
2983
3050
|
var INT8_MAX = 127;
|
|
2984
3051
|
function quantizeEmbedding(v) {
|
|
@@ -3736,6 +3803,7 @@ function createStreamingDeAnonymizer(redactor, emit) {
|
|
|
3736
3803
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3737
3804
|
0 && (module.exports = {
|
|
3738
3805
|
BUILT_IN_TOOL_SETS,
|
|
3806
|
+
CHUNKS_DISCARDED_ORIGIN,
|
|
3739
3807
|
DEFAULT_ANALYSIS_PROMPT,
|
|
3740
3808
|
DEFAULT_ANALYZE_AFTER_MESSAGES,
|
|
3741
3809
|
DEFAULT_DOCUMENT_PATTERN,
|
|
@@ -3751,6 +3819,7 @@ function createStreamingDeAnonymizer(redactor, emit) {
|
|
|
3751
3819
|
PiiRedactor,
|
|
3752
3820
|
SseIdleTimeoutError,
|
|
3753
3821
|
TOOL_CATALOG,
|
|
3822
|
+
TOOL_RESULT_ORIGIN,
|
|
3754
3823
|
activatedToolSetNames,
|
|
3755
3824
|
analyzeStyle,
|
|
3756
3825
|
applyToolSets,
|
|
@@ -3762,6 +3831,7 @@ function createStreamingDeAnonymizer(redactor, emit) {
|
|
|
3762
3831
|
cosineInt8,
|
|
3763
3832
|
createServerToolsFilter,
|
|
3764
3833
|
createStreamingDeAnonymizer,
|
|
3834
|
+
decodeChunkVector,
|
|
3765
3835
|
decryptConversationTitle,
|
|
3766
3836
|
defaultServerToolsFilter,
|
|
3767
3837
|
deleteApiV1Account,
|
|
@@ -3776,6 +3846,7 @@ function createStreamingDeAnonymizer(redactor, emit) {
|
|
|
3776
3846
|
deleteApiV1UserApiKeysByKeyId,
|
|
3777
3847
|
deleteApiV1WalletsBindingByAddress,
|
|
3778
3848
|
dequantizeEmbedding,
|
|
3849
|
+
encodeChunkVector,
|
|
3779
3850
|
expandToolSetsAdditive,
|
|
3780
3851
|
getApiV1AdminApps,
|
|
3781
3852
|
getApiV1AdminAppsByAppIdApiKeys,
|