@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/atp/merchantAgent.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
// ATP Merchant Agent Template
|
|
2
|
-
// Provides a ready-to-use merchant agent that registers services,
|
|
3
|
-
// listens for orders, processes them, and submits delivery proofs.
|
|
4
|
-
//
|
|
5
|
-
// Usage:
|
|
6
|
-
// const merchant = require('./merchantAgent');
|
|
7
|
-
// merchant.start({ services: [{ title: 'Code Review', ... }] });
|
|
8
|
-
|
|
9
|
-
const { getNodeId, sendHelloToHub, startHeartbeat, stopHeartbeat, consumeAvailableWork } = require('../gep/a2aProtocol');
|
|
10
|
-
const { publishService } = require('./serviceHelper');
|
|
11
|
-
const { submitDelivery, getMerchantTier, listProofs } = require('./hubClient');
|
|
12
|
-
|
|
13
|
-
let _running = false;
|
|
14
|
-
let _pollInterval = null;
|
|
15
|
-
const DEFAULT_POLL_MS = 30000;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Start the merchant agent loop.
|
|
19
|
-
* @param {object} opts
|
|
20
|
-
* @param {Array<object>} opts.services - services to register
|
|
21
|
-
* @param {function} opts.onOrder - async handler(order) => proofPayload
|
|
22
|
-
* @param {number} [opts.pollMs] - order poll interval (default 30s)
|
|
23
|
-
*/
|
|
24
|
-
async function start(opts) {
|
|
25
|
-
if (_running) {
|
|
26
|
-
console.log('[ATP-Merchant] Already running, skipping duplicate start.');
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
_running = true;
|
|
30
|
-
|
|
31
|
-
const hello = await sendHelloToHub();
|
|
32
|
-
if (!hello || !hello.ok) {
|
|
33
|
-
console.error('[ATP-Merchant] Failed to register with Hub:', hello?.error);
|
|
34
|
-
_running = false;
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
console.log('[ATP-Merchant] Registered as', getNodeId());
|
|
39
|
-
|
|
40
|
-
if (Array.isArray(opts.services)) {
|
|
41
|
-
for (const svc of opts.services) {
|
|
42
|
-
try {
|
|
43
|
-
const result = await publishService(svc);
|
|
44
|
-
if (result.ok) {
|
|
45
|
-
console.log('[ATP-Merchant] Published service:', svc.title);
|
|
46
|
-
} else {
|
|
47
|
-
console.warn('[ATP-Merchant] Failed to publish service:', svc.title, result.error);
|
|
48
|
-
}
|
|
49
|
-
} catch (e) {
|
|
50
|
-
console.warn('[ATP-Merchant] Service publish error:', e.message);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
startHeartbeat();
|
|
56
|
-
|
|
57
|
-
const pollMs = opts.pollMs || DEFAULT_POLL_MS;
|
|
58
|
-
_pollInterval = setInterval(async () => {
|
|
59
|
-
try {
|
|
60
|
-
const work = consumeAvailableWork();
|
|
61
|
-
if (!work || work.length === 0) return;
|
|
62
|
-
|
|
63
|
-
for (const order of work) {
|
|
64
|
-
if (typeof opts.onOrder === 'function') {
|
|
65
|
-
try {
|
|
66
|
-
const proofPayload = await opts.onOrder(order);
|
|
67
|
-
if (proofPayload && order.atp_order_id) {
|
|
68
|
-
const delivery = await submitDelivery(order.atp_order_id, proofPayload);
|
|
69
|
-
if (delivery.ok) {
|
|
70
|
-
console.log('[ATP-Merchant] Delivered order:', order.atp_order_id);
|
|
71
|
-
} else {
|
|
72
|
-
console.warn('[ATP-Merchant] Delivery failed:', delivery.error);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
} catch (e) {
|
|
76
|
-
console.error('[ATP-Merchant] Order handler error:', e.message);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
} catch (e) {
|
|
81
|
-
console.error('[ATP-Merchant] Poll error:', e.message);
|
|
82
|
-
}
|
|
83
|
-
}, pollMs);
|
|
84
|
-
|
|
85
|
-
console.log('[ATP-Merchant] Polling for orders every', pollMs, 'ms');
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function stop() {
|
|
89
|
-
_running = false;
|
|
90
|
-
if (_pollInterval) {
|
|
91
|
-
clearInterval(_pollInterval);
|
|
92
|
-
_pollInterval = null;
|
|
93
|
-
}
|
|
94
|
-
stopHeartbeat();
|
|
95
|
-
console.log('[ATP-Merchant] Stopped');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function isRunning() {
|
|
99
|
-
return _running;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async function getStatus() {
|
|
103
|
-
const tier = await getMerchantTier();
|
|
104
|
-
const proofs = await listProofs({ role: 'merchant', limit: 5 });
|
|
105
|
-
return {
|
|
106
|
-
node_id: getNodeId(),
|
|
107
|
-
running: _running,
|
|
108
|
-
tier: tier.ok ? tier.data : null,
|
|
109
|
-
recent_proofs: proofs.ok ? proofs.data : null,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
module.exports = {
|
|
114
|
-
start,
|
|
115
|
-
stop,
|
|
116
|
-
isRunning,
|
|
117
|
-
getStatus,
|
|
118
|
-
};
|
package/src/atp/protocol.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Protocol-level enum constants for the Agent Transaction Protocol.
|
|
2
|
-
//
|
|
3
|
-
// These values (verify modes, routing modes, proof statuses, roles,
|
|
4
|
-
// execution modes) live in @evomap/atp-sdk. This module is a thin
|
|
5
|
-
// CommonJS facade so callsites in src/atp/ can `require('./protocol')`
|
|
6
|
-
// for the authoritative sets instead of re-spelling the literals.
|
|
7
|
-
//
|
|
8
|
-
// Why move them out: ATP is the wire contract between this engine, the
|
|
9
|
-
// EvoMap Hub, and (in future) evox-Rust. Hand-maintaining the allowed
|
|
10
|
-
// value sets in each implementation is exactly the drift that the
|
|
11
|
-
// v1.80.8 "explore" enum incident taught us to avoid for GEP. The ATP
|
|
12
|
-
// contract is extracted into its own SDK before a second runtime wires
|
|
13
|
-
// in, while it is still cheap. If you find yourself writing an enum
|
|
14
|
-
// list literal here again (e.g. ['pending','verified',...]), stop --
|
|
15
|
-
// import the constant from this facade instead, and bump
|
|
16
|
-
// @evomap/atp-sdk if the set itself needs to change.
|
|
17
|
-
//
|
|
18
|
-
// Implementation note: @evomap/atp-sdk is published as ESM
|
|
19
|
-
// (`"type": "module"`). Node supports `require()` of synchronous ESM
|
|
20
|
-
// packages on 22.12.0 and later. The SDK itself stays permissive
|
|
21
|
-
// (`engines.node >=18`) so `import`-based consumers on 18/20 aren't
|
|
22
|
-
// blocked; the `>=22.12` guarantee that makes the require() below work
|
|
23
|
-
// is pinned in THIS package's (evolver's) `engines.node`, not the SDK's.
|
|
24
|
-
|
|
25
|
-
const {
|
|
26
|
-
ATP_VERIFY_MODES,
|
|
27
|
-
ATP_VERIFY_ACTIONS,
|
|
28
|
-
ATP_ROUTING_MODES,
|
|
29
|
-
ATP_PROOF_STATUSES,
|
|
30
|
-
ATP_ROLES,
|
|
31
|
-
ATP_EXECUTION_MODES,
|
|
32
|
-
} = require('@evomap/atp-sdk');
|
|
33
|
-
|
|
34
|
-
module.exports = {
|
|
35
|
-
ATP_VERIFY_MODES,
|
|
36
|
-
ATP_VERIFY_ACTIONS,
|
|
37
|
-
ATP_ROUTING_MODES,
|
|
38
|
-
ATP_PROOF_STATUSES,
|
|
39
|
-
ATP_ROLES,
|
|
40
|
-
ATP_EXECUTION_MODES,
|
|
41
|
-
};
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
// ATP Question Composer
|
|
2
|
-
//
|
|
3
|
-
// Generates a natural-language buyer question from raw capability/signal
|
|
4
|
-
// inputs. autoBuyer previously concatenated signals into a string like
|
|
5
|
-
// "Capability gap detected by evolver: code_evolution,performance,..."
|
|
6
|
-
// which is uninformative to the merchant and produces poor answers.
|
|
7
|
-
//
|
|
8
|
-
// This module maps each known capability (or signal prefix) to a template
|
|
9
|
-
// that phrases the request as something a real buyer might ask. When no
|
|
10
|
-
// template matches, falls back to a generic "please help me with <caps>"
|
|
11
|
-
// phrasing. Templates deliberately stay concise (under 240 chars) so buyer
|
|
12
|
-
// budgets and merchant time are not wasted on padding.
|
|
13
|
-
//
|
|
14
|
-
// Templates are intentionally defensive: they never leak Evolver internals
|
|
15
|
-
// ("signals", "cycle", "mutation") into merchant-visible text.
|
|
16
|
-
|
|
17
|
-
const DEFAULT_MAX_LEN = 240;
|
|
18
|
-
|
|
19
|
-
const TEMPLATES = {
|
|
20
|
-
code_evolution: [
|
|
21
|
-
'I want to improve code quality on a small module. Please suggest one concrete, minimal patch I can apply, including the exact files, the change, and why it helps.',
|
|
22
|
-
'I am iterating on a codebase and would like one high-leverage refactor suggestion. Be specific about the file, the current issue, and the proposed change.',
|
|
23
|
-
],
|
|
24
|
-
performance: [
|
|
25
|
-
'My app has a slow hot-path and I want one concrete optimization idea. Explain the likely bottleneck, propose a specific fix, and estimate the impact.',
|
|
26
|
-
'I need help diagnosing a performance issue. Ask the right clarifying question if needed, or give me the top-3 most likely causes in priority order.',
|
|
27
|
-
],
|
|
28
|
-
debugging: [
|
|
29
|
-
'I am stuck on a bug and need a fresh pair of eyes. Walk me through a systematic debugging approach that would isolate the root cause in under an hour.',
|
|
30
|
-
'Help me debug a tricky issue: please outline 3 reproduction strategies, each with the signals I should look for to confirm or rule out a hypothesis.',
|
|
31
|
-
],
|
|
32
|
-
testing: [
|
|
33
|
-
'I want to add tests to an under-tested module. Recommend the specific test cases (happy path, edge cases, regression) that give the best coverage per line of test code.',
|
|
34
|
-
'Please review a typical testing gap for this kind of module and tell me the 3 test cases I probably missed.',
|
|
35
|
-
],
|
|
36
|
-
documentation: [
|
|
37
|
-
'I need to write user-facing documentation for a feature. Give me a concise outline and sample opening paragraph that sets expectations correctly.',
|
|
38
|
-
'Help me rewrite a README section so it is clear to a first-time user. Focus on the smallest change that removes the most confusion.',
|
|
39
|
-
],
|
|
40
|
-
refactoring: [
|
|
41
|
-
'I want to refactor a module without changing behavior. Suggest the safest single-step refactor that reduces complexity, and what I should watch for during review.',
|
|
42
|
-
'Please propose a refactoring plan I can apply in small commits, starting with the change that has the highest value/risk ratio.',
|
|
43
|
-
],
|
|
44
|
-
security: [
|
|
45
|
-
'Review a typical security concern for this kind of service and give me one actionable hardening I should implement first.',
|
|
46
|
-
'I want a short security checklist for my app. List the top 5 issues to check in priority order, with the quickest mitigation for each.',
|
|
47
|
-
],
|
|
48
|
-
data_analysis: [
|
|
49
|
-
'I have a dataset and want to extract one useful insight. Recommend the analysis I should run first, the metric to compute, and how to interpret the result.',
|
|
50
|
-
'Given a typical CSV of user events, which 3 analyses would most likely surface actionable patterns? Explain why for each.',
|
|
51
|
-
],
|
|
52
|
-
architecture: [
|
|
53
|
-
'Help me think through an architectural trade-off: I need to choose between two patterns for a small service. Give me the decision factors and a recommended default.',
|
|
54
|
-
'I need a rough architecture sketch for a new feature. Describe the smallest viable design and list the 2 decisions that are easy to get wrong.',
|
|
55
|
-
],
|
|
56
|
-
deployment: [
|
|
57
|
-
'Help me set up a safe deployment path for my app. Outline the minimum CI/CD steps and the 3 most common pitfalls to avoid.',
|
|
58
|
-
'I want to harden my deploy pipeline. Recommend the smallest change that most reduces the risk of a broken deploy reaching production.',
|
|
59
|
-
],
|
|
60
|
-
general: [
|
|
61
|
-
'I have a small task I would like an agent to help with. Please ask me the single most useful clarifying question, then outline how you would approach it.',
|
|
62
|
-
'Please give me a concise, practical answer for a typical task in this capability. If context is needed, ask one focused clarifying question first.',
|
|
63
|
-
],
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
function _normalize(s) {
|
|
67
|
-
return String(s || '').toLowerCase().replace(/[^a-z0-9_]+/g, '_').replace(/^_+|_+$/g, '');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _pickTemplate(key, hashSeed) {
|
|
71
|
-
const list = TEMPLATES[key] || TEMPLATES.general;
|
|
72
|
-
if (!list || list.length === 0) return null;
|
|
73
|
-
// Deterministic pick from a seed so the same signals yield the same
|
|
74
|
-
// question across runs (plays nicely with autoBuyer's dedup hash).
|
|
75
|
-
const n = Math.abs(Number(hashSeed) || 0) % list.length;
|
|
76
|
-
return list[n];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function _hashFor(parts) {
|
|
80
|
-
const s = Array.isArray(parts) ? parts.join('|') : String(parts || '');
|
|
81
|
-
let h = 0;
|
|
82
|
-
for (let i = 0; i < s.length; i++) {
|
|
83
|
-
h = (h * 31 + s.charCodeAt(i)) | 0;
|
|
84
|
-
}
|
|
85
|
-
return h;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function _clip(s, maxLen) {
|
|
89
|
-
const text = String(s || '').trim();
|
|
90
|
-
const cap = Math.max(40, Number(maxLen) || DEFAULT_MAX_LEN);
|
|
91
|
-
if (text.length <= cap) return text;
|
|
92
|
-
return text.slice(0, cap - 3).replace(/\s+$/, '') + '...';
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Build a natural-language buyer question from capabilities + signals.
|
|
97
|
-
*
|
|
98
|
-
* @param {object} opts
|
|
99
|
-
* @param {string[]} opts.capabilities -- buyer-side capability ids (first one picks the template)
|
|
100
|
-
* @param {string[]} [opts.signals] -- evolver signals (used as tiebreaker; never leaked verbatim)
|
|
101
|
-
* @param {string} [opts.fallback] -- caller-provided fallback sentence
|
|
102
|
-
* @param {number} [opts.maxLen=240]
|
|
103
|
-
* @returns {string} -- composed question (never empty)
|
|
104
|
-
*/
|
|
105
|
-
function compose(opts) {
|
|
106
|
-
const capabilities = Array.isArray(opts && opts.capabilities) ? opts.capabilities : [];
|
|
107
|
-
const signals = Array.isArray(opts && opts.signals) ? opts.signals : [];
|
|
108
|
-
const maxLen = Number(opts && opts.maxLen) || DEFAULT_MAX_LEN;
|
|
109
|
-
|
|
110
|
-
const keys = capabilities.map(_normalize).filter(Boolean);
|
|
111
|
-
const primary = keys.find(function (k) { return TEMPLATES[k]; }) || keys[0] || 'general';
|
|
112
|
-
const tmplKey = TEMPLATES[primary] ? primary : 'general';
|
|
113
|
-
|
|
114
|
-
const seed = _hashFor(keys.concat(signals.slice(0, 4)));
|
|
115
|
-
const tmpl = _pickTemplate(tmplKey, seed);
|
|
116
|
-
|
|
117
|
-
if (tmpl) return _clip(tmpl, maxLen);
|
|
118
|
-
|
|
119
|
-
// Generic fallback when TEMPLATES does not have `general` (defensive).
|
|
120
|
-
const capsText = capabilities.length ? capabilities.slice(0, 3).join(', ') : 'a common task';
|
|
121
|
-
const fb = (opts && opts.fallback && String(opts.fallback).trim())
|
|
122
|
-
|| 'I would like help with ' + capsText + '. Please provide one concrete, actionable answer.';
|
|
123
|
-
return _clip(fb, maxLen);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
module.exports = {
|
|
127
|
-
compose,
|
|
128
|
-
// exported for tests
|
|
129
|
-
_normalize,
|
|
130
|
-
_pickTemplate,
|
|
131
|
-
_hashFor,
|
|
132
|
-
TEMPLATES,
|
|
133
|
-
};
|
package/src/atp/serviceHelper.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
// ATP Service Helper -- wraps marketplace service publishing for merchant agents.
|
|
2
|
-
|
|
3
|
-
const { getNodeId, buildHubHeaders, buildNodeScopedHubHeaders, getHubUrl } = require('../gep/a2aProtocol');
|
|
4
|
-
const { hubFetch } = require('../gep/hubFetch');
|
|
5
|
-
const { HTTP_TRANSPORT_TIMEOUT_MS } = require('../config');
|
|
6
|
-
|
|
7
|
-
async function postService(endpoint, body) {
|
|
8
|
-
try {
|
|
9
|
-
const buildHeaders = buildNodeScopedHubHeaders || buildHubHeaders;
|
|
10
|
-
const res = await hubFetch(endpoint, {
|
|
11
|
-
method: 'POST',
|
|
12
|
-
headers: Object.assign({ 'Content-Type': 'application/json' }, buildHeaders() || {}),
|
|
13
|
-
body: JSON.stringify(body),
|
|
14
|
-
signal: AbortSignal.timeout(HTTP_TRANSPORT_TIMEOUT_MS),
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
if (!res.ok) {
|
|
18
|
-
const t = await res.text();
|
|
19
|
-
return { ok: false, status: res.status, error: t.slice(0, 400) };
|
|
20
|
-
}
|
|
21
|
-
const data = await res.json();
|
|
22
|
-
return { ok: true, data };
|
|
23
|
-
} catch (err) {
|
|
24
|
-
const msg = (err && err.message) || String(err);
|
|
25
|
-
if (msg.indexOf('[hubFetch]') !== -1) {
|
|
26
|
-
return { ok: false, error: 'tls_refused: ' + msg };
|
|
27
|
-
}
|
|
28
|
-
return { ok: false, error: msg };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Publish a ServiceListing via the Hub marketplace API.
|
|
34
|
-
* @param {object} svc
|
|
35
|
-
* @param {string} svc.title
|
|
36
|
-
* @param {string} [svc.description]
|
|
37
|
-
* @param {string[]} [svc.capabilities]
|
|
38
|
-
* @param {string[]} [svc.useCases]
|
|
39
|
-
* @param {number} [svc.pricePerTask] - min 1 Credit
|
|
40
|
-
* @param {string} [svc.executionMode] - exclusive | open | swarm
|
|
41
|
-
* @param {number} [svc.maxConcurrent]
|
|
42
|
-
* @param {string} [svc.recipeId]
|
|
43
|
-
* @returns {Promise<{ok: boolean, data?: object, error?: string}>}
|
|
44
|
-
*/
|
|
45
|
-
async function publishService(svc) {
|
|
46
|
-
const hubUrl = getHubUrl();
|
|
47
|
-
if (!hubUrl) return { ok: false, error: 'no_hub_url' };
|
|
48
|
-
|
|
49
|
-
const nodeId = getNodeId();
|
|
50
|
-
const endpoint = hubUrl.replace(/\/+$/, '') + '/a2a/service/publish';
|
|
51
|
-
|
|
52
|
-
const body = {
|
|
53
|
-
sender_id: nodeId,
|
|
54
|
-
title: svc.title,
|
|
55
|
-
description: svc.description,
|
|
56
|
-
capabilities: svc.capabilities,
|
|
57
|
-
use_cases: svc.useCases,
|
|
58
|
-
price_per_task: Math.max(1, Math.round(Number(svc.pricePerTask) || 10)),
|
|
59
|
-
execution_mode: svc.executionMode || 'exclusive',
|
|
60
|
-
max_concurrent: Math.max(1, Math.round(Number(svc.maxConcurrent) || 3)),
|
|
61
|
-
recipe_id: svc.recipeId,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
return postService(endpoint, body);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Update an existing ServiceListing.
|
|
69
|
-
* @param {string} listingId
|
|
70
|
-
* @param {object} updates
|
|
71
|
-
* @returns {Promise<{ok: boolean, data?: object, error?: string}>}
|
|
72
|
-
*/
|
|
73
|
-
async function updateService(listingId, updates) {
|
|
74
|
-
const hubUrl = getHubUrl();
|
|
75
|
-
if (!hubUrl) return { ok: false, error: 'no_hub_url' };
|
|
76
|
-
|
|
77
|
-
const nodeId = getNodeId();
|
|
78
|
-
const endpoint = hubUrl.replace(/\/+$/, '') + '/a2a/service/update';
|
|
79
|
-
|
|
80
|
-
const body = {
|
|
81
|
-
sender_id: nodeId,
|
|
82
|
-
listing_id: listingId,
|
|
83
|
-
...updates,
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
return postService(endpoint, body);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
module.exports = {
|
|
90
|
-
publishService,
|
|
91
|
-
updateService,
|
|
92
|
-
};
|
package/src/canary.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Canary script: run in a forked child process to verify index.js loads
|
|
2
|
-
// without crashing. Exit 0 = safe, non-zero = broken.
|
|
3
|
-
//
|
|
4
|
-
// This is the last safety net before solidify commits an evolution.
|
|
5
|
-
// If a patch broke index.js (syntax error, missing require, etc.),
|
|
6
|
-
// the canary catches it BEFORE the daemon restarts with broken code.
|
|
7
|
-
try {
|
|
8
|
-
require('../index.js');
|
|
9
|
-
process.exit(0);
|
|
10
|
-
} catch (e) {
|
|
11
|
-
process.stderr.write(String(e.message || e).slice(0, 500));
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|