@evomap/evolver 1.90.0 → 2.0.0-beta.1
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 -3670
- 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/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 -602
- 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 -361
- 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/solo/breaker.js +0 -25
- package/src/solo/gitGuard.js +0 -65
- 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
package/src/gep/schemas/gene.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// Gene Schema — single source of truth for the Gene object shape.
|
|
5
|
-
// All modules that create or consume Gene objects should use createGene() and
|
|
6
|
-
// validateGene() rather than assuming field presence inline.
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
const VALID_CATEGORIES = ['repair', 'optimize', 'innovate', 'explore'];
|
|
10
|
-
|
|
11
|
-
// EvoX agent-core enums consumed via the gene → router/tool-gate
|
|
12
|
-
// pipeline (`crates/evox-evo-session/src/lifecycle.rs:345-388`). Keep
|
|
13
|
-
// these strings exact — the Rust side does case-sensitive matching.
|
|
14
|
-
const VALID_ROUTING_TIERS = ['cheap', 'mid', 'expensive'];
|
|
15
|
-
const VALID_REASONING_LEVELS = ['off', 'low', 'medium', 'high'];
|
|
16
|
-
const VALID_TOOL_POLICY_SEVERITIES = ['warn', 'block'];
|
|
17
|
-
|
|
18
|
-
const GENE_DEFAULTS = {
|
|
19
|
-
type: 'Gene',
|
|
20
|
-
id: null,
|
|
21
|
-
category: 'innovate',
|
|
22
|
-
signals_match: [],
|
|
23
|
-
strategy: [],
|
|
24
|
-
validation: [],
|
|
25
|
-
constraints: {
|
|
26
|
-
max_files: 20,
|
|
27
|
-
forbidden_paths: ['.git', 'node_modules'],
|
|
28
|
-
},
|
|
29
|
-
preconditions: [],
|
|
30
|
-
summary: '',
|
|
31
|
-
schema_version: '1.6.0',
|
|
32
|
-
epigenetic_marks: [],
|
|
33
|
-
learning_history: [],
|
|
34
|
-
anti_patterns: [],
|
|
35
|
-
// Optional EvoX-side hints. Null = "no opinion, let the router /
|
|
36
|
-
// tool dispatcher take its historical fast path". Genes that
|
|
37
|
-
// genuinely benefit from cheap-tier classification or restricted
|
|
38
|
-
// tools opt in by setting these to a non-null object.
|
|
39
|
-
routing_hint: null,
|
|
40
|
-
tool_policy: null,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// createGene: merge partial with defaults and normalize array/object fields.
|
|
44
|
-
// Safe to call with a fully-formed Gene (idempotent).
|
|
45
|
-
function createGene(partial) {
|
|
46
|
-
const g = Object.assign({}, GENE_DEFAULTS, partial);
|
|
47
|
-
|
|
48
|
-
// Always create fresh array copies — never hold references to GENE_DEFAULTS arrays
|
|
49
|
-
// or to partial's arrays, so downstream .push() calls cannot contaminate other genes.
|
|
50
|
-
g.signals_match = Array.isArray(g.signals_match) ? g.signals_match.slice() : [];
|
|
51
|
-
g.strategy = Array.isArray(g.strategy) ? g.strategy.slice() : [];
|
|
52
|
-
g.validation = Array.isArray(g.validation) ? g.validation.slice() : [];
|
|
53
|
-
g.preconditions = Array.isArray(g.preconditions) ? g.preconditions.slice() : [];
|
|
54
|
-
g.epigenetic_marks = Array.isArray(g.epigenetic_marks) ? g.epigenetic_marks.slice() : [];
|
|
55
|
-
g.learning_history = Array.isArray(g.learning_history) ? g.learning_history.slice() : [];
|
|
56
|
-
g.anti_patterns = Array.isArray(g.anti_patterns) ? g.anti_patterns.slice() : [];
|
|
57
|
-
|
|
58
|
-
// Normalize constraints
|
|
59
|
-
if (!g.constraints || typeof g.constraints !== 'object') {
|
|
60
|
-
g.constraints = Object.assign({}, GENE_DEFAULTS.constraints);
|
|
61
|
-
} else {
|
|
62
|
-
g.constraints = Object.assign({}, GENE_DEFAULTS.constraints, g.constraints);
|
|
63
|
-
}
|
|
64
|
-
if (!Array.isArray(g.constraints.forbidden_paths) || g.constraints.forbidden_paths.length === 0) {
|
|
65
|
-
g.constraints.forbidden_paths = ['.git', 'node_modules'];
|
|
66
|
-
} else {
|
|
67
|
-
g.constraints.forbidden_paths = g.constraints.forbidden_paths.slice();
|
|
68
|
-
}
|
|
69
|
-
if (!g.constraints.max_files || typeof g.constraints.max_files !== 'number') {
|
|
70
|
-
g.constraints.max_files = GENE_DEFAULTS.constraints.max_files;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Normalize category
|
|
74
|
-
if (!g.category || !VALID_CATEGORIES.includes(g.category)) {
|
|
75
|
-
g.category = GENE_DEFAULTS.category;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Normalize string fields
|
|
79
|
-
if (typeof g.summary !== 'string') g.summary = '';
|
|
80
|
-
if (typeof g.schema_version !== 'string') g.schema_version = GENE_DEFAULTS.schema_version;
|
|
81
|
-
|
|
82
|
-
// Normalize optional routing_hint / tool_policy. The EvoX agent-core
|
|
83
|
-
// side (`crates/evox-evo-session/src/lifecycle.rs`) treats absent
|
|
84
|
-
// *or* empty hints as "no opinion" via `GeneRoutingHint::is_empty()`,
|
|
85
|
-
// so dropping malformed fragments to `null` is the safer default —
|
|
86
|
-
// a partial object would fail the strict tier-string match on the
|
|
87
|
-
// Rust side and silently route as if no hint existed.
|
|
88
|
-
g.routing_hint = normalizeRoutingHint(g.routing_hint);
|
|
89
|
-
g.tool_policy = normalizeToolPolicy(g.tool_policy);
|
|
90
|
-
|
|
91
|
-
return g;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function normalizeRoutingHint(raw) {
|
|
95
|
-
if (!raw || typeof raw !== 'object') return null;
|
|
96
|
-
const out = {};
|
|
97
|
-
if (raw.tier && VALID_ROUTING_TIERS.includes(String(raw.tier))) {
|
|
98
|
-
out.tier = String(raw.tier);
|
|
99
|
-
}
|
|
100
|
-
if (raw.reasoning_level && VALID_REASONING_LEVELS.includes(String(raw.reasoning_level))) {
|
|
101
|
-
out.reasoning_level = String(raw.reasoning_level);
|
|
102
|
-
}
|
|
103
|
-
return Object.keys(out).length > 0 ? out : null;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function normalizeToolPolicy(raw) {
|
|
107
|
-
if (!raw || typeof raw !== 'object') return null;
|
|
108
|
-
const out = {};
|
|
109
|
-
// Filter falsy entries first, then only keep the field if anything
|
|
110
|
-
// survives. A raw input like { allow_only: ['', ''] } would otherwise
|
|
111
|
-
// emit `allow_only: []` here; on the Rust executor gate
|
|
112
|
-
// (`crates/evox-agent-core/src/types.rs::ToolGate`) an empty
|
|
113
|
-
// `allow_only` means "allow zero tools" and blocks every tool call.
|
|
114
|
-
if (Array.isArray(raw.allow_only)) {
|
|
115
|
-
const cleaned = raw.allow_only.map(String).filter(Boolean);
|
|
116
|
-
if (cleaned.length > 0) out.allow_only = cleaned;
|
|
117
|
-
}
|
|
118
|
-
if (Array.isArray(raw.deny)) {
|
|
119
|
-
const cleaned = raw.deny.map(String).filter(Boolean);
|
|
120
|
-
if (cleaned.length > 0) out.deny = cleaned;
|
|
121
|
-
}
|
|
122
|
-
// severity defaults to 'warn' when omitted but a list is present —
|
|
123
|
-
// matches `GeneToolPolicy::default_severity()` on the Rust side.
|
|
124
|
-
const hasList = !!(out.allow_only || out.deny);
|
|
125
|
-
if (hasList) {
|
|
126
|
-
out.severity = VALID_TOOL_POLICY_SEVERITIES.includes(String(raw.severity))
|
|
127
|
-
? String(raw.severity)
|
|
128
|
-
: 'warn';
|
|
129
|
-
}
|
|
130
|
-
return hasList ? out : null;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// validateGene: throw if required fields are missing or malformed.
|
|
134
|
-
// Use before broadcasting/publishing a Gene to the Hub or writing to disk.
|
|
135
|
-
function validateGene(g) {
|
|
136
|
-
if (!g || typeof g !== 'object') throw new Error('Gene must be an object');
|
|
137
|
-
if (g.type !== 'Gene') throw new Error('Gene.type must be "Gene", got: ' + g.type);
|
|
138
|
-
if (!g.id || typeof g.id !== 'string') throw new Error('Gene.id is required and must be a string');
|
|
139
|
-
if (!VALID_CATEGORIES.includes(g.category))
|
|
140
|
-
throw new Error('Gene.category must be one of: ' + VALID_CATEGORIES.join(', ') + ', got: ' + g.category);
|
|
141
|
-
if (!Array.isArray(g.signals_match)) throw new Error('Gene.signals_match must be an array');
|
|
142
|
-
if (!Array.isArray(g.strategy)) throw new Error('Gene.strategy must be an array');
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
module.exports = {
|
|
147
|
-
createGene,
|
|
148
|
-
validateGene,
|
|
149
|
-
GENE_DEFAULTS,
|
|
150
|
-
VALID_CATEGORIES,
|
|
151
|
-
VALID_ROUTING_TIERS,
|
|
152
|
-
VALID_REASONING_LEVELS,
|
|
153
|
-
VALID_TOOL_POLICY_SEVERITIES,
|
|
154
|
-
};
|
package/src/gep/schemas/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// Protocol Schema — single source of truth for ALL string literal enums that
|
|
5
|
-
// appear both in code (validation/normalization) and in the LLM prompt schema.
|
|
6
|
-
//
|
|
7
|
-
// Why this file exists: prior to 2026-05-16 the GEP prompt template (prompt.js)
|
|
8
|
-
// hardcoded its own copies of category/intent/risk_level/outcome.status enums.
|
|
9
|
-
// They drifted from src/gep/schemas/gene.js's VALID_CATEGORIES — when 'explore'
|
|
10
|
-
// was added to the engine's whitelist, it was silently dropped from the LLM
|
|
11
|
-
// prompt for months. v1.80.8 patched the literal; this module makes that class
|
|
12
|
-
// of bug structurally impossible by routing every prompt enum through here.
|
|
13
|
-
//
|
|
14
|
-
// Rule: if a string literal enum is referenced both in JS validation code AND
|
|
15
|
-
// in the prompt template, it MUST be defined here. NEVER duplicate it inline.
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
|
|
18
|
-
const {
|
|
19
|
-
VALID_CATEGORIES,
|
|
20
|
-
VALID_ROUTING_TIERS,
|
|
21
|
-
VALID_REASONING_LEVELS,
|
|
22
|
-
VALID_TOOL_POLICY_SEVERITIES,
|
|
23
|
-
} = require('./gene');
|
|
24
|
-
const { VALID_OUTCOME_STATUSES } = require('./capsule');
|
|
25
|
-
|
|
26
|
-
const VALID_RISK_LEVELS = ['low', 'medium', 'high'];
|
|
27
|
-
const VALID_TRACE_STAGES = ['build', 'validate', 'canary'];
|
|
28
|
-
|
|
29
|
-
// renderEnum: format an enum array as a pipe-joined string for prompt schemas.
|
|
30
|
-
// Example: ['repair', 'optimize', ...] -> 'repair|optimize|...'
|
|
31
|
-
function renderEnum(arr) {
|
|
32
|
-
return arr.join('|');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// renderEnumList: format an enum array as a quoted JSON-ish list for prompt schemas.
|
|
36
|
-
// Example: ['build', 'validate', 'canary'] -> '"build","validate","canary"'
|
|
37
|
-
function renderEnumList(arr) {
|
|
38
|
-
return arr.map((s) => '"' + s + '"').join(',');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
module.exports = {
|
|
42
|
-
VALID_CATEGORIES,
|
|
43
|
-
VALID_OUTCOME_STATUSES,
|
|
44
|
-
VALID_RISK_LEVELS,
|
|
45
|
-
VALID_TRACE_STAGES,
|
|
46
|
-
VALID_ROUTING_TIERS,
|
|
47
|
-
VALID_REASONING_LEVELS,
|
|
48
|
-
VALID_TOOL_POLICY_SEVERITIES,
|
|
49
|
-
renderEnum,
|
|
50
|
-
renderEnumList,
|
|
51
|
-
};
|
package/src/gep/schemas/task.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// Task Schema — single source of truth for the Task object shape.
|
|
5
|
-
// Tasks are received from the Hub (not created locally), so createTask()
|
|
6
|
-
// primarily normalizes fields for safe access. validateTask() guards the
|
|
7
|
-
// pipeline entry points before any processing begins.
|
|
8
|
-
// ---------------------------------------------------------------------------
|
|
9
|
-
|
|
10
|
-
const VALID_TASK_STATUSES = ['open', 'claimed', 'completed', 'expired', 'cancelled'];
|
|
11
|
-
|
|
12
|
-
const TASK_DEFAULTS = {
|
|
13
|
-
type: 'Task',
|
|
14
|
-
task_id: null,
|
|
15
|
-
title: '',
|
|
16
|
-
signals: '',
|
|
17
|
-
status: 'open',
|
|
18
|
-
claimed_by: null,
|
|
19
|
-
bounty_id: null,
|
|
20
|
-
bounty_amount: 0,
|
|
21
|
-
complexity_score: null,
|
|
22
|
-
historical_completion_rate: null,
|
|
23
|
-
expires_at: null,
|
|
24
|
-
body: '',
|
|
25
|
-
description: '',
|
|
26
|
-
nonce: null,
|
|
27
|
-
validation_commands: [],
|
|
28
|
-
result_asset_id: null,
|
|
29
|
-
atp_order_id: null,
|
|
30
|
-
_commitment_deadline: null,
|
|
31
|
-
_worker_pending: false,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// createTask: normalize a Hub-received task object against known defaults.
|
|
35
|
-
// Safe to call with a fully-formed Task (idempotent).
|
|
36
|
-
function createTask(partial) {
|
|
37
|
-
const t = Object.assign({}, TASK_DEFAULTS, partial);
|
|
38
|
-
|
|
39
|
-
// Normalize validation_commands — the only array field
|
|
40
|
-
t.validation_commands = Array.isArray(t.validation_commands)
|
|
41
|
-
? t.validation_commands.slice()
|
|
42
|
-
: [];
|
|
43
|
-
|
|
44
|
-
// Normalize string fields
|
|
45
|
-
if (typeof t.title !== 'string') t.title = '';
|
|
46
|
-
if (typeof t.signals !== 'string') t.signals = '';
|
|
47
|
-
if (typeof t.body !== 'string') t.body = '';
|
|
48
|
-
if (typeof t.description !== 'string') t.description = '';
|
|
49
|
-
|
|
50
|
-
// Normalize numeric fields
|
|
51
|
-
if (typeof t.bounty_amount !== 'number' || !isFinite(t.bounty_amount)) {
|
|
52
|
-
t.bounty_amount = 0;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Normalize status
|
|
56
|
-
if (!VALID_TASK_STATUSES.includes(t.status)) {
|
|
57
|
-
t.status = 'open';
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return t;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// validateTask: throw if required fields are missing or malformed.
|
|
64
|
-
// Use at pipeline entry points before processing or claiming a task.
|
|
65
|
-
function validateTask(t) {
|
|
66
|
-
if (!t || typeof t !== 'object') throw new Error('Task must be an object');
|
|
67
|
-
if (!t.task_id || typeof t.task_id !== 'string')
|
|
68
|
-
throw new Error('Task.task_id is required and must be a string');
|
|
69
|
-
if (!VALID_TASK_STATUSES.includes(t.status))
|
|
70
|
-
throw new Error('Task.status must be one of: ' + VALID_TASK_STATUSES.join(', ') + ', got: ' + t.status);
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
module.exports = { createTask, validateTask, TASK_DEFAULTS, VALID_TASK_STATUSES };
|