@sentry/junior-memory 0.209.0 → 0.210.1
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 +38 -18
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1370,22 +1370,22 @@ var memoryReviewDecisionSchema = z3.discriminatedUnion("decision", [
|
|
|
1370
1370
|
reason: memoryRejectReasonSchema
|
|
1371
1371
|
}).strict()
|
|
1372
1372
|
]);
|
|
1373
|
-
var memoryReviewResponseSchema = z3.
|
|
1374
|
-
z3.
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1373
|
+
var memoryReviewResponseSchema = z3.object({
|
|
1374
|
+
decision: z3.enum(["store", "reject"]),
|
|
1375
|
+
kind: memoryKindSchema.nullable().describe(
|
|
1376
|
+
"Use preference only for actor-owned personal preferences, opinions, habits, or workflows. Use procedure for reusable task or process instructions. Use knowledge for shared project, channel, operational, or runbook facts. Null when rejecting."
|
|
1377
|
+
),
|
|
1378
|
+
canonicalFact: z3.string().min(1).nullable().describe(
|
|
1379
|
+
"Stored memory text. It must be self-contained and must not include actor names, actor/user labels, source labels, or first- or second-person wording. Null when rejecting."
|
|
1380
|
+
),
|
|
1381
|
+
expiresAtMs: expiresAtMsSchema,
|
|
1382
|
+
reason: memoryRejectReasonSchema.nullable().describe("Reject reason. Null when storing.")
|
|
1383
|
+
}).strict();
|
|
1384
|
+
var memorySupersessionResponseSchema = z3.object({
|
|
1385
|
+
decision: z3.enum(["duplicate", "supersedes_old", "distinct", "uncertain"]),
|
|
1386
|
+
duplicateId: z3.string().min(1).nullable().describe("Existing memory id for duplicate, otherwise null."),
|
|
1387
|
+
supersededIds: z3.array(z3.string().min(1)).nullable().describe("Existing memory ids for supersedes_old, otherwise null.")
|
|
1388
|
+
}).strict();
|
|
1389
1389
|
var extractedMemorySchema = z3.object({
|
|
1390
1390
|
kind: memoryKindSchema.describe(
|
|
1391
1391
|
"Use preference only for actor-owned personal preferences, opinions, habits, or workflows. Use procedure for reusable task or process instructions. Use knowledge for shared project, channel, operational, or runbook facts."
|
|
@@ -1560,6 +1560,7 @@ function reviewPrompt(request) {
|
|
|
1560
1560
|
"- Reject third-party personal profile facts, even if they mention a name.",
|
|
1561
1561
|
"- Reject vague content such as 'remember this' unless the candidate or current-user-message contains the concrete fact.",
|
|
1562
1562
|
"- Preserve the requested expiration when one exists; otherwise set expiresAtMs to null.",
|
|
1563
|
+
"- When storing, set reason to null. When rejecting, set kind, canonicalFact, and expiresAtMs to null.",
|
|
1563
1564
|
"- If unsure, reject.",
|
|
1564
1565
|
"</rules>",
|
|
1565
1566
|
"</memory-review-input>"
|
|
@@ -1687,6 +1688,7 @@ function preferenceAdjudicationPrompt(request) {
|
|
|
1687
1688
|
"- Return uncertain when broader or narrower wording makes equivalence or replacement unclear.",
|
|
1688
1689
|
"- Do not supersede memories from different topics even if they are both preferences.",
|
|
1689
1690
|
"- duplicateId and supersededIds may contain only ids from existing-memories.",
|
|
1691
|
+
"- Set duplicateId to null unless the decision is duplicate. Set supersededIds to null unless the decision is supersedes_old.",
|
|
1690
1692
|
"- If unsure, return uncertain.",
|
|
1691
1693
|
"</rules>",
|
|
1692
1694
|
"</memory-preference-adjudication-input>"
|
|
@@ -1714,12 +1716,14 @@ function createMemoryAgent(model) {
|
|
|
1714
1716
|
async adjudicateSupersession(rawRequest) {
|
|
1715
1717
|
const request = memorySupersessionInputSchema.parse(rawRequest);
|
|
1716
1718
|
const result = await model.completeObject({
|
|
1717
|
-
schema:
|
|
1719
|
+
schema: memorySupersessionResponseSchema,
|
|
1718
1720
|
system: MEMORY_PREFERENCE_ADJUDICATION_SYSTEM,
|
|
1719
1721
|
prompt: preferenceAdjudicationPrompt(request),
|
|
1720
1722
|
maxTokens: 400
|
|
1721
1723
|
});
|
|
1722
|
-
return
|
|
1724
|
+
return memorySupersessionFromResponse(
|
|
1725
|
+
memorySupersessionResponseSchema.parse(result.object)
|
|
1726
|
+
);
|
|
1723
1727
|
},
|
|
1724
1728
|
async extractSessionMemories(rawRequest) {
|
|
1725
1729
|
const request = extractSessionRequestSchema.parse(rawRequest);
|
|
@@ -1763,6 +1767,22 @@ function memoryReviewFromResponse(response) {
|
|
|
1763
1767
|
reason: response.reason
|
|
1764
1768
|
});
|
|
1765
1769
|
}
|
|
1770
|
+
function memorySupersessionFromResponse(response) {
|
|
1771
|
+
switch (response.decision) {
|
|
1772
|
+
case "duplicate":
|
|
1773
|
+
return memorySupersessionDecisionSchema.parse({
|
|
1774
|
+
decision: "duplicate",
|
|
1775
|
+
duplicateId: response.duplicateId
|
|
1776
|
+
});
|
|
1777
|
+
case "supersedes_old":
|
|
1778
|
+
return memorySupersessionDecisionSchema.parse({
|
|
1779
|
+
decision: "supersedes_old",
|
|
1780
|
+
supersededIds: response.supersededIds
|
|
1781
|
+
});
|
|
1782
|
+
default:
|
|
1783
|
+
return { decision: response.decision };
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1766
1786
|
function extractedMemoriesFromResponse(response) {
|
|
1767
1787
|
const toMemory = (memory) => parseExtractedMemory({
|
|
1768
1788
|
content: memory.canonicalFact,
|