@siftd/connect-agent 0.2.16 → 0.2.17

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/agent.js CHANGED
@@ -1,4 +1,4 @@
1
- import { spawn } from 'child_process';
1
+ import { spawn, execSync } from 'child_process';
2
2
  import { pollMessages, sendResponse } from './api.js';
3
3
  import { getUserId, getAnthropicApiKey, isCloudMode, getDeploymentInfo } from './config.js';
4
4
  import { MasterOrchestrator } from './orchestrator.js';
@@ -8,6 +8,51 @@ import { startHeartbeat, stopHeartbeat, getHeartbeatState } from './heartbeat.js
8
8
  function stripAnsi(str) {
9
9
  return str.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, '');
10
10
  }
11
+ /**
12
+ * Actually perform a self-update - runs npm install and restarts
13
+ */
14
+ async function performSelfUpdate() {
15
+ console.log('[AGENT] Starting self-update...');
16
+ try {
17
+ // Get current version
18
+ let currentVersion = 'unknown';
19
+ try {
20
+ currentVersion = execSync('npm list -g @siftd/connect-agent --json 2>/dev/null | grep version || echo "unknown"', { encoding: 'utf8', shell: '/bin/bash' }).trim();
21
+ }
22
+ catch { /* ignore */ }
23
+ console.log('[AGENT] Current version:', currentVersion);
24
+ console.log('[AGENT] Running: npm install -g @siftd/connect-agent@latest');
25
+ // Actually run the npm install
26
+ const installOutput = execSync('npm install -g @siftd/connect-agent@latest 2>&1', {
27
+ encoding: 'utf8',
28
+ shell: '/bin/bash',
29
+ timeout: 120000 // 2 minute timeout
30
+ });
31
+ console.log('[AGENT] Install output:', installOutput);
32
+ // Get new version
33
+ let newVersion = 'unknown';
34
+ try {
35
+ const versionOutput = execSync('npm list -g @siftd/connect-agent --depth=0 2>/dev/null', { encoding: 'utf8', shell: '/bin/bash' });
36
+ const match = versionOutput.match(/@siftd\/connect-agent@([\d.]+)/);
37
+ if (match)
38
+ newVersion = match[1];
39
+ }
40
+ catch { /* ignore */ }
41
+ console.log('[AGENT] New version:', newVersion);
42
+ // Schedule restart
43
+ console.log('[AGENT] Scheduling restart in 2 seconds...');
44
+ setTimeout(() => {
45
+ console.log('[AGENT] Restarting...');
46
+ process.exit(0); // Exit - systemd/pm2/user will restart
47
+ }, 2000);
48
+ return `✅ Update complete!\n\nInstalled: @siftd/connect-agent@${newVersion}\n\nRestarting agent in 2 seconds...`;
49
+ }
50
+ catch (error) {
51
+ const errMsg = error instanceof Error ? error.message : String(error);
52
+ console.error('[AGENT] Update failed:', errMsg);
53
+ return `❌ Update failed: ${errMsg}\n\nYou may need to run manually:\nnpm install -g @siftd/connect-agent@latest`;
54
+ }
55
+ }
11
56
  // Conversation history for orchestrator mode
12
57
  let conversationHistory = [];
13
58
  let orchestrator = null;
@@ -152,6 +197,12 @@ export async function processMessage(message) {
152
197
  );
153
198
  return response;
154
199
  }
200
+ // Handle self-update requests - ACTUALLY run the update, don't just pretend
201
+ if (content.includes('update') && content.includes('connect-agent') &&
202
+ (content.includes('npm install') || content.includes('latest'))) {
203
+ console.log('[AGENT] Self-update request detected - forcing actual execution');
204
+ return await performSelfUpdate();
205
+ }
155
206
  try {
156
207
  if (orchestrator) {
157
208
  return await sendToOrchestrator(message.content, orchestrator, message.id, message.apiKey);
package/dist/heartbeat.js CHANGED
@@ -10,7 +10,7 @@ import { hostname } from 'os';
10
10
  import { createHash } from 'crypto';
11
11
  import { getServerUrl, getAgentToken, getUserId, isCloudMode } from './config.js';
12
12
  const HEARTBEAT_INTERVAL = 10000; // 10 seconds
13
- const VERSION = '0.2.16'; // Should match package.json
13
+ const VERSION = '0.2.17'; // Should match package.json
14
14
  const state = {
15
15
  intervalId: null,
16
16
  runnerId: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siftd/connect-agent",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "description": "Master orchestrator agent - control Claude Code remotely via web",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",