@anuma/sdk 3.7.0 → 3.8.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/client/index.cjs +10 -0
- package/dist/client/index.d.mts +98 -3
- package/dist/client/index.d.ts +98 -3
- package/dist/client/index.mjs +9 -0
- package/dist/expo/{consolidate-J5PHQKKY.mjs → consolidate-HKN32P5W.mjs} +24 -10
- package/dist/expo/index.cjs +73 -25
- package/dist/expo/index.d.mts +6 -0
- package/dist/expo/index.d.ts +6 -0
- package/dist/expo/index.mjs +49 -16
- package/dist/index.d.mts +38 -2
- package/dist/index.d.ts +38 -2
- package/dist/react/{chunk-3VPEZDYL.mjs → chunk-3LUACMDC.mjs} +1 -1
- package/dist/react/{consolidate-PWJCAPZA.mjs → consolidate-7UUX56GM.mjs} +24 -10
- package/dist/react/index.cjs +73 -25
- package/dist/react/index.d.mts +6 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.mjs +50 -17
- package/dist/react/{recall-Z7BWJ67X.mjs → recall-CCA4VTDK.mjs} +1 -1
- package/dist/server/{consolidate-PCHO3D3G.mjs → consolidate-BKLNVH5Y.mjs} +24 -10
- package/dist/server/index.cjs +73 -25
- package/dist/server/index.mjs +49 -16
- package/package.json +4 -3
package/dist/expo/index.cjs
CHANGED
|
@@ -7633,14 +7633,27 @@ function validate2(parsed, newContent, validIds) {
|
|
|
7633
7633
|
const c2 = typeof obj.content === "string" ? obj.content.trim() : "";
|
|
7634
7634
|
return { action: "create", content: c2.length > 0 ? c2 : newContent };
|
|
7635
7635
|
}
|
|
7636
|
-
const targetId = typeof obj.targetId === "string" ? obj.targetId : null;
|
|
7637
|
-
if (!targetId || !validIds.has(targetId)) return null;
|
|
7638
7636
|
if (action === "noop") {
|
|
7639
|
-
|
|
7637
|
+
const targetId2 = typeof obj.targetId === "string" ? obj.targetId : null;
|
|
7638
|
+
if (!targetId2 || !validIds.has(targetId2)) return null;
|
|
7639
|
+
return { action: "noop", targetId: targetId2 };
|
|
7640
7640
|
}
|
|
7641
7641
|
const c = typeof obj.content === "string" ? obj.content.trim() : "";
|
|
7642
7642
|
if (c.length === 0) return null;
|
|
7643
|
-
|
|
7643
|
+
if (action === "supersede") {
|
|
7644
|
+
const rawIds = [
|
|
7645
|
+
...Array.isArray(obj.targetIds) ? obj.targetIds : [],
|
|
7646
|
+
...typeof obj.targetId === "string" ? [obj.targetId] : []
|
|
7647
|
+
];
|
|
7648
|
+
const targetIds = [
|
|
7649
|
+
...new Set(rawIds.filter((id) => typeof id === "string" && validIds.has(id)))
|
|
7650
|
+
];
|
|
7651
|
+
if (targetIds.length === 0) return null;
|
|
7652
|
+
return { action: "supersede", targetId: targetIds[0], targetIds, content: c };
|
|
7653
|
+
}
|
|
7654
|
+
const targetId = typeof obj.targetId === "string" ? obj.targetId : null;
|
|
7655
|
+
if (!targetId || !validIds.has(targetId)) return null;
|
|
7656
|
+
return { action: "update", targetId, content: c };
|
|
7644
7657
|
}
|
|
7645
7658
|
var DEFAULT_MODEL3, DEFAULT_CONSOLIDATE_ATTEMPTS, DEFAULT_CONSOLIDATE_TOTAL_TIMEOUT_MS, SYSTEM_PROMPT3;
|
|
7646
7659
|
var init_consolidate = __esm({
|
|
@@ -7660,7 +7673,7 @@ Decide one of four actions:
|
|
|
7660
7673
|
|
|
7661
7674
|
- "create": the new memory describes a distinct fact not covered by any existing memory. Write it as new.
|
|
7662
7675
|
- "update": the new memory describes the SAME FACET as exactly one existing memory and is COMPATIBLE with it \u2014 it adds detail, fixes an incomplete value, or rephrases the same still-true fact. Return targetId of that existing memory + the consolidated content (richest version of the two).
|
|
7663
|
-
- "supersede": the new memory REPLACES a standing fact whose value has CHANGED and is now INCOMPATIBLE with an existing memory \u2014 the old fact was true before but is false now (a state change). Return
|
|
7676
|
+
- "supersede": the new memory REPLACES a standing fact whose value has CHANGED and is now INCOMPATIBLE with an existing memory \u2014 the old fact was true before but is false now (a state change). Return "targetIds": an array of the ids of EVERY existing candidate that describes the SAME standing attribute now being changed \u2014 retire ALL stale duplicates of the old value, not just one (the candidate list may contain several paraphrases of the same old fact) + content = the NEW fact. The old memories are kept as history, not overwritten or deleted; do not re-state them.
|
|
7664
7677
|
- "noop": the new memory is already fully captured by an existing memory \u2014 same facet, no new information. Skip the write.
|
|
7665
7678
|
|
|
7666
7679
|
RULES (carry these strictly):
|
|
@@ -7676,14 +7689,15 @@ RULES (carry these strictly):
|
|
|
7676
7689
|
OUTPUT \u2014 strict JSON, no prose:
|
|
7677
7690
|
{
|
|
7678
7691
|
"action": "create" | "update" | "supersede" | "noop",
|
|
7679
|
-
"targetId": "<existing memory id \u2014 required for update/
|
|
7692
|
+
"targetId": "<existing memory id \u2014 required for update/noop, omit for create/supersede>",
|
|
7693
|
+
"targetIds": ["<id>", ...],
|
|
7680
7694
|
"content": "<content \u2014 required for create/update/supersede, omit for noop>"
|
|
7681
7695
|
}
|
|
7682
7696
|
|
|
7683
|
-
For "create": content is the new memory verbatim (or a slight refinement).
|
|
7684
|
-
For "update": content is the merged richest-version, \u226480 words.
|
|
7685
|
-
For "supersede": content is the NEW fact only (\u226480 words);
|
|
7686
|
-
For "noop": no content (existing memory is already correct).`;
|
|
7697
|
+
For "create": content is the new memory verbatim (or a slight refinement); omit targetId/targetIds.
|
|
7698
|
+
For "update": content is the merged richest-version, \u226480 words; targetId is the single memory to update.
|
|
7699
|
+
For "supersede": content is the NEW fact only (\u226480 words); "targetIds" lists EVERY stale memory being retired (all candidates describing the same now-changed attribute).
|
|
7700
|
+
For "noop": no content (existing memory is already correct); targetId is that memory.`;
|
|
7687
7701
|
}
|
|
7688
7702
|
});
|
|
7689
7703
|
|
|
@@ -8612,7 +8626,7 @@ var CompletionsStrategy = class {
|
|
|
8612
8626
|
model,
|
|
8613
8627
|
stream,
|
|
8614
8628
|
...temperature !== void 0 && { temperature },
|
|
8615
|
-
...maxOutputTokens !== void 0 && {
|
|
8629
|
+
...maxOutputTokens !== void 0 && { max_completion_tokens: maxOutputTokens },
|
|
8616
8630
|
...tools && { tools },
|
|
8617
8631
|
...toolChoice && { tool_choice: toolChoice },
|
|
8618
8632
|
...portal && { portal }
|
|
@@ -14001,14 +14015,15 @@ init_portalLlm();
|
|
|
14001
14015
|
|
|
14002
14016
|
// src/lib/memory/retain.ts
|
|
14003
14017
|
init_operations3();
|
|
14018
|
+
init_logger();
|
|
14004
14019
|
init_constants();
|
|
14005
14020
|
init_embeddings();
|
|
14006
14021
|
init_vector();
|
|
14007
14022
|
init_searchTool();
|
|
14008
|
-
var DEFAULT_AUTO_MERGE_THRESHOLD = 0.
|
|
14023
|
+
var DEFAULT_AUTO_MERGE_THRESHOLD = 0.8;
|
|
14009
14024
|
var DEFAULT_SCOPE = "private";
|
|
14010
|
-
var DEFAULT_CONSOLIDATE_THRESHOLD = 0.
|
|
14011
|
-
var DEFAULT_CONSOLIDATE_TOP_K =
|
|
14025
|
+
var DEFAULT_CONSOLIDATE_THRESHOLD = 0.55;
|
|
14026
|
+
var DEFAULT_CONSOLIDATE_TOP_K = 20;
|
|
14012
14027
|
async function retain(content, ctx, options = {}) {
|
|
14013
14028
|
const trimmed = content.trim();
|
|
14014
14029
|
if (trimmed.length === 0) {
|
|
@@ -14017,18 +14032,18 @@ async function retain(content, ctx, options = {}) {
|
|
|
14017
14032
|
const enableAutoMerge = options.enableAutoMerge ?? true;
|
|
14018
14033
|
const threshold = options.autoMergeThreshold ?? DEFAULT_AUTO_MERGE_THRESHOLD;
|
|
14019
14034
|
const resolvedScope = options.scope ?? DEFAULT_SCOPE;
|
|
14020
|
-
let
|
|
14035
|
+
let supersedeTargetIds = [];
|
|
14021
14036
|
let supersedeContent;
|
|
14022
14037
|
if (enableAutoMerge) {
|
|
14023
14038
|
if (options.consolidateOptions) {
|
|
14024
14039
|
const outcome = await tryConsolidate(trimmed, ctx, options);
|
|
14025
14040
|
if (outcome) {
|
|
14026
14041
|
if ("done" in outcome) return outcome.done;
|
|
14027
|
-
|
|
14042
|
+
supersedeTargetIds = outcome.supersede;
|
|
14028
14043
|
supersedeContent = outcome.content;
|
|
14029
14044
|
}
|
|
14030
14045
|
}
|
|
14031
|
-
if (
|
|
14046
|
+
if (supersedeTargetIds.length === 0) {
|
|
14032
14047
|
const matches = await searchVaultMemories(
|
|
14033
14048
|
trimmed,
|
|
14034
14049
|
ctx.vaultCtx,
|
|
@@ -14132,18 +14147,42 @@ async function retain(content, ctx, options = {}) {
|
|
|
14132
14147
|
// memory's tier. The DB op re-validates against the known set.
|
|
14133
14148
|
...options.trustTier !== void 0 && { trustTier: options.trustTier }
|
|
14134
14149
|
};
|
|
14135
|
-
if (
|
|
14150
|
+
if (supersedeTargetIds.length > 0) {
|
|
14151
|
+
const [primaryTargetId, ...restTargetIds] = supersedeTargetIds;
|
|
14136
14152
|
const { created: created2, retired } = await createSupersedingMemoryOp(
|
|
14137
14153
|
ctx.vaultCtx,
|
|
14138
14154
|
createOpts,
|
|
14139
|
-
|
|
14155
|
+
primaryTargetId
|
|
14140
14156
|
);
|
|
14141
14157
|
if (created2 && retired) {
|
|
14142
14158
|
ctx.vaultCache.set(created2.uniqueId, Float32Array.from(embedding));
|
|
14159
|
+
const liveLeftovers = [];
|
|
14160
|
+
for (const staleId of restTargetIds) {
|
|
14161
|
+
let ok = false;
|
|
14162
|
+
try {
|
|
14163
|
+
ok = await supersedeVaultMemoryOp(ctx.vaultCtx, staleId, created2.uniqueId) === true;
|
|
14164
|
+
} catch {
|
|
14165
|
+
}
|
|
14166
|
+
if (ok) continue;
|
|
14167
|
+
const stillLive = await getVaultMemoryOp(ctx.vaultCtx, staleId).catch(() => null);
|
|
14168
|
+
if (stillLive && !stillLive.supersededBy) liveLeftovers.push(staleId);
|
|
14169
|
+
}
|
|
14170
|
+
if (liveLeftovers.length > 0) {
|
|
14171
|
+
getLogger().warn(
|
|
14172
|
+
"[memory/retain] supersede left duplicate row(s) live \u2014 will reconcile at next consolidation",
|
|
14173
|
+
{
|
|
14174
|
+
newMemoryId: created2.uniqueId,
|
|
14175
|
+
leftover: liveLeftovers.length,
|
|
14176
|
+
// Log the specific ids (opaque record ids, not content) so an
|
|
14177
|
+
// operator can identify exactly which rows are still active.
|
|
14178
|
+
leftoverIds: liveLeftovers
|
|
14179
|
+
}
|
|
14180
|
+
);
|
|
14181
|
+
}
|
|
14143
14182
|
return {
|
|
14144
14183
|
action: "supersede",
|
|
14145
14184
|
memoryId: created2.uniqueId,
|
|
14146
|
-
targetId:
|
|
14185
|
+
targetId: primaryTargetId,
|
|
14147
14186
|
proofCount: 1
|
|
14148
14187
|
};
|
|
14149
14188
|
}
|
|
@@ -14229,10 +14268,16 @@ async function tryConsolidate(trimmed, ctx, options) {
|
|
|
14229
14268
|
const { consolidateMemory: doConsolidate } = await Promise.resolve().then(() => (init_consolidate(), consolidate_exports));
|
|
14230
14269
|
const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
|
|
14231
14270
|
if (decision.action === "create") return null;
|
|
14232
|
-
if (decision.action === "supersede" && decision.
|
|
14233
|
-
const
|
|
14234
|
-
if (
|
|
14235
|
-
|
|
14271
|
+
if (decision.action === "supersede" && decision.content) {
|
|
14272
|
+
const requestedIds = decision.targetIds?.length ? decision.targetIds : decision.targetId ? [decision.targetId] : [];
|
|
14273
|
+
if (requestedIds.length === 0) return null;
|
|
14274
|
+
const valid = [];
|
|
14275
|
+
for (const id of requestedIds) {
|
|
14276
|
+
const existing = await getVaultMemoryOp(ctx.vaultCtx, id);
|
|
14277
|
+
if (existing && !existing.supersededBy) valid.push(id);
|
|
14278
|
+
}
|
|
14279
|
+
if (valid.length === 0) return null;
|
|
14280
|
+
return { supersede: valid, content: decision.content };
|
|
14236
14281
|
}
|
|
14237
14282
|
if (decision.action === "noop" && decision.targetId) {
|
|
14238
14283
|
const existing = await getVaultMemoryOp(ctx.vaultCtx, decision.targetId);
|
|
@@ -15527,7 +15572,10 @@ ${evidence}`;
|
|
|
15527
15572
|
headers: { ...authHeaders, "Content-Type": "application/json" },
|
|
15528
15573
|
body: JSON.stringify({
|
|
15529
15574
|
model,
|
|
15530
|
-
|
|
15575
|
+
// Modern OpenAI field; the portal reads only `max_completion_tokens`
|
|
15576
|
+
// (the deprecated `max_tokens` is silently ignored → falls back to the
|
|
15577
|
+
// portal's default output cap and truncates the answer).
|
|
15578
|
+
max_completion_tokens: maxTokens,
|
|
15531
15579
|
messages: [
|
|
15532
15580
|
{ role: "system", content: systemPrompt },
|
|
15533
15581
|
{ role: "user", content: userMessage }
|
package/dist/expo/index.d.mts
CHANGED
|
@@ -580,6 +580,12 @@ type HandlersCreditBalanceResponse = {
|
|
|
580
580
|
* Total credits ever received (1 credit = $0.01)
|
|
581
581
|
*/
|
|
582
582
|
lifetime_credits: number;
|
|
583
|
+
/**
|
|
584
|
+
* NextResetDate is the next monthly credit refill date (ISO8601), keyed on the
|
|
585
|
+
* credit_expiry_day anchor — the same anchor the monthly claim uses, NOT the grant
|
|
586
|
+
* expires_at (which is anchor+1). Display-only; does not affect reset logic.
|
|
587
|
+
*/
|
|
588
|
+
next_reset_date?: string;
|
|
583
589
|
/**
|
|
584
590
|
* "basic" or "pro"
|
|
585
591
|
*/
|
package/dist/expo/index.d.ts
CHANGED
|
@@ -580,6 +580,12 @@ type HandlersCreditBalanceResponse = {
|
|
|
580
580
|
* Total credits ever received (1 credit = $0.01)
|
|
581
581
|
*/
|
|
582
582
|
lifetime_credits: number;
|
|
583
|
+
/**
|
|
584
|
+
* NextResetDate is the next monthly credit refill date (ISO8601), keyed on the
|
|
585
|
+
* credit_expiry_day anchor — the same anchor the monthly claim uses, NOT the grant
|
|
586
|
+
* expires_at (which is anchor+1). Display-only; does not affect reset logic.
|
|
587
|
+
*/
|
|
588
|
+
next_reset_date?: string;
|
|
583
589
|
/**
|
|
584
590
|
* "basic" or "pro"
|
|
585
591
|
*/
|
package/dist/expo/index.mjs
CHANGED
|
@@ -847,7 +847,7 @@ var CompletionsStrategy = class {
|
|
|
847
847
|
model,
|
|
848
848
|
stream,
|
|
849
849
|
...temperature !== void 0 && { temperature },
|
|
850
|
-
...maxOutputTokens !== void 0 && {
|
|
850
|
+
...maxOutputTokens !== void 0 && { max_completion_tokens: maxOutputTokens },
|
|
851
851
|
...tools && { tools },
|
|
852
852
|
...toolChoice && { tool_choice: toolChoice },
|
|
853
853
|
...portal && { portal }
|
|
@@ -6194,10 +6194,10 @@ function injectionSignatureCatalog() {
|
|
|
6194
6194
|
}
|
|
6195
6195
|
|
|
6196
6196
|
// src/lib/memory/retain.ts
|
|
6197
|
-
var DEFAULT_AUTO_MERGE_THRESHOLD = 0.
|
|
6197
|
+
var DEFAULT_AUTO_MERGE_THRESHOLD = 0.8;
|
|
6198
6198
|
var DEFAULT_SCOPE = "private";
|
|
6199
|
-
var DEFAULT_CONSOLIDATE_THRESHOLD = 0.
|
|
6200
|
-
var DEFAULT_CONSOLIDATE_TOP_K =
|
|
6199
|
+
var DEFAULT_CONSOLIDATE_THRESHOLD = 0.55;
|
|
6200
|
+
var DEFAULT_CONSOLIDATE_TOP_K = 20;
|
|
6201
6201
|
async function retain(content, ctx, options = {}) {
|
|
6202
6202
|
const trimmed = content.trim();
|
|
6203
6203
|
if (trimmed.length === 0) {
|
|
@@ -6206,18 +6206,18 @@ async function retain(content, ctx, options = {}) {
|
|
|
6206
6206
|
const enableAutoMerge = options.enableAutoMerge ?? true;
|
|
6207
6207
|
const threshold = options.autoMergeThreshold ?? DEFAULT_AUTO_MERGE_THRESHOLD;
|
|
6208
6208
|
const resolvedScope = options.scope ?? DEFAULT_SCOPE;
|
|
6209
|
-
let
|
|
6209
|
+
let supersedeTargetIds = [];
|
|
6210
6210
|
let supersedeContent;
|
|
6211
6211
|
if (enableAutoMerge) {
|
|
6212
6212
|
if (options.consolidateOptions) {
|
|
6213
6213
|
const outcome = await tryConsolidate(trimmed, ctx, options);
|
|
6214
6214
|
if (outcome) {
|
|
6215
6215
|
if ("done" in outcome) return outcome.done;
|
|
6216
|
-
|
|
6216
|
+
supersedeTargetIds = outcome.supersede;
|
|
6217
6217
|
supersedeContent = outcome.content;
|
|
6218
6218
|
}
|
|
6219
6219
|
}
|
|
6220
|
-
if (
|
|
6220
|
+
if (supersedeTargetIds.length === 0) {
|
|
6221
6221
|
const matches = await searchVaultMemories(
|
|
6222
6222
|
trimmed,
|
|
6223
6223
|
ctx.vaultCtx,
|
|
@@ -6321,18 +6321,42 @@ async function retain(content, ctx, options = {}) {
|
|
|
6321
6321
|
// memory's tier. The DB op re-validates against the known set.
|
|
6322
6322
|
...options.trustTier !== void 0 && { trustTier: options.trustTier }
|
|
6323
6323
|
};
|
|
6324
|
-
if (
|
|
6324
|
+
if (supersedeTargetIds.length > 0) {
|
|
6325
|
+
const [primaryTargetId, ...restTargetIds] = supersedeTargetIds;
|
|
6325
6326
|
const { created: created2, retired } = await createSupersedingMemoryOp(
|
|
6326
6327
|
ctx.vaultCtx,
|
|
6327
6328
|
createOpts,
|
|
6328
|
-
|
|
6329
|
+
primaryTargetId
|
|
6329
6330
|
);
|
|
6330
6331
|
if (created2 && retired) {
|
|
6331
6332
|
ctx.vaultCache.set(created2.uniqueId, Float32Array.from(embedding));
|
|
6333
|
+
const liveLeftovers = [];
|
|
6334
|
+
for (const staleId of restTargetIds) {
|
|
6335
|
+
let ok = false;
|
|
6336
|
+
try {
|
|
6337
|
+
ok = await supersedeVaultMemoryOp(ctx.vaultCtx, staleId, created2.uniqueId) === true;
|
|
6338
|
+
} catch {
|
|
6339
|
+
}
|
|
6340
|
+
if (ok) continue;
|
|
6341
|
+
const stillLive = await getVaultMemoryOp(ctx.vaultCtx, staleId).catch(() => null);
|
|
6342
|
+
if (stillLive && !stillLive.supersededBy) liveLeftovers.push(staleId);
|
|
6343
|
+
}
|
|
6344
|
+
if (liveLeftovers.length > 0) {
|
|
6345
|
+
getLogger().warn(
|
|
6346
|
+
"[memory/retain] supersede left duplicate row(s) live \u2014 will reconcile at next consolidation",
|
|
6347
|
+
{
|
|
6348
|
+
newMemoryId: created2.uniqueId,
|
|
6349
|
+
leftover: liveLeftovers.length,
|
|
6350
|
+
// Log the specific ids (opaque record ids, not content) so an
|
|
6351
|
+
// operator can identify exactly which rows are still active.
|
|
6352
|
+
leftoverIds: liveLeftovers
|
|
6353
|
+
}
|
|
6354
|
+
);
|
|
6355
|
+
}
|
|
6332
6356
|
return {
|
|
6333
6357
|
action: "supersede",
|
|
6334
6358
|
memoryId: created2.uniqueId,
|
|
6335
|
-
targetId:
|
|
6359
|
+
targetId: primaryTargetId,
|
|
6336
6360
|
proofCount: 1
|
|
6337
6361
|
};
|
|
6338
6362
|
}
|
|
@@ -6415,13 +6439,19 @@ async function tryConsolidate(trimmed, ctx, options) {
|
|
|
6415
6439
|
content: m.content,
|
|
6416
6440
|
similarity: m.similarity
|
|
6417
6441
|
}));
|
|
6418
|
-
const { consolidateMemory: doConsolidate } = await import("./consolidate-
|
|
6442
|
+
const { consolidateMemory: doConsolidate } = await import("./consolidate-HKN32P5W.mjs");
|
|
6419
6443
|
const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
|
|
6420
6444
|
if (decision.action === "create") return null;
|
|
6421
|
-
if (decision.action === "supersede" && decision.
|
|
6422
|
-
const
|
|
6423
|
-
if (
|
|
6424
|
-
|
|
6445
|
+
if (decision.action === "supersede" && decision.content) {
|
|
6446
|
+
const requestedIds = decision.targetIds?.length ? decision.targetIds : decision.targetId ? [decision.targetId] : [];
|
|
6447
|
+
if (requestedIds.length === 0) return null;
|
|
6448
|
+
const valid = [];
|
|
6449
|
+
for (const id of requestedIds) {
|
|
6450
|
+
const existing = await getVaultMemoryOp(ctx.vaultCtx, id);
|
|
6451
|
+
if (existing && !existing.supersededBy) valid.push(id);
|
|
6452
|
+
}
|
|
6453
|
+
if (valid.length === 0) return null;
|
|
6454
|
+
return { supersede: valid, content: decision.content };
|
|
6425
6455
|
}
|
|
6426
6456
|
if (decision.action === "noop" && decision.targetId) {
|
|
6427
6457
|
const existing = await getVaultMemoryOp(ctx.vaultCtx, decision.targetId);
|
|
@@ -7692,7 +7722,10 @@ ${evidence}`;
|
|
|
7692
7722
|
headers: { ...authHeaders, "Content-Type": "application/json" },
|
|
7693
7723
|
body: JSON.stringify({
|
|
7694
7724
|
model,
|
|
7695
|
-
|
|
7725
|
+
// Modern OpenAI field; the portal reads only `max_completion_tokens`
|
|
7726
|
+
// (the deprecated `max_tokens` is silently ignored → falls back to the
|
|
7727
|
+
// portal's default output cap and truncates the answer).
|
|
7728
|
+
max_completion_tokens: maxTokens,
|
|
7696
7729
|
messages: [
|
|
7697
7730
|
{ role: "system", content: systemPrompt },
|
|
7698
7731
|
{ role: "user", content: userMessage }
|
package/dist/index.d.mts
CHANGED
|
@@ -1729,6 +1729,12 @@ type HandlersCreditBalanceResponse = {
|
|
|
1729
1729
|
* Total credits ever received (1 credit = $0.01)
|
|
1730
1730
|
*/
|
|
1731
1731
|
lifetime_credits: number;
|
|
1732
|
+
/**
|
|
1733
|
+
* NextResetDate is the next monthly credit refill date (ISO8601), keyed on the
|
|
1734
|
+
* credit_expiry_day anchor — the same anchor the monthly claim uses, NOT the grant
|
|
1735
|
+
* expires_at (which is anchor+1). Display-only; does not affect reset logic.
|
|
1736
|
+
*/
|
|
1737
|
+
next_reset_date?: string;
|
|
1732
1738
|
/**
|
|
1733
1739
|
* "basic" or "pro"
|
|
1734
1740
|
*/
|
|
@@ -2130,13 +2136,22 @@ type HandlersSetSubscriptionTierRequest = {
|
|
|
2130
2136
|
*/
|
|
2131
2137
|
app_id?: number;
|
|
2132
2138
|
/**
|
|
2133
|
-
* "
|
|
2139
|
+
* "month" or "year"; ignored for basic
|
|
2140
|
+
*/
|
|
2141
|
+
interval?: string;
|
|
2142
|
+
/**
|
|
2143
|
+
* "basic", "starter", or "pro"
|
|
2134
2144
|
*/
|
|
2135
2145
|
tier?: string;
|
|
2136
2146
|
user_address?: string;
|
|
2137
2147
|
};
|
|
2138
2148
|
type HandlersSetSubscriptionTierResponse = {
|
|
2149
|
+
changed?: boolean;
|
|
2150
|
+
interval?: string;
|
|
2139
2151
|
message?: string;
|
|
2152
|
+
scheduled_interval?: string;
|
|
2153
|
+
scheduled_tier?: string;
|
|
2154
|
+
status: string;
|
|
2140
2155
|
success: boolean;
|
|
2141
2156
|
tier: string;
|
|
2142
2157
|
user_address: string;
|
|
@@ -2461,8 +2476,10 @@ type HandlersUserLookupEnrollment = {
|
|
|
2461
2476
|
created_at?: string;
|
|
2462
2477
|
id?: number;
|
|
2463
2478
|
lifetime_credits?: number;
|
|
2479
|
+
payment_provider?: string;
|
|
2464
2480
|
pro_activated_at?: string;
|
|
2465
2481
|
starter_activated_at?: string;
|
|
2482
|
+
subscription_source?: string;
|
|
2466
2483
|
subscription_tier?: string;
|
|
2467
2484
|
updated_at?: string;
|
|
2468
2485
|
};
|
|
@@ -2482,7 +2499,10 @@ type HandlersUserLookupResponse = {
|
|
|
2482
2499
|
account?: HandlersUserLookupAccount;
|
|
2483
2500
|
enrollments?: Array<HandlersUserLookupEnrollment>;
|
|
2484
2501
|
portal_account_exists?: boolean;
|
|
2502
|
+
primary_app_id?: number;
|
|
2485
2503
|
privy?: HandlersUserLookupPrivy;
|
|
2504
|
+
subscription?: HandlersSubscriptionStatusResponse;
|
|
2505
|
+
subscription_error?: string;
|
|
2486
2506
|
text_registrations?: Array<HandlersUserLookupTextReg>;
|
|
2487
2507
|
};
|
|
2488
2508
|
type HandlersUserLookupTextReg = {
|
|
@@ -4321,14 +4341,30 @@ type PostApiV1AdminSubscriptionTierErrors = {
|
|
|
4321
4341
|
* Unauthorized
|
|
4322
4342
|
*/
|
|
4323
4343
|
401: ResponseErrorResponse;
|
|
4344
|
+
/**
|
|
4345
|
+
* Payment Required
|
|
4346
|
+
*/
|
|
4347
|
+
402: ResponseErrorResponse;
|
|
4324
4348
|
/**
|
|
4325
4349
|
* Not Found
|
|
4326
4350
|
*/
|
|
4327
4351
|
404: ResponseErrorResponse;
|
|
4352
|
+
/**
|
|
4353
|
+
* Conflict
|
|
4354
|
+
*/
|
|
4355
|
+
409: ResponseErrorResponse;
|
|
4328
4356
|
/**
|
|
4329
4357
|
* Internal Server Error
|
|
4330
4358
|
*/
|
|
4331
4359
|
500: ResponseErrorResponse;
|
|
4360
|
+
/**
|
|
4361
|
+
* Bad Gateway
|
|
4362
|
+
*/
|
|
4363
|
+
502: ResponseErrorResponse;
|
|
4364
|
+
/**
|
|
4365
|
+
* Service Unavailable
|
|
4366
|
+
*/
|
|
4367
|
+
503: ResponseErrorResponse;
|
|
4332
4368
|
};
|
|
4333
4369
|
type PostApiV1AdminSubscriptionTierError = PostApiV1AdminSubscriptionTierErrors[keyof PostApiV1AdminSubscriptionTierErrors];
|
|
4334
4370
|
type PostApiV1AdminSubscriptionTierResponses = {
|
|
@@ -6704,7 +6740,7 @@ declare const postApiV1AdminSeedApps: <ThrowOnError extends boolean = false>(opt
|
|
|
6704
6740
|
/**
|
|
6705
6741
|
* Set user subscription tier
|
|
6706
6742
|
*
|
|
6707
|
-
*
|
|
6743
|
+
* Updates an existing Stripe subscription. Upgrades apply immediately, downgrades and basic-tier cancellations apply at period end. RevenueCat/staking users and users without an active Stripe subscription are rejected. Requires admin API key.
|
|
6708
6744
|
*/
|
|
6709
6745
|
declare const postApiV1AdminSubscriptionTier: <ThrowOnError extends boolean = false>(options: Options<PostApiV1AdminSubscriptionTierData, ThrowOnError>) => RequestResult<PostApiV1AdminSubscriptionTierResponses, PostApiV1AdminSubscriptionTierErrors, ThrowOnError>;
|
|
6710
6746
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1729,6 +1729,12 @@ type HandlersCreditBalanceResponse = {
|
|
|
1729
1729
|
* Total credits ever received (1 credit = $0.01)
|
|
1730
1730
|
*/
|
|
1731
1731
|
lifetime_credits: number;
|
|
1732
|
+
/**
|
|
1733
|
+
* NextResetDate is the next monthly credit refill date (ISO8601), keyed on the
|
|
1734
|
+
* credit_expiry_day anchor — the same anchor the monthly claim uses, NOT the grant
|
|
1735
|
+
* expires_at (which is anchor+1). Display-only; does not affect reset logic.
|
|
1736
|
+
*/
|
|
1737
|
+
next_reset_date?: string;
|
|
1732
1738
|
/**
|
|
1733
1739
|
* "basic" or "pro"
|
|
1734
1740
|
*/
|
|
@@ -2130,13 +2136,22 @@ type HandlersSetSubscriptionTierRequest = {
|
|
|
2130
2136
|
*/
|
|
2131
2137
|
app_id?: number;
|
|
2132
2138
|
/**
|
|
2133
|
-
* "
|
|
2139
|
+
* "month" or "year"; ignored for basic
|
|
2140
|
+
*/
|
|
2141
|
+
interval?: string;
|
|
2142
|
+
/**
|
|
2143
|
+
* "basic", "starter", or "pro"
|
|
2134
2144
|
*/
|
|
2135
2145
|
tier?: string;
|
|
2136
2146
|
user_address?: string;
|
|
2137
2147
|
};
|
|
2138
2148
|
type HandlersSetSubscriptionTierResponse = {
|
|
2149
|
+
changed?: boolean;
|
|
2150
|
+
interval?: string;
|
|
2139
2151
|
message?: string;
|
|
2152
|
+
scheduled_interval?: string;
|
|
2153
|
+
scheduled_tier?: string;
|
|
2154
|
+
status: string;
|
|
2140
2155
|
success: boolean;
|
|
2141
2156
|
tier: string;
|
|
2142
2157
|
user_address: string;
|
|
@@ -2461,8 +2476,10 @@ type HandlersUserLookupEnrollment = {
|
|
|
2461
2476
|
created_at?: string;
|
|
2462
2477
|
id?: number;
|
|
2463
2478
|
lifetime_credits?: number;
|
|
2479
|
+
payment_provider?: string;
|
|
2464
2480
|
pro_activated_at?: string;
|
|
2465
2481
|
starter_activated_at?: string;
|
|
2482
|
+
subscription_source?: string;
|
|
2466
2483
|
subscription_tier?: string;
|
|
2467
2484
|
updated_at?: string;
|
|
2468
2485
|
};
|
|
@@ -2482,7 +2499,10 @@ type HandlersUserLookupResponse = {
|
|
|
2482
2499
|
account?: HandlersUserLookupAccount;
|
|
2483
2500
|
enrollments?: Array<HandlersUserLookupEnrollment>;
|
|
2484
2501
|
portal_account_exists?: boolean;
|
|
2502
|
+
primary_app_id?: number;
|
|
2485
2503
|
privy?: HandlersUserLookupPrivy;
|
|
2504
|
+
subscription?: HandlersSubscriptionStatusResponse;
|
|
2505
|
+
subscription_error?: string;
|
|
2486
2506
|
text_registrations?: Array<HandlersUserLookupTextReg>;
|
|
2487
2507
|
};
|
|
2488
2508
|
type HandlersUserLookupTextReg = {
|
|
@@ -4321,14 +4341,30 @@ type PostApiV1AdminSubscriptionTierErrors = {
|
|
|
4321
4341
|
* Unauthorized
|
|
4322
4342
|
*/
|
|
4323
4343
|
401: ResponseErrorResponse;
|
|
4344
|
+
/**
|
|
4345
|
+
* Payment Required
|
|
4346
|
+
*/
|
|
4347
|
+
402: ResponseErrorResponse;
|
|
4324
4348
|
/**
|
|
4325
4349
|
* Not Found
|
|
4326
4350
|
*/
|
|
4327
4351
|
404: ResponseErrorResponse;
|
|
4352
|
+
/**
|
|
4353
|
+
* Conflict
|
|
4354
|
+
*/
|
|
4355
|
+
409: ResponseErrorResponse;
|
|
4328
4356
|
/**
|
|
4329
4357
|
* Internal Server Error
|
|
4330
4358
|
*/
|
|
4331
4359
|
500: ResponseErrorResponse;
|
|
4360
|
+
/**
|
|
4361
|
+
* Bad Gateway
|
|
4362
|
+
*/
|
|
4363
|
+
502: ResponseErrorResponse;
|
|
4364
|
+
/**
|
|
4365
|
+
* Service Unavailable
|
|
4366
|
+
*/
|
|
4367
|
+
503: ResponseErrorResponse;
|
|
4332
4368
|
};
|
|
4333
4369
|
type PostApiV1AdminSubscriptionTierError = PostApiV1AdminSubscriptionTierErrors[keyof PostApiV1AdminSubscriptionTierErrors];
|
|
4334
4370
|
type PostApiV1AdminSubscriptionTierResponses = {
|
|
@@ -6704,7 +6740,7 @@ declare const postApiV1AdminSeedApps: <ThrowOnError extends boolean = false>(opt
|
|
|
6704
6740
|
/**
|
|
6705
6741
|
* Set user subscription tier
|
|
6706
6742
|
*
|
|
6707
|
-
*
|
|
6743
|
+
* Updates an existing Stripe subscription. Upgrades apply immediately, downgrades and basic-tier cancellations apply at period end. RevenueCat/staking users and users without an active Stripe subscription are rejected. Requires admin API key.
|
|
6708
6744
|
*/
|
|
6709
6745
|
declare const postApiV1AdminSubscriptionTier: <ThrowOnError extends boolean = false>(options: Options<PostApiV1AdminSubscriptionTierData, ThrowOnError>) => RequestResult<PostApiV1AdminSubscriptionTierResponses, PostApiV1AdminSubscriptionTierErrors, ThrowOnError>;
|
|
6710
6746
|
/**
|
|
@@ -5641,7 +5641,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
5641
5641
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
5642
5642
|
);
|
|
5643
5643
|
}
|
|
5644
|
-
const { recall: recall2 } = await import("./recall-
|
|
5644
|
+
const { recall: recall2 } = await import("./recall-CCA4VTDK.mjs");
|
|
5645
5645
|
const result = await recall2(
|
|
5646
5646
|
query,
|
|
5647
5647
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
|
@@ -19,7 +19,7 @@ Decide one of four actions:
|
|
|
19
19
|
|
|
20
20
|
- "create": the new memory describes a distinct fact not covered by any existing memory. Write it as new.
|
|
21
21
|
- "update": the new memory describes the SAME FACET as exactly one existing memory and is COMPATIBLE with it \u2014 it adds detail, fixes an incomplete value, or rephrases the same still-true fact. Return targetId of that existing memory + the consolidated content (richest version of the two).
|
|
22
|
-
- "supersede": the new memory REPLACES a standing fact whose value has CHANGED and is now INCOMPATIBLE with an existing memory \u2014 the old fact was true before but is false now (a state change). Return
|
|
22
|
+
- "supersede": the new memory REPLACES a standing fact whose value has CHANGED and is now INCOMPATIBLE with an existing memory \u2014 the old fact was true before but is false now (a state change). Return "targetIds": an array of the ids of EVERY existing candidate that describes the SAME standing attribute now being changed \u2014 retire ALL stale duplicates of the old value, not just one (the candidate list may contain several paraphrases of the same old fact) + content = the NEW fact. The old memories are kept as history, not overwritten or deleted; do not re-state them.
|
|
23
23
|
- "noop": the new memory is already fully captured by an existing memory \u2014 same facet, no new information. Skip the write.
|
|
24
24
|
|
|
25
25
|
RULES (carry these strictly):
|
|
@@ -35,14 +35,15 @@ RULES (carry these strictly):
|
|
|
35
35
|
OUTPUT \u2014 strict JSON, no prose:
|
|
36
36
|
{
|
|
37
37
|
"action": "create" | "update" | "supersede" | "noop",
|
|
38
|
-
"targetId": "<existing memory id \u2014 required for update/
|
|
38
|
+
"targetId": "<existing memory id \u2014 required for update/noop, omit for create/supersede>",
|
|
39
|
+
"targetIds": ["<id>", ...],
|
|
39
40
|
"content": "<content \u2014 required for create/update/supersede, omit for noop>"
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
For "create": content is the new memory verbatim (or a slight refinement).
|
|
43
|
-
For "update": content is the merged richest-version, \u226480 words.
|
|
44
|
-
For "supersede": content is the NEW fact only (\u226480 words);
|
|
45
|
-
For "noop": no content (existing memory is already correct).`;
|
|
43
|
+
For "create": content is the new memory verbatim (or a slight refinement); omit targetId/targetIds.
|
|
44
|
+
For "update": content is the merged richest-version, \u226480 words; targetId is the single memory to update.
|
|
45
|
+
For "supersede": content is the NEW fact only (\u226480 words); "targetIds" lists EVERY stale memory being retired (all candidates describing the same now-changed attribute).
|
|
46
|
+
For "noop": no content (existing memory is already correct); targetId is that memory.`;
|
|
46
47
|
async function consolidateMemory(newContent, candidates, options) {
|
|
47
48
|
const fallback = {
|
|
48
49
|
action: "create",
|
|
@@ -123,14 +124,27 @@ function validate(parsed, newContent, validIds) {
|
|
|
123
124
|
const c2 = typeof obj.content === "string" ? obj.content.trim() : "";
|
|
124
125
|
return { action: "create", content: c2.length > 0 ? c2 : newContent };
|
|
125
126
|
}
|
|
126
|
-
const targetId = typeof obj.targetId === "string" ? obj.targetId : null;
|
|
127
|
-
if (!targetId || !validIds.has(targetId)) return null;
|
|
128
127
|
if (action === "noop") {
|
|
129
|
-
|
|
128
|
+
const targetId2 = typeof obj.targetId === "string" ? obj.targetId : null;
|
|
129
|
+
if (!targetId2 || !validIds.has(targetId2)) return null;
|
|
130
|
+
return { action: "noop", targetId: targetId2 };
|
|
130
131
|
}
|
|
131
132
|
const c = typeof obj.content === "string" ? obj.content.trim() : "";
|
|
132
133
|
if (c.length === 0) return null;
|
|
133
|
-
|
|
134
|
+
if (action === "supersede") {
|
|
135
|
+
const rawIds = [
|
|
136
|
+
...Array.isArray(obj.targetIds) ? obj.targetIds : [],
|
|
137
|
+
...typeof obj.targetId === "string" ? [obj.targetId] : []
|
|
138
|
+
];
|
|
139
|
+
const targetIds = [
|
|
140
|
+
...new Set(rawIds.filter((id) => typeof id === "string" && validIds.has(id)))
|
|
141
|
+
];
|
|
142
|
+
if (targetIds.length === 0) return null;
|
|
143
|
+
return { action: "supersede", targetId: targetIds[0], targetIds, content: c };
|
|
144
|
+
}
|
|
145
|
+
const targetId = typeof obj.targetId === "string" ? obj.targetId : null;
|
|
146
|
+
if (!targetId || !validIds.has(targetId)) return null;
|
|
147
|
+
return { action: "update", targetId, content: c };
|
|
134
148
|
}
|
|
135
149
|
export {
|
|
136
150
|
consolidateMemory
|