@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.
Files changed (231) hide show
  1. package/README.md +27 -564
  2. package/bin/evolver-llm-proxy.js +3 -0
  3. package/bin/evolver-mcp.js +2 -0
  4. package/bin/evolver-proxy.js +3 -0
  5. package/bin/evolver.js +4 -0
  6. package/index.js +1 -3586
  7. package/package.json +32 -62
  8. package/CONTRIBUTING.md +0 -19
  9. package/LICENSE +0 -641
  10. package/README.ja-JP.md +0 -521
  11. package/README.ko-KR.md +0 -520
  12. package/README.zh-CN.md +0 -531
  13. package/SKILL.md +0 -365
  14. package/assets/cover.png +0 -0
  15. package/assets/gep/genes.seed.json +0 -496
  16. package/conformance/savings-core/constants.json +0 -30
  17. package/conformance/savings-core/golden-vectors.json +0 -333
  18. package/scripts/a2a_export.js +0 -63
  19. package/scripts/a2a_ingest.js +0 -79
  20. package/scripts/a2a_promote.js +0 -118
  21. package/scripts/analyze_by_skill.js +0 -121
  22. package/scripts/build_binaries.js +0 -479
  23. package/scripts/check-changelog.js +0 -166
  24. package/scripts/extract_log.js +0 -85
  25. package/scripts/generate_history.js +0 -75
  26. package/scripts/gep_append_event.js +0 -96
  27. package/scripts/gep_personality_report.js +0 -234
  28. package/scripts/human_report.js +0 -147
  29. package/scripts/recall-verify-report.js +0 -234
  30. package/scripts/recover_loop.js +0 -61
  31. package/scripts/refresh_stars_badge.js +0 -168
  32. package/scripts/seed-merchants.js +0 -91
  33. package/scripts/skill2recipes.js +0 -118
  34. package/scripts/suggest_version.js +0 -89
  35. package/scripts/validate-modules.js +0 -38
  36. package/scripts/validate-suite.js +0 -78
  37. package/skills/_meta/SKILL.md +0 -41
  38. package/skills/index.json +0 -14
  39. package/src/adapters/claudeCode.js +0 -194
  40. package/src/adapters/codex.js +0 -216
  41. package/src/adapters/cursor.js +0 -91
  42. package/src/adapters/hookAdapter.js +0 -469
  43. package/src/adapters/kiro.js +0 -195
  44. package/src/adapters/opencode.js +0 -326
  45. package/src/adapters/scripts/_lockPaths.js +0 -74
  46. package/src/adapters/scripts/_memoryFiltering.js +0 -35
  47. package/src/adapters/scripts/_runtimePaths.js +0 -440
  48. package/src/adapters/scripts/evolver-session-end.js +0 -321
  49. package/src/adapters/scripts/evolver-session-start.js +0 -587
  50. package/src/adapters/scripts/evolver-signal-detect.js +0 -98
  51. package/src/adapters/scripts/evolver-task-recall.js +0 -173
  52. package/src/atp/atpExecute.js +0 -283
  53. package/src/atp/atpTaskPickup.js +0 -233
  54. package/src/atp/autoBuyer.js +0 -382
  55. package/src/atp/autoDeliver.js +0 -215
  56. package/src/atp/cli.js +0 -354
  57. package/src/atp/cliAutobuyPrompt.js +0 -154
  58. package/src/atp/consumerAgent.js +0 -157
  59. package/src/atp/defaultHandler.js +0 -69
  60. package/src/atp/heartbeatSignalsHandler.js +0 -254
  61. package/src/atp/hubClient.js +0 -317
  62. package/src/atp/index.js +0 -38
  63. package/src/atp/merchantAgent.js +0 -118
  64. package/src/atp/protocol.js +0 -41
  65. package/src/atp/questionComposer.js +0 -133
  66. package/src/atp/serviceHelper.js +0 -92
  67. package/src/canary.js +0 -13
  68. package/src/config.js +0 -351
  69. package/src/evolve/guards.js +0 -1
  70. package/src/evolve/pipeline/collect.js +0 -1
  71. package/src/evolve/pipeline/dispatch.js +0 -1
  72. package/src/evolve/pipeline/enrich.js +0 -1
  73. package/src/evolve/pipeline/hub.js +0 -1
  74. package/src/evolve/pipeline/select.js +0 -1
  75. package/src/evolve/pipeline/signals.js +0 -1
  76. package/src/evolve/utils.js +0 -1
  77. package/src/evolve.js +0 -1
  78. package/src/experiment/agentRunner.js +0 -229
  79. package/src/experiment/cli.js +0 -159
  80. package/src/experiment/comparison.js +0 -233
  81. package/src/experiment/metrics.js +0 -75
  82. package/src/forceUpdate.js +0 -991
  83. package/src/gep/a2a.js +0 -173
  84. package/src/gep/a2aProtocol.js +0 -1
  85. package/src/gep/analyzer.js +0 -35
  86. package/src/gep/antiAbuseTelemetry.js +0 -1
  87. package/src/gep/assetCallLog.js +0 -197
  88. package/src/gep/assetStore.js +0 -723
  89. package/src/gep/assets.js +0 -36
  90. package/src/gep/autoDistillConv.js +0 -1
  91. package/src/gep/autoDistillLlm.js +0 -1
  92. package/src/gep/bridge.js +0 -138
  93. package/src/gep/candidateEval.js +0 -1
  94. package/src/gep/candidates.js +0 -1
  95. package/src/gep/claimNudge.js +0 -121
  96. package/src/gep/cliContracts.js +0 -1190
  97. package/src/gep/contentHash.js +0 -1
  98. package/src/gep/conversationDistiller.js +0 -1
  99. package/src/gep/conversationSniffer.js +0 -1
  100. package/src/gep/crypto.js +0 -1
  101. package/src/gep/curriculum.js +0 -1
  102. package/src/gep/deviceId.js +0 -1
  103. package/src/gep/directoryClient.js +0 -115
  104. package/src/gep/envFingerprint.js +0 -1
  105. package/src/gep/epigenetics.js +0 -1
  106. package/src/gep/execBridge.js +0 -1
  107. package/src/gep/executionTrace.js +0 -291
  108. package/src/gep/explore.js +0 -1
  109. package/src/gep/featureFlags.js +0 -121
  110. package/src/gep/gitOps.js +0 -265
  111. package/src/gep/hash.js +0 -1
  112. package/src/gep/hostErrorClassifier.js +0 -34
  113. package/src/gep/hubFetch.js +0 -1
  114. package/src/gep/hubReview.js +0 -1
  115. package/src/gep/hubSearch.js +0 -1
  116. package/src/gep/hubVerify.js +0 -1
  117. package/src/gep/idleScheduler.js +0 -400
  118. package/src/gep/issueReporter.js +0 -416
  119. package/src/gep/learningSignals.js +0 -1
  120. package/src/gep/llmReview.js +0 -92
  121. package/src/gep/localStateAwareness.js +0 -243
  122. package/src/gep/mailboxTransport.js +0 -119
  123. package/src/gep/memoryGraph.js +0 -1
  124. package/src/gep/memoryGraphAdapter.js +0 -1
  125. package/src/gep/mutation.js +0 -1
  126. package/src/gep/narrativeMemory.js +0 -1
  127. package/src/gep/oauthLogin.js +0 -181
  128. package/src/gep/openPRRegistry.js +0 -1
  129. package/src/gep/paths.js +0 -522
  130. package/src/gep/personality.js +0 -1
  131. package/src/gep/policyCheck.js +0 -1
  132. package/src/gep/portable.js +0 -103
  133. package/src/gep/privacyClient.js +0 -235
  134. package/src/gep/prompt.js +0 -1
  135. package/src/gep/questionGenerator.js +0 -518
  136. package/src/gep/recallInject.js +0 -1
  137. package/src/gep/recallVerifier.js +0 -1
  138. package/src/gep/reflection.js +0 -1
  139. package/src/gep/sanitize.js +0 -264
  140. package/src/gep/savingsCore.js +0 -1
  141. package/src/gep/schemas/capsule.js +0 -170
  142. package/src/gep/schemas/gene.js +0 -154
  143. package/src/gep/schemas/index.js +0 -8
  144. package/src/gep/schemas/protocol.js +0 -51
  145. package/src/gep/schemas/task.js +0 -74
  146. package/src/gep/selector.js +0 -1
  147. package/src/gep/selfPR.js +0 -469
  148. package/src/gep/signals.js +0 -776
  149. package/src/gep/skill2gep.js +0 -1056
  150. package/src/gep/skill2gepAudit.js +0 -303
  151. package/src/gep/skill2recipes.js +0 -511
  152. package/src/gep/skillDistiller.js +0 -1
  153. package/src/gep/skillPublisher.js +0 -358
  154. package/src/gep/solidify.js +0 -1
  155. package/src/gep/strategy.js +0 -1
  156. package/src/gep/taskReceiver.js +0 -575
  157. package/src/gep/tokenSavings.js +0 -1
  158. package/src/gep/trajectoryExport.js +0 -1
  159. package/src/gep/validationReport.js +0 -55
  160. package/src/gep/validator/index.js +0 -411
  161. package/src/gep/validator/reporter.js +0 -210
  162. package/src/gep/validator/sandboxExecutor.js +0 -480
  163. package/src/gep/validator/stakeBootstrap.js +0 -357
  164. package/src/gep/workspaceKeychain.js +0 -1
  165. package/src/ops/cleanup.js +0 -80
  166. package/src/ops/commentary.js +0 -60
  167. package/src/ops/health_check.js +0 -104
  168. package/src/ops/index.js +0 -11
  169. package/src/ops/innovation.js +0 -67
  170. package/src/ops/lifecycle.js +0 -798
  171. package/src/ops/self_repair.js +0 -76
  172. package/src/ops/skills_monitor.js +0 -147
  173. package/src/ops/trigger.js +0 -33
  174. package/src/proxy/clientSettings.js +0 -405
  175. package/src/proxy/envelope.js +0 -59
  176. package/src/proxy/extensions/dmHandler.js +0 -45
  177. package/src/proxy/extensions/sessionHandler.js +0 -141
  178. package/src/proxy/extensions/skillUpdater.js +0 -64
  179. package/src/proxy/extensions/traceControl.js +0 -1
  180. package/src/proxy/index.js +0 -1395
  181. package/src/proxy/inject.js +0 -1
  182. package/src/proxy/lifecycle/manager.js +0 -1568
  183. package/src/proxy/mailbox/state.js +0 -207
  184. package/src/proxy/mailbox/store.js +0 -590
  185. package/src/proxy/router/cache_passthrough.js +0 -26
  186. package/src/proxy/router/features.js +0 -84
  187. package/src/proxy/router/gemini_route.js +0 -154
  188. package/src/proxy/router/messages_route.js +0 -535
  189. package/src/proxy/router/model_router.js +0 -113
  190. package/src/proxy/router/models_route.js +0 -52
  191. package/src/proxy/router/ollama_route.js +0 -103
  192. package/src/proxy/router/responses_route.js +0 -170
  193. package/src/proxy/router/vertex_route.js +0 -110
  194. package/src/proxy/server/http.js +0 -363
  195. package/src/proxy/server/routes.js +0 -558
  196. package/src/proxy/server/settings.js +0 -115
  197. package/src/proxy/sync/engine.js +0 -179
  198. package/src/proxy/sync/inbound.js +0 -211
  199. package/src/proxy/sync/outbound.js +0 -320
  200. package/src/proxy/task/monitor.js +0 -131
  201. package/src/proxy/trace/extractor.js +0 -1
  202. package/src/proxy/trace/usage.js +0 -1
  203. package/src/webui/client/clientJs/assets.js +0 -111
  204. package/src/webui/client/clientJs/bootstrap.js +0 -92
  205. package/src/webui/client/clientJs/common.js +0 -77
  206. package/src/webui/client/clientJs/i18n.js +0 -366
  207. package/src/webui/client/clientJs/index.js +0 -35
  208. package/src/webui/client/clientJs/interactions.js +0 -351
  209. package/src/webui/client/clientJs/overview.js +0 -152
  210. package/src/webui/client/clientJs/personality.js +0 -285
  211. package/src/webui/client/clientJs/pipelines.js +0 -330
  212. package/src/webui/client/indexHtml.js +0 -221
  213. package/src/webui/client/static.js +0 -23
  214. package/src/webui/client/stylesCss.js +0 -639
  215. package/src/webui/client/vendor/README.md +0 -15
  216. package/src/webui/client/vendor/echarts.min.js +0 -45
  217. package/src/webui/index.js +0 -14
  218. package/src/webui/observer/assets.js +0 -146
  219. package/src/webui/observer/index.js +0 -37
  220. package/src/webui/observer/interactions.js +0 -127
  221. package/src/webui/observer/jsonl.js +0 -75
  222. package/src/webui/observer/paths.js +0 -46
  223. package/src/webui/observer/personality.js +0 -43
  224. package/src/webui/observer/pipelineEvents.js +0 -58
  225. package/src/webui/observer/redact.js +0 -63
  226. package/src/webui/observer/runs.js +0 -356
  227. package/src/webui/observer/safety.js +0 -57
  228. package/src/webui/observer/skills.js +0 -70
  229. package/src/webui/observer/status.js +0 -71
  230. package/src/webui/server/http.js +0 -138
  231. package/src/webui/server/routes.js +0 -41
@@ -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
- };
@@ -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
- };
@@ -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
- }