@hasna/mementos 0.6.0 → 0.8.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/dist/cli/index.js +2015 -170
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/entities.d.ts.map +1 -1
- package/dist/db/memories.d.ts.map +1 -1
- package/dist/db/relations.d.ts.map +1 -1
- package/dist/db/synthesis.d.ts +101 -0
- package/dist/db/synthesis.d.ts.map +1 -0
- package/dist/db/webhook_hooks.d.ts +25 -0
- package/dist/db/webhook_hooks.d.ts.map +1 -0
- package/dist/index.js +229 -9
- package/dist/lib/built-in-hooks.d.ts +12 -0
- package/dist/lib/built-in-hooks.d.ts.map +1 -0
- package/dist/lib/focus.d.ts.map +1 -1
- package/dist/lib/hooks.d.ts +50 -0
- package/dist/lib/hooks.d.ts.map +1 -0
- package/dist/lib/synthesis/corpus-builder.d.ts +30 -0
- package/dist/lib/synthesis/corpus-builder.d.ts.map +1 -0
- package/dist/lib/synthesis/executor.d.ts +14 -0
- package/dist/lib/synthesis/executor.d.ts.map +1 -0
- package/dist/lib/synthesis/index.d.ts +37 -0
- package/dist/lib/synthesis/index.d.ts.map +1 -0
- package/dist/lib/synthesis/llm-analyzer.d.ts +18 -0
- package/dist/lib/synthesis/llm-analyzer.d.ts.map +1 -0
- package/dist/lib/synthesis/metrics.d.ts +13 -0
- package/dist/lib/synthesis/metrics.d.ts.map +1 -0
- package/dist/lib/synthesis/scheduler.d.ts +18 -0
- package/dist/lib/synthesis/scheduler.d.ts.map +1 -0
- package/dist/lib/synthesis/validator.d.ts +19 -0
- package/dist/lib/synthesis/validator.d.ts.map +1 -0
- package/dist/mcp/index.js +8102 -6127
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +3627 -1726
- package/dist/types/hooks.d.ts +136 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook system types for open-mementos lifecycle events.
|
|
3
|
+
*
|
|
4
|
+
* Blocking hooks: handler returns false → operation is cancelled.
|
|
5
|
+
* Non-blocking hooks: fire-and-forget, never delay the caller.
|
|
6
|
+
*/
|
|
7
|
+
import type { Memory, CreateMemoryInput, UpdateMemoryInput } from "./index.js";
|
|
8
|
+
export type HookType = "PreMemorySave" | "PostMemorySave" | "PreMemoryUpdate" | "PostMemoryUpdate" | "PreMemoryDelete" | "PostMemoryDelete" | "PreEntityCreate" | "PostEntityCreate" | "PreRelationCreate" | "PostRelationCreate" | "OnSessionStart" | "OnSessionEnd" | "PreMemoryInject" | "PostMemoryInject";
|
|
9
|
+
export interface BaseHookContext {
|
|
10
|
+
agentId?: string;
|
|
11
|
+
projectId?: string;
|
|
12
|
+
sessionId?: string;
|
|
13
|
+
timestamp: number;
|
|
14
|
+
}
|
|
15
|
+
export interface PreMemorySaveContext extends BaseHookContext {
|
|
16
|
+
input: CreateMemoryInput;
|
|
17
|
+
}
|
|
18
|
+
export interface PostMemorySaveContext extends BaseHookContext {
|
|
19
|
+
memory: Memory;
|
|
20
|
+
wasUpdated: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface PreMemoryUpdateContext extends BaseHookContext {
|
|
23
|
+
memoryId: string;
|
|
24
|
+
input: UpdateMemoryInput;
|
|
25
|
+
existing: Memory;
|
|
26
|
+
}
|
|
27
|
+
export interface PostMemoryUpdateContext extends BaseHookContext {
|
|
28
|
+
memory: Memory;
|
|
29
|
+
previousValue: string;
|
|
30
|
+
}
|
|
31
|
+
export interface PreMemoryDeleteContext extends BaseHookContext {
|
|
32
|
+
memoryId: string;
|
|
33
|
+
memory: Memory;
|
|
34
|
+
}
|
|
35
|
+
export interface PostMemoryDeleteContext extends BaseHookContext {
|
|
36
|
+
memoryId: string;
|
|
37
|
+
}
|
|
38
|
+
export interface PreEntityCreateContext extends BaseHookContext {
|
|
39
|
+
name: string;
|
|
40
|
+
entityType: string;
|
|
41
|
+
}
|
|
42
|
+
export interface PostEntityCreateContext extends BaseHookContext {
|
|
43
|
+
entityId: string;
|
|
44
|
+
name: string;
|
|
45
|
+
entityType: string;
|
|
46
|
+
}
|
|
47
|
+
export interface PreRelationCreateContext extends BaseHookContext {
|
|
48
|
+
sourceEntityId: string;
|
|
49
|
+
targetEntityId: string;
|
|
50
|
+
relationType: string;
|
|
51
|
+
}
|
|
52
|
+
export interface PostRelationCreateContext extends BaseHookContext {
|
|
53
|
+
relationId: string;
|
|
54
|
+
sourceEntityId: string;
|
|
55
|
+
targetEntityId: string;
|
|
56
|
+
relationType: string;
|
|
57
|
+
}
|
|
58
|
+
export interface OnSessionStartContext extends BaseHookContext {
|
|
59
|
+
agentId: string;
|
|
60
|
+
projectId?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface OnSessionEndContext extends BaseHookContext {
|
|
63
|
+
agentId: string;
|
|
64
|
+
projectId?: string;
|
|
65
|
+
/** Optional session summary for memory extraction */
|
|
66
|
+
summary?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface PreMemoryInjectContext extends BaseHookContext {
|
|
69
|
+
/** Memories about to be injected — hook can mutate this array */
|
|
70
|
+
memories: Memory[];
|
|
71
|
+
format: string;
|
|
72
|
+
}
|
|
73
|
+
export interface PostMemoryInjectContext extends BaseHookContext {
|
|
74
|
+
memoriesCount: number;
|
|
75
|
+
format: string;
|
|
76
|
+
contextLength: number;
|
|
77
|
+
}
|
|
78
|
+
/** Union of all hook contexts keyed by type */
|
|
79
|
+
export type HookContextMap = {
|
|
80
|
+
PreMemorySave: PreMemorySaveContext;
|
|
81
|
+
PostMemorySave: PostMemorySaveContext;
|
|
82
|
+
PreMemoryUpdate: PreMemoryUpdateContext;
|
|
83
|
+
PostMemoryUpdate: PostMemoryUpdateContext;
|
|
84
|
+
PreMemoryDelete: PreMemoryDeleteContext;
|
|
85
|
+
PostMemoryDelete: PostMemoryDeleteContext;
|
|
86
|
+
PreEntityCreate: PreEntityCreateContext;
|
|
87
|
+
PostEntityCreate: PostEntityCreateContext;
|
|
88
|
+
PreRelationCreate: PreRelationCreateContext;
|
|
89
|
+
PostRelationCreate: PostRelationCreateContext;
|
|
90
|
+
OnSessionStart: OnSessionStartContext;
|
|
91
|
+
OnSessionEnd: OnSessionEndContext;
|
|
92
|
+
PreMemoryInject: PreMemoryInjectContext;
|
|
93
|
+
PostMemoryInject: PostMemoryInjectContext;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Blocking hook: return false to cancel the operation.
|
|
97
|
+
* Non-blocking hook: return value is ignored.
|
|
98
|
+
*/
|
|
99
|
+
export type HookHandler<T extends HookType = HookType> = (context: HookContextMap[T]) => Promise<boolean | void>;
|
|
100
|
+
export interface Hook<T extends HookType = HookType> {
|
|
101
|
+
id: string;
|
|
102
|
+
type: T;
|
|
103
|
+
handler: HookHandler<T>;
|
|
104
|
+
/** Lower number = runs first. Default: 50 */
|
|
105
|
+
priority: number;
|
|
106
|
+
/**
|
|
107
|
+
* If true: operation waits for handler result. Return false = cancel.
|
|
108
|
+
* If false: runs async in background, return value ignored.
|
|
109
|
+
*/
|
|
110
|
+
blocking: boolean;
|
|
111
|
+
/** Scope: only fire for this agent (undefined = all agents) */
|
|
112
|
+
agentId?: string;
|
|
113
|
+
/** Scope: only fire for this project (undefined = all projects) */
|
|
114
|
+
projectId?: string;
|
|
115
|
+
/** Human-readable description */
|
|
116
|
+
description?: string;
|
|
117
|
+
/** Whether this is a built-in system hook (can't be unregistered) */
|
|
118
|
+
builtin?: boolean;
|
|
119
|
+
}
|
|
120
|
+
export type HookRegistration<T extends HookType = HookType> = Omit<Hook<T>, "id">;
|
|
121
|
+
export interface WebhookHook {
|
|
122
|
+
id: string;
|
|
123
|
+
type: HookType;
|
|
124
|
+
/** HTTP endpoint to POST the context to */
|
|
125
|
+
handlerUrl: string;
|
|
126
|
+
priority: number;
|
|
127
|
+
blocking: boolean;
|
|
128
|
+
agentId?: string;
|
|
129
|
+
projectId?: string;
|
|
130
|
+
description?: string;
|
|
131
|
+
enabled: boolean;
|
|
132
|
+
createdAt: string;
|
|
133
|
+
invocationCount: number;
|
|
134
|
+
failureCount: number;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/types/hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAI/E,MAAM,MAAM,QAAQ,GAEhB,eAAe,GACf,gBAAgB,GAChB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAElB,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,GACnB,oBAAoB,GAEpB,gBAAgB,GAChB,cAAc,GAEd,iBAAiB,GACjB,kBAAkB,CAAC;AAIvB,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,KAAK,EAAE,iBAAiB,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,sBAAuB,SAAQ,eAAe;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,sBAAuB,SAAQ,eAAe;IAC7D,QAAQ,EAA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