Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ cd cortex && npm install --omit=dev
| `autoRecall` | `boolean` | `true` | Retrieve relevant memories before each agent turn |
| `autoCapture` | `boolean` | `true` | Extract and store memories after each agent turn |
| `shadowMode` | `boolean` | `false` | Dry-run mode — runs extraction but skips storage |
| `gbrainShadowEnabled` | `boolean` | `false` | Enable observe-only GBrain shadow v1 scaffolding |
| `gbrainShadowCapture` | `boolean` | `true` | Log what GBrain shadow would process on end-of-turn capture |
| `gbrainShadowRecall` | `boolean` | `true` | Log what GBrain shadow would contribute on recall |
| `gbrainShadowLogEnabled` | `boolean` | `true` | Persist structured timestamped shadow logs under `dist/logs/` |
| `gbrainShadowProviderBaseUrl` | `string` | `https://api.minimax.io/v1` | Base URL for MiniMax full-model observe-only path |
| `gbrainShadowModel` | `string` | `MiniMax-M2.7` | Model name used in GBrain shadow log metadata |
Comment on lines +76 to +78
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README defaults/paths for GBrain shadow don’t match the implementation: the code defaults gbrainShadowProviderBaseUrl to https://api.minimax.io/anthropic and gbrainShadowModel to MiniMax-M2.7-HighSpeed, and writes logs under shadow-logs/ next to the plugin file, not dist/logs/. Please update the README to reflect the actual defaults and log location (or change the code to match the documented behavior).

Suggested change
| `gbrainShadowLogEnabled` | `boolean` | `true` | Persist structured timestamped shadow logs under `dist/logs/` |
| `gbrainShadowProviderBaseUrl` | `string` | `https://api.minimax.io/v1` | Base URL for MiniMax full-model observe-only path |
| `gbrainShadowModel` | `string` | `MiniMax-M2.7` | Model name used in GBrain shadow log metadata |
| `gbrainShadowLogEnabled` | `boolean` | `true` | Persist structured timestamped shadow logs under `shadow-logs/` next to the plugin file |
| `gbrainShadowProviderBaseUrl` | `string` | `https://api.minimax.io/anthropic` | Base URL for MiniMax full-model observe-only path |
| `gbrainShadowModel` | `string` | `MiniMax-M2.7-HighSpeed` | Model name used in GBrain shadow log metadata |

Copilot uses AI. Check for mistakes.
| `retrievalBudget` | `number` | `2000` | Max token budget for retrieved memories |
| `maxInjectionChars` | `number` | `8000` | Max characters injected into agent context |
| `retrievalMode` | `string` | `fast` | Retrieval mode: `auto`, `fast`, or `thorough` |
Expand Down Expand Up @@ -126,6 +132,10 @@ Cortex operates two invisible loops around every agent conversation:

Memories include metadata (dates, salience, categories) and are deduplicated, contradiction-checked, and relevance-scored at retrieval time.

## GBrain Shadow v1

This plugin now includes a narrow, safe GBrain shadow scaffold. When `gbrainShadowEnabled` is on, Cortex keeps authoritative recall/capture behavior unchanged and only writes observe-only JSONL log entries describing what a GBrain layer would have seen or contributed. Logs are timestamped, capped, and include MiniMax provider metadata so you can wire a full-model path later without taking over the hot path.

## Benchmarks

> 🚧 **Benchmarks coming soon.** We're running evaluations against [LoCoMo](https://github.com/snap-research/locomo), [AMB](https://github.com/microsoft/AMB), and [MSC](https://github.com/facebookresearch/ParlAI/tree/main/projects/msc) — the standard long-term memory benchmarks for conversational AI.
Expand Down
2 changes: 2 additions & 0 deletions dist/__tests__/gbrain-shadow.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=gbrain-shadow.test.d.ts.map
1 change: 1 addition & 0 deletions dist/__tests__/gbrain-shadow.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions dist/__tests__/gbrain-shadow.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/__tests__/gbrain-shadow.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/__tests__/turn-gating.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=turn-gating.test.d.ts.map
1 change: 1 addition & 0 deletions dist/__tests__/turn-gating.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions dist/__tests__/turn-gating.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/__tests__/turn-gating.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

