shieldcortex 3.0.3 → 3.0.4

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 (91) hide show
  1. package/dashboard/.next/standalone/dashboard/.next/BUILD_ID +1 -1
  2. package/dashboard/.next/standalone/dashboard/.next/build-manifest.json +2 -2
  3. package/dashboard/.next/standalone/dashboard/.next/prerender-manifest.json +3 -3
  4. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.html +2 -2
  5. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.rsc +1 -1
  6. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.html +1 -1
  13. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.rsc +2 -2
  14. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  15. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  16. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  17. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  19. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  20. package/dashboard/.next/standalone/dashboard/.next/server/app/index.html +1 -1
  21. package/dashboard/.next/standalone/dashboard/.next/server/app/index.rsc +3 -3
  22. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  23. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_full.segment.rsc +3 -3
  24. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_head.segment.rsc +1 -1
  25. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_index.segment.rsc +2 -2
  26. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  27. package/dashboard/.next/standalone/dashboard/.next/server/app/page/react-loadable-manifest.json +1 -1
  28. package/dashboard/.next/standalone/dashboard/.next/server/app/page_client-reference-manifest.js +1 -1
  29. package/dashboard/.next/standalone/dashboard/.next/server/chunks/ssr/dashboard_3051539d._.js +1 -1
  30. package/dashboard/.next/standalone/dashboard/.next/server/pages/404.html +1 -1
  31. package/dashboard/.next/standalone/dashboard/.next/server/pages/500.html +2 -2
  32. package/dashboard/.next/standalone/dashboard/.next/server/server-reference-manifest.js +1 -1
  33. package/dashboard/.next/standalone/dashboard/.next/server/server-reference-manifest.json +1 -1
  34. package/dashboard/.next/standalone/dashboard/.next/static/chunks/313c0d327bbf244a.js +9 -0
  35. package/dashboard/.next/standalone/dashboard/.next/static/chunks/{fa5217550a8ab9a6.js → 49c1cec591af1460.js} +2 -2
  36. package/dashboard/.next/standalone/dashboard/.next/static/chunks/{f69fd1c5e71fbbfd.js → ca21f348cb163905.js} +1 -1
  37. package/dashboard/.next/standalone/dashboard/.next/static/chunks/f4ca424319f58dc7.css +3 -0
  38. package/dist/api/routes/admin.d.ts +12 -0
  39. package/dist/api/routes/admin.js +502 -0
  40. package/dist/api/routes/graph.d.ts +4 -0
  41. package/dist/api/routes/graph.js +333 -0
  42. package/dist/api/routes/incidents.d.ts +2 -0
  43. package/dist/api/routes/incidents.js +32 -0
  44. package/dist/api/routes/memories.d.ts +4 -0
  45. package/dist/api/routes/memories.js +659 -0
  46. package/dist/api/routes/recall.d.ts +4 -0
  47. package/dist/api/routes/recall.js +36 -0
  48. package/dist/api/routes/system.d.ts +9 -0
  49. package/dist/api/routes/system.js +201 -0
  50. package/dist/api/visualization-server.js +31 -1913
  51. package/dist/memory/search.d.ts +37 -0
  52. package/dist/memory/search.js +143 -0
  53. package/dist/memory/store.js +2 -166
  54. package/dist/tools/forget.d.ts +2 -2
  55. package/dist/tools/recall.d.ts +2 -2
  56. package/hooks/openclaw/cortex-memory/handler.ts +5 -141
  57. package/hooks/openclaw/cortex-memory/runtime.mjs +129 -0
  58. package/package.json +8 -4
  59. package/plugins/openclaw/dist/index.js +5 -39
  60. package/scripts/run-jest.mjs +25 -1
  61. package/dashboard/.next/standalone/dashboard/.next/static/chunks/be6970da20a17c0b.js +0 -9
  62. package/dashboard/.next/standalone/dashboard/.next/static/chunks/e63d2228780629dd.css +0 -3
  63. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/_tsc.js +0 -133818
  64. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/_tsserver.js +0 -659
  65. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/_typingsInstaller.js +0 -222
  66. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +0 -2122
  67. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/de/diagnosticMessages.generated.json +0 -2122
  68. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/es/diagnosticMessages.generated.json +0 -2122
  69. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +0 -2122
  70. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/it/diagnosticMessages.generated.json +0 -2122
  71. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +0 -2122
  72. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +0 -2122
  73. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +0 -2122
  74. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +0 -2122
  75. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +0 -2122
  76. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +0 -2122
  77. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/tsc.js +0 -8
  78. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/tsserver.js +0 -8
  79. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/tsserverlibrary.js +0 -21
  80. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/typesMap.json +0 -497
  81. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/typescript.js +0 -200276
  82. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/typingsInstaller.js +0 -8
  83. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/watchGuard.js +0 -53
  84. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -2122
  85. package/dashboard/.next/standalone/dashboard/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -2122
  86. package/dashboard/.next/standalone/dashboard/node_modules/typescript/package.json +0 -120
  87. package/scripts/start-dashboard.sh +0 -41
  88. package/scripts/stop-dashboard.sh +0 -21
  89. /package/dashboard/.next/standalone/dashboard/.next/static/{THy6JENQ0c1sq6jQhvIDp → BEvyMAX62LQMyt5iSb-F9}/_buildManifest.js +0 -0
  90. /package/dashboard/.next/standalone/dashboard/.next/static/{THy6JENQ0c1sq6jQhvIDp → BEvyMAX62LQMyt5iSb-F9}/_clientMiddlewareManifest.json +0 -0
  91. /package/dashboard/.next/standalone/dashboard/.next/static/{THy6JENQ0c1sq6jQhvIDp → BEvyMAX62LQMyt5iSb-F9}/_ssgManifest.js +0 -0
