memorix 1.10.0 → 1.10.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +2 -0
  3. package/README.zh-CN.md +2 -0
  4. package/dist/cli/index.js +176 -46
  5. package/dist/index.js +160 -45
  6. package/dist/maintenance-runner.js +56 -2
  7. package/dist/media-audio-runner.js +56 -2
  8. package/dist/media-video-runner.js +56 -2
  9. package/dist/memcode-runtime/CHANGELOG.md +11 -0
  10. package/dist/sdk.js +159 -44
  11. package/dist/vector-backfill-runner.js +56 -2
  12. package/docs/1.2.0-EVALUATION-HARNESS.md +18 -0
  13. package/docs/CONFIGURATION.md +25 -0
  14. package/docs/DEVELOPMENT.md +4 -3
  15. package/docs/README.md +2 -2
  16. package/docs/ROADMAP-1.9.12-2.0.md +13 -6
  17. package/package.json +1 -1
  18. package/plugins/antigravity/memorix/plugin.json +1 -1
  19. package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
  20. package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
  21. package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
  22. package/plugins/copilot/memorix/plugin.json +1 -1
  23. package/plugins/gemini/memorix/gemini-extension.json +1 -1
  24. package/plugins/hermes/memorix/plugin.yaml +1 -1
  25. package/plugins/omp/memorix/package.json +1 -1
  26. package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
  27. package/plugins/pi/memorix/package.json +1 -1
  28. package/server.json +2 -2
  29. package/src/cli/commands/init.ts +6 -2
  30. package/src/cli/tui/ConfigureView.tsx +2 -0
  31. package/src/codegraph/auto-context.ts +17 -0
  32. package/src/codegraph/context-pack.ts +15 -0
  33. package/src/compact/engine.ts +11 -0
  34. package/src/config/dotenv-loader.ts +1 -0
  35. package/src/config/resolved-config.ts +5 -2
  36. package/src/config/yaml-loader.ts +2 -2
  37. package/src/dashboard/server.ts +3 -0
  38. package/src/knowledge/context-assembly.ts +13 -0
  39. package/src/knowledge/context-receipt.ts +32 -0
  40. package/src/knowledge/workset.ts +8 -0
  41. package/src/llm/provider.ts +2 -1
  42. package/src/multimodal/image-loader.ts +2 -2
  43. package/src/search/derived-view-receipt.ts +22 -0
  44. package/src/store/orama-store.ts +62 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memorix-pi-package",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "Memorix shared workspace memory package for Pi coding agent.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
package/server.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "https://github.com/AVIDS2/memorix",
8
8
  "source": "github"
9
9
  },
10
- "version": "1.10.0",
10
+ "version": "1.10.1",
11
11
  "websiteUrl": "https://mem.rglens.com",
