memorix 1.10.0 → 1.10.2
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/CHANGELOG.md +25 -0
- package/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/cli/index.js +575 -196
- package/dist/index.js +375 -134
- package/dist/maintenance-runner.js +210 -46
- package/dist/media-audio-runner.js +182 -18
- package/dist/media-video-runner.js +209 -45
- package/dist/memcode-runtime/CHANGELOG.md +25 -0
- package/dist/sdk.js +426 -134
- package/dist/vector-backfill-runner.js +209 -45
- package/docs/1.2.0-EVALUATION-HARNESS.md +18 -0
- package/docs/CONFIGURATION.md +25 -0
- package/docs/DEVELOPMENT.md +3 -3
- package/docs/PERFORMANCE.md +23 -0
- package/docs/README.md +2 -2
- package/docs/ROADMAP-1.9.12-2.0.md +13 -6
- package/package.json +1 -1
- package/plugins/antigravity/memorix/plugin.json +1 -1
- package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
- package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
- package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
- package/plugins/copilot/memorix/plugin.json +1 -1
- package/plugins/gemini/memorix/gemini-extension.json +1 -1
- package/plugins/hermes/memorix/__init__.py +1 -2
- package/plugins/hermes/memorix/plugin.yaml +1 -1
- package/plugins/omp/memorix/package.json +1 -1
- package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
- package/plugins/pi/memorix/package.json +1 -1
- package/server.json +2 -2
- package/src/cli/commands/init.ts +6 -2
- package/src/cli/commands/repair.ts +17 -3
- package/src/cli/tui/ConfigureView.tsx +2 -0
- package/src/codegraph/auto-context.ts +17 -0
- package/src/codegraph/context-pack.ts +15 -0
- package/src/compact/engine.ts +11 -0
- package/src/compact/index-format.ts +1 -1
- package/src/config/dotenv-loader.ts +1 -0
- package/src/config/resolved-config.ts +5 -2
- package/src/config/yaml-loader.ts +2 -2
- package/src/dashboard/server.ts +3 -0
- package/src/knowledge/context-assembly.ts +13 -0
- package/src/knowledge/context-receipt.ts +35 -0
- package/src/knowledge/workset.ts +8 -0
- package/src/llm/provider.ts +2 -1
- package/src/memory/observations.ts +7 -5
- package/src/multimodal/image-loader.ts +2 -2
- package/src/search/derived-view-receipt.ts +62 -0
- package/src/search/semantic-index.ts +149 -1
- package/src/server.ts +18 -3
- package/src/store/orama-store.ts +80 -2
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.
|
|
10
|
+
"version": "1.10.2",
|
|
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.
|
|
25
|
+
"version": "1.10.2",
|
|
26
26
|
"runtimeHint": "npx",
|
|
27
27
|
"packageArguments": [
|
|
28
28
|
{
|
package/src/cli/commands/init.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* memorix repair —
|
|
2
|
+
* memorix repair — Repair agent integrations and derived indexes.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { defineCommand } from 'citty';
|
|
@@ -7,7 +7,7 @@ import { defineCommand } from 'citty';
|
|
|
7
7
|
export default defineCommand({
|
|
8
8
|
meta: {
|
|
9
9
|
name: 'repair',
|
|
10
|
-
description: 'Repair
|
|
10
|
+
description: 'Repair agent integrations or compact the semantic index',
|
|
11
11
|
},
|
|
12
12
|
args: {
|
|
13
13
|
agent: {
|
|
@@ -33,8 +33,22 @@ export default defineCommand({
|
|
|
33
33
|
const positional = (args._ as string[]) ?? [];
|
|
34
34
|
const action = positional[0] || 'agents';
|
|
35
35
|
|
|
36
|
+
if (action === 'index') {
|
|
37
|
+
if (args.dry) throw new Error('`memorix repair index` does not support --dry');
|
|
38
|
+
const { detectProject } = await import('../../project/detector.js');
|
|
39
|
+
const { getProjectDataDir } = await import('../../store/persistence.js');
|
|
40
|
+
const { optimizeSemanticIndexes } = await import('../../search/semantic-index.js');
|
|
41
|
+
const project = detectProject(process.cwd());
|
|
42
|
+
if (!project) throw new Error('Run `memorix repair index` inside a Git project');
|
|
43
|
+
const dataDir = await getProjectDataDir(project.id);
|
|
44
|
+
const tables = await optimizeSemanticIndexes(dataDir);
|
|
45
|
+
if (args.json) console.log(JSON.stringify({ dataDir, optimizedTables: tables }, null, 2));
|
|
46
|
+
else console.log(`Optimized ${tables.length} semantic table(s) in ${dataDir}`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
36
50
|
if (action !== 'agents') {
|
|
37
|
-
const message = 'Usage: memorix repair agents [--agent <agent>] [--scope local|project|global|all] [--dry]';
|
|
51
|
+
const message = 'Usage: memorix repair agents [--agent <agent>] [--scope local|project|global|all] [--dry] | memorix repair index [--json]';
|
|
38
52
|
if (args.json) {
|
|
39
53
|
console.log(JSON.stringify({ error: message }, null, 2));
|
|
40
54
|
} else {
|
|
@@ -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')
|
package/src/compact/engine.ts
CHANGED
|
@@ -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
|
},
|
|
@@ -348,7 +348,7 @@ function getProgressiveDisclosureHint(hasProject: boolean, surface: RetrievalSur
|
|
|
348
348
|
// ── Phase 3a display helpers ──────────────────────────────────────
|
|
349
349
|
|
|
350
350
|
/** Format an entry reference as a canonical typed ref usable in memorix_detail */
|
|
351
|
-
function formatEntryRef(entry: IndexEntry): string {
|
|
351
|
+
export function formatEntryRef(entry: IndexEntry): string {
|
|
352
352
|
if (entry.documentType === 'mini-skill') return `skill:${entry.id}`;
|
|
353
353
|
return entry.projectId ? `obs:${entry.id}@${entry.projectId}` : `obs:${entry.id}`;
|
|
354
354
|
}
|
|
@@ -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
|
|
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
|
|
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;
|
package/src/dashboard/server.ts
CHANGED
|
@@ -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,8 @@
|
|
|
1
1
|
import type { CodeGraphProviderQuality } from '../codegraph/types.js';
|
|
2
|
+
import {
|
|
3
|
+
sanitizeDerivedViewFailureReason,
|
|
4
|
+
type RetrievalDerivedViewReceipt,
|
|
5
|
+
} from '../search/derived-view-receipt.js';
|
|
2
6
|
import type { TaskWorkset } from './workset.js';
|
|
3
7
|
import type { TaskContinuityLedger } from './task-continuity.js';
|
|
4
8
|
|
|
@@ -26,6 +30,37 @@ export interface BoundedContextReceipt {
|
|
|
26
30
|
};
|
|
27
31
|
}
|
|
28
32
|
|
|
33
|
+
/** Build the graph view status without exposing source contents or paths. */
|
|
34
|
+
export function buildCodeGraphDerivedView(input: {
|
|
35
|
+
providerQuality?: CodeGraphProviderQuality;
|
|
36
|
+
snapshot?: { id?: string; sourceEpoch?: number; incomplete?: boolean };
|
|
37
|
+
}): RetrievalDerivedViewReceipt {
|
|
38
|
+
const provider = input.providerQuality;
|
|
39
|
+
const snapshot = input.snapshot;
|
|
40
|
+
const externalFailure = provider?.external.state !== undefined
|
|
41
|
+
&& !['ready', 'disabled', 'not-detected'].includes(provider.external.state);
|
|
42
|
+
if (snapshot?.id) {
|
|
43
|
+
return {
|
|
44
|
+
...(snapshot.sourceEpoch !== undefined ? { generation: snapshot.sourceEpoch } : {}),
|
|
45
|
+
freshness: snapshot.incomplete ? 'stale' : 'current',
|
|
46
|
+
rebuildStatus: snapshot.incomplete ? 'failed' : 'idle',
|
|
47
|
+
...(snapshot.incomplete
|
|
48
|
+
? { failureReason: 'latest CodeGraph snapshot is incomplete' }
|
|
49
|
+
: externalFailure && provider?.external.reason
|
|
50
|
+
? { failureReason: sanitizeDerivedViewFailureReason(provider.external.reason) }
|
|
51
|
+
: {}),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
freshness: 'unknown',
|
|
57
|
+
rebuildStatus: externalFailure ? 'failed' : 'unavailable',
|
|
58
|
+
...(provider?.external.reason
|
|
59
|
+
? { failureReason: sanitizeDerivedViewFailureReason(provider.external.reason) }
|
|
60
|
+
: { failureReason: 'CodeGraph snapshot is not initialized' }),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
29
64
|
export function buildBoundedContextReceipt(input: {
|
|
30
65
|
workset: TaskWorkset;
|
|
31
66
|
providerQuality?: CodeGraphProviderQuality;
|
package/src/knowledge/workset.ts
CHANGED
|
@@ -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',
|
package/src/llm/provider.ts
CHANGED
|
@@ -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
|
};
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
batchGenerateEmbeddings,
|
|
29
29
|
getDb,
|
|
30
30
|
getDeferredCachedVectorHydration,
|
|
31
|
+
getPersistentSemanticVectorIds,
|
|
31
32
|
getVectorDimensions,
|
|
32
33
|
queueSemanticVector,
|
|
33
34
|
hydrateIndexForStartup,
|
|
@@ -1369,16 +1370,17 @@ export async function prepareSearchIndex(options: { skipCachedVectors?: boolean
|
|
|
1369
1370
|
}
|
|
1370
1371
|
|
|
1371
1372
|
const hydratedProjectDir = projectDir;
|
|
1372
|
-
const queueMissingVectors = () => {
|
|
1373
|
-
if (projectDir !== hydratedProjectDir) return;
|
|
1373
|
+
const queueMissingVectors = async () => {
|
|
1374
|
+
if (!hydratedProjectDir || projectDir !== hydratedProjectDir) return;
|
|
1374
1375
|
vectorMissingIds.clear();
|
|
1375
1376
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
1377
|
+
const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
|
|
1376
1378
|
const projectsWithMissingVectors = new Set<string>();
|
|
1377
1379
|
for (const obs of observations) {
|
|
1378
1380
|
// Queue ALL statuses for vector backfill — status filtering happens at query time,
|
|
1379
1381
|
// not at index time. Omitting non-active observations here would permanently
|
|
1380
1382
|
// exclude resolved/archived memories from hybrid search after restart.
|
|
1381
|
-
if (!hasObservationVector(obs.projectId, obs.id)) {
|
|
1383
|
+
if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
|
|
1382
1384
|
vectorMissingIds.add(obs.id);
|
|
1383
1385
|
projectsWithMissingVectors.add(obs.projectId);
|
|
1384
1386
|
}
|
|
@@ -1391,9 +1393,9 @@ export async function prepareSearchIndex(options: { skipCachedVectors?: boolean
|
|
|
1391
1393
|
if (cacheHydration) {
|
|
1392
1394
|
// Let the disk cache finish outside the interactive startup path. Misses are
|
|
1393
1395
|
// queued only after it has had a chance to restore compatible vectors.
|
|
1394
|
-
void cacheHydration.
|
|
1396
|
+
void cacheHydration.then(queueMissingVectors, queueMissingVectors).catch(() => undefined);
|
|
1395
1397
|
} else {
|
|
1396
|
-
queueMissingVectors();
|
|
1398
|
+
await queueMissingVectors();
|
|
1397
1399
|
}
|
|
1398
1400
|
|
|
1399
1401
|
searchIndexPrepared = true;
|
|
@@ -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,62 @@
|
|
|
1
|
+
import { sanitizeCredentials } from '../memory/secret-filter.js';
|
|
2
|
+
import type { EmbeddingRuntimeHealth } from '../embedding/provider.js';
|
|
3
|
+
|
|
4
|
+
/** Privacy-safe health metadata for retrieval's derived evidence views. */
|
|
5
|
+
export type RetrievalDerivedViewName = 'fts' | 'orama' | 'embedding' | 'graph';
|
|
6
|
+
|
|
7
|
+
export type RetrievalDerivedViewFreshness = 'current' | 'stale' | 'unknown';
|
|
8
|
+
|
|
9
|
+
export type RetrievalDerivedViewRebuildStatus =
|
|
10
|
+
| 'idle'
|
|
11
|
+
| 'rebuilding'
|
|
12
|
+
| 'unavailable'
|
|
13
|
+
| 'failed'
|
|
14
|
+
| 'disabled';
|
|
15
|
+
|
|
16
|
+
export interface RetrievalDerivedViewReceipt {
|
|
17
|
+
/** Durable or process-local generation when one exists. */
|
|
18
|
+
generation?: number;
|
|
19
|
+
freshness: RetrievalDerivedViewFreshness;
|
|
20
|
+
rebuildStatus: RetrievalDerivedViewRebuildStatus;
|
|
21
|
+
/** Bounded operator-facing reason; never raw memory content. */
|
|
22
|
+
failureReason?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type RetrievalDerivedViews = Partial<Record<RetrievalDerivedViewName, RetrievalDerivedViewReceipt>>;
|
|
26
|
+
|
|
27
|
+
/** Normalize an operator-facing failure without persisting credentials or host paths. */
|
|
28
|
+
export function sanitizeDerivedViewFailureReason(reason: string): string {
|
|
29
|
+
const safe = sanitizeCredentials(reason)
|
|
30
|
+
.replace(/(?:[A-Za-z]:[\\/]|\\\\[^\\/\s]+[\\/]|\/(?:home|Users|tmp|var|private|mnt|workspace|workspaces)\/)[^\s"'<>|]*/gi, '[path]')
|
|
31
|
+
.replace(/\s+/g, ' ')
|
|
32
|
+
.trim();
|
|
33
|
+
return safe.slice(0, 240) || 'derived view failed';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function embeddingHealthReceipt(
|
|
37
|
+
health: EmbeddingRuntimeHealth | undefined,
|
|
38
|
+
embeddingEnabled: boolean,
|
|
39
|
+
): RetrievalDerivedViewReceipt {
|
|
40
|
+
if (health?.status === 'disabled') {
|
|
41
|
+
return { freshness: 'current', rebuildStatus: 'disabled' };
|
|
42
|
+
}
|
|
43
|
+
if (health?.status === 'ready' || embeddingEnabled) {
|
|
44
|
+
return { freshness: 'current', rebuildStatus: 'idle' };
|
|
45
|
+
}
|
|
46
|
+
if (health?.status === 'degraded') {
|
|
47
|
+
return {
|
|
48
|
+
freshness: 'stale',
|
|
49
|
+
rebuildStatus: 'failed',
|
|
50
|
+
...(health.failure
|
|
51
|
+
? {
|
|
52
|
+
failureReason: `embedding ${health.failure.kind}; retry in ${health.failure.retryAfterMs}ms`,
|
|
53
|
+
}
|
|
54
|
+
: { failureReason: 'embedding provider degraded' }),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
freshness: 'unknown',
|
|
59
|
+
rebuildStatus: 'unavailable',
|
|
60
|
+
failureReason: 'embedding provider is not initialized',
|
|
61
|
+
};
|
|
62
|
+
}
|