@evomap/evolver 1.89.20 → 2.0.0-beta.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/README.md +27 -564
- package/bin/evolver-llm-proxy.js +3 -0
- package/bin/evolver-mcp.js +2 -0
- package/bin/evolver-proxy.js +3 -0
- package/bin/evolver.js +4 -0
- package/index.js +1 -3586
- package/package.json +32 -62
- package/CONTRIBUTING.md +0 -19
- package/LICENSE +0 -641
- package/README.ja-JP.md +0 -521
- package/README.ko-KR.md +0 -520
- package/README.zh-CN.md +0 -531
- package/SKILL.md +0 -365
- package/assets/cover.png +0 -0
- package/assets/gep/genes.seed.json +0 -496
- package/conformance/savings-core/constants.json +0 -30
- package/conformance/savings-core/golden-vectors.json +0 -333
- package/scripts/a2a_export.js +0 -63
- package/scripts/a2a_ingest.js +0 -79
- package/scripts/a2a_promote.js +0 -118
- package/scripts/analyze_by_skill.js +0 -121
- package/scripts/build_binaries.js +0 -479
- package/scripts/check-changelog.js +0 -166
- package/scripts/extract_log.js +0 -85
- package/scripts/generate_history.js +0 -75
- package/scripts/gep_append_event.js +0 -96
- package/scripts/gep_personality_report.js +0 -234
- package/scripts/human_report.js +0 -147
- package/scripts/recall-verify-report.js +0 -234
- package/scripts/recover_loop.js +0 -61
- package/scripts/refresh_stars_badge.js +0 -168
- package/scripts/seed-merchants.js +0 -91
- package/scripts/skill2recipes.js +0 -118
- package/scripts/suggest_version.js +0 -89
- package/scripts/validate-modules.js +0 -38
- package/scripts/validate-suite.js +0 -78
- package/skills/_meta/SKILL.md +0 -41
- package/skills/index.json +0 -14
- package/src/adapters/claudeCode.js +0 -194
- package/src/adapters/codex.js +0 -216
- package/src/adapters/cursor.js +0 -91
- package/src/adapters/hookAdapter.js +0 -469
- package/src/adapters/kiro.js +0 -195
- package/src/adapters/opencode.js +0 -326
- package/src/adapters/scripts/_lockPaths.js +0 -74
- package/src/adapters/scripts/_memoryFiltering.js +0 -35
- package/src/adapters/scripts/_runtimePaths.js +0 -440
- package/src/adapters/scripts/evolver-session-end.js +0 -321
- package/src/adapters/scripts/evolver-session-start.js +0 -587
- package/src/adapters/scripts/evolver-signal-detect.js +0 -98
- package/src/adapters/scripts/evolver-task-recall.js +0 -173
- package/src/atp/atpExecute.js +0 -283
- package/src/atp/atpTaskPickup.js +0 -233
- package/src/atp/autoBuyer.js +0 -382
- package/src/atp/autoDeliver.js +0 -215
- package/src/atp/cli.js +0 -354
- package/src/atp/cliAutobuyPrompt.js +0 -154
- package/src/atp/consumerAgent.js +0 -157
- package/src/atp/defaultHandler.js +0 -69
- package/src/atp/heartbeatSignalsHandler.js +0 -254
- package/src/atp/hubClient.js +0 -317
- package/src/atp/index.js +0 -38
- package/src/atp/merchantAgent.js +0 -118
- package/src/atp/protocol.js +0 -41
- package/src/atp/questionComposer.js +0 -133
- package/src/atp/serviceHelper.js +0 -92
- package/src/canary.js +0 -13
- package/src/config.js +0 -351
- package/src/evolve/guards.js +0 -1
- package/src/evolve/pipeline/collect.js +0 -1
- package/src/evolve/pipeline/dispatch.js +0 -1
- package/src/evolve/pipeline/enrich.js +0 -1
- package/src/evolve/pipeline/hub.js +0 -1
- package/src/evolve/pipeline/select.js +0 -1
- package/src/evolve/pipeline/signals.js +0 -1
- package/src/evolve/utils.js +0 -1
- package/src/evolve.js +0 -1
- package/src/experiment/agentRunner.js +0 -229
- package/src/experiment/cli.js +0 -159
- package/src/experiment/comparison.js +0 -233
- package/src/experiment/metrics.js +0 -75
- package/src/forceUpdate.js +0 -991
- package/src/gep/a2a.js +0 -173
- package/src/gep/a2aProtocol.js +0 -1
- package/src/gep/analyzer.js +0 -35
- package/src/gep/antiAbuseTelemetry.js +0 -1
- package/src/gep/assetCallLog.js +0 -197
- package/src/gep/assetStore.js +0 -723
- package/src/gep/assets.js +0 -36
- package/src/gep/autoDistillConv.js +0 -1
- package/src/gep/autoDistillLlm.js +0 -1
- package/src/gep/bridge.js +0 -138
- package/src/gep/candidateEval.js +0 -1
- package/src/gep/candidates.js +0 -1
- package/src/gep/claimNudge.js +0 -121
- package/src/gep/cliContracts.js +0 -1190
- package/src/gep/contentHash.js +0 -1
- package/src/gep/conversationDistiller.js +0 -1
- package/src/gep/conversationSniffer.js +0 -1
- package/src/gep/crypto.js +0 -1
- package/src/gep/curriculum.js +0 -1
- package/src/gep/deviceId.js +0 -1
- package/src/gep/directoryClient.js +0 -115
- package/src/gep/envFingerprint.js +0 -1
- package/src/gep/epigenetics.js +0 -1
- package/src/gep/execBridge.js +0 -1
- package/src/gep/executionTrace.js +0 -291
- package/src/gep/explore.js +0 -1
- package/src/gep/featureFlags.js +0 -121
- package/src/gep/gitOps.js +0 -265
- package/src/gep/hash.js +0 -1
- package/src/gep/hostErrorClassifier.js +0 -34
- package/src/gep/hubFetch.js +0 -1
- package/src/gep/hubReview.js +0 -1
- package/src/gep/hubSearch.js +0 -1
- package/src/gep/hubVerify.js +0 -1
- package/src/gep/idleScheduler.js +0 -400
- package/src/gep/issueReporter.js +0 -416
- package/src/gep/learningSignals.js +0 -1
- package/src/gep/llmReview.js +0 -92
- package/src/gep/localStateAwareness.js +0 -243
- package/src/gep/mailboxTransport.js +0 -119
- package/src/gep/memoryGraph.js +0 -1
- package/src/gep/memoryGraphAdapter.js +0 -1
- package/src/gep/mutation.js +0 -1
- package/src/gep/narrativeMemory.js +0 -1
- package/src/gep/oauthLogin.js +0 -181
- package/src/gep/openPRRegistry.js +0 -1
- package/src/gep/paths.js +0 -522
- package/src/gep/personality.js +0 -1
- package/src/gep/policyCheck.js +0 -1
- package/src/gep/portable.js +0 -103
- package/src/gep/privacyClient.js +0 -235
- package/src/gep/prompt.js +0 -1
- package/src/gep/questionGenerator.js +0 -518
- package/src/gep/recallInject.js +0 -1
- package/src/gep/recallVerifier.js +0 -1
- package/src/gep/reflection.js +0 -1
- package/src/gep/sanitize.js +0 -264
- package/src/gep/savingsCore.js +0 -1
- package/src/gep/schemas/capsule.js +0 -170
- package/src/gep/schemas/gene.js +0 -154
- package/src/gep/schemas/index.js +0 -8
- package/src/gep/schemas/protocol.js +0 -51
- package/src/gep/schemas/task.js +0 -74
- package/src/gep/selector.js +0 -1
- package/src/gep/selfPR.js +0 -469
- package/src/gep/signals.js +0 -776
- package/src/gep/skill2gep.js +0 -1056
- package/src/gep/skill2gepAudit.js +0 -303
- package/src/gep/skill2recipes.js +0 -511
- package/src/gep/skillDistiller.js +0 -1
- package/src/gep/skillPublisher.js +0 -358
- package/src/gep/solidify.js +0 -1
- package/src/gep/strategy.js +0 -1
- package/src/gep/taskReceiver.js +0 -575
- package/src/gep/tokenSavings.js +0 -1
- package/src/gep/trajectoryExport.js +0 -1
- package/src/gep/validationReport.js +0 -55
- package/src/gep/validator/index.js +0 -411
- package/src/gep/validator/reporter.js +0 -210
- package/src/gep/validator/sandboxExecutor.js +0 -480
- package/src/gep/validator/stakeBootstrap.js +0 -357
- package/src/gep/workspaceKeychain.js +0 -1
- package/src/ops/cleanup.js +0 -80
- package/src/ops/commentary.js +0 -60
- package/src/ops/health_check.js +0 -104
- package/src/ops/index.js +0 -11
- package/src/ops/innovation.js +0 -67
- package/src/ops/lifecycle.js +0 -798
- package/src/ops/self_repair.js +0 -76
- package/src/ops/skills_monitor.js +0 -147
- package/src/ops/trigger.js +0 -33
- package/src/proxy/clientSettings.js +0 -405
- package/src/proxy/envelope.js +0 -59
- package/src/proxy/extensions/dmHandler.js +0 -45
- package/src/proxy/extensions/sessionHandler.js +0 -141
- package/src/proxy/extensions/skillUpdater.js +0 -64
- package/src/proxy/extensions/traceControl.js +0 -1
- package/src/proxy/index.js +0 -1395
- package/src/proxy/inject.js +0 -1
- package/src/proxy/lifecycle/manager.js +0 -1568
- package/src/proxy/mailbox/state.js +0 -207
- package/src/proxy/mailbox/store.js +0 -590
- package/src/proxy/router/cache_passthrough.js +0 -26
- package/src/proxy/router/features.js +0 -84
- package/src/proxy/router/gemini_route.js +0 -154
- package/src/proxy/router/messages_route.js +0 -535
- package/src/proxy/router/model_router.js +0 -113
- package/src/proxy/router/models_route.js +0 -52
- package/src/proxy/router/ollama_route.js +0 -103
- package/src/proxy/router/responses_route.js +0 -170
- package/src/proxy/router/vertex_route.js +0 -110
- package/src/proxy/server/http.js +0 -363
- package/src/proxy/server/routes.js +0 -558
- package/src/proxy/server/settings.js +0 -115
- package/src/proxy/sync/engine.js +0 -179
- package/src/proxy/sync/inbound.js +0 -211
- package/src/proxy/sync/outbound.js +0 -320
- package/src/proxy/task/monitor.js +0 -131
- package/src/proxy/trace/extractor.js +0 -1
- package/src/proxy/trace/usage.js +0 -1
- package/src/webui/client/clientJs/assets.js +0 -111
- package/src/webui/client/clientJs/bootstrap.js +0 -92
- package/src/webui/client/clientJs/common.js +0 -77
- package/src/webui/client/clientJs/i18n.js +0 -366
- package/src/webui/client/clientJs/index.js +0 -35
- package/src/webui/client/clientJs/interactions.js +0 -351
- package/src/webui/client/clientJs/overview.js +0 -152
- package/src/webui/client/clientJs/personality.js +0 -285
- package/src/webui/client/clientJs/pipelines.js +0 -330
- package/src/webui/client/indexHtml.js +0 -221
- package/src/webui/client/static.js +0 -23
- package/src/webui/client/stylesCss.js +0 -639
- package/src/webui/client/vendor/README.md +0 -15
- package/src/webui/client/vendor/echarts.min.js +0 -45
- package/src/webui/index.js +0 -14
- package/src/webui/observer/assets.js +0 -146
- package/src/webui/observer/index.js +0 -37
- package/src/webui/observer/interactions.js +0 -127
- package/src/webui/observer/jsonl.js +0 -75
- package/src/webui/observer/paths.js +0 -46
- package/src/webui/observer/personality.js +0 -43
- package/src/webui/observer/pipelineEvents.js +0 -58
- package/src/webui/observer/redact.js +0 -63
- package/src/webui/observer/runs.js +0 -356
- package/src/webui/observer/safety.js +0 -57
- package/src/webui/observer/skills.js +0 -70
- package/src/webui/observer/status.js +0 -71
- package/src/webui/server/http.js +0 -138
- package/src/webui/server/routes.js +0 -41
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const { getRepoRoot, getWorkspaceRoot, getMemoryDir, getEvolutionDir, getSkillsDir, getEvomapDir } = require('./paths');
|
|
6
|
-
|
|
7
|
-
// Lazy resolution via paths.getEvomapDir() — honors EVOLVER_HOME (#114).
|
|
8
|
-
function _nodeIdFile() { return path.join(getEvomapDir(), 'node_id'); }
|
|
9
|
-
function _nodeSecretFile() { return path.join(getEvomapDir(), 'node_secret'); }
|
|
10
|
-
|
|
11
|
-
const A2A_ENV_KEYS = [
|
|
12
|
-
'A2A_NODE_ID',
|
|
13
|
-
'A2A_HUB_URL',
|
|
14
|
-
'A2A_NODE_SECRET',
|
|
15
|
-
'AGENT_NAME',
|
|
16
|
-
'EVOLVE_STRATEGY',
|
|
17
|
-
'WORKER_ENABLED',
|
|
18
|
-
'EVOLVER_SESSION_SCOPE',
|
|
19
|
-
'GITHUB_TOKEN',
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
function _readFileSafe(filePath) {
|
|
23
|
-
try {
|
|
24
|
-
if (!fs.existsSync(filePath)) return null;
|
|
25
|
-
return fs.readFileSync(filePath, 'utf8').trim();
|
|
26
|
-
} catch (_) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function _readJsonSafe(filePath) {
|
|
32
|
-
try {
|
|
33
|
-
if (!fs.existsSync(filePath)) return null;
|
|
34
|
-
const raw = fs.readFileSync(filePath, 'utf8').trim();
|
|
35
|
-
if (!raw) return null;
|
|
36
|
-
return JSON.parse(raw);
|
|
37
|
-
} catch (_) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function _fileExists(filePath) {
|
|
43
|
-
try { return fs.existsSync(filePath); } catch (_) { return false; }
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function _fileSize(filePath) {
|
|
47
|
-
try { return fs.statSync(filePath).size; } catch (_) { return 0; }
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _countDirs(dirPath) {
|
|
51
|
-
try {
|
|
52
|
-
if (!fs.existsSync(dirPath)) return 0;
|
|
53
|
-
return fs.readdirSync(dirPath, { withFileTypes: true })
|
|
54
|
-
.filter(function (d) { return d.isDirectory(); }).length;
|
|
55
|
-
} catch (_) {
|
|
56
|
-
return 0;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function captureNodeIdentity() {
|
|
61
|
-
const lines = [];
|
|
62
|
-
|
|
63
|
-
const nodeId = process.env.A2A_NODE_ID || _readFileSafe(_nodeIdFile());
|
|
64
|
-
if (nodeId) {
|
|
65
|
-
lines.push('- Node ID: ' + nodeId + ' (REGISTERED -- do NOT re-register)');
|
|
66
|
-
} else {
|
|
67
|
-
lines.push('- Node ID: NOT SET (registration may be needed)');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const localNodeIdFile = path.join(getRepoRoot(), '.evomap_node_id');
|
|
71
|
-
if (!nodeId && _fileExists(localNodeIdFile)) {
|
|
72
|
-
const localId = _readFileSafe(localNodeIdFile);
|
|
73
|
-
if (localId) {
|
|
74
|
-
lines.push('- Local node_id fallback: ' + localId + ' (found at ' + localNodeIdFile + ')');
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const hasSecret = !!process.env.A2A_NODE_SECRET || _fileExists(_nodeSecretFile());
|
|
79
|
-
if (hasSecret) {
|
|
80
|
-
lines.push('- Node Secret: PRESENT (authenticated -- do NOT request new secret)');
|
|
81
|
-
} else {
|
|
82
|
-
lines.push('- Node Secret: MISSING (hello handshake may be needed)');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return lines;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function captureEnvConfig() {
|
|
89
|
-
const lines = [];
|
|
90
|
-
const configured = [];
|
|
91
|
-
const missing = [];
|
|
92
|
-
|
|
93
|
-
for (var i = 0; i < A2A_ENV_KEYS.length; i++) {
|
|
94
|
-
var key = A2A_ENV_KEYS[i];
|
|
95
|
-
var val = process.env[key];
|
|
96
|
-
if (val !== undefined && val !== '') {
|
|
97
|
-
configured.push(key);
|
|
98
|
-
} else {
|
|
99
|
-
missing.push(key);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (configured.length > 0) {
|
|
104
|
-
lines.push('- Env configured: ' + configured.join(', '));
|
|
105
|
-
}
|
|
106
|
-
if (missing.length > 0) {
|
|
107
|
-
lines.push('- Env not set: ' + missing.join(', '));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const repoRoot = getRepoRoot();
|
|
111
|
-
const envFile = path.join(repoRoot, '.env');
|
|
112
|
-
if (_fileExists(envFile)) {
|
|
113
|
-
lines.push('- .env file: EXISTS at ' + envFile);
|
|
114
|
-
} else {
|
|
115
|
-
lines.push('- .env file: MISSING at ' + envFile);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return lines;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function captureEvolutionState() {
|
|
122
|
-
const lines = [];
|
|
123
|
-
const evoDir = getEvolutionDir();
|
|
124
|
-
|
|
125
|
-
const statePath = path.join(evoDir, 'evolution_state.json');
|
|
126
|
-
const state = _readJsonSafe(statePath);
|
|
127
|
-
if (state) {
|
|
128
|
-
lines.push('- Evolution cycles completed: ' + (state.cycleCount || 0));
|
|
129
|
-
if (state.lastRun) {
|
|
130
|
-
var ago = Math.round((Date.now() - state.lastRun) / 1000);
|
|
131
|
-
lines.push('- Last evolution run: ' + ago + 's ago');
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
lines.push('- Evolution state: NOT FOUND (first run?)');
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const solidifyPath = path.join(evoDir, 'evolution_solidify_state.json');
|
|
138
|
-
const solidifyState = _readJsonSafe(solidifyPath);
|
|
139
|
-
if (solidifyState && solidifyState.last_run) {
|
|
140
|
-
var lr = solidifyState.last_run;
|
|
141
|
-
lines.push('- Last run gene: ' + (lr.selected_gene_id || 'none'));
|
|
142
|
-
if (lr.active_task_title) {
|
|
143
|
-
lines.push('- Active task: ' + lr.active_task_title);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const personalityPath = path.join(evoDir, 'personality_state.json');
|
|
148
|
-
const personality = _readJsonSafe(personalityPath);
|
|
149
|
-
if (personality && personality.current) {
|
|
150
|
-
var p = personality.current;
|
|
151
|
-
lines.push('- Personality: rigor=' + (p.rigor || 0) +
|
|
152
|
-
' creativity=' + (p.creativity || 0) +
|
|
153
|
-
' risk_tolerance=' + (p.risk_tolerance || 0));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return lines;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function captureMemoryState() {
|
|
160
|
-
const lines = [];
|
|
161
|
-
const memDir = getMemoryDir();
|
|
162
|
-
|
|
163
|
-
if (_fileExists(memDir)) {
|
|
164
|
-
lines.push('- Memory directory: EXISTS at ' + memDir);
|
|
165
|
-
} else {
|
|
166
|
-
lines.push('- Memory directory: MISSING');
|
|
167
|
-
return lines;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const memoryMd = path.join(memDir, 'MEMORY.md');
|
|
171
|
-
if (_fileExists(memoryMd)) {
|
|
172
|
-
lines.push('- MEMORY.md: ' + _fileSize(memoryMd) + ' bytes');
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const evoDir = getEvolutionDir();
|
|
176
|
-
const graphPath = path.join(evoDir, 'memory_graph.jsonl');
|
|
177
|
-
if (_fileExists(graphPath)) {
|
|
178
|
-
lines.push('- Memory graph: ' + _fileSize(graphPath) + ' bytes');
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const narrativePath = path.join(evoDir, 'evolution_narrative.md');
|
|
182
|
-
if (_fileExists(narrativePath)) {
|
|
183
|
-
lines.push('- Evolution narrative: EXISTS');
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return lines;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function captureSkillsState() {
|
|
190
|
-
const lines = [];
|
|
191
|
-
const skillsDir = getSkillsDir();
|
|
192
|
-
|
|
193
|
-
if (_fileExists(skillsDir)) {
|
|
194
|
-
var count = _countDirs(skillsDir);
|
|
195
|
-
lines.push('- Installed skills: ' + count + ' (at ' + skillsDir + ')');
|
|
196
|
-
} else {
|
|
197
|
-
lines.push('- Skills directory: NOT FOUND');
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return lines;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function captureLocalState() {
|
|
204
|
-
var sections = [];
|
|
205
|
-
|
|
206
|
-
sections.push('[Node Identity]');
|
|
207
|
-
sections = sections.concat(captureNodeIdentity());
|
|
208
|
-
|
|
209
|
-
sections.push('[Environment Config]');
|
|
210
|
-
sections = sections.concat(captureEnvConfig());
|
|
211
|
-
|
|
212
|
-
sections.push('[Evolution State]');
|
|
213
|
-
sections = sections.concat(captureEvolutionState());
|
|
214
|
-
|
|
215
|
-
sections.push('[Memory & Knowledge]');
|
|
216
|
-
sections = sections.concat(captureMemoryState());
|
|
217
|
-
|
|
218
|
-
sections.push('[Skills]');
|
|
219
|
-
sections = sections.concat(captureSkillsState());
|
|
220
|
-
|
|
221
|
-
return sections.join('\n');
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function captureLocalStatePaths() {
|
|
225
|
-
return {
|
|
226
|
-
nodeIdFile: _nodeIdFile(),
|
|
227
|
-
nodeSecretFile: _nodeSecretFile(),
|
|
228
|
-
envFile: path.join(getRepoRoot(), '.env'),
|
|
229
|
-
memoryDir: getMemoryDir(),
|
|
230
|
-
evolutionDir: getEvolutionDir(),
|
|
231
|
-
skillsDir: getSkillsDir(),
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
module.exports = {
|
|
236
|
-
captureLocalState,
|
|
237
|
-
captureLocalStatePaths,
|
|
238
|
-
captureNodeIdentity,
|
|
239
|
-
captureEnvConfig,
|
|
240
|
-
captureEvolutionState,
|
|
241
|
-
captureMemoryState,
|
|
242
|
-
captureSkillsState,
|
|
243
|
-
};
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const http = require('http');
|
|
4
|
-
const { getProxyUrl, getProxyToken } = require('../proxy/server/settings');
|
|
5
|
-
|
|
6
|
-
// Bounded keep-alive agent. Default `agent: undefined` would use Node's
|
|
7
|
-
// global `http.globalAgent` whose default keep-alive timeout is 8 seconds
|
|
8
|
-
// AND survives macOS sleep on libuv's monotonic clock. After the laptop
|
|
9
|
-
// resumes, the next request reuses a socket the proxy / local OS has
|
|
10
|
-
// already closed and only fails after `timeout: 10_000` -- enough time
|
|
11
|
-
// for the proxy-mode heartbeat to look stalled.
|
|
12
|
-
//
|
|
13
|
-
// Round-6 (§19.8): the previous value was 1000ms keepAliveMsecs, which
|
|
14
|
-
// was wrong for two reasons:
|
|
15
|
-
// 1. NAT eviction in residential / corporate networks is 300-900s,
|
|
16
|
-
// not 1s. The 1s window was cargo-culted from browser keep-alive
|
|
17
|
-
// defaults and gives zero real NAT-eviction protection for the
|
|
18
|
-
// proxy is on localhost (NAT does not apply).
|
|
19
|
-
// 2. A 1s window forces a fresh TCP+TLS handshake on every request
|
|
20
|
-
// that lands >=1s after the previous one, which is essentially
|
|
21
|
-
// every request in steady state -- adding 10-50ms per call for
|
|
22
|
-
// no gain. Locally the proxy is the only consumer; the real
|
|
23
|
-
// sleep/wake risk is covered by the explicit
|
|
24
|
-
// drainPool/wake-recovery path on the undici agent used for hub
|
|
25
|
-
// traffic, NOT this localhost agent.
|
|
26
|
-
// 30s window balances:
|
|
27
|
-
// - keep-alive reuse for legitimate proxy-mode bursts (proxy clients
|
|
28
|
-
// issue heartbeat + mailbox poll + receive within sub-second)
|
|
29
|
-
// - guarantees a fresh socket post-wake (longer-than-30s sleep ->
|
|
30
|
-
// pool is empty by definition; shorter sleep -> proxy on
|
|
31
|
-
// localhost would not have lost the socket anyway)
|
|
32
|
-
const _proxyAgent = new http.Agent({
|
|
33
|
-
keepAlive: true,
|
|
34
|
-
keepAliveMsecs: 30_000,
|
|
35
|
-
maxSockets: 16,
|
|
36
|
-
maxFreeSockets: 4,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
function _request(method, path, body) {
|
|
40
|
-
const proxyUrl = getProxyUrl();
|
|
41
|
-
if (!proxyUrl) {
|
|
42
|
-
return Promise.reject(new Error('Proxy not running (no url in settings.json)'));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const url = new URL(path, proxyUrl);
|
|
46
|
-
|
|
47
|
-
return new Promise((resolve, reject) => {
|
|
48
|
-
const payload = body ? JSON.stringify(body) : '';
|
|
49
|
-
const token = getProxyToken();
|
|
50
|
-
const headers = {
|
|
51
|
-
'Content-Type': 'application/json',
|
|
52
|
-
'Content-Length': Buffer.byteLength(payload),
|
|
53
|
-
};
|
|
54
|
-
if (token) headers['Authorization'] = 'Bearer ' + token;
|
|
55
|
-
const req = http.request(
|
|
56
|
-
{
|
|
57
|
-
hostname: url.hostname,
|
|
58
|
-
port: url.port,
|
|
59
|
-
path: url.pathname,
|
|
60
|
-
method,
|
|
61
|
-
headers,
|
|
62
|
-
timeout: 10_000,
|
|
63
|
-
agent: _proxyAgent,
|
|
64
|
-
},
|
|
65
|
-
(res) => {
|
|
66
|
-
const chunks = [];
|
|
67
|
-
res.on('data', (c) => chunks.push(c));
|
|
68
|
-
res.on('end', () => {
|
|
69
|
-
const raw = Buffer.concat(chunks).toString();
|
|
70
|
-
try {
|
|
71
|
-
resolve(JSON.parse(raw));
|
|
72
|
-
} catch {
|
|
73
|
-
resolve({ raw });
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
req.on('error', reject);
|
|
79
|
-
req.on('timeout', () => {
|
|
80
|
-
req.destroy();
|
|
81
|
-
reject(new Error('Proxy request timeout'));
|
|
82
|
-
});
|
|
83
|
-
if (payload) req.write(payload);
|
|
84
|
-
req.end();
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function mailboxTransportSend(message) {
|
|
89
|
-
const type = message.message_type || message.type || 'unknown';
|
|
90
|
-
const payload = message.payload || message;
|
|
91
|
-
return _request('POST', '/mailbox/send', { type, payload });
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function mailboxTransportReceive(opts = {}) {
|
|
95
|
-
return _request('POST', '/mailbox/poll', {
|
|
96
|
-
type: opts.type || null,
|
|
97
|
-
channel: opts.channel || null,
|
|
98
|
-
limit: opts.limit || 20,
|
|
99
|
-
}).then((data) => data.messages || []);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function mailboxTransportList(opts = {}) {
|
|
103
|
-
const type = opts.type || 'hub_event';
|
|
104
|
-
return _request('GET', `/mailbox/list?type=${encodeURIComponent(type)}&limit=${opts.limit || 20}`)
|
|
105
|
-
.then((data) => data.messages || []);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const mailboxTransport = {
|
|
109
|
-
send: mailboxTransportSend,
|
|
110
|
-
receive: mailboxTransportReceive,
|
|
111
|
-
list: mailboxTransportList,
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
function registerMailboxTransport() {
|
|
115
|
-
const { registerTransport } = require('./a2aProtocol');
|
|
116
|
-
registerTransport('mailbox', mailboxTransport);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
module.exports = { mailboxTransport, registerMailboxTransport };
|