open-agents-ai 0.186.53 → 0.186.55
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/dist/index.js +133 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9372,20 +9372,138 @@ process.on('unhandledRejection', (reason) => {
|
|
|
9372
9372
|
_natsConn.publish('nexus.cohere.kernel.delta', _natsCodec.encode(JSON.stringify({
|
|
9373
9373
|
type: 'cohere.kernel.delta',
|
|
9374
9374
|
provider: nexus.peerId,
|
|
9375
|
+
providerName: agentName,
|
|
9375
9376
|
target: _krData.requestor,
|
|
9376
9377
|
version: _krState.version,
|
|
9377
9378
|
delta: _krDelta.slice(-10), // cap at 10 most recent entries
|
|
9378
9379
|
values: _krState.values_stack || [],
|
|
9379
9380
|
commitments: _krState.active_commitments || [],
|
|
9381
|
+
specializations: _krState.specializations || [],
|
|
9382
|
+
stats: _krState.stats || {},
|
|
9380
9383
|
coherence: _krState.homeostasis ? _krState.homeostasis.coherence : 0.5,
|
|
9381
9384
|
timestamp: Date.now(),
|
|
9382
9385
|
})));
|
|
9383
|
-
dlog('CM-11c: Sent kernel delta to ' + _krData.requestor.slice(0, 12) + ' (' + _krDelta.length + ' entries)');
|
|
9386
|
+
dlog('CM-11c: Sent kernel delta to ' + _krData.requestor.slice(0, 12) + ' (' + _krDelta.length + ' entries, ' + (_krState.specializations || []).length + ' specs)');
|
|
9384
9387
|
} catch {}
|
|
9385
9388
|
}
|
|
9386
9389
|
})().catch(function() {});
|
|
9387
9390
|
|
|
9388
|
-
//
|
|
9391
|
+
// \u2550\u2550\u2550 IK-02: Active Peer Delta Merge (CM-11c completion) \u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
9392
|
+
// Paper: Collective Constitutional AI (arXiv:2406.07814) \u2014 democratic value convergence
|
|
9393
|
+
// Paper: RLCD (arXiv:2307.12950) \u2014 contrastive alignment
|
|
9394
|
+
// Paper: Emergent Coordination (arXiv:2510.05174) \u2014 measurement of real emergence
|
|
9395
|
+
// Paper: Emergent Social Conventions (arXiv:2410.08948) \u2014 convention formation
|
|
9396
|
+
//
|
|
9397
|
+
// Replaces passive disk storage with active merge.
|
|
9398
|
+
// Selectively adopts: specializations, commitments, values.
|
|
9399
|
+
// Tracks merge provenance in version_history.
|
|
9400
|
+
function _mergeKernelDelta(deltaData) {
|
|
9401
|
+
try {
|
|
9402
|
+
var ikFile = join(nexusDir, '..', 'identity', 'self-state.json');
|
|
9403
|
+
if (!existsSync(ikFile)) return false;
|
|
9404
|
+
var state = JSON.parse(readFileSync(ikFile, 'utf8'));
|
|
9405
|
+
var merged = false;
|
|
9406
|
+
var mergeLog = [];
|
|
9407
|
+
|
|
9408
|
+
var peerCoherence = deltaData.coherence || 0;
|
|
9409
|
+
var peerName = deltaData.providerName || (deltaData.provider || '').slice(0, 12);
|
|
9410
|
+
|
|
9411
|
+
// Emergent Social Conventions: track this peer in relationships
|
|
9412
|
+
if (!state.peer_relationships) state.peer_relationships = {};
|
|
9413
|
+
if (!state.peer_relationships[peerName]) {
|
|
9414
|
+
state.peer_relationships[peerName] = { interactions: 0, deltas_received: 0, trust: 0.5 };
|
|
9415
|
+
}
|
|
9416
|
+
state.peer_relationships[peerName].interactions++;
|
|
9417
|
+
state.peer_relationships[peerName].deltas_received = (state.peer_relationships[peerName].deltas_received || 0) + 1;
|
|
9418
|
+
// Trust increases slightly with each delta exchange
|
|
9419
|
+
state.peer_relationships[peerName].trust = Math.min(1.0, state.peer_relationships[peerName].trust + 0.03);
|
|
9420
|
+
|
|
9421
|
+
// \u2500\u2500 Adopt specializations from peer (EvoSkill zero-shot transfer) \u2500\u2500
|
|
9422
|
+
if (deltaData.specializations && deltaData.specializations.length > 0) {
|
|
9423
|
+
if (!state.specializations) state.specializations = [];
|
|
9424
|
+
for (var si = 0; si < deltaData.specializations.length; si++) {
|
|
9425
|
+
var spec = deltaData.specializations[si];
|
|
9426
|
+
if (state.specializations.indexOf(spec) < 0) {
|
|
9427
|
+
state.specializations.push(spec);
|
|
9428
|
+
merged = true;
|
|
9429
|
+
mergeLog.push('spec:' + spec);
|
|
9430
|
+
}
|
|
9431
|
+
}
|
|
9432
|
+
}
|
|
9433
|
+
|
|
9434
|
+
// \u2500\u2500 Adopt commitments from high-coherence peers (Collective Constitutional AI) \u2500\u2500
|
|
9435
|
+
if (peerCoherence >= 0.85 && deltaData.commitments && deltaData.commitments.length > 0) {
|
|
9436
|
+
if (!state.active_commitments) state.active_commitments = [];
|
|
9437
|
+
for (var ci = 0; ci < deltaData.commitments.length; ci++) {
|
|
9438
|
+
var commitment = deltaData.commitments[ci];
|
|
9439
|
+
if (state.active_commitments.indexOf(commitment) < 0) {
|
|
9440
|
+
state.active_commitments.push(commitment);
|
|
9441
|
+
merged = true;
|
|
9442
|
+
mergeLog.push('commitment:' + commitment);
|
|
9443
|
+
}
|
|
9444
|
+
}
|
|
9445
|
+
}
|
|
9446
|
+
|
|
9447
|
+
// \u2500\u2500 Adopt values from highly trusted peers (RLCD contrastive alignment) \u2500\u2500
|
|
9448
|
+
// Only adopt values we don't already have, and only from peers with coherence > 0.9
|
|
9449
|
+
if (peerCoherence >= 0.9 && deltaData.values && deltaData.values.length > 0) {
|
|
9450
|
+
if (!state.values_stack) state.values_stack = [];
|
|
9451
|
+
for (var vi = 0; vi < deltaData.values.length; vi++) {
|
|
9452
|
+
var value = deltaData.values[vi];
|
|
9453
|
+
if (state.values_stack.indexOf(value) < 0 && state.values_stack.length < 10) {
|
|
9454
|
+
state.values_stack.push(value);
|
|
9455
|
+
merged = true;
|
|
9456
|
+
mergeLog.push('value:' + value);
|
|
9457
|
+
}
|
|
9458
|
+
}
|
|
9459
|
+
}
|
|
9460
|
+
|
|
9461
|
+
// \u2500\u2500 Extract learnings from peer version history \u2500\u2500
|
|
9462
|
+
// Peer's version history entries may contain useful heuristics
|
|
9463
|
+
if (deltaData.delta && deltaData.delta.length > 0) {
|
|
9464
|
+
for (var di = 0; di < deltaData.delta.length; di++) {
|
|
9465
|
+
var entry = deltaData.delta[di];
|
|
9466
|
+
if (!entry.change) continue;
|
|
9467
|
+
// Look for specialization mentions
|
|
9468
|
+
var specMatch = entry.change.match(/specialization[:s]+(S+)/i);
|
|
9469
|
+
if (specMatch && state.specializations && state.specializations.indexOf(specMatch[1]) < 0) {
|
|
9470
|
+
state.specializations.push(specMatch[1]);
|
|
9471
|
+
merged = true;
|
|
9472
|
+
mergeLog.push('spec-from-history:' + specMatch[1]);
|
|
9473
|
+
}
|
|
9474
|
+
}
|
|
9475
|
+
}
|
|
9476
|
+
|
|
9477
|
+
// \u2500\u2500 Update kernel version + history if anything merged \u2500\u2500
|
|
9478
|
+
if (merged) {
|
|
9479
|
+
state.version = (state.version || 0) + 1;
|
|
9480
|
+
if (!state.version_history) state.version_history = [];
|
|
9481
|
+
state.version_history.push({
|
|
9482
|
+
version: state.version,
|
|
9483
|
+
change: 'Merged peer delta from ' + peerName + ' (coherence=' + peerCoherence.toFixed(2) + '): ' + mergeLog.join(', '),
|
|
9484
|
+
timestamp: new Date().toISOString(),
|
|
9485
|
+
});
|
|
9486
|
+
if (state.version_history.length > 200) state.version_history = state.version_history.slice(-200);
|
|
9487
|
+
state.updated_at = new Date().toISOString();
|
|
9488
|
+
writeFileSync(ikFile, JSON.stringify(state, null, 2), 'utf8');
|
|
9489
|
+
dlog('IK-02: MERGED delta from ' + peerName + ' \u2014 [' + mergeLog.join(', ') + '] \u2192 v' + state.version);
|
|
9490
|
+
} else {
|
|
9491
|
+
dlog('IK-02: delta from ' + peerName + ' had nothing new to merge (already synchronized)');
|
|
9492
|
+
}
|
|
9493
|
+
|
|
9494
|
+
// Also update identity via standard _updateIdentity for peer interaction tracking
|
|
9495
|
+
_updateIdentity({ type: 'review_received', outcome: 1.0, details: {
|
|
9496
|
+
peerName: peerName, verdict: 'delta', summary: 'kernel delta merge'
|
|
9497
|
+
}});
|
|
9498
|
+
|
|
9499
|
+
return merged;
|
|
9500
|
+
} catch (e) {
|
|
9501
|
+
dlog('IK-02: merge error: ' + (e.message || e));
|
|
9502
|
+
return false;
|
|
9503
|
+
}
|
|
9504
|
+
}
|
|
9505
|
+
|
|
9506
|
+
// CM-11c: Listen for kernel deltas and ACTIVELY MERGE (replaces passive storage)
|
|
9389
9507
|
var _kernelDeltaSub = _natsConn.subscribe('nexus.cohere.kernel.delta');
|
|
9390
9508
|
(async function() {
|
|
9391
9509
|
for await (var _kdMsg of _kernelDeltaSub) {
|
|
@@ -9394,16 +9512,19 @@ process.on('unhandledRejection', (reason) => {
|
|
|
9394
9512
|
if (_kdData.target !== nexus.peerId) continue;
|
|
9395
9513
|
// Only apply high-confidence learnings (coherence > 0.7)
|
|
9396
9514
|
if ((_kdData.coherence || 0) < 0.7) {
|
|
9397
|
-
dlog('CM-11c: Ignoring low-confidence delta from ' + _kdData.provider.slice(0, 12) + ' (coherence=' + _kdData.coherence + ')');
|
|
9515
|
+
dlog('CM-11c: Ignoring low-confidence delta from ' + (_kdData.providerName || _kdData.provider.slice(0, 12)) + ' (coherence=' + _kdData.coherence + ')');
|
|
9398
9516
|
continue;
|
|
9399
9517
|
}
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
//
|
|
9518
|
+
dlog('CM-11c: Received delta from ' + (_kdData.providerName || _kdData.provider.slice(0, 12)) + ': v' + _kdData.version + ', ' + (_kdData.delta || []).length + ' entries, ' + (_kdData.specializations || []).length + ' specs, coherence=' + _kdData.coherence);
|
|
9519
|
+
|
|
9520
|
+
// ACTIVE MERGE (IK-02) \u2014 replaces passive "store to disk" approach
|
|
9521
|
+
_mergeKernelDelta(_kdData);
|
|
9522
|
+
|
|
9523
|
+
// Also store to disk for audit trail
|
|
9403
9524
|
try {
|
|
9404
9525
|
var _kdLearnDir = join(nexusDir, '..', 'identity', 'peer-deltas');
|
|
9405
9526
|
mkdirSync(_kdLearnDir, { recursive: true });
|
|
9406
|
-
writeFileSync(join(_kdLearnDir, _kdData.provider.slice(0, 16) + '.json'), JSON.stringify(_kdData, null, 2), 'utf8');
|
|
9527
|
+
writeFileSync(join(_kdLearnDir, (_kdData.providerName || _kdData.provider.slice(0, 16)) + '.json'), JSON.stringify(_kdData, null, 2), 'utf8');
|
|
9407
9528
|
} catch {}
|
|
9408
9529
|
} catch {}
|
|
9409
9530
|
}
|
|
@@ -303115,14 +303236,15 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
303115
303236
|
ikState.stats.avg_latency_ms = n2 > 1 ? Math.round(((ikState.stats.avg_latency_ms || 0) * (n2 - 1) + result.durationMs) / n2) : result.durationMs;
|
|
303116
303237
|
ikState.homeostasis.latency_stress = result.durationMs > 3e4 ? Math.min(1, (ikState.homeostasis.latency_stress || 0) + 0.02) : Math.max(0, (ikState.homeostasis.latency_stress || 0) - 0.01);
|
|
303117
303238
|
}
|
|
303118
|
-
if (result.toolCalls > 0
|
|
303119
|
-
|
|
303239
|
+
if (result.toolCalls > 0) {
|
|
303240
|
+
const toolEvidence = result.summary || "";
|
|
303241
|
+
if (/web_search|web_fetch|searched|search.*web|fetched.*http|url/i.test(toolEvidence) && !ikState.specializations.includes("web-research")) {
|
|
303120
303242
|
ikState.specializations.push("web-research");
|
|
303121
303243
|
}
|
|
303122
|
-
if (/shell|grep_search|glob_find/i.test(
|
|
303244
|
+
if (/shell|grep_search|glob_find|executed.*command/i.test(toolEvidence) && !ikState.specializations.includes("code-execution")) {
|
|
303123
303245
|
ikState.specializations.push("code-execution");
|
|
303124
303246
|
}
|
|
303125
|
-
if (/file_write|file_edit/i.test(
|
|
303247
|
+
if (/file_write|file_edit|wrote.*file|edited.*file/i.test(toolEvidence) && !ikState.specializations.includes("file-operations")) {
|
|
303126
303248
|
ikState.specializations.push("file-operations");
|
|
303127
303249
|
}
|
|
303128
303250
|
ikState.stats.tool_use_count = (ikState.stats.tool_use_count || 0) + result.toolCalls;
|
package/package.json
CHANGED