openclaw-sc 5.38.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.
- package/.env.example +13 -0
- package/INSTALL.md +13 -0
- package/LICENSE +233 -0
- package/README.md +123 -0
- package/SECURITY.md +27 -0
- package/index.js +3479 -0
- package/lib/code-review-shared.js +164 -0
- package/lib/config.js +164 -0
- package/lib/constants.js +438 -0
- package/lib/decomposer.js +896 -0
- package/lib/dialog-recall.js +389 -0
- package/lib/env.js +59 -0
- package/lib/level-rules.js +72 -0
- package/lib/log-manager.js +258 -0
- package/lib/preemption.js +278 -0
- package/lib/priority-calc.js +134 -0
- package/lib/prompt-injection.js +748 -0
- package/lib/route-evidence.js +701 -0
- package/lib/shared-fs.js +244 -0
- package/lib/steward-rules.js +648 -0
- package/lib/task-center.js +602 -0
- package/lib/task-chain.js +713 -0
- package/lib/task-checker.js +317 -0
- package/lib/task-profiles.js +255 -0
- package/lib/tcell.js +411 -0
- package/lib/tool-auto-discover.js +522 -0
- package/lib/tool-enrich-subagent.js +375 -0
- package/lib/tool-handlers.js +178 -0
- package/lib/tool-selector.js +459 -0
- package/openclaw.plugin.json +55 -0
- package/package.json +63 -0
- package/security.js +141 -0
- package/tools/bridge.js +3288 -0
- package/tools/dashboard/tk-dashboard.py +262 -0
- package/tools/hippocampus-multi-search.js +1038 -0
- package/tools/hippocampus-sqlite.js +738 -0
- package/tools/hippocampus-store.js +262 -0
- package/tools/mcp-tools.config.json +653 -0
- package/tools/pipeline-engine.js +667 -0
- package/tools/sidecar/_check_tools.py +34 -0
- package/tools/sidecar/sidecar-server.cjs +1360 -0
- package/tools/sidecar/subagent-runner.cjs +1471 -0
- package/tools/system-tools.js +619 -0
- package/vector/README.md +100 -0
- package/vector/usearch-bridge.js +639 -0
- package/vector/usearch-http.js +74 -0
- package/vector/usearch-serve.js +156 -0
- package/workers/worker.js +1419 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* usearch-serve.js - OpenClaw/Codex single-service multi-backend USearch.
|
|
4
|
+
*
|
|
5
|
+
* Port 18793.
|
|
6
|
+
* - POST /query without backend remains compatible and searches OpenClaw only.
|
|
7
|
+
* - POST /query with backend="codex_qa_usearch" searches Codex QA only.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { createServer } from 'http';
|
|
11
|
+
import { DEFAULT_BACKEND_ID, DIM, MODEL_ID, MODEL_SOURCE_REPO, MODEL_VARIANT, listBackends, qdrantBuild, qdrantQuery } from './usearch-bridge.js';
|
|
12
|
+
|
|
13
|
+
const PORT = 18793;
|
|
14
|
+
const CT = 'application/json; charset=utf-8';
|
|
15
|
+
|
|
16
|
+
let _uptime = Date.now();
|
|
17
|
+
let _ready = false;
|
|
18
|
+
let _startupWarning = null;
|
|
19
|
+
let _defaultTotal = 0;
|
|
20
|
+
|
|
21
|
+
function json(res, status, payload) {
|
|
22
|
+
const body = JSON.stringify(payload);
|
|
23
|
+
res.writeHead(status, { 'Content-Type': CT });
|
|
24
|
+
res.end(body);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function readBody(req) {
|
|
28
|
+
return new Promise((resolve) => {
|
|
29
|
+
let body = '';
|
|
30
|
+
req.on('data', (chunk) => { body += chunk; });
|
|
31
|
+
req.on('end', () => resolve(body));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function routeUrl(req) {
|
|
36
|
+
return new URL(req.url || '/', `http://${req.headers.host || '127.0.0.1'}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const server = createServer(async (req, res) => {
|
|
40
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
41
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
42
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
|
43
|
+
|
|
44
|
+
if (req.method === 'OPTIONS') {
|
|
45
|
+
res.writeHead(204);
|
|
46
|
+
res.end();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const url = routeUrl(req);
|
|
51
|
+
|
|
52
|
+
if (req.method === 'GET' && url.pathname === '/health') {
|
|
53
|
+
json(res, 200, {
|
|
54
|
+
status: _ready ? (_startupWarning ? 'degraded' : 'ok') : 'warming',
|
|
55
|
+
service: 'usearch',
|
|
56
|
+
port: PORT,
|
|
57
|
+
uptime: Math.round((Date.now() - _uptime) / 1000),
|
|
58
|
+
backend: DEFAULT_BACKEND_ID,
|
|
59
|
+
dimension: DIM,
|
|
60
|
+
model: MODEL_ID,
|
|
61
|
+
model_variant: MODEL_VARIANT,
|
|
62
|
+
model_source_repo: MODEL_SOURCE_REPO,
|
|
63
|
+
total_vectors: _defaultTotal,
|
|
64
|
+
startup_warning: _startupWarning,
|
|
65
|
+
backends: listBackends(),
|
|
66
|
+
});
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (req.method === 'GET' && url.pathname === '/backends') {
|
|
71
|
+
json(res, 200, {
|
|
72
|
+
service: 'usearch',
|
|
73
|
+
default_backend: DEFAULT_BACKEND_ID,
|
|
74
|
+
dimension: DIM,
|
|
75
|
+
model: MODEL_ID,
|
|
76
|
+
model_variant: MODEL_VARIANT,
|
|
77
|
+
model_source_repo: MODEL_SOURCE_REPO,
|
|
78
|
+
backends: listBackends(),
|
|
79
|
+
});
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (req.method === 'POST' && url.pathname === '/query') {
|
|
84
|
+
if (!_ready) {
|
|
85
|
+
json(res, 503, { error: 'service warming' });
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const raw = await readBody(req);
|
|
90
|
+
const args = raw ? JSON.parse(raw) : {};
|
|
91
|
+
const query = String(args.query || '').trim();
|
|
92
|
+
if (!query) {
|
|
93
|
+
json(res, 400, { error: 'query is required' });
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const backend = args.backend || url.searchParams.get('backend') || DEFAULT_BACKEND_ID;
|
|
97
|
+
const result = await qdrantQuery(query, args.topK || args.top_k || 10, {
|
|
98
|
+
backend,
|
|
99
|
+
timeoutMs: args.timeoutMs || args.timeout_ms || args.timeout,
|
|
100
|
+
});
|
|
101
|
+
if (result.backend === DEFAULT_BACKEND_ID) _defaultTotal = result.total_in_index || _defaultTotal;
|
|
102
|
+
json(res, 200, result);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
json(res, 500, { error: error.message });
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (req.method === 'POST' && url.pathname === '/incremental') {
|
|
110
|
+
if (!_ready) {
|
|
111
|
+
json(res, 503, { error: 'service warming' });
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const raw = await readBody(req);
|
|
116
|
+
const args = raw ? JSON.parse(raw) : {};
|
|
117
|
+
const files = args.files;
|
|
118
|
+
if (!files || files.length === 0) {
|
|
119
|
+
json(res, 400, { error: 'files is required' });
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const backend = args.backend || url.searchParams.get('backend') || DEFAULT_BACKEND_ID;
|
|
123
|
+
const result = await qdrantBuild(files, {
|
|
124
|
+
backend,
|
|
125
|
+
timeoutMs: args.timeoutMs || args.timeout_ms || args.timeout,
|
|
126
|
+
});
|
|
127
|
+
if (result.backend === DEFAULT_BACKEND_ID) _defaultTotal = result.total || _defaultTotal;
|
|
128
|
+
json(res, 200, result);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
json(res, 500, { error: error.message });
|
|
131
|
+
}
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
res.writeHead(404);
|
|
136
|
+
res.end('not found');
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
console.error('[usearch-serve] warming default backend...');
|
|
140
|
+
try {
|
|
141
|
+
const t0 = Date.now();
|
|
142
|
+
const r = await qdrantQuery('__warmup__', 1, { backend: DEFAULT_BACKEND_ID, timeoutMs: 90000 });
|
|
143
|
+
_defaultTotal = r.total_in_index || 0;
|
|
144
|
+
_ready = true;
|
|
145
|
+
_uptime = Date.now();
|
|
146
|
+
console.error(`[usearch-serve] warmup done: backend=${DEFAULT_BACKEND_ID}, total=${_defaultTotal}, ${Math.round((Date.now() - t0) / 1000)}s`);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
_startupWarning = error.message;
|
|
149
|
+
_ready = true;
|
|
150
|
+
_uptime = Date.now();
|
|
151
|
+
console.error(`[usearch-serve] warmup degraded: ${error.message}`);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
server.listen(PORT, '127.0.0.1', () => {
|
|
155
|
+
console.error(`[usearch-serve] HTTP service: http://127.0.0.1:${PORT}`);
|
|
156
|
+
});
|