noteconnection 1.6.8 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/LICENSE +674 -21
  2. package/README.md +258 -64
  3. package/dist/src/agent_workspace.contract.parity.test.js +475 -0
  4. package/dist/src/agent_workspace.frontend.test.js +9989 -0
  5. package/dist/src/agent_workspace.locale.contract.test.js +95 -0
  6. package/dist/src/agent_workspace.runtime.behavior.test.js +5072 -0
  7. package/dist/src/copy.assets.contract.test.js +130 -0
  8. package/dist/src/core/PathBridge.js +28 -3
  9. package/dist/src/export/WorkspaceExportBundle.js +1130 -0
  10. package/dist/src/export/WorkspaceExportBundle.test.js +1480 -0
  11. package/dist/src/export/index.js +18 -0
  12. package/dist/src/export/types.js +2 -0
  13. package/dist/src/fixrisk.issue.verifier.contract.test.js +3 -1
  14. package/dist/src/foundation.ann.runtime.contract.test.js +81 -0
  15. package/dist/src/foundation.release.evidence.contract.test.js +406 -0
  16. package/dist/src/foundation.sqlite.runtime.contract.test.js +82 -0
  17. package/dist/src/frontend/README.md +258 -64
  18. package/dist/src/frontend/agent_workspace.js +5353 -0
  19. package/dist/src/frontend/agent_workspace_runtime.js +4434 -0
  20. package/dist/src/frontend/analysis.js +31 -4
  21. package/dist/src/frontend/app.js +3597 -141
  22. package/dist/src/frontend/focus_mode_interactions.js +33 -0
  23. package/dist/src/frontend/godot_future_path_renderer.js +540 -0
  24. package/dist/src/frontend/godot_tree_interactions.js +178 -0
  25. package/dist/src/frontend/graph_state.mjs +105 -0
  26. package/dist/src/frontend/hosted_future_path_runtime.js +157 -0
  27. package/dist/src/frontend/i18n.mjs +186 -0
  28. package/dist/src/frontend/index.html +641 -266
  29. package/dist/src/frontend/layout_gpu.js +12 -4
  30. package/dist/src/frontend/locales/en.json +721 -5
  31. package/dist/src/frontend/locales/zh.json +721 -5
  32. package/dist/src/frontend/main.mjs +60 -0
  33. package/dist/src/frontend/markdown_runtime.js +827 -0
  34. package/dist/src/frontend/notemd.css +49 -0
  35. package/dist/src/frontend/notemd.html +7 -1
  36. package/dist/src/frontend/notemd.js +64 -0
  37. package/dist/src/frontend/path.html +107 -0
  38. package/dist/src/frontend/path_app.js +2189 -150
  39. package/dist/src/frontend/path_layout.mjs +143 -0
  40. package/dist/src/frontend/path_mermaid_utils.mjs +108 -0
  41. package/dist/src/frontend/path_modules_bridge.js +486 -0
  42. package/dist/src/frontend/path_state.mjs +118 -0
  43. package/dist/src/frontend/path_styles.css +146 -0
  44. package/dist/src/frontend/path_worker_bridge.mjs +85 -0
  45. package/dist/src/frontend/reader.js +522 -27
  46. package/dist/src/frontend/runtime_bridge.js +67 -54
  47. package/dist/src/frontend/runtime_bridge.mjs +279 -0
  48. package/dist/src/frontend/settings.js +130 -12
  49. package/dist/src/frontend/simulationWorker.js +241 -6
  50. package/dist/src/frontend/source_manager.js +190 -21
  51. package/dist/src/frontend/styles.css +2853 -72
  52. package/dist/src/frontend/workbench_state.mjs +101 -0
  53. package/dist/src/frontend/workspace_panes.js +10168 -0
  54. package/dist/src/frontend.locale.contract.test.js +62 -0
  55. package/dist/src/godot.sidecar.bootstrap.contract.test.js +244 -0
  56. package/dist/src/indexing/IndexLifecycle.js +195 -0
  57. package/dist/src/indexing/IndexLifecycle.test.js +49 -0
  58. package/dist/src/indexing/SegmentBuilder.js +64 -0
  59. package/dist/src/indexing/UnitBuilder.js +48 -0
  60. package/dist/src/indexing/types.js +2 -0
  61. package/dist/src/knowledge.api.contract.test.js +170 -0
  62. package/dist/src/learning/KnowledgeLearningPlatform.js +10386 -0
  63. package/dist/src/learning/KnowledgeLearningPlatform.persistence.test.js +327 -0
  64. package/dist/src/learning/KnowledgeLearningPlatform.program-f.test.js +99 -0
  65. package/dist/src/learning/KnowledgeLearningPlatform.test.js +2971 -0
  66. package/dist/src/learning/KnowledgeWorkspaceConversationRegression.js +2974 -0
  67. package/dist/src/learning/KnowledgeWorkspaceConversationRegression.test.js +3928 -0
  68. package/dist/src/learning/answerReleaseReview.js +4319 -0
  69. package/dist/src/learning/answerReleaseReview.test.js +2888 -0
  70. package/dist/src/learning/api.js +2 -0
  71. package/dist/src/learning/conversationComposer.js +1480 -0
  72. package/dist/src/learning/conversationComposer.test.js +1817 -0
  73. package/dist/src/learning/domains/ConversationManager.js +53 -0
  74. package/dist/src/learning/domains/KnowledgeIngestor.js +238 -0
  75. package/dist/src/learning/domains/KnowledgeQuerier.js +187 -0
  76. package/dist/src/learning/domains/MasteryEngine.js +387 -0
  77. package/dist/src/learning/domains/MemoryPolicyManager.js +408 -0
  78. package/dist/src/learning/domains/QualityEvaluator.js +307 -0
  79. package/dist/src/learning/domains/TutorRouter.js +313 -0
  80. package/dist/src/learning/domains/index.js +33 -0
  81. package/dist/src/learning/domains/types.js +7 -0
  82. package/dist/src/learning/errors.js +29 -0
  83. package/dist/src/learning/evidenceContextAssembler.js +1176 -0
  84. package/dist/src/learning/evidenceContextAssembler.test.js +6332 -0
  85. package/dist/src/learning/graphContextAssembler.js +870 -0
  86. package/dist/src/learning/graphContextAssembler.test.js +1033 -0
  87. package/dist/src/learning/index.js +28 -0
  88. package/dist/src/learning/queryBackend.js +1898 -0
  89. package/dist/src/learning/queryBackend.test.js +955 -0
  90. package/dist/src/learning/ragContextPack.js +257 -0
  91. package/dist/src/learning/ragContextPack.test.js +160 -0
  92. package/dist/src/learning/ragPublicText.js +38 -0
  93. package/dist/src/learning/ragSufficiencyJudge.js +161 -0
  94. package/dist/src/learning/ragSufficiencyJudge.test.js +177 -0
  95. package/dist/src/learning/ragSufficiencyProviderJudge.js +227 -0
  96. package/dist/src/learning/ragSufficiencyProviderJudge.test.js +156 -0
  97. package/dist/src/learning/requestNormalization.js +198 -0
  98. package/dist/src/learning/runtimeCapability.js +4677 -0
  99. package/dist/src/learning/runtimeCapability.test.js +3635 -0
  100. package/dist/src/learning/store.js +1240 -0
  101. package/dist/src/learning/store.test.js +1126 -0
  102. package/dist/src/learning/tutorAdapter.js +2 -0
  103. package/dist/src/learning/types.js +2 -0
  104. package/dist/src/learning/vectorAccelerationAdapter.js +942 -0
  105. package/dist/src/learning/vectorAccelerationAdapter.test.js +382 -0
  106. package/dist/src/lfs.asset.policy.contract.test.js +153 -0
  107. package/dist/src/license.policy.contract.test.js +66 -0
  108. package/dist/src/memory/MemoryGovernance.js +74 -0
  109. package/dist/src/memory/MemoryGovernance.test.js +46 -0
  110. package/dist/src/memory/types.js +2 -0
  111. package/dist/src/mermaid.frontend.guard.contract.test.js +77 -0
  112. package/dist/src/middleware/auth.js +17 -0
  113. package/dist/src/middleware/body-parser.js +45 -0
  114. package/dist/src/middleware/cors.js +44 -0
  115. package/dist/src/middleware/index.js +21 -0
  116. package/dist/src/middleware/request-trace.js +96 -0
  117. package/dist/src/notemd/AppConfigToml.js +6 -4
  118. package/dist/src/notemd/MermaidProcessor.js +400 -50
  119. package/dist/src/notemd/NotemdService.js +498 -13
  120. package/dist/src/notemd/PromptManager.js +15 -0
  121. package/dist/src/notemd/cli/commands.js +357 -0
  122. package/dist/src/notemd/cli/dispatcher.js +225 -0
  123. package/dist/src/notemd/cli/index.js +169 -0
  124. package/dist/src/notemd/cli/parser.js +68 -0
  125. package/dist/src/notemd/cli/types.js +2 -0
  126. package/dist/src/notemd/constants.js +43 -0
  127. package/dist/src/notemd/diagram/diagramGenerationService.js +78 -0
  128. package/dist/src/notemd/diagram/diagramSpec.js +79 -0
  129. package/dist/src/notemd/diagram/diagramSpecResponseParser.js +131 -0
  130. package/dist/src/notemd/diagram/intent.js +95 -0
  131. package/dist/src/notemd/diagram/planner.js +71 -0
  132. package/dist/src/notemd/diagram/prompts/diagramSpecPrompt.js +42 -0
  133. package/dist/src/notemd/diagram/types.js +18 -0
  134. package/dist/src/notemd/index.js +26 -0
  135. package/dist/src/notemd/operations/capabilityManifest.js +23 -0
  136. package/dist/src/notemd/operations/cliContracts.js +17 -0
  137. package/dist/src/notemd/operations/configProfileCommands.js +85 -0
  138. package/dist/src/notemd/operations/registry.contract.test.js +95 -0
  139. package/dist/src/notemd/operations/registry.js +991 -0
  140. package/dist/src/notemd/operations/types.js +2 -0
  141. package/dist/src/notemd/providerDiagnostics.js +220 -0
  142. package/dist/src/notemd/providerProfiles.js +42 -0
  143. package/dist/src/notemd/providerTemplates.js +231 -0
  144. package/dist/src/notemd/search/DuckDuckGoProvider.js +39 -0
  145. package/dist/src/notemd/search/SearchManager.js +13 -0
  146. package/dist/src/notemd/search/SearchProvider.js +2 -0
  147. package/dist/src/notemd/search/TavilyProvider.js +44 -0
  148. package/dist/src/notemd.agent.manifest.test.js +85 -0
  149. package/dist/src/notemd.api.contract.test.js +14 -1
  150. package/dist/src/notemd.app_config_toml.test.js +2 -1
  151. package/dist/src/notemd.batch.workflow.test.js +117 -0
  152. package/dist/src/notemd.cli.e2e.test.js +136 -0
  153. package/dist/src/notemd.core.test.js +51 -0
  154. package/dist/src/notemd.diagram.pipeline.test.js +233 -0
  155. package/dist/src/notemd.providerTemplates.test.js +34 -0
  156. package/dist/src/notemd.server.integration.test.js +143 -35
  157. package/dist/src/notemd.workflow.pipeline.test.js +162 -0
  158. package/dist/src/pathbridge.handshake.contract.test.js +16 -2
  159. package/dist/src/pathmode.background.contract.test.js +69 -0
  160. package/dist/src/pathmode.settings.api.contract.test.js +9 -0
  161. package/dist/src/pkg.sidecar.contract.test.js +9 -3
  162. package/dist/src/platform/ExportProfile.js +58 -0
  163. package/dist/src/platform/PlatformCapabilities.js +45 -0
  164. package/dist/src/platform/PlatformCapabilities.test.js +30 -0
  165. package/dist/src/platform/RenderMaterializer.js +33 -0
  166. package/dist/src/platform/RenderMaterializer.test.js +32 -0
  167. package/dist/src/query_backend.external_http.integration.test.js +410 -0
  168. package/dist/src/reader_renderer.js +404 -3
  169. package/dist/src/reader_renderer.test.js +87 -0
  170. package/dist/src/release.godot.mirror.contract.test.js +73 -0
  171. package/dist/src/resources/ResourceRegistry.js +223 -0
  172. package/dist/src/resources/ResourceRegistry.test.js +61 -0
  173. package/dist/src/resources/types.js +2 -0
  174. package/dist/src/routes/agentWorkspaceDiagnostics.js +173 -0
  175. package/dist/src/routes/data.js +267 -0
  176. package/dist/src/routes/diagnostics.js +51 -0
  177. package/dist/src/routes/index.js +23 -0
  178. package/dist/src/routes/knowledge.js +968 -0
  179. package/dist/src/routes/markdown.js +287 -0
  180. package/dist/src/routes/notemd.js +565 -0
  181. package/dist/src/routes/registry.contract.test.js +130 -0
  182. package/dist/src/routes/render.js +285 -0
  183. package/dist/src/routes/runtimeRunbookRouteOps.js +149 -0
  184. package/dist/src/routes/runtimeRunbookRouteOps.test.js +194 -0
  185. package/dist/src/routes/settings.js +6 -0
  186. package/dist/src/routes/staticFiles.js +94 -0
  187. package/dist/src/routes/types.js +2 -0
  188. package/dist/src/runtime.transport.adapter.contract.test.js +81 -0
  189. package/dist/src/server.js +11090 -1549
  190. package/dist/src/server.migration.test.js +193 -21
  191. package/dist/src/server.port.fallback.contract.test.js +63 -0
  192. package/dist/src/session/SessionStateStore.js +81 -0
  193. package/dist/src/session/SessionStateStore.test.js +58 -0
  194. package/dist/src/session/types.js +2 -0
  195. package/dist/src/settings.runtime.contract.test.js +50 -0
  196. package/dist/src/shared/types.contract.test.js +107 -0
  197. package/dist/src/shared/types.js +22 -0
  198. package/dist/src/sidecar.replacement.boundary.contract.test.js +128 -0
  199. package/dist/src/sidecar.supply.readiness.contract.test.js +144 -0
  200. package/dist/src/source_manager.loadflow.test.js +46 -0
  201. package/dist/src/startup.layout.snapshot.contract.test.js +57 -0
  202. package/dist/src/tauri.frontend.build.contract.test.js +60 -0
  203. package/dist/src/tauri.sidecar.cleanup.contract.test.js +21 -0
  204. package/dist/src/utils/RuntimePaths.js +4 -13
  205. package/dist/src/utils/platform.js +153 -0
  206. package/dist/src/workflows/WorkflowArtifactStore.js +96 -0
  207. package/dist/src/workflows/WorkflowArtifactStore.test.js +80 -0
  208. package/dist/src/workflows/types.js +2 -0
  209. package/dist/src/workspace/WorkspaceRegistry.js +122 -0
  210. package/dist/src/workspace/WorkspaceRegistry.test.js +29 -0
  211. package/dist/src/workspace/types.js +2 -0
  212. package/package.json +61 -10
