@evomap/evolver 1.89.9 → 1.89.11

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 (71) hide show
  1. package/README.ja-JP.md +1 -1
  2. package/README.ko-KR.md +1 -1
  3. package/README.md +2 -1
  4. package/README.zh-CN.md +1 -1
  5. package/assets/cover.png +0 -0
  6. package/index.js +5 -3
  7. package/package.json +1 -1
  8. package/src/adapters/scripts/evolver-session-end.js +18 -37
  9. package/src/atp/atpExecute.js +27 -71
  10. package/src/atp/serviceHelper.js +28 -36
  11. package/src/config.js +17 -0
  12. package/src/evolve/guards.js +1 -1
  13. package/src/evolve/pipeline/collect.js +1 -1
  14. package/src/evolve/pipeline/dispatch.js +1 -1
  15. package/src/evolve/pipeline/enrich.js +1 -1
  16. package/src/evolve/pipeline/hub.js +1 -1
  17. package/src/evolve/pipeline/select.js +1 -1
  18. package/src/evolve/pipeline/signals.js +1 -1
  19. package/src/evolve/utils.js +1 -1
  20. package/src/evolve.js +1 -1
  21. package/src/gep/a2aProtocol.js +1 -1
  22. package/src/gep/antiAbuseTelemetry.js +1 -1
  23. package/src/gep/autoDistillConv.js +1 -1
  24. package/src/gep/autoDistillLlm.js +1 -1
  25. package/src/gep/candidateEval.js +1 -1
  26. package/src/gep/candidates.js +1 -1
  27. package/src/gep/contentHash.js +1 -1
  28. package/src/gep/conversationSniffer.js +1 -1
  29. package/src/gep/crypto.js +1 -1
  30. package/src/gep/curriculum.js +1 -1
  31. package/src/gep/deviceId.js +1 -1
  32. package/src/gep/envFingerprint.js +1 -1
  33. package/src/gep/epigenetics.js +1 -1
  34. package/src/gep/execBridge.js +1 -1
  35. package/src/gep/explore.js +1 -1
  36. package/src/gep/hash.js +1 -1
  37. package/src/gep/hubFetch.js +1 -1
  38. package/src/gep/hubReview.js +1 -1
  39. package/src/gep/hubSearch.js +1 -1
  40. package/src/gep/hubVerify.js +1 -1
  41. package/src/gep/learningSignals.js +1 -1
  42. package/src/gep/memoryGraph.js +1 -1
  43. package/src/gep/memoryGraphAdapter.js +1 -1
  44. package/src/gep/mutation.js +1 -1
  45. package/src/gep/narrativeMemory.js +1 -1
  46. package/src/gep/oauthLogin.js +9 -3
  47. package/src/gep/openPRRegistry.js +1 -1
  48. package/src/gep/personality.js +1 -1
  49. package/src/gep/policyCheck.js +1 -1
  50. package/src/gep/privacyClient.js +10 -9
  51. package/src/gep/prompt.js +1 -1
  52. package/src/gep/recallInject.js +1 -1
  53. package/src/gep/recallVerifier.js +1 -1
  54. package/src/gep/reflection.js +1 -1
  55. package/src/gep/savingsCore.js +1 -1
  56. package/src/gep/selector.js +1 -1
  57. package/src/gep/signals.js +85 -17
  58. package/src/gep/skillDistiller.js +1 -1
  59. package/src/gep/solidify.js +1 -1
  60. package/src/gep/strategy.js +1 -1
  61. package/src/gep/tokenSavings.js +1 -1
  62. package/src/gep/workspaceKeychain.js +1 -1
  63. package/src/proxy/extensions/traceControl.js +1 -1
  64. package/src/proxy/index.js +369 -20
  65. package/src/proxy/inject.js +1 -1
  66. package/src/proxy/router/models_route.js +52 -0
  67. package/src/proxy/router/ollama_route.js +103 -0
  68. package/src/proxy/router/vertex_route.js +110 -0
  69. package/src/proxy/server/routes.js +30 -7
  70. package/src/proxy/trace/extractor.js +1 -1
  71. package/src/proxy/trace/usage.js +1 -1
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ // GET /v1/models — model-list probe passthrough (format-aware routing, no translation). Many clients (codex,
4
+ // opencode, cursor in OpenAI mode, OpenAI/Anthropic SDKs) hit GET /v1/models on startup to validate the endpoint
5
+ // and list models; without a route they get a 404 and may fail to initialize or fall back. Route by the client's
6
+ // intended provider: Anthropic clients send the `anthropic-version` header → Anthropic /v1/models; everyone else
7
+ // → OpenAI /v1/models (the convention's home). Forwarded verbatim to the native upstream, no body, no translation.
8
+ // Not traced: it is a metadata probe, not an LLM call.
9
+
10
+ function detectModelsProvider(headers = {}) {
11
+ const lower = {};
12
+ for (const [k, v] of Object.entries(headers || {})) lower[String(k).toLowerCase()] = v;
13
+ // anthropic-version (and anthropic-beta) are sent by every Anthropic SDK request and by nothing else.
14
+ if (lower['anthropic-version'] || lower['anthropic-beta']) return 'anthropic';
15
+ return 'openai';
16
+ }
17
+
18
+ function buildModelsHandler({ anthropicProxy, openAIProxy, logger } = {}) {
19
+ if (typeof anthropicProxy !== 'function' || typeof openAIProxy !== 'function') {
20
+ throw new Error('buildModelsHandler requires anthropicProxy(path,body,opts) + openAIProxy(path,body,opts)');
21
+ }
22
+ const log = logger || console;
23
+
24
+ return async ({ headers }) => {
25
+ const inboundHeaders = headers || {};
26
+ const provider = detectModelsProvider(inboundHeaders);
27
+ const [proxyFn, reqPath, mode] = provider === 'anthropic'
28
+ ? [anthropicProxy, '/v1/models', 'anthropic']
29
+ : [openAIProxy, '/models', 'openai'];
30
+
31
+ let up;
32
+ try {
33
+ up = await proxyFn(reqPath, null, { method: 'GET', inboundHeaders, upstreamMode: mode });
34
+ } catch (err) {
35
+ const status = Number(err && err.statusCode) || 502;
36
+ return { status, body: { error: (err && err.message) || 'models upstream request failed' } };
37
+ }
38
+
39
+ let raw = '';
40
+ try { raw = up.text ? await up.text() : ''; } catch { raw = ''; }
41
+ let body;
42
+ try {
43
+ body = raw ? JSON.parse(raw) : {};
44
+ } catch {
45
+ log.warn?.(JSON.stringify({ event: 'models_fallback', reason: 'upstream_non_json', upstream_status: up.status }));
46
+ body = { error: raw };
47
+ }
48
+ return { status: up.status, body };
49
+ };
50
+ }
51
+
52
+ module.exports = { buildModelsHandler, detectModelsProvider };
@@ -0,0 +1,103 @@
1
+ 'use strict';
2
+
3
+ // Ollama native passthrough (local/self-hosted model server). Native paths POST /api/chat and /api/generate are
4
+ // forwarded verbatim to the Ollama upstream (EVOMAP_OLLAMA_BASE_URL, default 127.0.0.1:11434). Format-aware, no
5
+ // translation: an Ollama-shaped request goes to Ollama. Streaming is newline-delimited JSON (NDJSON), not SSE —
6
+ // the trace tee scans it the same way. apiPath is fixed per registration (/api/chat vs /api/generate). Ollama is
7
+ // typically auth-less; an optional bearer (EVOMAP_OLLAMA_API_KEY) covers a remote/protected instance.
8
+
9
+ const { createProxyTrace } = require('../trace/extractor');
10
+
11
+ function upstreamStatus(err, fallback = 502) {
12
+ const status = Number(err && err.statusCode);
13
+ return Number.isFinite(status) ? status : fallback;
14
+ }
15
+
16
+ function asUpstreamError(err, fallback = 502) {
17
+ if (err && err.statusCode && /^ollama upstream /.test(err.message || '')) return err;
18
+ const out = new Error('ollama upstream request failed');
19
+ out.statusCode = upstreamStatus(err, fallback);
20
+ out.cause = err;
21
+ return out;
22
+ }
23
+
24
+ function responseToBody(raw, status, headers, log) {
25
+ if (!raw) return {};
26
+ try {
27
+ return JSON.parse(raw);
28
+ } catch {
29
+ log.warn?.(JSON.stringify({
30
+ event: 'ollama_fallback',
31
+ reason: 'upstream_non_json',
32
+ upstream_status: status,
33
+ content_type: (headers && headers['content-type']) || '',
34
+ response_bytes: Buffer.byteLength(raw),
35
+ }));
36
+ return { error: raw };
37
+ }
38
+ }
39
+
40
+ function buildOllamaHandler({ ollamaProxy, logger, traceStore, onTraceQueued, apiPath = '/api/chat' } = {}) {
41
+ if (typeof ollamaProxy !== 'function') {
42
+ throw new Error('buildOllamaHandler requires ollamaProxy(path, body, opts)');
43
+ }
44
+ const log = logger || console;
45
+
46
+ return async ({ body, headers }) => {
47
+ const inboundHeaders = headers || {};
48
+ const originalModel = body && typeof body.model === 'string' ? body.model : null;
49
+
50
+ let trace = null;
51
+ try {
52
+ trace = createProxyTrace({
53
+ route: `POST ${apiPath}`,
54
+ headers: inboundHeaders,
55
+ body,
56
+ upstreamMode: 'ollama',
57
+ originalModel,
58
+ chosenModel: originalModel,
59
+ store: traceStore,
60
+ logger: traceStore ? log : null,
61
+ onTraceQueued,
62
+ });
63
+ } catch (_) { /* best-effort trace; never break the request */ }
64
+
65
+ let upstream;
66
+ try {
67
+ upstream = await ollamaProxy(apiPath, body, { inboundHeaders, upstreamMode: 'ollama' });
68
+ } catch (err) {
69
+ const wrapped = asUpstreamError(err, upstreamStatus(err));
70
+ trace?.record({ status: wrapped.statusCode, error: wrapped, upstreamMode: 'ollama', model: originalModel });
71
+ throw wrapped;
72
+ }
73
+
74
+ if (upstream.stream) {
75
+ const forwardHeaders = {};
76
+ const ct = upstream.headers && upstream.headers['content-type'];
77
+ if (ct) forwardHeaders['Content-Type'] = ct;
78
+ trace?.recordStreamStart({ status: upstream.status, upstreamMode: 'ollama', model: originalModel, headers: forwardHeaders });
79
+ return {
80
+ status: upstream.status,
81
+ // Tee the NDJSON body so the deferred trace captures the final chunk's eval counts + done_reason. Bytes unchanged.
82
+ stream: trace ? trace.observeStream(upstream.stream) : upstream.stream,
83
+ headers: forwardHeaders,
84
+ };
85
+ }
86
+
87
+ let raw = '';
88
+ if (upstream.text) {
89
+ try {
90
+ raw = await upstream.text();
91
+ } catch (err) {
92
+ const wrapped = asUpstreamError(err, upstreamStatus(err));
93
+ trace?.record({ status: wrapped.statusCode, error: wrapped, upstreamMode: 'ollama', model: originalModel });
94
+ throw wrapped;
95
+ }
96
+ }
97
+ const respBody = responseToBody(raw, upstream.status, upstream.headers, log);
98
+ trace?.record({ status: upstream.status, responseBody: respBody, upstreamMode: 'ollama', model: originalModel, headers: upstream.headers });
99
+ return { status: upstream.status, body: respBody };
100
+ };
101
+ }
102
+
103
+ module.exports = { buildOllamaHandler, responseToBody };
@@ -0,0 +1,110 @@
1
+ 'use strict';
2
+
3
+ // Vertex AI Gemini passthrough (enterprise GCP). Same Gemini request/response body as the AI Studio route, but
4
+ // the native Vertex path — POST /v1/projects/<project>/locations/<location>/publishers/google/models/<model>:
5
+ // generateContent | :streamGenerateContent — a region-specific upstream (<location>-aiplatform.googleapis.com),
6
+ // and OAuth Bearer auth (EVOMAP_VERTEX_ACCESS_TOKEN). Forwarded verbatim, no translation. Trace reuses the Gemini
7
+ // shape (usageMetadata + candidates[].finishReason), so only the path + base + auth differ from the AI Studio route.
8
+
9
+ const { createProxyTrace } = require('../trace/extractor');
10
+ const { parseModelAction } = require('./gemini_route');
11
+
12
+ function upstreamStatus(err, fallback = 502) {
13
+ const status = Number(err && err.statusCode);
14
+ return Number.isFinite(status) ? status : fallback;
15
+ }
16
+
17
+ function asUpstreamError(err, fallback = 502) {
18
+ if (err && err.statusCode && /^vertex /.test(err.message || '')) return err;
19
+ const out = new Error('vertex upstream request failed');
20
+ out.statusCode = upstreamStatus(err, fallback);
21
+ out.cause = err;
22
+ return out;
23
+ }
24
+
25
+ function responseToBody(raw, status, headers, log) {
26
+ if (!raw) return {};
27
+ try {
28
+ return JSON.parse(raw);
29
+ } catch {
30
+ log.warn?.(JSON.stringify({
31
+ event: 'vertex_fallback', reason: 'upstream_non_json', upstream_status: status,
32
+ content_type: (headers && headers['content-type']) || '', response_bytes: Buffer.byteLength(raw),
33
+ }));
34
+ return { error: raw };
35
+ }
36
+ }
37
+
38
+ // Region-specific Vertex base. EVOMAP_VERTEX_BASE_URL overrides (e.g. the global aiplatform endpoint); otherwise
39
+ // derive <location>-aiplatform.googleapis.com. `global` uses the un-prefixed host.
40
+ function vertexBaseUrl(location) {
41
+ const override = (process.env.EVOMAP_VERTEX_BASE_URL || '').trim();
42
+ if (override) return override.replace(/\/+$/, '');
43
+ const loc = String(location || '').trim();
44
+ if (!loc || loc === 'global') return 'https://aiplatform.googleapis.com';
45
+ return `https://${loc}-aiplatform.googleapis.com`;
46
+ }
47
+
48
+ function buildVertexHandler({ vertexProxy, logger, traceStore, onTraceQueued } = {}) {
49
+ if (typeof vertexProxy !== 'function') {
50
+ throw new Error('buildVertexHandler requires vertexProxy(path, body, opts)');
51
+ }
52
+ const log = logger || console;
53
+
54
+ return async ({ body, headers, params, query }) => {
55
+ const inboundHeaders = headers || {};
56
+ const project = (params && params.project) || '';
57
+ const location = (params && params.location) || '';
58
+ const modelAction = (params && params.modelAction) || '';
59
+ const { model } = parseModelAction(modelAction);
60
+ const baseUrl = vertexBaseUrl(location);
61
+ const qs = query && Object.keys(query).length ? '?' + new URLSearchParams(query).toString() : '';
62
+ const reqPath = `/v1/projects/${project}/locations/${location}/publishers/google/models/${modelAction}${qs}`;
63
+
64
+ let trace = null;
65
+ try {
66
+ trace = createProxyTrace({
67
+ route: `POST /v1/projects/${project}/locations/${location}/publishers/google/models/${modelAction}`,
68
+ headers: inboundHeaders, body, upstreamMode: 'vertex', originalModel: model, chosenModel: model,
69
+ store: traceStore, logger: traceStore ? log : null, onTraceQueued,
70
+ });
71
+ } catch (_) { /* best-effort trace */ }
72
+
73
+ let upstream;
74
+ try {
75
+ upstream = await vertexProxy(reqPath, body, { baseUrl, inboundHeaders, upstreamMode: 'vertex' });
76
+ } catch (err) {
77
+ const wrapped = asUpstreamError(err, upstreamStatus(err));
78
+ trace?.record({ status: wrapped.statusCode, error: wrapped, upstreamMode: 'vertex', model });
79
+ throw wrapped;
80
+ }
81
+
82
+ if (upstream.stream) {
83
+ const forwardHeaders = {};
84
+ const ct = upstream.headers && upstream.headers['content-type'];
85
+ if (ct) forwardHeaders['Content-Type'] = ct;
86
+ trace?.recordStreamStart({ status: upstream.status, upstreamMode: 'vertex', model, headers: forwardHeaders });
87
+ return {
88
+ status: upstream.status,
89
+ stream: trace ? trace.observeStream(upstream.stream) : upstream.stream,
90
+ headers: forwardHeaders,
91
+ };
92
+ }
93
+
94
+ let raw = '';
95
+ if (upstream.text) {
96
+ try {
97
+ raw = await upstream.text();
98
+ } catch (err) {
99
+ const wrapped = asUpstreamError(err, upstreamStatus(err));
100
+ trace?.record({ status: wrapped.statusCode, error: wrapped, upstreamMode: 'vertex', model });
101
+ throw wrapped;
102
+ }
103
+ }
104
+ const respBody = responseToBody(raw, upstream.status, upstream.headers, log);
105
+ trace?.record({ status: upstream.status, responseBody: respBody, upstreamMode: 'vertex', model, headers: upstream.headers });
106
+ return { status: upstream.status, body: respBody };
107
+ };
108
+ }
109
+
110
+ module.exports = { buildVertexHandler, vertexBaseUrl };
@@ -12,6 +12,10 @@ function buildRoutes(store, proxyHandlers, taskMonitor, extensions) {
12
12
  responsesHandler,
13
13
  geminiHandler,
14
14
  chatCompletionsHandler,
15
+ modelsHandler,
16
+ ollamaChatHandler,
17
+ ollamaGenerateHandler,
18
+ vertexHandler,
15
19
  } = extensions || {};
