noteconnection 1.7.0 → 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 (211) hide show
  1. package/LICENSE +674 -21
  2. package/README.md +242 -62
  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 +242 -62
  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 +2178 -62
  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 +2108 -130
  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 +393 -33
  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/source_manager.js +190 -21
  50. package/dist/src/frontend/styles.css +2720 -72
  51. package/dist/src/frontend/workbench_state.mjs +101 -0
  52. package/dist/src/frontend/workspace_panes.js +10168 -0
  53. package/dist/src/frontend.locale.contract.test.js +62 -0
  54. package/dist/src/godot.sidecar.bootstrap.contract.test.js +244 -0
  55. package/dist/src/indexing/IndexLifecycle.js +195 -0
  56. package/dist/src/indexing/IndexLifecycle.test.js +49 -0
  57. package/dist/src/indexing/SegmentBuilder.js +64 -0
  58. package/dist/src/indexing/UnitBuilder.js +48 -0
  59. package/dist/src/indexing/types.js +2 -0
  60. package/dist/src/knowledge.api.contract.test.js +170 -0
  61. package/dist/src/learning/KnowledgeLearningPlatform.js +10386 -0
  62. package/dist/src/learning/KnowledgeLearningPlatform.persistence.test.js +327 -0
  63. package/dist/src/learning/KnowledgeLearningPlatform.program-f.test.js +99 -0
  64. package/dist/src/learning/KnowledgeLearningPlatform.test.js +2971 -0
  65. package/dist/src/learning/KnowledgeWorkspaceConversationRegression.js +2974 -0
  66. package/dist/src/learning/KnowledgeWorkspaceConversationRegression.test.js +3928 -0
  67. package/dist/src/learning/answerReleaseReview.js +4319 -0
  68. package/dist/src/learning/answerReleaseReview.test.js +2888 -0
  69. package/dist/src/learning/api.js +2 -0
  70. package/dist/src/learning/conversationComposer.js +1480 -0
  71. package/dist/src/learning/conversationComposer.test.js +1817 -0
  72. package/dist/src/learning/domains/ConversationManager.js +53 -0
  73. package/dist/src/learning/domains/KnowledgeIngestor.js +238 -0
  74. package/dist/src/learning/domains/KnowledgeQuerier.js +187 -0
  75. package/dist/src/learning/domains/MasteryEngine.js +387 -0
  76. package/dist/src/learning/domains/MemoryPolicyManager.js +408 -0
  77. package/dist/src/learning/domains/QualityEvaluator.js +307 -0
  78. package/dist/src/learning/domains/TutorRouter.js +313 -0
  79. package/dist/src/learning/domains/index.js +33 -0
  80. package/dist/src/learning/domains/types.js +7 -0
  81. package/dist/src/learning/errors.js +29 -0
  82. package/dist/src/learning/evidenceContextAssembler.js +1176 -0
  83. package/dist/src/learning/evidenceContextAssembler.test.js +6332 -0
  84. package/dist/src/learning/graphContextAssembler.js +870 -0
  85. package/dist/src/learning/graphContextAssembler.test.js +1033 -0
  86. package/dist/src/learning/index.js +28 -0
  87. package/dist/src/learning/queryBackend.js +1898 -0
  88. package/dist/src/learning/queryBackend.test.js +955 -0
  89. package/dist/src/learning/ragContextPack.js +257 -0
  90. package/dist/src/learning/ragContextPack.test.js +160 -0
  91. package/dist/src/learning/ragPublicText.js +38 -0
  92. package/dist/src/learning/ragSufficiencyJudge.js +161 -0
  93. package/dist/src/learning/ragSufficiencyJudge.test.js +177 -0
  94. package/dist/src/learning/ragSufficiencyProviderJudge.js +227 -0
  95. package/dist/src/learning/ragSufficiencyProviderJudge.test.js +156 -0
  96. package/dist/src/learning/requestNormalization.js +198 -0
  97. package/dist/src/learning/runtimeCapability.js +4677 -0
  98. package/dist/src/learning/runtimeCapability.test.js +3635 -0
  99. package/dist/src/learning/store.js +1240 -0
  100. package/dist/src/learning/store.test.js +1126 -0
  101. package/dist/src/learning/tutorAdapter.js +2 -0
  102. package/dist/src/learning/types.js +2 -0
  103. package/dist/src/learning/vectorAccelerationAdapter.js +942 -0
  104. package/dist/src/learning/vectorAccelerationAdapter.test.js +382 -0
  105. package/dist/src/lfs.asset.policy.contract.test.js +153 -0
  106. package/dist/src/license.policy.contract.test.js +66 -0
  107. package/dist/src/memory/MemoryGovernance.js +74 -0
  108. package/dist/src/memory/MemoryGovernance.test.js +46 -0
  109. package/dist/src/memory/types.js +2 -0
  110. package/dist/src/mermaid.frontend.guard.contract.test.js +77 -0
  111. package/dist/src/middleware/auth.js +17 -0
  112. package/dist/src/middleware/body-parser.js +45 -0
  113. package/dist/src/middleware/cors.js +44 -0
  114. package/dist/src/middleware/index.js +21 -0
  115. package/dist/src/middleware/request-trace.js +96 -0
  116. package/dist/src/notemd/AppConfigToml.js +6 -4
  117. package/dist/src/notemd/MermaidProcessor.js +400 -50
  118. package/dist/src/notemd/NotemdService.js +498 -13
  119. package/dist/src/notemd/PromptManager.js +15 -0
  120. package/dist/src/notemd/cli/commands.js +357 -0
  121. package/dist/src/notemd/cli/dispatcher.js +225 -0
  122. package/dist/src/notemd/cli/index.js +169 -0
  123. package/dist/src/notemd/cli/parser.js +68 -0
  124. package/dist/src/notemd/cli/types.js +2 -0
  125. package/dist/src/notemd/constants.js +43 -0
  126. package/dist/src/notemd/diagram/diagramGenerationService.js +78 -0
  127. package/dist/src/notemd/diagram/diagramSpec.js +79 -0
  128. package/dist/src/notemd/diagram/diagramSpecResponseParser.js +131 -0
  129. package/dist/src/notemd/diagram/intent.js +95 -0
  130. package/dist/src/notemd/diagram/planner.js +71 -0
  131. package/dist/src/notemd/diagram/prompts/diagramSpecPrompt.js +42 -0
  132. package/dist/src/notemd/diagram/types.js +18 -0
  133. package/dist/src/notemd/index.js +26 -0
  134. package/dist/src/notemd/operations/capabilityManifest.js +23 -0
  135. package/dist/src/notemd/operations/cliContracts.js +17 -0
  136. package/dist/src/notemd/operations/configProfileCommands.js +85 -0
  137. package/dist/src/notemd/operations/registry.contract.test.js +95 -0
  138. package/dist/src/notemd/operations/registry.js +991 -0
  139. package/dist/src/notemd/operations/types.js +2 -0
  140. package/dist/src/notemd/providerDiagnostics.js +220 -0
  141. package/dist/src/notemd/providerProfiles.js +42 -0
  142. package/dist/src/notemd/providerTemplates.js +231 -0
  143. package/dist/src/notemd/search/DuckDuckGoProvider.js +39 -0
  144. package/dist/src/notemd/search/SearchManager.js +13 -0
  145. package/dist/src/notemd/search/SearchProvider.js +2 -0
  146. package/dist/src/notemd/search/TavilyProvider.js +44 -0
  147. package/dist/src/notemd.agent.manifest.test.js +85 -0
  148. package/dist/src/notemd.api.contract.test.js +14 -1
  149. package/dist/src/notemd.app_config_toml.test.js +2 -1
  150. package/dist/src/notemd.batch.workflow.test.js +117 -0
  151. package/dist/src/notemd.cli.e2e.test.js +136 -0
  152. package/dist/src/notemd.core.test.js +51 -0
  153. package/dist/src/notemd.diagram.pipeline.test.js +233 -0
  154. package/dist/src/notemd.providerTemplates.test.js +34 -0
  155. package/dist/src/notemd.server.integration.test.js +143 -35
  156. package/dist/src/notemd.workflow.pipeline.test.js +162 -0
  157. package/dist/src/pathbridge.handshake.contract.test.js +16 -2
  158. package/dist/src/pathmode.background.contract.test.js +69 -0
  159. package/dist/src/pathmode.settings.api.contract.test.js +9 -0
  160. package/dist/src/pkg.sidecar.contract.test.js +9 -3
  161. package/dist/src/platform/ExportProfile.js +58 -0
  162. package/dist/src/platform/PlatformCapabilities.js +45 -0
  163. package/dist/src/platform/PlatformCapabilities.test.js +30 -0
  164. package/dist/src/platform/RenderMaterializer.js +33 -0
  165. package/dist/src/platform/RenderMaterializer.test.js +32 -0
  166. package/dist/src/query_backend.external_http.integration.test.js +410 -0
  167. package/dist/src/reader_renderer.js +404 -3
  168. package/dist/src/reader_renderer.test.js +87 -0
  169. package/dist/src/release.godot.mirror.contract.test.js +73 -0
  170. package/dist/src/resources/ResourceRegistry.js +223 -0
  171. package/dist/src/resources/ResourceRegistry.test.js +61 -0
  172. package/dist/src/resources/types.js +2 -0
  173. package/dist/src/routes/agentWorkspaceDiagnostics.js +173 -0
  174. package/dist/src/routes/data.js +267 -0
  175. package/dist/src/routes/diagnostics.js +51 -0
  176. package/dist/src/routes/index.js +23 -0
  177. package/dist/src/routes/knowledge.js +968 -0
  178. package/dist/src/routes/markdown.js +287 -0
  179. package/dist/src/routes/notemd.js +565 -0
  180. package/dist/src/routes/registry.contract.test.js +130 -0
  181. package/dist/src/routes/render.js +285 -0
  182. package/dist/src/routes/runtimeRunbookRouteOps.js +149 -0
  183. package/dist/src/routes/runtimeRunbookRouteOps.test.js +194 -0
  184. package/dist/src/routes/settings.js +6 -0
  185. package/dist/src/routes/staticFiles.js +94 -0
  186. package/dist/src/routes/types.js +2 -0
  187. package/dist/src/runtime.transport.adapter.contract.test.js +81 -0
  188. package/dist/src/server.js +11090 -1549
  189. package/dist/src/server.migration.test.js +193 -21
  190. package/dist/src/server.port.fallback.contract.test.js +63 -0
  191. package/dist/src/session/SessionStateStore.js +81 -0
  192. package/dist/src/session/SessionStateStore.test.js +58 -0
  193. package/dist/src/session/types.js +2 -0
  194. package/dist/src/settings.runtime.contract.test.js +50 -0
  195. package/dist/src/shared/types.contract.test.js +107 -0
  196. package/dist/src/shared/types.js +22 -0
  197. package/dist/src/sidecar.replacement.boundary.contract.test.js +128 -0
  198. package/dist/src/sidecar.supply.readiness.contract.test.js +144 -0
  199. package/dist/src/source_manager.loadflow.test.js +46 -0
  200. package/dist/src/startup.layout.snapshot.contract.test.js +57 -0
  201. package/dist/src/tauri.frontend.build.contract.test.js +60 -0
  202. package/dist/src/tauri.sidecar.cleanup.contract.test.js +21 -0
  203. package/dist/src/utils/RuntimePaths.js +4 -13
  204. package/dist/src/utils/platform.js +153 -0
  205. package/dist/src/workflows/WorkflowArtifactStore.js +96 -0
  206. package/dist/src/workflows/WorkflowArtifactStore.test.js +80 -0
  207. package/dist/src/workflows/types.js +2 -0
  208. package/dist/src/workspace/WorkspaceRegistry.js +122 -0
  209. package/dist/src/workspace/WorkspaceRegistry.test.js +29 -0
  210. package/dist/src/workspace/types.js +2 -0
  211. package/package.json +53 -10
