@jungjaehoon/mama-core 1.9.0 → 2.0.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.
Files changed (136) hide show
  1. package/dist/agent-graph/alias-write.js +3 -0
  2. package/dist/agent-graph/entity-resolve.js +3 -7
  3. package/dist/agent-graph/graph-query.js +5 -4
  4. package/dist/agent-graph/types.d.ts +30 -0
  5. package/dist/cases/store.d.ts +0 -4
  6. package/dist/cases/store.js +0 -66
  7. package/dist/cases/wiki-page-index.d.ts +0 -13
  8. package/dist/cases/wiki-page-index.js +0 -153
  9. package/dist/connectors/event-index.d.ts +1 -22
  10. package/dist/connectors/event-index.js +0 -157
  11. package/dist/context-compile/channel-grant.d.ts +46 -0
  12. package/dist/context-compile/channel-grant.js +66 -0
  13. package/dist/context-compile/compiler.js +5 -2
  14. package/dist/context-compile/index.d.ts +1 -0
  15. package/dist/context-compile/index.js +1 -0
  16. package/dist/context-compile/packet-store.d.ts +0 -1
  17. package/dist/context-compile/packet-store.js +0 -16
  18. package/dist/context-compile/source-readers.d.ts +1 -0
  19. package/dist/context-compile/source-readers.js +156 -23
  20. package/dist/context-compile/types.d.ts +17 -0
  21. package/dist/context-compile/visibility.js +28 -4
  22. package/dist/db-adapter/node-sqlite-adapter.js +4 -0
  23. package/dist/db-manager.d.ts +0 -13
  24. package/dist/db-manager.js +0 -66
  25. package/dist/decision-formatter.d.ts +0 -11
  26. package/dist/decision-formatter.js +0 -122
  27. package/dist/decision-tracker.d.ts +0 -12
  28. package/dist/decision-tracker.js +0 -50
  29. package/dist/edges/ref-validation.d.ts +1 -2
  30. package/dist/edges/ref-validation.js +33 -13
  31. package/dist/edges/store.d.ts +1 -3
  32. package/dist/edges/store.js +0 -214
  33. package/dist/edges/types.d.ts +10 -0
  34. package/dist/embedding-client.d.ts +0 -17
  35. package/dist/embedding-client.js +0 -80
  36. package/dist/embedding-server/mobile/auth.d.ts +1 -10
  37. package/dist/embedding-server/mobile/auth.js +0 -15
  38. package/dist/embeddings.d.ts +0 -12
  39. package/dist/embeddings.js +0 -68
  40. package/dist/entities/audit-metrics.d.ts +0 -5
  41. package/dist/entities/audit-metrics.js +0 -4
  42. package/dist/entities/candidate-generator.d.ts +1 -2
  43. package/dist/entities/candidate-generator.js +0 -412
  44. package/dist/entities/entity-list.d.ts +0 -1
  45. package/dist/entities/entity-list.js +0 -96
  46. package/dist/entities/entity-orphan-list.d.ts +0 -9
  47. package/dist/entities/entity-orphan-list.js +0 -88
  48. package/dist/entities/entity-search.d.ts +0 -1
  49. package/dist/entities/entity-search.js +0 -147
  50. package/dist/entities/errors.d.ts +0 -10
  51. package/dist/entities/errors.js +1 -25
  52. package/dist/entities/lineage-store.d.ts +0 -23
  53. package/dist/entities/lineage-store.js +0 -104
  54. package/dist/entities/policy-store.d.ts +0 -9
  55. package/dist/entities/policy-store.js +0 -188
  56. package/dist/entities/provenance-query.d.ts +0 -1
  57. package/dist/entities/provenance-query.js +0 -164
  58. package/dist/entities/resolution-engine.d.ts +1 -8
  59. package/dist/entities/resolution-engine.js +0 -66
  60. package/dist/entities/rollback-preview.d.ts +0 -4
  61. package/dist/entities/rollback-preview.js +0 -232
  62. package/dist/entities/store.d.ts +1 -10
  63. package/dist/entities/store.js +0 -49
  64. package/dist/index.d.ts +15 -31
  65. package/dist/index.js +4 -46
  66. package/dist/mama-api.d.ts +19 -1
  67. package/dist/mama-api.js +97 -2
  68. package/dist/memory/api.d.ts +8 -0
  69. package/dist/memory/api.js +55 -2
  70. package/dist/memory/event-store.d.ts +0 -1
  71. package/dist/memory/event-store.js +0 -15
  72. package/dist/memory/finding-store.d.ts +0 -1
  73. package/dist/memory/finding-store.js +0 -12
  74. package/dist/memory/scope-backfill.d.ts +0 -3
  75. package/dist/memory/scope-backfill.js +0 -74
  76. package/dist/memory/scope-store.d.ts +0 -1
  77. package/dist/memory/scope-store.js +0 -4
  78. package/dist/memory/truth-store.d.ts +0 -3
  79. package/dist/memory/truth-store.js +0 -22
  80. package/dist/memory/types.d.ts +0 -1
  81. package/dist/memory/types.js +0 -13
  82. package/dist/memory-store.d.ts +0 -16
  83. package/dist/memory-store.js +0 -51
  84. package/dist/ollama-client.d.ts +0 -9
  85. package/dist/ollama-client.js +0 -125
  86. package/dist/outcome-tracker.d.ts +0 -14
  87. package/dist/outcome-tracker.js +0 -44
  88. package/dist/progress-indicator.d.ts +0 -4
  89. package/dist/progress-indicator.js +0 -7
  90. package/dist/provenance/source-ref.d.ts +0 -9
  91. package/dist/provenance/source-ref.js +0 -145
  92. package/dist/query-intent.d.ts +0 -4
  93. package/dist/query-intent.js +0 -30
  94. package/dist/relevance-scorer.d.ts +0 -9
  95. package/dist/relevance-scorer.js +0 -81
  96. package/dist/search/feedback-store.d.ts +0 -1
  97. package/dist/search/feedback-store.js +0 -4
  98. package/dist/search/ranker-rescore.d.ts +0 -3
  99. package/dist/search/ranker-rescore.js +0 -27
  100. package/dist/search/ranker-trainer.d.ts +0 -8
  101. package/dist/search/ranker-trainer.js +0 -376
  102. package/dist/tier-validator.d.ts +0 -12
  103. package/dist/tier-validator.js +0 -56
  104. package/package.json +1 -10
  105. package/dist/cases/case-links.d.ts +0 -116
  106. package/dist/cases/case-links.js +0 -794
  107. package/dist/cases/composition-overrides.d.ts +0 -90
  108. package/dist/cases/composition-overrides.js +0 -724
  109. package/dist/cases/corrections.d.ts +0 -156
  110. package/dist/cases/corrections.js +0 -1045
  111. package/dist/cases/freshness.d.ts +0 -57
  112. package/dist/cases/freshness.js +0 -283
  113. package/dist/cases/live-state.d.ts +0 -48
  114. package/dist/cases/live-state.js +0 -256
  115. package/dist/cases/membership-explain.d.ts +0 -56
  116. package/dist/cases/membership-explain.js +0 -140
  117. package/dist/cases/membership-matcher.d.ts +0 -23
  118. package/dist/cases/membership-matcher.js +0 -193
  119. package/dist/cases/merge-split.d.ts +0 -61
  120. package/dist/cases/merge-split.js +0 -368
  121. package/dist/cases/role-inference.d.ts +0 -10
  122. package/dist/cases/role-inference.js +0 -85
  123. package/dist/cases/sqlite-transaction.d.ts +0 -10
  124. package/dist/cases/sqlite-transaction.js +0 -62
  125. package/dist/cases/target-ref.d.ts +0 -25
  126. package/dist/cases/target-ref.js +0 -22
  127. package/dist/cases/tombstone-sweeper.d.ts +0 -13
  128. package/dist/cases/tombstone-sweeper.js +0 -128
  129. package/dist/entities/entity-impact.d.ts +0 -41
  130. package/dist/entities/entity-impact.js +0 -140
  131. package/dist/entities/exact-merge-backfill.d.ts +0 -11
  132. package/dist/entities/exact-merge-backfill.js +0 -161
  133. package/dist/entities/lineage-backfill.d.ts +0 -12
  134. package/dist/entities/lineage-backfill.js +0 -101
  135. package/dist/memory-inject.d.ts +0 -24
  136. package/dist/memory-inject.js +0 -116
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createAuditFinding = createAuditFinding;
7
7
  exports.listOpenAuditFindings = listOpenAuditFindings;