122 changes: 122 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ interface EvaMemoryConfig {
autoRecall: boolean;
autoCapture: boolean;
shadowMode: boolean;
gbrainShadowEnabled: boolean;
gbrainShadowCapture: boolean;
gbrainShadowRecall: boolean;
gbrainShadowLogEnabled: boolean;
gbrainShadowMaxPromptChars: number;
gbrainShadowLogMaxEntries: number;
gbrainShadowProviderBaseUrl: string;
gbrainShadowModel: string;
gbrainShadowApiKey: string;
retrievalBudget: number;
maxInjectionChars: number;
maxInjectedMemories: number;
Expand Down Expand Up @@ -72,7 +81,52 @@ interface ProcessedItem {
conflictWithId?: string;
relationHint?: string;
}
interface GBrainShadowEvent {
schemaVersion: "gbrain-shadow-v1";
ts: string;
phase: "recall" | "capture";
sessionId?: string;
turnId?: string;
mode: "observe";
provider: {
baseUrl: string;
model: string;
liveCall: boolean;
};
gbrainRetrieval?: {
attempted: boolean;
ok: boolean;
query?: string;
hits?: Array<{
slug: string;
preview: string;
}>;
summary?: string;
};
promptPreview?: string;
conversationPreview?: Array<{
role: string;
content: string;
}>;
status: "skipped" | "simulated" | "disabled";
reason?: string;
note: string;
source: "gbrain-shadow-scaffold";
divergenceFromAuthoritative?: string;
}
declare function parseConfig(raw: unknown): EvaMemoryConfig;
export declare function isMemoryRelevant(prompt: string): boolean;
type HookRunKind = "main" | "subagent" | "cron" | "isolated" | "hook" | "unknown";
type HookLaneContext = {
runKind?: HookRunKind;
isHeartbeat?: boolean;
sessionKey?: string;
trigger?: string;
};
export declare function classifyTurnForMemory(prompt: string | undefined, messages: unknown[] | undefined, ctx?: HookLaneContext): {
allow: boolean;
reason: string;
};
/** Session risk mode for dynamic threshold selection. */
type InjectionMode = "critical" | "technical" | "personal";
/** Parse raw plugin config into a validated EvaMemoryConfig object. */
Expand All @@ -98,6 +152,38 @@ export declare function detectInjectionMode(promptText: string): InjectionMode;
export declare function screenInjectionCandidates(items: RetrievedItem[], promptText: string, cfg: Pick<EvaMemoryConfig, "injectionHardFloor" | "injectionCriticalThreshold" | "injectionTechnicalThreshold" | "injectionPersonalThreshold">, log?: (msg: string) => void): RetrievedItem[];
export declare function preprocessClaims(items: RetrievedItem[], options: Pick<EvaMemoryConfig, "showConflicts" | "showRelations" | "dedup">): ProcessedItem[];
export declare function formatMemoryContext(items: RetrievedItem[], maxChars: number, totalCount?: number, maxCount?: number, minScore?: number, options?: Pick<EvaMemoryConfig, "injectionFormat" | "showConflicts" | "showRelations" | "dedup">): string;
export declare function getGBrainShadowLogPath(ownerId: string): string;
export declare function createGBrainShadowEvent(params: {
phase: "recall" | "capture";
sessionId?: string;
turnId?: string;
providerBaseUrl: string;
model: string;
prompt?: string;
conversation?: Array<{
role: string;
content: string;
}>;
maxPromptChars: number;
status: "skipped" | "simulated" | "disabled";
reason?: string;
note: string;
divergenceFromAuthoritative?: string;
gbrainRetrieval?: {
attempted: boolean;
ok: boolean;
query?: string;
hits?: Array<{
slug: string;
preview: string;
}>;
summary?: string;
};
}): GBrainShadowEvent;
export declare function extractMessages(rawMessages: unknown[]): Array<{
role: string;
content: string;
}>;
declare const cortexPlugin: {
id: string;
name: string;
Expand Down Expand Up @@ -128,6 +214,42 @@ declare const cortexPlugin: {
type: string;
description: string;
};
gbrainShadowEnabled: {
type: string;
description: string;
};
gbrainShadowCapture: {
type: string;
description: string;
};
gbrainShadowRecall: {
type: string;
description: string;
};
gbrainShadowLogEnabled: {
type: string;
description: string;
};
gbrainShadowMaxPromptChars: {
type: string;
description: string;
};
gbrainShadowLogMaxEntries: {
type: string;
description: string;
};
gbrainShadowProviderBaseUrl: {
type: string;
description: string;
};
gbrainShadowModel: {
type: string;
description: string;
};
gbrainShadowApiKey: {
type: string;
description: string;
};
retrievalBudget: {
type: string;
};
Expand Down
Loading
Loading