@jungjaehoon/mama-core 1.5.0 → 1.7.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/README.md +48 -10
- package/db/migrations/032-add-memory-provenance-columns.sql +21 -0
- package/db/migrations/033-create-model-runs-and-tool-traces.sql +53 -0
- package/db/migrations/034-add-connector-event-scope-columns.sql +14 -0
- package/db/migrations/035-create-twin-edges.sql +63 -0
- package/db/migrations/036-create-agent-situation-packets.sql +61 -0
- package/db/migrations/037-create-context-packets.sql +32 -0
- package/dist/agent-graph/alias-write.d.ts +3 -0
- package/dist/agent-graph/alias-write.js +231 -0
- package/dist/agent-graph/entity-resolve.d.ts +3 -0
- package/dist/agent-graph/entity-resolve.js +275 -0
- package/dist/agent-graph/errors.d.ts +4 -0
- package/dist/agent-graph/errors.js +11 -0
- package/dist/agent-graph/graph-query.d.ts +5 -0
- package/dist/agent-graph/graph-query.js +359 -0
- package/dist/agent-graph/index.d.ts +6 -0
- package/dist/agent-graph/index.js +22 -0
- package/dist/agent-graph/types.d.ts +162 -0
- package/dist/agent-graph/types.js +3 -0
- package/dist/agent-situation/builder.d.ts +8 -0
- package/dist/agent-situation/builder.js +239 -0
- package/dist/agent-situation/cache-key.d.ts +4 -0
- package/dist/agent-situation/cache-key.js +64 -0
- package/dist/agent-situation/index.d.ts +7 -0
- package/dist/agent-situation/index.js +28 -0
- package/dist/agent-situation/packet-store.d.ts +27 -0
- package/dist/agent-situation/packet-store.js +228 -0
- package/dist/agent-situation/ranking-policy.d.ts +18 -0
- package/dist/agent-situation/ranking-policy.js +75 -0
- package/dist/agent-situation/source-readers.d.ts +52 -0
- package/dist/agent-situation/source-readers.js +300 -0
- package/dist/agent-situation/types.d.ts +195 -0
- package/dist/agent-situation/types.js +3 -0
- package/dist/cases/search-rollup.d.ts +4 -0
- package/dist/cases/search-rollup.js +84 -0
- package/dist/cases/wiki-page-index.js +6 -2
- package/dist/connectors/event-index.d.ts +1 -0
- package/dist/connectors/event-index.js +19 -4
- package/dist/connectors/raw-query.d.ts +18 -0
- package/dist/connectors/raw-query.js +305 -0
- package/dist/connectors/types.d.ts +40 -0
- package/dist/context-compile/boundary-defaults.d.ts +12 -0
- package/dist/context-compile/boundary-defaults.js +105 -0
- package/dist/context-compile/compiler-policy.d.ts +39 -0
- package/dist/context-compile/compiler-policy.js +147 -0
- package/dist/context-compile/compiler.d.ts +18 -0
- package/dist/context-compile/compiler.js +401 -0
- package/dist/context-compile/index.d.ts +9 -0
- package/dist/context-compile/index.js +25 -0
- package/dist/context-compile/packet-store.d.ts +9 -0
- package/dist/context-compile/packet-store.js +255 -0
- package/dist/context-compile/ref.d.ts +7 -0
- package/dist/context-compile/ref.js +102 -0
- package/dist/context-compile/source-readers.d.ts +69 -0
- package/dist/context-compile/source-readers.js +707 -0
- package/dist/context-compile/types.d.ts +138 -0
- package/dist/context-compile/types.js +11 -0
- package/dist/context-compile/visibility.d.ts +21 -0
- package/dist/context-compile/visibility.js +200 -0
- package/dist/db-adapter/node-sqlite-adapter.d.ts +9 -0
- package/dist/db-adapter/node-sqlite-adapter.js +207 -0
- package/dist/db-manager.d.ts +8 -1
- package/dist/db-manager.js +53 -5
- package/dist/edges/ref-validation.d.ts +8 -0
- package/dist/edges/ref-validation.js +301 -0
- package/dist/edges/store.d.ts +10 -0
- package/dist/edges/store.js +343 -0
- package/dist/edges/types.d.ts +88 -0
- package/dist/edges/types.js +18 -0
- package/dist/embeddings.d.ts +3 -0
- package/dist/embeddings.js +49 -9
- package/dist/entities/store.d.ts +4 -1
- package/dist/entities/store.js +206 -78
- package/dist/entities/types.d.ts +5 -1
- package/dist/entities/types.js +1 -1
- package/dist/index.d.ts +18 -3
- package/dist/index.js +54 -4
- package/dist/mama-api.d.ts +32 -35
- package/dist/mama-api.js +173 -22
- package/dist/memory/api.d.ts +17 -56
- package/dist/memory/api.js +494 -52
- package/dist/memory/event-store.d.ts +3 -0
- package/dist/memory/event-store.js +21 -2
- package/dist/memory/provenance-audit.d.ts +22 -0
- package/dist/memory/provenance-audit.js +112 -0
- package/dist/memory/provenance-query.d.ts +11 -0
- package/dist/memory/provenance-query.js +193 -0
- package/dist/memory/provenance.d.ts +29 -0
- package/dist/memory/provenance.js +137 -0
- package/dist/memory/scope-backfill.d.ts +17 -0
- package/dist/memory/scope-backfill.js +77 -0
- package/dist/memory/types.d.ts +87 -14
- package/dist/model-runs/store.d.ts +13 -0
- package/dist/model-runs/store.js +457 -0
- package/dist/model-runs/tool-trace-store.d.ts +4 -0
- package/dist/model-runs/tool-trace-store.js +114 -0
- package/dist/model-runs/types.d.ts +69 -0
- package/dist/model-runs/types.js +5 -0
- package/dist/runtime/trusted-provenance.d.ts +3 -0
- package/dist/runtime/trusted-provenance.js +6 -0
- package/dist/search/search-quality.d.ts +36 -0
- package/dist/search/search-quality.js +29 -0
- package/package.json +11 -3
package/dist/mama-api.d.ts
CHANGED
|
@@ -19,9 +19,14 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { DecisionRecord } from './db-manager.js';
|
|
21
21
|
import { SemanticEdges } from './decision-formatter.js';
|
|
22
|
-
import { saveMemory, recallMemory, buildProfile, ingestMemory, evolveMemory, buildMemoryBootstrap, createAuditAck, recordMemoryAudit, upsertChannelSummary, getChannelSummary } from './memory/api.js';
|
|
22
|
+
import { saveMemory, saveMemoryWithTrustedProvenance, recallMemory, buildProfile, ingestMemory, ingestWithTrustedProvenance, ingestConversation, ingestConversationWithTrustedProvenance, evolveMemory, buildMemoryBootstrap, createAuditAck, recordMemoryAudit, upsertChannelSummary, getChannelSummary } from './memory/api.js';
|
|
23
23
|
import { listOpenAuditFindings } from './memory/finding-store.js';
|
|
24
|
-
import { listRecentMemoryEvents } from './memory/event-store.js';
|
|
24
|
+
import { listMemoryEventsForMemory, listRecentMemoryEvents } from './memory/event-store.js';
|
|
25
|
+
import type { TrustedMemoryWriteOptions } from './memory/provenance.js';
|
|
26
|
+
import { getMemoryProvenance, listMemoriesByEnvelopeHash, listMemoriesByGatewayCallId, listMemoriesByModelRunId } from './memory/provenance-query.js';
|
|
27
|
+
import { beginModelRun, beginModelRunInAdapter, commitModelRun, commitModelRunInAdapter, failModelRun, failModelRunInAdapter, getModelRun, getModelRunInAdapter } from './model-runs/store.js';
|
|
28
|
+
import { appendToolTrace, listToolTracesForRun } from './model-runs/tool-trace-store.js';
|
|
29
|
+
import { type SearchHitDiagnostics, type SearchQualityOptions } from './search/search-quality.js';
|
|
25
30
|
/**
|
|
26
31
|
* Parameters for mama.save()
|
|
27
32
|
*/
|
|
@@ -68,6 +73,7 @@ interface SimilarDecision {
|
|
|
68
73
|
created_at?: number | string;
|
|
69
74
|
event_date?: string | null;
|
|
70
75
|
event_datetime?: number | null;
|
|
76
|
+
retrieval_diagnostics?: SearchHitDiagnostics;
|
|
71
77
|
}
|
|
72
78
|
/**
|
|
73
79
|
* Search result from mama.search()
|
|
@@ -397,34 +403,6 @@ export interface QualityReport {
|
|
|
397
403
|
meetsTarget: boolean;
|
|
398
404
|
};
|
|
399
405
|
}
|
|
400
|
-
/**
|
|
401
|
-
* Save a decision or insight to MAMA's memory
|
|
402
|
-
*
|
|
403
|
-
* Simple API for Claude to save insights without complex configuration
|
|
404
|
-
* AC #1: Simple API - no complex configuration required
|
|
405
|
-
*
|
|
406
|
-
* @param {Object} params - Decision parameters
|
|
407
|
-
* @param {string} params.topic - Decision topic (e.g., 'auth_strategy', 'date_format')
|
|
408
|
-
* @param {string} params.decision - The decision made (e.g., 'JWT', 'ISO 8601 + Unix')
|
|
409
|
-
* @param {string} params.reasoning - Why this decision was made
|
|
410
|
-
* @param {number} [params.confidence=0.5] - Confidence score 0.0-1.0 (optional)
|
|
411
|
-
* @param {string} [params.type='user_decision'] - 'user_decision' or 'assistant_insight' (optional)
|
|
412
|
-
* @param {string} [params.outcome='pending'] - 'pending', 'success', 'failure', 'partial', 'superseded' (optional)
|
|
413
|
-
* @param {string} [params.failure_reason] - Why this decision failed (optional, used with outcome='failure')
|
|
414
|
-
* @param {string} [params.limitation] - Known limitations of this decision (optional)
|
|
415
|
-
* @returns {Promise<{success: boolean, id: string, similar_decisions?: Array, warning?: string, collaboration_hint?: string, reasoning_graph?: Object}>} Save result with decision ID and metadata
|
|
416
|
-
*
|
|
417
|
-
* @example
|
|
418
|
-
* const decisionId = await mama.save({
|
|
419
|
-
* topic: 'date_calculation_format',
|
|
420
|
-
* decision: 'Support both ISO 8601 and Unix timestamp formats',
|
|
421
|
-
* reasoning: 'Bootstrap data stored as ISO 8601 causing NaN errors',
|
|
422
|
-
* confidence: 0.95,
|
|
423
|
-
* type: 'assistant_insight',
|
|
424
|
-
* outcome: 'success'
|
|
425
|
-
* });
|
|
426
|
-
*/
|
|
427
|
-
declare function save({ topic, decision, reasoning, confidence, type, outcome, failure_reason, limitation, trust_context: _trust_context, is_static, scopes: inputScopes, event_date, timelineEvent, }: SaveParams): Promise<SaveResult>;
|
|
428
406
|
/**
|
|
429
407
|
* Recall decisions by topic
|
|
430
408
|
*
|
|
@@ -573,23 +551,22 @@ declare function expandWithGraph(candidates: SearchCandidate[]): Promise<SearchC
|
|
|
573
551
|
* const markdown = await mama.suggest('mesh optimization', { format: 'markdown' });
|
|
574
552
|
* // → "💡 MAMA found 3 related topics:\n1. ..."
|
|
575
553
|
*/
|
|
576
|
-
interface SuggestFunctionOptions {
|
|
554
|
+
interface SuggestFunctionOptions extends SearchQualityOptions {
|
|
577
555
|
format?: 'json' | 'markdown';
|
|
578
556
|
limit?: number;
|
|
579
|
-
threshold?: number;
|
|
580
557
|
useReranking?: boolean;
|
|
581
558
|
/** Phase 3 Task 33: apply learned offline ranker rescoring. */
|
|
582
559
|
rerankWithLearned?: boolean;
|
|
583
560
|
recencyWeight?: number;
|
|
584
561
|
recencyScale?: number;
|
|
585
562
|
recencyDecay?: number;
|
|
586
|
-
disableRecency?: boolean;
|
|
587
|
-
topicPrefix?: string;
|
|
588
563
|
scopes?: Array<{
|
|
589
564
|
kind: 'global' | 'user' | 'channel' | 'project';
|
|
590
565
|
id: string;
|
|
591
566
|
}>;
|
|
592
567
|
}
|
|
568
|
+
declare function save(params: SaveParams): Promise<SaveResult>;
|
|
569
|
+
declare function saveWithTrustedProvenance(params: SaveParams, options: TrustedMemoryWriteOptions): Promise<SaveResult>;
|
|
593
570
|
declare function suggest(userQuestion: string, options?: SuggestFunctionOptions): Promise<any>;
|
|
594
571
|
/**
|
|
595
572
|
* List recent decisions (all topics, chronological)
|
|
@@ -1050,14 +1027,19 @@ declare function generateQualityReport(options?: QualityReportOptions): string |
|
|
|
1050
1027
|
*/
|
|
1051
1028
|
declare const mama: {
|
|
1052
1029
|
save: typeof save;
|
|
1030
|
+
saveWithTrustedProvenance: typeof saveWithTrustedProvenance;
|
|
1053
1031
|
suggest: typeof suggest;
|
|
1054
1032
|
saveMemory: typeof saveMemory;
|
|
1033
|
+
saveMemoryWithTrustedProvenance: typeof saveMemoryWithTrustedProvenance;
|
|
1055
1034
|
recallMemory: typeof recallMemory;
|
|
1056
1035
|
list: typeof listDecisions;
|
|
1057
1036
|
listCheckpoints: typeof listCheckpoints;
|
|
1058
1037
|
updateOutcome: typeof updateOutcome;
|
|
1059
1038
|
buildProfile: typeof buildProfile;
|
|
1060
1039
|
ingestMemory: typeof ingestMemory;
|
|
1040
|
+
ingestWithTrustedProvenance: typeof ingestWithTrustedProvenance;
|
|
1041
|
+
ingestConversation: typeof ingestConversation;
|
|
1042
|
+
ingestConversationWithTrustedProvenance: typeof ingestConversationWithTrustedProvenance;
|
|
1061
1043
|
evolveMemory: typeof evolveMemory;
|
|
1062
1044
|
buildMemoryBootstrap: typeof buildMemoryBootstrap;
|
|
1063
1045
|
createAuditAck: typeof createAuditAck;
|
|
@@ -1065,7 +1047,22 @@ declare const mama: {
|
|
|
1065
1047
|
upsertChannelSummary: typeof upsertChannelSummary;
|
|
1066
1048
|
getChannelSummary: typeof getChannelSummary;
|
|
1067
1049
|
listAuditFindings: typeof listOpenAuditFindings;
|
|
1050
|
+
getMemoryProvenance: typeof getMemoryProvenance;
|
|
1051
|
+
listMemoriesByEnvelopeHash: typeof listMemoriesByEnvelopeHash;
|
|
1052
|
+
listMemoriesByGatewayCallId: typeof listMemoriesByGatewayCallId;
|
|
1053
|
+
listMemoriesByModelRunId: typeof listMemoriesByModelRunId;
|
|
1054
|
+
listMemoryEventsForMemory: typeof listMemoryEventsForMemory;
|
|
1068
1055
|
listRecentMemoryEvents: typeof listRecentMemoryEvents;
|
|
1056
|
+
beginModelRun: typeof beginModelRun;
|
|
1057
|
+
beginModelRunInAdapter: typeof beginModelRunInAdapter;
|
|
1058
|
+
commitModelRun: typeof commitModelRun;
|
|
1059
|
+
commitModelRunInAdapter: typeof commitModelRunInAdapter;
|
|
1060
|
+
failModelRun: typeof failModelRun;
|
|
1061
|
+
failModelRunInAdapter: typeof failModelRunInAdapter;
|
|
1062
|
+
getModelRun: typeof getModelRun;
|
|
1063
|
+
getModelRunInAdapter: typeof getModelRunInAdapter;
|
|
1064
|
+
appendToolTrace: typeof appendToolTrace;
|
|
1065
|
+
listToolTracesForRun: typeof listToolTracesForRun;
|
|
1069
1066
|
saveCheckpoint: typeof saveCheckpoint;
|
|
1070
1067
|
loadCheckpoint: typeof loadCheckpoint;
|
|
1071
1068
|
recall: typeof recall;
|
|
@@ -1090,6 +1087,6 @@ declare const mama: {
|
|
|
1090
1087
|
validateCleanupResult: typeof validateCleanupResult;
|
|
1091
1088
|
expandWithGraph: typeof expandWithGraph;
|
|
1092
1089
|
};
|
|
1093
|
-
export { save, suggest, saveMemory, recallMemory, listDecisions as list, listCheckpoints, updateOutcome, buildProfile, ingestMemory, evolveMemory, buildMemoryBootstrap, createAuditAck, recordMemoryAudit, upsertChannelSummary, getChannelSummary, listOpenAuditFindings, listRecentMemoryEvents, saveCheckpoint, loadCheckpoint, recall, proposeLink, approveLink, rejectLink, getPendingLinks, deprecateAutoLinks, calculateCoverage, calculateQuality, generateQualityReport, logRestartAttempt, calculateRestartSuccessRate, calculateRestartLatency, getRestartMetrics, scanAutoLinks, createLinkBackup, generatePreCleanupReport, restoreLinkBackup, verifyBackupExists, deleteAutoLinks, validateCleanupResult, };
|
|
1090
|
+
export { save, saveWithTrustedProvenance, suggest, saveMemory, saveMemoryWithTrustedProvenance, recallMemory, listDecisions as list, listCheckpoints, updateOutcome, buildProfile, ingestMemory, ingestWithTrustedProvenance, ingestConversation, ingestConversationWithTrustedProvenance, evolveMemory, buildMemoryBootstrap, createAuditAck, recordMemoryAudit, upsertChannelSummary, getChannelSummary, listOpenAuditFindings, getMemoryProvenance, listMemoriesByEnvelopeHash, listMemoriesByGatewayCallId, listMemoriesByModelRunId, listMemoryEventsForMemory, listRecentMemoryEvents, beginModelRun, beginModelRunInAdapter, commitModelRun, commitModelRunInAdapter, failModelRun, failModelRunInAdapter, getModelRun, getModelRunInAdapter, appendToolTrace, listToolTracesForRun, saveCheckpoint, loadCheckpoint, recall, proposeLink, approveLink, rejectLink, getPendingLinks, deprecateAutoLinks, calculateCoverage, calculateQuality, generateQualityReport, logRestartAttempt, calculateRestartSuccessRate, calculateRestartLatency, getRestartMetrics, scanAutoLinks, createLinkBackup, generatePreCleanupReport, restoreLinkBackup, verifyBackupExists, deleteAutoLinks, validateCleanupResult, expandWithGraph, };
|
|
1094
1091
|
export default mama;
|
|
1095
1092
|
//# sourceMappingURL=mama-api.d.ts.map
|
package/dist/mama-api.js
CHANGED
|
@@ -22,8 +22,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.listRecentMemoryEvents = exports.listOpenAuditFindings = exports.getChannelSummary = exports.upsertChannelSummary = exports.recordMemoryAudit = exports.createAuditAck = exports.buildMemoryBootstrap = exports.evolveMemory = exports.ingestMemory = exports.buildProfile = exports.recallMemory = exports.saveMemory = void 0;
|
|
25
|
+
exports.listToolTracesForRun = exports.appendToolTrace = exports.getModelRunInAdapter = exports.getModelRun = exports.failModelRunInAdapter = exports.failModelRun = exports.commitModelRunInAdapter = exports.commitModelRun = exports.beginModelRunInAdapter = exports.beginModelRun = exports.listRecentMemoryEvents = exports.listMemoryEventsForMemory = exports.listMemoriesByModelRunId = exports.listMemoriesByGatewayCallId = exports.listMemoriesByEnvelopeHash = exports.getMemoryProvenance = exports.listOpenAuditFindings = exports.getChannelSummary = exports.upsertChannelSummary = exports.recordMemoryAudit = exports.createAuditAck = exports.buildMemoryBootstrap = exports.evolveMemory = exports.ingestConversationWithTrustedProvenance = exports.ingestConversation = exports.ingestWithTrustedProvenance = exports.ingestMemory = exports.buildProfile = exports.recallMemory = exports.saveMemoryWithTrustedProvenance = exports.saveMemory = void 0;
|
|
26
26
|
exports.save = save;
|
|
27
|
+
exports.saveWithTrustedProvenance = saveWithTrustedProvenance;
|
|
27
28
|
exports.suggest = suggest;
|
|
28
29
|
exports.list = listDecisions;
|
|
29
30
|
exports.listCheckpoints = listCheckpoints;
|
|
@@ -50,6 +51,7 @@ exports.restoreLinkBackup = restoreLinkBackup;
|
|
|
50
51
|
exports.verifyBackupExists = verifyBackupExists;
|
|
51
52
|
exports.deleteAutoLinks = deleteAutoLinks;
|
|
52
53
|
exports.validateCleanupResult = validateCleanupResult;
|
|
54
|
+
exports.expandWithGraph = expandWithGraph;
|
|
53
55
|
// Node built-ins
|
|
54
56
|
const fs_1 = __importDefault(require("fs"));
|
|
55
57
|
const path_1 = __importDefault(require("path"));
|
|
@@ -67,9 +69,13 @@ const ollama_client_js_1 = require("./ollama-client.js");
|
|
|
67
69
|
const debug_logger_js_1 = require("./debug-logger.js");
|
|
68
70
|
const api_js_1 = require("./memory/api.js");
|
|
69
71
|
Object.defineProperty(exports, "saveMemory", { enumerable: true, get: function () { return api_js_1.saveMemory; } });
|
|
72
|
+
Object.defineProperty(exports, "saveMemoryWithTrustedProvenance", { enumerable: true, get: function () { return api_js_1.saveMemoryWithTrustedProvenance; } });
|
|
70
73
|
Object.defineProperty(exports, "recallMemory", { enumerable: true, get: function () { return api_js_1.recallMemory; } });
|
|
71
74
|
Object.defineProperty(exports, "buildProfile", { enumerable: true, get: function () { return api_js_1.buildProfile; } });
|
|
72
75
|
Object.defineProperty(exports, "ingestMemory", { enumerable: true, get: function () { return api_js_1.ingestMemory; } });
|
|
76
|
+
Object.defineProperty(exports, "ingestWithTrustedProvenance", { enumerable: true, get: function () { return api_js_1.ingestWithTrustedProvenance; } });
|
|
77
|
+
Object.defineProperty(exports, "ingestConversation", { enumerable: true, get: function () { return api_js_1.ingestConversation; } });
|
|
78
|
+
Object.defineProperty(exports, "ingestConversationWithTrustedProvenance", { enumerable: true, get: function () { return api_js_1.ingestConversationWithTrustedProvenance; } });
|
|
73
79
|
Object.defineProperty(exports, "evolveMemory", { enumerable: true, get: function () { return api_js_1.evolveMemory; } });
|
|
74
80
|
Object.defineProperty(exports, "buildMemoryBootstrap", { enumerable: true, get: function () { return api_js_1.buildMemoryBootstrap; } });
|
|
75
81
|
Object.defineProperty(exports, "createAuditAck", { enumerable: true, get: function () { return api_js_1.createAuditAck; } });
|
|
@@ -79,10 +85,29 @@ Object.defineProperty(exports, "getChannelSummary", { enumerable: true, get: fun
|
|
|
79
85
|
const finding_store_js_1 = require("./memory/finding-store.js");
|
|
80
86
|
Object.defineProperty(exports, "listOpenAuditFindings", { enumerable: true, get: function () { return finding_store_js_1.listOpenAuditFindings; } });
|
|
81
87
|
const event_store_js_1 = require("./memory/event-store.js");
|
|
88
|
+
Object.defineProperty(exports, "listMemoryEventsForMemory", { enumerable: true, get: function () { return event_store_js_1.listMemoryEventsForMemory; } });
|
|
82
89
|
Object.defineProperty(exports, "listRecentMemoryEvents", { enumerable: true, get: function () { return event_store_js_1.listRecentMemoryEvents; } });
|
|
90
|
+
const provenance_query_js_1 = require("./memory/provenance-query.js");
|
|
91
|
+
Object.defineProperty(exports, "getMemoryProvenance", { enumerable: true, get: function () { return provenance_query_js_1.getMemoryProvenance; } });
|
|
92
|
+
Object.defineProperty(exports, "listMemoriesByEnvelopeHash", { enumerable: true, get: function () { return provenance_query_js_1.listMemoriesByEnvelopeHash; } });
|
|
93
|
+
Object.defineProperty(exports, "listMemoriesByGatewayCallId", { enumerable: true, get: function () { return provenance_query_js_1.listMemoriesByGatewayCallId; } });
|
|
94
|
+
Object.defineProperty(exports, "listMemoriesByModelRunId", { enumerable: true, get: function () { return provenance_query_js_1.listMemoriesByModelRunId; } });
|
|
95
|
+
const store_js_1 = require("./model-runs/store.js");
|
|
96
|
+
Object.defineProperty(exports, "beginModelRun", { enumerable: true, get: function () { return store_js_1.beginModelRun; } });
|
|
97
|
+
Object.defineProperty(exports, "beginModelRunInAdapter", { enumerable: true, get: function () { return store_js_1.beginModelRunInAdapter; } });
|
|
98
|
+
Object.defineProperty(exports, "commitModelRun", { enumerable: true, get: function () { return store_js_1.commitModelRun; } });
|
|
99
|
+
Object.defineProperty(exports, "commitModelRunInAdapter", { enumerable: true, get: function () { return store_js_1.commitModelRunInAdapter; } });
|
|
100
|
+
Object.defineProperty(exports, "failModelRun", { enumerable: true, get: function () { return store_js_1.failModelRun; } });
|
|
101
|
+
Object.defineProperty(exports, "failModelRunInAdapter", { enumerable: true, get: function () { return store_js_1.failModelRunInAdapter; } });
|
|
102
|
+
Object.defineProperty(exports, "getModelRun", { enumerable: true, get: function () { return store_js_1.getModelRun; } });
|
|
103
|
+
Object.defineProperty(exports, "getModelRunInAdapter", { enumerable: true, get: function () { return store_js_1.getModelRunInAdapter; } });
|
|
104
|
+
const tool_trace_store_js_1 = require("./model-runs/tool-trace-store.js");
|
|
105
|
+
Object.defineProperty(exports, "appendToolTrace", { enumerable: true, get: function () { return tool_trace_store_js_1.appendToolTrace; } });
|
|
106
|
+
Object.defineProperty(exports, "listToolTracesForRun", { enumerable: true, get: function () { return tool_trace_store_js_1.listToolTracesForRun; } });
|
|
83
107
|
const search_rollup_js_1 = require("./cases/search-rollup.js");
|
|
84
108
|
const ranker_rescore_js_1 = require("./search/ranker-rescore.js");
|
|
85
109
|
const ranker_features_js_1 = require("./search/ranker-features.js");
|
|
110
|
+
const search_quality_js_1 = require("./search/search-quality.js");
|
|
86
111
|
// Session-level warning cooldown cache (Story 1.1, 1.2)
|
|
87
112
|
// Prevents spam by tracking warned topics per session
|
|
88
113
|
const warnedTopicsCache = new Map();
|
|
@@ -114,7 +139,7 @@ const WARNING_COOLDOWN_MS = 5 * 60 * 1000; // 5 minutes
|
|
|
114
139
|
* outcome: 'success'
|
|
115
140
|
* });
|
|
116
141
|
*/
|
|
117
|
-
async function
|
|
142
|
+
async function saveInternal({ topic, decision, reasoning, confidence = 0.5, type = 'user_decision', outcome = 'pending', failure_reason = null, limitation = null, trust_context: _trust_context = null, is_static, scopes: inputScopes, event_date, timelineEvent, }, options) {
|
|
118
143
|
// Validate required fields
|
|
119
144
|
if (!topic || typeof topic !== 'string') {
|
|
120
145
|
throw new Error('mama.save() requires topic (string)');
|
|
@@ -164,20 +189,35 @@ async function save({ topic, decision, reasoning, confidence = 0.5, type = 'user
|
|
|
164
189
|
// Future: Will use decision_type column for proper distinction
|
|
165
190
|
const _userInvolvement = type === 'user_decision' ? 'approved' : null;
|
|
166
191
|
(0, progress_indicator_js_1.logProgress)(`Saving decision: ${topic.substring(0, 30)}...`);
|
|
167
|
-
const { id: decisionId, timeline_event_id: timelineEventId, timeline_event_ids: timelineEventIds, } =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
192
|
+
const { id: decisionId, timeline_event_id: timelineEventId, timeline_event_ids: timelineEventIds, } = options
|
|
193
|
+
? await (0, api_js_1.saveMemoryWithTrustedProvenance)({
|
|
194
|
+
topic,
|
|
195
|
+
kind: is_static === 1 ? 'preference' : 'decision',
|
|
196
|
+
summary: decision,
|
|
197
|
+
details: reasoning,
|
|
198
|
+
confidence,
|
|
199
|
+
scopes: Array.isArray(inputScopes) && inputScopes.length > 0 ? inputScopes : [],
|
|
200
|
+
source: {
|
|
201
|
+
package: 'mama-core',
|
|
202
|
+
source_type: 'legacy_save',
|
|
203
|
+
},
|
|
204
|
+
eventDate: event_date ?? undefined,
|
|
205
|
+
timelineEvent,
|
|
206
|
+
}, options)
|
|
207
|
+
: await (0, api_js_1.saveMemory)({
|
|
208
|
+
topic,
|
|
209
|
+
kind: is_static === 1 ? 'preference' : 'decision',
|
|
210
|
+
summary: decision,
|
|
211
|
+
details: reasoning,
|
|
212
|
+
confidence,
|
|
213
|
+
scopes: Array.isArray(inputScopes) && inputScopes.length > 0 ? inputScopes : [],
|
|
214
|
+
source: {
|
|
215
|
+
package: 'mama-core',
|
|
216
|
+
source_type: 'legacy_save',
|
|
217
|
+
},
|
|
218
|
+
eventDate: event_date ?? undefined,
|
|
219
|
+
timelineEvent,
|
|
220
|
+
});
|
|
181
221
|
(0, progress_indicator_js_1.logComplete)(`Decision saved: ${decisionId.substring(0, 20)}...`);
|
|
182
222
|
// Update user_involvement, outcome, failure_reason, limitation
|
|
183
223
|
// Note: learnDecision always sets 'requested', we need to override it
|
|
@@ -760,6 +800,7 @@ function confidenceValue(record, fallback) {
|
|
|
760
800
|
}
|
|
761
801
|
function mapRolledUpResult(result) {
|
|
762
802
|
const record = resultRecord(result);
|
|
803
|
+
const retrievalDiagnostics = result.retrieval_diagnostics;
|
|
763
804
|
const topic = stringOrNull(record.topic ?? record.title) ?? result.source_id;
|
|
764
805
|
// For wiki_page leaves, prefer the markdown body (`content`) in `decision` so
|
|
765
806
|
// downstream consumers see the meaningful body rather than the short title.
|
|
@@ -787,15 +828,25 @@ function mapRolledUpResult(result) {
|
|
|
787
828
|
created_at: record.created_at ?? null,
|
|
788
829
|
event_date: record.event_date ?? null,
|
|
789
830
|
event_datetime: record.event_datetime ?? null,
|
|
790
|
-
graph_source: 'primary',
|
|
831
|
+
graph_source: retrievalDiagnostics?.graph_source ?? 'primary',
|
|
791
832
|
graph_rank: 1,
|
|
792
833
|
related_to: null,
|
|
793
834
|
edge_reason: null,
|
|
794
835
|
case_id: result.case_id,
|
|
795
836
|
source_type: result.source_type,
|
|
796
837
|
contributing_leaves: result.contributing_leaves ?? null,
|
|
838
|
+
...(result.contributing_leaf_diagnostics
|
|
839
|
+
? { contributing_leaf_diagnostics: result.contributing_leaf_diagnostics }
|
|
840
|
+
: {}),
|
|
841
|
+
...(retrievalDiagnostics ? { retrieval_diagnostics: retrievalDiagnostics } : {}),
|
|
797
842
|
};
|
|
798
843
|
}
|
|
844
|
+
async function save(params) {
|
|
845
|
+
return saveInternal(params);
|
|
846
|
+
}
|
|
847
|
+
async function saveWithTrustedProvenance(params, options) {
|
|
848
|
+
return saveInternal(params, options);
|
|
849
|
+
}
|
|
799
850
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
800
851
|
async function suggest(userQuestion, options = {}) {
|
|
801
852
|
if (!userQuestion || typeof userQuestion !== 'string') {
|
|
@@ -807,17 +858,66 @@ async function suggest(userQuestion, options = {}) {
|
|
|
807
858
|
recencyScale = 7, // Days until recency score drops to 50%
|
|
808
859
|
recencyDecay = 0.5, // Score at scale point (0.5 = 50%)
|
|
809
860
|
disableRecency = false, // Set true to disable recency boosting entirely
|
|
810
|
-
|
|
861
|
+
strict, strictness, includeRelated, minLexicalSupport, diagnostics: includeDiagnostics, } = options;
|
|
862
|
+
const normalizedSearchOptions = (0, search_quality_js_1.normalizeSearchQualityOptions)({
|
|
863
|
+
threshold,
|
|
864
|
+
strict,
|
|
865
|
+
strictness,
|
|
866
|
+
disableRecency,
|
|
867
|
+
includeRelated,
|
|
868
|
+
topicPrefix: options.topicPrefix,
|
|
869
|
+
minLexicalSupport,
|
|
870
|
+
diagnostics: includeDiagnostics,
|
|
871
|
+
});
|
|
872
|
+
const memoryV2QualityContractRequested = threshold !== undefined ||
|
|
873
|
+
strict !== undefined ||
|
|
874
|
+
strictness !== undefined ||
|
|
875
|
+
includeRelated !== undefined ||
|
|
876
|
+
minLexicalSupport !== undefined ||
|
|
877
|
+
includeDiagnostics === true ||
|
|
878
|
+
options.topicPrefix !== undefined ||
|
|
879
|
+
options.scopes !== undefined;
|
|
811
880
|
const rerankPoolLimit = rerankWithLearned ? Math.max(limit * 4, limit + 5) : limit;
|
|
812
881
|
try {
|
|
813
882
|
const bundle = await (0, api_js_1.recallMemory)(userQuestion, {
|
|
814
883
|
includeProfile: false,
|
|
815
884
|
topicPrefix: options.topicPrefix,
|
|
816
885
|
limit: rerankPoolLimit,
|
|
886
|
+
threshold,
|
|
887
|
+
strict,
|
|
888
|
+
strictness,
|
|
889
|
+
disableRecency,
|
|
890
|
+
includeRelated,
|
|
891
|
+
minLexicalSupport,
|
|
892
|
+
diagnostics: includeDiagnostics,
|
|
817
893
|
...(options.scopes && { scopes: options.scopes }),
|
|
818
894
|
});
|
|
819
|
-
const
|
|
895
|
+
const diagnosticsByMemoryId = new Map(bundle.memories
|
|
896
|
+
.filter((memory) => memory.retrieval_diagnostics)
|
|
897
|
+
.map((memory) => [memory.id, memory.retrieval_diagnostics]));
|
|
898
|
+
const rawFusedHits = bundle.fused_hits ?? [];
|
|
899
|
+
const fusedHits = rawFusedHits.map((hit) => {
|
|
900
|
+
if (hit.source_type !== 'decision') {
|
|
901
|
+
return hit;
|
|
902
|
+
}
|
|
903
|
+
const recordDiagnostics = typeof hit.record === 'object' && hit.record !== null && !Array.isArray(hit.record)
|
|
904
|
+
? hit.record.retrieval_diagnostics
|
|
905
|
+
: undefined;
|
|
906
|
+
const retrievalDiagnostics = diagnosticsByMemoryId.get(hit.source_id) ?? recordDiagnostics;
|
|
907
|
+
if (!retrievalDiagnostics) {
|
|
908
|
+
return hit;
|
|
909
|
+
}
|
|
910
|
+
const record = typeof hit.record === 'object' && hit.record !== null && !Array.isArray(hit.record)
|
|
911
|
+
? { ...hit.record, retrieval_diagnostics: retrievalDiagnostics }
|
|
912
|
+
: hit.record;
|
|
913
|
+
return {
|
|
914
|
+
...hit,
|
|
915
|
+
record,
|
|
916
|
+
retrieval_diagnostics: retrievalDiagnostics,
|
|
917
|
+
};
|
|
918
|
+
});
|
|
820
919
|
const rolledUp = fusedHits.length > 0 ? (0, search_rollup_js_1.rollUpSearchHits)({ fusedHits, adapter: (0, memory_store_js_1.getAdapter)() }) : [];
|
|
920
|
+
const diagnosticsResponse = includeDiagnostics === true ? { diagnostics: bundle.search_meta.diagnostics ?? null } : {};
|
|
821
921
|
// Phase 3 Task 33: compute base ranker meta once so every return path
|
|
822
922
|
// (rolledUp, memories fallback, vector-search fallback) can attach it.
|
|
823
923
|
// rerankWithLearned-driven rescoring still only applies to result arrays
|
|
@@ -901,10 +1001,11 @@ async function suggest(userQuestion, options = {}) {
|
|
|
901
1001
|
return {
|
|
902
1002
|
query: userQuestion,
|
|
903
1003
|
results: limitedResults,
|
|
1004
|
+
...diagnosticsResponse,
|
|
904
1005
|
meta: {
|
|
905
1006
|
count: limitedResults.length,
|
|
906
1007
|
search_method: 'memory_v2',
|
|
907
|
-
threshold: threshold
|
|
1008
|
+
threshold: normalizedSearchOptions.threshold,
|
|
908
1009
|
recency_boost: disableRecency
|
|
909
1010
|
? null
|
|
910
1011
|
: {
|
|
@@ -939,7 +1040,7 @@ async function suggest(userQuestion, options = {}) {
|
|
|
939
1040
|
created_at: memory.created_at,
|
|
940
1041
|
event_date: memory.event_date ?? null,
|
|
941
1042
|
event_datetime: memory.event_datetime ?? null,
|
|
942
|
-
graph_source: 'primary',
|
|
1043
|
+
graph_source: memory.retrieval_diagnostics?.graph_source ?? 'primary',
|
|
943
1044
|
graph_rank: 1,
|
|
944
1045
|
related_to: null,
|
|
945
1046
|
edge_reason: null,
|
|
@@ -949,6 +1050,9 @@ async function suggest(userQuestion, options = {}) {
|
|
|
949
1050
|
memory.source_type ??
|
|
950
1051
|
memory.type ??
|
|
951
1052
|
'decision',
|
|
1053
|
+
...(memory.retrieval_diagnostics
|
|
1054
|
+
? { retrieval_diagnostics: memory.retrieval_diagnostics }
|
|
1055
|
+
: {}),
|
|
952
1056
|
}));
|
|
953
1057
|
const { results: rankedRows, meta: rankerMeta } = applyLearnedRanker(baseRows);
|
|
954
1058
|
const limitedRows = rankedRows.slice(0, limit);
|
|
@@ -961,10 +1065,11 @@ async function suggest(userQuestion, options = {}) {
|
|
|
961
1065
|
return {
|
|
962
1066
|
query: userQuestion,
|
|
963
1067
|
results: limitedRows,
|
|
1068
|
+
...diagnosticsResponse,
|
|
964
1069
|
meta: {
|
|
965
1070
|
count: limitedRows.length,
|
|
966
1071
|
search_method: 'memory_v2',
|
|
967
|
-
threshold: threshold
|
|
1072
|
+
threshold: normalizedSearchOptions.threshold,
|
|
968
1073
|
recency_boost: disableRecency
|
|
969
1074
|
? null
|
|
970
1075
|
: {
|
|
@@ -977,6 +1082,32 @@ async function suggest(userQuestion, options = {}) {
|
|
|
977
1082
|
},
|
|
978
1083
|
};
|
|
979
1084
|
}
|
|
1085
|
+
if (memoryV2QualityContractRequested) {
|
|
1086
|
+
const emptyRows = [];
|
|
1087
|
+
const { meta: rankerMeta } = applyLearnedRanker(emptyRows);
|
|
1088
|
+
if (format === 'markdown') {
|
|
1089
|
+
return '🔍 Search method: memory_v2\n';
|
|
1090
|
+
}
|
|
1091
|
+
return {
|
|
1092
|
+
query: userQuestion,
|
|
1093
|
+
results: emptyRows,
|
|
1094
|
+
...diagnosticsResponse,
|
|
1095
|
+
meta: {
|
|
1096
|
+
count: 0,
|
|
1097
|
+
search_method: 'memory_v2',
|
|
1098
|
+
threshold: normalizedSearchOptions.threshold,
|
|
1099
|
+
recency_boost: disableRecency
|
|
1100
|
+
? null
|
|
1101
|
+
: {
|
|
1102
|
+
weight: recencyWeight,
|
|
1103
|
+
scale: recencyScale,
|
|
1104
|
+
decay: recencyDecay,
|
|
1105
|
+
},
|
|
1106
|
+
graph_expansion: summarizeGraphExpansion(emptyRows),
|
|
1107
|
+
ranker: rankerMeta,
|
|
1108
|
+
},
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
980
1111
|
// 1. Try vector search first (if sqlite-vss is available)
|
|
981
1112
|
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-explicit-any
|
|
982
1113
|
let results = [];
|
|
@@ -2567,14 +2698,19 @@ function formatQualityReportMarkdown(report) {
|
|
|
2567
2698
|
const mama = {
|
|
2568
2699
|
// Core functions (used by 4 MCP tools)
|
|
2569
2700
|
save,
|
|
2701
|
+
saveWithTrustedProvenance,
|
|
2570
2702
|
suggest,
|
|
2571
2703
|
saveMemory: api_js_1.saveMemory,
|
|
2704
|
+
saveMemoryWithTrustedProvenance: api_js_1.saveMemoryWithTrustedProvenance,
|
|
2572
2705
|
recallMemory: api_js_1.recallMemory,
|
|
2573
2706
|
list: listDecisions,
|
|
2574
2707
|
listCheckpoints,
|
|
2575
2708
|
updateOutcome,
|
|
2576
2709
|
buildProfile: api_js_1.buildProfile,
|
|
2577
2710
|
ingestMemory: api_js_1.ingestMemory,
|
|
2711
|
+
ingestWithTrustedProvenance: api_js_1.ingestWithTrustedProvenance,
|
|
2712
|
+
ingestConversation: api_js_1.ingestConversation,
|
|
2713
|
+
ingestConversationWithTrustedProvenance: api_js_1.ingestConversationWithTrustedProvenance,
|
|
2578
2714
|
evolveMemory: api_js_1.evolveMemory,
|
|
2579
2715
|
buildMemoryBootstrap: api_js_1.buildMemoryBootstrap,
|
|
2580
2716
|
createAuditAck: api_js_1.createAuditAck,
|
|
@@ -2582,7 +2718,22 @@ const mama = {
|
|
|
2582
2718
|
upsertChannelSummary: api_js_1.upsertChannelSummary,
|
|
2583
2719
|
getChannelSummary: api_js_1.getChannelSummary,
|
|
2584
2720
|
listAuditFindings: finding_store_js_1.listOpenAuditFindings,
|
|
2721
|
+
getMemoryProvenance: provenance_query_js_1.getMemoryProvenance,
|
|
2722
|
+
listMemoriesByEnvelopeHash: provenance_query_js_1.listMemoriesByEnvelopeHash,
|
|
2723
|
+
listMemoriesByGatewayCallId: provenance_query_js_1.listMemoriesByGatewayCallId,
|
|
2724
|
+
listMemoriesByModelRunId: provenance_query_js_1.listMemoriesByModelRunId,
|
|
2725
|
+
listMemoryEventsForMemory: event_store_js_1.listMemoryEventsForMemory,
|
|
2585
2726
|
listRecentMemoryEvents: event_store_js_1.listRecentMemoryEvents,
|
|
2727
|
+
beginModelRun: store_js_1.beginModelRun,
|
|
2728
|
+
beginModelRunInAdapter: store_js_1.beginModelRunInAdapter,
|
|
2729
|
+
commitModelRun: store_js_1.commitModelRun,
|
|
2730
|
+
commitModelRunInAdapter: store_js_1.commitModelRunInAdapter,
|
|
2731
|
+
failModelRun: store_js_1.failModelRun,
|
|
2732
|
+
failModelRunInAdapter: store_js_1.failModelRunInAdapter,
|
|
2733
|
+
getModelRun: store_js_1.getModelRun,
|
|
2734
|
+
getModelRunInAdapter: store_js_1.getModelRunInAdapter,
|
|
2735
|
+
appendToolTrace: tool_trace_store_js_1.appendToolTrace,
|
|
2736
|
+
listToolTracesForRun: tool_trace_store_js_1.listToolTracesForRun,
|
|
2586
2737
|
saveCheckpoint,
|
|
2587
2738
|
loadCheckpoint,
|
|
2588
2739
|
// Legacy functions (retained for internal use, not exposed via MCP)
|
package/dist/memory/api.d.ts
CHANGED
|
@@ -1,82 +1,42 @@
|
|
|
1
1
|
import { type WikiPageIndexRecord } from '../cases/wiki-page-index.js';
|
|
2
2
|
import { resolveMemoryEvolution } from './evolution-engine.js';
|
|
3
3
|
import { getChannelSummary, upsertChannelSummary } from './channel-summary-store.js';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
details: string;
|
|
10
|
-
confidence?: number;
|
|
11
|
-
status?: MemoryStatus;
|
|
12
|
-
scopes: MemoryScopeRef[];
|
|
13
|
-
source: {
|
|
14
|
-
package: 'mama-core' | 'mcp-server' | 'standalone' | 'claude-code-plugin';
|
|
15
|
-
source_type: string;
|
|
16
|
-
user_id?: string;
|
|
17
|
-
channel_id?: string;
|
|
18
|
-
project_id?: string;
|
|
19
|
-
};
|
|
20
|
-
/** IDs to exclude from supersede candidates (e.g., sibling facts from same ingestion batch) */
|
|
21
|
-
excludeIds?: string[];
|
|
22
|
-
/**
|
|
23
|
-
* ISO 8601 date string for when the event actually occurred (e.g. "2023-01-15").
|
|
24
|
-
* Stored in the event_date column. Defaults to created_at if omitted.
|
|
25
|
-
*/
|
|
26
|
-
eventDate?: string;
|
|
27
|
-
/** Source event timestamp in milliseconds when known. */
|
|
28
|
-
eventDateTime?: number;
|
|
29
|
-
entityObservationIds?: string[];
|
|
30
|
-
timelineEvent?: {
|
|
31
|
-
id?: string;
|
|
32
|
-
entity_id?: string;
|
|
33
|
-
event_type: string;
|
|
34
|
-
role?: string | null;
|
|
35
|
-
valid_from?: number | null;
|
|
36
|
-
valid_to?: number | null;
|
|
37
|
-
observed_at?: number | null;
|
|
38
|
-
source_ref?: string | null;
|
|
39
|
-
summary: string;
|
|
40
|
-
details?: string | null;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
interface RecallMemoryOptions {
|
|
44
|
-
scopes?: MemoryScopeRef[];
|
|
45
|
-
includeProfile?: boolean;
|
|
46
|
-
includeHistory?: boolean;
|
|
47
|
-
skipGraphExpansion?: boolean;
|
|
48
|
-
topicPrefix?: string;
|
|
49
|
-
limit?: number;
|
|
50
|
-
}
|
|
51
|
-
interface IngestMemoryInput {
|
|
52
|
-
content: string;
|
|
53
|
-
scopes?: MemoryScopeRef[];
|
|
54
|
-
source: SaveMemoryInput['source'];
|
|
55
|
-
eventDate?: string;
|
|
56
|
-
eventDateTime?: number;
|
|
57
|
-
}
|
|
4
|
+
import { type SearchHitDiagnostics } from '../search/search-quality.js';
|
|
5
|
+
import type { MemoryAgentBootstrap, MemoryAuditAck, MemoryEdge, MemoryRecord, MemoryScopeRef, ProfileSnapshot, PublicIngestMemoryInput, PublicSaveMemoryInput, RecallBundle, IngestConversationInput, ExtractedMemoryUnit, IngestConversationResult, RecallMemoryOptions } from './types.js';
|
|
6
|
+
import { type TrustedMemoryWriteOptions } from './provenance.js';
|
|
7
|
+
type SaveMemoryInput = PublicSaveMemoryInput;
|
|
8
|
+
type IngestMemoryInput = PublicIngestMemoryInput;
|
|
58
9
|
export interface FusedHit {
|
|
59
10
|
source_type: 'decision' | 'wiki_page';
|
|
60
11
|
source_id: string;
|
|
61
12
|
record: MemoryRecord | WikiPageIndexRecord;
|
|
62
13
|
fused_rank_score: number;
|
|
14
|
+
page_type?: WikiPageIndexRecord['page_type'];
|
|
15
|
+
case_id?: string | null;
|
|
16
|
+
retrieval_diagnostics?: SearchHitDiagnostics;
|
|
63
17
|
}
|
|
64
18
|
export declare const LEXICAL_STOPWORDS: Set<string>;
|
|
65
19
|
export declare function getLexicalQueryTokens(query: string): string[];
|
|
66
20
|
export declare function loadEdgesForIds(ids: string[]): Promise<MemoryEdge[]>;
|
|
67
|
-
|
|
21
|
+
type SaveMemoryResult = {
|
|
68
22
|
success: boolean;
|
|
69
23
|
id: string;
|
|
70
24
|
saved_decision_id?: string;
|
|
71
25
|
timeline_event_id?: string | null;
|
|
72
26
|
timeline_event_ids?: string[];
|
|
73
|
-
}
|
|
27
|
+
};
|
|
28
|
+
export declare function saveMemory(input: SaveMemoryInput): Promise<SaveMemoryResult>;
|
|
29
|
+
export declare function saveMemoryWithTrustedProvenance(input: SaveMemoryInput, options: TrustedMemoryWriteOptions): Promise<SaveMemoryResult>;
|
|
74
30
|
export declare function buildProfile(scopes: MemoryScopeRef[]): Promise<ProfileSnapshot>;
|
|
75
31
|
export declare function recallMemory(query: string, options?: RecallMemoryOptions): Promise<RecallBundle>;
|
|
76
32
|
export declare function ingestMemory(input: IngestMemoryInput): Promise<{
|
|
77
33
|
success: boolean;
|
|
78
34
|
id: string;
|
|
79
35
|
}>;
|
|
36
|
+
export declare function ingestWithTrustedProvenance(input: IngestMemoryInput, options: TrustedMemoryWriteOptions): Promise<{
|
|
37
|
+
success: boolean;
|
|
38
|
+
id: string;
|
|
39
|
+
}>;
|
|
80
40
|
export declare function evolveMemory(input: Parameters<typeof resolveMemoryEvolution>[0]): Promise<import("./evolution-engine.js").EvolutionResult>;
|
|
81
41
|
export declare function buildMemoryBootstrap(params: {
|
|
82
42
|
scopes: MemoryScopeRef[];
|
|
@@ -104,5 +64,6 @@ export declare function recordMemoryAudit(input: {
|
|
|
104
64
|
declare function callExtractionLLM(prompt: string, options: NonNullable<IngestConversationInput['extract']>): Promise<ExtractedMemoryUnit[]>;
|
|
105
65
|
export declare function setExtractionFn(fn: typeof callExtractionLLM | null): void;
|
|
106
66
|
export declare function ingestConversation(input: IngestConversationInput): Promise<IngestConversationResult>;
|
|
67
|
+
export declare function ingestConversationWithTrustedProvenance(input: IngestConversationInput, options: TrustedMemoryWriteOptions): Promise<IngestConversationResult>;
|
|
107
68
|
export { upsertChannelSummary, getChannelSummary };
|
|
108
69
|
//# sourceMappingURL=api.d.ts.map
|