@j0hanz/memory-mcp 1.1.0 → 1.2.1

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.
Files changed (51) hide show
  1. package/dist/completions/index.js +1 -1
  2. package/dist/lib/instructions.d.ts.map +1 -1
  3. package/dist/lib/instructions.js +2 -88
  4. package/dist/lib/instructions.js.map +1 -1
  5. package/dist/lib/tool-contracts.d.ts.map +1 -1
  6. package/dist/lib/tool-contracts.js +68 -13
  7. package/dist/lib/tool-contracts.js.map +1 -1
  8. package/dist/lib/tool-response.d.ts.map +1 -1
  9. package/dist/lib/tool-response.js +7 -8
  10. package/dist/lib/tool-response.js.map +1 -1
  11. package/dist/resources/index.d.ts.map +1 -1
  12. package/dist/resources/index.js +121 -8
  13. package/dist/resources/index.js.map +1 -1
  14. package/dist/resources/instructions.d.ts +2 -0
  15. package/dist/resources/instructions.d.ts.map +1 -0
  16. package/dist/resources/instructions.js +106 -0
  17. package/dist/resources/instructions.js.map +1 -0
  18. package/dist/resources/server-config.d.ts +2 -0
  19. package/dist/resources/server-config.d.ts.map +1 -0
  20. package/dist/resources/server-config.js +72 -0
  21. package/dist/resources/server-config.js.map +1 -0
  22. package/dist/resources/tool-catalog.d.ts +2 -0
  23. package/dist/resources/tool-catalog.d.ts.map +1 -0
  24. package/dist/resources/tool-catalog.js +64 -0
  25. package/dist/resources/tool-catalog.js.map +1 -0
  26. package/dist/resources/tool-info.d.ts +5 -0
  27. package/dist/resources/tool-info.d.ts.map +1 -0
  28. package/dist/resources/tool-info.js +129 -0
  29. package/dist/resources/tool-info.js.map +1 -0
  30. package/dist/resources/workflows.d.ts +2 -0
  31. package/dist/resources/workflows.d.ts.map +1 -0
  32. package/dist/resources/workflows.js +55 -0
  33. package/dist/resources/workflows.js.map +1 -0
  34. package/dist/schemas/inputs.d.ts.map +1 -1
  35. package/dist/schemas/inputs.js +55 -27
  36. package/dist/schemas/inputs.js.map +1 -1
  37. package/dist/schemas/outputs.d.ts.map +1 -1
  38. package/dist/schemas/outputs.js +144 -91
  39. package/dist/schemas/outputs.js.map +1 -1
  40. package/dist/server.d.ts.map +1 -1
  41. package/dist/server.js +7 -0
  42. package/dist/server.js.map +1 -1
  43. package/dist/tools/get-relationships.js +1 -1
  44. package/dist/tools/get-relationships.js.map +1 -1
  45. package/dist/tools/progress.d.ts.map +1 -1
  46. package/dist/tools/progress.js +3 -5
  47. package/dist/tools/progress.js.map +1 -1
  48. package/dist/tools/retrieve-context.d.ts.map +1 -1
  49. package/dist/tools/retrieve-context.js +4 -6
  50. package/dist/tools/retrieve-context.js.map +1 -1
  51. package/package.json +1 -1
