@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-ILAWDQDE.mjs";
|
|
5
5
|
import {
|
|
6
6
|
BASE_URL,
|
|
7
7
|
createClientConfig
|
|
@@ -2037,6 +2037,19 @@ async function decryptVaultMemoryFields(memory, address, signMessage, embeddedWa
|
|
|
2037
2037
|
}
|
|
2038
2038
|
|
|
2039
2039
|
// src/lib/db/memoryVault/operations.ts
|
|
2040
|
+
function visibilityOrPrivate(value) {
|
|
2041
|
+
return value === "public" ? value : "private";
|
|
2042
|
+
}
|
|
2043
|
+
var NON_PRIVATE_VISIBILITIES = ["public"];
|
|
2044
|
+
function visibilityConditions(requested) {
|
|
2045
|
+
if (!requested?.length) return [];
|
|
2046
|
+
if (!requested.includes("private")) {
|
|
2047
|
+
return [Q3.where("visibility", Q3.oneOf([...requested]))];
|
|
2048
|
+
}
|
|
2049
|
+
const excluded = NON_PRIVATE_VISIBILITIES.filter((v) => !requested.includes(v));
|
|
2050
|
+
if (excluded.length === 0) return [];
|
|
2051
|
+
return [Q3.or(Q3.where("visibility", null), Q3.where("visibility", Q3.notIn(excluded)))];
|
|
2052
|
+
}
|
|
2040
2053
|
function isOwnedByCtxUser(ctx, record) {
|
|
2041
2054
|
return ctx.userId === void 0 || record.userId === ctx.userId;
|
|
2042
2055
|
}
|
|
@@ -2098,6 +2111,10 @@ function vaultMemoryToStoredRaw(memory) {
|
|
|
2098
2111
|
factType: memory.factType ?? null,
|
|
2099
2112
|
archivedAt: memory.archivedAt ?? null,
|
|
2100
2113
|
trustTier: memory.trustTier ?? null,
|
|
2114
|
+
visibility: visibilityOrPrivate(memory.visibility),
|
|
2115
|
+
twinOptIn: memory.twinOptIn ?? false,
|
|
2116
|
+
publishedAt: memory.publishedAt ?? null,
|
|
2117
|
+
geohash: memory.geohash ?? null,
|
|
2101
2118
|
createdAt: memory.createdAt,
|
|
2102
2119
|
updatedAt: memory.updatedAt,
|
|
2103
2120
|
isDeleted: memory.isDeleted
|
|
@@ -2145,6 +2162,14 @@ async function createVaultMemoryOp(ctx, opts) {
|
|
|
2145
2162
|
if (opts.trustTier !== void 0) {
|
|
2146
2163
|
record._setRaw("trust_tier", normalizeTrustTier(opts.trustTier));
|
|
2147
2164
|
}
|
|
2165
|
+
record._setRaw("visibility", opts.visibility ?? "private");
|
|
2166
|
+
record._setRaw(
|
|
2167
|
+
"published_at",
|
|
2168
|
+
opts.visibility && opts.visibility !== "private" ? opts.publishedAt ?? Date.now() : null
|
|
2169
|
+
);
|
|
2170
|
+
if (opts.geohash !== void 0) {
|
|
2171
|
+
record._setRaw("geohash", opts.geohash);
|
|
2172
|
+
}
|
|
2148
2173
|
});
|
|
2149
2174
|
});
|
|
2150
2175
|
return vaultMemoryToStored(created, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
|
|
@@ -2291,6 +2316,14 @@ async function createVaultMemoriesBatchOp(ctx, optionsArray) {
|
|
|
2291
2316
|
if (opts.trustTier !== void 0) {
|
|
2292
2317
|
record._setRaw("trust_tier", normalizeTrustTier(opts.trustTier));
|
|
2293
2318
|
}
|
|
2319
|
+
record._setRaw("visibility", opts.visibility ?? "private");
|
|
2320
|
+
record._setRaw(
|
|
2321
|
+
"published_at",
|
|
2322
|
+
opts.visibility && opts.visibility !== "private" ? opts.publishedAt ?? Date.now() : null
|
|
2323
|
+
);
|
|
2324
|
+
if (opts.geohash !== void 0) {
|
|
2325
|
+
record._setRaw("geohash", opts.geohash);
|
|
2326
|
+
}
|
|
2294
2327
|
})
|
|
2295
2328
|
);
|
|
2296
2329
|
await ctx.database.batch(...prepared);
|
|
@@ -2354,6 +2387,10 @@ function vaultMemoryRawToStoredRaw(raw) {
|
|
|
2354
2387
|
factType: raw.fact_type ?? null,
|
|
2355
2388
|
archivedAt: raw.archived_at ?? null,
|
|
2356
2389
|
trustTier: raw.trust_tier ?? null,
|
|
2390
|
+
visibility: visibilityOrPrivate(raw.visibility),
|
|
2391
|
+
twinOptIn: raw.twin_opt_in === true || raw.twin_opt_in === 1,
|
|
2392
|
+
publishedAt: raw.published_at ?? null,
|
|
2393
|
+
geohash: raw.geohash ?? null,
|
|
2357
2394
|
createdAt: new Date(raw.created_at),
|
|
2358
2395
|
updatedAt: new Date(raw.updated_at),
|
|
2359
2396
|
isDeleted: raw.is_deleted === true || raw.is_deleted === 1
|
|
@@ -2370,6 +2407,7 @@ async function getAllVaultMemoriesOp(ctx, options) {
|
|
|
2370
2407
|
const conditions = [
|
|
2371
2408
|
...baseVaultConditions(ctx, options),
|
|
2372
2409
|
...options?.scopes?.length ? [Q3.where("scope", Q3.oneOf(options.scopes))] : [],
|
|
2410
|
+
...visibilityConditions(options?.visibility),
|
|
2373
2411
|
...options?.folderId !== void 0 ? [Q3.where("folder_id", options.folderId)] : [],
|
|
2374
2412
|
...options?.factTypes?.length ? [Q3.where("fact_type", Q3.oneOf(options.factTypes))] : [],
|
|
2375
2413
|
Q3.sortBy(options?.since ? "updated_at" : "created_at", Q3.desc),
|
|
@@ -2583,6 +2621,38 @@ async function updateVaultMemoryOp(ctx, id, opts) {
|
|
|
2583
2621
|
return null;
|
|
2584
2622
|
}
|
|
2585
2623
|
}
|
|
2624
|
+
async function setMemoryVisibilityOp(ctx, id, opts) {
|
|
2625
|
+
let record;
|
|
2626
|
+
try {
|
|
2627
|
+
record = await ctx.vaultMemoryCollection.find(id);
|
|
2628
|
+
} catch {
|
|
2629
|
+
return null;
|
|
2630
|
+
}
|
|
2631
|
+
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) return null;
|
|
2632
|
+
let stale = false;
|
|
2633
|
+
await ctx.database.write(async () => {
|
|
2634
|
+
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) {
|
|
2635
|
+
stale = true;
|
|
2636
|
+
return;
|
|
2637
|
+
}
|
|
2638
|
+
const currentUpdatedAt = record.updatedAt.getTime();
|
|
2639
|
+
const currentPublishedAt = record.publishedAt ?? null;
|
|
2640
|
+
await record.update((r) => {
|
|
2641
|
+
r._setRaw("visibility", opts.visibility);
|
|
2642
|
+
if (opts.visibility === "private") {
|
|
2643
|
+
r._setRaw("published_at", null);
|
|
2644
|
+
} else if (currentPublishedAt === null) {
|
|
2645
|
+
r._setRaw("published_at", Date.now());
|
|
2646
|
+
}
|
|
2647
|
+
if (opts.twinOptIn !== void 0) {
|
|
2648
|
+
r._setRaw("twin_opt_in", opts.twinOptIn);
|
|
2649
|
+
}
|
|
2650
|
+
r._setRaw("updated_at", currentUpdatedAt);
|
|
2651
|
+
});
|
|
2652
|
+
});
|
|
2653
|
+
if (stale) return null;
|
|
2654
|
+
return vaultMemoryToStored(record, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
|
|
2655
|
+
}
|
|
2586
2656
|
async function deleteVaultMemoryOp(ctx, id) {
|
|
2587
2657
|
try {
|
|
2588
2658
|
const record = await ctx.vaultMemoryCollection.find(id);
|
|
@@ -5658,7 +5728,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
5658
5728
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
5659
5729
|
);
|
|
5660
5730
|
}
|
|
5661
|
-
const { recall: recall2 } = await import("./recall-
|
|
5731
|
+
const { recall: recall2 } = await import("./recall-IBGUFY4P.mjs");
|
|
5662
5732
|
const result = await recall2(
|
|
5663
5733
|
query,
|
|
5664
5734
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
|
@@ -6640,6 +6710,7 @@ export {
|
|
|
6640
6710
|
getAllVaultMemoriesOp,
|
|
6641
6711
|
getAllVaultMemoryContentsOp,
|
|
6642
6712
|
updateVaultMemoryOp,
|
|
6713
|
+
setMemoryVisibilityOp,
|
|
6643
6714
|
deleteVaultMemoryOp,
|
|
6644
6715
|
supersedeVaultMemoryOp,
|
|
6645
6716
|
getUnfiledVaultMemoriesOp,
|
|
@@ -196,6 +196,7 @@ async function attemptPortalJson(req, endpoint) {
|
|
|
196
196
|
return { kind: "retryable", reason: `response body parse failed: ${err.message}` };
|
|
197
197
|
}
|
|
198
198
|
clearTimeout(timer);
|
|
199
|
+
logPortalUsage(body, req.tag);
|
|
199
200
|
const rawContent = extractCompletionContent(body);
|
|
200
201
|
if (!rawContent) {
|
|
201
202
|
return { kind: "retryable", reason: "portal response had no completion content" };
|
|
@@ -251,6 +252,29 @@ function extractJsonCandidate(raw) {
|
|
|
251
252
|
}
|
|
252
253
|
return body;
|
|
253
254
|
}
|
|
255
|
+
function asRecord(value) {
|
|
256
|
+
return typeof value === "object" && value !== null ? value : void 0;
|
|
257
|
+
}
|
|
258
|
+
function asCount(value) {
|
|
259
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
260
|
+
}
|
|
261
|
+
function logPortalUsage(body, tag) {
|
|
262
|
+
try {
|
|
263
|
+
const root = asRecord(body);
|
|
264
|
+
if (!root) return;
|
|
265
|
+
const usage = asRecord(root.usage);
|
|
266
|
+
const promptTokens = asCount(usage?.prompt_tokens);
|
|
267
|
+
const completionTokens = asCount(usage?.completion_tokens);
|
|
268
|
+
if (promptTokens === void 0 && completionTokens === void 0) return;
|
|
269
|
+
const cachedTokens = asCount(asRecord(root.portal)?.cached_tokens) ?? asCount(asRecord(usage?.prompt_tokens_details)?.cached_tokens) ?? 0;
|
|
270
|
+
const parts = [];
|
|
271
|
+
if (promptTokens !== void 0) parts.push(`prompt=${promptTokens}`);
|
|
272
|
+
if (completionTokens !== void 0) parts.push(`completion=${completionTokens}`);
|
|
273
|
+
parts.push(`cached=${cachedTokens}`);
|
|
274
|
+
getLogger().debug(`[${tag}] usage ${parts.join(" ")}`);
|
|
275
|
+
} catch {
|
|
276
|
+
}
|
|
277
|
+
}
|
|
254
278
|
function extractCompletionContent(body) {
|
|
255
279
|
if (typeof body !== "object" || body === null) return null;
|
|
256
280
|
const choices = body.choices;
|
package/dist/expo/index.cjs
CHANGED
|
@@ -4279,6 +4279,18 @@ var init_encryption2 = __esm({
|
|
|
4279
4279
|
});
|
|
4280
4280
|
|
|
4281
4281
|
// src/lib/db/memoryVault/operations.ts
|
|
4282
|
+
function visibilityOrPrivate(value) {
|
|
4283
|
+
return value === "public" ? value : "private";
|
|
4284
|
+
}
|
|
4285
|
+
function visibilityConditions(requested) {
|
|
4286
|
+
if (!requested?.length) return [];
|
|
4287
|
+
if (!requested.includes("private")) {
|
|
4288
|
+
return [import_watermelondb9.Q.where("visibility", import_watermelondb9.Q.oneOf([...requested]))];
|
|
4289
|
+
}
|
|
4290
|
+
const excluded = NON_PRIVATE_VISIBILITIES.filter((v) => !requested.includes(v));
|
|
4291
|
+
if (excluded.length === 0) return [];
|
|
4292
|
+
return [import_watermelondb9.Q.or(import_watermelondb9.Q.where("visibility", null), import_watermelondb9.Q.where("visibility", import_watermelondb9.Q.notIn(excluded)))];
|
|
4293
|
+
}
|
|
4282
4294
|
function isOwnedByCtxUser(ctx, record) {
|
|
4283
4295
|
return ctx.userId === void 0 || record.userId === ctx.userId;
|
|
4284
4296
|
}
|
|
@@ -4339,6 +4351,10 @@ function vaultMemoryToStoredRaw(memory) {
|
|
|
4339
4351
|
factType: memory.factType ?? null,
|
|
4340
4352
|
archivedAt: memory.archivedAt ?? null,
|
|
4341
4353
|
trustTier: memory.trustTier ?? null,
|
|
4354
|
+
visibility: visibilityOrPrivate(memory.visibility),
|
|
4355
|
+
twinOptIn: memory.twinOptIn ?? false,
|
|
4356
|
+
publishedAt: memory.publishedAt ?? null,
|
|
4357
|
+
geohash: memory.geohash ?? null,
|
|
4342
4358
|
createdAt: memory.createdAt,
|
|
4343
4359
|
updatedAt: memory.updatedAt,
|
|
4344
4360
|
isDeleted: memory.isDeleted
|
|
@@ -4386,6 +4402,14 @@ async function createVaultMemoryOp(ctx, opts) {
|
|
|
4386
4402
|
if (opts.trustTier !== void 0) {
|
|
4387
4403
|
record._setRaw("trust_tier", normalizeTrustTier(opts.trustTier));
|
|
4388
4404
|
}
|
|
4405
|
+
record._setRaw("visibility", opts.visibility ?? "private");
|
|
4406
|
+
record._setRaw(
|
|
4407
|
+
"published_at",
|
|
4408
|
+
opts.visibility && opts.visibility !== "private" ? opts.publishedAt ?? Date.now() : null
|
|
4409
|
+
);
|
|
4410
|
+
if (opts.geohash !== void 0) {
|
|
4411
|
+
record._setRaw("geohash", opts.geohash);
|
|
4412
|
+
}
|
|
4389
4413
|
});
|
|
4390
4414
|
});
|
|
4391
4415
|
return vaultMemoryToStored(created, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
|
|
@@ -4532,6 +4556,14 @@ async function createVaultMemoriesBatchOp(ctx, optionsArray) {
|
|
|
4532
4556
|
if (opts.trustTier !== void 0) {
|
|
4533
4557
|
record._setRaw("trust_tier", normalizeTrustTier(opts.trustTier));
|
|
4534
4558
|
}
|
|
4559
|
+
record._setRaw("visibility", opts.visibility ?? "private");
|
|
4560
|
+
record._setRaw(
|
|
4561
|
+
"published_at",
|
|
4562
|
+
opts.visibility && opts.visibility !== "private" ? opts.publishedAt ?? Date.now() : null
|
|
4563
|
+
);
|
|
4564
|
+
if (opts.geohash !== void 0) {
|
|
4565
|
+
record._setRaw("geohash", opts.geohash);
|
|
4566
|
+
}
|
|
4535
4567
|
})
|
|
4536
4568
|
);
|
|
4537
4569
|
await ctx.database.batch(...prepared);
|
|
@@ -4595,6 +4627,10 @@ function vaultMemoryRawToStoredRaw(raw) {
|
|
|
4595
4627
|
factType: raw.fact_type ?? null,
|
|
4596
4628
|
archivedAt: raw.archived_at ?? null,
|
|
4597
4629
|
trustTier: raw.trust_tier ?? null,
|
|
4630
|
+
visibility: visibilityOrPrivate(raw.visibility),
|
|
4631
|
+
twinOptIn: raw.twin_opt_in === true || raw.twin_opt_in === 1,
|
|
4632
|
+
publishedAt: raw.published_at ?? null,
|
|
4633
|
+
geohash: raw.geohash ?? null,
|
|
4598
4634
|
createdAt: new Date(raw.created_at),
|
|
4599
4635
|
updatedAt: new Date(raw.updated_at),
|
|
4600
4636
|
isDeleted: raw.is_deleted === true || raw.is_deleted === 1
|
|
@@ -4611,6 +4647,7 @@ async function getAllVaultMemoriesOp(ctx, options) {
|
|
|
4611
4647
|
const conditions = [
|
|
4612
4648
|
...baseVaultConditions(ctx, options),
|
|
4613
4649
|
...options?.scopes?.length ? [import_watermelondb9.Q.where("scope", import_watermelondb9.Q.oneOf(options.scopes))] : [],
|
|
4650
|
+
...visibilityConditions(options?.visibility),
|
|
4614
4651
|
...options?.folderId !== void 0 ? [import_watermelondb9.Q.where("folder_id", options.folderId)] : [],
|
|
4615
4652
|
...options?.factTypes?.length ? [import_watermelondb9.Q.where("fact_type", import_watermelondb9.Q.oneOf(options.factTypes))] : [],
|
|
4616
4653
|
import_watermelondb9.Q.sortBy(options?.since ? "updated_at" : "created_at", import_watermelondb9.Q.desc),
|
|
@@ -4824,6 +4861,38 @@ async function updateVaultMemoryOp(ctx, id, opts) {
|
|
|
4824
4861
|
return null;
|
|
4825
4862
|
}
|
|
4826
4863
|
}
|
|
4864
|
+
async function setMemoryVisibilityOp(ctx, id, opts) {
|
|
4865
|
+
let record;
|
|
4866
|
+
try {
|
|
4867
|
+
record = await ctx.vaultMemoryCollection.find(id);
|
|
4868
|
+
} catch {
|
|
4869
|
+
return null;
|
|
4870
|
+
}
|
|
4871
|
+
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) return null;
|
|
4872
|
+
let stale = false;
|
|
4873
|
+
await ctx.database.write(async () => {
|
|
4874
|
+
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) {
|
|
4875
|
+
stale = true;
|
|
4876
|
+
return;
|
|
4877
|
+
}
|
|
4878
|
+
const currentUpdatedAt = record.updatedAt.getTime();
|
|
4879
|
+
const currentPublishedAt = record.publishedAt ?? null;
|
|
4880
|
+
await record.update((r) => {
|
|
4881
|
+
r._setRaw("visibility", opts.visibility);
|
|
4882
|
+
if (opts.visibility === "private") {
|
|
4883
|
+
r._setRaw("published_at", null);
|
|
4884
|
+
} else if (currentPublishedAt === null) {
|
|
4885
|
+
r._setRaw("published_at", Date.now());
|
|
4886
|
+
}
|
|
4887
|
+
if (opts.twinOptIn !== void 0) {
|
|
4888
|
+
r._setRaw("twin_opt_in", opts.twinOptIn);
|
|
4889
|
+
}
|
|
4890
|
+
r._setRaw("updated_at", currentUpdatedAt);
|
|
4891
|
+
});
|
|
4892
|
+
});
|
|
4893
|
+
if (stale) return null;
|
|
4894
|
+
return vaultMemoryToStored(record, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
|
|
4895
|
+
}
|
|
4827
4896
|
async function deleteVaultMemoryOp(ctx, id) {
|
|
4828
4897
|
try {
|
|
4829
4898
|
const record = await ctx.vaultMemoryCollection.find(id);
|
|
@@ -5113,7 +5182,7 @@ async function updateVaultMemoryEmbeddingOp(ctx, id, embedding, embeddingModel)
|
|
|
5113
5182
|
return false;
|
|
5114
5183
|
}
|
|
5115
5184
|
}
|
|
5116
|
-
var import_watermelondb9, KNOWN_TRUST_TIERS, TOPICS_EXTRACTION_VERSION;
|
|
5185
|
+
var import_watermelondb9, NON_PRIVATE_VISIBILITIES, KNOWN_TRUST_TIERS, TOPICS_EXTRACTION_VERSION;
|
|
5117
5186
|
var init_operations3 = __esm({
|
|
5118
5187
|
"src/lib/db/memoryVault/operations.ts"() {
|
|
5119
5188
|
"use strict";
|
|
@@ -5121,6 +5190,7 @@ var init_operations3 = __esm({
|
|
|
5121
5190
|
init_logger();
|
|
5122
5191
|
init_operations2();
|
|
5123
5192
|
init_encryption2();
|
|
5193
|
+
NON_PRIVATE_VISIBILITIES = ["public"];
|
|
5124
5194
|
KNOWN_TRUST_TIERS = /* @__PURE__ */ new Set(["quarantined", "trusted"]);
|
|
5125
5195
|
TOPICS_EXTRACTION_VERSION = 3;
|
|
5126
5196
|
}
|
|
@@ -5274,6 +5344,7 @@ async function attemptPortalJson(req, endpoint) {
|
|
|
5274
5344
|
return { kind: "retryable", reason: `response body parse failed: ${err.message}` };
|
|
5275
5345
|
}
|
|
5276
5346
|
clearTimeout(timer);
|
|
5347
|
+
logPortalUsage(body, req.tag);
|
|
5277
5348
|
const rawContent = extractCompletionContent(body);
|
|
5278
5349
|
if (!rawContent) {
|
|
5279
5350
|
return { kind: "retryable", reason: "portal response had no completion content" };
|
|
@@ -5329,6 +5400,29 @@ function extractJsonCandidate(raw) {
|
|
|
5329
5400
|
}
|
|
5330
5401
|
return body;
|
|
5331
5402
|
}
|
|
5403
|
+
function asRecord(value) {
|
|
5404
|
+
return typeof value === "object" && value !== null ? value : void 0;
|
|
5405
|
+
}
|
|
5406
|
+
function asCount(value) {
|
|
5407
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
5408
|
+
}
|
|
5409
|
+
function logPortalUsage(body, tag) {
|
|
5410
|
+
try {
|
|
5411
|
+
const root = asRecord(body);
|
|
5412
|
+
if (!root) return;
|
|
5413
|
+
const usage = asRecord(root.usage);
|
|
5414
|
+
const promptTokens = asCount(usage?.prompt_tokens);
|
|
5415
|
+
const completionTokens = asCount(usage?.completion_tokens);
|
|
5416
|
+
if (promptTokens === void 0 && completionTokens === void 0) return;
|
|
5417
|
+
const cachedTokens = asCount(asRecord(root.portal)?.cached_tokens) ?? asCount(asRecord(usage?.prompt_tokens_details)?.cached_tokens) ?? 0;
|
|
5418
|
+
const parts = [];
|
|
5419
|
+
if (promptTokens !== void 0) parts.push(`prompt=${promptTokens}`);
|
|
5420
|
+
if (completionTokens !== void 0) parts.push(`completion=${completionTokens}`);
|
|
5421
|
+
parts.push(`cached=${cachedTokens}`);
|
|
5422
|
+
getLogger().debug(`[${tag}] usage ${parts.join(" ")}`);
|
|
5423
|
+
} catch {
|
|
5424
|
+
}
|
|
5425
|
+
}
|
|
5332
5426
|
function extractCompletionContent(body) {
|
|
5333
5427
|
if (typeof body !== "object" || body === null) return null;
|
|
5334
5428
|
const choices = body.choices;
|
|
@@ -8188,6 +8282,7 @@ __export(index_exports, {
|
|
|
8188
8282
|
sdkSchema: () => sdkSchema,
|
|
8189
8283
|
searchVaultMemories: () => searchVaultMemories,
|
|
8190
8284
|
setLogger: () => setLogger,
|
|
8285
|
+
setMemoryVisibilityOp: () => setMemoryVisibilityOp,
|
|
8191
8286
|
shouldChunkMessage: () => shouldChunkMessage,
|
|
8192
8287
|
stampTopicsExtractedAtOp: () => stampTopicsExtractedAtOp,
|
|
8193
8288
|
streamCancelPath: () => streamCancelPath,
|
|
@@ -13708,6 +13803,18 @@ __decorateClass([
|
|
|
13708
13803
|
__decorateClass([
|
|
13709
13804
|
(0, import_decorators3.field)("trust_tier")
|
|
13710
13805
|
], VaultMemory.prototype, "trustTier", 2);
|
|
13806
|
+
__decorateClass([
|
|
13807
|
+
(0, import_decorators3.field)("visibility")
|
|
13808
|
+
], VaultMemory.prototype, "visibility", 2);
|
|
13809
|
+
__decorateClass([
|
|
13810
|
+
(0, import_decorators3.field)("twin_opt_in")
|
|
13811
|
+
], VaultMemory.prototype, "twinOptIn", 2);
|
|
13812
|
+
__decorateClass([
|
|
13813
|
+
(0, import_decorators3.field)("published_at")
|
|
13814
|
+
], VaultMemory.prototype, "publishedAt", 2);
|
|
13815
|
+
__decorateClass([
|
|
13816
|
+
(0, import_decorators3.field)("geohash")
|
|
13817
|
+
], VaultMemory.prototype, "geohash", 2);
|
|
13711
13818
|
__decorateClass([
|
|
13712
13819
|
import_decorators3.readonly,
|
|
13713
13820
|
(0, import_decorators3.date)("created_at")
|
|
@@ -15324,18 +15431,16 @@ function createAutoExtractor(options) {
|
|
|
15324
15431
|
} catch {
|
|
15325
15432
|
}
|
|
15326
15433
|
};
|
|
15327
|
-
const
|
|
15328
|
-
|
|
15329
|
-
|
|
15330
|
-
|
|
15331
|
-
|
|
15332
|
-
|
|
15333
|
-
|
|
15334
|
-
|
|
15335
|
-
|
|
15336
|
-
|
|
15337
|
-
// extractAndRetain (so direct callers are covered too), not copied here.
|
|
15338
|
-
} : void 0;
|
|
15434
|
+
const subPassAuth = (baseUrlOverride) => {
|
|
15435
|
+
const baseUrl = baseUrlOverride ?? options.extract.baseUrl;
|
|
15436
|
+
return {
|
|
15437
|
+
...options.extract.apiKey !== void 0 && { apiKey: options.extract.apiKey },
|
|
15438
|
+
...options.extract.getToken !== void 0 && { getToken: options.extract.getToken },
|
|
15439
|
+
...baseUrl !== void 0 && { baseUrl }
|
|
15440
|
+
};
|
|
15441
|
+
};
|
|
15442
|
+
const consolidateOptions = options.consolidate ? { ...options.consolidate, ...subPassAuth(options.consolidate.baseUrl) } : void 0;
|
|
15443
|
+
const injectionClassifierOptions = options.injectionClassifier ? { ...options.injectionClassifier, ...subPassAuth(options.injectionClassifier.baseUrl) } : void 0;
|
|
15339
15444
|
if (options.retainCtx.vaultCtx.entityCtx && !options.entityCtx) {
|
|
15340
15445
|
getLogger().warn(
|
|
15341
15446
|
"[memory/extract] retainCtx.vaultCtx.entityCtx is set but extractor was created without `entityCtx` \u2014 W5 graph lane will receive no writes"
|
|
@@ -15389,6 +15494,9 @@ function createAutoExtractor(options) {
|
|
|
15389
15494
|
...options.scope !== void 0 && { scope: options.scope },
|
|
15390
15495
|
...options.folderId !== void 0 && { folderId: options.folderId },
|
|
15391
15496
|
...consolidateOptions !== void 0 && { consolidateOptions },
|
|
15497
|
+
...injectionClassifierOptions !== void 0 && {
|
|
15498
|
+
injectionClassifier: injectionClassifierOptions
|
|
15499
|
+
},
|
|
15392
15500
|
...options.onCandidateFailed && {
|
|
15393
15501
|
onCandidateFailed: (candidate, error) => options.onCandidateFailed?.({ candidate, error, conversationId })
|
|
15394
15502
|
},
|
|
@@ -19894,7 +20002,7 @@ __decorateClass([
|
|
|
19894
20002
|
], VaultFolder.prototype, "context", 2);
|
|
19895
20003
|
|
|
19896
20004
|
// src/lib/db/schema.ts
|
|
19897
|
-
var SDK_SCHEMA_VERSION =
|
|
20005
|
+
var SDK_SCHEMA_VERSION = 41;
|
|
19898
20006
|
var sdkSchema = (0, import_watermelondb19.appSchema)({
|
|
19899
20007
|
version: SDK_SCHEMA_VERSION,
|
|
19900
20008
|
tables: [
|
|
@@ -20053,7 +20161,26 @@ var sdkSchema = (0, import_watermelondb19.appSchema)({
|
|
|
20053
20161
|
// Tier-0 security (PR3) — "quarantined" when the write-time injection
|
|
20054
20162
|
// screen flagged this fact, else null/"trusted". Indexed so the recall
|
|
20055
20163
|
// choke point can default-exclude quarantined rows.
|
|
20056
|
-
{ name: "trust_tier", type: "string", isOptional: true, isIndexed: true }
|
|
20164
|
+
{ name: "trust_tier", type: "string", isOptional: true, isIndexed: true },
|
|
20165
|
+
// People Nearby cross-user visibility axis — ORTHOGONAL to `scope`
|
|
20166
|
+
// (which partitions by MODEL access: private vs shared providers).
|
|
20167
|
+
// TWO tiers: 'private' (or null, or any unrecognised value —
|
|
20168
|
+
// grandfathered / fail-safe) = local-only; 'public' = embedding +
|
|
20169
|
+
// plaintext may be published (matching/profile/discovery/twin).
|
|
20170
|
+
// The server index is the authority for what IS published; this
|
|
20171
|
+
// column records the user's intent.
|
|
20172
|
+
{ name: "visibility", type: "string", isOptional: true, isIndexed: true },
|
|
20173
|
+
// When true, the owner opted this memory into their own digital twin
|
|
20174
|
+
// even if it is otherwise private (twin-scoped upload only — never
|
|
20175
|
+
// indexed for matching, never displayed). Null/false = follows visibility.
|
|
20176
|
+
{ name: "twin_opt_in", type: "boolean", isOptional: true },
|
|
20177
|
+
// Unix ms when visibility last became non-private. Null when private
|
|
20178
|
+
// (cleared on revoke) — the publish reconciler uses it to diff local
|
|
20179
|
+
// intent against the server index.
|
|
20180
|
+
{ name: "published_at", type: "number", isOptional: true },
|
|
20181
|
+
// Reserved geo slot (coarse geohash) for landmark/Trail memories.
|
|
20182
|
+
// Unused at launch; populated by location-tagged memory sources.
|
|
20183
|
+
{ name: "geohash", type: "string", isOptional: true }
|
|
20057
20184
|
]
|
|
20058
20185
|
}),
|
|
20059
20186
|
// Entity table — canonical names extracted from auto-extraction (W5).
|
|
@@ -20728,6 +20855,24 @@ var sdkMigrations = (0, import_migrations2.schemaMigrations)({
|
|
|
20728
20855
|
]
|
|
20729
20856
|
})
|
|
20730
20857
|
]
|
|
20858
|
+
},
|
|
20859
|
+
// v40 -> v41: People Nearby visibility axis on memory_vault. Existing rows
|
|
20860
|
+
// keep visibility NULL — read as 'private' (nothing pre-existing is ever
|
|
20861
|
+
// published without an explicit user action; the consent posture requires
|
|
20862
|
+
// opt-in, never a retroactive default).
|
|
20863
|
+
{
|
|
20864
|
+
toVersion: 41,
|
|
20865
|
+
steps: [
|
|
20866
|
+
(0, import_migrations2.addColumns)({
|
|
20867
|
+
table: "memory_vault",
|
|
20868
|
+
columns: [
|
|
20869
|
+
{ name: "visibility", type: "string", isOptional: true, isIndexed: true },
|
|
20870
|
+
{ name: "twin_opt_in", type: "boolean", isOptional: true },
|
|
20871
|
+
{ name: "published_at", type: "number", isOptional: true },
|
|
20872
|
+
{ name: "geohash", type: "string", isOptional: true }
|
|
20873
|
+
]
|
|
20874
|
+
})
|
|
20875
|
+
]
|
|
20731
20876
|
}
|
|
20732
20877
|
]
|
|
20733
20878
|
});
|
|
@@ -22222,6 +22367,7 @@ function createNotionTools(getAccessToken, requestNotionAccess) {
|
|
|
22222
22367
|
sdkSchema,
|
|
22223
22368
|
searchVaultMemories,
|
|
22224
22369
|
setLogger,
|
|
22370
|
+
setMemoryVisibilityOp,
|
|
22225
22371
|
shouldChunkMessage,
|
|
22226
22372
|
stampTopicsExtractedAtOp,
|
|
22227
22373
|
streamCancelPath,
|