agent-relay 2.0.6 → 2.0.7

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 (145) hide show
  1. package/deploy/workspace/entrypoint.sh +80 -22
  2. package/deploy/workspace/gh-credential-relay +90 -0
  3. package/dist/dashboard/out/404.html +1 -1
  4. package/{packages/dashboard/ui-dist/_next/static/chunks/677-7323947c23b35979.js → dist/dashboard/out/_next/static/chunks/320-22ebe7be58cf982a.js} +1 -1
  5. package/dist/dashboard/out/_next/static/chunks/app/app/onboarding/page-9914652442f7e4fb.js +1 -0
  6. package/{packages/dashboard/ui-dist/_next/static/chunks/app/app/page-2e525b1dcc790967.js → dist/dashboard/out/_next/static/chunks/app/app/page-9d6bc8729b429956.js} +1 -1
  7. package/{packages/dashboard/ui-dist/_next/static/chunks/app/cloud/link/page-5011ae044b90449d.js → dist/dashboard/out/_next/static/chunks/app/cloud/link/page-fa1d5842aa90e8a6.js} +1 -1
  8. package/dist/dashboard/out/_next/static/chunks/app/connect-repos/page-113060009ef35bc2.js +1 -0
  9. package/{packages/dashboard/ui-dist/_next/static/chunks/app/history/page-b2ce7c96ed0931da.js → dist/dashboard/out/_next/static/chunks/app/history/page-9965d2483011b846.js} +1 -1
  10. package/dist/dashboard/out/_next/static/chunks/app/layout-6b91e33784c20610.js +1 -0
  11. package/{packages/dashboard/ui-dist/_next/static/chunks/app/login/page-6ec54eee75877971.js → dist/dashboard/out/_next/static/chunks/app/login/page-a0ca6f7ca6a100b8.js} +1 -1
  12. package/{packages/dashboard/ui-dist/_next/static/chunks/app/metrics/page-bf2cb1e5915bc92d.js → dist/dashboard/out/_next/static/chunks/app/metrics/page-1e37ef8e73940b40.js} +1 -1
  13. package/dist/dashboard/out/_next/static/chunks/app/{page-4e64923d73c35bc9.js → page-487fa38f041815c1.js} +1 -1
  14. package/dist/dashboard/out/_next/static/chunks/app/pricing/page-9db3ebdfa567a7c9.js +1 -0
  15. package/dist/dashboard/out/_next/static/chunks/app/providers/page-bcf46064ac4474ce.js +1 -0
  16. package/dist/dashboard/out/_next/static/chunks/app/providers/setup/[provider]/{page-84161c802b020a1f.js → page-4dbe33f0f7691b7c.js} +1 -1
  17. package/dist/dashboard/out/_next/static/chunks/app/signup/{page-18a4665665f6be11.js → page-1ede2205b58649ca.js} +1 -1
  18. package/dist/dashboard/out/_next/static/chunks/main-app-fdbeb09028f57c9f.js +1 -0
  19. package/dist/dashboard/out/app/onboarding.html +1 -1
  20. package/dist/dashboard/out/app/onboarding.txt +2 -2
  21. package/dist/dashboard/out/app.html +1 -1
  22. package/dist/dashboard/out/app.txt +2 -2
  23. package/dist/dashboard/out/cloud/link.html +1 -1
  24. package/dist/dashboard/out/cloud/link.txt +2 -2
  25. package/dist/dashboard/out/connect-repos.html +1 -1
  26. package/dist/dashboard/out/connect-repos.txt +2 -2
  27. package/dist/dashboard/out/history.html +1 -1
  28. package/dist/dashboard/out/history.txt +2 -2
  29. package/dist/dashboard/out/index.html +1 -1
  30. package/dist/dashboard/out/index.txt +2 -2
  31. package/dist/dashboard/out/login.html +2 -2
  32. package/dist/dashboard/out/login.txt +2 -2
  33. package/dist/dashboard/out/metrics.html +1 -1
  34. package/dist/dashboard/out/metrics.txt +2 -2
  35. package/dist/dashboard/out/pricing.html +2 -2
  36. package/dist/dashboard/out/pricing.txt +2 -2
  37. package/dist/dashboard/out/providers/setup/claude.html +1 -1
  38. package/dist/dashboard/out/providers/setup/claude.txt +2 -2
  39. package/dist/dashboard/out/providers/setup/codex.html +1 -1
  40. package/dist/dashboard/out/providers/setup/codex.txt +2 -2
  41. package/dist/dashboard/out/providers/setup/cursor.html +1 -1
  42. package/dist/dashboard/out/providers/setup/cursor.txt +2 -2
  43. package/dist/dashboard/out/providers.html +1 -1
  44. package/dist/dashboard/out/providers.txt +2 -2
  45. package/dist/dashboard/out/signup.html +2 -2
  46. package/dist/dashboard/out/signup.txt +2 -2
  47. package/package.json +14 -14
  48. package/packages/api-types/package.json +1 -1
  49. package/packages/bridge/dist/spawner.js +9 -0
  50. package/packages/bridge/package.json +7 -7
  51. package/packages/cloud/dist/server.js +3 -3
  52. package/packages/cloud/package.json +6 -6
  53. package/packages/config/package.json +2 -2
  54. package/packages/continuity/package.json +1 -1
  55. package/packages/daemon/package.json +12 -12
  56. package/packages/dashboard/dist/server.js +9 -9
  57. package/packages/dashboard/package.json +12 -12
  58. package/packages/dashboard/ui/react-components/App.tsx +21 -435
  59. package/packages/dashboard/ui/react-components/ChannelChat.tsx +29 -75
  60. package/packages/dashboard/ui/react-components/MessageComposer.tsx +457 -0
  61. package/packages/dashboard/ui-dist/404.html +1 -1
  62. package/packages/dashboard/ui-dist/_next/static/chunks/320-22ebe7be58cf982a.js +1 -0
  63. package/{dist/dashboard/out/_next/static/chunks/app/app/page-2e525b1dcc790967.js → packages/dashboard/ui-dist/_next/static/chunks/app/app/page-9d6bc8729b429956.js} +1 -1
  64. package/packages/dashboard/ui-dist/_next/static/chunks/app/{page-4e64923d73c35bc9.js → page-487fa38f041815c1.js} +1 -1
  65. package/packages/dashboard/ui-dist/app/onboarding.html +1 -1
  66. package/packages/dashboard/ui-dist/app/onboarding.txt +2 -2
  67. package/packages/dashboard/ui-dist/app.html +1 -1
  68. package/packages/dashboard/ui-dist/app.txt +2 -2
  69. package/packages/dashboard/ui-dist/cloud/link.html +1 -1
  70. package/packages/dashboard/ui-dist/cloud/link.txt +2 -2
  71. package/packages/dashboard/ui-dist/connect-repos.html +1 -1
  72. package/packages/dashboard/ui-dist/connect-repos.txt +2 -2
  73. package/packages/dashboard/ui-dist/history.html +1 -1
  74. package/packages/dashboard/ui-dist/history.txt +2 -2
  75. package/packages/dashboard/ui-dist/index.html +1 -1
  76. package/packages/dashboard/ui-dist/index.txt +2 -2
  77. package/packages/dashboard/ui-dist/login.html +2 -2
  78. package/packages/dashboard/ui-dist/login.txt +2 -2
  79. package/packages/dashboard/ui-dist/metrics.html +1 -1
  80. package/packages/dashboard/ui-dist/metrics.txt +2 -2
  81. package/packages/dashboard/ui-dist/pricing.html +2 -2
  82. package/packages/dashboard/ui-dist/pricing.txt +2 -2
  83. package/packages/dashboard/ui-dist/providers/setup/claude.html +1 -1
  84. package/packages/dashboard/ui-dist/providers/setup/claude.txt +2 -2
  85. package/packages/dashboard/ui-dist/providers/setup/codex.html +1 -1
  86. package/packages/dashboard/ui-dist/providers/setup/codex.txt +2 -2
  87. package/packages/dashboard/ui-dist/providers/setup/cursor.html +1 -1
  88. package/packages/dashboard/ui-dist/providers/setup/cursor.txt +2 -2
  89. package/packages/dashboard/ui-dist/providers.html +1 -1
  90. package/packages/dashboard/ui-dist/providers.txt +2 -2
  91. package/packages/dashboard/ui-dist/signup.html +2 -2
  92. package/packages/dashboard/ui-dist/signup.txt +2 -2
  93. package/packages/dashboard-server/dist/server.js +5 -5
  94. package/packages/dashboard-server/package.json +12 -12
  95. package/packages/hooks/package.json +4 -4
  96. package/packages/mcp/package.json +2 -2
  97. package/packages/memory/package.json +2 -2
  98. package/packages/policy/package.json +2 -2
  99. package/packages/protocol/package.json +1 -1
  100. package/packages/resiliency/dist/cgroup-manager.d.ts +152 -0
  101. package/packages/resiliency/dist/cgroup-manager.js +394 -0
  102. package/packages/resiliency/dist/index.d.ts +1 -0
  103. package/packages/resiliency/dist/index.js +1 -0
  104. package/packages/resiliency/package.json +1 -1
  105. package/packages/sdk/package.json +2 -2
  106. package/packages/spawner/package.json +1 -1
  107. package/packages/state/package.json +1 -1
  108. package/packages/storage/package.json +2 -2
  109. package/packages/telemetry/package.json +1 -1
  110. package/packages/trajectory/package.json +2 -2
  111. package/packages/user-directory/package.json +2 -2
  112. package/packages/utils/package.json +1 -1
  113. package/packages/wrapper/dist/relay-pty-orchestrator.d.ts +8 -4
  114. package/packages/wrapper/dist/relay-pty-orchestrator.js +47 -25
  115. package/packages/wrapper/package.json +6 -6
  116. package/dist/dashboard/out/_next/static/chunks/320-900169c942e31422.js +0 -1
  117. package/dist/dashboard/out/_next/static/chunks/app/app/onboarding/page-f746f29e01fffc43.js +0 -1
  118. package/dist/dashboard/out/_next/static/chunks/app/cloud/link/page-5011ae044b90449d.js +0 -1
  119. package/dist/dashboard/out/_next/static/chunks/app/connect-repos/page-03ac6f35a6654ea6.js +0 -1
  120. package/dist/dashboard/out/_next/static/chunks/app/history/page-b2ce7c96ed0931da.js +0 -1
  121. package/dist/dashboard/out/_next/static/chunks/app/layout-c0d118c0f92d969c.js +0 -1
  122. package/dist/dashboard/out/_next/static/chunks/app/login/page-6ec54eee75877971.js +0 -1
  123. package/dist/dashboard/out/_next/static/chunks/app/metrics/page-bf2cb1e5915bc92d.js +0 -1
  124. package/dist/dashboard/out/_next/static/chunks/app/pricing/page-0efa024c28ba4597.js +0 -1
  125. package/dist/dashboard/out/_next/static/chunks/app/providers/page-e65a0010da6ea5be.js +0 -1
  126. package/dist/dashboard/out/_next/static/chunks/main-app-6e8e8d3ef4e0192a.js +0 -1
  127. package/packages/dashboard/ui-dist/_next/static/chunks/320-900169c942e31422.js +0 -1
  128. package/packages/dashboard/ui-dist/_next/static/chunks/app/app/onboarding/page-f746f29e01fffc43.js +0 -1
  129. package/packages/dashboard/ui-dist/_next/static/chunks/app/app/page-44813aa26ad19681.js +0 -1
  130. package/packages/dashboard/ui-dist/_next/static/chunks/app/connect-repos/page-03ac6f35a6654ea6.js +0 -1
  131. package/packages/dashboard/ui-dist/_next/static/chunks/app/layout-c0d118c0f92d969c.js +0 -1
  132. package/packages/dashboard/ui-dist/_next/static/chunks/app/page-7993778218818ace.js +0 -1
  133. package/packages/dashboard/ui-dist/_next/static/chunks/app/pricing/page-0efa024c28ba4597.js +0 -1
  134. package/packages/dashboard/ui-dist/_next/static/chunks/app/providers/page-e65a0010da6ea5be.js +0 -1
  135. package/packages/dashboard/ui-dist/_next/static/chunks/app/providers/setup/[provider]/page-84161c802b020a1f.js +0 -1
  136. package/packages/dashboard/ui-dist/_next/static/chunks/app/signup/page-18a4665665f6be11.js +0 -1
  137. package/packages/dashboard/ui-dist/_next/static/chunks/main-app-6e8e8d3ef4e0192a.js +0 -1
  138. /package/dist/dashboard/out/_next/static/{lIJs7zSKBaI58kpqegulQ → loxKCRf0rbwVD8vl_Gw60}/_buildManifest.js +0 -0
  139. /package/dist/dashboard/out/_next/static/{lIJs7zSKBaI58kpqegulQ → loxKCRf0rbwVD8vl_Gw60}/_ssgManifest.js +0 -0
  140. /package/packages/dashboard/ui-dist/_next/static/{KIxE0Ds_zdGuDJDQu7_sb → 1yt8VDAusp2yTBf4JFA7F}/_buildManifest.js +0 -0
  141. /package/packages/dashboard/ui-dist/_next/static/{KIxE0Ds_zdGuDJDQu7_sb → 1yt8VDAusp2yTBf4JFA7F}/_ssgManifest.js +0 -0
  142. /package/packages/dashboard/ui-dist/_next/static/{SoK46dEi3IsNBVWXD9x0L → chdCrViSD2yReZElqRfk0}/_buildManifest.js +0 -0
  143. /package/packages/dashboard/ui-dist/_next/static/{SoK46dEi3IsNBVWXD9x0L → chdCrViSD2yReZElqRfk0}/_ssgManifest.js +0 -0
  144. /package/packages/dashboard/ui-dist/_next/static/{lIJs7zSKBaI58kpqegulQ → loxKCRf0rbwVD8vl_Gw60}/_buildManifest.js +0 -0
  145. /package/packages/dashboard/ui-dist/_next/static/{lIJs7zSKBaI58kpqegulQ → loxKCRf0rbwVD8vl_Gw60}/_ssgManifest.js +0 -0
