thinknagent 0.1.7 → 0.1.8

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/lib/connect.js +23 -25
  2. package/package.json +1 -1
package/lib/connect.js CHANGED
@@ -34,18 +34,18 @@ class Connection {
34
34
  reconnection: true,
35
35
  reconnectionDelay: RECONNECT_DELAY,
36
36
  reconnectionAttempts: Infinity,
37
- auth: (cb) => {
38
- // YE CHANGE KARO — har reconnect pe fresh config read karo
39
- const freshCfg = store.read();
40
- cb({
41
- agentId: freshCfg.agentId,
42
- agentToken: freshCfg.agentToken || null,
43
- name: freshCfg.name,
44
- hostname: require('os').hostname(),
45
- version: require('../package.json').version,
46
- roomId: freshCfg.roomId || null,
47
- });
48
- }
37
+ auth: (cb) => {
38
+ const freshCfg = store.read();
39
+ console.log('[debug] Reconnecting with token:', !!freshCfg.agentToken, 'agentId:', freshCfg.agentId);
40
+ cb({
41
+ agentId: freshCfg.agentId,
42
+ agentToken: freshCfg.agentToken || null,
43
+ name: freshCfg.name,
44
+ hostname: require('os').hostname(),
45
+ version: require('../package.json').version,
46
+ roomId: freshCfg.roomId || null,
47
+ });
48
+ }
49
49
  });
50
50
 
51
51
  this._bind();
@@ -58,26 +58,24 @@ class Connection {
58
58
  // ── Registration flow (Option B) ─────────────────────────────────────────
59
59
 
60
60
  // Server says: "I got your registration, waiting for Owner approval"
61
- s.on('agent:pending', ({ agentId }) => {
62
- store.set('agentId', agentId);
63
- this.agentId = agentId;
64
- console.log(`[thinknagent] Registered as ${agentId} — waiting for Owner approval in ThinkNCollab...`);
65
- });
61
+ s.on('agent:pending', ({ agentId }) => {
62
+ // ✅ agentId store mat karo — UUID pehle se store mein hai
63
+ console.log(`[thinknagent] Registered — waiting for Owner approval...`);
64
+ });
66
65
 
67
- // Server says: "Owner approved, here is your token + assigned role"
68
- s.on('agent:approved', ({ agentToken, role, roomId }) => {
66
+ s.on('agent:approved', ({ agentToken, role, roomId }) => {
67
+ // agentId yahan store mat karo — UUID already store mein sahi hai
69
68
  store.set('agentToken', agentToken);
70
- store.set('agentId', this.agentId);
71
69
  store.set('role', role);
72
70
  store.set('roomId', roomId);
71
+ // agentId touch mat karo!
72
+
73
73
  this.agentToken = agentToken;
74
74
  this.role = role;
75
+
75
76
  console.log(`[thinknagent] Approved! Reconnecting with token...`);
76
-
77
- this.socket.disconnect(); // pehle disconnect
78
- setTimeout(() => {
79
- this.socket.connect(); // phir manually reconnect
80
- }, 500);
77
+ this.socket.disconnect();
78
+ setTimeout(() => this.socket.connect(), 500);
81
79
  });
82
80
  // Server says: "Owner rejected this agent"
83
81
  s.on('agent:rejected', ({ reason }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thinknagent",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "ThinkNCollab server agent — metrics, logs, alerts, shell bridge",
5
5
  "main": "lib/agent.js",
6
6
  "bin": {