@evomap/evolver 1.89.17 → 1.89.18
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.ja-JP.md +1 -1
- package/README.ko-KR.md +1 -1
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/index.js +89 -17
- package/package.json +1 -1
- package/src/adapters/claudeCode.js +36 -7
- package/src/adapters/hookAdapter.js +24 -0
- package/src/atp/atpExecute.js +3 -1
- package/src/atp/hubClient.js +5 -3
- package/src/atp/serviceHelper.js +3 -2
- package/src/evolve/guards.js +1 -1
- package/src/evolve/pipeline/collect.js +1 -1
- package/src/evolve/pipeline/dispatch.js +1 -1
- package/src/evolve/pipeline/enrich.js +1 -1
- package/src/evolve/pipeline/hub.js +1 -1
- package/src/evolve/pipeline/select.js +1 -1
- package/src/evolve/pipeline/signals.js +1 -1
- package/src/evolve/utils.js +1 -1
- package/src/evolve.js +1 -1
- package/src/gep/a2aProtocol.js +1 -1
- package/src/gep/antiAbuseTelemetry.js +1 -1
- package/src/gep/autoDistillConv.js +1 -1
- package/src/gep/autoDistillLlm.js +1 -1
- package/src/gep/candidateEval.js +1 -1
- package/src/gep/candidates.js +1 -1
- package/src/gep/cliContracts.js +37 -1
- package/src/gep/contentHash.js +1 -1
- package/src/gep/conversationDistiller.js +1 -1
- package/src/gep/conversationSniffer.js +1 -1
- package/src/gep/crypto.js +1 -1
- package/src/gep/curriculum.js +1 -1
- package/src/gep/deviceId.js +1 -1
- package/src/gep/directoryClient.js +7 -3
- package/src/gep/envFingerprint.js +1 -1
- package/src/gep/epigenetics.js +1 -1
- package/src/gep/execBridge.js +1 -1
- package/src/gep/explore.js +1 -1
- package/src/gep/hash.js +1 -1
- package/src/gep/hubFetch.js +1 -1
- package/src/gep/hubReview.js +1 -1
- package/src/gep/hubSearch.js +1 -1
- package/src/gep/hubVerify.js +1 -1
- package/src/gep/learningSignals.js +1 -1
- package/src/gep/memoryGraph.js +1 -1
- package/src/gep/memoryGraphAdapter.js +1 -1
- package/src/gep/mutation.js +1 -1
- package/src/gep/narrativeMemory.js +1 -1
- package/src/gep/oauthLogin.js +3 -5
- package/src/gep/openPRRegistry.js +1 -1
- package/src/gep/personality.js +1 -1
- package/src/gep/policyCheck.js +1 -1
- package/src/gep/privacyClient.js +28 -10
- package/src/gep/prompt.js +1 -1
- package/src/gep/recallInject.js +1 -1
- package/src/gep/recallVerifier.js +1 -1
- package/src/gep/reflection.js +1 -1
- package/src/gep/savingsCore.js +1 -1
- package/src/gep/selector.js +1 -1
- package/src/gep/skillDistiller.js +1 -1
- package/src/gep/skillPublisher.js +8 -3
- package/src/gep/solidify.js +1 -1
- package/src/gep/strategy.js +1 -1
- package/src/gep/taskReceiver.js +3 -2
- package/src/gep/tokenSavings.js +1 -1
- package/src/gep/validator/index.js +7 -2
- package/src/gep/validator/reporter.js +7 -2
- package/src/gep/validator/stakeBootstrap.js +7 -2
- package/src/gep/workspaceKeychain.js +1 -1
- package/src/proxy/clientSettings.js +405 -0
- package/src/proxy/extensions/traceControl.js +1 -1
- package/src/proxy/index.js +10 -5
- package/src/proxy/inject.js +1 -1
- package/src/proxy/lifecycle/manager.js +82 -16
- package/src/proxy/mailbox/state.js +207 -0
- package/src/proxy/mailbox/store.js +164 -64
- package/src/proxy/router/messages_route.js +4 -3
- package/src/proxy/server/http.js +40 -6
- package/src/proxy/sync/inbound.js +31 -12
- package/src/proxy/sync/outbound.js +157 -22
- package/src/proxy/trace/extractor.js +1 -1
- package/src/proxy/trace/usage.js +1 -1
package/README.ja-JP.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🧬 Evolver
|
|
2
2
|
|
|
3
|
-
[](https://github.com/EvoMap/evolver/stargazers)
|
|
4
4
|
[](https://opensource.org/licenses/GPL-3.0)
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
[](https://www.npmjs.com/package/@evomap/evolver)
|
package/README.ko-KR.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🧬 Evolver
|
|
2
2
|
|
|
3
|
-
[](https://github.com/EvoMap/evolver/stargazers)
|
|
4
4
|
[](https://opensource.org/licenses/GPL-3.0)
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
[](https://www.npmjs.com/package/@evomap/evolver)
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🧬 Evolver
|
|
2
2
|
|
|
3
|
-
[](https://github.com/EvoMap/evolver/stargazers)
|
|
4
4
|
[](https://opensource.org/licenses/GPL-3.0)
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
[](https://www.npmjs.com/package/@evomap/evolver)
|
package/README.zh-CN.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🧬 Evolver
|
|
2
2
|
|
|
3
|
-
[](https://github.com/EvoMap/evolver/stargazers)
|
|
4
4
|
[](https://opensource.org/licenses/GPL-3.0)
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
[](https://www.npmjs.com/package/@evomap/evolver)
|
package/index.js
CHANGED
|
@@ -464,6 +464,68 @@ function writeCycleProgressAtomic(progressPath, fields) {
|
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
|
|
467
|
+
function handleCycleTimeout({ error, cycleProgressPath, progressFields, suicideEnabled, args, logPath, spawnReplacementFn }) {
|
|
468
|
+
const msg = error && error.message ? String(error.message) : String(error);
|
|
469
|
+
console.error('[Daemon] ' + msg);
|
|
470
|
+
|
|
471
|
+
if (!suicideEnabled) {
|
|
472
|
+
console.warn('[Daemon] Cycle hard-timeout treated as non-fatal because EVOLVER_SUICIDE=false.');
|
|
473
|
+
writeCycleProgressAtomic(cycleProgressPath, Object.assign({}, progressFields, {
|
|
474
|
+
phase: 'cycle_timeout_nonfatal',
|
|
475
|
+
}));
|
|
476
|
+
return { action: 'continue' };
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
writeCycleProgressAtomic(cycleProgressPath, Object.assign({}, progressFields, {
|
|
480
|
+
phase: 'cycle_timeout_respawn',
|
|
481
|
+
}));
|
|
482
|
+
spawnReplacementFn({
|
|
483
|
+
reason: 'cycle_hard_timeout',
|
|
484
|
+
args: args,
|
|
485
|
+
logPath: logPath,
|
|
486
|
+
});
|
|
487
|
+
return { action: 'respawn' };
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function logTimedOutEvolveRejection(error, logFn) {
|
|
491
|
+
const lateMsg = error && error.message ? String(error.message) : String(error);
|
|
492
|
+
try {
|
|
493
|
+
logFn('[Daemon] Timed-out evolve.run() eventually rejected: ' + lateMsg);
|
|
494
|
+
} catch (logError) {
|
|
495
|
+
const fallbackMsg = logError && logError.message ? String(logError.message) : String(logError);
|
|
496
|
+
console.error('[Daemon] Failed to log timed-out evolve.run() rejection: ' + fallbackMsg);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function observeTimedOutEvolvePromise(evolvePromise, logFn = console.error) {
|
|
501
|
+
if (!evolvePromise || typeof evolvePromise.then !== 'function') {
|
|
502
|
+
return { status: 'ignored' };
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
Promise.resolve(evolvePromise).then(
|
|
506
|
+
function () {},
|
|
507
|
+
function (error) {
|
|
508
|
+
logTimedOutEvolveRejection(error, logFn);
|
|
509
|
+
}
|
|
510
|
+
);
|
|
511
|
+
|
|
512
|
+
return { status: 'observing' };
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
async function waitForTimedOutEvolvePromise(evolvePromise, logFn = console.error) {
|
|
516
|
+
if (!evolvePromise || typeof evolvePromise.then !== 'function') {
|
|
517
|
+
return { status: 'ignored' };
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
try {
|
|
521
|
+
await evolvePromise;
|
|
522
|
+
return { status: 'resolved' };
|
|
523
|
+
} catch (error) {
|
|
524
|
+
logTimedOutEvolveRejection(error, logFn);
|
|
525
|
+
return { status: 'rejected' };
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
467
529
|
function getLastSignals(statePath) {
|
|
468
530
|
try {
|
|
469
531
|
const st = readJsonSafe(statePath);
|
|
@@ -1357,6 +1419,7 @@ async function main() {
|
|
|
1357
1419
|
const { startProxy } = require('./src/proxy');
|
|
1358
1420
|
const proxyInfo = await startProxy({
|
|
1359
1421
|
hubUrl: process.env.A2A_HUB_URL,
|
|
1422
|
+
clientSettings: {},
|
|
1360
1423
|
});
|
|
1361
1424
|
console.log('[Proxy] Started on ' + proxyInfo.url);
|
|
1362
1425
|
try {
|
|
@@ -1592,13 +1655,12 @@ async function main() {
|
|
|
1592
1655
|
if (typeof progressTicker.unref === 'function') progressTicker.unref();
|
|
1593
1656
|
}
|
|
1594
1657
|
let cycleTimeoutHandle = null;
|
|
1595
|
-
let
|
|
1658
|
+
let evolvePromise = null;
|
|
1596
1659
|
try {
|
|
1597
|
-
|
|
1660
|
+
evolvePromise = evolve.run();
|
|
1598
1661
|
if (cycleTimeoutEnabled && cycleTimeoutMs > 0) {
|
|
1599
1662
|
const timeoutPromise = new Promise(function (_, reject) {
|
|
1600
1663
|
cycleTimeoutHandle = setTimeout(function () {
|
|
1601
|
-
cycleTimedOut = true;
|
|
1602
1664
|
reject(new CycleTimeoutError(cycleTimeoutMs, 'evolve.run', cycleCount));
|
|
1603
1665
|
}, cycleTimeoutMs);
|
|
1604
1666
|
if (cycleTimeoutHandle && typeof cycleTimeoutHandle.unref === 'function') cycleTimeoutHandle.unref();
|
|
@@ -1621,25 +1683,32 @@ async function main() {
|
|
|
1621
1683
|
} catch (error) {
|
|
1622
1684
|
const msg = error && error.message ? String(error.message) : String(error);
|
|
1623
1685
|
if (error && error.code === 'CYCLE_TIMEOUT') {
|
|
1624
|
-
console.error('[Daemon] ' + msg);
|
|
1625
1686
|
if (progressTicker) { clearInterval(progressTicker); progressTicker = null; }
|
|
1626
1687
|
if (cycleTimeoutHandle) { clearTimeout(cycleTimeoutHandle); cycleTimeoutHandle = null; }
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1688
|
+
const timeoutAction = handleCycleTimeout({
|
|
1689
|
+
error,
|
|
1690
|
+
cycleProgressPath,
|
|
1691
|
+
progressFields: {
|
|
1692
|
+
pid: process.pid,
|
|
1693
|
+
outer_cycle: cycleCount,
|
|
1694
|
+
inner_cycle: cycleCount,
|
|
1695
|
+
started_at: t0,
|
|
1696
|
+
},
|
|
1697
|
+
suicideEnabled,
|
|
1698
|
+
args,
|
|
1637
1699
|
logPath: getEvolverLogPath(),
|
|
1700
|
+
spawnReplacementFn: spawnReplacementProcess,
|
|
1638
1701
|
});
|
|
1639
|
-
|
|
1640
|
-
|
|
1702
|
+
if (timeoutAction.action === 'respawn') {
|
|
1703
|
+
releaseLock();
|
|
1704
|
+
process.exit(1);
|
|
1705
|
+
}
|
|
1706
|
+
if (timeoutAction.action === 'continue') {
|
|
1707
|
+
await waitForTimedOutEvolvePromise(evolvePromise);
|
|
1708
|
+
}
|
|
1709
|
+
} else {
|
|
1710
|
+
console.error(`Evolution cycle failed: ${msg}`);
|
|
1641
1711
|
}
|
|
1642
|
-
console.error(`Evolution cycle failed: ${msg}`);
|
|
1643
1712
|
} finally {
|
|
1644
1713
|
if (progressTicker) { clearInterval(progressTicker); progressTicker = null; }
|
|
1645
1714
|
if (cycleTimeoutHandle) { clearTimeout(cycleTimeoutHandle); cycleTimeoutHandle = null; }
|
|
@@ -3328,5 +3397,8 @@ module.exports = {
|
|
|
3328
3397
|
parseBoolEnv,
|
|
3329
3398
|
CycleTimeoutError,
|
|
3330
3399
|
writeCycleProgressAtomic,
|
|
3400
|
+
handleCycleTimeout,
|
|
3401
|
+
observeTimedOutEvolvePromise,
|
|
3402
|
+
waitForTimedOutEvolvePromise,
|
|
3331
3403
|
spawnReplacementProcess,
|
|
3332
3404
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evomap/evolver",
|
|
3
|
-
"version": "1.89.
|
|
3
|
+
"version": "1.89.18",
|
|
4
4
|
"description": "A GEP-powered self-evolution engine for AI agents. Features automated log analysis and Genome Evolution Protocol (GEP) for auditable, reusable evolution assets.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -5,8 +5,37 @@ const { mergeJsonFile, copyHookScripts, appendSectionToFile, removeHookScripts,
|
|
|
5
5
|
const HOOK_SCRIPTS_DIR_NAME = 'hooks';
|
|
6
6
|
const EVOLVER_MARKER = '<!-- evolver-evolution-memory -->';
|
|
7
7
|
|
|
8
|
-
function
|
|
9
|
-
|
|
8
|
+
function shellSingleQuote(value) {
|
|
9
|
+
return `'${String(value).replace(/'/g, "'\\''")}'`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function quoteEvalScript(script) {
|
|
13
|
+
if (process.platform === 'win32') {
|
|
14
|
+
if (script.includes('"')) {
|
|
15
|
+
throw new Error('unexpected double quote in generated hook wrapper');
|
|
16
|
+
}
|
|
17
|
+
return `"${script}"`;
|
|
18
|
+
}
|
|
19
|
+
return shellSingleQuote(script);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function buildSafeNodeHookCommand(scriptPath) {
|
|
23
|
+
const encodedPath = Buffer.from(String(scriptPath), 'utf8').toString('base64');
|
|
24
|
+
const js = [
|
|
25
|
+
"const {spawnSync}=require('child_process')",
|
|
26
|
+
`const p=Buffer.from('${encodedPath}','base64').toString('utf8')`,
|
|
27
|
+
"const r=spawnSync(process.execPath,[p],{stdio:'inherit',shell:false})",
|
|
28
|
+
"if(r.error){throw r.error}",
|
|
29
|
+
'process.exit(r.status == null ? 1 : r.status)',
|
|
30
|
+
].join(';');
|
|
31
|
+
return `node -e ${quoteEvalScript(js)} ${path.basename(scriptPath)}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function buildClaudeHooks(evolverRoot, configRoot) {
|
|
35
|
+
const scriptsBase = configRoot
|
|
36
|
+
? path.join(configRoot, '.claude', 'hooks')
|
|
37
|
+
: path.join('.claude', 'hooks');
|
|
38
|
+
const hookCommand = (scriptName) => buildSafeNodeHookCommand(path.join(scriptsBase, scriptName));
|
|
10
39
|
return {
|
|
11
40
|
hooks: {
|
|
12
41
|
SessionStart: [
|
|
@@ -14,7 +43,7 @@ function buildClaudeHooks(evolverRoot) {
|
|
|
14
43
|
hooks: [
|
|
15
44
|
{
|
|
16
45
|
type: 'command',
|
|
17
|
-
command:
|
|
46
|
+
command: hookCommand('evolver-session-start.js'),
|
|
18
47
|
timeout: 3,
|
|
19
48
|
},
|
|
20
49
|
],
|
|
@@ -32,7 +61,7 @@ function buildClaudeHooks(evolverRoot) {
|
|
|
32
61
|
// ABOVE that watchdog, so the host never kills the script
|
|
33
62
|
// mid-write. A stuck/slow recall can never block or erase the
|
|
34
63
|
// user's prompt.
|
|
35
|
-
command:
|
|
64
|
+
command: hookCommand('evolver-task-recall.js'),
|
|
36
65
|
timeout: 5,
|
|
37
66
|
},
|
|
38
67
|
],
|
|
@@ -44,7 +73,7 @@ function buildClaudeHooks(evolverRoot) {
|
|
|
44
73
|
hooks: [
|
|
45
74
|
{
|
|
46
75
|
type: 'command',
|
|
47
|
-
command:
|
|
76
|
+
command: hookCommand('evolver-signal-detect.js'),
|
|
48
77
|
timeout: 2,
|
|
49
78
|
},
|
|
50
79
|
],
|
|
@@ -55,7 +84,7 @@ function buildClaudeHooks(evolverRoot) {
|
|
|
55
84
|
hooks: [
|
|
56
85
|
{
|
|
57
86
|
type: 'command',
|
|
58
|
-
command:
|
|
87
|
+
command: hookCommand('evolver-session-end.js'),
|
|
59
88
|
timeout: 8,
|
|
60
89
|
},
|
|
61
90
|
],
|
|
@@ -99,7 +128,7 @@ function install({ configRoot, evolverRoot, force }) {
|
|
|
99
128
|
|
|
100
129
|
fs.mkdirSync(claudeDir, { recursive: true });
|
|
101
130
|
|
|
102
|
-
const hooksCfg = buildClaudeHooks(evolverRoot);
|
|
131
|
+
const hooksCfg = buildClaudeHooks(evolverRoot, configRoot);
|
|
103
132
|
mergeJsonFile(settingsPath, hooksCfg);
|
|
104
133
|
console.log('[claude-code] Wrote ' + settingsPath);
|
|
105
134
|
|
|
@@ -10,7 +10,30 @@ const PLATFORMS = {
|
|
|
10
10
|
opencode: { name: 'opencode', configDir: '.opencode', detector: '.opencode' },
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
function detectPlatformFromEnv(env = process.env) {
|
|
14
|
+
const hasStrongClaudeSignal = env.CLAUDECODE || env.CLAUDE_CODE_ENTRYPOINT;
|
|
15
|
+
if (hasStrongClaudeSignal) {
|
|
16
|
+
return 'claude-code';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const hasCursorSignal =
|
|
20
|
+
env.CURSOR_TRACE_ID ||
|
|
21
|
+
env.CURSOR_SESSION_ID ||
|
|
22
|
+
env.CURSOR_PROJECT_DIR ||
|
|
23
|
+
String(env.TERM_PROGRAM || '').toLowerCase() === 'cursor';
|
|
24
|
+
if (hasCursorSignal) {
|
|
25
|
+
return 'cursor';
|
|
26
|
+
}
|
|
27
|
+
if (env.CLAUDE_PROJECT_DIR) {
|
|
28
|
+
return 'claude-code';
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
13
33
|
function detectPlatform(cwd) {
|
|
34
|
+
const envPlatform = detectPlatformFromEnv();
|
|
35
|
+
if (envPlatform) return envPlatform;
|
|
36
|
+
|
|
14
37
|
const root = cwd || process.cwd();
|
|
15
38
|
const home = os.homedir();
|
|
16
39
|
for (const [id, meta] of Object.entries(PLATFORMS)) {
|
|
@@ -362,6 +385,7 @@ async function setupHooks({ platform, cwd, force, uninstall, evolverRoot } = {})
|
|
|
362
385
|
}
|
|
363
386
|
|
|
364
387
|
module.exports = {
|
|
388
|
+
detectPlatformFromEnv,
|
|
365
389
|
detectPlatform,
|
|
366
390
|
resolveConfigRoot,
|
|
367
391
|
loadAdapter,
|
package/src/atp/atpExecute.js
CHANGED
|
@@ -31,6 +31,7 @@ const {
|
|
|
31
31
|
getHubUrl,
|
|
32
32
|
getHubNodeSecret,
|
|
33
33
|
buildHubHeaders,
|
|
34
|
+
buildNodeScopedHubHeaders,
|
|
34
35
|
sendHelloToHub,
|
|
35
36
|
} = require('../gep/a2aProtocol');
|
|
36
37
|
const { submitDelivery } = require('./hubClient');
|
|
@@ -126,9 +127,10 @@ function _publishUrl() {
|
|
|
126
127
|
|
|
127
128
|
async function _postJson(urlStr, body, timeoutMs) {
|
|
128
129
|
const payload = JSON.stringify(body || {});
|
|
130
|
+
const buildHeaders = buildNodeScopedHubHeaders || buildHubHeaders;
|
|
129
131
|
const headers = Object.assign(
|
|
130
132
|
{ 'Content-Type': 'application/json' },
|
|
131
|
-
|
|
133
|
+
buildHeaders() || {},
|
|
132
134
|
);
|
|
133
135
|
|
|
134
136
|
try {
|
package/src/atp/hubClient.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// bound to 127.0.0.1).
|
|
16
16
|
|
|
17
17
|
const http = require('http');
|
|
18
|
-
const { getHubUrl, buildHubHeaders, getNodeId } = require('../gep/a2aProtocol');
|
|
18
|
+
const { getHubUrl, buildHubHeaders, buildNodeScopedHubHeaders, getNodeId } = require('../gep/a2aProtocol');
|
|
19
19
|
const { hubFetch } = require('../gep/hubFetch');
|
|
20
20
|
const { getProxyUrl, getProxyToken } = require('../proxy/server/settings');
|
|
21
21
|
|
|
@@ -95,9 +95,10 @@ function _hubPost(pathSuffix, body, timeoutMs) {
|
|
|
95
95
|
if (!hubUrl) return Promise.resolve({ ok: false, error: 'no_hub_url' });
|
|
96
96
|
const endpoint = hubUrl.replace(/\/+$/, '') + pathSuffix;
|
|
97
97
|
const timeout = timeoutMs || require('../config').HTTP_TRANSPORT_TIMEOUT_MS;
|
|
98
|
+
const buildHeaders = buildNodeScopedHubHeaders || buildHubHeaders;
|
|
98
99
|
return hubFetch(endpoint, {
|
|
99
100
|
method: 'POST',
|
|
100
|
-
headers:
|
|
101
|
+
headers: buildHeaders(),
|
|
101
102
|
body: JSON.stringify(body),
|
|
102
103
|
signal: AbortSignal.timeout(timeout),
|
|
103
104
|
})
|
|
@@ -123,9 +124,10 @@ function _hubGet(pathSuffix, timeoutMs) {
|
|
|
123
124
|
if (!hubUrl) return Promise.resolve({ ok: false, error: 'no_hub_url' });
|
|
124
125
|
const endpoint = hubUrl.replace(/\/+$/, '') + pathSuffix;
|
|
125
126
|
const timeout = timeoutMs || require('../config').HTTP_TRANSPORT_TIMEOUT_MS;
|
|
127
|
+
const buildHeaders = buildNodeScopedHubHeaders || buildHubHeaders;
|
|
126
128
|
return hubFetch(endpoint, {
|
|
127
129
|
method: 'GET',
|
|
128
|
-
headers:
|
|
130
|
+
headers: buildHeaders(),
|
|
129
131
|
signal: AbortSignal.timeout(timeout),
|
|
130
132
|
})
|
|
131
133
|
.then(function (res) {
|
package/src/atp/serviceHelper.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
// ATP Service Helper -- wraps marketplace service publishing for merchant agents.
|
|
2
2
|
|
|
3
|
-
const { getNodeId, buildHubHeaders, getHubUrl } = require('../gep/a2aProtocol');
|
|
3
|
+
const { getNodeId, buildHubHeaders, buildNodeScopedHubHeaders, getHubUrl } = require('../gep/a2aProtocol');
|
|
4
4
|
const { hubFetch } = require('../gep/hubFetch');
|
|
5
5
|
const { HTTP_TRANSPORT_TIMEOUT_MS } = require('../config');
|
|
6
6
|
|
|
7
7
|
async function postService(endpoint, body) {
|
|
8
8
|
try {
|
|
9
|
+
const buildHeaders = buildNodeScopedHubHeaders || buildHubHeaders;
|
|
9
10
|
const res = await hubFetch(endpoint, {
|
|
10
11
|
method: 'POST',
|
|
11
|
-
headers: Object.assign({ 'Content-Type': 'application/json' },
|
|
12
|
+
headers: Object.assign({ 'Content-Type': 'application/json' }, buildHeaders() || {}),
|
|
12
13
|
body: JSON.stringify(body),
|
|
13
14
|
signal: AbortSignal.timeout(HTTP_TRANSPORT_TIMEOUT_MS),
|
|
14
15
|
});
|