12
12
  "icons": [
13
13
  {
@@ -22,7 +22,7 @@
22
22
  {
23
23
  "registryType": "npm",
24
24
  "identifier": "memorix",
25
- "version": "1.10.0",
25
+ "version": "1.10.1",
26
26
  "runtimeHint": "npx",
27
27
  "packageArguments": [
28
28
  {
@@ -21,7 +21,7 @@ import {
21
21
  type InitScope,
22
22
  } from './init-shared.js';
23
23
 
24
- type InitLlmProvider = 'none' | 'openai' | 'anthropic' | 'openrouter' | 'requesty' | 'apiroute' | 'atlascloud' | 'custom';
24
+ type InitLlmProvider = 'none' | 'openai' | 'anthropic' | 'openrouter' | 'requesty' | 'apiroute' | 'cheaperinference' | 'atlascloud' | 'custom';
25
25
  type InitEmbeddingProvider = 'off' | 'api' | 'fastembed';
26
26
  type InitInjectMode = 'minimal' | 'full' | 'silent';
27
27
 
@@ -105,6 +105,7 @@ export default defineCommand({
105
105
  { value: 'openrouter', label: 'OpenRouter', hint: 'multi-provider' },
106
106
  { value: 'requesty', label: 'Requesty', hint: 'multi-provider' },
107
107
  { value: 'apiroute', label: 'API Route', hint: 'multi-provider' },
108
+ { value: 'cheaperinference', label: 'Cheaper Inference', hint: 'multi-provider' },
108
109
  { value: 'atlascloud', label: 'Atlas Cloud', hint: 'DeepSeek V3.2' },
109
110
  { value: 'custom', label: 'Custom', hint: 'OpenAI-compatible endpoint' },
110
111
  ],
@@ -165,7 +166,7 @@ export default defineCommand({
165
166
 
166
167
  if (llmProvider !== 'none') {
167
168
  envLines.push('# LLM API key');
168
- if (llmProvider === 'openai' || llmProvider === 'custom' || llmProvider === 'atlascloud' || llmProvider === 'apiroute') {
169
+ if (llmProvider === 'openai' || llmProvider === 'custom' || llmProvider === 'atlascloud' || llmProvider === 'apiroute' || llmProvider === 'cheaperinference') {
169
170
  envLines.push('MEMORIX_LLM_API_KEY=sk-your-key-here');
170
171
  } else if (llmProvider === 'anthropic') {
171
172
  envLines.push('MEMORIX_LLM_API_KEY=sk-ant-your-key-here');
@@ -203,6 +204,7 @@ export default defineCommand({
203
204
  envLines.push('# OPENROUTER_API_KEY=sk-or-...');
204
205
  envLines.push('# REQUESTY_API_KEY=rqsty-...');
205
206
  envLines.push('# API_ROUTE_API_KEY=sk-...');
207
+ envLines.push('# CHEAPER_INFERENCE_API_KEY=ci_live_...');
206
208
  envLines.push('');
207
209
 
208
210
  mkdirSync(targetDir, { recursive: true });
@@ -303,6 +305,8 @@ export function buildInitTomlConfig(options: {
303
305
  lines.push('# model = "openai/gpt-4o-mini"');
304
306
  } else if (options.llmProvider === 'apiroute') {
305
307
  lines.push('model = "deepseek-v4.1-flash"');
308
+ } else if (options.llmProvider === 'cheaperinference') {
309
+ lines.push('model = "gpt-5.4-mini"');
306
310
  } else if (options.llmProvider === 'atlascloud') {
307
311
  lines.push('model = "deepseek-ai/deepseek-v3.2"');
308
312
  }
@@ -168,6 +168,7 @@ export function ConfigureView({ onBack }: ConfigureViewProps): React.ReactElemen
168
168
  { key: 'openrouter', label: 'OpenRouter', hint: 'multi-provider' },
169
169
  { key: 'requesty', label: 'Requesty', hint: 'multi-provider' },
170
170
  { key: 'apiroute', label: 'API Route', hint: 'multi-provider' },
171
+ { key: 'cheaperinference', label: 'Cheaper Inference', hint: 'multi-provider' },
171
172
  { key: 'atlascloud', label: 'Atlas Cloud', hint: 'DeepSeek V3.2' },
172
173
  { key: 'custom', label: 'Custom endpoint', hint: 'OpenAI-compatible' },
173
174
  { key: 'disable', label: 'Disable LLM', hint: 'free heuristic mode', color: COLORS.warning },
@@ -451,6 +452,7 @@ function getDefaultModel(provider: string): string {
451
452
  if (provider === 'openrouter') return 'openai/gpt-4o-mini';
452
453
  if (provider === 'requesty') return 'openai/gpt-4o-mini';
453
454
  if (provider === 'apiroute') return 'deepseek-v4.1-flash';
455
+ if (provider === 'cheaperinference') return 'gpt-5.4-mini';
454
456
  if (provider === 'atlascloud') return 'deepseek-ai/deepseek-v3.2';
455
457
  return 'gpt-4o-mini';
456
458
  }
@@ -33,6 +33,7 @@ import { getSessionResumeBrief } from '../memory/session.js';
33
33
  import { listLongTermMemories } from '../memory/long-term.js';
34
34
  import { filterReadableObservations } from '../memory/visibility.js';
35
35
  import { initSessionStore } from '../store/session-store.js';
36
+ import { buildCodeGraphDerivedView } from '../knowledge/context-receipt.js';
36
37
  import type { TaskContinuityLedger } from '../knowledge/task-continuity.js';
37
38
  import {
38
39
  isContinuationTask,
@@ -464,6 +465,22 @@ export async function buildAutoProjectContext(input: {
464
465
  mode: semanticOutline ? 'hybrid' : 'lexical',
465
466
  codeProvider: providerQuality.selected,
466
467
  ...(externalCaution ? { fallbackReason: externalCaution } : {}),
468
+ derivedViews: {
469
+ graph: buildCodeGraphDerivedView({
470
+ providerQuality,
471
+ ...(latestSnapshot
472
+ ? {
473
+ snapshot: {
474
+ id: latestSnapshot.id,
475
+ sourceEpoch: latestSnapshot.sourceEpoch,
476
+ incomplete: latestSnapshot.completeness.skippedOversizedFiles > 0
477
+ || (latestSnapshot.completeness.unreadableFiles ?? 0) > 0
478
+ || latestSnapshot.completeness.removalScanDeferred,
479
+ },
480
+ }
481
+ : {}),
482
+ }),
483
+ },
467
484
  },
468
485
  currentFacts: worksetFactLines(currentFacts),
469
486
  ...(continuation ? { continuation } : {}),
@@ -1,4 +1,5 @@
1
1
  import { evaluateCodeRefFreshness } from './freshness.js';
2
+ import { buildCodeGraphDerivedView } from '../knowledge/context-receipt.js';
2
3
  import { buildTaskWorkset, type TaskWorkset, type WorksetCaution } from '../knowledge/workset.js';
3
4
  import type {
4
5
  CodeFile,
@@ -311,6 +312,20 @@ export async function attachTaskWorkset(input: {
311
312
  retrieval: {
312
313
  mode: semanticCode ? 'hybrid' : 'unknown',
313
314
  ...(input.providerQuality?.selected ? { codeProvider: input.providerQuality.selected } : {}),
315
+ derivedViews: {
316
+ graph: buildCodeGraphDerivedView({
317
+ providerQuality: input.providerQuality,
318
+ ...(input.snapshot
319
+ ? {
320
+ snapshot: {
321
+ id: input.snapshot.id,
322
+ sourceEpoch: input.snapshot.sourceEpoch,
323
+ incomplete: input.snapshot.incomplete,
324
+ },
325
+ }
326
+ : {}),
327
+ }),
328
+ },
314
329
  },
315
330
  reliableMemory: input.pack.memories
316
331
  .filter(memory => memory.status === 'current')
@@ -17,6 +17,7 @@ import {
17
17
  makeOramaObservationId,
18
18
  getLastSearchMode,
19
19
  getLastSearchDiagnostics,
20
+ getSearchDerivedViews,
20
21
  } from '../store/orama-store.js';
21
22
  import { getObservation, getAllObservations } from '../memory/observations.js';
22
23
  import { ensureFreshIndex } from '../memory/freshness.js';
@@ -79,6 +80,7 @@ export interface CompactSearchReceipt {
79
80
  omittedByTokenBudget: number;
80
81
  fallbackUsed: boolean;
81
82
  fallbackReason?: string;
83
+ derivedViews: import('../search/derived-view-receipt.js').RetrievalDerivedViews;
82
84
  tokenCount: number;
83
85
  elapsedMs: number;
84
86
  }
@@ -156,6 +158,14 @@ export async function compactSearch(options: SearchOptions, surface: RetrievalSu
156
158
 
157
159
  const totalTokens = countTextTokens(formatted);
158
160
  const diagnostics = getLastSearchDiagnostics(options.projectId);
161
+ const derivedViews = getSearchDerivedViews();
162
+ if (diagnostics?.fallbackUsed && diagnostics.fallbackReason) {
163
+ derivedViews.embedding = {
164
+ freshness: 'stale',
165
+ rebuildStatus: 'failed',
166
+ failureReason: diagnostics.fallbackReason,
167
+ };
168
+ }
159
169
 
160
170
  return {
161
171
  entries,
@@ -171,6 +181,7 @@ export async function compactSearch(options: SearchOptions, surface: RetrievalSu
171
181
  omittedByTokenBudget: diagnostics?.omittedByTokenBudget ?? 0,
172
182
  fallbackUsed: diagnostics?.fallbackUsed ?? false,
173
183
  ...(diagnostics?.fallbackReason ? { fallbackReason: diagnostics.fallbackReason } : {}),
184
+ derivedViews,
174
185
  tokenCount: totalTokens,
175
186
  elapsedMs: Math.max(0, Date.now() - startedAt),
176
187
  },
@@ -145,6 +145,7 @@ export function getLoadedEnvValue(key: string): string | undefined {
145
145
  // OPENROUTER_API_KEY — OpenRouter compatibility fallback
146
146
  // REQUESTY_API_KEY - Requesty memory preset and embedding endpoint key
147
147
  // API_ROUTE_API_KEY - API Route memory preset key (only when selected)
148
+ // CHEAPER_INFERENCE_API_KEY - Cheaper Inference memory preset key (only when selected)
148
149
  // MINIMAX_API_KEY — MiniMax global image/video generation key
149
150
  // MINIMAX_CN_API_KEY — MiniMax China-region image/video generation key
150
151
  // MINIMAX_REGION — MiniMax region: global or cn
@@ -121,7 +121,8 @@ export function getResolvedConfig(options: ResolvedLaneOptions = {}): ResolvedMe
121
121
  const isAtlasCloud = memoryLlmProvider === 'atlascloud';
122
122
  const isRequesty = memoryLlmProvider === 'requesty';
123
123
  const isApiRoute = memoryLlmProvider === 'apiroute';
124
- const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute;
124
+ const isCheaperInference = memoryLlmProvider === 'cheaperinference';
125
+ const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute || isCheaperInference;
125
126
  const memoryLlmApiKey = first(
126
127
  process.env.MEMORIX_LLM_API_KEY,
127
128
  process.env.MEMORIX_API_KEY,
@@ -131,7 +132,8 @@ export function getResolvedConfig(options: ResolvedLaneOptions = {}): ResolvedMe
131
132
  // Never borrow another provider's credentials for these gateway presets.
132
133
  isAtlasCloud ? process.env.ATLASCLOUD_API_KEY
133
134
  : isRequesty ? process.env.REQUESTY_API_KEY
134
- : isApiRoute ? process.env.API_ROUTE_API_KEY : process.env.OPENAI_API_KEY,
135
+ : isApiRoute ? process.env.API_ROUTE_API_KEY
136
+ : isCheaperInference ? process.env.CHEAPER_INFERENCE_API_KEY : process.env.OPENAI_API_KEY,
135
137
  usesPresetKeyOnly ? undefined : process.env.ANTHROPIC_API_KEY,
136
138
  usesPresetKeyOnly ? undefined : openRouterMemoryLlmApiKey,
137
139
  );
@@ -331,6 +333,7 @@ function getEnvSourceNames(): string[] {
331
333
  'OPENROUTER_API_KEY',
332
334
  'REQUESTY_API_KEY',
333
335
  'API_ROUTE_API_KEY',
336
+ 'CHEAPER_INFERENCE_API_KEY',
334
337
  'ATLASCLOUD_API_KEY',
335
338
  ].filter((name) => process.env[name]);
336
339
  }
@@ -25,7 +25,7 @@ import { getGlobalYamlPath, getProjectYamlPath } from './config-paths.js';
25
25
  export interface MemorixYamlConfig {
26
26
  /** LLM provider configuration */
27
27
  llm?: {
28
- provider?: 'openai' | 'anthropic' | 'openrouter' | 'requesty' | 'apiroute' | string;
28
+ provider?: 'openai' | 'anthropic' | 'openrouter' | 'requesty' | 'apiroute' | 'cheaperinference' | string;
29
29
  model?: string;
30
30
  apiKey?: string;
31
31
  baseUrl?: string;
@@ -33,7 +33,7 @@ export interface MemorixYamlConfig {
33
33
 
34
34
  /** TUI / chat agent LLM provider configuration */
35
35
  agent?: {
36
- provider?: 'openai' | 'anthropic' | 'openrouter' | 'requesty' | 'apiroute' | string;
36
+ provider?: 'openai' | 'anthropic' | 'openrouter' | 'requesty' | 'apiroute' | 'cheaperinference' | string;
37
37
  model?: string;
38
38
  apiKey?: string;
39
39
  baseUrl?: string;
@@ -688,6 +688,9 @@ async function handleApi(
688
688
  ...(resolved.memory.llm.provider === 'apiroute'
689
689
  ? ['API_ROUTE_API_KEY']
690
690
  : []),
691
+ ...(resolved.memory.llm.provider === 'cheaperinference'
692
+ ? ['CHEAPER_INFERENCE_API_KEY']
693
+ : []),
691
694
  ];
692
695
  if (llmKey) {
693
696
  const src = resolveDashboardKeySource({ value: llmKey, envKeys: memoryKeyEnv, configSource });
@@ -1,3 +1,5 @@
1
+ import type { RetrievalDerivedViews } from '../search/derived-view-receipt.js';
2
+
1
3
  /**
2
4
  * Shared metadata contract for every bounded context delivery surface.
3
5
  * The rendered Workset stays agent-facing; this receipt is for JSON, explain,
@@ -41,6 +43,7 @@ export interface ContextReceiptRetrieval {
41
43
  candidateCount: number;
42
44
  selectedCount: number;
43
45
  omittedCount: number;
46
+ derivedViews?: RetrievalDerivedViews;
44
47
  }
45
48
 
46
49
  export interface ContextReceiptSelection {
@@ -121,6 +124,16 @@ export function formatContextReceipt(receipt: ContextReceipt): string {
121
124
  lines.push(`- Fallback: ${receipt.retrieval.fallbackReason ?? 'retrieval fallback used'}`);
122
125
  }
123
126
 
127
+ if (receipt.retrieval.derivedViews) {
128
+ lines.push('', 'Derived views');
129
+ for (const [name, view] of Object.entries(receipt.retrieval.derivedViews)) {
130
+ if (!view) continue;
131
+ const generation = view.generation === undefined ? '' : `, generation=${view.generation}`;
132
+ const reason = view.failureReason ? `, reason=${view.failureReason}` : '';
133
+ lines.push(`- ${name}: ${view.freshness}/${view.rebuildStatus}${generation}${reason}`);
134
+ }
135
+ }
136
+
124
137
  if (receipt.selected.length > 0) {
125
138
  lines.push('', 'Selected evidence');
126
139
  for (const item of receipt.selected.slice(0, 20)) {
@@ -1,4 +1,5 @@
1
1
  import type { CodeGraphProviderQuality } from '../codegraph/types.js';
2
+ import type { RetrievalDerivedViewReceipt } from '../search/derived-view-receipt.js';
2
3
  import type { TaskWorkset } from './workset.js';
3
4
  import type { TaskContinuityLedger } from './task-continuity.js';
4
5
 
@@ -26,6 +27,37 @@ export interface BoundedContextReceipt {
26
27
  };
27
28
  }
28
29
 
30
+ /** Build the graph view status without exposing source contents or paths. */
31
+ export function buildCodeGraphDerivedView(input: {
32
+ providerQuality?: CodeGraphProviderQuality;
33
+ snapshot?: { id?: string; sourceEpoch?: number; incomplete?: boolean };
34
+ }): RetrievalDerivedViewReceipt {
35
+ const provider = input.providerQuality;
36
+ const snapshot = input.snapshot;
37
+ const externalFailure = provider?.external.state !== undefined
38
+ && !['ready', 'disabled', 'not-detected'].includes(provider.external.state);
39
+ if (snapshot?.id) {
40
+ return {
41
+ ...(snapshot.sourceEpoch !== undefined ? { generation: snapshot.sourceEpoch } : {}),
42
+ freshness: snapshot.incomplete ? 'stale' : 'current',
43
+ rebuildStatus: snapshot.incomplete ? 'failed' : 'idle',
44
+ ...(snapshot.incomplete
45
+ ? { failureReason: 'latest CodeGraph snapshot is incomplete' }
46
+ : externalFailure && provider?.external.reason
47
+ ? { failureReason: provider.external.reason.slice(0, 240) }
48
+ : {}),
49
+ };
50
+ }
51
+
52
+ return {
53
+ freshness: 'unknown',
54
+ rebuildStatus: externalFailure ? 'failed' : 'unavailable',
55
+ ...(provider?.external.reason
56
+ ? { failureReason: provider.external.reason.slice(0, 240) }
57
+ : { failureReason: 'CodeGraph snapshot is not initialized' }),
58
+ };
59
+ }
60
+
29
61
  export function buildBoundedContextReceipt(input: {
30
62
  workset: TaskWorkset;
31
63
  providerQuality?: CodeGraphProviderQuality;
@@ -27,6 +27,8 @@ import type { WorkflowSelection } from './workflow-types.js';
27
27
  import type { ObservationReader } from '../types.js';
28
28
  import type { LongTermMemory, LongTermMemoryEvidence } from '../memory/long-term-types.js';
29
29
  import type { TaskContinuityLedger } from './task-continuity.js';
30
+ import { getSearchDerivedViews } from '../store/orama-store.js';
31
+ import type { RetrievalDerivedViews } from '../search/derived-view-receipt.js';
30
32
 
31
33
  export type WorksetCautionKind =
32
34
  | 'dirty-worktree'
@@ -211,6 +213,7 @@ export interface BuildTaskWorksetInput {
211
213
  mode: ContextRetrievalMode;
212
214
  codeProvider?: string;
213
215
  fallbackReason?: string;
216
+ derivedViews?: RetrievalDerivedViews;
214
217
  };
215
218
  reliableMemory?: WorksetMemorySource[];
216
219
  cautionMemory?: WorksetMemorySource[];
@@ -1246,6 +1249,10 @@ export async function buildTaskWorkset(input: BuildTaskWorksetInput): Promise<Ta
1246
1249
  budget: { maxTokens },
1247
1250
  });
1248
1251
  const omittedReceipt = receiptOmissions(rendered.omittedItems, base.hiddenCautionMemoryCount);
1252
+ const derivedViews: RetrievalDerivedViews = {
1253
+ ...getSearchDerivedViews(),
1254
+ ...(input.retrieval?.derivedViews ?? {}),
1255
+ };
1249
1256
  const retrieval = {
1250
1257
  mode: input.retrieval?.mode ?? (input.semanticCode ? 'hybrid' : 'unknown'),
1251
1258
  ...(input.retrieval?.codeProvider || input.providerQuality?.selected
@@ -1256,6 +1263,7 @@ export async function buildTaskWorkset(input: BuildTaskWorksetInput): Promise<Ta
1256
1263
  candidateCount: governed.plan.decisions.length,
1257
1264
  selectedCount: rendered.selected.length,
1258
1265
  omittedCount: omittedReceipt.reduce((total, omission) => total + omission.count, 0),
1266
+ derivedViews,
1259
1267
  } as const;
1260
1268
  const receipt: ContextReceipt = {
1261
1269
  version: '1.3',
@@ -20,7 +20,7 @@ import {
20
20
  } from '../config.js';
21
21
 
22
22
  export interface LLMConfig {
23
- provider: 'openai' | 'anthropic' | 'openrouter' | 'requesty' | 'apiroute' | 'atlascloud' | 'custom';
23
+ provider: 'openai' | 'anthropic' | 'openrouter' | 'requesty' | 'apiroute' | 'cheaperinference' | 'atlascloud' | 'custom';
24
24
  apiKey: string;
25
25
  model?: string;
26
26
  baseUrl?: string;
@@ -203,6 +203,7 @@ const PROVIDER_DEFAULTS: Record<string, { baseUrl: string; model: string }> = {
203
203
  openrouter: { baseUrl: 'https://openrouter.ai/api/v1', model: 'openai/gpt-4.1-nano' },
204
204
  requesty: { baseUrl: 'https://router.requesty.ai/v1', model: 'openai/gpt-4.1-nano' },
205
205
  apiroute: { baseUrl: 'https://global.api-route.com/v1', model: 'deepseek-v4.1-flash' },
206
+ cheaperinference: { baseUrl: 'https://api.cheaperinference.com/v1', model: 'gpt-5.4-mini' },
206
207
  atlascloud: { baseUrl: 'https://api.atlascloud.ai/v1', model: 'deepseek-ai/deepseek-v3.2' },
207
208
  custom: { baseUrl: 'http://localhost:11434/v1', model: 'llama3' },
208
209
  };
@@ -19,7 +19,7 @@ import {
19
19
  } from './image-payload.js';
20
20
 
21
21
  // Providers that use the OpenAI-compatible /chat/completions Vision endpoint
22
- const OPENAI_COMPATIBLE_PROVIDERS = new Set(['openai', 'openrouter', 'requesty', 'apiroute', 'custom']);
22
+ const OPENAI_COMPATIBLE_PROVIDERS = new Set(['openai', 'openrouter', 'requesty', 'apiroute', 'cheaperinference', 'custom']);
23
23
  const MAX_VISION_PROMPT_CHARS = 12_000;
24
24
  const MAX_VISION_DESCRIPTION_CHARS = 12_000;
25
25
  const MAX_VISION_LABELS = 50;
@@ -138,7 +138,7 @@ export async function analyzeImage(input: ImageInput): Promise<ImageAnalysisResu
138
138
  const config = getLLMConfig()!;
139
139
  if (!OPENAI_COMPATIBLE_PROVIDERS.has(config.provider)) {
140
140
  throw new Error(
141
- `Image analysis requires an OpenAI-compatible provider (openai, openrouter, requesty, apiroute, or custom). ` +
141
+ `Image analysis requires an OpenAI-compatible provider (openai, openrouter, requesty, apiroute, cheaperinference, or custom). ` +
142
142
  `Current provider "${config.provider}" uses a different API shape. ` +
143
143
  `Set MEMORIX_LLM_PROVIDER=openai or configure an OpenAI-compatible base URL.`,
144
144
  );
@@ -0,0 +1,22 @@
1
+ /** Privacy-safe health metadata for retrieval's derived evidence views. */
2
+ export type RetrievalDerivedViewName = 'fts' | 'orama' | 'embedding' | 'graph';
3
+
4
+ export type RetrievalDerivedViewFreshness = 'current' | 'stale' | 'unknown';
5
+
6
+ export type RetrievalDerivedViewRebuildStatus =
7
+ | 'idle'
8
+ | 'rebuilding'
9
+ | 'unavailable'
10
+ | 'failed'
11
+ | 'disabled';
12
+
13
+ export interface RetrievalDerivedViewReceipt {
14
+ /** Durable or process-local generation when one exists. */
15
+ generation?: number;
16
+ freshness: RetrievalDerivedViewFreshness;
17
+ rebuildStatus: RetrievalDerivedViewRebuildStatus;
18
+ /** Bounded operator-facing reason; never raw memory content. */
19
+ failureReason?: string;
20
+ }
21
+
22
+ export type RetrievalDerivedViews = Partial<Record<RetrievalDerivedViewName, RetrievalDerivedViewReceipt>>;
@@ -33,6 +33,7 @@ import {
33
33
  type SemanticIndexProfile,
34
34
  type SemanticVectorRecord,
35
35
  } from '../search/semantic-index.js';
36
+ import type { RetrievalDerivedViews } from '../search/derived-view-receipt.js';
36
37
 
37
38
  let db: AnyOrama | null = null;
38
39
  let dbInitPromise: Promise<AnyOrama> | null = null;
@@ -77,6 +78,67 @@ export function getLastSearchDiagnostics(projectId?: string): SearchDiagnostics
77
78
  return diagnostics ? { ...diagnostics } : undefined;
78
79
  }
79
80
 
81
+ /**
82
+ * Return bounded health metadata for the derived views used by retrieval.
83
+ * This is intentionally synchronous and network-free; provider initialization
84
+ * remains owned by the request that actually needs semantic search.
85
+ */
86
+ export function getSearchDerivedViews(): RetrievalDerivedViews {
87
+ const views: RetrievalDerivedViews = {};
88
+ const store = getOptionalObservationStore();
89
+ if (store) {
90
+ try {
91
+ const generation = store.getGeneration();
92
+ if (store.hasLexicalIndex?.()) {
93
+ views.fts = { generation, freshness: 'current', rebuildStatus: 'idle' };
94
+ } else {
95
+ views.fts = {
96
+ generation,
97
+ freshness: 'unknown',
98
+ rebuildStatus: 'unavailable',
99
+ failureReason: store.getBackendReason?.() ?? 'persistent lexical index unavailable',
100
+ };
101
+ }
102
+ } catch (error) {
103
+ views.fts = {
104
+ freshness: 'unknown',
105
+ rebuildStatus: 'failed',
106
+ failureReason: error instanceof Error ? error.message.slice(0, 240) : String(error).slice(0, 240),
107
+ };
108
+ }
109
+ } else {
110
+ views.fts = {
111
+ freshness: 'unknown',
112
+ rebuildStatus: 'unavailable',
113
+ failureReason: 'observation store is not initialized',
114
+ };
115
+ }
116
+
117
+ views.orama = db
118
+ ? { generation: dbGeneration, freshness: 'current', rebuildStatus: 'idle' }
119
+ : {
120
+ generation: dbGeneration,
121
+ freshness: 'unknown',
122
+ rebuildStatus: 'unavailable',
123
+ failureReason: 'Orama index is not initialized',
124
+ };
125
+
126
+ const configuredEmbeddingMode = process.env.MEMORIX_EMBEDDING?.trim().toLowerCase();
127
+ if (configuredEmbeddingMode === 'off') {
128
+ views.embedding = { freshness: 'current', rebuildStatus: 'disabled' };
129
+ } else if (embeddingEnabled) {
130
+ views.embedding = { freshness: 'current', rebuildStatus: 'idle' };
131
+ } else {
132
+ views.embedding = {
133
+ freshness: 'unknown',
134
+ rebuildStatus: 'unavailable',
135
+ failureReason: 'embedding provider is not initialized',
136
+ };
137
+ }
138
+
139
+ return views;
140
+ }
141
+
80
142
  function rememberSearchDiagnostics(key: string, value: SearchDiagnostics): void {
81
143
  if (!lastSearchDiagnosticsByProject.has(key) && lastSearchDiagnosticsByProject.size >= MAX_SEARCH_MODE_KEYS) {
82
144
  const oldest = lastSearchDiagnosticsByProject.keys().next().value;