@j0hanz/memory-mcp 1.5.0 → 1.6.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.
Files changed (119) hide show
  1. package/dist/completions/index.d.ts +1 -0
  2. package/dist/completions/index.d.ts.map +1 -0
  3. package/dist/db/index.d.ts +1 -0
  4. package/dist/db/index.d.ts.map +1 -0
  5. package/dist/db/index.js +10 -8
  6. package/dist/db/typed.d.ts +1 -0
  7. package/dist/db/typed.d.ts.map +1 -0
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/lib/errors.d.ts +1 -0
  11. package/dist/lib/errors.d.ts.map +1 -0
  12. package/dist/lib/hash.d.ts +1 -0
  13. package/dist/lib/hash.d.ts.map +1 -0
  14. package/dist/lib/instructions.d.ts +1 -0
  15. package/dist/lib/instructions.d.ts.map +1 -0
  16. package/dist/lib/json-schema.d.ts +1 -0
  17. package/dist/lib/json-schema.d.ts.map +1 -0
  18. package/dist/lib/mcp-utils.d.ts +1 -0
  19. package/dist/lib/mcp-utils.d.ts.map +1 -0
  20. package/dist/lib/pagination.d.ts +1 -0
  21. package/dist/lib/pagination.d.ts.map +1 -0
  22. package/dist/lib/search-cursor.d.ts +1 -0
  23. package/dist/lib/search-cursor.d.ts.map +1 -0
  24. package/dist/lib/search.d.ts +1 -0
  25. package/dist/lib/search.d.ts.map +1 -0
  26. package/dist/lib/search.js +31 -23
  27. package/dist/lib/sql.d.ts +1 -0
  28. package/dist/lib/sql.d.ts.map +1 -0
  29. package/dist/lib/tool-contracts.d.ts +1 -0
  30. package/dist/lib/tool-contracts.d.ts.map +1 -0
  31. package/dist/lib/tool-contracts.js +65 -93
  32. package/dist/lib/tool-execution.d.ts +13 -0
  33. package/dist/lib/tool-execution.d.ts.map +1 -0
  34. package/dist/lib/tool-execution.js +28 -0
  35. package/dist/lib/tool-response.d.ts +1 -0
  36. package/dist/lib/tool-response.d.ts.map +1 -0
  37. package/dist/lib/types.d.ts +1 -0
  38. package/dist/lib/types.d.ts.map +1 -0
  39. package/dist/prompts/index.d.ts +1 -0
  40. package/dist/prompts/index.d.ts.map +1 -0
  41. package/dist/prompts/index.js +12 -8
  42. package/dist/resources/index.d.ts +1 -0
  43. package/dist/resources/index.d.ts.map +1 -0
  44. package/dist/resources/index.js +65 -38
  45. package/dist/resources/instructions.d.ts +1 -0
  46. package/dist/resources/instructions.d.ts.map +1 -0
  47. package/dist/resources/instructions.js +44 -37
  48. package/dist/resources/server-config.d.ts +1 -0
  49. package/dist/resources/server-config.d.ts.map +1 -0
  50. package/dist/resources/server-config.js +33 -22
  51. package/dist/resources/tool-catalog.d.ts +1 -0
  52. package/dist/resources/tool-catalog.d.ts.map +1 -0
  53. package/dist/resources/tool-catalog.js +10 -5
  54. package/dist/resources/tool-info.d.ts +1 -0
  55. package/dist/resources/tool-info.d.ts.map +1 -0
  56. package/dist/resources/tool-info.js +17 -8
  57. package/dist/resources/workflows.d.ts +1 -0
  58. package/dist/resources/workflows.d.ts.map +1 -0
  59. package/dist/resources/workflows.js +69 -40
  60. package/dist/schemas/index.d.ts +1 -0
  61. package/dist/schemas/index.d.ts.map +1 -0
  62. package/dist/schemas/inputs.d.ts +1 -0
  63. package/dist/schemas/inputs.d.ts.map +1 -0
  64. package/dist/schemas/inputs.js +14 -10
  65. package/dist/schemas/outputs.d.ts +7 -6
  66. package/dist/schemas/outputs.d.ts.map +1 -0
  67. package/dist/schemas/outputs.js +7 -6
  68. package/dist/server.d.ts +1 -0
  69. package/dist/server.d.ts.map +1 -0
  70. package/dist/server.js +11 -4
  71. package/dist/tools/create-relationship.d.ts +1 -0
  72. package/dist/tools/create-relationship.d.ts.map +1 -0
  73. package/dist/tools/create-relationship.js +14 -19
  74. package/dist/tools/delete-memories.d.ts +1 -0
  75. package/dist/tools/delete-memories.d.ts.map +1 -0
  76. package/dist/tools/delete-memories.js +27 -37
  77. package/dist/tools/delete-memory.d.ts +1 -0
  78. package/dist/tools/delete-memory.d.ts.map +1 -0
  79. package/dist/tools/delete-memory.js +9 -15
  80. package/dist/tools/delete-relationship.d.ts +1 -0
  81. package/dist/tools/delete-relationship.d.ts.map +1 -0
  82. package/dist/tools/delete-relationship.js +7 -12
  83. package/dist/tools/get-memory.d.ts +1 -0
  84. package/dist/tools/get-memory.d.ts.map +1 -0
  85. package/dist/tools/get-memory.js +9 -14
  86. package/dist/tools/get-relationships.d.ts +1 -0
  87. package/dist/tools/get-relationships.d.ts.map +1 -0
  88. package/dist/tools/get-relationships.js +12 -17
  89. package/dist/tools/index.d.ts +1 -0
  90. package/dist/tools/index.d.ts.map +1 -0
  91. package/dist/tools/memory-stats.d.ts +1 -0
  92. package/dist/tools/memory-stats.d.ts.map +1 -0
  93. package/dist/tools/memory-stats.js +22 -28
  94. package/dist/tools/progress.d.ts +1 -0
  95. package/dist/tools/progress.d.ts.map +1 -0
  96. package/dist/tools/progress.js +30 -23
  97. package/dist/tools/recall.d.ts +1 -0
  98. package/dist/tools/recall.d.ts.map +1 -0
  99. package/dist/tools/recall.js +77 -48
  100. package/dist/tools/register-contract.d.ts +1 -0
  101. package/dist/tools/register-contract.d.ts.map +1 -0
  102. package/dist/tools/result.d.ts +1 -0
  103. package/dist/tools/result.d.ts.map +1 -0
  104. package/dist/tools/retrieve-context.d.ts +1 -0
  105. package/dist/tools/retrieve-context.d.ts.map +1 -0
  106. package/dist/tools/retrieve-context.js +47 -33
  107. package/dist/tools/search-memories.d.ts +1 -0
  108. package/dist/tools/search-memories.d.ts.map +1 -0
  109. package/dist/tools/search-memories.js +24 -30
  110. package/dist/tools/store-memories.d.ts +1 -0
  111. package/dist/tools/store-memories.d.ts.map +1 -0
  112. package/dist/tools/store-memories.js +32 -42
  113. package/dist/tools/store-memory.d.ts +1 -0
  114. package/dist/tools/store-memory.d.ts.map +1 -0
  115. package/dist/tools/store-memory.js +12 -18
  116. package/dist/tools/update-memory.d.ts +1 -0
  117. package/dist/tools/update-memory.d.ts.map +1 -0
  118. package/dist/tools/update-memory.js +41 -46
  119. package/package.json +1 -1