@@ -0,0 +1,968 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerKnowledgeRoutes = registerKnowledgeRoutes;
4
+ const CrashLogger_1 = require("../backend/utils/CrashLogger");
5
+ const requestNormalization_1 = require("../learning/requestNormalization");
6
+ function registerKnowledgeRoutes(ctx) {
7
+ const { knowledgeLearningPlatform, knowledgeIngestor, knowledgeQuerier, LOOPBACK_HOST, finalPort, KNOWLEDGE_GRAPH_STORE_BACKEND, KNOWLEDGE_GRAPHDB_ADAPTER_PROVIDER, KNOWLEDGE_GRAPHDB_ADAPTER_ID, KNOWLEDGE_GRAPHDB_FALLBACK_ENABLED, KNOWLEDGE_GRAPHDB_OPERATION_MODE, runtimeRunbookOps, scheduleKnowledgeLearningPlatformWarmup, } = ctx;
8
+ const api = (path) => `/api/knowledge${path}`;
9
+ const json = (res, code, data) => {
10
+ res.writeHead(code, { 'Content-Type': 'application/json' });
11
+ res.end(JSON.stringify(data));
12
+ };
13
+ const ok = (res, data) => json(res, 200, { success: true, ...data });
14
+ const fail = (res, error, label) => {
15
+ console.error(error);
16
+ CrashLogger_1.CrashLogger.log(error, label);
17
+ json(res, 500, { success: false, error: String(error) });
18
+ };
19
+ const readBody = (req) => new Promise((resolve, reject) => {
20
+ const chunks = [];
21
+ req.on('data', (c) => chunks.push(c));
22
+ req.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
23
+ req.on('error', reject);
24
+ });
25
+ const parseQuery = (req) => new URL(req.url || '/', `http://${LOOPBACK_HOST}:${finalPort}`).searchParams;
26
+ return [
27
+ // --- GET routes (self-contained, no external normalize functions) ---
28
+ {
29
+ method: 'GET',
30
+ path: api('/state'),
31
+ handler: async (_req, res) => {
32
+ try {
33
+ scheduleKnowledgeLearningPlatformWarmup?.('knowledge_state_request');
34
+ const payload = await knowledgeLearningPlatform.getKnowledgeState();
35
+ ok(res, payload);
36
+ }
37
+ catch (e) {
38
+ fail(res, e, 'GET /api/knowledge/state');
39
+ }
40
+ },
41
+ },
42
+ {
43
+ method: 'GET',
44
+ path: api('/store-diagnostics'),
45
+ handler: async (_req, res) => {
46
+ try {
47
+ const store = await knowledgeLearningPlatform.getStoreDiagnostics();
48
+ ok(res, {
49
+ configuredBackend: KNOWLEDGE_GRAPH_STORE_BACKEND,
50
+ configuredGraphDbAdapterProvider: KNOWLEDGE_GRAPHDB_ADAPTER_PROVIDER,
51
+ configuredGraphDbAdapterId: KNOWLEDGE_GRAPHDB_ADAPTER_ID,
52
+ graphDbFallbackEnabled: KNOWLEDGE_GRAPHDB_FALLBACK_ENABLED,
53
+ configuredGraphDbOperationMode: KNOWLEDGE_GRAPHDB_OPERATION_MODE,
54
+ store,
55
+ });
56
+ }
57
+ catch (e) {
58
+ fail(res, e, 'GET /api/knowledge/store-diagnostics');
59
+ }
60
+ },
61
+ },
62
+ {
63
+ method: 'GET',
64
+ path: api('/tutor/catalog'),
65
+ handler: async (_req, res) => {
66
+ try {
67
+ const catalog = await knowledgeLearningPlatform.getTutorAdapterCatalog();
68
+ ok(res, { catalog });
69
+ }
70
+ catch (e) {
71
+ fail(res, e, 'GET /api/knowledge/tutor/catalog');
72
+ }
73
+ },
74
+ },
75
+ {
76
+ method: 'GET',
77
+ path: api('/tutor/telemetry'),
78
+ handler: async (_req, res) => {
79
+ try {
80
+ const result = await knowledgeLearningPlatform.getTutorAdapterTelemetry();
81
+ ok(res, { result });
82
+ }
83
+ catch (e) {
84
+ fail(res, e, 'GET /api/knowledge/tutor/telemetry');
85
+ }
86
+ },
87
+ },
88
+ {
89
+ method: 'GET',
90
+ path: api('/tutor/trace-diagnostics'),
91
+ handler: async (req, res) => {
92
+ try {
93
+ const params = parseQuery(req);
94
+ const fallbackUsedToken = String(params.get('fallbackUsed') || '').trim().toLowerCase();
95
+ const result = await knowledgeLearningPlatform.queryTutorTraceDiagnostics({
96
+ userId: String(params.get('userId') || '').trim() || undefined,
97
+ source: String(params.get('source') || '').trim() || undefined,
98
+ actionKind: String(params.get('actionKind') || '').trim() || undefined,
99
+ providerName: String(params.get('providerName') || '').trim() || undefined,
100
+ providerMode: String(params.get('providerMode') || '').trim() || undefined,
101
+ fallbackUsed: fallbackUsedToken === 'true'
102
+ ? true
103
+ : fallbackUsedToken === 'false'
104
+ ? false
105
+ : undefined,
106
+ limit: Number(params.get('limit')) || 20,
107
+ });
108
+ ok(res, { result });
109
+ }
110
+ catch (e) {
111
+ fail(res, e, 'GET /api/knowledge/tutor/trace-diagnostics');
112
+ }
113
+ },
114
+ },
115
+ {
116
+ method: 'GET',
117
+ path: api('/query-backend-diagnostics'),
118
+ handler: async (_req, res) => {
119
+ try {
120
+ const diag = await knowledgeLearningPlatform.getQueryBackendDiagnostics();
121
+ ok(res, { queryBackendDiagnostics: diag });
122
+ }
123
+ catch (e) {
124
+ fail(res, e, 'GET /api/knowledge/query-backend-diagnostics');
125
+ }
126
+ },
127
+ },
128
+ {
129
+ method: 'GET',
130
+ path: api('/query/compare-backends/history'),
131
+ handler: async (req, res) => {
132
+ try {
133
+ const params = parseQuery(req);
134
+ const result = await knowledgeLearningPlatform.queryKnowledgeQueryBackendComparisonHistory({
135
+ limit: Number(params.get('limit')) || 8,
136
+ });
137
+ ok(res, { result });
138
+ }
139
+ catch (e) {
140
+ fail(res, e, 'GET /api/knowledge/query/compare-backends/history');
141
+ }
142
+ },
143
+ },
144
+ {
145
+ method: 'GET',
146
+ path: api('/query/compare-backends/trend'),
147
+ handler: async (req, res) => {
148
+ try {
149
+ const params = parseQuery(req);
150
+ const result = await knowledgeLearningPlatform.queryKnowledgeQueryBackendComparisonTrend({
151
+ limit: Number(params.get('limit')) || 12,
152
+ windowSize: Number(params.get('windowSize')) || 2,
153
+ minSamples: Number(params.get('minSamples')) || 1,
154
+ });
155
+ ok(res, { result });
156
+ }
157
+ catch (e) {
158
+ fail(res, e, 'GET /api/knowledge/query/compare-backends/trend');
159
+ }
160
+ },
161
+ },
162
+ {
163
+ method: 'GET',
164
+ path: api('/query-backend-config'),
165
+ handler: async (_req, res) => {
166
+ try {
167
+ const config = knowledgeLearningPlatform.getQueryBackendConfig();
168
+ ok(res, { queryBackendConfig: config });
169
+ }
170
+ catch (e) {
171
+ fail(res, e, 'GET /api/knowledge/query-backend-config');
172
+ }
173
+ },
174
+ },
175
+ {
176
+ method: 'GET',
177
+ path: api('/quality/trend'),
178
+ handler: async (req, res) => {
179
+ try {
180
+ const params = parseQuery(req);
181
+ const result = await knowledgeLearningPlatform.queryLearningQualityTrend({
182
+ userId: String(params.get('userId') || '').trim() || undefined,
183
+ limit: Number(params.get('limit')) || 10,
184
+ windowSize: Number(params.get('windowSize')) || undefined,
185
+ minSamples: Number(params.get('minSamples')) || undefined,
186
+ });
187
+ ok(res, { result });
188
+ }
189
+ catch (e) {
190
+ fail(res, e, 'GET /api/knowledge/quality/trend');
191
+ }
192
+ },
193
+ },
194
+ {
195
+ method: 'GET',
196
+ path: api('/quality/history'),
197
+ handler: async (req, res) => {
198
+ try {
199
+ const params = parseQuery(req);
200
+ const result = await knowledgeLearningPlatform.queryLearningQualityHistory({
201
+ userId: String(params.get('userId') || '').trim() || undefined,
202
+ limit: Number(params.get('limit')) || 20,
203
+ });
204
+ ok(res, { result });
205
+ }
206
+ catch (e) {
207
+ fail(res, e, 'GET /api/knowledge/quality/history');
208
+ }
209
+ },
210
+ },
211
+ {
212
+ method: 'GET',
213
+ path: api('/quality/baseline'),
214
+ handler: async (req, res) => {
215
+ try {
216
+ const params = parseQuery(req);
217
+ const userId = String(params.get('userId') || '').trim();
218
+ const result = await knowledgeLearningPlatform.getLearningQualityBaseline({ userId });
219
+ ok(res, { result });
220
+ }
221
+ catch (e) {
222
+ fail(res, e, 'GET /api/knowledge/quality/baseline');
223
+ }
224
+ },
225
+ },
226
+ {
227
+ method: 'GET',
228
+ path: api('/session/history'),
229
+ handler: async (req, res) => {
230
+ try {
231
+ const params = parseQuery(req);
232
+ const result = await knowledgeLearningPlatform.queryStudySessionHistory({
233
+ userId: String(params.get('userId') || '').trim() || undefined,
234
+ limit: Number(params.get('limit')) || 20,
235
+ sinceMinutes: Number(params.get('sinceMinutes')) || undefined,
236
+ refreshSource: String(params.get('refreshSource') || '').trim() || undefined,
237
+ });
238
+ ok(res, { result });
239
+ }
240
+ catch (e) {
241
+ fail(res, e, 'GET /api/knowledge/session/history');
242
+ }
243
+ },
244
+ },
245
+ {
246
+ method: 'GET',
247
+ path: api('/workflow-artifacts'),
248
+ handler: async (req, res) => {
249
+ try {
250
+ const params = parseQuery(req);
251
+ const artifactKinds = String(params.get('artifactKinds') || '').trim()
252
+ ? String(params.get('artifactKinds') || '')
253
+ .split(',')
254
+ .map((value) => String(value || '').trim())
255
+ .filter(Boolean)
256
+ : undefined;
257
+ const result = await knowledgeLearningPlatform.queryWorkflowArtifacts?.({
258
+ workspaceId: String(params.get('workspaceId') || '').trim() || undefined,
259
+ sessionId: String(params.get('sessionId') || '').trim() || undefined,
260
+ userId: String(params.get('userId') || '').trim() || undefined,
261
+ artifactId: String(params.get('artifactId') || '').trim() || undefined,
262
+ runId: String(params.get('runId') || '').trim() || undefined,
263
+ artifactKinds,
264
+ limit: Number(params.get('limit')) || 12,
265
+ });
266
+ ok(res, { result });
267
+ }
268
+ catch (e) {
269
+ fail(res, e, 'GET /api/knowledge/workflow-artifacts');
270
+ }
271
+ },
272
+ },
273
+ {
274
+ method: 'GET',
275
+ path: api('/session/plan/quality/trend'),
276
+ handler: async (req, res) => {
277
+ try {
278
+ const params = parseQuery(req);
279
+ const result = await knowledgeLearningPlatform.queryStudySessionPlanQualityTrend({
280
+ userId: String(params.get('userId') || '').trim() || undefined,
281
+ limit: Number(params.get('limit')) || 10,
282
+ windowSize: Number(params.get('windowSize')) || undefined,
283
+ minSamples: Number(params.get('minSamples')) || undefined,
284
+ });
285
+ ok(res, { result });
286
+ }
287
+ catch (e) {
288
+ fail(res, e, 'GET /api/knowledge/session/plan/quality/trend');
289
+ }
290
+ },
291
+ },
292
+ {
293
+ method: 'GET',
294
+ path: api('/session/plan/quality/history'),
295
+ handler: async (req, res) => {
296
+ try {
297
+ const params = parseQuery(req);
298
+ const result = await knowledgeLearningPlatform.queryStudySessionPlanQualityHistory({
299
+ userId: String(params.get('userId') || '').trim() || undefined,
300
+ limit: Number(params.get('limit')) || 20,
301
+ });
302
+ ok(res, { result });
303
+ }
304
+ catch (e) {
305
+ fail(res, e, 'GET /api/knowledge/session/plan/quality/history');
306
+ }
307
+ },
308
+ },
309
+ {
310
+ method: 'GET',
311
+ path: api('/memory-policy/diagnostics'),
312
+ handler: async (req, res) => {
313
+ try {
314
+ const params = parseQuery(req);
315
+ const persistRecordToken = String(params.get('persistRecord') || '').trim().toLowerCase();
316
+ const result = await knowledgeLearningPlatform.queryMemoryPolicyDiagnostics({
317
+ limit: Number(params.get('limit')) || undefined,
318
+ sampleLimit: Number(params.get('sampleLimit')) || undefined,
319
+ staleAfterHours: Number(params.get('staleAfterHours')) || undefined,
320
+ nearExpiryHours: Number(params.get('nearExpiryHours')) || undefined,
321
+ lowConfidenceThreshold: Number(params.get('lowConfidenceThreshold')) || undefined,
322
+ now: String(params.get('now') || '').trim() || undefined,
323
+ persistRecord: persistRecordToken === 'false'
324
+ ? false
325
+ : persistRecordToken === 'true'
326
+ ? true
327
+ : undefined,
328
+ });
329
+ ok(res, { result });
330
+ }
331
+ catch (e) {
332
+ fail(res, e, 'GET /api/knowledge/memory-policy/diagnostics');
333
+ }
334
+ },
335
+ },
336
+ {
337
+ method: 'GET',
338
+ path: api('/conversation/turn-cache/diagnostics'),
339
+ handler: async (req, res) => {
340
+ try {
341
+ const params = parseQuery(req);
342
+ const result = await knowledgeLearningPlatform.getAgentConversationTurnCacheDiagnostics({ format: params.get('format') || 'summary' });
343
+ ok(res, result);
344
+ }
345
+ catch (e) {
346
+ fail(res, e, 'GET /api/knowledge/conversation/turn-cache/diagnostics');
347
+ }
348
+ },
349
+ },
350
+ {
351
+ method: 'GET',
352
+ path: api('/conversation/turn-cache/diagnostics/trend'),
353
+ handler: async (req, res) => {
354
+ try {
355
+ const params = parseQuery(req);
356
+ const result = await knowledgeLearningPlatform.getAgentConversationTurnCacheTrend({ limit: Number(params.get('limit')) || 20, windowSize: Number(params.get('windowSize')) || 6, minSamples: Number(params.get('minSamples')) || 3 });
357
+ ok(res, result);
358
+ }
359
+ catch (e) {
360
+ fail(res, e, 'GET /api/knowledge/conversation/turn-cache/diagnostics/trend');
361
+ }
362
+ },
363
+ },
364
+ {
365
+ method: 'GET',
366
+ path: api('/runtime-capability-matrix'),
367
+ handler: async (_req, res) => {
368
+ try {
369
+ const matrix = await knowledgeLearningPlatform.getRuntimeCapabilityMatrix();
370
+ ok(res, { matrix });
371
+ }
372
+ catch (e) {
373
+ fail(res, e, 'GET /api/knowledge/runtime-capability-matrix');
374
+ }
375
+ },
376
+ },
377
+ {
378
+ method: 'GET',
379
+ path: api('/runtime-capability-runbook'),
380
+ handler: async (req, res) => {
381
+ try {
382
+ const params = parseQuery(req);
383
+ const runbook = runtimeRunbookOps?.getRunbook
384
+ ? await runtimeRunbookOps.getRunbook({
385
+ checkId: String(params.get('checkId') || '').trim(),
386
+ })
387
+ : await knowledgeLearningPlatform.getRuntimeCapabilityRunbook();
388
+ ok(res, { runbook });
389
+ }
390
+ catch (e) {
391
+ fail(res, e, 'GET /api/knowledge/runtime-capability-runbook');
392
+ }
393
+ },
394
+ },
395
+ {
396
+ method: 'GET',
397
+ path: api('/runtime-capability-runbook/verify'),
398
+ handler: async (req, res) => {
399
+ try {
400
+ const params = parseQuery(req);
401
+ const request = {
402
+ checkId: String(params.get('checkId') || '').trim(),
403
+ focus: String(params.get('focus') || '').trim(),
404
+ focusLimit: Number(params.get('focusLimit')) || 12,
405
+ sinceMinutes: Number(params.get('sinceMinutes')) || 1440,
406
+ status: String(params.get('status') || '').trim(),
407
+ checkQuery: String(params.get('checkQuery') || '').trim(),
408
+ limit: Number(params.get('limit')) || 20,
409
+ };
410
+ const result = runtimeRunbookOps?.verify
411
+ ? await runtimeRunbookOps.verify(request)
412
+ : await knowledgeLearningPlatform.verifyRuntimeCapabilityRunbook(request);
413
+ ok(res, { result });
414
+ }
415
+ catch (e) {
416
+ fail(res, e, 'GET /api/knowledge/runtime-capability-runbook/verify');
417
+ }
418
+ },
419
+ },
420
+ {
421
+ method: 'GET',
422
+ path: api('/runtime-capability-runbook/history'),
423
+ handler: async (req, res) => {
424
+ try {
425
+ const params = parseQuery(req);
426
+ const request = {
427
+ limit: Number(params.get('limit')) || 20,
428
+ checkId: String(params.get('checkId') || '').trim(),
429
+ sinceMinutes: Number(params.get('sinceMinutes')) || 10080,
430
+ status: String(params.get('status') || '').trim(),
431
+ };
432
+ const result = runtimeRunbookOps?.getHistory
433
+ ? await runtimeRunbookOps.getHistory(request)
434
+ : await knowledgeLearningPlatform.getRuntimeCapabilityRunbookHistory(request);
435
+ ok(res, { result });
436
+ }
437
+ catch (e) {
438
+ fail(res, e, 'GET /api/knowledge/runtime-capability-runbook/history');
439
+ }
440
+ },
441
+ },
442
+ {
443
+ method: 'GET',
444
+ path: api('/runtime-capability-runbook/history/checks'),
445
+ handler: async (req, res) => {
446
+ try {
447
+ const params = parseQuery(req);
448
+ const request = {
449
+ limit: Number(params.get('limit')) || 8,
450
+ sinceMinutes: Number(params.get('sinceMinutes')) || 10080,
451
+ status: String(params.get('status') || '').trim(),
452
+ checkQuery: String(params.get('checkQuery') || '').trim(),
453
+ };
454
+ const result = runtimeRunbookOps?.getChecks
455
+ ? await runtimeRunbookOps.getChecks(request)
456
+ : await knowledgeLearningPlatform.queryRuntimeCapabilityRunbookChecks(request);
457
+ ok(res, { result });
458
+ }
459
+ catch (e) {
460
+ fail(res, e, 'GET /api/knowledge/runtime-capability-runbook/history/checks');
461
+ }
462
+ },
463
+ },
464
+ {
465
+ method: 'GET',
466
+ path: api('/runtime-capability-runbook/history/action-queue'),
467
+ handler: async (req, res) => {
468
+ try {
469
+ const params = parseQuery(req);
470
+ const request = {
471
+ limit: Number(params.get('limit')) || 8,
472
+ sinceMinutes: Number(params.get('sinceMinutes')) || 10080,
473
+ status: String(params.get('status') || '').trim(),
474
+ checkQuery: String(params.get('checkQuery') || '').trim(),
475
+ queueLimit: Number(params.get('queueLimit')) || 12,
476
+ priority: String(params.get('priority') || '').trim(),
477
+ category: String(params.get('category') || '').trim(),
478
+ checkId: String(params.get('checkId') || '').trim(),
479
+ remediationStatus: String(params.get('remediationStatus') || '').trim(),
480
+ remediationTrend: String(params.get('remediationTrend') || '').trim(),
481
+ };
482
+ const result = runtimeRunbookOps?.getActionQueue
483
+ ? await runtimeRunbookOps.getActionQueue(request)
484
+ : await knowledgeLearningPlatform.queryRuntimeCapabilityRunbookActionQueue(request);
485
+ ok(res, { result });
486
+ }
487
+ catch (e) {
488
+ fail(res, e, 'GET /api/knowledge/runtime-capability-runbook/history/action-queue');
489
+ }
490
+ },
491
+ },
492
+ {
493
+ method: 'GET',
494
+ path: api('/runtime-capability-runbook/remediation-history'),
495
+ handler: async (req, res) => {
496
+ try {
497
+ const params = parseQuery(req);
498
+ const request = {
499
+ limit: Number(params.get('limit')) || 20,
500
+ sinceMinutes: Number(params.get('sinceMinutes')) || 10080,
501
+ status: String(params.get('status') || '').trim(),
502
+ source: String(params.get('source') || '').trim(),
503
+ checkId: String(params.get('checkId') || '').trim(),
504
+ };
505
+ const result = runtimeRunbookOps?.getRemediationHistory
506
+ ? await runtimeRunbookOps.getRemediationHistory(request)
507
+ : await knowledgeLearningPlatform.getRuntimeCapabilityRunbookRemediationHistory(request);
508
+ ok(res, { result });
509
+ }
510
+ catch (e) {
511
+ fail(res, e, 'GET /api/knowledge/runtime-capability-runbook/remediation-history');
512
+ }
513
+ },
514
+ },
515
+ {
516
+ method: 'GET',
517
+ path: api('/runtime-capability-runbook/replay-schedule'),
518
+ handler: async (_req, res) => {
519
+ try {
520
+ const schedule = runtimeRunbookOps?.getReplaySchedule
521
+ ? await runtimeRunbookOps.getReplaySchedule()
522
+ : await knowledgeLearningPlatform.getRuntimeCapabilityRunbookReplaySchedule();
523
+ ok(res, { schedule });
524
+ }
525
+ catch (e) {
526
+ fail(res, e, 'GET /api/knowledge/runtime-capability-runbook/replay-schedule');
527
+ }
528
+ },
529
+ },
530
+ // --- POST routes ---
531
+ {
532
+ method: 'POST',
533
+ path: api('/ingest'),
534
+ handler: async (req, res) => {
535
+ try {
536
+ const body = await readBody(req);
537
+ const result = await knowledgeIngestor.ingestKnowledge(JSON.parse(body));
538
+ ok(res, { result, ingestStats: { avgLatencyMs: knowledgeIngestor.averageIngestLatencyMs(20) } });
539
+ }
540
+ catch (e) {
541
+ fail(res, e, 'POST /api/knowledge/ingest');
542
+ }
543
+ },
544
+ },
545
+ {
546
+ method: 'POST',
547
+ path: api('/query'),
548
+ handler: async (req, res) => {
549
+ try {
550
+ const body = await readBody(req);
551
+ const result = await knowledgeQuerier.queryKnowledge((0, requestNormalization_1.normalizeKnowledgeQueryRequestPayload)(JSON.parse(body)));
552
+ ok(res, { result, queryStats: knowledgeQuerier.getDiagnosticsSummary() });
553
+ }
554
+ catch (e) {
555
+ fail(res, e, 'POST /api/knowledge/query');
556
+ }
557
+ },
558
+ },
559
+ {
560
+ method: 'POST',
561
+ path: api('/workspace-readiness'),
562
+ handler: async (req, res) => {
563
+ try {
564
+ const body = await readBody(req);
565
+ const payload = JSON.parse(body);
566
+ const result = await knowledgeLearningPlatform.inspectKnowledgeWorkspaceRequest({
567
+ query: String(payload?.query || '').trim(),
568
+ scope: payload?.scope,
569
+ queryBackend: payload?.queryBackend,
570
+ });
571
+ ok(res, { result });
572
+ }
573
+ catch (e) {
574
+ fail(res, e, 'POST /api/knowledge/workspace-readiness');
575
+ }
576
+ },
577
+ },
578
+ {
579
+ method: 'POST',
580
+ path: api('/mastery/diagnostics'),
581
+ handler: async (req, res) => {
582
+ try {
583
+ const body = await readBody(req);
584
+ const result = await knowledgeLearningPlatform.queryMasteryDiagnostics(JSON.parse(body));
585
+ ok(res, { result });
586
+ }
587
+ catch (e) {
588
+ fail(res, e, 'POST /api/knowledge/mastery/diagnostics');
589
+ }
590
+ },
591
+ },
592
+ {
593
+ method: 'POST',
594
+ path: api('/learning-path'),
595
+ handler: async (req, res) => {
596
+ try {
597
+ const body = await readBody(req);
598
+ const result = await knowledgeLearningPlatform.generateLearningPath(JSON.parse(body));
599
+ ok(res, { result });
600
+ }
601
+ catch (e) {
602
+ fail(res, e, 'POST /api/knowledge/learning-path');
603
+ }
604
+ },
605
+ },
606
+ {
607
+ method: 'POST',
608
+ path: api('/session/build'),
609
+ handler: async (req, res) => {
610
+ try {
611
+ const body = await readBody(req);
612
+ const result = await knowledgeLearningPlatform.buildStudySession(JSON.parse(body));
613
+ ok(res, { result });
614
+ }
615
+ catch (e) {
616
+ fail(res, e, 'POST /api/knowledge/session/build');
617
+ }
618
+ },
619
+ },
620
+ {
621
+ method: 'POST',
622
+ path: api('/session/execute'),
623
+ handler: async (req, res) => {
624
+ try {
625
+ const body = await readBody(req);
626
+ const result = await knowledgeLearningPlatform.executeStudySessionPlan(JSON.parse(body));
627
+ ok(res, { result });
628
+ }
629
+ catch (e) {
630
+ fail(res, e, 'POST /api/knowledge/session/execute');
631
+ }
632
+ },
633
+ },
634
+ {
635
+ method: 'POST',
636
+ path: api('/workflow-artifacts/review-follow-up'),
637
+ handler: async (req, res) => {
638
+ try {
639
+ const body = await readBody(req);
640
+ const result = await knowledgeLearningPlatform.executeWorkflowArtifactReviewFollowUp((0, requestNormalization_1.normalizeWorkflowArtifactReviewFollowUpRequestPayload)(JSON.parse(body)));
641
+ ok(res, { result });
642
+ }
643
+ catch (e) {
644
+ fail(res, e, 'POST /api/knowledge/workflow-artifacts/review-follow-up');
645
+ }
646
+ },
647
+ },
648
+ {
649
+ method: 'POST',
650
+ path: api('/session/graph-focus-diagnostics'),
651
+ handler: async (req, res) => {
652
+ try {
653
+ const body = await readBody(req);
654
+ const result = await knowledgeLearningPlatform.recordGraphFocusRenderDiagnostics(JSON.parse(body));
655
+ ok(res, { result });
656
+ }
657
+ catch (e) {
658
+ fail(res, e, 'POST /api/knowledge/session/graph-focus-diagnostics');
659
+ }
660
+ },
661
+ },
662
+ {
663
+ method: 'POST',
664
+ path: api('/export/workspace'),
665
+ handler: async (req, res) => {
666
+ try {
667
+ const body = await readBody(req);
668
+ const result = await knowledgeLearningPlatform.buildWorkspaceExportBundle(JSON.parse(body));
669
+ ok(res, { result });
670
+ }
671
+ catch (e) {
672
+ fail(res, e, 'POST /api/knowledge/export/workspace');
673
+ }
674
+ },
675
+ },
676
+ {
677
+ method: 'POST',
678
+ path: api('/quality/evaluate'),
679
+ handler: async (req, res) => {
680
+ try {
681
+ const body = await readBody(req);
682
+ const result = await knowledgeLearningPlatform.evaluateLearningQuality(JSON.parse(body));
683
+ ok(res, { result });
684
+ }
685
+ catch (e) {
686
+ fail(res, e, 'POST /api/knowledge/quality/evaluate');
687
+ }
688
+ },
689
+ },
690
+ {
691
+ method: 'POST',
692
+ path: api('/quality/snapshot'),
693
+ handler: async (req, res) => {
694
+ try {
695
+ const body = await readBody(req);
696
+ const result = await knowledgeLearningPlatform.captureLearningQualitySnapshot(JSON.parse(body));
697
+ ok(res, { result });
698
+ }
699
+ catch (e) {
700
+ fail(res, e, 'POST /api/knowledge/quality/snapshot');
701
+ }
702
+ },
703
+ },
704
+ {
705
+ method: 'POST',
706
+ path: api('/quality/baseline'),
707
+ handler: async (req, res) => {
708
+ try {
709
+ const body = await readBody(req);
710
+ const result = await knowledgeLearningPlatform.setLearningQualityBaseline(JSON.parse(body));
711
+ ok(res, { result });
712
+ }
713
+ catch (e) {
714
+ fail(res, e, 'POST /api/knowledge/quality/baseline');
715
+ }
716
+ },
717
+ },
718
+ {
719
+ method: 'POST',
720
+ path: api('/quality/baseline/clear'),
721
+ handler: async (req, res) => {
722
+ try {
723
+ const body = await readBody(req);
724
+ const result = await knowledgeLearningPlatform.clearLearningQualityBaseline(JSON.parse(body));
725
+ ok(res, { result });
726
+ }
727
+ catch (e) {
728
+ fail(res, e, 'POST /api/knowledge/quality/baseline/clear');
729
+ }
730
+ },
731
+ },
732
+ {
733
+ method: 'POST',
734
+ path: api('/quality/baseline/evaluate'),
735
+ handler: async (req, res) => {
736
+ try {
737
+ const body = await readBody(req);
738
+ const result = await knowledgeLearningPlatform.evaluateLearningQualityAgainstBaseline(JSON.parse(body));
739
+ ok(res, { result });
740
+ }
741
+ catch (e) {
742
+ fail(res, e, 'POST /api/knowledge/quality/baseline/evaluate');
743
+ }
744
+ },
745
+ },
746
+ {
747
+ method: 'POST',
748
+ path: api('/tutor/action'),
749
+ handler: async (req, res) => {
750
+ try {
751
+ const body = await readBody(req);
752
+ const result = await knowledgeLearningPlatform.executeTutorAction(JSON.parse(body));
753
+ ok(res, { result });
754
+ }
755
+ catch (e) {
756
+ fail(res, e, 'POST /api/knowledge/tutor/action');
757
+ }
758
+ },
759
+ },
760
+ {
761
+ method: 'POST',
762
+ path: api('/memory-policy'),
763
+ handler: async (req, res) => {
764
+ try {
765
+ const body = await readBody(req);
766
+ const result = await knowledgeLearningPlatform.applyMemoryPolicy(JSON.parse(body));
767
+ ok(res, { result });
768
+ }
769
+ catch (e) {
770
+ fail(res, e, 'POST /api/knowledge/memory-policy');
771
+ }
772
+ },
773
+ },
774
+ {
775
+ method: 'POST',
776
+ path: api('/query/compare-backends'),
777
+ handler: async (req, res) => {
778
+ try {
779
+ const body = await readBody(req);
780
+ const result = await knowledgeLearningPlatform.compareQueryBackends(JSON.parse(body));
781
+ ok(res, { result });
782
+ }
783
+ catch (e) {
784
+ fail(res, e, 'POST /api/knowledge/query/compare-backends');
785
+ }
786
+ },
787
+ },
788
+ {
789
+ method: 'POST',
790
+ path: api('/store/reload'),
791
+ handler: async (_req, res) => {
792
+ try {
793
+ await knowledgeLearningPlatform.reloadStore();
794
+ ok(res, { reloaded: true });
795
+ }
796
+ catch (e) {
797
+ fail(res, e, 'POST /api/knowledge/store/reload');
798
+ }
799
+ },
800
+ },
801
+ {
802
+ method: 'POST',
803
+ path: api('/query-backend-config'),
804
+ handler: async (req, res) => {
805
+ try {
806
+ const body = await readBody(req);
807
+ const result = await knowledgeLearningPlatform.updateQueryBackendConfig(JSON.parse(body));
808
+ ok(res, { result });
809
+ }
810
+ catch (e) {
811
+ fail(res, e, 'POST /api/knowledge/query-backend-config');
812
+ }
813
+ },
814
+ },
815
+ {
816
+ method: 'POST',
817
+ path: api('/ingest/guardrail'),
818
+ handler: async (req, res) => {
819
+ try {
820
+ const body = await readBody(req);
821
+ const result = await knowledgeLearningPlatform.evaluateIngestGuardrail(JSON.parse(body));
822
+ ok(res, { result });
823
+ }
824
+ catch (e) {
825
+ fail(res, e, 'POST /api/knowledge/ingest/guardrail');
826
+ }
827
+ },
828
+ },
829
+ {
830
+ method: 'POST',
831
+ path: api('/runtime-capability-runbook/remediation-event'),
832
+ handler: async (req, res) => {
833
+ try {
834
+ const body = await readBody(req);
835
+ const payload = JSON.parse(body);
836
+ const result = runtimeRunbookOps?.recordRemediationEvent
837
+ ? await runtimeRunbookOps.recordRemediationEvent(payload, String(req.requestId || req.headers['x-request-id'] || ''))
838
+ : await knowledgeLearningPlatform.recordRuntimeCapabilityRemediationEvent(payload);
839
+ ok(res, { result });
840
+ }
841
+ catch (e) {
842
+ fail(res, e, 'POST /api/knowledge/runtime-capability-runbook/remediation-event');
843
+ }
844
+ },
845
+ },
846
+ {
847
+ method: 'POST',
848
+ path: api('/runtime-capability-runbook/remediation-event/replay'),
849
+ handler: async (req, res) => {
850
+ try {
851
+ const body = await readBody(req);
852
+ const payload = JSON.parse(body);
853
+ const result = runtimeRunbookOps?.replayRemediationEvent
854
+ ? await runtimeRunbookOps.replayRemediationEvent(payload)
855
+ : await knowledgeLearningPlatform.replayRuntimeCapabilityRemediationEvent(payload);
856
+ ok(res, { result });
857
+ }
858
+ catch (e) {
859
+ fail(res, e, 'POST /api/knowledge/runtime-capability-runbook/remediation-event/replay');
860
+ }
861
+ },
862
+ },
863
+ {
864
+ method: 'POST',
865
+ path: api('/runtime-capability-runbook/replay-schedule'),
866
+ handler: async (req, res) => {
867
+ try {
868
+ const body = await readBody(req);
869
+ const payload = JSON.parse(body);
870
+ const result = runtimeRunbookOps?.updateReplaySchedule
871
+ ? await runtimeRunbookOps.updateReplaySchedule(payload)
872
+ : await knowledgeLearningPlatform.updateRuntimeCapabilityReplaySchedule(payload);
873
+ ok(res, { result });
874
+ }
875
+ catch (e) {
876
+ fail(res, e, 'POST /api/knowledge/runtime-capability-runbook/replay-schedule');
877
+ }
878
+ },
879
+ },
880
+ {
881
+ method: 'POST',
882
+ path: api('/runtime-capability-runbook/replay-schedule/tick'),
883
+ handler: async (req, res) => {
884
+ try {
885
+ const body = await readBody(req);
886
+ const payload = body.trim() ? JSON.parse(body) : {};
887
+ const result = runtimeRunbookOps?.tickReplaySchedule
888
+ ? await runtimeRunbookOps.tickReplaySchedule(payload)
889
+ : await knowledgeLearningPlatform.tickRuntimeCapabilityReplaySchedule();
890
+ ok(res, { result });
891
+ }
892
+ catch (e) {
893
+ fail(res, e, 'POST /api/knowledge/runtime-capability-runbook/replay-schedule/tick');
894
+ }
895
+ },
896
+ },
897
+ {
898
+ method: 'POST',
899
+ path: api('/session/orchestration/config'),
900
+ handler: async (req, res) => {
901
+ try {
902
+ const body = await readBody(req);
903
+ const result = await knowledgeLearningPlatform.updateStudySessionOrchestrationConfig(JSON.parse(body));
904
+ ok(res, { result });
905
+ }
906
+ catch (e) {
907
+ fail(res, e, 'POST /api/knowledge/session/orchestration/config');
908
+ }
909
+ },
910
+ },
911
+ {
912
+ method: 'POST',
913
+ path: api('/conversation-memory/add'),
914
+ handler: async (req, res) => {
915
+ try {
916
+ const body = await readBody(req);
917
+ const result = await knowledgeLearningPlatform.addConversationMemory(JSON.parse(body));
918
+ ok(res, { result });
919
+ }
920
+ catch (e) {
921
+ fail(res, e, 'POST /api/knowledge/conversation-memory/add');
922
+ }
923
+ },
924
+ },
925
+ {
926
+ method: 'POST',
927
+ path: api('/conversation-memory/search'),
928
+ handler: async (req, res) => {
929
+ try {
930
+ const body = await readBody(req);
931
+ const result = await knowledgeLearningPlatform.searchConversationMemory(JSON.parse(body));
932
+ ok(res, { result });
933
+ }
934
+ catch (e) {
935
+ fail(res, e, 'POST /api/knowledge/conversation-memory/search');
936
+ }
937
+ },
938
+ },
939
+ {
940
+ method: 'POST',
941
+ path: api('/conversation-memory/delete'),
942
+ handler: async (req, res) => {
943
+ try {
944
+ const body = await readBody(req);
945
+ const result = await knowledgeLearningPlatform.deleteConversationMemory(JSON.parse(body));
946
+ ok(res, { result });
947
+ }
948
+ catch (e) {
949
+ fail(res, e, 'POST /api/knowledge/conversation-memory/delete');
950
+ }
951
+ },
952
+ },
953
+ {
954
+ method: 'POST',
955
+ path: api('/conversation-memory/feedback'),
956
+ handler: async (req, res) => {
957
+ try {
958
+ const body = await readBody(req);
959
+ const result = await knowledgeLearningPlatform.feedbackConversationMemory(JSON.parse(body));
960
+ ok(res, { result });
961
+ }
962
+ catch (e) {
963
+ fail(res, e, 'POST /api/knowledge/conversation-memory/feedback');
964
+ }
965
+ },
966
+ },
967
+ ];
968
+ }