@trylucy/agent-memory 0.1.2 → 0.1.3
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/contracts/agent-memory-api.contract.json +2 -1
- package/contracts/hashes.json +4 -4
- package/package.json +1 -1
- package/schemas/v1/common.schema.json +2 -1
- package/schemas/v1/contract-document.schema.json +2 -1
- package/schemas/v1/recall-request.schema.json +1 -1
- package/src/client/index.d.ts +1 -1
- package/src/client/validation.mjs +2 -2
- package/src/mcp/schemas.mjs +11 -3
- package/src/mcp/server.mjs +2 -2
package/contracts/hashes.json
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"contract": {
|
|
4
4
|
"path": "contracts/agent-memory-api.contract.json",
|
|
5
|
-
"sha256": "
|
|
5
|
+
"sha256": "664b3a9e079f6173a8d779d88f6bcd9cae70b642d41124e4ff2d31ac71c93990"
|
|
6
6
|
},
|
|
7
7
|
"schemas": {
|
|
8
|
-
"schemas/v1/common.schema.json": "
|
|
9
|
-
"schemas/v1/contract-document.schema.json": "
|
|
8
|
+
"schemas/v1/common.schema.json": "2b84bbb652bb5ea05e53b64eb81ce2f71eea6a038cf88b0c224c126493e55c02",
|
|
9
|
+
"schemas/v1/contract-document.schema.json": "b7371f43c493d69cf9d2599b1d376d8a9a679b2bfe7f48bcc2275f0419328fb9",
|
|
10
10
|
"schemas/v1/create-proposal-request.schema.json": "cc0c90de7243f9f1a7040831d0ddaa644d896747c567b79c340fb42a64fc3637",
|
|
11
11
|
"schemas/v1/error.schema.json": "07dac4fea8be5ce2c09ee2b5924e870d353645ff83fca66bf657018c57b43b23",
|
|
12
12
|
"schemas/v1/memory-version-state.schema.json": "09353978ddca519bc6238306c466be1ec6994248f04071562537658bac76567c",
|
|
13
13
|
"schemas/v1/memory.schema.json": "559c992d6041dd49f3a9fcc969f313ffaa318679f44fdac20ecf9a50242bdc29",
|
|
14
14
|
"schemas/v1/proposal-status.schema.json": "909d901ba9ab2bbcfe39e6b2e41b7828ed957fd1e877cbea2a3155a460804adb",
|
|
15
15
|
"schemas/v1/public-surface.schema.json": "fd0bda7dfbe4f3b779c79e7b1edc6cfc26ec0bde8709ccf7235eba81b30cce91",
|
|
16
|
-
"schemas/v1/recall-request.schema.json": "
|
|
16
|
+
"schemas/v1/recall-request.schema.json": "72f898f94dfd7ea77c8f56196725138193dcc85627a81a4162d3bc637f218e69",
|
|
17
17
|
"schemas/v1/recall-response.schema.json": "51c3fd68cd6157c07766144c2533edbd440eb7621727ea463c88910186c2458f",
|
|
18
18
|
"schemas/v1/receipt.schema.json": "16b2a739f3c4e175f69b9273f28541b51a5ba303c2f842a095487d773779911f",
|
|
19
19
|
"schemas/v1/replace-proposal-request.schema.json": "020c1a18017ce68897fae2b1edbe2dcae31bdb4aa1bab0445df137be6a499940",
|
package/package.json
CHANGED
package/src/client/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type MemoryKind = 'fact' | 'preference' | 'decision' | 'rule';
|
|
1
|
+
export type MemoryKind = 'fact' | 'preference' | 'decision' | 'rule' | 'context';
|
|
2
2
|
export type MemoryLifecycle = 'active' | 'superseded' | 'revoked' | 'forgotten';
|
|
3
3
|
export type ProposalLifecycle = 'pending' | 'approved' | 'rejected' | 'expired' | 'superseded';
|
|
4
4
|
export type PublicPermission = 'memory:read' | 'memory:propose';
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ProposalContractIncompatibilityError, ValidationFailureError,
|
|
5
5
|
} from './errors.mjs';
|
|
6
6
|
|
|
7
|
-
export const MEMORY_KINDS = Object.freeze(['fact', 'preference', 'decision', 'rule']);
|
|
7
|
+
export const MEMORY_KINDS = Object.freeze(['fact', 'preference', 'decision', 'rule', 'context']);
|
|
8
8
|
export const MEMORY_LIFECYCLES = Object.freeze(['active', 'superseded', 'revoked', 'forgotten']);
|
|
9
9
|
export const PROPOSAL_LIFECYCLES = Object.freeze(['pending', 'approved', 'rejected', 'expired', 'superseded']);
|
|
10
10
|
export const SCOPE_KINDS = Object.freeze(['user', 'workspace', 'project']);
|
|
@@ -81,7 +81,7 @@ export function validateRecallRequest(request) {
|
|
|
81
81
|
allowed(request, new Set(['query', 'scope', 'keys', 'kinds', 'limit']), 'recall request');
|
|
82
82
|
bounded(request.query, 'query', { max: 1024 }); validateScope(request.scope);
|
|
83
83
|
if (request.keys !== undefined) unique(request.keys, 'keys', 20, validateKey);
|
|
84
|
-
if (request.kinds !== undefined) unique(request.kinds, 'kinds',
|
|
84
|
+
if (request.kinds !== undefined) unique(request.kinds, 'kinds', MEMORY_KINDS.length, validateKind);
|
|
85
85
|
if (request.limit !== undefined && (!Number.isInteger(request.limit) || request.limit < 1 || request.limit > 5)) throw new ValidationFailureError('limit must be an integer between 1 and 5.');
|
|
86
86
|
return request;
|
|
87
87
|
}
|
package/src/mcp/schemas.mjs
CHANGED
|
@@ -57,6 +57,14 @@ function bundled(name) {
|
|
|
57
57
|
const definitions = definitionsFor([name]);
|
|
58
58
|
return { ...structuredClone(definitions[name]), $defs: definitions };
|
|
59
59
|
}
|
|
60
|
+
function publishScope(value) {
|
|
61
|
+
if (Array.isArray(value)) return value.map(publishScope);
|
|
62
|
+
if (!value || typeof value !== 'object') return value;
|
|
63
|
+
if (value.$ref === '#/$defs/common/$defs/scope') {
|
|
64
|
+
return structuredClone(documents.get('common').$defs.scope);
|
|
65
|
+
}
|
|
66
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, publishScope(child)]));
|
|
67
|
+
}
|
|
60
68
|
function deepFreeze(value) {
|
|
61
69
|
if (value && typeof value === 'object' && !Object.isFrozen(value)) {
|
|
62
70
|
Object.freeze(value);
|
|
@@ -73,12 +81,12 @@ const proposalBranch = (name) => {
|
|
|
73
81
|
};
|
|
74
82
|
const statusDefinitions = definitionsFor(['common']);
|
|
75
83
|
export const MCP_SCHEMAS = deepFreeze({
|
|
76
|
-
recallInput: bundled('recall-request'),
|
|
77
|
-
proposalInput: {
|
|
84
|
+
recallInput: publishScope(bundled('recall-request')),
|
|
85
|
+
proposalInput: publishScope({
|
|
78
86
|
type: 'object',
|
|
79
87
|
oneOf: [proposalBranch('create-proposal-request'), proposalBranch('replace-proposal-request')],
|
|
80
88
|
$defs: proposalDefinitions,
|
|
81
|
-
},
|
|
89
|
+
}),
|
|
82
90
|
proposalStatusInput: {
|
|
83
91
|
type: 'object',
|
|
84
92
|
additionalProperties: false,
|
package/src/mcp/server.mjs
CHANGED
|
@@ -19,7 +19,7 @@ export const LUCY_MEMORY_TOOL_NAMES = Object.freeze([
|
|
|
19
19
|
const SAFE_ERROR_MESSAGES = Object.freeze({
|
|
20
20
|
authentication_failure: 'Lucy authentication failed.',
|
|
21
21
|
authorization_failure: 'Lucy authorization failed.',
|
|
22
|
-
invalid_scope: 'The memory scope is invalid.',
|
|
22
|
+
invalid_scope: 'The memory scope is invalid. Use {"kind":"user"}, {"kind":"workspace"}, or {"kind":"project","id":"project_..."}.',
|
|
23
23
|
invalid_key: 'The memory key is invalid.',
|
|
24
24
|
invalid_kind: 'The memory kind is invalid.',
|
|
25
25
|
validation_failure: 'The memory request is invalid.',
|
|
@@ -126,7 +126,7 @@ async function requireClient(client) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
export async function createLucyMemoryMcpServer({ client, name = 'lucy-memory-mcp', version = '0.1.
|
|
129
|
+
export async function createLucyMemoryMcpServer({ client, name = 'lucy-memory-mcp', version = '0.1.3' } = {}) {
|
|
130
130
|
const memoryClient = await requireClient(client);
|
|
131
131
|
const server = new Server(
|
|
132
132
|
{ name, version },
|