@@ -28,7 +28,7 @@ const __dirname = dirname(__filename);
28
28
  import { BaseWrapper } from './base-wrapper.js';
29
29
  import { parseSummaryWithDetails, parseSessionEndFromOutput } from './parser.js';
30
30
  import { stripAnsi, sleep, buildInjectionString, verifyInjection, INJECTION_CONSTANTS, AdaptiveThrottle, } from './shared.js';
31
- import { getMemoryMonitor, formatBytes, } from '@agent-relay/resiliency';
31
+ import { getMemoryMonitor, formatBytes, getCgroupManager, } from '@agent-relay/resiliency';
32
32
  // ============================================================================
33
33
  // Types for relay-pty socket protocol
34
34
  // ============================================================================
@@ -89,6 +89,9 @@ export class RelayPtyOrchestrator extends BaseWrapper {
89
89
  // Memory/CPU monitoring
90
90
  memoryMonitor;
91
91
  memoryAlertHandler = null;
92
+ // CPU limiting via cgroups (optional, Linux only)
93
+ cgroupManager;
94
+ hasCgroupSetup = false;
92
95
  // Note: sessionEndProcessed and lastSummaryRawContent are inherited from BaseWrapper
93
96
  constructor(config) {
94
97
  super(config);
@@ -159,6 +162,8 @@ export class RelayPtyOrchestrator extends BaseWrapper {
159
162
  this.isInteractive = config.headless ? false : (process.stdin.isTTY === true);
160
163
  // Initialize memory monitor (shared singleton, 10s polling interval)
161
164
  this.memoryMonitor = getMemoryMonitor({ checkIntervalMs: 10_000 });
165
+ // Initialize cgroup manager for CPU limiting (shared singleton)
166
+ this.cgroupManager = getCgroupManager();
162
167
  }
163
168
  /**
164
169
  * Debug log - only outputs when debug is enabled
@@ -172,9 +177,7 @@ export class RelayPtyOrchestrator extends BaseWrapper {
172
177
  * Error log - always outputs (errors are important)
173
178
  */
174
179
  logError(message) {
175
- if (this.config.debug) {
176
- console.error(`[relay-pty-orchestrator:${this.config.name}] ERROR: ${message}`);
177
- }
180
+ console.error(`[relay-pty-orchestrator:${this.config.name}] ERROR: ${message}`);
178
181
  }
179
182
  /**
180
183
  * Get the outbox path for this agent (for documentation purposes)
@@ -320,6 +323,11 @@ export class RelayPtyOrchestrator extends BaseWrapper {
320
323
  this.memoryMonitor.off('alert', this.memoryAlertHandler);
321
324
  this.memoryAlertHandler = null;
322
325
  }
326
+ // Clean up cgroup if we set one up
327
+ if (this.hasCgroupSetup) {
328
+ await this.cgroupManager.removeAgentCgroup(this.config.name);
329
+ this.hasCgroupSetup = false;
330
+ }
323
331
  this.log(` Stopping...`);
324
332
  // Send shutdown command via socket
325
333
  if (this.socket && this.socketConnected) {
@@ -478,6 +486,11 @@ export class RelayPtyOrchestrator extends BaseWrapper {
478
486
  this.memoryMonitor.off('alert', this.memoryAlertHandler);
479
487
  this.memoryAlertHandler = null;
480
488
  }
489
+ // Clean up cgroup (fire and forget - process already exited)
490
+ if (this.hasCgroupSetup) {
491
+ this.cgroupManager.removeAgentCgroup(this.config.name).catch(() => { });
492
+ this.hasCgroupSetup = false;
493
+ }
481
494
  // Broadcast crash notification if not a graceful stop
482
495
  if (!this.isGracefulStop && this.client.state === 'READY') {
483
496
  const canBroadcast = typeof this.client.broadcast === 'function';
@@ -530,6 +543,13 @@ export class RelayPtyOrchestrator extends BaseWrapper {
530
543
  if (proc.pid) {
531
544
  this.memoryMonitor.register(this.config.name, proc.pid);
532
545
  this.memoryMonitor.start(); // Idempotent - starts if not already running
546
+ // Set up CPU limiting via cgroups (if configured and available)
547
+ // This prevents one agent from starving others during npm install/build
548
+ if (this.config.cpuLimitPercent && this.config.cpuLimitPercent > 0) {
549
+ this.setupCgroupLimit(proc.pid, this.config.cpuLimitPercent).catch((err) => {
550
+ this.log(` Failed to set up cgroup CPU limit: ${err.message}`);
551
+ });
552
+ }
533
553
  // Set up alert handler to send resource alerts to dashboard only (not other agents)
534
554
  this.memoryAlertHandler = (alert) => {
535
555
  if (alert.agentName !== this.config.name)
@@ -553,6 +573,25 @@ export class RelayPtyOrchestrator extends BaseWrapper {
553
573
  this.memoryMonitor.on('alert', this.memoryAlertHandler);
554
574
  }
555
575
  }
576
+ /**
577
+ * Set up cgroup CPU limit for this agent
578
+ */
579
+ async setupCgroupLimit(pid, cpuPercent) {
580
+ await this.cgroupManager.initialize();
581
+ if (!this.cgroupManager.isAvailable()) {
582
+ this.log(` cgroups not available, skipping CPU limit`);
583
+ return;
584
+ }
585
+ const created = await this.cgroupManager.createAgentCgroup(this.config.name, { cpuPercent });
586
+ if (!created) {
587
+ return;
588
+ }
589
+ const added = await this.cgroupManager.addProcess(this.config.name, pid);
590
+ if (added) {
591
+ this.hasCgroupSetup = true;
592
+ this.log(` CPU limit set to ${cpuPercent}% for agent ${this.config.name}`);
593
+ }
594
+ }
556
595
  /**
557
596
  * Handle output from relay-pty stdout (headless mode only)
558
597
  * In interactive mode, stdout goes directly to terminal via inherited stdio
@@ -1158,10 +1197,6 @@ export class RelayPtyOrchestrator extends BaseWrapper {
1158
1197
  });
1159
1198
  });
1160
1199
  }
1161
- /** Maximum retries for failed injections before giving up */
1162
- static MAX_INJECTION_RETRIES = 5;
1163
- /** Backoff delay multiplier (ms) for retries: delay = BASE * 2^retryCount */
1164
- static INJECTION_RETRY_BASE_MS = 2000;
1165
1200
  /**
1166
1201
  * Process queued messages
1167
1202
  */
@@ -1183,30 +1218,17 @@ export class RelayPtyOrchestrator extends BaseWrapper {
1183
1218
  this.isInjecting = true;
1184
1219
  this.injectionStartTime = Date.now();
1185
1220
  const msg = this.messageQueue.shift();
1186
- const retryCount = msg._retryCount ?? 0;
1187
1221
  const bodyPreview = msg.body.substring(0, 50).replace(/\n/g, '\\n');
1188
- this.log(` Processing message from ${msg.from}: "${bodyPreview}..." (remaining=${this.messageQueue.length}, retry=${retryCount})`);
1222
+ this.log(` Processing message from ${msg.from}: "${bodyPreview}..." (remaining=${this.messageQueue.length})`);
1189
1223
  try {
1190
1224
  const success = await this.injectMessage(msg);
1191
1225
  // Metrics are now tracked in handleInjectResult which knows about retries
1192
1226
  if (!success) {
1193
1227
  // Record failure for adaptive throttling
1194
1228
  this.throttle.recordFailure();
1195
- // Re-queue with backoff if under retry limit
1196
- if (retryCount < RelayPtyOrchestrator.MAX_INJECTION_RETRIES) {
1197
- const backoffMs = RelayPtyOrchestrator.INJECTION_RETRY_BASE_MS * Math.pow(2, retryCount);
1198
- this.log(` Re-queuing message ${msg.messageId.substring(0, 8)} for retry ${retryCount + 1} in ${backoffMs}ms`);
1199
- msg._retryCount = retryCount + 1;
1200
- // Add to front of queue for priority
1201
- this.messageQueue.unshift(msg);
1202
- // Wait before retrying
1203
- this.isInjecting = false;
1204
- setTimeout(() => this.processMessageQueue(), backoffMs);
1205
- return;
1206
- }
1207
- this.logError(` Injection failed for message ${msg.messageId.substring(0, 8)} after ${retryCount} retries`);
1208
- this.config.onInjectionFailed?.(msg.messageId, 'Injection failed after max retries');
1209
- this.sendSyncAck(msg.messageId, msg.sync, 'ERROR', { error: 'injection_failed_max_retries' });
1229
+ this.logError(` Injection failed for message ${msg.messageId.substring(0, 8)}`);
1230
+ this.config.onInjectionFailed?.(msg.messageId, 'Injection failed');
1231
+ this.sendSyncAck(msg.messageId, msg.sync, 'ERROR', { error: 'injection_failed' });
1210
1232
  }
1211
1233
  else {
1212
1234
  // Record success for adaptive throttling
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-relay/wrapper",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "CLI agent wrappers for Agent Relay - tmux, pty integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,11 +30,11 @@
30
30
  "clean": "rm -rf dist"
31
31
  },
32
32
  "dependencies": {
33
- "@agent-relay/api-types": "2.0.6",
34
- "@agent-relay/protocol": "2.0.6",
35
- "@agent-relay/config": "2.0.6",
36
- "@agent-relay/continuity": "2.0.6",
37
- "@agent-relay/resiliency": "2.0.6"
33
+ "@agent-relay/api-types": "2.0.7",
34
+ "@agent-relay/protocol": "2.0.7",
35
+ "@agent-relay/config": "2.0.7",
36
+ "@agent-relay/continuity": "2.0.7",
37
+ "@agent-relay/resiliency": "2.0.7"
38
38
  },
39
39
  "devDependencies": {
40
40
  "typescript": "^5.9.3",