@noopolis/mneme 0.1.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/README.md +83 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +46 -0
- package/dist/contract/index.d.ts +3 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +2 -0
- package/dist/contract/toolDescriptors.d.ts +14 -0
- package/dist/contract/toolDescriptors.d.ts.map +1 -0
- package/dist/contract/toolDescriptors.js +98 -0
- package/dist/contract/types.d.ts +262 -0
- package/dist/contract/types.d.ts.map +1 -0
- package/dist/contract/types.js +1 -0
- package/dist/identity/ids.d.ts +9 -0
- package/dist/identity/ids.d.ts.map +1 -0
- package/dist/identity/ids.js +25 -0
- package/dist/identity/index.d.ts +3 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/index.js +2 -0
- package/dist/identity/scope.d.ts +24 -0
- package/dist/identity/scope.d.ts.map +1 -0
- package/dist/identity/scope.js +123 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/kernel/index.d.ts +3 -0
- package/dist/kernel/index.d.ts.map +1 -0
- package/dist/kernel/index.js +2 -0
- package/dist/kernel/kernel.d.ts +19 -0
- package/dist/kernel/kernel.d.ts.map +1 -0
- package/dist/kernel/kernel.js +318 -0
- package/dist/kernel/support.d.ts +66 -0
- package/dist/kernel/support.d.ts.map +1 -0
- package/dist/kernel/support.js +207 -0
- package/dist/mcp/config.d.ts +23 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +76 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/schemas.d.ts +150 -0
- package/dist/mcp/schemas.d.ts.map +1 -0
- package/dist/mcp/schemas.js +54 -0
- package/dist/mcp/server.d.ts +5 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +45 -0
- package/dist/policy/index.d.ts +2 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +1 -0
- package/dist/policy/policy.d.ts +9 -0
- package/dist/policy/policy.d.ts.map +1 -0
- package/dist/policy/policy.js +123 -0
- package/dist/recall/index.d.ts +2 -0
- package/dist/recall/index.d.ts.map +1 -0
- package/dist/recall/index.js +1 -0
- package/dist/recall/recall.d.ts +28 -0
- package/dist/recall/recall.d.ts.map +1 -0
- package/dist/recall/recall.js +178 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/runtime.d.ts +19 -0
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/runtime/runtime.js +129 -0
- package/dist/runtime/support.d.ts +52 -0
- package/dist/runtime/support.d.ts.map +1 -0
- package/dist/runtime/support.js +229 -0
- package/dist/store/index.d.ts +3 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +2 -0
- package/dist/store/sqliteIndex.d.ts +38 -0
- package/dist/store/sqliteIndex.d.ts.map +1 -0
- package/dist/store/sqliteIndex.js +270 -0
- package/dist/store/store.d.ts +27 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +114 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Mneme
|
|
2
|
+
|
|
3
|
+
Mneme is the Noopolis scoped memory runtime for agentic systems.
|
|
4
|
+
|
|
5
|
+
It provides:
|
|
6
|
+
|
|
7
|
+
- an append-only JSONL memory ledger;
|
|
8
|
+
- a rebuildable SQLite search index;
|
|
9
|
+
- scoped access and redaction policy;
|
|
10
|
+
- runtime-neutral memory tool descriptors;
|
|
11
|
+
- an MCP stdio server for external runtimes.
|
|
12
|
+
|
|
13
|
+
The package can be used directly by a host runtime or exposed through MCP.
|
|
14
|
+
|
|
15
|
+
## Install Locally
|
|
16
|
+
|
|
17
|
+
During incubation, sibling projects can depend on this package without a
|
|
18
|
+
published npm release:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@noopolis/mneme": "file:../mneme"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Then run:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## MCP Server
|
|
35
|
+
|
|
36
|
+
Start a local stdio MCP server for one agent:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
mneme mcp \
|
|
40
|
+
--runtime-home ./.runtime/agent-a \
|
|
41
|
+
--agent-id agent-a \
|
|
42
|
+
--conversation-scope global
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The server exposes:
|
|
46
|
+
|
|
47
|
+
- `memory_search`
|
|
48
|
+
- `memory_locate`
|
|
49
|
+
- `memory_register`
|
|
50
|
+
- `memory_summarize`
|
|
51
|
+
- `memory_forget`
|
|
52
|
+
|
|
53
|
+
The MCP adapter uses the same kernel as direct in-process integrations. The
|
|
54
|
+
transport only changes the envelope metadata.
|
|
55
|
+
|
|
56
|
+
## Environment
|
|
57
|
+
|
|
58
|
+
The CLI also accepts environment variables:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
MNEME_RUNTIME_HOME=./.runtime/agent-a \
|
|
62
|
+
MNEME_AGENT_ID=agent-a \
|
|
63
|
+
mneme mcp
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Useful variables:
|
|
67
|
+
|
|
68
|
+
- `MNEME_RUNTIME_HOME`
|
|
69
|
+
- `MNEME_AGENT_ID`
|
|
70
|
+
- `MNEME_AGENT_SCOPE`
|
|
71
|
+
- `MNEME_AGENT_QUALIFIER`
|
|
72
|
+
- `MNEME_CONVERSATION_SCOPE`
|
|
73
|
+
- `MNEME_AUDIENCE_KEY`
|
|
74
|
+
- `MNEME_POLICY_VERSION`
|
|
75
|
+
|
|
76
|
+
## Development
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm install
|
|
80
|
+
npm run typecheck
|
|
81
|
+
npm test
|
|
82
|
+
npm run build
|
|
83
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const printUsage = () => {
|
|
3
|
+
process.stderr.write(`Usage:
|
|
4
|
+
mneme mcp --runtime-home <path> --agent-id <id> [options]
|
|
5
|
+
|
|
6
|
+
Options:
|
|
7
|
+
--agent-scope <scope> Principal scope. Default: global
|
|
8
|
+
--agent-qualifier <value> Principal qualifier for room/team/pair/task scopes
|
|
9
|
+
--conversation-scope <scope> Conversation scope id. Default: principal scope id
|
|
10
|
+
--audience-key <key> Audience key. Default: agent id
|
|
11
|
+
--policy-version <version> Policy version. Default: memory-policy.v1
|
|
12
|
+
--source <label> Source label for generated memory events
|
|
13
|
+
--token-budget <number> Default recall token budget
|
|
14
|
+
|
|
15
|
+
Environment:
|
|
16
|
+
MNEME_RUNTIME_HOME
|
|
17
|
+
MNEME_AGENT_ID
|
|
18
|
+
MNEME_AGENT_SCOPE
|
|
19
|
+
MNEME_AGENT_QUALIFIER
|
|
20
|
+
MNEME_CONVERSATION_SCOPE
|
|
21
|
+
MNEME_AUDIENCE_KEY
|
|
22
|
+
MNEME_POLICY_VERSION
|
|
23
|
+
MNEME_SOURCE
|
|
24
|
+
MNEME_TOKEN_BUDGET
|
|
25
|
+
`);
|
|
26
|
+
};
|
|
27
|
+
const main = async () => {
|
|
28
|
+
const [command, ...args] = process.argv.slice(2);
|
|
29
|
+
if (command === "help" || command === "--help" || command === "-h") {
|
|
30
|
+
printUsage();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (command !== "mcp") {
|
|
34
|
+
printUsage();
|
|
35
|
+
process.exitCode = 2;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const { connectMnemeMcpStdio } = await import("../mcp/server.js");
|
|
39
|
+
const { parseMnemeMcpArgs } = await import("../mcp/config.js");
|
|
40
|
+
await connectMnemeMcpStdio(parseMnemeMcpArgs(args));
|
|
41
|
+
};
|
|
42
|
+
main().catch((error) => {
|
|
43
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
});
|
|
46
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MemoryExecutableToolName, MemoryKernel, MemoryModelToolName, MemoryToolCallEnvelope, MemoryToolDescriptor, MemoryToolExecutionContext } from "./types.js";
|
|
2
|
+
interface MemoryToolSpec {
|
|
3
|
+
name: MemoryExecutableToolName;
|
|
4
|
+
modelName: MemoryModelToolName;
|
|
5
|
+
label: string;
|
|
6
|
+
description: string;
|
|
7
|
+
promptSnippet: string;
|
|
8
|
+
promptGuidelines: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare const memoryToolSpecs: MemoryToolSpec[];
|
|
11
|
+
export declare const createMemoryToolEnvelope: (context: MemoryToolExecutionContext) => MemoryToolCallEnvelope;
|
|
12
|
+
export declare const createMemoryToolDescriptors: (kernel: MemoryKernel) => MemoryToolDescriptor[];
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=toolDescriptors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolDescriptors.d.ts","sourceRoot":"","sources":["../../src/contract/toolDescriptors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,YAAY,EACZ,mBAAmB,EAEnB,sBAAsB,EACtB,oBAAoB,EACpB,0BAA0B,EAE3B,MAAM,YAAY,CAAC;AAYpB,UAAU,cAAc;IACtB,IAAI,EAAE,wBAAwB,CAAC;IAC/B,SAAS,EAAE,mBAAmB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,eAAO,MAAM,eAAe,EAAE,cAAc,EAqD3C,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,SAAS,0BAA0B,KAClC,sBAaD,CAAC;AAyBH,eAAO,MAAM,2BAA2B,GACtC,QAAQ,YAAY,KACnB,oBAAoB,EAKlB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const defaultScopeAliases = [
|
|
2
|
+
"current",
|
|
3
|
+
"global",
|
|
4
|
+
"public_profile",
|
|
5
|
+
"public_facts",
|
|
6
|
+
"current_room",
|
|
7
|
+
"current_pair",
|
|
8
|
+
"current_task"
|
|
9
|
+
];
|
|
10
|
+
export const memoryToolSpecs = [
|
|
11
|
+
{
|
|
12
|
+
name: "memory.search",
|
|
13
|
+
modelName: "memory_search",
|
|
14
|
+
label: "Memory Search",
|
|
15
|
+
description: "Search scoped long-term memory through the policy boundary.",
|
|
16
|
+
promptSnippet: "Search scoped memory for relevant prior events.",
|
|
17
|
+
promptGuidelines: [
|
|
18
|
+
"Use memory_search before answering when prior room, pair, team, or global context may matter.",
|
|
19
|
+
"Treat redacted or private results as boundaries; do not infer hidden content."
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "memory.locate",
|
|
24
|
+
modelName: "memory_locate",
|
|
25
|
+
label: "Memory Locate",
|
|
26
|
+
description: "Locate which scoped memories may contain an answer without exposing private content.",
|
|
27
|
+
promptSnippet: "Locate memory candidates without necessarily exposing their content.",
|
|
28
|
+
promptGuidelines: [
|
|
29
|
+
"Use memory_locate when you suspect another scope has relevant history but need to respect privacy."
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "memory.register",
|
|
34
|
+
modelName: "memory_register",
|
|
35
|
+
label: "Memory Register",
|
|
36
|
+
description: "Register a durable memory with explicit evidence and visibility.",
|
|
37
|
+
promptSnippet: "Register durable memories with evidence and an explicit visibility.",
|
|
38
|
+
promptGuidelines: [
|
|
39
|
+
"Use memory_register for stable facts, decisions, relationships, or artifacts that should survive future turns.",
|
|
40
|
+
"Choose the narrowest visibility that fits the memory."
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "memory.summarize",
|
|
45
|
+
modelName: "memory_summarize",
|
|
46
|
+
label: "Memory Summarize",
|
|
47
|
+
description: "Summarize recent memory in a scope and store the summary as memory.",
|
|
48
|
+
promptSnippet: "Summarize a memory scope when history is too verbose.",
|
|
49
|
+
promptGuidelines: [
|
|
50
|
+
"Use memory_summarize to compact a scope before a long-running task or after a meaningful exchange."
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "memory.forget",
|
|
55
|
+
modelName: "memory_forget",
|
|
56
|
+
label: "Memory Forget",
|
|
57
|
+
description: "Write tombstones for memories that should no longer be recalled.",
|
|
58
|
+
promptSnippet: "Forget memories by writing tombstones instead of mutating history.",
|
|
59
|
+
promptGuidelines: [
|
|
60
|
+
"Use memory_forget only for explicitly obsolete, wrong, or policy-unsafe memories."
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
export const createMemoryToolEnvelope = (context) => ({
|
|
65
|
+
version: "mneme.memory.tool.v1",
|
|
66
|
+
wake_id: context.wakeId,
|
|
67
|
+
thread_id: context.threadId,
|
|
68
|
+
principal: context.principal,
|
|
69
|
+
conversation_scope: context.conversationScope,
|
|
70
|
+
audience_key: context.audienceKey ?? context.principal.agentId,
|
|
71
|
+
policy_version: context.policyVersion ?? "memory-policy.v1",
|
|
72
|
+
allowed_scope_aliases: context.allowedScopeAliases ?? defaultScopeAliases,
|
|
73
|
+
transport: context.transport ?? "in_process",
|
|
74
|
+
nonce: context.nonce ?? `${context.wakeId}:${Date.now()}`,
|
|
75
|
+
expires_at: context.expiresAt ?? new Date(Date.now() + 5 * 60_000).toISOString(),
|
|
76
|
+
capability: context.capability ?? "memory"
|
|
77
|
+
});
|
|
78
|
+
const createMemoryToolCall = (tool, argumentsValue, context) => ({
|
|
79
|
+
request_id: `${context.wakeId}:${tool}:${Date.now()}`,
|
|
80
|
+
tool,
|
|
81
|
+
arguments: argumentsValue,
|
|
82
|
+
envelope: createMemoryToolEnvelope(context)
|
|
83
|
+
});
|
|
84
|
+
const executeMemoryTool = (kernel, tool, call) => {
|
|
85
|
+
if (tool === "memory.search")
|
|
86
|
+
return kernel.search(call);
|
|
87
|
+
if (tool === "memory.locate")
|
|
88
|
+
return kernel.locate(call);
|
|
89
|
+
if (tool === "memory.register")
|
|
90
|
+
return kernel.register(call);
|
|
91
|
+
if (tool === "memory.summarize")
|
|
92
|
+
return kernel.summarize(call);
|
|
93
|
+
return kernel.forget(call);
|
|
94
|
+
};
|
|
95
|
+
export const createMemoryToolDescriptors = (kernel) => memoryToolSpecs.map((spec) => ({
|
|
96
|
+
...spec,
|
|
97
|
+
invoke: (argumentsValue, context) => executeMemoryTool(kernel, spec.name, createMemoryToolCall(spec.name, argumentsValue, context))
|
|
98
|
+
}));
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
export interface MemoryPrincipalRef {
|
|
2
|
+
agentId: string;
|
|
3
|
+
scope: "global" | "team" | "room" | "pair" | "task" | "role" | "artifact";
|
|
4
|
+
qualifier?: string;
|
|
5
|
+
}
|
|
6
|
+
export type MemoryWakeKind = "manual" | "message" | "schedule";
|
|
7
|
+
export interface MemoryToolCallEnvelope {
|
|
8
|
+
version: "mneme.memory.tool.v1";
|
|
9
|
+
wake_id: string;
|
|
10
|
+
thread_id: string;
|
|
11
|
+
principal: MemoryPrincipalRef;
|
|
12
|
+
conversation_scope: string;
|
|
13
|
+
audience_key: string;
|
|
14
|
+
policy_version: string;
|
|
15
|
+
allowed_scope_aliases: ReadonlyArray<"current" | "global" | "public_profile" | "public_facts" | "current_room" | "current_pair" | "current_task">;
|
|
16
|
+
transport: "in_process" | "mcp" | "protocol" | "text_loop";
|
|
17
|
+
nonce: string;
|
|
18
|
+
expires_at: string;
|
|
19
|
+
capability: string;
|
|
20
|
+
}
|
|
21
|
+
export type MemoryToolName = "memory.search" | "memory.locate" | "memory.register" | "memory.write" | "memory.summarize" | "memory.forget";
|
|
22
|
+
export type MemoryExecutableToolName = Exclude<MemoryToolName, "memory.write">;
|
|
23
|
+
export type MemoryModelToolName = "memory_search" | "memory_locate" | "memory_register" | "memory_summarize" | "memory_forget";
|
|
24
|
+
export interface MemoryToolExecutionContext {
|
|
25
|
+
wakeId: string;
|
|
26
|
+
threadId: string;
|
|
27
|
+
principal: MemoryPrincipalRef;
|
|
28
|
+
conversationScope: string;
|
|
29
|
+
audienceKey?: string;
|
|
30
|
+
policyVersion?: string;
|
|
31
|
+
allowedScopeAliases?: MemoryToolCallEnvelope["allowed_scope_aliases"];
|
|
32
|
+
transport?: MemoryToolCallEnvelope["transport"];
|
|
33
|
+
expiresAt?: string;
|
|
34
|
+
nonce?: string;
|
|
35
|
+
capability?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface MemoryToolCall {
|
|
38
|
+
request_id: string;
|
|
39
|
+
tool: MemoryToolName;
|
|
40
|
+
arguments: Record<string, unknown>;
|
|
41
|
+
envelope: MemoryToolCallEnvelope;
|
|
42
|
+
}
|
|
43
|
+
export type MemoryToolDecision = "allow_raw" | "allow_summary" | "allow_redacted_summary" | "known_but_private" | "locate_only" | "deny" | "unavailable" | "malformed_request";
|
|
44
|
+
export interface MemoryContext {
|
|
45
|
+
networkId?: string;
|
|
46
|
+
roomId?: string;
|
|
47
|
+
teamId?: string;
|
|
48
|
+
taskId?: string;
|
|
49
|
+
roleId?: string;
|
|
50
|
+
pairPeers?: string[];
|
|
51
|
+
artifactPaths?: string[];
|
|
52
|
+
from?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface WakeMemoryContext extends MemoryContext {
|
|
55
|
+
participants?: string[];
|
|
56
|
+
}
|
|
57
|
+
export interface MemoryToolResultContent {
|
|
58
|
+
kind: "memory" | "claim" | "narrative" | "relationship" | "artifact" | "locate";
|
|
59
|
+
text?: string;
|
|
60
|
+
event_ids: string[];
|
|
61
|
+
scope?: string;
|
|
62
|
+
principal?: MemoryPrincipalRef;
|
|
63
|
+
confidence?: number;
|
|
64
|
+
redactions: string[];
|
|
65
|
+
}
|
|
66
|
+
export interface MemoryToolAudit {
|
|
67
|
+
request_id: string;
|
|
68
|
+
requester: MemoryPrincipalRef;
|
|
69
|
+
sources: MemoryPrincipalRef[];
|
|
70
|
+
transport: "in_process" | "mcp" | "protocol" | "text_loop";
|
|
71
|
+
latency_ms: number;
|
|
72
|
+
argument_hash?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface MemoryToolResult {
|
|
75
|
+
request_id: string;
|
|
76
|
+
tool: MemoryToolName;
|
|
77
|
+
decision: MemoryToolDecision;
|
|
78
|
+
content: MemoryToolResultContent[];
|
|
79
|
+
audit: MemoryToolAudit;
|
|
80
|
+
error?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface MemorySearchArguments {
|
|
83
|
+
scope: string;
|
|
84
|
+
query: string;
|
|
85
|
+
limit?: number;
|
|
86
|
+
}
|
|
87
|
+
export interface MemoryLocateArguments {
|
|
88
|
+
query: string;
|
|
89
|
+
limit?: number;
|
|
90
|
+
active_scope?: string;
|
|
91
|
+
}
|
|
92
|
+
export type MemoryRegisterKind = MemoryContent["kind"] | "text";
|
|
93
|
+
export interface MemoryRegisterArguments {
|
|
94
|
+
scope: string;
|
|
95
|
+
kind: MemoryRegisterKind;
|
|
96
|
+
content: MemoryContent;
|
|
97
|
+
visibility: MemoryVisibility;
|
|
98
|
+
sensitivity: MemorySensitivity;
|
|
99
|
+
evidence_event_ids: string[];
|
|
100
|
+
source_type: string;
|
|
101
|
+
confidence?: number;
|
|
102
|
+
principal?: MemoryPrincipalRef;
|
|
103
|
+
}
|
|
104
|
+
export interface MemorySummarizeArguments {
|
|
105
|
+
scope: string;
|
|
106
|
+
horizon?: number;
|
|
107
|
+
}
|
|
108
|
+
export interface MemoryForgetArguments {
|
|
109
|
+
scope: string;
|
|
110
|
+
event_ids: string[];
|
|
111
|
+
reason?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface MemoryKernel {
|
|
114
|
+
search(call: MemoryToolCall): Promise<MemoryToolResult>;
|
|
115
|
+
locate(call: MemoryToolCall): Promise<MemoryToolResult>;
|
|
116
|
+
register(call: MemoryToolCall): Promise<MemoryToolResult>;
|
|
117
|
+
summarize(call: MemoryToolCall): Promise<MemoryToolResult>;
|
|
118
|
+
forget(call: MemoryToolCall): Promise<MemoryToolResult>;
|
|
119
|
+
}
|
|
120
|
+
export interface MemoryToolDescriptor {
|
|
121
|
+
name: MemoryExecutableToolName;
|
|
122
|
+
modelName: MemoryModelToolName;
|
|
123
|
+
label: string;
|
|
124
|
+
description: string;
|
|
125
|
+
promptSnippet: string;
|
|
126
|
+
promptGuidelines: string[];
|
|
127
|
+
invoke(argumentsValue: Record<string, unknown>, context: MemoryToolExecutionContext): Promise<MemoryToolResult>;
|
|
128
|
+
}
|
|
129
|
+
export type MemoryVisibility = "private" | "pair" | "team" | "room" | "global" | "public" | "sealed";
|
|
130
|
+
export type MemorySensitivity = "normal" | "sensitive" | "secret";
|
|
131
|
+
export type MemoryEventType = "memory.observed" | "memory.claimed" | "memory.registered" | "memory.summarized" | "memory.recalled" | "memory.located" | "memory.denied" | "memory.forgotten";
|
|
132
|
+
export type MemoryContent = {
|
|
133
|
+
kind: "text";
|
|
134
|
+
text: string;
|
|
135
|
+
} | {
|
|
136
|
+
kind: "claim";
|
|
137
|
+
subject: string;
|
|
138
|
+
predicate: string;
|
|
139
|
+
object: string;
|
|
140
|
+
} | {
|
|
141
|
+
kind: "decision";
|
|
142
|
+
decision: string;
|
|
143
|
+
rationale?: string;
|
|
144
|
+
} | {
|
|
145
|
+
kind: "artifact";
|
|
146
|
+
path?: string;
|
|
147
|
+
uri?: string;
|
|
148
|
+
description: string;
|
|
149
|
+
} | {
|
|
150
|
+
kind: "relationship";
|
|
151
|
+
from: string;
|
|
152
|
+
relation: string;
|
|
153
|
+
to: string;
|
|
154
|
+
};
|
|
155
|
+
export interface MemoryEvent {
|
|
156
|
+
id: string;
|
|
157
|
+
type: MemoryEventType;
|
|
158
|
+
createdAt: string;
|
|
159
|
+
principal: MemoryPrincipalRef;
|
|
160
|
+
scope: string;
|
|
161
|
+
visibility: MemoryVisibility;
|
|
162
|
+
source: string;
|
|
163
|
+
content: MemoryContent;
|
|
164
|
+
tags: string[];
|
|
165
|
+
entities: string[];
|
|
166
|
+
sensitivity: MemorySensitivity;
|
|
167
|
+
confidence?: number;
|
|
168
|
+
ttl?: string;
|
|
169
|
+
parentEventIds: string[];
|
|
170
|
+
checksum: string;
|
|
171
|
+
}
|
|
172
|
+
export interface MemoryEventInput {
|
|
173
|
+
type: MemoryEventType;
|
|
174
|
+
principal: MemoryPrincipalRef;
|
|
175
|
+
scope: string;
|
|
176
|
+
visibility: MemoryVisibility;
|
|
177
|
+
source: string;
|
|
178
|
+
content: MemoryContent;
|
|
179
|
+
tags?: string[];
|
|
180
|
+
entities?: string[];
|
|
181
|
+
sensitivity?: MemorySensitivity;
|
|
182
|
+
confidence?: number;
|
|
183
|
+
ttl?: string;
|
|
184
|
+
parentEventIds?: string[];
|
|
185
|
+
}
|
|
186
|
+
export type MemoryDecision = "allow_raw" | "allow_summary" | "allow_redacted_summary" | "known_but_private" | "locate_only" | "deny" | "unavailable" | "malformed_request";
|
|
187
|
+
export interface MemoryPolicyInput {
|
|
188
|
+
request: MemoryPrincipalRef;
|
|
189
|
+
activeScope?: MemoryPrincipalRef;
|
|
190
|
+
candidate: MemoryEvent;
|
|
191
|
+
}
|
|
192
|
+
export interface MemoryRecallAudit {
|
|
193
|
+
totalCandidates: number;
|
|
194
|
+
selectedEventIds: string[];
|
|
195
|
+
selected?: Array<{
|
|
196
|
+
eventId: string;
|
|
197
|
+
decision: MemoryDecision;
|
|
198
|
+
scope: string;
|
|
199
|
+
representation: string;
|
|
200
|
+
}>;
|
|
201
|
+
decisions: Array<{
|
|
202
|
+
eventId: string;
|
|
203
|
+
decision: MemoryDecision;
|
|
204
|
+
reason: string;
|
|
205
|
+
}>;
|
|
206
|
+
tokenBudgetUsed: number;
|
|
207
|
+
redactionCount: number;
|
|
208
|
+
}
|
|
209
|
+
export interface MemoryPacket {
|
|
210
|
+
principal: MemoryPrincipalRef;
|
|
211
|
+
sections: Array<{
|
|
212
|
+
heading: string;
|
|
213
|
+
text: string;
|
|
214
|
+
}>;
|
|
215
|
+
rawHint?: string;
|
|
216
|
+
}
|
|
217
|
+
export interface MemoryPacketInput {
|
|
218
|
+
activePrincipal: MemoryPrincipalRef;
|
|
219
|
+
event: {
|
|
220
|
+
id: string;
|
|
221
|
+
kind: string;
|
|
222
|
+
text: string;
|
|
223
|
+
from?: string;
|
|
224
|
+
};
|
|
225
|
+
context: WakeMemoryContext;
|
|
226
|
+
recalls: Array<{
|
|
227
|
+
event: MemoryEvent;
|
|
228
|
+
decision: MemoryDecision;
|
|
229
|
+
representation: string;
|
|
230
|
+
scope: string;
|
|
231
|
+
}>;
|
|
232
|
+
}
|
|
233
|
+
export interface MemoryRecallRequest {
|
|
234
|
+
eventId: string;
|
|
235
|
+
kind: MemoryWakeKind;
|
|
236
|
+
text: string;
|
|
237
|
+
from?: string;
|
|
238
|
+
context: WakeMemoryContext;
|
|
239
|
+
tokenBudget?: number;
|
|
240
|
+
}
|
|
241
|
+
export interface MemoryPrepareTurnResult {
|
|
242
|
+
principal: MemoryPrincipalRef;
|
|
243
|
+
packet: MemoryPacket;
|
|
244
|
+
promptText: string;
|
|
245
|
+
recall: MemoryRecallAudit;
|
|
246
|
+
}
|
|
247
|
+
export interface MemoryTurnRecord {
|
|
248
|
+
principal: MemoryPrincipalRef;
|
|
249
|
+
prompt: MemoryPacket;
|
|
250
|
+
request: MemoryRecallRequest;
|
|
251
|
+
recall?: MemoryRecallAudit;
|
|
252
|
+
result: "completed" | "failed";
|
|
253
|
+
outputText: string;
|
|
254
|
+
toolEvents?: unknown[];
|
|
255
|
+
error?: string;
|
|
256
|
+
}
|
|
257
|
+
export interface MemoryRuntime {
|
|
258
|
+
prepareTurn(request: MemoryRecallRequest): Promise<MemoryPrepareTurnResult>;
|
|
259
|
+
recordTurn(input: MemoryTurnRecord): Promise<void>;
|
|
260
|
+
kernel: MemoryKernel;
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/contract/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE/D,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,sBAAsB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,aAAa,CAClC,SAAS,GAAG,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AQ,EAAE,cAAc,CAAC;QACzB,cAAc,EAAE,MAAM,CAAC;QACvB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,iBAAiB,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC5E,UAAU,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,EAAE,YAAY,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MemoryEvent, MemoryPrincipalRef, MemoryEventInput } from "../contract/types.js";
|
|
2
|
+
export declare const canonicalPrincipalKey: (principal: MemoryPrincipalRef) => string;
|
|
3
|
+
export declare const canonicalScopeKey: (scope?: string) => string;
|
|
4
|
+
export declare const pairScopeId: (left: string, right: string) => string;
|
|
5
|
+
export declare const makeEventId: () => string;
|
|
6
|
+
export declare const makeChecksum: (event: MemoryEventInput | MemoryEvent) => string;
|
|
7
|
+
export declare const memoryScopeId: (principal: MemoryPrincipalRef) => string;
|
|
8
|
+
export declare const sanitizePrincipalQualifier: (value?: string) => string | undefined;
|
|
9
|
+
//# sourceMappingURL=ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/identity/ids.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,qBAAqB,GAAI,WAAW,kBAAkB,KAAG,MAMrE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,KAAG,MAA2C,CAAC;AAE/F,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,KAAG,MAGzD,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,MAA+B,CAAC;AAE/D,eAAO,MAAM,YAAY,GAAI,OAAO,gBAAgB,GAAG,WAAW,KAAG,MAGpE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,WAAW,kBAAkB,KAAG,MAC5B,CAAC;AAEnC,eAAO,MAAM,0BAA0B,GAAI,QAAQ,MAAM,KAAG,MAAM,GAAG,SAKpE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
export const canonicalPrincipalKey = (principal) => {
|
|
3
|
+
const parts = [`agent:${principal.agentId}`, `scope:${principal.scope}`];
|
|
4
|
+
if (principal.qualifier) {
|
|
5
|
+
parts.push(`qualifier:${principal.qualifier}`);
|
|
6
|
+
}
|
|
7
|
+
return parts.join("/");
|
|
8
|
+
};
|
|
9
|
+
export const canonicalScopeKey = (scope) => scope?.trim().toLowerCase() ?? "";
|
|
10
|
+
export const pairScopeId = (left, right) => {
|
|
11
|
+
const sorted = [left, right].map((value) => value.trim()).sort();
|
|
12
|
+
return `${sorted[0]}::${sorted[1]}`;
|
|
13
|
+
};
|
|
14
|
+
export const makeEventId = () => `evt_${randomUUID()}`;
|
|
15
|
+
export const makeChecksum = (event) => {
|
|
16
|
+
const content = JSON.stringify(event);
|
|
17
|
+
return createHash("sha256").update(content).digest("hex");
|
|
18
|
+
};
|
|
19
|
+
export const memoryScopeId = (principal) => canonicalPrincipalKey(principal);
|
|
20
|
+
export const sanitizePrincipalQualifier = (value) => {
|
|
21
|
+
if (!value) {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
return value.trim().toLowerCase();
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { WakeMemoryContext, MemoryPrincipalRef, MemoryWakeKind } from "../contract/types.js";
|
|
2
|
+
export interface ResolvedScopePlan {
|
|
3
|
+
activePrincipal: MemoryPrincipalRef;
|
|
4
|
+
readableScopes: MemoryPrincipalRef[];
|
|
5
|
+
candidateScopes: MemoryPrincipalRef[];
|
|
6
|
+
deniedScopes: MemoryPrincipalRef[];
|
|
7
|
+
}
|
|
8
|
+
export declare const resolveScopePlan: (input: {
|
|
9
|
+
agentId: string;
|
|
10
|
+
context?: WakeMemoryContext;
|
|
11
|
+
wake: {
|
|
12
|
+
id?: string;
|
|
13
|
+
kind: MemoryWakeKind;
|
|
14
|
+
from?: string;
|
|
15
|
+
};
|
|
16
|
+
}) => ResolvedScopePlan;
|
|
17
|
+
export declare const readMemoryContext: (event: {
|
|
18
|
+
kind: MemoryWakeKind;
|
|
19
|
+
from?: string;
|
|
20
|
+
text: string;
|
|
21
|
+
id?: string;
|
|
22
|
+
context?: WakeMemoryContext;
|
|
23
|
+
}) => WakeMemoryContext;
|
|
24
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/identity/scope.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAiB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEjH,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,kBAAkB,CAAC;IACpC,cAAc,EAAE,kBAAkB,EAAE,CAAC;IACrC,eAAe,EAAE,kBAAkB,EAAE,CAAC;IACtC,YAAY,EAAE,kBAAkB,EAAE,CAAC;CACpC;AA+DD,eAAO,MAAM,gBAAgB,GAAI,OAAO;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,IAAI,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,cAAc,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5D,KAAG,iBA4DH,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,OAAO;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,iBAAiB,CAAA;CAAE,KACrG,iBAkBF,CAAC"}
|