@anuma/sdk 3.9.6 → 3.11.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-FFB4CDPC.mjs → chunk-7CTI3XR6.mjs} +73 -2
- package/dist/expo/{chunk-BOY27A2C.mjs → chunk-ILAWDQDE.mjs} +24 -0
- package/dist/expo/{consolidate-NC5DOC5J.mjs → consolidate-HYIEFPFA.mjs} +1 -1
- package/dist/expo/index.cjs +161 -15
- package/dist/expo/index.d.mts +88 -2
- package/dist/expo/index.d.ts +88 -2
- package/dist/expo/index.mjs +69 -17
- package/dist/{react/recall-ELUJPQQB.mjs → expo/recall-IBGUFY4P.mjs} +2 -2
- package/dist/react/{chunk-BOY27A2C.mjs → chunk-ILAWDQDE.mjs} +24 -0
- package/dist/react/{chunk-YGCJX5YW.mjs → chunk-LAFUCS4U.mjs} +73 -2
- package/dist/react/{consolidate-54UWIMP6.mjs → consolidate-DOY3ZWTE.mjs} +1 -1
- package/dist/react/index.cjs +161 -15
- package/dist/react/index.d.mts +88 -2
- package/dist/react/index.d.ts +88 -2
- package/dist/react/index.mjs +69 -17
- package/dist/{expo/recall-JA6SOQRR.mjs → react/recall-Q5V5DN4L.mjs} +2 -2
- package/dist/server/{chunk-FXS3EUKX.mjs → chunk-NCKDSZPQ.mjs} +73 -2
- package/dist/server/{chunk-MIXEASUP.mjs → chunk-OBDRKQQI.mjs} +24 -0
- package/dist/server/{consolidate-YCD45CXO.mjs → consolidate-JMGL3MXG.mjs} +1 -1
- package/dist/server/index.cjs +161 -15
- package/dist/server/index.d.mts +88 -2
- package/dist/server/index.d.ts +88 -2
- package/dist/server/index.mjs +69 -17
- package/dist/server/{recall-VZO4USXK.mjs → recall-AN7HBEFS.mjs} +2 -2
- package/package.json +3 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
callPortalJsonCompletion,
|
|
3
3
|
getLogger
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OBDRKQQI.mjs";
|
|
5
5
|
import {
|
|
6
6
|
BASE_URL,
|
|
7
7
|
__commonJS,
|
|
@@ -16239,6 +16239,19 @@ async function decryptVaultMemoryFields(memory, address, signMessage, embeddedWa
|
|
|
16239
16239
|
}
|
|
16240
16240
|
|
|
16241
16241
|
// src/lib/db/memoryVault/operations.ts
|
|
16242
|
+
function visibilityOrPrivate(value) {
|
|
16243
|
+
return value === "public" ? value : "private";
|
|
16244
|
+
}
|
|
16245
|
+
var NON_PRIVATE_VISIBILITIES = ["public"];
|
|
16246
|
+
function visibilityConditions(requested) {
|
|
16247
|
+
if (!requested?.length) return [];
|
|
16248
|
+
if (!requested.includes("private")) {
|
|
16249
|
+
return [import_watermelondb3.Q.where("visibility", import_watermelondb3.Q.oneOf([...requested]))];
|
|
16250
|
+
}
|
|
16251
|
+
const excluded = NON_PRIVATE_VISIBILITIES.filter((v) => !requested.includes(v));
|
|
16252
|
+
if (excluded.length === 0) return [];
|
|
16253
|
+
return [import_watermelondb3.Q.or(import_watermelondb3.Q.where("visibility", null), import_watermelondb3.Q.where("visibility", import_watermelondb3.Q.notIn(excluded)))];
|
|
16254
|
+
}
|
|
16242
16255
|
function isOwnedByCtxUser(ctx, record) {
|
|
16243
16256
|
return ctx.userId === void 0 || record.userId === ctx.userId;
|
|
16244
16257
|
}
|
|
@@ -16300,6 +16313,10 @@ function vaultMemoryToStoredRaw(memory) {
|
|
|
16300
16313
|
factType: memory.factType ?? null,
|
|
16301
16314
|
archivedAt: memory.archivedAt ?? null,
|
|
16302
16315
|
trustTier: memory.trustTier ?? null,
|
|
16316
|
+
visibility: visibilityOrPrivate(memory.visibility),
|
|
16317
|
+
twinOptIn: memory.twinOptIn ?? false,
|
|
16318
|
+
publishedAt: memory.publishedAt ?? null,
|
|
16319
|
+
geohash: memory.geohash ?? null,
|
|
16303
16320
|
createdAt: memory.createdAt,
|
|
16304
16321
|
updatedAt: memory.updatedAt,
|
|
16305
16322
|
isDeleted: memory.isDeleted
|
|
@@ -16347,6 +16364,14 @@ async function createVaultMemoryOp(ctx, opts) {
|
|
|
16347
16364
|
if (opts.trustTier !== void 0) {
|
|
16348
16365
|
record._setRaw("trust_tier", normalizeTrustTier(opts.trustTier));
|
|
16349
16366
|
}
|
|
16367
|
+
record._setRaw("visibility", opts.visibility ?? "private");
|
|
16368
|
+
record._setRaw(
|
|
16369
|
+
"published_at",
|
|
16370
|
+
opts.visibility && opts.visibility !== "private" ? opts.publishedAt ?? Date.now() : null
|
|
16371
|
+
);
|
|
16372
|
+
if (opts.geohash !== void 0) {
|
|
16373
|
+
record._setRaw("geohash", opts.geohash);
|
|
16374
|
+
}
|
|
16350
16375
|
});
|
|
16351
16376
|
});
|
|
16352
16377
|
return vaultMemoryToStored(created, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
|
|
@@ -16493,6 +16518,14 @@ async function createVaultMemoriesBatchOp(ctx, optionsArray) {
|
|
|
16493
16518
|
if (opts.trustTier !== void 0) {
|
|
16494
16519
|
record._setRaw("trust_tier", normalizeTrustTier(opts.trustTier));
|
|
16495
16520
|
}
|
|
16521
|
+
record._setRaw("visibility", opts.visibility ?? "private");
|
|
16522
|
+
record._setRaw(
|
|
16523
|
+
"published_at",
|
|
16524
|
+
opts.visibility && opts.visibility !== "private" ? opts.publishedAt ?? Date.now() : null
|
|
16525
|
+
);
|
|
16526
|
+
if (opts.geohash !== void 0) {
|
|
16527
|
+
record._setRaw("geohash", opts.geohash);
|
|
16528
|
+
}
|
|
16496
16529
|
})
|
|
16497
16530
|
);
|
|
16498
16531
|
await ctx.database.batch(...prepared);
|
|
@@ -16556,6 +16589,10 @@ function vaultMemoryRawToStoredRaw(raw) {
|
|
|
16556
16589
|
factType: raw.fact_type ?? null,
|
|
16557
16590
|
archivedAt: raw.archived_at ?? null,
|
|
16558
16591
|
trustTier: raw.trust_tier ?? null,
|
|
16592
|
+
visibility: visibilityOrPrivate(raw.visibility),
|
|
16593
|
+
twinOptIn: raw.twin_opt_in === true || raw.twin_opt_in === 1,
|
|
16594
|
+
publishedAt: raw.published_at ?? null,
|
|
16595
|
+
geohash: raw.geohash ?? null,
|
|
16559
16596
|
createdAt: new Date(raw.created_at),
|
|
16560
16597
|
updatedAt: new Date(raw.updated_at),
|
|
16561
16598
|
isDeleted: raw.is_deleted === true || raw.is_deleted === 1
|
|
@@ -16572,6 +16609,7 @@ async function getAllVaultMemoriesOp(ctx, options) {
|
|
|
16572
16609
|
const conditions = [
|
|
16573
16610
|
...baseVaultConditions(ctx, options),
|
|
16574
16611
|
...options?.scopes?.length ? [import_watermelondb3.Q.where("scope", import_watermelondb3.Q.oneOf(options.scopes))] : [],
|
|
16612
|
+
...visibilityConditions(options?.visibility),
|
|
16575
16613
|
...options?.folderId !== void 0 ? [import_watermelondb3.Q.where("folder_id", options.folderId)] : [],
|
|
16576
16614
|
...options?.factTypes?.length ? [import_watermelondb3.Q.where("fact_type", import_watermelondb3.Q.oneOf(options.factTypes))] : [],
|
|
16577
16615
|
import_watermelondb3.Q.sortBy(options?.since ? "updated_at" : "created_at", import_watermelondb3.Q.desc),
|
|
@@ -16785,6 +16823,38 @@ async function updateVaultMemoryOp(ctx, id, opts) {
|
|
|
16785
16823
|
return null;
|
|
16786
16824
|
}
|
|
16787
16825
|
}
|
|
16826
|
+
async function setMemoryVisibilityOp(ctx, id, opts) {
|
|
16827
|
+
let record;
|
|
16828
|
+
try {
|
|
16829
|
+
record = await ctx.vaultMemoryCollection.find(id);
|
|
16830
|
+
} catch {
|
|
16831
|
+
return null;
|
|
16832
|
+
}
|
|
16833
|
+
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) return null;
|
|
16834
|
+
let stale = false;
|
|
16835
|
+
await ctx.database.write(async () => {
|
|
16836
|
+
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) {
|
|
16837
|
+
stale = true;
|
|
16838
|
+
return;
|
|
16839
|
+
}
|
|
16840
|
+
const currentUpdatedAt = record.updatedAt.getTime();
|
|
16841
|
+
const currentPublishedAt = record.publishedAt ?? null;
|
|
16842
|
+
await record.update((r) => {
|
|
16843
|
+
r._setRaw("visibility", opts.visibility);
|
|
16844
|
+
if (opts.visibility === "private") {
|
|
16845
|
+
r._setRaw("published_at", null);
|
|
16846
|
+
} else if (currentPublishedAt === null) {
|
|
16847
|
+
r._setRaw("published_at", Date.now());
|
|
16848
|
+
}
|
|
16849
|
+
if (opts.twinOptIn !== void 0) {
|
|
16850
|
+
r._setRaw("twin_opt_in", opts.twinOptIn);
|
|
16851
|
+
}
|
|
16852
|
+
r._setRaw("updated_at", currentUpdatedAt);
|
|
16853
|
+
});
|
|
16854
|
+
});
|
|
16855
|
+
if (stale) return null;
|
|
16856
|
+
return vaultMemoryToStored(record, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
|
|
16857
|
+
}
|
|
16788
16858
|
async function deleteVaultMemoryOp(ctx, id) {
|
|
16789
16859
|
try {
|
|
16790
16860
|
const record = await ctx.vaultMemoryCollection.find(id);
|
|
@@ -19849,7 +19919,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
19849
19919
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
19850
19920
|
);
|
|
19851
19921
|
}
|
|
19852
|
-
const { recall: recall2 } = await import("./recall-
|
|
19922
|
+
const { recall: recall2 } = await import("./recall-AN7HBEFS.mjs");
|
|
19853
19923
|
const result = await recall2(
|
|
19854
19924
|
query,
|
|
19855
19925
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
|
@@ -20835,6 +20905,7 @@ export {
|
|
|
20835
20905
|
getAllVaultMemoriesOp,
|
|
20836
20906
|
getAllVaultMemoryContentsOp,
|
|
20837
20907
|
updateVaultMemoryOp,
|
|
20908
|
+
setMemoryVisibilityOp,
|
|
20838
20909
|
deleteVaultMemoryOp,
|
|
20839
20910
|
supersedeVaultMemoryOp,
|
|
20840
20911
|
getUnfiledVaultMemoriesOp,
|
|
@@ -183,6 +183,7 @@ async function attemptPortalJson(req, endpoint) {
|
|
|
183
183
|
return { kind: "retryable", reason: `response body parse failed: ${err.message}` };
|
|
184
184
|
}
|
|
185
185
|
clearTimeout(timer);
|
|
186
|
+
logPortalUsage(body, req.tag);
|
|
186
187
|
const rawContent = extractCompletionContent(body);
|
|
187
188
|
if (!rawContent) {
|
|
188
189
|
return { kind: "retryable", reason: "portal response had no completion content" };
|
|
@@ -238,6 +239,29 @@ function extractJsonCandidate(raw) {
|
|
|
238
239
|
}
|
|
239
240
|
return body;
|
|
240
241
|
}
|
|
242
|
+
function asRecord(value) {
|
|
243
|
+
return typeof value === "object" && value !== null ? value : void 0;
|
|
244
|
+
}
|
|
245
|
+
function asCount(value) {
|
|
246
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
247
|
+
}
|
|
248
|
+
function logPortalUsage(body, tag) {
|
|
249
|
+
try {
|
|
250
|
+
const root = asRecord(body);
|
|
251
|
+
if (!root) return;
|
|
252
|
+
const usage = asRecord(root.usage);
|
|
253
|
+
const promptTokens = asCount(usage?.prompt_tokens);
|
|
254
|
+
const completionTokens = asCount(usage?.completion_tokens);
|
|
255
|
+
if (promptTokens === void 0 && completionTokens === void 0) return;
|
|
256
|
+
const cachedTokens = asCount(asRecord(root.portal)?.cached_tokens) ?? asCount(asRecord(usage?.prompt_tokens_details)?.cached_tokens) ?? 0;
|
|
257
|
+
const parts = [];
|
|
258
|
+
if (promptTokens !== void 0) parts.push(`prompt=${promptTokens}`);
|
|
259
|
+
if (completionTokens !== void 0) parts.push(`completion=${completionTokens}`);
|
|
260
|
+
parts.push(`cached=${cachedTokens}`);
|
|
261
|
+
getLogger().debug(`[${tag}] usage ${parts.join(" ")}`);
|
|
262
|
+
} catch {
|
|
263
|
+
}
|
|
264
|
+
}
|
|
241
265
|
function extractCompletionContent(body) {
|
|
242
266
|
if (typeof body !== "object" || body === null) return null;
|
|
243
267
|
const choices = body.choices;
|
package/dist/server/index.cjs
CHANGED
|
@@ -17046,6 +17046,18 @@ var init_encryption2 = __esm({
|
|
|
17046
17046
|
});
|
|
17047
17047
|
|
|
17048
17048
|
// src/lib/db/memoryVault/operations.ts
|
|
17049
|
+
function visibilityOrPrivate(value) {
|
|
17050
|
+
return value === "public" ? value : "private";
|
|
17051
|
+
}
|
|
17052
|
+
function visibilityConditions(requested) {
|
|
17053
|
+
if (!requested?.length) return [];
|
|
17054
|
+
if (!requested.includes("private")) {
|
|
17055
|
+
return [import_watermelondb17.Q.where("visibility", import_watermelondb17.Q.oneOf([...requested]))];
|
|
17056
|
+
}
|
|
17057
|
+
const excluded = NON_PRIVATE_VISIBILITIES.filter((v) => !requested.includes(v));
|
|
17058
|
+
if (excluded.length === 0) return [];
|
|
17059
|
+
return [import_watermelondb17.Q.or(import_watermelondb17.Q.where("visibility", null), import_watermelondb17.Q.where("visibility", import_watermelondb17.Q.notIn(excluded)))];
|
|
17060
|
+
}
|
|
17049
17061
|
function isOwnedByCtxUser(ctx, record) {
|
|
17050
17062
|
return ctx.userId === void 0 || record.userId === ctx.userId;
|
|
17051
17063
|
}
|
|
@@ -17106,6 +17118,10 @@ function vaultMemoryToStoredRaw(memory) {
|
|
|
17106
17118
|
factType: memory.factType ?? null,
|
|
17107
17119
|
archivedAt: memory.archivedAt ?? null,
|
|
17108
17120
|
trustTier: memory.trustTier ?? null,
|
|
17121
|
+
visibility: visibilityOrPrivate(memory.visibility),
|
|
17122
|
+
twinOptIn: memory.twinOptIn ?? false,
|
|
17123
|
+
publishedAt: memory.publishedAt ?? null,
|
|
17124
|
+
geohash: memory.geohash ?? null,
|
|
17109
17125
|
createdAt: memory.createdAt,
|
|
17110
17126
|
updatedAt: memory.updatedAt,
|
|
17111
17127
|
isDeleted: memory.isDeleted
|
|
@@ -17153,6 +17169,14 @@ async function createVaultMemoryOp(ctx, opts) {
|
|
|
17153
17169
|
if (opts.trustTier !== void 0) {
|
|
17154
17170
|
record._setRaw("trust_tier", normalizeTrustTier(opts.trustTier));
|
|
17155
17171
|
}
|
|
17172
|
+
record._setRaw("visibility", opts.visibility ?? "private");
|
|
17173
|
+
record._setRaw(
|
|
17174
|
+
"published_at",
|
|
17175
|
+
opts.visibility && opts.visibility !== "private" ? opts.publishedAt ?? Date.now() : null
|
|
17176
|
+
);
|
|
17177
|
+
if (opts.geohash !== void 0) {
|
|
17178
|
+
record._setRaw("geohash", opts.geohash);
|
|
17179
|
+
}
|
|
17156
17180
|
});
|
|
17157
17181
|
});
|
|
17158
17182
|
return vaultMemoryToStored(created, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
|
|
@@ -17299,6 +17323,14 @@ async function createVaultMemoriesBatchOp(ctx, optionsArray) {
|
|
|
17299
17323
|
if (opts.trustTier !== void 0) {
|
|
17300
17324
|
record._setRaw("trust_tier", normalizeTrustTier(opts.trustTier));
|
|
17301
17325
|
}
|
|
17326
|
+
record._setRaw("visibility", opts.visibility ?? "private");
|
|
17327
|
+
record._setRaw(
|
|
17328
|
+
"published_at",
|
|
17329
|
+
opts.visibility && opts.visibility !== "private" ? opts.publishedAt ?? Date.now() : null
|
|
17330
|
+
);
|
|
17331
|
+
if (opts.geohash !== void 0) {
|
|
17332
|
+
record._setRaw("geohash", opts.geohash);
|
|
17333
|
+
}
|
|
17302
17334
|
})
|
|
17303
17335
|
);
|
|
17304
17336
|
await ctx.database.batch(...prepared);
|
|
@@ -17362,6 +17394,10 @@ function vaultMemoryRawToStoredRaw(raw) {
|
|
|
17362
17394
|
factType: raw.fact_type ?? null,
|
|
17363
17395
|
archivedAt: raw.archived_at ?? null,
|
|
17364
17396
|
trustTier: raw.trust_tier ?? null,
|
|
17397
|
+
visibility: visibilityOrPrivate(raw.visibility),
|
|
17398
|
+
twinOptIn: raw.twin_opt_in === true || raw.twin_opt_in === 1,
|
|
17399
|
+
publishedAt: raw.published_at ?? null,
|
|
17400
|
+
geohash: raw.geohash ?? null,
|
|
17365
17401
|
createdAt: new Date(raw.created_at),
|
|
17366
17402
|
updatedAt: new Date(raw.updated_at),
|
|
17367
17403
|
isDeleted: raw.is_deleted === true || raw.is_deleted === 1
|
|
@@ -17378,6 +17414,7 @@ async function getAllVaultMemoriesOp(ctx, options) {
|
|
|
17378
17414
|
const conditions = [
|
|
17379
17415
|
...baseVaultConditions(ctx, options),
|
|
17380
17416
|
...options?.scopes?.length ? [import_watermelondb17.Q.where("scope", import_watermelondb17.Q.oneOf(options.scopes))] : [],
|
|
17417
|
+
...visibilityConditions(options?.visibility),
|
|
17381
17418
|
...options?.folderId !== void 0 ? [import_watermelondb17.Q.where("folder_id", options.folderId)] : [],
|
|
17382
17419
|
...options?.factTypes?.length ? [import_watermelondb17.Q.where("fact_type", import_watermelondb17.Q.oneOf(options.factTypes))] : [],
|
|
17383
17420
|
import_watermelondb17.Q.sortBy(options?.since ? "updated_at" : "created_at", import_watermelondb17.Q.desc),
|
|
@@ -17591,6 +17628,38 @@ async function updateVaultMemoryOp(ctx, id, opts) {
|
|
|
17591
17628
|
return null;
|
|
17592
17629
|
}
|
|
17593
17630
|
}
|
|
17631
|
+
async function setMemoryVisibilityOp(ctx, id, opts) {
|
|
17632
|
+
let record;
|
|
17633
|
+
try {
|
|
17634
|
+
record = await ctx.vaultMemoryCollection.find(id);
|
|
17635
|
+
} catch {
|
|
17636
|
+
return null;
|
|
17637
|
+
}
|
|
17638
|
+
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) return null;
|
|
17639
|
+
let stale = false;
|
|
17640
|
+
await ctx.database.write(async () => {
|
|
17641
|
+
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) {
|
|
17642
|
+
stale = true;
|
|
17643
|
+
return;
|
|
17644
|
+
}
|
|
17645
|
+
const currentUpdatedAt = record.updatedAt.getTime();
|
|
17646
|
+
const currentPublishedAt = record.publishedAt ?? null;
|
|
17647
|
+
await record.update((r) => {
|
|
17648
|
+
r._setRaw("visibility", opts.visibility);
|
|
17649
|
+
if (opts.visibility === "private") {
|
|
17650
|
+
r._setRaw("published_at", null);
|
|
17651
|
+
} else if (currentPublishedAt === null) {
|
|
17652
|
+
r._setRaw("published_at", Date.now());
|
|
17653
|
+
}
|
|
17654
|
+
if (opts.twinOptIn !== void 0) {
|
|
17655
|
+
r._setRaw("twin_opt_in", opts.twinOptIn);
|
|
17656
|
+
}
|
|
17657
|
+
r._setRaw("updated_at", currentUpdatedAt);
|
|
17658
|
+
});
|
|
17659
|
+
});
|
|
17660
|
+
if (stale) return null;
|
|
17661
|
+
return vaultMemoryToStored(record, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
|
|
17662
|
+
}
|
|
17594
17663
|
async function deleteVaultMemoryOp(ctx, id) {
|
|
17595
17664
|
try {
|
|
17596
17665
|
const record = await ctx.vaultMemoryCollection.find(id);
|
|
@@ -17880,7 +17949,7 @@ async function updateVaultMemoryEmbeddingOp(ctx, id, embedding, embeddingModel)
|
|
|
17880
17949
|
return false;
|
|
17881
17950
|
}
|
|
17882
17951
|
}
|
|
17883
|
-
var import_watermelondb17, KNOWN_TRUST_TIERS, TOPICS_EXTRACTION_VERSION;
|
|
17952
|
+
var import_watermelondb17, NON_PRIVATE_VISIBILITIES, KNOWN_TRUST_TIERS, TOPICS_EXTRACTION_VERSION;
|
|
17884
17953
|
var init_operations3 = __esm({
|
|
17885
17954
|
"src/lib/db/memoryVault/operations.ts"() {
|
|
17886
17955
|
"use strict";
|
|
@@ -17888,6 +17957,7 @@ var init_operations3 = __esm({
|
|
|
17888
17957
|
init_logger();
|
|
17889
17958
|
init_operations2();
|
|
17890
17959
|
init_encryption2();
|
|
17960
|
+
NON_PRIVATE_VISIBILITIES = ["public"];
|
|
17891
17961
|
KNOWN_TRUST_TIERS = /* @__PURE__ */ new Set(["quarantined", "trusted"]);
|
|
17892
17962
|
TOPICS_EXTRACTION_VERSION = 3;
|
|
17893
17963
|
}
|
|
@@ -19851,6 +19921,7 @@ async function attemptPortalJson(req, endpoint) {
|
|
|
19851
19921
|
return { kind: "retryable", reason: `response body parse failed: ${err.message}` };
|
|
19852
19922
|
}
|
|
19853
19923
|
clearTimeout(timer);
|
|
19924
|
+
logPortalUsage(body, req.tag);
|
|
19854
19925
|
const rawContent = extractCompletionContent(body);
|
|
19855
19926
|
if (!rawContent) {
|
|
19856
19927
|
return { kind: "retryable", reason: "portal response had no completion content" };
|
|
@@ -19906,6 +19977,29 @@ function extractJsonCandidate(raw) {
|
|
|
19906
19977
|
}
|
|
19907
19978
|
return body;
|
|
19908
19979
|
}
|
|
19980
|
+
function asRecord(value) {
|
|
19981
|
+
return typeof value === "object" && value !== null ? value : void 0;
|
|
19982
|
+
}
|
|
19983
|
+
function asCount(value) {
|
|
19984
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
19985
|
+
}
|
|
19986
|
+
function logPortalUsage(body, tag) {
|
|
19987
|
+
try {
|
|
19988
|
+
const root = asRecord(body);
|
|
19989
|
+
if (!root) return;
|
|
19990
|
+
const usage = asRecord(root.usage);
|
|
19991
|
+
const promptTokens = asCount(usage?.prompt_tokens);
|
|
19992
|
+
const completionTokens = asCount(usage?.completion_tokens);
|
|
19993
|
+
if (promptTokens === void 0 && completionTokens === void 0) return;
|
|
19994
|
+
const cachedTokens = asCount(asRecord(root.portal)?.cached_tokens) ?? asCount(asRecord(usage?.prompt_tokens_details)?.cached_tokens) ?? 0;
|
|
19995
|
+
const parts = [];
|
|
19996
|
+
if (promptTokens !== void 0) parts.push(`prompt=${promptTokens}`);
|
|
19997
|
+
if (completionTokens !== void 0) parts.push(`completion=${completionTokens}`);
|
|
19998
|
+
parts.push(`cached=${cachedTokens}`);
|
|
19999
|
+
getLogger().debug(`[${tag}] usage ${parts.join(" ")}`);
|
|
20000
|
+
} catch {
|
|
20001
|
+
}
|
|
20002
|
+
}
|
|
19909
20003
|
function extractCompletionContent(body) {
|
|
19910
20004
|
if (typeof body !== "object" || body === null) return null;
|
|
19911
20005
|
const choices = body.choices;
|
|
@@ -23114,6 +23208,7 @@ __export(index_exports, {
|
|
|
23114
23208
|
searchVaultMemories: () => searchVaultMemories,
|
|
23115
23209
|
selectServerToolsForPrompt: () => selectServerToolsForPrompt,
|
|
23116
23210
|
serverPlatformStorage: () => serverPlatformStorage,
|
|
23211
|
+
setMemoryVisibilityOp: () => setMemoryVisibilityOp,
|
|
23117
23212
|
setModelPreferenceOp: () => setModelPreferenceOp,
|
|
23118
23213
|
setUserPreferenceOp: () => setUserPreferenceOp,
|
|
23119
23214
|
shouldAnalyzeStyle: () => shouldAnalyzeStyle,
|
|
@@ -23504,6 +23599,18 @@ __decorateClass([
|
|
|
23504
23599
|
__decorateClass([
|
|
23505
23600
|
(0, import_decorators6.field)("trust_tier")
|
|
23506
23601
|
], VaultMemory.prototype, "trustTier", 2);
|
|
23602
|
+
__decorateClass([
|
|
23603
|
+
(0, import_decorators6.field)("visibility")
|
|
23604
|
+
], VaultMemory.prototype, "visibility", 2);
|
|
23605
|
+
__decorateClass([
|
|
23606
|
+
(0, import_decorators6.field)("twin_opt_in")
|
|
23607
|
+
], VaultMemory.prototype, "twinOptIn", 2);
|
|
23608
|
+
__decorateClass([
|
|
23609
|
+
(0, import_decorators6.field)("published_at")
|
|
23610
|
+
], VaultMemory.prototype, "publishedAt", 2);
|
|
23611
|
+
__decorateClass([
|
|
23612
|
+
(0, import_decorators6.field)("geohash")
|
|
23613
|
+
], VaultMemory.prototype, "geohash", 2);
|
|
23507
23614
|
__decorateClass([
|
|
23508
23615
|
import_decorators6.readonly,
|
|
23509
23616
|
(0, import_decorators6.date)("created_at")
|
|
@@ -23651,7 +23758,7 @@ __decorateClass([
|
|
|
23651
23758
|
], VaultFolder.prototype, "context", 2);
|
|
23652
23759
|
|
|
23653
23760
|
// src/lib/db/schema.ts
|
|
23654
|
-
var SDK_SCHEMA_VERSION =
|
|
23761
|
+
var SDK_SCHEMA_VERSION = 41;
|
|
23655
23762
|
var sdkSchema = (0, import_watermelondb12.appSchema)({
|
|
23656
23763
|
version: SDK_SCHEMA_VERSION,
|
|
23657
23764
|
tables: [
|
|
@@ -23810,7 +23917,26 @@ var sdkSchema = (0, import_watermelondb12.appSchema)({
|
|
|
23810
23917
|
// Tier-0 security (PR3) — "quarantined" when the write-time injection
|
|
23811
23918
|
// screen flagged this fact, else null/"trusted". Indexed so the recall
|
|
23812
23919
|
// choke point can default-exclude quarantined rows.
|
|
23813
|
-
{ name: "trust_tier", type: "string", isOptional: true, isIndexed: true }
|
|
23920
|
+
{ name: "trust_tier", type: "string", isOptional: true, isIndexed: true },
|
|
23921
|
+
// People Nearby cross-user visibility axis — ORTHOGONAL to `scope`
|
|
23922
|
+
// (which partitions by MODEL access: private vs shared providers).
|
|
23923
|
+
// TWO tiers: 'private' (or null, or any unrecognised value —
|
|
23924
|
+
// grandfathered / fail-safe) = local-only; 'public' = embedding +
|
|
23925
|
+
// plaintext may be published (matching/profile/discovery/twin).
|
|
23926
|
+
// The server index is the authority for what IS published; this
|
|
23927
|
+
// column records the user's intent.
|
|
23928
|
+
{ name: "visibility", type: "string", isOptional: true, isIndexed: true },
|
|
23929
|
+
// When true, the owner opted this memory into their own digital twin
|
|
23930
|
+
// even if it is otherwise private (twin-scoped upload only — never
|
|
23931
|
+
// indexed for matching, never displayed). Null/false = follows visibility.
|
|
23932
|
+
{ name: "twin_opt_in", type: "boolean", isOptional: true },
|
|
23933
|
+
// Unix ms when visibility last became non-private. Null when private
|
|
23934
|
+
// (cleared on revoke) — the publish reconciler uses it to diff local
|
|
23935
|
+
// intent against the server index.
|
|
23936
|
+
{ name: "published_at", type: "number", isOptional: true },
|
|
23937
|
+
// Reserved geo slot (coarse geohash) for landmark/Trail memories.
|
|
23938
|
+
// Unused at launch; populated by location-tagged memory sources.
|
|
23939
|
+
{ name: "geohash", type: "string", isOptional: true }
|
|
23814
23940
|
]
|
|
23815
23941
|
}),
|
|
23816
23942
|
// Entity table — canonical names extracted from auto-extraction (W5).
|
|
@@ -24485,6 +24611,24 @@ var sdkMigrations = (0, import_migrations.schemaMigrations)({
|
|
|
24485
24611
|
]
|
|
24486
24612
|
})
|
|
24487
24613
|
]
|
|
24614
|
+
},
|
|
24615
|
+
// v40 -> v41: People Nearby visibility axis on memory_vault. Existing rows
|
|
24616
|
+
// keep visibility NULL — read as 'private' (nothing pre-existing is ever
|
|
24617
|
+
// published without an explicit user action; the consent posture requires
|
|
24618
|
+
// opt-in, never a retroactive default).
|
|
24619
|
+
{
|
|
24620
|
+
toVersion: 41,
|
|
24621
|
+
steps: [
|
|
24622
|
+
(0, import_migrations.addColumns)({
|
|
24623
|
+
table: "memory_vault",
|
|
24624
|
+
columns: [
|
|
24625
|
+
{ name: "visibility", type: "string", isOptional: true, isIndexed: true },
|
|
24626
|
+
{ name: "twin_opt_in", type: "boolean", isOptional: true },
|
|
24627
|
+
{ name: "published_at", type: "number", isOptional: true },
|
|
24628
|
+
{ name: "geohash", type: "string", isOptional: true }
|
|
24629
|
+
]
|
|
24630
|
+
})
|
|
24631
|
+
]
|
|
24488
24632
|
}
|
|
24489
24633
|
]
|
|
24490
24634
|
});
|
|
@@ -28480,18 +28624,16 @@ function createAutoExtractor(options) {
|
|
|
28480
28624
|
} catch {
|
|
28481
28625
|
}
|
|
28482
28626
|
};
|
|
28483
|
-
const
|
|
28484
|
-
|
|
28485
|
-
|
|
28486
|
-
|
|
28487
|
-
|
|
28488
|
-
|
|
28489
|
-
|
|
28490
|
-
|
|
28491
|
-
|
|
28492
|
-
|
|
28493
|
-
// extractAndRetain (so direct callers are covered too), not copied here.
|
|
28494
|
-
} : void 0;
|
|
28627
|
+
const subPassAuth = (baseUrlOverride) => {
|
|
28628
|
+
const baseUrl = baseUrlOverride ?? options.extract.baseUrl;
|
|
28629
|
+
return {
|
|
28630
|
+
...options.extract.apiKey !== void 0 && { apiKey: options.extract.apiKey },
|
|
28631
|
+
...options.extract.getToken !== void 0 && { getToken: options.extract.getToken },
|
|
28632
|
+
...baseUrl !== void 0 && { baseUrl }
|
|
28633
|
+
};
|
|
28634
|
+
};
|
|
28635
|
+
const consolidateOptions = options.consolidate ? { ...options.consolidate, ...subPassAuth(options.consolidate.baseUrl) } : void 0;
|
|
28636
|
+
const injectionClassifierOptions = options.injectionClassifier ? { ...options.injectionClassifier, ...subPassAuth(options.injectionClassifier.baseUrl) } : void 0;
|
|
28495
28637
|
if (options.retainCtx.vaultCtx.entityCtx && !options.entityCtx) {
|
|
28496
28638
|
getLogger().warn(
|
|
28497
28639
|
"[memory/extract] retainCtx.vaultCtx.entityCtx is set but extractor was created without `entityCtx` \u2014 W5 graph lane will receive no writes"
|
|
@@ -28545,6 +28687,9 @@ function createAutoExtractor(options) {
|
|
|
28545
28687
|
...options.scope !== void 0 && { scope: options.scope },
|
|
28546
28688
|
...options.folderId !== void 0 && { folderId: options.folderId },
|
|
28547
28689
|
...consolidateOptions !== void 0 && { consolidateOptions },
|
|
28690
|
+
...injectionClassifierOptions !== void 0 && {
|
|
28691
|
+
injectionClassifier: injectionClassifierOptions
|
|
28692
|
+
},
|
|
28548
28693
|
...options.onCandidateFailed && {
|
|
28549
28694
|
onCandidateFailed: (candidate, error) => options.onCandidateFailed?.({ candidate, error, conversationId })
|
|
28550
28695
|
},
|
|
@@ -35680,6 +35825,7 @@ function buildSystemPrompt(ctx, options) {
|
|
|
35680
35825
|
searchVaultMemories,
|
|
35681
35826
|
selectServerToolsForPrompt,
|
|
35682
35827
|
serverPlatformStorage,
|
|
35828
|
+
setMemoryVisibilityOp,
|
|
35683
35829
|
setModelPreferenceOp,
|
|
35684
35830
|
setUserPreferenceOp,
|
|
35685
35831
|
shouldAnalyzeStyle,
|