16
20
  const routes = {
17
21
  // -- Mailbox --
@@ -82,14 +86,17 @@ function buildRoutes(store, proxyHandlers, taskMonitor, extensions) {
82
86
  },
83
87
 
84
88
  'POST /asset/submit': async ({ body }) => {
85
- if (!body.assets && !body.asset_id) {
86
- throw Object.assign(new Error('assets or asset_id is required'), { statusCode: 400 });
89
+ // The publish path builds a bundle from full asset objects; a bare
90
+ // asset_id is not a valid input here (Bugbot #256 Medium — route used to
91
+ // accept asset_id the handler then ignored).
92
+ if (!body.assets && !body.asset) {
93
+ throw Object.assign(new Error('assets (array) or asset (single object) is required'), { statusCode: 400 });
87
94
  }
88
- const result = store.send({
89
- type: 'asset_submit',
90
- payload: body,
91
- priority: body.priority || 'normal',
92
- });
95
+ // Publish synchronously via the signed Gene+Capsule bundle path
96
+ // (POST /a2a/publish). The old `asset_submit` mailbox dispatch is gated
97
+ // off at the Hub (A2A_MAILBOX_ASSET_SUBMIT_ENABLED), so it silently
98
+ // failed; the Hub now enforces bundles. Returns the per-asset Hub result.
99
+ const result = await proxyHandlers.assetPublish(body);
93
100
  return { body: result };
94
101
  },
95
102
 
@@ -487,6 +494,22 @@ function buildRoutes(store, proxyHandlers, taskMonitor, extensions) {
487
494
  // OpenAI Chat Completions ingress (cursor's OpenAI mode + generic OpenAI clients) → OpenAI upstream.
488
495
  routes['POST /v1/chat/completions'] = chatCompletionsHandler;
489
496
  }
497
+ if (modelsHandler) {
498
+ // Model-list probe (codex/opencode/cursor/SDKs hit it on startup) → routed by anthropic-version header to
499
+ // the Anthropic or OpenAI upstream's /v1/models, so the probe never 404s.
500
+ routes['GET /v1/models'] = modelsHandler;
501
+ }
502
+ if (ollamaChatHandler) {
503
+ // Ollama native ingress (local/self-hosted models) → Ollama upstream, NDJSON streaming.
504
+ routes['POST /api/chat'] = ollamaChatHandler;
505
+ }
506
+ if (ollamaGenerateHandler) {
507
+ routes['POST /api/generate'] = ollamaGenerateHandler;
508
+ }
509
+ if (vertexHandler) {
510
+ // Vertex AI Gemini native path: project/location/model:action across fixed segments + :modelAction.
511
+ routes['POST /v1/projects/:project/locations/:location/publishers/google/models/:modelAction'] = vertexHandler;
512
+ }
490
513
 
491
514
  return routes;
492
515
  }