8
- exports.resolveAuditFinding = resolveAuditFinding;
9
8
  const node_crypto_1 = __importDefault(require("node:crypto"));
10
9
  const db_manager_js_1 = require("../db-manager.js");
11
10
  function safeParseJsonArray(value) {
@@ -61,15 +60,4 @@ async function listOpenAuditFindings() {
61
60
  .all();
62
61
  return rows.map(deserializeFinding);
63
62
  }
64
- async function resolveAuditFinding(findingId, status) {
65
- await (0, db_manager_js_1.initDB)();
66
- const adapter = (0, db_manager_js_1.getAdapter)();
67
- adapter
68
- .prepare(`
69
- UPDATE audit_findings
70
- SET status = ?, resolved_at = ?
71
- WHERE finding_id = ?
72
- `)
73
- .run(status, Date.now(), findingId);
74
- }
75
63
  //# sourceMappingURL=finding-store.js.map
@@ -1,4 +1,3 @@
1
- import { type DatabaseAdapter } from '../db-manager.js';
2
1
  export interface BackfillResult {
3
2
  scanned: number;
4
3
  updated: number;
@@ -12,6 +11,4 @@ export interface ConnectorEventScopeBackfillInput {
12
11
  memory_scope_kind?: string;
13
12
  memory_scope_id?: string;
14
13
  }
15
- export declare function backfillLegacyMemoryProvenance(adapter?: DatabaseAdapter | null): Promise<BackfillResult>;
16
- export declare function backfillConnectorEventScopeMetadata(input: ConnectorEventScopeBackfillInput, adapter?: DatabaseAdapter | null): Promise<BackfillResult>;
17
14
  //# sourceMappingURL=scope-backfill.d.ts.map
@@ -1,77 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.backfillLegacyMemoryProvenance = backfillLegacyMemoryProvenance;
4
- exports.backfillConnectorEventScopeMetadata = backfillConnectorEventScopeMetadata;
5
- const db_manager_js_1 = require("../db-manager.js");
6
- const LEGACY_PROVENANCE_JSON = JSON.stringify({
7
- actor: 'actor:legacy',
8
- source_type: 'legacy',
9
- });
10
- async function backfillLegacyMemoryProvenance(adapter = null) {
11
- await (0, db_manager_js_1.initDB)();
12
- const db = adapter ?? (0, db_manager_js_1.getAdapter)();
13
- const row = db
14
- .prepare(`
15
- SELECT COUNT(*) AS count
16
- FROM decisions
17
- WHERE provenance_json IS NULL
18
- `)
19
- .get();
20
- const result = db
21
- .prepare(`
22
- UPDATE decisions
23
- SET
24
- source_refs_json = COALESCE(source_refs_json, '[]'),
25
- provenance_json = ?
26
- WHERE provenance_json IS NULL
27
- `)
28
- .run(LEGACY_PROVENANCE_JSON);
29
- return {
30
- scanned: row.count,
31
- updated: result.changes,
32
- };
33
- }
34
- async function backfillConnectorEventScopeMetadata(input, adapter = null) {
35
- await (0, db_manager_js_1.initDB)();
36
- const db = adapter ?? (0, db_manager_js_1.getAdapter)();
37
- const assignments = [];
38
- const assignmentParams = [];
39
- for (const column of [
40
- 'source_cursor',
41
- 'tenant_id',
42
- 'project_id',
43
- 'memory_scope_kind',
44
- 'memory_scope_id',
45
- ]) {
46
- const value = input[column];
47
- if (value !== undefined) {
48
- assignments.push(`${column} = COALESCE(${column}, ?)`);
49
- assignmentParams.push(value);
50
- }
51
- }
52
- if (assignments.length === 0) {
53
- return { scanned: 0, updated: 0 };
54
- }
55
- const where = [];
56
- const whereParams = [];
57
- if (input.source_connector !== undefined) {
58
- where.push('source_connector = ?');
59
- whereParams.push(input.source_connector);
60
- }
61
- if (input.source_id !== undefined) {
62
- where.push('source_id = ?');
63
- whereParams.push(input.source_id);
64
- }
65
- const whereSql = where.length > 0 ? ` WHERE ${where.join(' AND ')}` : '';
66
- const scanned = db
67
- .prepare(`SELECT COUNT(*) AS count FROM connector_event_index${whereSql}`)
68
- .get(...whereParams);
69
- const result = db
70
- .prepare(`UPDATE connector_event_index SET ${assignments.join(', ')}${whereSql}`)
71
- .run(...assignmentParams, ...whereParams);
72
- return {
73
- scanned: scanned.count,
74
- updated: result.changes,
75
- };
76
- }
77
3
  //# sourceMappingURL=scope-backfill.js.map
@@ -1,5 +1,4 @@
1
1
  import type { MemoryScopeKind, MemoryScopeRef } from './types.js';
2
2
  export declare const PRIORITY_SCOPE_ORDER: MemoryScopeKind[];
3
3
  export declare function sortScopesByPriority(scopes: MemoryScopeRef[]): MemoryScopeRef[];
4
- export declare function getPrimaryScope(scopes: MemoryScopeRef[]): MemoryScopeRef | null;
5
4
  //# sourceMappingURL=scope-store.d.ts.map
@@ -2,12 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PRIORITY_SCOPE_ORDER = void 0;
4
4
  exports.sortScopesByPriority = sortScopesByPriority;
5
- exports.getPrimaryScope = getPrimaryScope;
6
5
  exports.PRIORITY_SCOPE_ORDER = ['project', 'channel', 'user', 'global'];
7
6
  function sortScopesByPriority(scopes) {
8
7
  return [...scopes].sort((left, right) => exports.PRIORITY_SCOPE_ORDER.indexOf(left.kind) - exports.PRIORITY_SCOPE_ORDER.indexOf(right.kind));
9
8
  }
10
- function getPrimaryScope(scopes) {
11
- return sortScopesByPriority(scopes)[0] ?? null;
12
- }
13
9
  //# sourceMappingURL=scope-store.js.map
@@ -1,8 +1,5 @@
1
1
  import type { MemoryScopeRef, MemoryTruthRow } from './types.js';
2
2
  export declare function projectMemoryTruth(row: MemoryTruthRow): Promise<void>;
3
- export declare function queryTruthByTopic(topic: string, options?: {
4
- includeHistory?: boolean;
5
- }): Promise<MemoryTruthRow[]>;
6
3
  export declare function queryRelevantTruth(params: {
7
4
  query: string;
8
5
  scopes: MemoryScopeRef[];
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.projectMemoryTruth = projectMemoryTruth;
4
- exports.queryTruthByTopic = queryTruthByTopic;
5
4
  exports.queryRelevantTruth = queryRelevantTruth;
6
5
  const db_manager_js_1 = require("../db-manager.js");
7
6
  function deserializeTruthRow(row) {
@@ -55,27 +54,6 @@ async function projectMemoryTruth(row) {
55
54
  `)
56
55
  .run(row.memory_id, row.topic, row.truth_status, row.effective_summary, row.effective_details, row.trust_score, JSON.stringify(row.scope_refs), JSON.stringify(row.supporting_event_ids), row.superseded_by ?? null, row.contradicted_by ? JSON.stringify(row.contradicted_by) : null, row.memory_id, now, now);
57
56
  }
58
- async function queryTruthByTopic(topic, options = {}) {
59
- await (0, db_manager_js_1.initDB)();
60
- const adapter = (0, db_manager_js_1.getAdapter)();
61
- const rows = adapter
62
- .prepare(`
63
- SELECT mt.memory_id, mt.topic, mt.truth_status, mt.effective_summary, mt.effective_details, mt.trust_score,
64
- mt.scope_refs, mt.supporting_event_ids, mt.superseded_by, mt.contradicted_by, mt.created_at, mt.updated_at,
65
- d.kind
66
- FROM memory_truth mt
67
- LEFT JOIN decisions d ON d.id = mt.memory_id
68
- WHERE mt.topic = ?
69
- ORDER BY mt.updated_at DESC
70
- `)
71
- .all(topic);
72
- return rows
73
- .map(deserializeTruthRow)
74
- .filter((row) => options.includeHistory === true ||
75
- (row.truth_status !== 'quarantined' &&
76
- row.truth_status !== 'superseded' &&
77
- row.truth_status !== 'contradicted'));
78
- }
79
57
  async function queryRelevantTruth(params) {
80
58
  await (0, db_manager_js_1.initDB)();
81
59
  const adapter = (0, db_manager_js_1.getAdapter)();
@@ -306,7 +306,6 @@ export interface ChannelSummaryStateRecord {
306
306
  updated_at: number;
307
307
  }
308
308
  export declare function createEmptyRecallBundle(query: string): RecallBundle;
309
- export declare function createEmptyMemoryAgentBootstrap(input: Pick<MemoryAgentBootstrap, 'scope_context'> & Partial<Omit<MemoryAgentBootstrap, 'scope_context'>>): MemoryAgentBootstrap;
310
309
  export declare function createMemoryAuditAck(input: Pick<MemoryAuditAck, 'status' | 'action' | 'event_ids'> & Partial<MemoryAuditAck>): MemoryAuditAck;
311
310
  export interface ConversationMessage {
312
311
  role: 'user' | 'assistant' | 'system';
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MEMORY_AUDIT_ACK_STATUSES = exports.MEMORY_CONSULT_INTENTS = exports.MEMORY_AGENT_ACTIONS = exports.MEMORY_EDGE_TYPES = exports.MEMORY_TRUTH_STATUSES = exports.MEMORY_STATUSES = exports.MEMORY_KINDS = exports.MEMORY_SCOPE_KINDS = void 0;
4
4
  exports.createEmptyRecallBundle = createEmptyRecallBundle;
5
- exports.createEmptyMemoryAgentBootstrap = createEmptyMemoryAgentBootstrap;
6
5
  exports.createMemoryAuditAck = createMemoryAuditAck;
7
6
  exports.MEMORY_SCOPE_KINDS = ['global', 'user', 'channel', 'project'];
8
7
  exports.MEMORY_KINDS = [
@@ -60,18 +59,6 @@ function createEmptyRecallBundle(query) {
60
59
  },
61
60
  };
62
61
  }
63
- function createEmptyMemoryAgentBootstrap(input) {
64
- return {
65
- current_goal: input.current_goal,
66
- scope_context: input.scope_context,
67
- channel_summary_markdown: input.channel_summary_markdown,
68
- truth_snapshot: input.truth_snapshot ?? [],
69
- open_audit_findings: input.open_audit_findings ?? [],
70
- recent_memory_events: input.recent_memory_events ?? [],
71
- profile_snapshot: input.profile_snapshot,
72
- main_agent_state: input.main_agent_state,
73
- };
74
- }
75
62
  function createMemoryAuditAck(input) {
76
63
  return {
77
64
  status: input.status,
@@ -80,22 +80,6 @@ export declare const updateDecisionOutcome: typeof dbManager.updateDecisionOutco
80
80
  export declare const getPreparedStmt: typeof dbManager.getPreparedStmt;
81
81
  export declare const getDbPath: typeof dbManager.getDbPath;
82
82
  export declare const traverseDecisionChain: typeof dbManager.queryDecisionGraph;
83
- /**
84
- * Get decisions for a specific session
85
- */
86
- export declare function getSessionDecisions(sessionId: string): Promise<unknown[]>;
87
- /**
88
- * Increment usage success counter
89
- */
90
- export declare function incrementUsageSuccess(decisionId: string, timeSaved?: number): Promise<void>;
91
- /**
92
- * Increment usage failure counter
93
- */
94
- export declare function incrementUsageFailure(decisionId: string): Promise<void>;
95
- /**
96
- * Get decision by ID
97
- */
98
- export declare function getDecisionById(decisionId: string): Promise<unknown>;
99
83
  export declare const DB_PATH: string;
100
84
  export declare const DB_DIR: string;
101
85
  export declare const LEGACY_DB_PATH = "~/.spinelift/memories.db";
@@ -51,10 +51,6 @@ var __importStar = (this && this.__importStar) || (function () {
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  exports.DEFAULT_DB_PATH = exports.LEGACY_DB_PATH = exports.DB_DIR = exports.DB_PATH = exports.traverseDecisionChain = exports.getDbPath = exports.getPreparedStmt = exports.updateDecisionOutcome = exports.querySemanticEdges = exports.queryDecisionGraph = exports.insertDecisionWithEmbedding = exports.queryVectorSearch = exports.vectorSearch = exports.insertEmbedding = exports.closeDB = exports.getAdapter = exports.getDB = exports.initDB = void 0;
54
- exports.getSessionDecisions = getSessionDecisions;
55
- exports.incrementUsageSuccess = incrementUsageSuccess;
56
- exports.incrementUsageFailure = incrementUsageFailure;
57
- exports.getDecisionById = getDecisionById;
58
54
  const dbManager = __importStar(require("./db-manager.js"));
59
55
  // Re-export all db-manager functions for backward compatibility
60
56
  // These maintain the same interface as the original memory-store.js
@@ -73,53 +69,6 @@ exports.getPreparedStmt = dbManager.getPreparedStmt;
73
69
  exports.getDbPath = dbManager.getDbPath;
74
70
  // Legacy exports (for backward compatibility with old code)
75
71
  exports.traverseDecisionChain = dbManager.queryDecisionGraph; // Alias
76
- /**
77
- * Get decisions for a specific session
78
- */
79
- async function getSessionDecisions(sessionId) {
80
- const adapter = dbManager.getAdapter();
81
- const stmt = adapter.prepare(`
82
- SELECT * FROM decisions
83
- WHERE session_id = ?
84
- ORDER BY created_at DESC
85
- `);
86
- return stmt.all(sessionId);
87
- }
88
- /**
89
- * Increment usage success counter
90
- */
91
- async function incrementUsageSuccess(decisionId, timeSaved = 0) {
92
- const adapter = dbManager.getAdapter();
93
- const stmt = adapter.prepare(`
94
- UPDATE decisions
95
- SET usage_success = usage_success + 1,
96
- time_saved = time_saved + ?,
97
- updated_at = ?
98
- WHERE id = ?
99
- `);
100
- stmt.run(timeSaved, Date.now(), decisionId);
101
- }
102
- /**
103
- * Increment usage failure counter
104
- */
105
- async function incrementUsageFailure(decisionId) {
106
- const adapter = dbManager.getAdapter();
107
- const stmt = adapter.prepare(`
108
- UPDATE decisions
109
- SET usage_failure = usage_failure + 1,
110
- updated_at = ?
111
- WHERE id = ?
112
- `);
113
- stmt.run(Date.now(), decisionId);
114
- }
115
- /**
116
- * Get decision by ID
117
- */
118
- async function getDecisionById(decisionId) {
119
- const adapter = dbManager.getAdapter();
120
- const stmt = adapter.prepare('SELECT * FROM decisions WHERE id = ?');
121
- return stmt.get(decisionId);
122
- }
123
72
  // Path exports (labels for display/logging, not actual filesystem paths)
124
73
  // Note: Actual paths are managed by sqlite-adapter.ts (~/.claude/mama-memory.db)
125
74
  exports.DB_PATH = process.env.MAMA_DATABASE_URL ? 'PostgreSQL' : 'SQLite';
@@ -5,7 +5,6 @@
5
5
  *
6
6
  * @module ollama-client
7
7
  */
8
- import type { ToolExecution, SessionContext } from './decision-tracker.js';
9
8
  export declare const DEFAULT_MODEL = "exaone3.5:2.4b";
10
9
  export declare const FALLBACK_MODEL = "gemma:2b";
11
10
  export interface GenerateOptions {
@@ -26,20 +25,12 @@ export interface DecisionAnalysisResult {
26
25
  reasoning: string;
27
26
  confidence: number;
28
27
  }
29
- /**
30
- * Analyze decision from tool execution
31
- */
32
- export declare function analyzeDecision(toolExecution: ToolExecution, sessionContext: SessionContext): Promise<DecisionAnalysisResult>;
33
28
  export interface QueryIntentResult {
34
29
  involves_decision: boolean;
35
30
  topic: string | null;
36
31
  query_type: 'recall' | 'evolution' | 'none';
37
32
  reasoning: string;
38
33
  }
39
- /**
40
- * Analyze query intent
41
- */
42
- export declare function analyzeQueryIntent(userMessage: string): Promise<QueryIntentResult>;
43
34
  /**
44
35
  * Check if Ollama is available
45
36
  */
@@ -12,8 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.FALLBACK_MODEL = exports.DEFAULT_MODEL = void 0;
14
14
  exports.generate = generate;
15
- exports.analyzeDecision = analyzeDecision;
16
- exports.analyzeQueryIntent = analyzeQueryIntent;
17
15
  exports.isAvailable = isAvailable;
18
16
  exports.listModels = listModels;
19
17
  const http_1 = __importDefault(require("http"));
@@ -120,129 +118,6 @@ async function generate(prompt, options = {}) {
120
118
  throw error;
121
119
  }
122
120
  }
123
- /**
124
- * Validate DecisionAnalysisResult shape at runtime
125
- */
126
- function isDecisionAnalysisResult(obj) {
127
- if (typeof obj !== 'object' || obj === null) {
128
- return false;
129
- }
130
- const o = obj;
131
- return (typeof o.is_decision === 'boolean' &&
132
- (typeof o.topic === 'string' || o.topic === null) &&
133
- (typeof o.decision === 'string' || o.decision === null) &&
134
- typeof o.reasoning === 'string' &&
135
- typeof o.confidence === 'number');
136
- }
137
- /**
138
- * Validate QueryIntentResult shape at runtime
139
- */
140
- function isQueryIntentResult(obj) {
141
- if (typeof obj !== 'object' || obj === null) {
142
- return false;
143
- }
144
- const o = obj;
145
- return (typeof o.involves_decision === 'boolean' &&
146
- (typeof o.topic === 'string' || o.topic === null) &&
147
- (o.query_type === 'recall' || o.query_type === 'evolution' || o.query_type === 'none') &&
148
- typeof o.reasoning === 'string');
149
- }
150
- /**
151
- * Analyze decision from tool execution
152
- */
153
- async function analyzeDecision(toolExecution, sessionContext) {
154
- const prompt = `
155
- Analyze if this represents a DECISION (not just an action):
156
-
157
- Session Context:
158
- - Latest User Message: ${sessionContext.latest_user_message || 'N/A'}
159
- - Recent Exchange: ${sessionContext.recent_exchange || 'N/A'}
160
-
161
- Tool Execution:
162
- - Tool: ${toolExecution.tool_name ?? 'N/A'}
163
- - Input: ${JSON.stringify(toolExecution.tool_input ?? null)}
164
- - Result: ${toolExecution.exit_code !== undefined ? (toolExecution.exit_code === 0 ? 'SUCCESS' : 'FAILED') : 'UNKNOWN'}
165
-
166
- Decision Indicators:
167
- 1. User explicitly chose between alternatives?
168
- Example: "Let's use JWT" (not "Use JWT" - that's just action)
169
-
170
- 2. User changed previous approach?
171
- Example: "Complex → Simple approach"
172
-
173
- 3. User expressed preference?
174
- Example: "Let's do it this way from now", "This approach is better"
175
-
176
- 4. Significant architectural choice?
177
- Example: "Mesh structure: COMPLEX", "Authentication: JWT"
178
-
179
- Is this a DECISION? Return JSON with "topic" as a short snake_case identifier:
180
- {
181
- "is_decision": boolean,
182
- "topic": string or null (extract main technical topic in snake_case, e.g., "mesh_structure", "database_choice", "auth_strategy"),
183
- "decision": string or null (the actual choice made, e.g., "COMPLEX", "PostgreSQL", "JWT"),
184
- "reasoning": "Why this is/isn't a decision",
185
- "confidence": 0.0-1.0
186
- }
187
-
188
- IMPORTANT: Generate "topic" freely based on context. Do NOT limit to predefined values.
189
- `;
190
- try {
191
- const response = await generate(prompt, {
192
- format: 'json',
193
- temperature: 0.3,
194
- max_tokens: 300,
195
- });
196
- if (!isDecisionAnalysisResult(response)) {
197
- throw new Error('Invalid LLM response shape for DecisionAnalysisResult');
198
- }
199
- return response;
200
- }
201
- catch (error) {
202
- const message = error instanceof Error ? error.message : String(error);
203
- (0, debug_logger_js_1.error)(`[MAMA] Decision analysis FAILED: ${message}`);
204
- throw new Error(`Decision analysis failed: ${message}`);
205
- }
206
- }
207
- /**
208
- * Analyze query intent
209
- */
210
- async function analyzeQueryIntent(userMessage) {
211
- const prompt = `
212
- Analyze this user message to determine if it involves past decisions:
213
-
214
- User Message: "${userMessage}"
215
-
216
- Questions to answer:
217
- 1. Does this query reference past decisions or choices?
218
- 2. Is the user asking about previous approaches?
219
- 3. What topic is being discussed? (e.g., "mesh_structure", "authentication", "testing")
220
-
221
- Return JSON:
222
- {
223
- "involves_decision": boolean,
224
- "topic": "topic_name" | null,
225
- "query_type": "recall" | "evolution" | "none",
226
- "reasoning": "Why this involves/doesn't involve decisions"
227
- }
228
- `;
229
- try {
230
- const response = await generate(prompt, {
231
- format: 'json',
232
- temperature: 0.3,
233
- max_tokens: 200,
234
- });
235
- if (!isQueryIntentResult(response)) {
236
- throw new Error('Invalid LLM response shape for QueryIntentResult');
237
- }
238
- return response;
239
- }
240
- catch (error) {
241
- const message = error instanceof Error ? error.message : String(error);
242
- (0, debug_logger_js_1.error)(`[MAMA] Query intent analysis FAILED: ${message}`);
243
- throw new Error(`Query intent analysis failed: ${message}`);
244
- }
245
- }
246
121
  /**
247
122
  * Check if Ollama is available
248
123
  */
@@ -147,19 +147,5 @@ export declare function getEvidenceImpact(outcome: OutcomeType, durationDays: nu
147
147
  * @param durationDays - Duration in days
148
148
  */
149
149
  export declare function markOutcome(decisionId: string, outcome: OutcomeType, failureReason: string | null, durationDays: number): Promise<void>;
150
- /**
151
- * UserPromptSubmit Handler
152
- *
153
- * Task 4.4: On UserPromptSubmit, analyze user message for indicators
154
- * Task 4.5: If matches + recent decision (< 1 hour), mark outcome
155
- * Task 4.6: Extract failure_reason from user message
156
- * Task 4.7: Calculate duration_days
157
- * Task 4.8: Update decision row
158
- *
159
- * AC #3: Failure tracking (user feedback → outcome marked)
160
- *
161
- * @param hookContext - Hook context from Claude Code
162
- */
163
- export declare function onUserPromptSubmit(hookContext: HookContext): Promise<void>;
164
150
  export {};
165
151
  //# sourceMappingURL=outcome-tracker.d.ts.map
@@ -21,7 +21,6 @@ exports.getRecentDecision = getRecentDecision;
21
21
  exports.calculateDurationDays = calculateDurationDays;
22
22
  exports.getEvidenceImpact = getEvidenceImpact;
23
23
  exports.markOutcome = markOutcome;
24
- exports.onUserPromptSubmit = onUserPromptSubmit;
25
24
  const debug_logger_js_1 = require("./debug-logger.js");
26
25
  const memory_store_js_1 = require("./memory-store.js");
27
26
  const decision_tracker_js_1 = require("./decision-tracker.js");
@@ -269,47 +268,4 @@ async function markOutcome(decisionId, outcome, failureReason, durationDays) {
269
268
  throw new Error(`Failed to mark outcome: ${message}`);
270
269
  }
271
270
  }
272
- /**
273
- * UserPromptSubmit Handler
274
- *
275
- * Task 4.4: On UserPromptSubmit, analyze user message for indicators
276
- * Task 4.5: If matches + recent decision (< 1 hour), mark outcome
277
- * Task 4.6: Extract failure_reason from user message
278
- * Task 4.7: Calculate duration_days
279
- * Task 4.8: Update decision row
280
- *
281
- * AC #3: Failure tracking (user feedback → outcome marked)
282
- *
283
- * @param hookContext - Hook context from Claude Code
284
- */
285
- async function onUserPromptSubmit(hookContext) {
286
- try {
287
- const userMessage = hookContext.user_message || '';
288
- const sessionId = hookContext.session_id || '';
289
- // Task 4.4: Analyze user message for outcome
290
- const outcome = analyzeOutcome(userMessage);
291
- if (!outcome) {
292
- // No clear outcome detected
293
- return;
294
- }
295
- // Task 4.5: Find recent decision (< 1 hour)
296
- const recentDecision = getRecentDecision(sessionId);
297
- if (!recentDecision) {
298
- // No recent decision to mark
299
- return;
300
- }
301
- // Task 4.6: Extract failure reason
302
- const failureReason = extractFailureReason(userMessage, outcome);
303
- // Task 4.7: Calculate duration
304
- const durationDays = calculateDurationDays(recentDecision.created_at);
305
- // Task 4.8: Mark outcome
306
- await markOutcome(recentDecision.id, outcome, failureReason, durationDays);
307
- (0, debug_logger_js_1.info)(`[MAMA] Outcome marked: ${recentDecision.id} → ${outcome} (${durationDays} days)`);
308
- }
309
- catch (error) {
310
- // Log error but don't crash hook
311
- const message = error instanceof Error ? error.message : String(error);
312
- (0, debug_logger_js_1.error)(`[MAMA] Outcome tracking failed: ${message}`);
313
- }
314
- }
315
271
  //# sourceMappingURL=outcome-tracker.js.map
@@ -33,10 +33,6 @@ export declare function logComplete(message: string): void;
33
33
  */
34
34
  export declare function logFailed(message: string): void;
35
35
  export declare const logError: typeof logFailed;
36
- /**
37
- * Log info message
38
- */
39
- export declare function logInfo(message: string): void;
40
36
  /**
41
37
  * Log loading message
42
38
  */
@@ -17,7 +17,6 @@ exports.logError = void 0;
17
17
  exports.logProgress = logProgress;
18
18
  exports.logComplete = logComplete;
19
19
  exports.logFailed = logFailed;
20
- exports.logInfo = logInfo;
21
20
  exports.logLoading = logLoading;
22
21
  exports.logSearching = logSearching;
23
22
  /**
@@ -58,12 +57,6 @@ function logFailed(message) {
58
57
  }
59
58
  // Alias for backward compatibility
60
59
  exports.logError = logFailed;
61
- /**
62
- * Log info message
63
- */
64
- function logInfo(message) {
65
- logProgress(message, 'ℹ️');
66
- }
67
60
  /**
68
61
  * Log loading message
69
62
  */
@@ -1,4 +1,3 @@
1
- import { type ContextRef } from '../context-compile/types.js';
2
1
  export declare const STRICT_SOURCE_REF_KINDS: readonly ["memory", "raw", "entity", "case", "decision", "os_task", "agent_situation_packet", "report_slot", "context_packet", "model_run", "tool_trace", "wiki_page", "report"];
3
2
  export type StrictSourceRefKind = (typeof STRICT_SOURCE_REF_KINDS)[number];
4
3
  export declare const LEGACY_SOURCE_REF_KINDS: readonly ["message", "conversation", "raw_memory"];
@@ -17,13 +16,5 @@ export type SourceRef = {
17
16
  legacy_kind: LegacySourceRefKind;
18
17
  id: string;
19
18
  };
20
- export declare function fromContextRef(ref: ContextRef): SourceRef;
21
- export declare function toContextRef(ref: SourceRef): ContextRef | null;
22
- export declare function fromVerifyArtifact(artifact: {
23
- type: string;
24
- id: string;
25
- }): SourceRef;
26
- export declare function parseSourceRefString(value: string): SourceRef;
27
19
  export declare function serializeSourceRef(ref: SourceRef): string;
28
- export declare function assertNonEmptySourceRefs(refs: readonly SourceRef[]): void;
29
20
  //# sourceMappingURL=source-ref.d.ts.map