@@ -0,0 +1,106 @@
1
+ import { getToolContracts } from '../lib/tool-contracts.js';
2
+ import { getSharedConstraints } from './tool-info.js';
3
+ const PROMPTS_INVENTORY = ['- `get-help` — Return full usage instructions.'];
4
+ const RESOURCES_INVENTORY = [
5
+ '- `internal://instructions` — This document. Read for tool routing, error codes, and workflows.',
6
+ '- `internal://tool-catalog` — Tool reference table, optional parameter matrix, and cross-tool data flow.',
7
+ '- `internal://tool-info/{toolName}` — Per-tool detail: parameters, behavior, and output shape.',
8
+ '- `internal://workflows` — Recommended multi-step workflow sequences.',
9
+ '- `internal://server-config` — Runtime configuration, limits, and capabilities.',
10
+ '- `memory://memories/{hash}` — Fetch a single memory by URI with hash auto-completion.',
11
+ ];
12
+ const ERROR_CODES = [
13
+ '| Code | Meaning |',
14
+ '| --- | --- |',
15
+ '| `E_NOT_FOUND` | Hash or relationship does not exist |',
16
+ '| `E_CONFLICT` | `update_memory` target content+tags already maps to an existing hash |',
17
+ '| `E_CANCELLED` | Request was cancelled |',
18
+ '| `E_UNKNOWN` | Unexpected internal error — retry once |',
19
+ ];
20
+ const DATA_MODEL = `### Memory
21
+ - \`hash\` — SHA-256 of \`(content + sorted tags)\`; deterministic; changes when content or tags change
22
+ - \`content\` — Text; 1–100,000 chars
23
+ - \`tags\` — Array; 1–100 tags; each 1–50 chars, no whitespace; minimum 1 required
24
+ - \`memory_type\` — \`general\` | \`fact\` | \`plan\` | \`decision\` | \`reflection\` | \`lesson\` | \`error\` | \`gradient\` (default \`general\`)
25
+ - \`importance\` — Integer 0–10 (default 0; 10 = critical)
26
+ - \`created_at\`, \`updated_at\` — ISO 8601 timestamps
27
+
28
+ ### Relationship
29
+ - Directed edge: \`from_hash -[relation_type]-> to_hash\`
30
+ - \`relation_type\` — Free-form string, 1–50 chars, no whitespace
31
+ - Suggested types: \`related_to\`, \`causes\`, \`depends_on\`, \`parent_of\`, \`child_of\`, \`supersedes\`, \`contradicts\`, \`supports\`, \`references\`
32
+ - Both endpoints must exist before creating a relationship
33
+ - Cascade-deleted when either endpoint memory is deleted
34
+ - Cascade-updated when either endpoint hash changes (ON UPDATE CASCADE)`;
35
+ const WORKFLOWS = `### Store and Link
36
+ \`\`\`
37
+ store_memories({ items: [...] }) → { items[].hash, succeeded, failed }
38
+ create_relationship({ from_hash, to_hash, relation_type }) × N
39
+ \`\`\`
40
+
41
+ ### Search and Read
42
+ \`\`\`
43
+ search_memories({ query, limit }) → { memories[], nextCursor }
44
+ # or, for relationship navigation:
45
+ recall({ query, depth: 1 }) → { memories[], graph[] }
46
+ \`\`\`
47
+
48
+ ### Fill Context Window
49
+ \`\`\`
50
+ retrieve_context({ query, token_budget: 4000, strategy: 'relevance' })
51
+ → { memories[], estimated_tokens, truncated }
52
+ \`\`\`
53
+
54
+ ### Update a Memory
55
+ \`\`\`
56
+ update_memory({ hash, content }) → { old_hash, new_hash }
57
+ # Existing relationships auto-update to new_hash via CASCADE
58
+ \`\`\`
59
+
60
+ ### Batch Delete
61
+ \`\`\`
62
+ delete_memories({ hashes: [...] }) → { items[].{ hash, deleted }, succeeded, failed }
63
+ # deleted: false means hash not found — not an error
64
+ \`\`\``;
65
+ function buildToolRouting() {
66
+ const contracts = getToolContracts();
67
+ const rows = contracts.map((c) => {
68
+ const purpose = c.description.split('.')[0] ?? '';
69
+ return `| \`${c.name}\` | ${purpose} |`;
70
+ });
71
+ return [
72
+ '## Tool Routing',
73
+ '',
74
+ '| Tool | Purpose |',
75
+ '| --- | --- |',
76
+ ...rows,
77
+ ].join('\n');
78
+ }
79
+ export function buildServerInstructions() {
80
+ return [
81
+ '# Memory MCP — Usage Guide',
82
+ '',
83
+ buildToolRouting(),
84
+ '',
85
+ '## Shared Constraints',
86
+ getSharedConstraints()
87
+ .map((c) => `- ${c}`)
88
+ .join('\n'),
89
+ '',
90
+ '## Error Codes',
91
+ ERROR_CODES.join('\n'),
92
+ '',
93
+ '## Data Model',
94
+ DATA_MODEL,
95
+ '',
96
+ '## Common Workflows',
97
+ WORKFLOWS,
98
+ '',
99
+ '## Prompts',
100
+ PROMPTS_INVENTORY.join('\n'),
101
+ '',
102
+ '## Resources',
103
+ RESOURCES_INVENTORY.join('\n'),
104
+ ].join('\n');
105
+ }
106
+ //# sourceMappingURL=instructions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/resources/instructions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,iBAAiB,GAAG,CAAC,gDAAgD,CAAC,CAAC;AAE7E,MAAM,mBAAmB,GAAG;IAC1B,iGAAiG;IACjG,0GAA0G;IAC1G,gGAAgG;IAChG,uEAAuE;IACvE,iFAAiF;IACjF,wFAAwF;CACzF,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB,oBAAoB;IACpB,eAAe;IACf,yDAAyD;IACzD,yFAAyF;IACzF,2CAA2C;IAC3C,0DAA0D;CAC3D,CAAC;AAEF,MAAM,UAAU,GAAG;;;;;;;;;;;;;;wEAcqD,CAAC;AAEzE,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BX,CAAC;AAER,SAAS,gBAAgB;IACvB,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAC;IACrC,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC/B,MAAM,OAAO,GAAG,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAClD,OAAO,OAAO,CAAC,CAAC,IAAI,QAAQ,OAAO,IAAI,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,iBAAiB;QACjB,EAAE;QACF,oBAAoB;QACpB,eAAe;QACf,GAAG,IAAI;KACR,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,OAAO;QACL,4BAA4B;QAC5B,EAAE;QACF,gBAAgB,EAAE;QAClB,EAAE;QACF,uBAAuB;QACvB,oBAAoB,EAAE;aACnB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;aACpB,IAAI,CAAC,IAAI,CAAC;QACb,EAAE;QACF,gBAAgB;QAChB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;QACtB,EAAE;QACF,eAAe;QACf,UAAU;QACV,EAAE;QACF,qBAAqB;QACrB,SAAS;QACT,EAAE;QACF,YAAY;QACZ,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5B,EAAE;QACF,cAAc;QACd,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC;KAC/B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function buildServerConfig(): string;
2
+ //# sourceMappingURL=server-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../src/resources/server-config.ts"],"names":[],"mappings":"AAgDA,wBAAgB,iBAAiB,IAAI,MAAM,CA8B1C"}
@@ -0,0 +1,72 @@
1
+ const ENV_VARS = [
2
+ {
3
+ name: 'MEMORY_DB_PATH',
4
+ default: 'memory.db',
5
+ range: '—',
6
+ purpose: 'SQLite database file path',
7
+ },
8
+ {
9
+ name: 'RECALL_MAX_FRONTIER_SIZE',
10
+ default: '1000',
11
+ range: '100–50000',
12
+ purpose: 'Maximum BFS frontier size per hop',
13
+ },
14
+ {
15
+ name: 'RECALL_MAX_EDGE_ROWS',
16
+ default: '5000',
17
+ range: '100–50000',
18
+ purpose: 'Maximum edge rows fetched per traversal',
19
+ },
20
+ {
21
+ name: 'RECALL_MAX_VISITED_NODES',
22
+ default: '5000',
23
+ range: '100–50000',
24
+ purpose: 'Maximum visited nodes during BFS traversal',
25
+ },
26
+ ];
27
+ const DATA_LIMITS = [
28
+ { dimension: 'Content length', range: '1–100,000 chars' },
29
+ { dimension: 'Tags per memory', range: '1–100 tags' },
30
+ { dimension: 'Tag length', range: '1–50 chars, no whitespace' },
31
+ { dimension: 'Batch size', range: '1–50 items' },
32
+ { dimension: 'Search results per page', range: '1–100 (default 20)' },
33
+ { dimension: 'Recall depth', range: '0–3 hops' },
34
+ { dimension: 'Token budget', range: '100–200,000' },
35
+ { dimension: 'Hash format', range: 'SHA-256, 64 hex chars' },
36
+ { dimension: 'Relation type', range: '1–50 chars, no whitespace' },
37
+ { dimension: 'Importance', range: '0–10 (integer)' },
38
+ ];
39
+ const CAPABILITIES = [
40
+ { capability: 'tools', status: 'enabled' },
41
+ { capability: 'resources', status: 'enabled (subscribe supported)' },
42
+ { capability: 'prompts', status: 'enabled' },
43
+ { capability: 'completions', status: 'enabled' },
44
+ { capability: 'logging', status: 'enabled' },
45
+ ];
46
+ export function buildServerConfig() {
47
+ const envRows = ENV_VARS.map((v) => `| \`${v.name}\` | ${v.default} | ${v.range} | ${v.purpose} |`);
48
+ const limitRows = DATA_LIMITS.map((l) => `| ${l.dimension} | ${l.range} |`);
49
+ const capRows = CAPABILITIES.map((c) => `| ${c.capability} | ${c.status} |`);
50
+ return [
51
+ '# Server Configuration',
52
+ '',
53
+ '## Environment Variables',
54
+ '',
55
+ '| Variable | Default | Range | Purpose |',
56
+ '|----------|---------|-------|---------|',
57
+ ...envRows,
58
+ '',
59
+ '## Capabilities',
60
+ '',
61
+ '| Capability | Status |',
62
+ '|------------|--------|',
63
+ ...capRows,
64
+ '',
65
+ '## Data Limits',
66
+ '',
67
+ '| Dimension | Range |',
68
+ '|-----------|-------|',
69
+ ...limitRows,
70
+ ].join('\n');
71
+ }
72
+ //# sourceMappingURL=server-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-config.js","sourceRoot":"","sources":["../../src/resources/server-config.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG;IACf;QACE,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,WAAW;QACpB,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,2BAA2B;KACrC;IACD;QACE,IAAI,EAAE,0BAA0B;QAChC,OAAO,EAAE,MAAM;QACf,KAAK,EAAE,WAAW;QAClB,OAAO,EAAE,mCAAmC;KAC7C;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,OAAO,EAAE,MAAM;QACf,KAAK,EAAE,WAAW;QAClB,OAAO,EAAE,yCAAyC;KACnD;IACD;QACE,IAAI,EAAE,0BAA0B;QAChC,OAAO,EAAE,MAAM;QACf,KAAK,EAAE,WAAW;QAClB,OAAO,EAAE,4CAA4C;KACtD;CACO,CAAC;AAEX,MAAM,WAAW,GAAG;IAClB,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,iBAAiB,EAAE;IACzD,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,EAAE;IACrD,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,2BAA2B,EAAE;IAC/D,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;IAChD,EAAE,SAAS,EAAE,yBAAyB,EAAE,KAAK,EAAE,oBAAoB,EAAE;IACrE,EAAE,SAAS,EAAE,cA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C1C,0CAA0C;QAC1C,GAAG,OAAO;QACV,EAAE;QACF,iBAAiB;QACjB,EAAE;QACF,yBAAyB;QACzB,yBAAyB;QACzB,GAAG,OAAO;QACV,EAAE;QACF,gBAAgB;QAChB,EAAE;QACF,uBAAuB;QACvB,uBAAuB;QACvB,GAAG,SAAS;KACb,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function buildToolCatalog(): string;
2
+ //# sourceMappingURL=tool-catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-catalog.d.ts","sourceRoot":"","sources":["../../src/resources/tool-catalog.ts"],"names":[],"mappings":"AA0DA,wBAAgB,gBAAgB,IAAI,MAAM,CAwBzC"}
@@ -0,0 +1,64 @@
1
+ import { z } from 'zod/v4';
2
+ import { getToolContracts } from '../lib/tool-contracts.js';
3
+ import { buildCoreContextPack } from './tool-info.js';
4
+ function extractJsonSchema(schema) {
5
+ try {
6
+ return z.toJSONSchema(schema);
7
+ }
8
+ catch {
9
+ return {};
10
+ }
11
+ }
12
+ function extractOptionalParams(toolName, schema) {
13
+ const jsonSchema = extractJsonSchema(schema);
14
+ const properties = (jsonSchema['properties'] ?? {});
15
+ const requiredFields = new Set(Array.isArray(jsonSchema['required'])
16
+ ? jsonSchema['required']
17
+ : []);
18
+ const rows = [];
19
+ for (const [name, prop] of Object.entries(properties).sort(([a], [b]) => a.localeCompare(b))) {
20
+ if (requiredFields.has(name))
21
+ continue;
22
+ const desc = typeof prop['description'] === 'string' ? prop['description'] : '';
23
+ const rawDefault = prop['default'];
24
+ const defaultVal = rawDefault !== undefined ? JSON.stringify(rawDefault) : '—';
25
+ rows.push(`| \`${toolName}\` | \`${name}\` | ${defaultVal} | ${desc} |`);
26
+ }
27
+ return rows;
28
+ }
29
+ const CROSS_TOOL_DATA_FLOW = `## Cross-Tool Data Flow
30
+
31
+ \`\`\`
32
+ store_memory.hash ──→ get_memory.hash
33
+ store_memory.hash ──→ create_relationship.from_hash / to_hash
34
+ store_memory.hash ──→ update_memory.hash
35
+ store_memory.hash ──→ delete_memory.hash
36
+ store_memories.items[].hash ──→ get_memory.hash
37
+ search_memories.memories[].hash ──→ get_memory.hash
38
+ search_memories.nextCursor ──→ search_memories.cursor
39
+ recall.memories[].hash ──→ get_memory.hash
40
+ recall.nextCursor ──→ recall.cursor
41
+ update_memory.new_hash ──→ get_memory.hash
42
+ get_relationships.relationships[].linked_hash ──→ get_memory.hash
43
+ \`\`\``;
44
+ export function buildToolCatalog() {
45
+ const contracts = getToolContracts();
46
+ const optionalRows = contracts.flatMap((c) => extractOptionalParams(c.name, c.inputSchema));
47
+ const optionalParamSection = optionalRows.length > 0
48
+ ? [
49
+ '## Optional Parameter Matrix',
50
+ '',
51
+ '| Tool | Parameter | Default | Purpose |',
52
+ '|------|-----------|---------|---------|',
53
+ ...optionalRows,
54
+ ].join('\n')
55
+ : '';
56
+ return [
57
+ buildCoreContextPack(),
58
+ '',
59
+ optionalParamSection,
60
+ '',
61
+ CROSS_TOOL_DATA_FLOW,
62
+ ].join('\n');
63
+ }
64
+ //# sourceMappingURL=tool-catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-catalog.js","sourceRoot":"","sources":["../../src/resources/tool-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAItD,SAAS,iBAAiB,CAAC,MAAiB;IAC1C,IAAI,CAAC;QACH,OAAO,CAAC,CAAC,YAAY,CAAC,MAAM,CAAqB,CAAC;IACpD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,QAAgB,EAAE,MAAiB;IAChE,MAAM,UAAU,GAAG,iBAA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AO,CAAC,CAAC,CAAC,EAAE,EAAE,CAC3C,qBAAqB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,CAC7C,CAAC;IAEF,MAAM,oBAAoB,GACxB,YAAY,CAAC,MAAM,GAAG,CAAC;QACrB,CAAC,CAAC;YACE,8BAA8B;YAC9B,EAAE;YACF,0CAA0C;YAC1C,0CAA0C;YAC1C,GAAG,YAAY;SAChB,CAAC,IAAI,CAAC,IAAI,CAAC;QACd,CAAC,CAAC,EAAE,CAAC;IAET,OAAO;QACL,oBAAoB,EAAE;QACtB,EAAE;QACF,oBAAoB;QACpB,EAAE;QACF,oBAAoB;KACrB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare function getSharedConstraints(): readonly string[];
2
+ export declare function buildCoreContextPack(): string;
3
+ export declare function getToolInfo(name: string): string | undefined;
4
+ export declare function getToolNames(): string[];
5
+ //# sourceMappingURL=tool-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-info.d.ts","sourceRoot":"","sources":["../../src/resources/tool-info.ts"],"names":[],"mappings":"AAcA,wBAAgB,oBAAoB,IAAI,SAAS,MAAM,EAAE,CAExD;AA4BD,wBAAgB,oBAAoB,IAAI,MAAM,CAgB7C;AAiED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAwC5D;AAED,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAIvC"}
@@ -0,0 +1,129 @@
1
+ import { z } from 'zod/v4';
2
+ import { getToolContracts } from '../lib/tool-contracts.js';
3
+ // --- Shared Constraints (Single Source of Truth) ---
4
+ const SHARED_CONSTRAINTS = [
5
+ 'Idempotence: `store_memory` and `store_memories` return `created: false` if content+tags already exist.',
6
+ 'Atomic Transactions: `store_memories` and `delete_memories` roll back entirely on unexpected errors.',
7
+ 'Hash Changes: `update_memory` changes the hash when content or tags change. Relationships survive via CASCADE.',
8
+ 'FTS Search Limits: Query terms matched individually (all-OR logic). Phrase operators and negation not supported.',
9
+ 'Recall Limits: BFS traversal is bounded by env vars (RECALL_MAX_FRONTIER_SIZE, RECALL_MAX_EDGE_ROWS, RECALL_MAX_VISITED_NODES). Returns `aborted: true` with partial results when limits are hit.',
10
+ ];
11
+ export function getSharedConstraints() {
12
+ return SHARED_CONSTRAINTS;
13
+ }
14
+ function formatBehavior(annotations) {
15
+ const hints = [];
16
+ if (annotations.readOnlyHint === true)
17
+ hints.push('read-only');
18
+ if (annotations.destructiveHint === true)
19
+ hints.push('destructive');
20
+ if (annotations.idempotentHint === true)
21
+ hints.push('idempotent');
22
+ return hints.join(', ') || '—';
23
+ }
24
+ function toEntry(contract) {
25
+ return {
26
+ name: contract.name,
27
+ purpose: contract.description.split('.')[0] ?? '',
28
+ behavior: formatBehavior(contract.annotations),
29
+ };
30
+ }
31
+ export function buildCoreContextPack() {
32
+ const contracts = getToolContracts();
33
+ const entries = contracts
34
+ .map(toEntry)
35
+ .sort((a, b) => a.name.localeCompare(b.name));
36
+ const rows = entries.map((e) => `| \`${e.name}\` | ${e.purpose} | ${e.behavior} |`);
37
+ return [
38
+ '# Core Context Pack',
39
+ '',
40
+ '| Tool | Purpose | Behavior |',
41
+ '|------|---------|----------|',
42
+ ...rows,
43
+ ].join('\n');
44
+ }
45
+ // --- Per-Tool Info ---
46
+ function extractJsonSchema(schema) {
47
+ try {
48
+ return z.toJSONSchema(schema);
49
+ }
50
+ catch {
51
+ return {};
52
+ }
53
+ }
54
+ function formatParamConstraints(prop) {
55
+ const parts = [];
56
+ if (typeof prop['minimum'] === 'number')
57
+ parts.push(`min: ${prop['minimum']}`);
58
+ if (typeof prop['maximum'] === 'number')
59
+ parts.push(`max: ${prop['maximum']}`);
60
+ if (typeof prop['minLength'] === 'number')
61
+ parts.push(`minLength: ${prop['minLength']}`);
62
+ if (typeof prop['maxLength'] === 'number')
63
+ parts.push(`maxLength: ${prop['maxLength']}`);
64
+ if (typeof prop['minItems'] === 'number')
65
+ parts.push(`minItems: ${prop['minItems']}`);
66
+ if (typeof prop['maxItems'] === 'number')
67
+ parts.push(`maxItems: ${prop['maxItems']}`);
68
+ if (Array.isArray(prop['enum']))
69
+ parts.push(`enum: ${prop['enum'].join(' | ')}`);
70
+ return parts.length > 0 ? `; ${parts.join(', ')}` : '';
71
+ }
72
+ function formatParam(name, prop, required) {
73
+ const type = typeof prop['type'] === 'string' ? prop['type'] : 'unknown';
74
+ const desc = typeof prop['description'] === 'string' ? prop['description'] : '';
75
+ const constraints = formatParamConstraints(prop);
76
+ return `- \`${name}\` (${type}, ${required ? 'required' : 'optional'}${constraints}) — ${desc}`;
77
+ }
78
+ function formatOutputShape(schema) {
79
+ const jsonSchema = extractJsonSchema(schema);
80
+ const properties = jsonSchema['properties'];
81
+ if (!properties)
82
+ return '{}';
83
+ const requiredFields = new Set(Array.isArray(jsonSchema['required'])
84
+ ? jsonSchema['required']
85
+ : []);
86
+ const parts = Object.entries(properties).map(([key, prop]) => {
87
+ const isArray = prop['type'] === 'array';
88
+ const isOptional = !requiredFields.has(key);
89
+ return `${key}${isArray ? '[]' : ''}${isOptional ? '?' : ''}`;
90
+ });
91
+ return `{${parts.join(', ')}}`;
92
+ }
93
+ export function getToolInfo(name) {
94
+ const contract = getToolContracts().find((c) => c.name === name);
95
+ if (!contract)
96
+ return undefined;
97
+ const inputSchema = extractJsonSchema(contract.inputSchema);
98
+ const properties = (inputSchema['properties'] ?? {});
99
+ const requiredFields = new Set(Array.isArray(inputSchema['required'])
100
+ ? inputSchema['required']
101
+ : []);
102
+ const paramLines = Object.entries(properties)
103
+ .sort(([a], [b]) => a.localeCompare(b))
104
+ .map(([pName, pSchema]) => formatParam(pName, pSchema, requiredFields.has(pName)));
105
+ const behaviorLine = formatBehavior(contract.annotations);
106
+ const outputShape = formatOutputShape(contract.outputSchema);
107
+ return [
108
+ `# \`${contract.name}\``,
109
+ '',
110
+ `**${contract.title}**`,
111
+ '',
112
+ contract.description,
113
+ '',
114
+ '## Parameters',
115
+ paramLines.length > 0 ? paramLines.join('\n') : '_No parameters._',
116
+ '',
117
+ '## Behavior',
118
+ behaviorLine,
119
+ '',
120
+ '## Output Shape',
121
+ `\`${outputShape}\``,
122
+ ].join('\n');
123
+ }
124
+ export function getToolNames() {
125
+ return getToolContracts()
126
+ .map((c) => c.name)
127
+ .sort((a, b) => a.localeCompare(b));
128
+ }
129
+ //# sourceMappingURL=tool-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-info.js","sourceRoot":"","sources":["../../src/resources/tool-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAqB,MAAM,0BAA0B,CAAC;AAE/E,sDAAsD;AAEtD,MAAM,kBAAkB,GAAsB;IAC5C,yGAAyG;IACzG,sGAAsG;IACtG,gHAAgH;IAChH,kHAAkH;IAClH,mMAAmM;CACpM,CAAC;AAEF,MAAM,UAAU,oBAAoB;IAClC,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAYD,SAAS,cAAc,CAAC,WAAwC;IAC9D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,WAAW,CAAC,YAAY,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/D,IAAI,WAAW,CAAC,eAAe,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACpE,IAAI,WAAW,CAAC,cAAc,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;AACjC,CAAC;AAED,SAAS,OAAO,CAAC,QAAsB;IACrC,OAAO;QACL,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,KAA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,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,gBAAgB,EAAE;SACtB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SAClB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function buildWorkflowGuide(): string;
2
+ //# sourceMappingURL=workflows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/resources/workflows.ts"],"names":[],"mappings":"AA0CA,wBAAgB,kBAAkB,IAAI,MAAM,CAa3C"}
@@ -0,0 +1,55 @@
1
+ import { getSharedConstraints } from './tool-info.js';
2
+ const WORKFLOW_TRACKS = `## Workflow A: Store and Link
3
+
4
+ 1. \`store_memories({ items: [...] })\` → \`{ items[].hash, succeeded, failed }\`
5
+ 2. \`create_relationship({ from_hash, to_hash, relation_type })\` × N
6
+
7
+ > Constraint: Both endpoint memories must exist before creating a relationship.
8
+
9
+ ## Workflow B: Search and Read
10
+
11
+ 1. \`search_memories({ query, limit })\` → \`{ memories[], nextCursor }\`
12
+ 2. \`get_memory({ hash })\` for full detail on a specific result
13
+
14
+ > Or use \`recall({ query, depth: 1 })\` → \`{ memories[], graph[] }\` to follow relationships.
15
+
16
+ ## Workflow C: Fill Context Window
17
+
18
+ 1. \`retrieve_context({ query, token_budget: 4000, strategy: 'relevance' })\` → \`{ memories[], estimated_tokens, truncated }\`
19
+
20
+ > Use \`strategy\` to control sort: \`relevance\` (FTS rank), \`importance\` (highest first), or \`recency\` (newest first).
21
+
22
+ ## Workflow D: Update a Memory
23
+
24
+ 1. \`update_memory({ hash, content })\` → \`{ old_hash, new_hash }\`
25
+
26
+ > Existing relationships auto-update to new_hash via CASCADE.
27
+ > Returns E_CONFLICT if the new content+tags already maps to an existing hash.
28
+
29
+ ## Workflow E: Batch Delete
30
+
31
+ 1. \`delete_memories({ hashes: [...] })\` → \`{ items[].{ hash, deleted }, succeeded, failed }\`
32
+
33
+ > \`deleted: false\` means hash not found — not an error, the batch still succeeds.
34
+
35
+ ## Workflow F: Explore Graph
36
+
37
+ 1. \`recall({ query, depth: 2 })\` → \`{ memories[], graph[], depth_reached, aborted }\`
38
+ 2. \`get_relationships({ hash, direction: 'both' })\` for a specific memory's edges
39
+
40
+ > BFS traversal emits progress per hop. Use \`depth: 0\` to skip traversal.`;
41
+ export function buildWorkflowGuide() {
42
+ return [
43
+ '# Workflow Reference',
44
+ '',
45
+ WORKFLOW_TRACKS,
46
+ '',
47
+ '## Shared Constraints',
48
+ getSharedConstraints()
49
+ .map((c) => `- ${c}`)
50
+ .join('\n'),
51
+ '',
52
+ '> See `internal://tool-catalog` for complete tool reference and cross-tool data flow.',
53
+ ].join('\n');
54
+ }
55
+ //# sourceMappingURL=workflows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflows.js","sourceRoot":"","sources":["../../src/resources/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EAsCoD,CAAC;AAE7E,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,sBAAsB;QACtB,EAAE;QACF,eAAe;QACf,EAAE;QACF,uBAAuB;QACvB,oBAAoB,EAAE;aACnB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;aACpB,IAAI,CAAC,IAAI,CAAC;QACb,EAAE;QACF,uFAAuF;KACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../src/schemas/inputs.ts"],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MAAM,oBAAoB;;kBAI0B,CAAC;AAE5D,eAAO,MAAM,uBAAuB;;;;kBAMgB,CAAC;AAErD,eAAO,MAAM,uBAAuB;;kBAIqB,CAAC;AAE1D,eAAO,MAAM,yBAAyB;;kBAQwB,CAAC;AAE/D,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;kBAmB4B,CAAC;AAEnE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;kBA0B6C,CAAC;AAE5E,eAAO,MAAM,0BAA0B;;;;;;;;kBAoB0B,CAAC;AAElE,eAAO,MAAM,2BAA2B;;;;;;;kBAS+B,CAAC;AAExE,eAAO,MAAM,6BAA6B;;;;kBAQoC,CAAC;AAE/E,eAAO,MAAM,6BAA6B;;;;kBAQoC,CAAC;AAE/E,eAAO,MAAM,sBAAsB,iCAEkB,CAAC"}
@@ -80,38 +80,53 @@ const STORE_MEMORY_SHAPE = {
80
80
  memory_type: MEMORY_TYPE_SCHEMA.optional(),
81
81
  importance: IMPORTANCE_SCHEMA.optional().prefault(0),
82
82
  };
