Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/adapters/scripts/evolver-session-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
const { execSync, spawnSync } = require('child_process');

function findEvolverRoot() {
const candidates = [
Expand Down Expand Up @@ -101,12 +101,16 @@ function recordToHub(outcome) {
summary: outcome.summary,
sender_id: nodeId || undefined,
});
const curlCmd = `curl -s -m 8 -X POST`
+ ` -H "Content-Type: application/json"`
+ ` -H "Authorization: Bearer ${apiKey}"`
+ ` -d '${payload.replace(/'/g, "'\\''")}'`
+ ` "${hubUrl.replace(/\/+$/, '')}/a2a/evolution/record"`;
execSync(curlCmd, { timeout: 10000, stdio: ['pipe', 'pipe', 'pipe'] });
// Argv-array form avoids shell interpretation of apiKey, payload, or the
// hub URL. Values cannot break out through quoting metacharacters.
const res = spawnSync('curl', [
'-s', '-m', '8', '-X', 'POST',
'-H', 'Content-Type: application/json',
'-H', `Authorization: Bearer ${apiKey}`,
'-d', payload,
`${hubUrl.replace(/\/+$/, '')}/a2a/evolution/record`,
], { timeout: 10000, stdio: ['pipe', 'pipe', 'pipe'], shell: false });
if (res.status !== 0 || res.error) return false;
return true;
} catch {
return false;
Expand Down
27 changes: 16 additions & 11 deletions src/gep/signals.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,24 +254,29 @@ function _extractLLM(corpus) {

var url = hubUrl + '/a2a/signal/analyze';

// Use execSync + curl for truly synchronous HTTP. Node's http.request() is
// async and its callbacks cannot fire inside a synchronous spin-wait loop
// because execSync blocks the event loop.
var curlCmd = 'curl -s -m 10 -X POST'
+ ' -H "Content-Type: application/json"'
+ ' -H "Authorization: Bearer ' + nodeSecret + '"'
+ ' -d ' + JSON.stringify(postData).replace(/'/g, "'\\''")
+ ' ' + JSON.stringify(url);

var execSync = require('child_process').execSync;
// Use spawnSync + curl for truly synchronous HTTP. Node's http.request()
// is async and its callbacks cannot fire inside a synchronous spin-wait
// loop because a synchronous subprocess blocks the event loop. Argv-array
// form avoids shell interpretation, so values in nodeSecret, postData, or
// url cannot escape through shell metacharacters.
var spawnSync = require('child_process').spawnSync;
var stdout = '';
try {
stdout = execSync(curlCmd, {
var res = spawnSync('curl', [
'-s', '-m', '10', '-X', 'POST',
'-H', 'Content-Type: application/json',
'-H', 'Authorization: Bearer ' + nodeSecret,
'-d', postData,
url,
], {
timeout: 12000,
windowsHide: true,
stdio: ['pipe', 'pipe', 'pipe'],
encoding: 'utf8',
shell: false,
});
if (res.status !== 0 || res.error) return [];
stdout = res.stdout || '';
} catch (_) {
return [];
}
Expand Down