@@ -0,0 +1,565 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.registerNotemdRoutes = registerNotemdRoutes;
37
+ const CrashLogger_1 = require("../backend/utils/CrashLogger");
38
+ const capabilityManifest_1 = require("../notemd/operations/capabilityManifest");
39
+ const cliContracts_1 = require("../notemd/operations/cliContracts");
40
+ const registry_1 = require("../notemd/operations/registry");
41
+ function registerNotemdRoutes(ctx) {
42
+ const { notemdService, loadNotemdSettings, persistNotemdSettings } = ctx;
43
+ const api = (path) => `/api/notemd${path}`;
44
+ const json = (res, code, data) => {
45
+ res.writeHead(code, { 'Content-Type': 'application/json' });
46
+ res.end(JSON.stringify(data));
47
+ };
48
+ const ok = (res, data) => json(res, 200, { success: true, ...data });
49
+ const fail = (res, error, label) => {
50
+ console.error(error);
51
+ CrashLogger_1.CrashLogger.log(error, label);
52
+ json(res, 500, { success: false, error: String(error) });
53
+ };
54
+ const readBody = (req) => new Promise((resolve, reject) => {
55
+ const chunks = [];
56
+ req.on('data', (c) => chunks.push(c));
57
+ req.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
58
+ req.on('error', reject);
59
+ });
60
+ return [
61
+ {
62
+ method: 'GET',
63
+ path: api('/settings'),
64
+ handler: async (_req, res) => {
65
+ try {
66
+ const settings = await loadNotemdSettings();
67
+ ok(res, { settings });
68
+ }
69
+ catch (e) {
70
+ fail(res, e, 'API:GET /api/notemd/settings');
71
+ }
72
+ },
73
+ },
74
+ {
75
+ method: 'POST',
76
+ path: api('/settings'),
77
+ handler: async (req, res) => {
78
+ try {
79
+ const body = await readBody(req);
80
+ const payload = JSON.parse(body);
81
+ const nextSettings = payload && typeof payload === 'object' && payload.settings !== undefined
82
+ ? payload.settings
83
+ : payload;
84
+ const settings = persistNotemdSettings
85
+ ? await persistNotemdSettings(nextSettings)
86
+ : await notemdService.updateSettings(payload);
87
+ ok(res, { settings });
88
+ }
89
+ catch (e) {
90
+ fail(res, e, 'API:POST /api/notemd/settings');
91
+ }
92
+ },
93
+ },
94
+ {
95
+ method: 'POST',
96
+ path: api('/test-llm'),
97
+ handler: async (req, res) => {
98
+ try {
99
+ const body = await readBody(req);
100
+ const settings = await loadNotemdSettings();
101
+ const result = await notemdService.testLlmConnection(JSON.parse(body), settings);
102
+ ok(res, { result });
103
+ }
104
+ catch (e) {
105
+ fail(res, e, 'API:POST /api/notemd/test-llm');
106
+ }
107
+ },
108
+ },
109
+ {
110
+ method: 'POST',
111
+ path: api('/process-file'),
112
+ handler: async (req, res) => {
113
+ try {
114
+ const body = await readBody(req);
115
+ const settings = await loadNotemdSettings();
116
+ const result = await notemdService.processFile(JSON.parse(body), settings);
117
+ ok(res, { result });
118
+ }
119
+ catch (e) {
120
+ fail(res, e, 'API:POST /api/notemd/process-file');
121
+ }
122
+ },
123
+ },
124
+ {
125
+ method: 'POST',
126
+ path: api('/process-folder'),
127
+ handler: async (req, res) => {
128
+ try {
129
+ const body = await readBody(req);
130
+ const settings = await loadNotemdSettings();
131
+ const result = await notemdService.processFolder(JSON.parse(body), settings);
132
+ ok(res, { result });
133
+ }
134
+ catch (e) {
135
+ fail(res, e, 'API:POST /api/notemd/process-folder');
136
+ }
137
+ },
138
+ },
139
+ {
140
+ method: 'POST',
141
+ path: api('/generate-content'),
142
+ handler: async (req, res) => {
143
+ try {
144
+ const body = await readBody(req);
145
+ const settings = await loadNotemdSettings();
146
+ const result = await notemdService.generateContent(JSON.parse(body), settings);
147
+ ok(res, { result });
148
+ }
149
+ catch (e) {
150
+ fail(res, e, 'API:POST /api/notemd/generate-content');
151
+ }
152
+ },
153
+ },
154
+ {
155
+ method: 'POST',
156
+ path: api('/translate-file'),
157
+ handler: async (req, res) => {
158
+ try {
159
+ const body = await readBody(req);
160
+ const settings = await loadNotemdSettings();
161
+ const result = await notemdService.translateFile(JSON.parse(body), settings);
162
+ ok(res, { result });
163
+ }
164
+ catch (e) {
165
+ fail(res, e, 'API:POST /api/notemd/translate-file');
166
+ }
167
+ },
168
+ },
169
+ {
170
+ method: 'POST',
171
+ path: api('/fix-mermaid'),
172
+ handler: async (req, res) => {
173
+ try {
174
+ const raw = await readBody(req);
175
+ const { filePath, inPlace } = JSON.parse(raw);
176
+ const result = await notemdService.fixMermaid(filePath, inPlace);
177
+ ok(res, { result });
178
+ }
179
+ catch (e) {
180
+ fail(res, e, 'API:POST /api/notemd/fix-mermaid');
181
+ }
182
+ },
183
+ },
184
+ {
185
+ method: 'POST',
186
+ path: api('/fix-formulas'),
187
+ handler: async (req, res) => {
188
+ try {
189
+ const raw = await readBody(req);
190
+ const { filePath, inPlace } = JSON.parse(raw);
191
+ const result = await notemdService.fixFormulas(filePath, inPlace);
192
+ ok(res, { result });
193
+ }
194
+ catch (e) {
195
+ fail(res, e, 'API:POST /api/notemd/fix-formulas');
196
+ }
197
+ },
198
+ },
199
+ {
200
+ method: 'POST',
201
+ path: api('/check-duplicates'),
202
+ handler: async (req, res) => {
203
+ try {
204
+ const raw = await readBody(req);
205
+ const { filePath } = JSON.parse(raw);
206
+ const result = await notemdService.checkDuplicates(filePath);
207
+ ok(res, { result });
208
+ }
209
+ catch (e) {
210
+ fail(res, e, 'API:POST /api/notemd/check-duplicates');
211
+ }
212
+ },
213
+ },
214
+ {
215
+ method: 'POST',
216
+ path: api('/extract-concepts'),
217
+ handler: async (req, res) => {
218
+ try {
219
+ const raw = await readBody(req);
220
+ const settings = await loadNotemdSettings();
221
+ const { filePath } = JSON.parse(raw);
222
+ const result = await notemdService.extractConcepts(filePath, settings);
223
+ ok(res, { result });
224
+ }
225
+ catch (e) {
226
+ fail(res, e, 'API:POST /api/notemd/extract-concepts');
227
+ }
228
+ },
229
+ },
230
+ {
231
+ method: 'POST',
232
+ path: api('/cancel'),
233
+ handler: async (_req, res) => {
234
+ try {
235
+ notemdService.cancelCurrentOperation();
236
+ ok(res, { cancelled: true });
237
+ }
238
+ catch (e) {
239
+ fail(res, e, 'API:POST /api/notemd/cancel');
240
+ }
241
+ },
242
+ },
243
+ // ── Diagram generation (obsidian-notemd v1.8.4) ──
244
+ {
245
+ method: 'POST',
246
+ path: api('/generate-diagram'),
247
+ handler: async (req, res) => {
248
+ try {
249
+ const body = await readBody(req);
250
+ const settings = await loadNotemdSettings();
251
+ const result = await notemdService.generateDiagram(JSON.parse(body), settings);
252
+ ok(res, { result });
253
+ }
254
+ catch (e) {
255
+ fail(res, e, 'API:POST /api/notemd/generate-diagram');
256
+ }
257
+ },
258
+ },
259
+ {
260
+ method: 'POST',
261
+ path: api('/preview-diagram'),
262
+ handler: async (req, res) => {
263
+ try {
264
+ const body = await readBody(req);
265
+ const settings = await loadNotemdSettings();
266
+ const result = await notemdService.previewDiagram(JSON.parse(body), settings);
267
+ ok(res, { result });
268
+ }
269
+ catch (e) {
270
+ fail(res, e, 'API:POST /api/notemd/preview-diagram');
271
+ }
272
+ },
273
+ },
274
+ {
275
+ method: 'POST',
276
+ path: api('/export-diagram'),
277
+ handler: async (req, res) => {
278
+ try {
279
+ const body = await readBody(req);
280
+ const settings = await loadNotemdSettings();
281
+ const result = await notemdService.exportDiagram(JSON.parse(body), settings);
282
+ ok(res, { result });
283
+ }
284
+ catch (e) {
285
+ fail(res, e, 'API:POST /api/notemd/export-diagram');
286
+ }
287
+ },
288
+ },
289
+ // ── Web search (obsidian-notemd v1.8.4) ──
290
+ {
291
+ method: 'POST',
292
+ path: api('/search'),
293
+ handler: async (req, res) => {
294
+ try {
295
+ const body = await readBody(req);
296
+ const settings = await loadNotemdSettings();
297
+ const result = await notemdService.search(JSON.parse(body), settings);
298
+ ok(res, { result });
299
+ }
300
+ catch (e) {
301
+ fail(res, e, 'API:POST /api/notemd/search');
302
+ }
303
+ },
304
+ },
305
+ // ── Batch progress query (obsidian-notemd v1.8.4) ──
306
+ {
307
+ method: 'GET',
308
+ path: api('/progress'),
309
+ handler: async (_req, res) => {
310
+ try {
311
+ const progress = await notemdService.getBatchProgress();
312
+ ok(res, { progress });
313
+ }
314
+ catch (e) {
315
+ fail(res, e, 'API:GET /api/notemd/progress');
316
+ }
317
+ },
318
+ },
319
+ // ── LLM provider diagnostics (obsidian-notemd v1.8.4) ──
320
+ {
321
+ method: 'POST',
322
+ path: api('/diagnose-llm'),
323
+ handler: async (req, res) => {
324
+ try {
325
+ const body = await readBody(req);
326
+ const result = await notemdService.diagnoseLlmProvider(JSON.parse(body));
327
+ ok(res, { result });
328
+ }
329
+ catch (e) {
330
+ fail(res, e, 'API:POST /api/notemd/diagnose-llm');
331
+ }
332
+ },
333
+ },
334
+ // ── Extract original text (obsidian-notemd v1.8.4) ──
335
+ {
336
+ method: 'POST',
337
+ path: api('/extract-original-text'),
338
+ handler: async (req, res) => {
339
+ try {
340
+ const body = await readBody(req);
341
+ const settings = await loadNotemdSettings();
342
+ const result = await notemdService.extractOriginalText(JSON.parse(body), settings);
343
+ ok(res, { result });
344
+ }
345
+ catch (e) {
346
+ fail(res, e, 'API:POST /api/notemd/extract-original-text');
347
+ }
348
+ },
349
+ },
350
+ // ── CLI operations registry ──
351
+ {
352
+ method: 'GET',
353
+ path: api('/capability-manifest'),
354
+ handler: async (_req, res) => {
355
+ try {
356
+ const manifest = (0, capabilityManifest_1.buildCliCapabilityManifest)('notemd');
357
+ ok(res, { manifest });
358
+ }
359
+ catch (e) {
360
+ fail(res, e, 'API:GET /api/notemd/capability-manifest');
361
+ }
362
+ },
363
+ },
364
+ {
365
+ method: 'GET',
366
+ path: api('/invocation-contract'),
367
+ handler: async (_req, res) => {
368
+ try {
369
+ const contract = (0, cliContracts_1.buildCliInvocationContract)();
370
+ ok(res, { contract });
371
+ }
372
+ catch (e) {
373
+ fail(res, e, 'API:GET /api/notemd/invocation-contract');
374
+ }
375
+ },
376
+ },
377
+ {
378
+ method: 'POST',
379
+ path: api('/provider-diagnostic'),
380
+ handler: async (req, res) => {
381
+ try {
382
+ const body = await readBody(req);
383
+ const settings = await loadNotemdSettings();
384
+ const result = await notemdService.diagnoseLlmProvider(JSON.parse(body), settings);
385
+ ok(res, { result });
386
+ }
387
+ catch (e) {
388
+ fail(res, e, 'API:POST /api/notemd/provider-diagnostic');
389
+ }
390
+ },
391
+ },
392
+ {
393
+ method: 'POST',
394
+ path: api('/one-click-extract'),
395
+ handler: async (req, res) => {
396
+ try {
397
+ const body = await readBody(req);
398
+ const settings = await loadNotemdSettings();
399
+ const result = await notemdService.oneClickExtract(JSON.parse(body).filePath, settings);
400
+ ok(res, { result });
401
+ }
402
+ catch (e) {
403
+ fail(res, e, 'API:POST /api/notemd/one-click-extract');
404
+ }
405
+ },
406
+ },
407
+ {
408
+ method: 'POST',
409
+ path: api('/batch-fix-mermaid'),
410
+ handler: async (req, res) => {
411
+ try {
412
+ const raw = await readBody(req);
413
+ const { folderPath, inPlace } = JSON.parse(raw);
414
+ const result = await notemdService.batchFixMermaid(folderPath, inPlace ?? true);
415
+ ok(res, { result });
416
+ }
417
+ catch (e) {
418
+ fail(res, e, 'API:POST /api/notemd/batch-fix-mermaid');
419
+ }
420
+ },
421
+ },
422
+ {
423
+ method: 'POST',
424
+ path: api('/batch-fix-formulas'),
425
+ handler: async (req, res) => {
426
+ try {
427
+ const raw = await readBody(req);
428
+ const { folderPath, inPlace } = JSON.parse(raw);
429
+ const result = await notemdService.batchFixFormulas(folderPath, inPlace ?? true);
430
+ ok(res, { result });
431
+ }
432
+ catch (e) {
433
+ fail(res, e, 'API:POST /api/notemd/batch-fix-formulas');
434
+ }
435
+ },
436
+ },
437
+ {
438
+ method: 'POST',
439
+ path: api('/batch-generate-content'),
440
+ handler: async (req, res) => {
441
+ try {
442
+ const raw = await readBody(req);
443
+ const { folderPath } = JSON.parse(raw);
444
+ const settings = await loadNotemdSettings();
445
+ const result = await notemdService.generateFolderContent(folderPath, settings);
446
+ ok(res, { result });
447
+ }
448
+ catch (e) {
449
+ fail(res, e, 'API:POST /api/notemd/batch-generate-content');
450
+ }
451
+ },
452
+ },
453
+ {
454
+ method: 'POST',
455
+ path: api('/batch-progress'),
456
+ handler: async (req, res) => {
457
+ try {
458
+ const raw = await readBody(req);
459
+ const { operationId } = JSON.parse(raw);
460
+ const result = await notemdService.getBatchProgress(operationId);
461
+ ok(res, { progress: result });
462
+ }
463
+ catch (e) {
464
+ fail(res, e, 'API:POST /api/notemd/batch-progress');
465
+ }
466
+ },
467
+ },
468
+ // ── Workflow pipeline (NoteConnection native) ──
469
+ {
470
+ method: 'POST',
471
+ path: api('/workflow'),
472
+ handler: async (req, res) => {
473
+ try {
474
+ const raw = await readBody(req);
475
+ const settings = await loadNotemdSettings();
476
+ const request = JSON.parse(raw);
477
+ const result = await notemdService.runWorkflow(request, settings);
478
+ ok(res, { result });
479
+ }
480
+ catch (e) {
481
+ fail(res, e, 'API:POST /api/notemd/workflow');
482
+ }
483
+ },
484
+ },
485
+ {
486
+ method: 'POST',
487
+ path: api('/batch-workflow'),
488
+ handler: async (req, res) => {
489
+ try {
490
+ const raw = await readBody(req);
491
+ const settings = await loadNotemdSettings();
492
+ const request = JSON.parse(raw);
493
+ const result = await notemdService.runBatchWorkflow(request, settings);
494
+ ok(res, { result });
495
+ }
496
+ catch (e) {
497
+ fail(res, e, 'API:POST /api/notemd/batch-workflow');
498
+ }
499
+ },
500
+ },
501
+ {
502
+ method: 'POST',
503
+ path: api('/provider-profiles/export'),
504
+ handler: async (req, res) => {
505
+ try {
506
+ const settings = await loadNotemdSettings();
507
+ const { buildProviderProfileExport } = await Promise.resolve().then(() => __importStar(require('../notemd/providerProfiles')));
508
+ const profile = buildProviderProfileExport(settings.providers);
509
+ ok(res, { profile });
510
+ }
511
+ catch (e) {
512
+ fail(res, e, 'API:POST /api/notemd/provider-profiles/export');
513
+ }
514
+ },
515
+ },
516
+ // ── Agent Workspace Bridge (Phase 4 P3) ──
517
+ {
518
+ method: 'GET',
519
+ path: api('/agent-manifest'),
520
+ handler: async (_req, res) => {
521
+ try {
522
+ const defs = (0, registry_1.listOperationDefinitions)();
523
+ const operations = defs.map(def => ({
524
+ operationId: def.id,
525
+ description: def.commandBindings[0]?.commandId ?? def.id,
526
+ automationLevel: def.automationLevel,
527
+ requiredContext: def.requiredContext,
528
+ sideEffectClass: def.sideEffectClass,
529
+ agentAutoExecutable: def.automationLevel === 'safe',
530
+ requiredParams: def.inputSchema
531
+ ? def.inputSchema.required ?? []
532
+ : [],
533
+ }));
534
+ const manifest = {
535
+ version: 1,
536
+ generatedAt: new Date().toISOString(),
537
+ totalOperations: operations.length,
538
+ agentExecutableCount: operations.filter(o => o.agentAutoExecutable).length,
539
+ operations,
540
+ };
541
+ ok(res, { manifest });
542
+ }
543
+ catch (e) {
544
+ fail(res, e, 'API:GET /api/notemd/agent-manifest');
545
+ }
546
+ },
547
+ },
548
+ {
549
+ method: 'POST',
550
+ path: api('/provider-profiles/import'),
551
+ handler: async (req, res) => {
552
+ try {
553
+ const body = await readBody(req);
554
+ const settings = await loadNotemdSettings();
555
+ const { parseProviderProfileImport } = await Promise.resolve().then(() => __importStar(require('../notemd/providerProfiles')));
556
+ const result = parseProviderProfileImport(body, settings.providers);
557
+ ok(res, { result });
558
+ }
559
+ catch (e) {
560
+ fail(res, e, 'API:POST /api/notemd/provider-profiles/import');
561
+ }
562
+ },
563
+ },
564
+ ];
565
+ }
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Route Registry Contract Tests
5
+ * Verifies the modular route registration and dispatch infrastructure.
6
+ */
7
+ const index_1 = require("./index");
8
+ function createMockContext() {
9
+ const scheduleKnowledgeLearningPlatformWarmup = jest.fn();
10
+ return {
11
+ knowledgeLearningPlatform: {
12
+ getKnowledgeState: async () => ({ documents: 0 })
13
+ },
14
+ scheduleKnowledgeLearningPlatformWarmup,
15
+ knowledgeIngestor: { ingestKnowledge: async () => ({}), averageIngestLatencyMs: () => 0, getDiagnostics: () => ({}) },
16
+ knowledgeQuerier: { queryKnowledge: async () => ({}), getDiagnosticsSummary: () => ({}) },
17
+ conversationManager: { getDiagnosticsSummary: () => ({}) },
18
+ masteryEngine: { getDiagnosticsSummary: () => ({}) },
19
+ qualityEvaluator: { getDiagnosticsSummary: () => ({}) },
20
+ tutorRouter: { getDiagnosticsSummary: () => ({}) },
21
+ memoryPolicyManager: { getDiagnosticsSummary: () => ({}) },
22
+ notemdService: {},
23
+ loadNotemdSettings: async () => ({}),
24
+ LOOPBACK_HOST: '127.0.0.1',
25
+ finalPort: 3000,
26
+ KNOWLEDGE_GRAPH_STORE_BACKEND: 'file',
27
+ KNOWLEDGE_GRAPHDB_ADAPTER_PROVIDER: 'none',
28
+ KNOWLEDGE_GRAPHDB_ADAPTER_ID: '',
29
+ KNOWLEDGE_GRAPHDB_FALLBACK_ENABLED: false,
30
+ KNOWLEDGE_GRAPHDB_OPERATION_MODE: 'read_write',
31
+ kbRoot: '/tmp/test-kb',
32
+ runtimeDataDir: '/tmp/test-runtime-data',
33
+ };
34
+ }
35
+ describe('Route Registry', () => {
36
+ const ctx = createMockContext();
37
+ const routes = (0, index_1.registerAllRoutes)(ctx);
38
+ test('registers all route groups', () => {
39
+ expect(routes.length).toBeGreaterThanOrEqual(70);
40
+ });
41
+ test('every route has required fields', () => {
42
+ for (const route of routes) {
43
+ expect(route.method).toMatch(/^(GET|POST|PUT|DELETE)$/);
44
+ expect(route.path).toBeTruthy();
45
+ expect(typeof route.handler).toBe('function');
46
+ }
47
+ });
48
+ test('knowledge routes are registered', () => {
49
+ const knowledgeRoutes = routes.filter(r => r.path.startsWith('/api/knowledge'));
50
+ expect(knowledgeRoutes.length).toBeGreaterThanOrEqual(30);
51
+ // Verify key endpoints exist
52
+ const paths = new Set(knowledgeRoutes.map(r => `${r.method} ${r.path}`));
53
+ expect(paths.has('GET /api/knowledge/state')).toBe(true);
54
+ expect(paths.has('GET /api/knowledge/workflow-artifacts')).toBe(true);
55
+ expect(paths.has('POST /api/knowledge/workflow-artifacts/review-follow-up')).toBe(true);
56
+ expect(paths.has('POST /api/knowledge/ingest')).toBe(true);
57
+ expect(paths.has('POST /api/knowledge/query')).toBe(true);
58
+ expect(paths.has('POST /api/knowledge/export/workspace')).toBe(true);
59
+ expect(paths.has('POST /api/knowledge/session/graph-focus-diagnostics')).toBe(true);
60
+ expect(paths.has('POST /api/knowledge/conversation')).toBe(false);
61
+ });
62
+ test('notemd routes are registered', () => {
63
+ const notemdRoutes = routes.filter(r => r.path.startsWith('/api/notemd'));
64
+ expect(notemdRoutes.length).toBeGreaterThanOrEqual(10);
65
+ const paths = new Set(notemdRoutes.map(r => `${r.method} ${r.path}`));
66
+ expect(paths.has('GET /api/notemd/settings')).toBe(true);
67
+ expect(paths.has('POST /api/notemd/process-file')).toBe(true);
68
+ });
69
+ test('render routes are registered', () => {
70
+ const renderRoutes = routes.filter(r => r.path.startsWith('/api/render') || r.path.startsWith('/api/clipboard'));
71
+ expect(renderRoutes.length).toBeGreaterThanOrEqual(4);
72
+ });
73
+ test('no duplicate method+path combinations', () => {
74
+ const seen = new Set();
75
+ for (const route of routes) {
76
+ const key = `${route.method} ${route.path}`;
77
+ expect(seen.has(key)).toBe(false);
78
+ seen.add(key);
79
+ }
80
+ });
81
+ test('all GET routes have idempotent paths', () => {
82
+ const getRoutes = routes.filter(r => r.method === 'GET');
83
+ for (const route of getRoutes) {
84
+ expect(route.path).toMatch(/^\/api\//);
85
+ }
86
+ });
87
+ test('domain diagnostics are exposed via context', () => {
88
+ // All 7 domain classes are available through ServerContext
89
+ expect(ctx.knowledgeIngestor).toBeDefined();
90
+ expect(ctx.knowledgeQuerier).toBeDefined();
91
+ expect(ctx.conversationManager).toBeDefined();
92
+ expect(ctx.masteryEngine).toBeDefined();
93
+ expect(ctx.qualityEvaluator).toBeDefined();
94
+ expect(ctx.tutorRouter).toBeDefined();
95
+ expect(ctx.memoryPolicyManager).toBeDefined();
96
+ });
97
+ test('domain diagnostics have required methods', () => {
98
+ expect(typeof ctx.knowledgeIngestor.getDiagnostics).toBe('function');
99
+ expect(typeof ctx.knowledgeQuerier.getDiagnosticsSummary).toBe('function');
100
+ expect(typeof ctx.conversationManager.getDiagnosticsSummary).toBe('function');
101
+ expect(typeof ctx.masteryEngine.getDiagnosticsSummary).toBe('function');
102
+ expect(typeof ctx.qualityEvaluator.getDiagnosticsSummary).toBe('function');
103
+ expect(typeof ctx.tutorRouter.getDiagnosticsSummary).toBe('function');
104
+ expect(typeof ctx.memoryPolicyManager.getDiagnosticsSummary).toBe('function');
105
+ });
106
+ test('knowledge routes can be dispatched', async () => {
107
+ const stateRoute = routes.find(r => r.method === 'GET' && r.path === '/api/knowledge/state');
108
+ expect(stateRoute).toBeDefined();
109
+ // Mock request/response
110
+ const mockRes = {
111
+ _statusCode: 0,
112
+ _headers: {},
113
+ _body: '',
114
+ writeHead(code, headers) {
115
+ this._statusCode = code;
116
+ this._headers = headers;
117
+ },
118
+ end(data) {
119
+ this._body = data;
120
+ },
121
+ setHeader(_name, _value) { },
122
+ getHeader(_name) { return ''; },
123
+ };
124
+ await stateRoute.handler({ url: '/api/knowledge/state', method: 'GET', headers: {} }, mockRes, ctx);
125
+ // The handler should produce a JSON response
126
+ expect(mockRes._statusCode).toBeGreaterThanOrEqual(200);
127
+ expect(mockRes._statusCode).toBeLessThan(600);
128
+ expect(ctx.scheduleKnowledgeLearningPlatformWarmup).toHaveBeenCalledWith('knowledge_state_request');
129
+ });
130
+ });