@sentry/junior-memory 0.179.0 → 0.180.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/index.js +52 -52
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/agent.ts +3 -3
- package/src/api.ts +3 -3
- package/src/personal-store.ts +1 -1
- package/src/personal.ts +9 -9
- package/src/plugin.ts +7 -7
- package/src/process-session.ts +3 -3
- package/src/ranking.ts +2 -2
- package/src/recall.ts +5 -5
- package/src/store.ts +10 -10
- package/src/tools.ts +7 -7
- package/src/user-pages.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -209,8 +209,8 @@ function rankMemoryMatches(matches, options) {
|
|
|
209
209
|
}
|
|
210
210
|
byId.set(match.memory.id, {
|
|
211
211
|
...existing,
|
|
212
|
-
...!existing.lexical && match.lexical ? { lexical: match.lexical } :
|
|
213
|
-
...!existing.vector && match.vector ? { vector: match.vector } :
|
|
212
|
+
...!existing.lexical && match.lexical ? { lexical: match.lexical } : void 0,
|
|
213
|
+
...!existing.vector && match.vector ? { vector: match.vector } : void 0
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
return [...byId.values()].sort((left, right) => {
|
|
@@ -560,11 +560,11 @@ function parseMemoryRow(row) {
|
|
|
560
560
|
content: parsed.content,
|
|
561
561
|
observedAtMs: parsed.observedAtMs,
|
|
562
562
|
createdAtMs: parsed.createdAtMs,
|
|
563
|
-
...parsed.expiresAtMs !== void 0 ? { expiresAtMs: parsed.expiresAtMs } :
|
|
564
|
-
...parsed.supersededAtMs !== void 0 ? { supersededAtMs: parsed.supersededAtMs } :
|
|
565
|
-
...parsed.supersededById ? { supersededById: parsed.supersededById } :
|
|
566
|
-
...parsed.archivedAtMs !== void 0 ? { archivedAtMs: parsed.archivedAtMs } :
|
|
567
|
-
...parsed.archiveReason ? { archiveReason: parsed.archiveReason } :
|
|
563
|
+
...parsed.expiresAtMs !== void 0 ? { expiresAtMs: parsed.expiresAtMs } : void 0,
|
|
564
|
+
...parsed.supersededAtMs !== void 0 ? { supersededAtMs: parsed.supersededAtMs } : void 0,
|
|
565
|
+
...parsed.supersededById ? { supersededById: parsed.supersededById } : void 0,
|
|
566
|
+
...parsed.archivedAtMs !== void 0 ? { archivedAtMs: parsed.archivedAtMs } : void 0,
|
|
567
|
+
...parsed.archiveReason ? { archiveReason: parsed.archiveReason } : void 0
|
|
568
568
|
});
|
|
569
569
|
}
|
|
570
570
|
function visibleScopePredicate(scopes) {
|
|
@@ -1150,7 +1150,7 @@ function createMemoryStore(db, context, options = {}) {
|
|
|
1150
1150
|
if (scopeKind === "personal" && input.kind === "preference" && supersessionDecider && (input.expiresAtMs === void 0 || input.expiresAtMs > nowMs)) {
|
|
1151
1151
|
const preferenceCandidates = await listPreferenceAdjudicationCandidates({
|
|
1152
1152
|
db,
|
|
1153
|
-
...candidateEmbedding ? { embedding: candidateEmbedding } :
|
|
1153
|
+
...candidateEmbedding ? { embedding: candidateEmbedding } : void 0,
|
|
1154
1154
|
nowMs,
|
|
1155
1155
|
scope,
|
|
1156
1156
|
subject
|
|
@@ -1236,7 +1236,7 @@ function createMemoryStore(db, context, options = {}) {
|
|
|
1236
1236
|
return {
|
|
1237
1237
|
created: true,
|
|
1238
1238
|
memory,
|
|
1239
|
-
...write.supersededIds.length > 0 ? { supersededIds: write.supersededIds } :
|
|
1239
|
+
...write.supersededIds.length > 0 ? { supersededIds: write.supersededIds } : void 0
|
|
1240
1240
|
};
|
|
1241
1241
|
}
|
|
1242
1242
|
const idempotent = await findByIdempotencyKey({
|
|
@@ -1292,7 +1292,7 @@ function createMemoryStore(db, context, options = {}) {
|
|
|
1292
1292
|
db,
|
|
1293
1293
|
embedding: queryEmbedding,
|
|
1294
1294
|
limit: candidateLimit,
|
|
1295
|
-
...vectorMaxDistance !== void 0 ? { maxDistance: vectorMaxDistance } :
|
|
1295
|
+
...vectorMaxDistance !== void 0 ? { maxDistance: vectorMaxDistance } : void 0,
|
|
1296
1296
|
nowMs,
|
|
1297
1297
|
scopes
|
|
1298
1298
|
}) : emptyMatches,
|
|
@@ -1317,8 +1317,8 @@ function createMemoryStore(db, context, options = {}) {
|
|
|
1317
1317
|
return rankMemoryMatches(matches.flat(), {
|
|
1318
1318
|
nowMs,
|
|
1319
1319
|
// Slight lexical preference protects exact ids/names/timezones on ties.
|
|
1320
|
-
...vectorMaxDistance === void 0 ?
|
|
1321
|
-
...channelPrefix ? { channelPrefix } :
|
|
1320
|
+
...vectorMaxDistance === void 0 ? void 0 : { lexicalWeight: 1, vectorWeight: 0.85 },
|
|
1321
|
+
...channelPrefix ? { channelPrefix } : void 0
|
|
1322
1322
|
}).slice(0, limit).map(({ memory }) => memory);
|
|
1323
1323
|
}
|
|
1324
1324
|
return {
|
|
@@ -1814,7 +1814,7 @@ function createMemoryAgent(model) {
|
|
|
1814
1814
|
relevantIds: [...new Set(decision.relevantIds)].filter(
|
|
1815
1815
|
(id) => candidateIds.has(id)
|
|
1816
1816
|
),
|
|
1817
|
-
...result.costUsd !== void 0 ? { costUsd: result.costUsd } :
|
|
1817
|
+
...result.costUsd !== void 0 ? { costUsd: result.costUsd } : void 0
|
|
1818
1818
|
};
|
|
1819
1819
|
},
|
|
1820
1820
|
async adjudicateSupersession(rawRequest) {
|
|
@@ -1839,7 +1839,7 @@ function createMemoryAgent(model) {
|
|
|
1839
1839
|
memories: extractedMemoriesFromResponse(
|
|
1840
1840
|
extractMemoriesResponseSchema.parse(result.object)
|
|
1841
1841
|
),
|
|
1842
|
-
...result.costUsd !== void 0 ? { costUsd: result.costUsd } :
|
|
1842
|
+
...result.costUsd !== void 0 ? { costUsd: result.costUsd } : void 0
|
|
1843
1843
|
};
|
|
1844
1844
|
},
|
|
1845
1845
|
async reviewCreateRequest(rawRequest) {
|
|
@@ -1861,7 +1861,7 @@ function memoryReviewFromResponse(response) {
|
|
|
1861
1861
|
decision: "store",
|
|
1862
1862
|
kind: response.kind,
|
|
1863
1863
|
content: response.canonicalFact,
|
|
1864
|
-
...response.expiresAtMs !== null ? { expiresAtMs: response.expiresAtMs } :
|
|
1864
|
+
...response.expiresAtMs !== null ? { expiresAtMs: response.expiresAtMs } : void 0
|
|
1865
1865
|
});
|
|
1866
1866
|
}
|
|
1867
1867
|
return parseMemoryReview({
|
|
@@ -2057,7 +2057,7 @@ function createPersonalMemoryCollection(db, scopes, options = {}) {
|
|
|
2057
2057
|
createdAtMs: last.createdAtMs,
|
|
2058
2058
|
id: last.id
|
|
2059
2059
|
}
|
|
2060
|
-
} :
|
|
2060
|
+
} : void 0
|
|
2061
2061
|
};
|
|
2062
2062
|
},
|
|
2063
2063
|
async stats() {
|
|
@@ -2188,10 +2188,10 @@ function encodeCursor(cursor, input) {
|
|
|
2188
2188
|
return Buffer.from(
|
|
2189
2189
|
JSON.stringify({
|
|
2190
2190
|
...cursor,
|
|
2191
|
-
...input.query ? { query: input.query } :
|
|
2192
|
-
...input.kind ? { kind: input.kind } :
|
|
2193
|
-
...input.origin ? { origin: input.origin } :
|
|
2194
|
-
...input.visibility ? { visibility: input.visibility } :
|
|
2191
|
+
...input.query ? { query: input.query } : void 0,
|
|
2192
|
+
...input.kind ? { kind: input.kind } : void 0,
|
|
2193
|
+
...input.origin ? { origin: input.origin } : void 0,
|
|
2194
|
+
...input.visibility ? { visibility: input.visibility } : void 0,
|
|
2195
2195
|
version: 1
|
|
2196
2196
|
}),
|
|
2197
2197
|
"utf8"
|
|
@@ -2212,10 +2212,10 @@ function createViewerMemories(db, user) {
|
|
|
2212
2212
|
async list(input) {
|
|
2213
2213
|
const query = input.query?.trim() || void 0;
|
|
2214
2214
|
const filters = {
|
|
2215
|
-
...input.kind ? { kind: input.kind } :
|
|
2216
|
-
...input.origin ? { origin: input.origin } :
|
|
2217
|
-
...query ? { query } :
|
|
2218
|
-
...input.visibility ? { visibility: input.visibility } :
|
|
2215
|
+
...input.kind ? { kind: input.kind } : void 0,
|
|
2216
|
+
...input.origin ? { origin: input.origin } : void 0,
|
|
2217
|
+
...query ? { query } : void 0,
|
|
2218
|
+
...input.visibility ? { visibility: input.visibility } : void 0
|
|
2219
2219
|
};
|
|
2220
2220
|
const page = await collection.list({
|
|
2221
2221
|
cursor: decodeCursor(input.cursor, filters),
|
|
@@ -2224,7 +2224,7 @@ function createViewerMemories(db, user) {
|
|
|
2224
2224
|
});
|
|
2225
2225
|
return {
|
|
2226
2226
|
memories: page.memories,
|
|
2227
|
-
...page.nextCursor ? { nextCursor: encodeCursor(page.nextCursor, filters) } :
|
|
2227
|
+
...page.nextCursor ? { nextCursor: encodeCursor(page.nextCursor, filters) } : void 0
|
|
2228
2228
|
};
|
|
2229
2229
|
},
|
|
2230
2230
|
async stats() {
|
|
@@ -2295,7 +2295,7 @@ function apiMemory(memory) {
|
|
|
2295
2295
|
return {
|
|
2296
2296
|
content: memory.content,
|
|
2297
2297
|
createdAt: new Date(memory.createdAtMs).toISOString(),
|
|
2298
|
-
...memory.expiresAtMs !== void 0 ? { expiresAt: new Date(memory.expiresAtMs).toISOString() } :
|
|
2298
|
+
...memory.expiresAtMs !== void 0 ? { expiresAt: new Date(memory.expiresAtMs).toISOString() } : void 0,
|
|
2299
2299
|
id: memory.id,
|
|
2300
2300
|
kind: memory.kind,
|
|
2301
2301
|
observedAt: new Date(memory.observedAtMs).toISOString(),
|
|
@@ -2367,11 +2367,11 @@ function createMemoryApi(options) {
|
|
|
2367
2367
|
const page = await memories.list({
|
|
2368
2368
|
cursor: query.cursor,
|
|
2369
2369
|
limit: query.limit,
|
|
2370
|
-
...query.q ? { query: query.q } :
|
|
2370
|
+
...query.q ? { query: query.q } : void 0
|
|
2371
2371
|
});
|
|
2372
2372
|
const body = memoryListResponseSchema.parse({
|
|
2373
2373
|
memories: page.memories.map(apiMemory),
|
|
2374
|
-
...page.nextCursor ? { nextCursor: page.nextCursor } :
|
|
2374
|
+
...page.nextCursor ? { nextCursor: page.nextCursor } : void 0
|
|
2375
2375
|
});
|
|
2376
2376
|
return request.method === "HEAD" ? new Response(null, {
|
|
2377
2377
|
headers: { "cache-control": "no-store" },
|
|
@@ -2575,15 +2575,15 @@ function asToolInputError(error) {
|
|
|
2575
2575
|
}
|
|
2576
2576
|
function memoryRuntimeContext(context) {
|
|
2577
2577
|
return memoryRuntimeContextSchema.parse({
|
|
2578
|
-
...context.conversationId ? { conversationId: context.conversationId } :
|
|
2579
|
-
...context.actor ? { actor: context.actor } :
|
|
2578
|
+
...context.conversationId ? { conversationId: context.conversationId } : void 0,
|
|
2579
|
+
...context.actor ? { actor: context.actor } : void 0,
|
|
2580
2580
|
source: context.source
|
|
2581
2581
|
});
|
|
2582
2582
|
}
|
|
2583
2583
|
function memoryStore(context, options = {}) {
|
|
2584
2584
|
return createMemoryStore(context.db, memoryRuntimeContext(context), {
|
|
2585
2585
|
embedder: context.embedder,
|
|
2586
|
-
...options.supersessionDecider ? { supersessionDecider: options.supersessionDecider } :
|
|
2586
|
+
...options.supersessionDecider ? { supersessionDecider: options.supersessionDecider } : void 0
|
|
2587
2587
|
});
|
|
2588
2588
|
}
|
|
2589
2589
|
function boundedLimit2(value, fallback) {
|
|
@@ -2742,7 +2742,7 @@ function createInput(context, input, toolCallId) {
|
|
|
2742
2742
|
content: requireMemoryContent(input.content),
|
|
2743
2743
|
idempotencyKey: `tool:${sourceIdempotencyKey(context)}:${toolCallId}`,
|
|
2744
2744
|
kind: input.kind,
|
|
2745
|
-
...input.expiresAtMs !== void 0 ? { expiresAtMs: input.expiresAtMs } :
|
|
2745
|
+
...input.expiresAtMs !== void 0 ? { expiresAtMs: input.expiresAtMs } : void 0
|
|
2746
2746
|
};
|
|
2747
2747
|
}
|
|
2748
2748
|
function targetForKind(kind) {
|
|
@@ -2757,7 +2757,7 @@ function compactMemory(memory) {
|
|
|
2757
2757
|
content: memory.content,
|
|
2758
2758
|
createdAtMs: memory.createdAtMs,
|
|
2759
2759
|
observedAtMs: memory.observedAtMs,
|
|
2760
|
-
...memory.expiresAtMs !== void 0 ? { expiresAtMs: memory.expiresAtMs } :
|
|
2760
|
+
...memory.expiresAtMs !== void 0 ? { expiresAtMs: memory.expiresAtMs } : void 0
|
|
2761
2761
|
});
|
|
2762
2762
|
}
|
|
2763
2763
|
function memoryToolResult(target, data) {
|
|
@@ -2793,13 +2793,13 @@ function createMemoryCreateTool(context) {
|
|
|
2793
2793
|
await context.agent.reviewCreateRequest(
|
|
2794
2794
|
parseCreateMemoryRequest({
|
|
2795
2795
|
content: requireMemoryContent(parsedInput.content),
|
|
2796
|
-
...requestedExpiresAtMs !== void 0 ? { expiresAtMs: requestedExpiresAtMs } :
|
|
2796
|
+
...requestedExpiresAtMs !== void 0 ? { expiresAtMs: requestedExpiresAtMs } : void 0,
|
|
2797
2797
|
runtimeContext,
|
|
2798
2798
|
...context.userText?.trim() ? {
|
|
2799
2799
|
sourceContext: {
|
|
2800
2800
|
currentUserText: context.userText.trim()
|
|
2801
2801
|
}
|
|
2802
|
-
} :
|
|
2802
|
+
} : void 0
|
|
2803
2803
|
})
|
|
2804
2804
|
)
|
|
2805
2805
|
);
|
|
@@ -3087,7 +3087,7 @@ function passiveInput(sessionId, memory, sourceKey2, target) {
|
|
|
3087
3087
|
content: memory.content,
|
|
3088
3088
|
idempotencyKey: `session:${sourceKey2}:${sessionId}:${memoryIdempotencySuffix(memory, target)}`,
|
|
3089
3089
|
kind: memory.kind,
|
|
3090
|
-
...memory.expiresAtMs !== null ? { expiresAtMs: memory.expiresAtMs } :
|
|
3090
|
+
...memory.expiresAtMs !== null ? { expiresAtMs: memory.expiresAtMs } : void 0
|
|
3091
3091
|
};
|
|
3092
3092
|
}
|
|
3093
3093
|
async function getTaskExtraction(context, extract) {
|
|
@@ -3125,7 +3125,7 @@ async function processMemorySession(context) {
|
|
|
3125
3125
|
}
|
|
3126
3126
|
const runtimeContext = memoryRuntimeContextSchema.parse({
|
|
3127
3127
|
conversationId: run.conversationId,
|
|
3128
|
-
...run.actor ? { actor: run.actor } :
|
|
3128
|
+
...run.actor ? { actor: run.actor } : void 0,
|
|
3129
3129
|
source: run.source
|
|
3130
3130
|
});
|
|
3131
3131
|
const agent = createMemoryAgent(context.model);
|
|
@@ -3166,7 +3166,7 @@ async function processMemorySession(context) {
|
|
|
3166
3166
|
await context.events.emit(
|
|
3167
3167
|
memoriesCapturedEvent({
|
|
3168
3168
|
memories: captured,
|
|
3169
|
-
...extraction.costUsd !== void 0 ? { costUsd: extraction.costUsd } :
|
|
3169
|
+
...extraction.costUsd !== void 0 ? { costUsd: extraction.costUsd } : void 0
|
|
3170
3170
|
})
|
|
3171
3171
|
);
|
|
3172
3172
|
}
|
|
@@ -3241,7 +3241,7 @@ async function emitRecallOutcome(args) {
|
|
|
3241
3241
|
await args.events?.emit(
|
|
3242
3242
|
memoriesRecalledEvent({
|
|
3243
3243
|
memories: args.memories,
|
|
3244
|
-
...args.costUsd !== void 0 ? { costUsd: args.costUsd } :
|
|
3244
|
+
...args.costUsd !== void 0 ? { costUsd: args.costUsd } : void 0
|
|
3245
3245
|
})
|
|
3246
3246
|
);
|
|
3247
3247
|
}
|
|
@@ -3256,8 +3256,8 @@ async function createMemoryPromptContributions(context) {
|
|
|
3256
3256
|
return void 0;
|
|
3257
3257
|
}
|
|
3258
3258
|
const runtimeContext = memoryRuntimeContextSchema.parse({
|
|
3259
|
-
...context.conversationId ? { conversationId: context.conversationId } :
|
|
3260
|
-
...context.actor ? { actor: context.actor } :
|
|
3259
|
+
...context.conversationId ? { conversationId: context.conversationId } : void 0,
|
|
3260
|
+
...context.actor ? { actor: context.actor } : void 0,
|
|
3261
3261
|
source: context.source
|
|
3262
3262
|
});
|
|
3263
3263
|
let embeddingCostUsd;
|
|
@@ -3277,7 +3277,7 @@ async function createMemoryPromptContributions(context) {
|
|
|
3277
3277
|
});
|
|
3278
3278
|
if (candidates.length === 0) {
|
|
3279
3279
|
await emitRecallOutcome({
|
|
3280
|
-
...embeddingCostUsd !== void 0 ? { costUsd: embeddingCostUsd } :
|
|
3280
|
+
...embeddingCostUsd !== void 0 ? { costUsd: embeddingCostUsd } : void 0,
|
|
3281
3281
|
events: context.events,
|
|
3282
3282
|
memories: []
|
|
3283
3283
|
});
|
|
@@ -3300,7 +3300,7 @@ async function createMemoryPromptContributions(context) {
|
|
|
3300
3300
|
const selected = selectPromptMemories(relevant);
|
|
3301
3301
|
const costUsd = addUsd(embeddingCostUsd, recall.costUsd);
|
|
3302
3302
|
await emitRecallOutcome({
|
|
3303
|
-
...costUsd !== void 0 ? { costUsd } :
|
|
3303
|
+
...costUsd !== void 0 ? { costUsd } : void 0,
|
|
3304
3304
|
events: context.events,
|
|
3305
3305
|
memories: selected.map(({ id }) => id)
|
|
3306
3306
|
});
|
|
@@ -3540,12 +3540,12 @@ function createMemoryUserPage() {
|
|
|
3540
3540
|
cursor: input.cursor,
|
|
3541
3541
|
...pageFilter(input.filter),
|
|
3542
3542
|
limit: input.limit,
|
|
3543
|
-
...input.query ? { query: input.query } :
|
|
3543
|
+
...input.query ? { query: input.query } : void 0
|
|
3544
3544
|
});
|
|
3545
3545
|
return {
|
|
3546
3546
|
type: "list",
|
|
3547
3547
|
emptyText: pageEmptyText(input),
|
|
3548
|
-
...page.nextCursor ? { nextCursor: page.nextCursor } :
|
|
3548
|
+
...page.nextCursor ? { nextCursor: page.nextCursor } : void 0,
|
|
3549
3549
|
searchPlaceholder: "Search memories",
|
|
3550
3550
|
records: page.memories.map((memory) => ({
|
|
3551
3551
|
actions: memory.visibility === "private" ? [
|
|
@@ -3593,12 +3593,12 @@ function memoryModelId(options) {
|
|
|
3593
3593
|
function memoryToolContext(ctx) {
|
|
3594
3594
|
return {
|
|
3595
3595
|
agent: ctx.agent,
|
|
3596
|
-
...ctx.conversationId ? { conversationId: ctx.conversationId } :
|
|
3597
|
-
...ctx.actor ? { actor: ctx.actor } :
|
|
3596
|
+
...ctx.conversationId ? { conversationId: ctx.conversationId } : void 0,
|
|
3597
|
+
...ctx.actor ? { actor: ctx.actor } : void 0,
|
|
3598
3598
|
db: ctx.db,
|
|
3599
|
-
...ctx.embedder ? { embedder: ctx.embedder } :
|
|
3599
|
+
...ctx.embedder ? { embedder: ctx.embedder } : void 0,
|
|
3600
3600
|
source: ctx.source,
|
|
3601
|
-
...ctx.userText ? { userText: ctx.userText } :
|
|
3601
|
+
...ctx.userText ? { userText: ctx.userText } : void 0
|
|
3602
3602
|
};
|
|
3603
3603
|
}
|
|
3604
3604
|
function memoryCreateToolContext(ctx) {
|
|
@@ -3679,8 +3679,8 @@ function memoryPlugin(options = {}) {
|
|
|
3679
3679
|
async userPrompt(ctx) {
|
|
3680
3680
|
return await createMemoryPromptContributions({
|
|
3681
3681
|
agent: createMemoryAgent(ctx.model),
|
|
3682
|
-
...ctx.conversationId ? { conversationId: ctx.conversationId } :
|
|
3683
|
-
...ctx.actor ? { actor: ctx.actor } :
|
|
3682
|
+
...ctx.conversationId ? { conversationId: ctx.conversationId } : void 0,
|
|
3683
|
+
...ctx.actor ? { actor: ctx.actor } : void 0,
|
|
3684
3684
|
db: ctx.db,
|
|
3685
3685
|
embedder: ctx.embedder,
|
|
3686
3686
|
events: ctx.events,
|
|
@@ -3689,7 +3689,7 @@ function memoryPlugin(options = {}) {
|
|
|
3689
3689
|
text: ctx.text
|
|
3690
3690
|
});
|
|
3691
3691
|
}
|
|
3692
|
-
} :
|
|
3692
|
+
} : void 0
|
|
3693
3693
|
}
|
|
3694
3694
|
});
|
|
3695
3695
|
}
|