@@ -0,0 +1,36 @@
1
+ import { searchMemoriesExplained } from '../../memory/store.js';
2
+ export function registerRecallRoutes(app, requireNotLocked) {
3
+ app.get('/api/recall/explain', requireNotLocked, async (req, res) => {
4
+ try {
5
+ const query = typeof req.query.query === 'string' ? req.query.query.trim() : '';
6
+ if (!query) {
7
+ return res.status(400).json({ error: 'query is required' });
8
+ }
9
+ const project = typeof req.query.project === 'string' ? req.query.project : undefined;
10
+ const type = typeof req.query.type === 'string' ? req.query.type : undefined;
11
+ const category = typeof req.query.category === 'string' ? req.query.category : undefined;
12
+ const limit = Math.min(parseInt(req.query.limit, 10) || 10, 50);
13
+ const includeDecayed = req.query.includeDecayed === 'true';
14
+ const includeGlobal = req.query.includeGlobal !== 'false';
15
+ const results = await searchMemoriesExplained({
16
+ query,
17
+ project,
18
+ type: type,
19
+ category: category,
20
+ limit,
21
+ includeDecayed,
22
+ includeGlobal,
23
+ });
24
+ res.json({
25
+ query,
26
+ project: project ?? null,
27
+ total: results.length,
28
+ sideEffects: 'disabled',
29
+ results,
30
+ });
31
+ }
32
+ catch (error) {
33
+ res.status(500).json({ error: error.message });
34
+ }
35
+ });
36
+ }
@@ -0,0 +1,9 @@
1
+ import type { Express } from 'express';
2
+ import { WebSocket } from 'ws';
3
+ import type { MemoryEvent } from '../events.js';
4
+ interface SystemRouteDeps {
5
+ broadcast: (event: MemoryEvent) => void;
6
+ clients: Set<WebSocket>;
7
+ }
8
+ export declare function registerSystemRoutes(app: Express, deps: SystemRouteDeps): void;
9
+ export {};
@@ -0,0 +1,201 @@
1
+ import { WebSocket } from 'ws';
2
+ import { getCloudConfig, getDefenceMode, getOpenClawMemoryConfig, isConfigTampered, readRawConfig, setCloudConfig, setDefenceMode, setOpenClawMemoryConfig, } from '../../cloud/config.js';
3
+ import { getQueueStats } from '../../cloud/sync-queue.js';
4
+ import { getControlStatus, isKillSwitchActive, pause, resume } from '../control.js';
5
+ import { checkForUpdates, getCurrentVersion, getRunningVersion, performUpdate, scheduleRestart, } from '../version.js';
6
+ export function registerSystemRoutes(app, deps) {
7
+ const { broadcast, clients } = deps;
8
+ app.get('/api/control/status', (_req, res) => {
9
+ try {
10
+ res.json(getControlStatus());
11
+ }
12
+ catch (error) {
13
+ res.status(500).json({ error: error.message });
14
+ }
15
+ });
16
+ app.post('/api/control/pause', (_req, res) => {
17
+ try {
18
+ if (isKillSwitchActive()) {
19
+ return res.status(409).json({ error: 'Kill switch is active — use /api/iron-dome/resume to deactivate first', code: 'KILL_SWITCH_ACTIVE' });
20
+ }
21
+ pause();
22
+ res.json({ paused: true, message: 'Memory creation paused' });
23
+ }
24
+ catch (error) {
25
+ res.status(500).json({ error: error.message });
26
+ }
27
+ });
28
+ app.post('/api/control/resume', (_req, res) => {
29
+ try {
30
+ if (isKillSwitchActive()) {
31
+ return res.status(409).json({ error: 'Kill switch is active — use /api/iron-dome/resume to deactivate first', code: 'KILL_SWITCH_ACTIVE' });
32
+ }
33
+ resume();
34
+ res.json({ paused: false, message: 'Memory creation resumed' });
35
+ }
36
+ catch (error) {
37
+ res.status(500).json({ error: error.message });
38
+ }
39
+ });
40
+ app.get('/api/cloud/config', (_req, res) => {
41
+ try {
42
+ const config = getCloudConfig();
43
+ res.json({
44
+ enabled: config.cloudEnabled,
45
+ apiKeySet: !!config.cloudApiKey,
46
+ baseUrl: config.cloudBaseUrl,
47
+ openclawMemory: getOpenClawMemoryConfig(),
48
+ });
49
+ }
50
+ catch (error) {
51
+ res.status(500).json({ error: error.message });
52
+ }
53
+ });
54
+ app.post('/api/cloud/config', (req, res) => {
55
+ try {
56
+ const { cloudApiKey, cloudEnabled, cloudBaseUrl, openclawAutoMemory, openclawAutoMemoryDedupe, openclawAutoMemoryNoveltyThreshold, openclawAutoMemoryMaxRecent, } = req.body;
57
+ if (openclawAutoMemory !== undefined && typeof openclawAutoMemory !== 'boolean') {
58
+ return res.status(400).json({ error: 'openclawAutoMemory must be a boolean' });
59
+ }
60
+ if (openclawAutoMemoryDedupe !== undefined && typeof openclawAutoMemoryDedupe !== 'boolean') {
61
+ return res.status(400).json({ error: 'openclawAutoMemoryDedupe must be a boolean' });
62
+ }
63
+ if (openclawAutoMemoryNoveltyThreshold !== undefined &&
64
+ (typeof openclawAutoMemoryNoveltyThreshold !== 'number' || Number.isNaN(openclawAutoMemoryNoveltyThreshold))) {
65
+ return res.status(400).json({ error: 'openclawAutoMemoryNoveltyThreshold must be a number' });
66
+ }
67
+ if (openclawAutoMemoryMaxRecent !== undefined &&
68
+ (typeof openclawAutoMemoryMaxRecent !== 'number' || Number.isNaN(openclawAutoMemoryMaxRecent))) {
69
+ return res.status(400).json({ error: 'openclawAutoMemoryMaxRecent must be a number' });
70
+ }
71
+ setCloudConfig({
72
+ ...(cloudApiKey !== undefined && { cloudApiKey }),
73
+ ...(cloudEnabled !== undefined && { cloudEnabled }),
74
+ ...(cloudBaseUrl !== undefined && { cloudBaseUrl }),
75
+ });
76
+ setOpenClawMemoryConfig({
77
+ ...(openclawAutoMemory !== undefined && { autoMemory: openclawAutoMemory }),
78
+ ...(openclawAutoMemoryDedupe !== undefined && { dedupe: openclawAutoMemoryDedupe }),
79
+ ...(openclawAutoMemoryNoveltyThreshold !== undefined && { noveltyThreshold: openclawAutoMemoryNoveltyThreshold }),
80
+ ...(openclawAutoMemoryMaxRecent !== undefined && { maxRecent: openclawAutoMemoryMaxRecent }),
81
+ });
82
+ const updated = getCloudConfig();
83
+ res.json({
84
+ success: true,
85
+ enabled: updated.cloudEnabled,
86
+ apiKeySet: !!updated.cloudApiKey,
87
+ baseUrl: updated.cloudBaseUrl,
88
+ openclawMemory: getOpenClawMemoryConfig(),
89
+ });
90
+ }
91
+ catch (error) {
92
+ res.status(500).json({ error: error.message });
93
+ }
94
+ });
95
+ app.get('/api/defence/config', (_req, res) => {
96
+ try {
97
+ res.json({ mode: getDefenceMode(), tampered: isConfigTampered() });
98
+ }
99
+ catch (error) {
100
+ res.status(500).json({ error: error.message });
101
+ }
102
+ });
103
+ app.post('/api/defence/config', (req, res) => {
104
+ try {
105
+ const { mode } = req.body;
106
+ const validModes = ['strict', 'balanced', 'permissive'];
107
+ if (!mode || !validModes.includes(mode)) {
108
+ return res.status(400).json({ error: `Invalid mode. Must be one of: ${validModes.join(', ')}` });
109
+ }
110
+ setDefenceMode(mode);
111
+ res.json({ success: true, mode });
112
+ }
113
+ catch (error) {
114
+ res.status(500).json({ error: error.message });
115
+ }
116
+ });
117
+ app.get('/api/cloud/sync-status', (_req, res) => {
118
+ try {
119
+ const config = getCloudConfig();
120
+ const raw = readRawConfig();
121
+ const queue = getQueueStats();
122
+ res.json({
123
+ enabled: config.cloudEnabled,
124
+ apiKeySet: !!config.cloudApiKey,
125
+ lastSyncAt: (typeof raw.lastSyncAt === 'string' ? raw.lastSyncAt : null),
126
+ queue: {
127
+ pending: queue.pending,
128
+ failed: queue.failed,
129
+ },
130
+ });
131
+ }
132
+ catch (error) {
133
+ res.status(500).json({ error: error.message });
134
+ }
135
+ });
136
+ app.get('/api/version', (_req, res) => {
137
+ try {
138
+ const version = getCurrentVersion();
139
+ const runningVersion = getRunningVersion();
140
+ res.json({ version, runningVersion, stale: runningVersion !== version });
141
+ }
142
+ catch (error) {
143
+ res.status(500).json({ error: error.message });
144
+ }
145
+ });
146
+ app.get('/api/version/check', async (req, res) => {
147
+ try {
148
+ res.json(await checkForUpdates(req.query.force === 'true'));
149
+ }
150
+ catch (error) {
151
+ res.status(500).json({ error: error.message });
152
+ }
153
+ });
154
+ app.post('/api/version/update', async (_req, res) => {
155
+ try {
156
+ broadcast({
157
+ type: 'update_started',
158
+ timestamp: new Date().toISOString(),
159
+ data: { message: 'Update in progress...' },
160
+ });
161
+ const result = await performUpdate();
162
+ broadcast({
163
+ type: result.success ? 'update_complete' : 'update_failed',
164
+ timestamp: new Date().toISOString(),
165
+ data: result,
166
+ });
167
+ res.json(result);
168
+ }
169
+ catch (error) {
170
+ res.status(500).json({ error: error.message });
171
+ }
172
+ });
173
+ app.post('/api/version/restart', (_req, res) => {
174
+ try {
175
+ broadcast({
176
+ type: 'server_restarting',
177
+ timestamp: new Date().toISOString(),
178
+ data: { message: 'Server restarting in 3 seconds...' },
179
+ });
180
+ for (const client of clients) {
181
+ try {
182
+ if (client.readyState === WebSocket.OPEN) {
183
+ client.send(JSON.stringify({
184
+ type: 'server_restarting',
185
+ timestamp: new Date().toISOString(),
186
+ data: { reconnectIn: 5000 },
187
+ }));
188
+ }
189
+ }
190
+ catch (error) {
191
+ console.error('[shieldcortex] WebSocket send failed during restart:', error);
192
+ }
193
+ }
194
+ res.json({ success: true, message: 'Server will restart in 3 seconds' });
195
+ scheduleRestart(3000);
196
+ }
197
+ catch (error) {
198
+ res.status(500).json({ error: error.message });
199
+ }
200
+ });
201
+ }