@@ -44,6 +44,13 @@ function createResourceAnnotations(audience, priority) {
44
44
  function getSingleVariable(value) {
45
45
  return Array.isArray(value) ? value[0] : value;
46
46
  }
47
+ function requireValidMemoryHash(variables) {
48
+ const hash = getSingleVariable(variables['hash']);
49
+ if (!hash || !HASH_REGEX.test(hash)) {
50
+ throw new McpError(ErrorCode.InvalidParams, 'Invalid hash: must be a 64-character hex string');
51
+ }
52
+ return hash;
53
+ }
47
54
  function requireSingleVariable(variables, key, errorMessage) {
48
55
  const value = getSingleVariable(variables[key]);
49
56
  if (!value) {
@@ -51,6 +58,13 @@ function requireSingleVariable(variables, key, errorMessage) {
51
58
  }
52
59
  return value;
53
60
  }
61
+ function requireKnownToolInfo(toolName) {
62
+ const info = getToolInfo(toolName);
63
+ if (!info) {
64
+ throw new McpError(ErrorCode.InvalidParams, `Unknown tool: ${toolName}`);
65
+ }
66
+ return info;
67
+ }
54
68
  function registerStaticMarkdownResource(server, config) {
55
69
  server.registerResource(config.name, config.uri, {
56
70
  title: config.title,
@@ -90,28 +104,67 @@ const INSTRUCTIONS_CONTENT = loadInstructions();
90
104
  const TOOL_CATALOG_CONTENT = buildToolCatalog();
91
105
  const WORKFLOW_GUIDE_CONTENT = buildWorkflowGuide();
92
106
  const SERVER_CONFIG_CONTENT = buildServerConfig();
93
- // --- Registration ---
94
- export function registerAllResources(server, db) {
95
- // internal://instructions
96
- registerStaticMarkdownResource(server, {
107
+ const STATIC_RESOURCE_SEEDS = [
108
+ {
97
109
  name: 'instructions',
98
110
  uri: INSTRUCTIONS_URI,
99
111
  title: 'Memory Instructions',
100
112
  description: 'Complete usage guide: tool inventory, routing decisions, error codes, data model, and workflow patterns. Read this first.',
101
113
  audience: ['assistant'],
102
114
  priority: 0.9,
103
- content: INSTRUCTIONS_CONTENT,
104
- });
105
- // internal://tool-catalog
106
- registerStaticMarkdownResource(server, {
115
+ contentKey: 'instructions',
116
+ },
117
+ {
107
118
  name: 'tool-catalog',
108
119
  uri: TOOL_CATALOG_URI,
109
120
  title: 'Tool Catalog',
110
121
  description: 'Tool reference table, optional parameter matrix, and cross-tool data flow.',
111
122
  audience: ['assistant'],
112
123
  priority: 0.7,
113
- content: TOOL_CATALOG_CONTENT,
114
- });
124
+ contentKey: 'toolCatalog',
125
+ },
126
+ {
127
+ name: 'workflows',
128
+ uri: WORKFLOWS_URI,
129
+ title: 'Workflow Guide',
130
+ description: 'Recommended multi-step workflow sequences with guardrails and tool reference.',
131
+ audience: ['assistant'],
132
+ priority: 0.7,
133
+ contentKey: 'workflows',
134
+ },
135
+ {
136
+ name: 'server-config',
137
+ uri: SERVER_CONFIG_URI,
138
+ title: 'Server Configuration',
139
+ description: 'Runtime configuration, environment variables, capabilities, and data limits.',
140
+ audience: ['user', 'assistant'],
141
+ priority: 0.5,
142
+ contentKey: 'serverConfig',
143
+ },
144
+ ];
145
+ function resolveStaticResourceContent(contentKey) {
146
+ switch (contentKey) {
147
+ case 'instructions':
148
+ return INSTRUCTIONS_CONTENT;
149
+ case 'toolCatalog':
150
+ return TOOL_CATALOG_CONTENT;
151
+ case 'workflows':
152
+ return WORKFLOW_GUIDE_CONTENT;
153
+ case 'serverConfig':
154
+ return SERVER_CONFIG_CONTENT;
155
+ }
156
+ }
157
+ function getStaticMarkdownResources() {
158
+ return STATIC_RESOURCE_SEEDS.map((seed) => ({
159
+ ...seed,
160
+ content: resolveStaticResourceContent(seed.contentKey),
161
+ }));
162
+ }
163
+ // --- Registration ---
164
+ export function registerAllResources(server, db) {
165
+ for (const config of getStaticMarkdownResources()) {
166
+ registerStaticMarkdownResource(server, config);
167
+ }
115
168
  // internal://tool-info/{toolName}
116
169
  server.registerResource('tool-info', new ResourceTemplate(TOOL_INFO_URI_TEMPLATE, {
117
170
  list: () => listToolInfoResources(),
@@ -125,34 +178,11 @@ export function registerAllResources(server, db) {
125
178
  annotations: createResourceAnnotations(['assistant'], 0.6),
126
179
  }, (uri, variables) => {
127
180
  const toolName = requireSingleVariable(variables, 'toolName', 'Missing toolName parameter');
128
- const info = getToolInfo(toolName);
129
- if (!info) {
130
- throw new McpError(ErrorCode.InvalidParams, `Unknown tool: ${toolName}`);
131
- }
181
+ const info = requireKnownToolInfo(toolName);
132
182
  return {
133
183
  contents: [createMarkdownContent(uri.href, info)],
134
184
  };
135
185
  });
136
- // internal://workflows
137
- registerStaticMarkdownResource(server, {
138
- name: 'workflows',
139
- uri: WORKFLOWS_URI,
140
- title: 'Workflow Guide',
141
- description: 'Recommended multi-step workflow sequences with guardrails and tool reference.',
142
- audience: ['assistant'],
143
- priority: 0.7,
144
- content: WORKFLOW_GUIDE_CONTENT,
145
- });
146
- // internal://server-config
147
- registerStaticMarkdownResource(server, {
148
- name: 'server-config',
149
- uri: SERVER_CONFIG_URI,
150
- title: 'Server Configuration',
151
- description: 'Runtime configuration, environment variables, capabilities, and data limits.',
152
- audience: ['user', 'assistant'],
153
- priority: 0.5,
154
- content: SERVER_CONFIG_CONTENT,
155
- });
156
186
  // memory://memories/{hash}
157
187
  const hashCompletion = createHashCompletionCallback(db);
158
188
  server.registerResource('memory', new ResourceTemplate(MEMORY_RESOURCE_URI_TEMPLATE, {
@@ -164,10 +194,7 @@ export function registerAllResources(server, db) {
164
194
  mimeType: 'application/json',
165
195
  annotations: createResourceAnnotations(['assistant'], 0.7),
166
196
  }, (uri, variables) => {
167
- const hash = getSingleVariable(variables['hash']);
168
- if (!hash || !HASH_REGEX.test(hash)) {
169
- throw new McpError(ErrorCode.InvalidParams, 'Invalid hash: must be a 64-character hex string');
170
- }
197
+ const hash = requireValidMemoryHash(variables);
171
198
  const row = readMemoryByHash(db, hash);
172
199
  if (!row) {
173
200
  return createErrorResourceContents(uri.href, 'Not found', hash);
@@ -1 +1,2 @@
1
1
  export declare function buildServerInstructions(): string;
2
+ //# sourceMappingURL=instructions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/resources/instructions.ts"],"names":[],"mappings":"AA8HA,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD"}
@@ -63,42 +63,49 @@ function renderSharedConstraints() {
63
63
  .map((c) => `- ${c}`)
64
64
  .join('\n');
65
65
  }
66
- export function buildServerInstructions() {
66
+ function renderTaggedSection(section) {
67
+ return [`<${section.tag}>`, section.content, `</${section.tag}>`].join('\n');
68
+ }
69
+ function buildTaggedSections() {
67
70
  return [
68
- '<role>',
69
- 'Memory MCP: Persistent memory storage, full-text retrieval, and relationship graph traversal.',
70
- '</role>',
71
- '',
72
- '<capabilities>',
73
- buildToolRouting(),
74
- '</capabilities>',
75
- '',
76
- '<constraints>',
77
- renderSharedConstraints(),
78
- '</constraints>',
79
- '',
80
- '<error_codes>',
81
- ERROR_CODES.join('\n'),
82
- '</error_codes>',
83
- '',
84
- '<error_result_conventions>',
85
- ERROR_RESULT_CONVENTIONS.join('\n'),
86
- '</error_result_conventions>',
87
- '',
88
- '<data_model>',
89
- DATA_MODEL,
90
- '</data_model>',
91
- '',
92
- '<workflows>',
93
- WORKFLOWS,
94
- '</workflows>',
95
- '',
96
- '<prompts>',
97
- PROMPTS_INVENTORY.join('\n'),
98
- '</prompts>',
99
- '',
100
- '<resources>',
101
- RESOURCES_INVENTORY.join('\n'),
102
- '</resources>',
103
- ].join('\n');
71
+ {
72
+ tag: 'role',
73
+ content: 'Memory MCP: Persistent memory storage, full-text retrieval, and relationship graph traversal.',
74
+ },
75
+ {
76
+ tag: 'capabilities',
77
+ content: buildToolRouting(),
78
+ },
79
+ {
80
+ tag: 'constraints',
81
+ content: renderSharedConstraints(),
82
+ },
83
+ {
84
+ tag: 'error_codes',
85
+ content: ERROR_CODES.join('\n'),
86
+ },
87
+ {
88
+ tag: 'error_result_conventions',
89
+ content: ERROR_RESULT_CONVENTIONS.join('\n'),
90
+ },
91
+ {
92
+ tag: 'data_model',
93
+ content: DATA_MODEL,
94
+ },
95
+ {
96
+ tag: 'workflows',
97
+ content: WORKFLOWS,
98
+ },
99
+ {
100
+ tag: 'prompts',
101
+ content: PROMPTS_INVENTORY.join('\n'),
102
+ },
103
+ {
104
+ tag: 'resources',
105
+ content: RESOURCES_INVENTORY.join('\n'),
106
+ },
107
+ ];
108
+ }
109
+ export function buildServerInstructions() {
110
+ return buildTaggedSections().map(renderTaggedSection).join('\n\n');
104
111
  }
@@ -1 +1,2 @@
1
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":"AA0EA,wBAAgB,iBAAiB,IAAI,MAAM,CA2B1C"}
@@ -46,32 +46,43 @@ const CAPABILITIES = [
46
46
  function toEnvVarRow(v) {
47
47
  return `| \`${v.name}\` | ${v.default} | ${v.range} | ${v.purpose} |`;
48
48
  }
49
- function toRangeRow(label, range) {
50
- return `| ${label} | ${range} |`;
49
+ function toTwoColumnRow(label, value) {
50
+ return `| ${label} | ${value} |`;
51
51
  }
52
- export function buildServerConfig() {
53
- const envRows = ENV_VARS.map(toEnvVarRow);
54
- const limitRows = DATA_LIMITS.map((l) => toRangeRow(l.dimension, l.range));
55
- const capRows = CAPABILITIES.map((c) => toRangeRow(c.capability, c.status));
52
+ function renderTableSection(section) {
56
53
  return [
57
- '# Server Configuration',
58
- '',
59
- '## Environment Variables',
60
- '',
61
- '| Variable | Default | Range | Purpose |',
62
- '|----------|---------|-------|---------|',
63
- ...envRows,
64
- '',
65
- '## Capabilities',
54
+ `## ${section.title}`,
66
55
  '',
67
- '| Capability | Status |',
68
- '|------------|--------|',
69
- ...capRows,
56
+ section.header,
57
+ section.separator,
58
+ ...section.rows,
70
59
  '',
71
- '## Data Limits',
60
+ ];
61
+ }
62
+ export function buildServerConfig() {
63
+ const sections = [
64
+ {
65
+ title: 'Environment Variables',
66
+ header: '| Variable | Default | Range | Purpose |',
67
+ separator: '|----------|---------|-------|---------|',
68
+ rows: ENV_VARS.map(toEnvVarRow),
69
+ },
70
+ {
71
+ title: 'Capabilities',
72
+ header: '| Capability | Status |',
73
+ separator: '|------------|--------|',
74
+ rows: CAPABILITIES.map((c) => toTwoColumnRow(c.capability, c.status)),
75
+ },
76
+ {
77
+ title: 'Data Limits',
78
+ header: '| Dimension | Range |',
79
+ separator: '|-----------|-------|',
80
+ rows: DATA_LIMITS.map((l) => toTwoColumnRow(l.dimension, l.range)),
81
+ },
82
+ ];
83
+ return [
84
+ '# Server Configuration',
72
85
  '',
73
- '| Dimension | Range |',
74
- '|-----------|-------|',
75
- ...limitRows,
86
+ ...sections.flatMap(renderTableSection),
76
87
  ].join('\n');
77
88
  }
@@ -1 +1,2 @@
1
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":"AA2DA,wBAAgB,gBAAgB,IAAI,MAAM,CA0BzC"}
@@ -1,12 +1,17 @@
1
1
  import { extractJsonSchema, } from '../lib/json-schema.js';
2
2
  import { getToolContracts } from '../lib/tool-contracts.js';
3
3
  import { buildCoreContextPack } from './tool-info.js';
4
- function extractOptionalParams(toolName, schema) {
4
+ function getSchemaMeta(schema) {
5
5
  const jsonSchema = extractJsonSchema(schema);
6
- const properties = (jsonSchema['properties'] ?? {});
7
- const requiredFields = new Set(Array.isArray(jsonSchema['required'])
8
- ? jsonSchema['required']
9
- : []);
6
+ return {
7
+ properties: (jsonSchema['properties'] ?? {}),
8
+ requiredFields: new Set(Array.isArray(jsonSchema['required'])
9
+ ? jsonSchema['required']
10
+ : []),
11
+ };
12
+ }
13
+ function extractOptionalParams(toolName, schema) {
14
+ const { properties, requiredFields } = getSchemaMeta(schema);
10
15
  const rows = [];
11
16
  for (const [name, prop] of Object.entries(properties).sort(([a], [b]) => a.localeCompare(b))) {
12
17
  if (requiredFields.has(name))
@@ -2,3 +2,4 @@ export declare function getSharedConstraints(): readonly string[];
2
2
  export declare function buildCoreContextPack(): string;
3
3
  export declare function getToolInfo(name: string): string | undefined;
4
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":"AAkBA,wBAAgB,oBAAoB,IAAI,SAAS,MAAM,EAAE,CAExD;AA+BD,wBAAgB,oBAAoB,IAAI,MAAM,CAgB7C;AAqFD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAoB5D;AAED,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAIvC"}
@@ -61,6 +61,21 @@ function formatParamConstraints(prop) {
61
61
  parts.push(`enum: ${prop['enum'].join(' | ')}`);
62
62
  return parts.length > 0 ? `; ${parts.join(', ')}` : '';
63
63
  }
64
+ function getSchemaMeta(schema) {
65
+ const jsonSchema = extractJsonSchema(schema);
66
+ return {
67
+ properties: (jsonSchema['properties'] ?? {}),
68
+ requiredFields: new Set(Array.isArray(jsonSchema['required'])
69
+ ? jsonSchema['required']
70
+ : []),
71
+ };
72
+ }
73
+ function getSortedSchemaProperties(properties) {
74
+ return Object.entries(properties).sort(([a], [b]) => a.localeCompare(b));
75
+ }
76
+ function formatParamLines(meta) {
77
+ return getSortedSchemaProperties(meta.properties).map(([pName, pSchema]) => formatParam(pName, pSchema, meta.requiredFields.has(pName)));
78
+ }
64
79
  function formatParam(name, prop, required) {
65
80
  const type = typeof prop['type'] === 'string' ? prop['type'] : 'unknown';
66
81
  const desc = typeof prop['description'] === 'string' ? prop['description'] : '';
@@ -87,14 +102,8 @@ export function getToolInfo(name) {
87
102
  const contract = getToolContracts().find((c) => c.name === name);
88
103
  if (!contract)
89
104
  return undefined;
90
- const inputSchema = extractJsonSchema(contract.inputSchema);
91
- const properties = (inputSchema['properties'] ?? {});
92
- const requiredFields = new Set(Array.isArray(inputSchema['required'])
93
- ? inputSchema['required']
94
- : []);
95
- const paramLines = Object.entries(properties)
96
- .sort(([a], [b]) => a.localeCompare(b))
97
- .map(([pName, pSchema]) => formatParam(pName, pSchema, requiredFields.has(pName)));
105
+ const inputMeta = getSchemaMeta(contract.inputSchema);
106
+ const paramLines = formatParamLines(inputMeta);
98
107
  const behaviorLine = formatBehavior(contract.annotations);
99
108
  const outputShape = formatOutputShape(contract.outputSchema);
100
109
  return [
@@ -1 +1,2 @@
1
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":"AAqFA,wBAAgB,kBAAkB,IAAI,MAAM,CAW3C"}
@@ -1,53 +1,82 @@
1
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.`;
2
+ const WORKFLOW_TRACKS = [
3
+ {
4
+ title: 'Workflow A: Store and Link',
5
+ steps: [
6
+ '`store_memories({ items: [...] })` → `{ items[].hash, succeeded, failed }`',
7
+ '`create_relationship({ from_hash, to_hash, relation_type })` × N',
8
+ ],
9
+ notes: [
10
+ 'Constraint: Both endpoint memories must exist before creating a relationship.',
11
+ ],
12
+ },
13
+ {
14
+ title: 'Workflow B: Search and Read',
15
+ steps: [
16
+ '`search_memories({ query, limit })` `{ memories[], nextCursor }`',
17
+ '`get_memory({ hash })` for full detail on a specific result',
18
+ ],
19
+ notes: [
20
+ 'Or use `recall({ query, depth: 1 })` `{ memories[], graph[] }` to follow relationships.',
21
+ ],
22
+ },
23
+ {
24
+ title: 'Workflow C: Fill Context Window',
25
+ steps: [
26
+ "`retrieve_context({ query, token_budget: 4000, strategy: 'relevance' })` → `{ memories[], estimated_tokens, truncated }`",
27
+ ],
28
+ notes: [
29
+ 'Use `strategy` to control sort: `relevance` (FTS rank), `importance` (highest first), or `recency` (newest first).',
30
+ ],
31
+ },
32
+ {
33
+ title: 'Workflow D: Update a Memory',
34
+ steps: ['`update_memory({ hash, content })` → `{ old_hash, new_hash }`'],
35
+ notes: [
36
+ 'Existing relationships auto-update to new_hash via CASCADE.',
37
+ 'Returns E_CONFLICT if the new content+tags already maps to an existing hash.',
38
+ ],
39
+ },
40
+ {
41
+ title: 'Workflow E: Batch Delete',
42
+ steps: [
43
+ '`delete_memories({ hashes: [...] })` → `{ items[].{ hash, deleted }, succeeded, failed }`',
44
+ ],
45
+ notes: [
46
+ '`deleted: false` means hash not found - not an error, the batch still succeeds.',
47
+ ],
48
+ },
49
+ {
50
+ title: 'Workflow F: Explore Graph',
51
+ steps: [
52
+ '`recall({ query, depth: 2 })` → `{ memories[], graph[], depth_reached, aborted }`',
53
+ "`get_relationships({ hash, direction: 'both' })` for a specific memory's edges",
54
+ ],
55
+ notes: [
56
+ 'BFS traversal emits progress per hop. Use `depth: 0` to skip traversal.',
57
+ ],
58
+ },
59
+ ];
41
60
  function renderSharedConstraintsSection() {
42
61
  return getSharedConstraints()
43
62
  .map((c) => `- ${c}`)
44
63
  .join('\n');
45
64
  }
65
+ function renderWorkflowTrack(track) {
66
+ const stepLines = track.steps
67
+ .map((step, idx) => `${idx + 1}. ${step}`)
68
+ .join('\n');
69
+ const noteLines = track.notes.map((note) => `> ${note}`).join('\n');
70
+ return [`## ${track.title}`, '', stepLines, '', noteLines].join('\n');
71
+ }
72
+ function renderWorkflowTracks() {
73
+ return WORKFLOW_TRACKS.map(renderWorkflowTrack).join('\n\n');
74
+ }
46
75
  export function buildWorkflowGuide() {
47
76
  return [
48
77
  '# Workflow Reference',
49
78
  '',
50
- WORKFLOW_TRACKS,
79
+ renderWorkflowTracks(),
51
80
  '',
52
81
  '## Shared Constraints',
53
82
  renderSharedConstraintsSection(),
@@ -1,2 +1,3 @@
1
1
  export * from './inputs.js';
2
2
  export * from './outputs.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
@@ -118,3 +118,4 @@ export declare const DeleteRelationshipInputSchema: z.ZodObject<{
118
118
  }, z.core.$strict>;
119
119
  export declare const MemoryStatsInputSchema: z.ZodObject<{}, z.core.$strict>;
120
120
  export {};
121
+ //# sourceMappingURL=inputs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../src/schemas/inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,eAAO,MAAM,WAAW,aAMG,CAAC;AAe5B,QAAA,MAAM,kBAAkB;;;;;;;;;EAWM,CAAC;AAiB/B,eAAO,MAAM,wBAAwB,iIAU3B,CAAC;AAgEX,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;kBAID,CAAC;AAEnC,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;kBAIP,CAAC;AAEjC,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;kBAQC,CAAC;AAEvC,eAAO,MAAM,oBAAoB;;kBAIA,CAAC;AAElC,eAAO,MAAM,uBAAuB;;;;kBAMR,CAAC;AAE7B,eAAO,MAAM,uBAAuB;;kBAIA,CAAC;AAErC,eAAO,MAAM,yBAAyB;;kBAQC,CAAC;AAQxC,eAAO,MAAM,yBAAyB;oBAvFpB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;oBAC1B,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;iBAC7B,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC;;;;kBAkGzB,CAAC;AAE/B,eAAO,MAAM,iBAAiB;oBAtGZ,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;oBAC1B,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;iBAC7B,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC;;;;;kBAwHL,CAAC;AAEnD,eAAO,MAAM,0BAA0B;;;;;;;;kBAgBY,CAAC;AAEpD,eAAO,MAAM,2BAA2B;;;;;;;kBASR,CAAC;AAEjC,eAAO,MAAM,6BAA6B;;;;kBAIR,CAAC;AAEnC,eAAO,MAAM,6BAA6B;;;;kBAIR,CAAC;AAEnC,eAAO,MAAM,sBAAsB,iCAEJ,CAAC"}
@@ -67,6 +67,9 @@ const SEARCH_MEMORY_TYPE_DESCRIPTION = 'Memory type filter';
67
67
  const RECALL_MIN_IMPORTANCE_DESCRIPTION = 'Min importance filter';
68
68
  const RECALL_MAX_IMPORTANCE_DESCRIPTION = 'Max importance filter';
69
69
  const RECALL_MEMORY_TYPE_DESCRIPTION = 'Memory type filter';
70
+ function describeHash(label) {
71
+ return HASH_SCHEMA.describe(label);
72
+ }
70
73
  function describeImportanceFilter(description) {
71
74
  return IMPORTANCE_FILTER_SCHEMA.clone().describe(description);
72
75
  }
@@ -114,19 +117,19 @@ export const StoreMemoriesInputSchema = z
114
117
  .describe('Store multiple memories');
115
118
  export const GetMemoryInputSchema = z
116
119
  .strictObject({
117
- hash: HASH_SCHEMA,
120
+ hash: describeHash('SHA-256 hash'),
118
121
  })
119
122
  .describe('Get memory by hash');
120
123
  export const UpdateMemoryInputSchema = z
121
124
  .strictObject({
122
- hash: HASH_SCHEMA,
125
+ hash: describeHash('SHA-256 hash'),
123
126
  content: CONTENT_SCHEMA,
124
127
  tags: TAGS_ARRAY_SCHEMA.optional(),
125
128
  })
126
129
  .describe('Update memory');
127
130
  export const DeleteMemoryInputSchema = z
128
131
  .strictObject({
129
- hash: HASH_SCHEMA,
132
+ hash: describeHash('SHA-256 hash'),
130
133
  })
131
134
  .describe('Delete memory by hash');
132
135
  export const DeleteMemoriesInputSchema = z
@@ -138,6 +141,11 @@ export const DeleteMemoriesInputSchema = z
138
141
  .describe('Hashes to delete (1-50)'),
139
142
  })
140
143
  .describe('Delete multiple memories');
144
+ const RELATIONSHIP_ENDPOINT_FIELDS = {
145
+ from_hash: describeHash('Source hash'),
146
+ to_hash: describeHash('Target hash'),
147
+ relation_type: RELATION_TYPE_SCHEMA.describe('Relationship type'),
148
+ };
141
149
  export const SearchMemoriesInputSchema = z
142
150
  .strictObject({
143
151
  query: SEARCH_QUERY_SCHEMA.describe('Search query'),
@@ -192,7 +200,7 @@ export const RetrieveContextInputSchema = z
192
200
  .describe('Retrieve context within token budget');
193
201
  export const GetRelationshipsInputSchema = z
194
202
  .strictObject({
195
- hash: HASH_SCHEMA,
203
+ hash: describeHash('SHA-256 hash'),
196
204
  direction: z
197
205
  .enum(['outgoing', 'incoming', 'both'])
198
206
  .optional()
@@ -202,16 +210,12 @@ export const GetRelationshipsInputSchema = z
202
210
  .describe('Get relationships');
203
211
  export const CreateRelationshipInputSchema = z
204
212
  .strictObject({
205
- from_hash: HASH_SCHEMA.describe('Source hash'),
206
- to_hash: HASH_SCHEMA.describe('Target hash'),
207
- relation_type: RELATION_TYPE_SCHEMA.describe('Relationship type'),
213
+ ...RELATIONSHIP_ENDPOINT_FIELDS,
208
214
  })
209
215
  .describe('Create relationship');
210
216
  export const DeleteRelationshipInputSchema = z
211
217
  .strictObject({
212
- from_hash: HASH_SCHEMA.describe('Source hash'),
213
- to_hash: HASH_SCHEMA.describe('Target hash'),
214
- relation_type: RELATION_TYPE_SCHEMA.describe('Relationship type'),
218
+ ...RELATIONSHIP_ENDPOINT_FIELDS,
215
219
  })
216
220
  .describe('Delete relationship');
217
221
  export const MemoryStatsInputSchema = z