open-mem 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/LICENSE +21 -0
- package/README.md +309 -0
- package/dist/ai/compressor.d.ts +43 -0
- package/dist/ai/compressor.d.ts.map +1 -0
- package/dist/ai/parser.d.ts +35 -0
- package/dist/ai/parser.d.ts.map +1 -0
- package/dist/ai/prompts.d.ts +15 -0
- package/dist/ai/prompts.d.ts.map +1 -0
- package/dist/ai/summarizer.d.ts +30 -0
- package/dist/ai/summarizer.d.ts.map +1 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/context/builder.d.ts +11 -0
- package/dist/context/builder.d.ts.map +1 -0
- package/dist/context/progressive.d.ts +13 -0
- package/dist/context/progressive.d.ts.map +1 -0
- package/dist/db/database.d.ts +45 -0
- package/dist/db/database.d.ts.map +1 -0
- package/dist/db/observations.d.ts +17 -0
- package/dist/db/observations.d.ts.map +1 -0
- package/dist/db/pending.d.ts +20 -0
- package/dist/db/pending.d.ts.map +1 -0
- package/dist/db/schema.d.ts +13 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/sessions.d.ts +17 -0
- package/dist/db/sessions.d.ts.map +1 -0
- package/dist/db/summaries.d.ts +12 -0
- package/dist/db/summaries.d.ts.map +1 -0
- package/dist/hooks/compaction.d.ts +19 -0
- package/dist/hooks/compaction.d.ts.map +1 -0
- package/dist/hooks/context-inject.d.ts +19 -0
- package/dist/hooks/context-inject.d.ts.map +1 -0
- package/dist/hooks/session-events.d.ts +18 -0
- package/dist/hooks/session-events.d.ts.map +1 -0
- package/dist/hooks/tool-capture.d.ts +25 -0
- package/dist/hooks/tool-capture.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +361 -0
- package/dist/queue/processor.d.ts +52 -0
- package/dist/queue/processor.d.ts.map +1 -0
- package/dist/tools/recall.d.ts +4 -0
- package/dist/tools/recall.d.ts.map +1 -0
- package/dist/tools/save.d.ts +5 -0
- package/dist/tools/save.d.ts.map +1 -0
- package/dist/tools/search.d.ts +5 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/timeline.d.ts +6 -0
- package/dist/tools/timeline.d.ts.map +1 -0
- package/dist/types.d.ts +177 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PendingMessage } from "../types";
|
|
2
|
+
import type { Database } from "./database";
|
|
3
|
+
export declare class PendingMessageRepository {
|
|
4
|
+
private db;
|
|
5
|
+
constructor(db: Database);
|
|
6
|
+
create(data: Omit<PendingMessage, "id" | "createdAt" | "status" | "retryCount" | "error">): PendingMessage;
|
|
7
|
+
getPending(limit?: number): PendingMessage[];
|
|
8
|
+
getByStatus(status: PendingMessage["status"]): PendingMessage[];
|
|
9
|
+
markProcessing(id: string): void;
|
|
10
|
+
markCompleted(id: string): void;
|
|
11
|
+
markFailed(id: string, error: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Reset stale "processing" messages back to "pending".
|
|
14
|
+
* Handles the case where the plugin crashes mid-processing.
|
|
15
|
+
* Returns the number of messages reset.
|
|
16
|
+
*/
|
|
17
|
+
resetStale(olderThanMinutes?: number): number;
|
|
18
|
+
private mapRow;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=pending.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending.d.ts","sourceRoot":"","sources":["../../src/db/pending.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,qBAAa,wBAAwB;IACxB,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,QAAQ;IAMhC,MAAM,CACL,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,GAAG,WAAW,GAAG,QAAQ,GAAG,YAAY,GAAG,OAAO,CAAC,GAChF,cAAc;IAuBjB,UAAU,CAAC,KAAK,SAAK,GAAG,cAAc,EAAE;IASxC,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,cAAc,EAAE;IAa/D,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIhC,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI/B,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAO3C;;;;OAIG;IACH,UAAU,CAAC,gBAAgB,SAAI,GAAG,MAAM;IAexC,OAAO,CAAC,MAAM;CAad"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Database, Migration } from "./database";
|
|
2
|
+
export declare const TABLES: {
|
|
3
|
+
readonly SESSIONS: "sessions";
|
|
4
|
+
readonly OBSERVATIONS: "observations";
|
|
5
|
+
readonly SESSION_SUMMARIES: "session_summaries";
|
|
6
|
+
readonly PENDING_MESSAGES: "pending_messages";
|
|
7
|
+
readonly OBSERVATIONS_FTS: "observations_fts";
|
|
8
|
+
readonly SUMMARIES_FTS: "summaries_fts";
|
|
9
|
+
};
|
|
10
|
+
export declare const MIGRATIONS: Migration[];
|
|
11
|
+
/** Run all migrations to bring the database schema up to date */
|
|
12
|
+
export declare function initializeSchema(db: Database): void;
|
|
13
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAMtD,eAAO,MAAM,MAAM;;;;;;;CAOT,CAAC;AAMX,eAAO,MAAM,UAAU,EAAE,SAAS,EA8LjC,CAAC;AAMF,iEAAiE;AACjE,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAEnD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Session } from "../types";
|
|
2
|
+
import type { Database } from "./database";
|
|
3
|
+
export declare class SessionRepository {
|
|
4
|
+
private db;
|
|
5
|
+
constructor(db: Database);
|
|
6
|
+
create(sessionId: string, projectPath: string): Session;
|
|
7
|
+
getOrCreate(sessionId: string, projectPath: string): Session;
|
|
8
|
+
getById(id: string): Session | null;
|
|
9
|
+
getRecent(projectPath: string, limit?: number): Session[];
|
|
10
|
+
getActive(): Session[];
|
|
11
|
+
updateStatus(id: string, status: Session["status"]): void;
|
|
12
|
+
markCompleted(id: string): void;
|
|
13
|
+
incrementObservationCount(id: string): void;
|
|
14
|
+
setSummary(sessionId: string, summaryId: string): void;
|
|
15
|
+
private mapRow;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=sessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../src/db/sessions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,qBAAa,iBAAiB;IACjB,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,QAAQ;IAMhC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IAWvD,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IAU5D,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAKnC,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,OAAO,EAAE;IASrD,SAAS,IAAI,OAAO,EAAE;IAYtB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI;IAIzD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAO/B,yBAAyB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI3C,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAQtD,OAAO,CAAC,MAAM;CAWd"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SessionSummary } from "../types";
|
|
2
|
+
import type { Database } from "./database";
|
|
3
|
+
export declare class SummaryRepository {
|
|
4
|
+
private db;
|
|
5
|
+
constructor(db: Database);
|
|
6
|
+
create(data: Omit<SessionSummary, "id" | "createdAt">): SessionSummary;
|
|
7
|
+
getBySessionId(sessionId: string): SessionSummary | null;
|
|
8
|
+
getRecent(limit?: number): SessionSummary[];
|
|
9
|
+
search(query: string, limit?: number): SessionSummary[];
|
|
10
|
+
private mapRow;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=summaries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summaries.d.ts","sourceRoot":"","sources":["../../src/db/summaries.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,qBAAa,iBAAiB;IACjB,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,QAAQ;IAMhC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,cAAc;IAgCtE,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAQxD,SAAS,CAAC,KAAK,SAAK,GAAG,cAAc,EAAE;IAavC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,cAAc,EAAE;IAkBnD,OAAO,CAAC,MAAM;CAkBd"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ObservationRepository } from "../db/observations";
|
|
2
|
+
import type { SessionRepository } from "../db/sessions";
|
|
3
|
+
import type { SummaryRepository } from "../db/summaries";
|
|
4
|
+
import type { OpenMemConfig } from "../types";
|
|
5
|
+
/**
|
|
6
|
+
* Factory for the `experimental.session.compacting` hook.
|
|
7
|
+
*
|
|
8
|
+
* Injects a reduced-budget memory context during session compaction
|
|
9
|
+
* so that memory survives across compaction boundaries.
|
|
10
|
+
*
|
|
11
|
+
* The handler NEVER throws.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createCompactionHook(config: OpenMemConfig, observations: ObservationRepository, sessions: SessionRepository, summaries: SummaryRepository, projectPath: string): (_input: {
|
|
14
|
+
sessionID: string;
|
|
15
|
+
}, output: {
|
|
16
|
+
context: string[];
|
|
17
|
+
prompt?: string;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
//# sourceMappingURL=compaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compaction.d.ts","sourceRoot":"","sources":["../../src/hooks/compaction.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,aAAa,EACrB,YAAY,EAAE,qBAAqB,EACnC,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,EAAE,iBAAiB,EAC5B,WAAW,EAAE,MAAM,IAGlB,QAAQ;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EAC7B,QAAQ;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAC5C,OAAO,CAAC,IAAI,CAAC,CA2BhB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ObservationRepository } from "../db/observations";
|
|
2
|
+
import type { SessionRepository } from "../db/sessions";
|
|
3
|
+
import type { SummaryRepository } from "../db/summaries";
|
|
4
|
+
import type { OpenMemConfig } from "../types";
|
|
5
|
+
/**
|
|
6
|
+
* Factory for the `experimental.chat.system.transform` hook.
|
|
7
|
+
*
|
|
8
|
+
* Appends relevant past-session context (summaries + observation index)
|
|
9
|
+
* to the system prompt within the configured token budget.
|
|
10
|
+
*
|
|
11
|
+
* The handler NEVER throws.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createContextInjectionHook(config: OpenMemConfig, observations: ObservationRepository, sessions: SessionRepository, summaries: SummaryRepository, projectPath: string): (_input: {
|
|
14
|
+
sessionID?: string;
|
|
15
|
+
model: string;
|
|
16
|
+
}, output: {
|
|
17
|
+
system: string[];
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
//# sourceMappingURL=context-inject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-inject.d.ts","sourceRoot":"","sources":["../../src/hooks/context-inject.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,UAAU,CAAC;AAE3D;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACzC,MAAM,EAAE,aAAa,EACrB,YAAY,EAAE,qBAAqB,EACnC,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,EAAE,iBAAiB,EAC5B,WAAW,EAAE,MAAM,IAGlB,QAAQ;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC7C,QAAQ;IAAE,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,KAC1B,OAAO,CAAC,IAAI,CAAC,CA2ChB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SessionRepository } from "../db/sessions";
|
|
2
|
+
import type { QueueProcessor } from "../queue/processor";
|
|
3
|
+
import type { OpenCodeEvent } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* Factory for the `event` hook.
|
|
6
|
+
*
|
|
7
|
+
* Handles session lifecycle events:
|
|
8
|
+
* - `session.created` — ensure session record exists
|
|
9
|
+
* - `session.idle` — trigger batch processing
|
|
10
|
+
* - `session.completed` / `session.ended` — process remaining queue,
|
|
11
|
+
* summarize, and mark session complete
|
|
12
|
+
*
|
|
13
|
+
* The handler NEVER throws.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createEventHandler(queue: QueueProcessor, sessions: SessionRepository, projectPath: string): (input: {
|
|
16
|
+
event: OpenCodeEvent;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
//# sourceMappingURL=session-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-events.d.ts","sourceRoot":"","sources":["../../src/hooks/session-events.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EAAE,MAAM,IAEL,OAAO;IAAE,KAAK,EAAE,aAAa,CAAA;CAAE,KAAG,OAAO,CAAC,IAAI,CAAC,CAsC7D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SessionRepository } from "../db/sessions";
|
|
2
|
+
import type { QueueProcessor } from "../queue/processor";
|
|
3
|
+
import type { OpenMemConfig } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* Factory for the `tool.execute.after` hook.
|
|
6
|
+
*
|
|
7
|
+
* On every tool execution the hook:
|
|
8
|
+
* 1. Filters out ignored tools and short/empty outputs
|
|
9
|
+
* 2. Redacts content matching sensitive patterns
|
|
10
|
+
* 3. Strips `<private>...</private>` blocks
|
|
11
|
+
* 4. Ensures the session exists in the DB
|
|
12
|
+
* 5. Enqueues the output for async AI compression
|
|
13
|
+
*
|
|
14
|
+
* The handler NEVER throws — errors are caught and logged.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createToolCaptureHook(config: OpenMemConfig, queue: QueueProcessor, sessions: SessionRepository, projectPath: string): (input: {
|
|
17
|
+
tool: string;
|
|
18
|
+
sessionID: string;
|
|
19
|
+
callID: string;
|
|
20
|
+
}, output: {
|
|
21
|
+
title: string;
|
|
22
|
+
output: string;
|
|
23
|
+
metadata: Record<string, unknown>;
|
|
24
|
+
}) => Promise<void>;
|
|
25
|
+
//# sourceMappingURL=tool-capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-capture.d.ts","sourceRoot":"","sources":["../../src/hooks/tool-capture.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EAAE,MAAM,IAGlB,OAAO;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC1D,QAAQ;IACP,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,KACC,OAAO,CAAC,IAAI,CAAC,CAkChB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Hooks, PluginInput } from "./types";
|
|
2
|
+
export default function plugin(input: PluginInput): Promise<Hooks>;
|
|
3
|
+
export type { OpenMemConfig, Observation, Session, SessionSummary, } from "./types";
|
|
4
|
+
export { resolveConfig, getDefaultConfig } from "./config";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAMlD,wBAA8B,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAqEvE;AAMD,YAAY,EACX,aAAa,EACb,WAAW,EACX,OAAO,EACP,cAAc,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|