open-agents-ai 0.186.45 → 0.186.46

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 (2) hide show
  1. package/dist/index.js +37 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8094,7 +8094,19 @@ process.on('unhandledRejection', (reason) => {
8094
8094
  dlog('COHERE triage: ' + _cData.queryId + ' tier=' + ['trivial','moderate','complex','expert'][_cTier] + ' tags=[' + _cTags.join(',') + '] minParams=' + (_cMinParams/1e9) + 'B');
8095
8095
  dlog('COHERE: entering mood/bid/election phase');
8096
8096
 
8097
- // CO-03: Mood/excitement \u2014 publish before bidding
8097
+ // Phase B: Collect GPU metrics + compute bid FIRST (mood needs real values)
8098
+ var _cGpuUtil = 50; // default if no metrics
8099
+ try {
8100
+ var _cSysm = await _collectSysMetrics();
8101
+ if (_cSysm && _cSysm.gpu && typeof _cSysm.gpu.utilization === 'number') _cGpuUtil = _cSysm.gpu.utilization;
8102
+ dlog('COHERE GPU: util=' + _cGpuUtil + '% available=' + (_cSysm && _cSysm.gpu ? _cSysm.gpu.available : 'N/A') + ' name=' + (_cSysm && _cSysm.gpu ? _cSysm.gpu.name : 'N/A'));
8103
+ } catch {}
8104
+ var _cWarmMatch = _cLastModel ? 1.0 : 0.3; // 1.0 if warm, 0.3 if cold
8105
+ var _cModelQuality = 0.5; // default \u2014 refined after model selection
8106
+ var _cAvgLat = _cohereStats.queriesAnswered > 0 ? Math.round(_cohereStats.totalLatencyMs / _cohereStats.queriesAnswered) : 5000;
8107
+ var _cTrackRecord = Math.min(1, (_cohereStats.queriesAnswered || 0) / 50);
8108
+
8109
+ // CO-03: Mood/excitement \u2014 publish before bidding (uses real GPU metrics now)
8098
8110
  var _cWarmSpec = 'general';
8099
8111
  if (_cLastModel) {
8100
8112
  if (/code|coder/i.test(_cLastModel)) _cWarmSpec = 'code';
@@ -8103,13 +8115,13 @@ process.on('unhandledRejection', (reason) => {
8103
8115
  var _cSpecMatch = true; // model decides relevance, not us
8104
8116
  var _cExcitement = parseFloat((
8105
8117
  (_cLastModel ? (_cSpecMatch ? 1.0 : 0.5) : 0.2) * 0.4 + // warm + specialty match
8106
- (1 - (_cGpuUtil || 50) / 100) * 0.25 + // GPU availability
8118
+ (1 - _cGpuUtil / 100) * 0.25 + // GPU availability (real value)
8107
8119
  0.5 * 0.2 + // model quality placeholder
8108
- Math.min(1, (_cohereStats.queriesAnswered || 0) / 50) * 0.15 // track record
8120
+ _cTrackRecord * 0.15 // track record
8109
8121
  ).toFixed(2));
8110
8122
  var _cMoodReason = (_cLastModel ? 'warm ' + _cLastModel : 'no warm model') +
8111
8123
  (_cSpecMatch ? ' matches' : ' general') +
8112
- ', GPU ' + (_cGpuUtil || 50) + '%';
8124
+ ', GPU ' + _cGpuUtil + '%';
8113
8125
 
8114
8126
  _natsConn.publish('nexus.cohere.mood', _natsCodec.encode(JSON.stringify({
8115
8127
  type: 'cohere.mood',
@@ -8118,24 +8130,13 @@ process.on('unhandledRejection', (reason) => {
8118
8130
  agentName: agentName,
8119
8131
  excitement: _cExcitement,
8120
8132
  warmModel: _cLastModel || null,
8121
- estimatedLatency: _cLastModel ? (_cAvgLat || 500) : ((_cAvgLat || 500) * 3),
8133
+ estimatedLatency: _cLastModel ? _cAvgLat : _cAvgLat * 3,
8122
8134
  reason: _cMoodReason,
8123
8135
  tier: _cTier,
8124
8136
  tags: _cTags,
8125
8137
  timestamp: Date.now(),
8126
8138
  })));
8127
8139
  dlog('COHERE mood: excitement=' + _cExcitement + ' reason=' + _cMoodReason);
8128
-
8129
- // Phase B: Compute local bid score (CO-05 warm/cold logic)
8130
- var _cGpuUtil = 50; // default if no metrics
8131
- try {
8132
- var _cSysm = await _collectSysMetrics();
8133
- if (_cSysm && typeof _cSysm.gpu === 'number' && !isNaN(_cSysm.gpu)) _cGpuUtil = _cSysm.gpu;
8134
- } catch {}
8135
- var _cWarmMatch = _cLastModel ? 1.0 : 0.3; // 1.0 if warm, 0.3 if cold
8136
- var _cModelQuality = 0.5; // default \u2014 refined after model selection
8137
- var _cAvgLat = _cohereStats.queriesAnswered > 0 ? Math.round(_cohereStats.totalLatencyMs / _cohereStats.queriesAnswered) : 5000;
8138
- var _cTrackRecord = Math.min(1, (_cohereStats.queriesAnswered || 0) / 50);
8139
8140
  var _cBidScore = parseFloat((
8140
8141
  _cWarmMatch * 0.4 +
8141
8142
  (1 - _cGpuUtil / 100) * 0.25 +
@@ -288005,12 +288006,22 @@ var init_banner = __esm({
288005
288006
  buf += "\x1B[0m";
288006
288007
  }
288007
288008
  buf += "\x1B[0m";
288008
- process.stdout.write(buf);
288009
+ try {
288010
+ process.stdout.write(buf);
288011
+ } catch (err) {
288012
+ if (err?.code === "EIO" || err?.code === "EPIPE" || err?.code === "ERR_STREAM_DESTROYED") {
288013
+ this.stop();
288014
+ return;
288015
+ }
288016
+ }
288009
288017
  if (this.onAfterRender)
288010
288018
  this.onAfterRender();
288011
288019
  const termRows = process.stdout.rows ?? 24;
288012
288020
  const inputRow = termRows - 2;
288013
- process.stdout.write(`\x1B[${inputRow};1H\x1B[?2026l`);
288021
+ try {
288022
+ process.stdout.write(`\x1B[${inputRow};1H\x1B[?2026l`);
288023
+ } catch {
288024
+ }
288014
288025
  }
288015
288026
  /** Handle terminal resize */
288016
288027
  handleResize() {
@@ -295832,7 +295843,14 @@ var init_status_bar = __esm({
295832
295843
  /** Write directly to the terminal, bypassing ALL interceptors.
295833
295844
  * ALL footer/input/braille rendering MUST use this, never process.stdout.write. */
295834
295845
  termWrite(data) {
295835
- this._trueStdoutWrite.call(process.stdout, data);
295846
+ try {
295847
+ this._trueStdoutWrite.call(process.stdout, data);
295848
+ } catch (err) {
295849
+ if (err?.code === "EIO" || err?.code === "EPIPE" || err?.code === "ERR_STREAM_DESTROYED") {
295850
+ this.stopAllMetrics();
295851
+ this.active = false;
295852
+ }
295853
+ }
295836
295854
  }
295837
295855
  beginContentWrite() {
295838
295856
  if (!this.active)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.186.45",
3
+ "version": "0.186.46",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",