83
- export const StoreMemoryInputSchema = z.strictObject({
83
+ export const StoreMemoryInputSchema = z
84
+ .strictObject({
84
85
  ...STORE_MEMORY_SHAPE,
85
- });
86
- export const StoreMemoryItemInputSchema = z.strictObject({
86
+ })
87
+ .describe('Input for storing a single memory');
88
+ export const StoreMemoryItemInputSchema = z
89
+ .strictObject({
87
90
  ...STORE_MEMORY_SHAPE,
88
- });
89
- export const StoreMemoriesInputSchema = z.strictObject({
91
+ })
92
+ .describe('A single memory item to store in a batch');
93
+ export const StoreMemoriesInputSchema = z
94
+ .strictObject({
90
95
  items: z
91
96
  .array(StoreMemoryItemInputSchema)
92
97
  .min(1, { error: 'At least one item is required' })
93
98
  .max(50, { error: 'Maximum 50 items per batch' })
94
99
  .describe('Memories to store (1-50 items)'),
95
- });
96
- export const GetMemoryInputSchema = z.strictObject({
100
+ })
101
+ .describe('Input for storing multiple memories atomically');
102
+ export const GetMemoryInputSchema = z
103
+ .strictObject({
97
104
  hash: HASH_SCHEMA,
98
- });
99
- export const UpdateMemoryInputSchema = z.strictObject({
105
+ })
106
+ .describe('Input for retrieving a single memory by hash');
107
+ export const UpdateMemoryInputSchema = z
108
+ .strictObject({
100
109
  hash: HASH_SCHEMA,
101
110
  content: CONTENT_SCHEMA,
102
111
  tags: TAGS_ARRAY_SCHEMA.optional(),
103
- });
104
- export const DeleteMemoryInputSchema = z.strictObject({
112
+ })
113
+ .describe('Input for updating an existing memory');
114
+ export const DeleteMemoryInputSchema = z
115
+ .strictObject({
105
116
  hash: HASH_SCHEMA,
106
- });
107
- export const DeleteMemoriesInputSchema = z.strictObject({
117
+ })
118
+ .describe('Input for deleting a single memory by hash');
119
+ export const DeleteMemoriesInputSchema = z
120
+ .strictObject({
108
121
  hashes: z
109
122
  .array(HASH_SCHEMA)
110
123
  .min(1, { error: 'At least one hash is required' })
111
124
  .max(50, { error: 'Maximum 50 hashes per batch' })
112
125
  .describe('Hashes of memories to delete (1-50 hashes)'),
113
- });
114
- export const SearchMemoriesInputSchema = z.strictObject({
126
+ })
127
+ .describe('Input for deleting multiple memories atomically');
128
+ export const SearchMemoriesInputSchema = z
129
+ .strictObject({
115
130
  query: SEARCH_QUERY_SCHEMA.describe('Search query (searches content and tags)'),
116
131
  limit: z
117
132
  .int()
@@ -124,8 +139,10 @@ export const SearchMemoriesInputSchema = z.strictObject({
124
139
  min_importance: describeImportanceFilter(SEARCH_MIN_IMPORTANCE_DESCRIPTION),
125
140
  max_importance: describeImportanceFilter(SEARCH_MAX_IMPORTANCE_DESCRIPTION),
126
141
  memory_type: MEMORY_TYPE_SCHEMA.optional().describe(SEARCH_MEMORY_TYPE_DESCRIPTION),
127
- });
128
- export const RecallInputSchema = z.strictObject({
142
+ })
143
+ .describe('Input for searching memories using full-text search');
144
+ export const RecallInputSchema = z
145
+ .strictObject({
129
146
  query: SEARCH_QUERY_SCHEMA.describe('Search query to find initial memories'),
130
147
  depth: z
131
148
  .int()
@@ -145,8 +162,10 @@ export const RecallInputSchema = z.strictObject({
145
162
  min_importance: describeImportanceFilter(RECALL_MIN_IMPORTANCE_DESCRIPTION),
146
163
  max_importance: describeImportanceFilter(RECALL_MAX_IMPORTANCE_DESCRIPTION),
147
164
  memory_type: MEMORY_TYPE_SCHEMA.optional().describe(RECALL_MEMORY_TYPE_DESCRIPTION),
148
- });
149
- export const RetrieveContextInputSchema = z.strictObject({
165
+ })
166
+ .describe('Input for exploring memory relationships via graph traversal');
167
+ export const RetrieveContextInputSchema = z
168
+ .strictObject({
150
169
  query: SEARCH_QUERY_SCHEMA.describe('Search query to find relevant memories'),
151
170
  token_budget: z
152
171
  .int()
@@ -160,24 +179,33 @@ export const RetrieveContextInputSchema = z.strictObject({
160
179
  .optional()
161
180
  .prefault('relevance')
162
181
  .describe('Sort strategy: relevance (FTS rank, default), importance (highest first), recency (newest first)'),
163
- });
164
- export const GetRelationshipsInputSchema = z.strictObject({
182
+ })
183
+ .describe('Input for retrieving context within a token budget');
184
+ export const GetRelationshipsInputSchema = z
185
+ .strictObject({
165
186
  hash: HASH_SCHEMA,
166
187
  direction: z
167
188
  .enum(['outgoing', 'incoming', 'both'])
168
189
  .optional()
169
190
  .prefault('both')
170
191
  .describe('Direction of relationships to retrieve'),
171
- });
172
- export const CreateRelationshipInputSchema = z.strictObject({
192
+ })
193
+ .describe('Input for retrieving relationships for a specific memory');
194
+ export const CreateRelationshipInputSchema = z
195
+ .strictObject({
173
196
  from_hash: HASH_SCHEMA.describe('Source memory hash'),
174
197
  to_hash: HASH_SCHEMA.describe('Target memory hash'),
175
198
  relation_type: RELATION_TYPE_SCHEMA.describe('Type of relationship (e.g. related_to, causes, depends_on)'),
176
- });
177
- export const DeleteRelationshipInputSchema = z.strictObject({
199
+ })
200
+ .describe('Input for creating a directed relationship between two memories');
201
+ export const DeleteRelationshipInputSchema = z
202
+ .strictObject({
178
203
  from_hash: HASH_SCHEMA.describe('Source memory hash'),
179
204
  to_hash: HASH_SCHEMA.describe('Target memory hash'),
180
205
  relation_type: RELATION_TYPE_SCHEMA.describe('Type of relationship to delete'),
181
- });
182
- export const MemoryStatsInputSchema = z.strictObject({});
206
+ })
207
+ .describe('Input for deleting a specific relationship between two memories');
208
+ export const MemoryStatsInputSchema = z
209
+ .strictObject({})
210
+ .describe('Input for retrieving memory statistics');
183
211
  //# sourceMappingURL=inputs.js.map