@codebolt/codeboltjs 2.0.15 → 2.0.16

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.
@@ -8,7 +8,6 @@ import type { PendingRequest } from '../types/commonTypes';
8
8
  export declare class MessageManager extends EventEmitter {
9
9
  pendingRequests: Map<string, PendingRequest>;
10
10
  websocket: WebSocket | null;
11
- requestCounter: number;
12
11
  /**
13
12
  * Initialize the message manager with a WebSocket instance
14
13
  */
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MessageManager = void 0;
4
4
  const events_1 = require("events");
5
+ const uuid_1 = require("uuid");
5
6
  /**
6
7
  * Centralized message manager for handling WebSocket communications
7
8
  */
@@ -10,7 +11,6 @@ class MessageManager extends events_1.EventEmitter {
10
11
  super(...arguments);
11
12
  this.pendingRequests = new Map();
12
13
  this.websocket = null;
13
- this.requestCounter = 0;
14
14
  }
15
15
  /**
16
16
  * Initialize the message manager with a WebSocket instance
@@ -70,7 +70,7 @@ class MessageManager extends events_1.EventEmitter {
70
70
  reject(new Error('WebSocket is not initialized'));
71
71
  return;
72
72
  }
73
- const requestId = `req_${++this.requestCounter}_${Date.now()}`;
73
+ const requestId = (0, uuid_1.v4)();
74
74
  // Add requestId to the message if it doesn't have one
75
75
  const messageWithId = { ...message, requestId };
76
76
  // Parse multiple message types separated by pipe
@@ -110,6 +110,8 @@ class MessageManager extends events_1.EventEmitter {
110
110
  * Send a message without waiting for response
111
111
  */
112
112
  send(message) {
113
+ const requestId = (0, uuid_1.v4)();
114
+ message.requestId = requestId;
113
115
  if (!this.websocket) {
114
116
  throw new Error('WebSocket is not initialized');
115
117
  }
@@ -66,7 +66,32 @@ class cbws {
66
66
  const agentTask = process.env.agentTask ? `&agentTask=${process.env.agentTask}` : '';
67
67
  const socketPort = process.env.SOCKET_PORT || '12345';
68
68
  const serverUrl = process.env.CODEBOLT_SERVER_URL || 'localhost';
69
- const wsUrl = `ws://${serverUrl}:${socketPort}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${parentAgentInstanceIdParam}${agentTask}${process.env.Is_Dev ? '&dev=true' : ''}`;
69
+ const threadToken = process.env.threadToken || null;
70
+ console.log('[WebSocket] Logging all relevant variables:');
71
+ console.log('uniqueConnectionId:', uniqueConnectionId);
72
+ console.log('initialMessage:', initialMessage);
73
+ console.log('agentIdParam:', agentIdParam);
74
+ console.log('parentIdParam:', parentIdParam);
75
+ console.log('parentAgentInstanceIdParam:', parentAgentInstanceIdParam);
76
+ console.log('agentTask:', agentTask);
77
+ console.log('socketPort:', socketPort);
78
+ console.log('serverUrl:', serverUrl);
79
+ console.log('threadToken:', threadToken);
80
+ console.log('[WebSocket] Environment variables check:');
81
+ console.log('process.env.agentId:', process.env.agentId);
82
+ console.log('process.env.threadToken:', process.env.threadToken);
83
+ console.log('process.env.parentId:', process.env.parentId);
84
+ console.log('process.env.agentTask:', process.env.agentTask);
85
+ const threadTokenParam = threadToken ? `&threadToken=${encodeURIComponent(threadToken)}` : '';
86
+ // Add all custom environment variables as URL parameters
87
+ const knownEnvVars = ['SOCKET_PORT', 'CODEBOLT_SERVER_URL', 'agentId', 'parentId', 'parentAgentInstanceId', 'agentTask', 'threadToken', 'Is_Dev', 'PATH', 'NODE_ENV', 'HOME', 'USER', 'SHELL'];
88
+ let customParams = '';
89
+ for (const [key, value] of Object.entries(process.env)) {
90
+ if (!knownEnvVars.includes(key) && value && !key.startsWith('npm_') && !key.startsWith('_')) {
91
+ customParams += `&${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
92
+ }
93
+ }
94
+ const wsUrl = `ws://${serverUrl}:${socketPort}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${parentAgentInstanceIdParam}${agentTask}${threadTokenParam}${customParams}${process.env.Is_Dev ? '&dev=true' : ''}`;
70
95
  console.log('[WebSocket] Connecting to:', wsUrl);
71
96
  this.websocket = new ws_1.default(wsUrl);
72
97
  return new Promise((resolve, reject) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "2.0.15",
3
+ "version": "2.0.16",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -32,6 +32,7 @@
32
32
  "@codebolt/types": "^1.0.10",
33
33
  "@modelcontextprotocol/sdk": "^1.4.1",
34
34
  "@types/pdf-parse": "^1.1.5",
35
+ "@types/uuid": "^10.0.0",
35
36
  "buffer": "^6.0.3",
36
37
  "execa": "^9.5.2",
37
38
  "file-type": "^19.6.0",
@@ -48,6 +49,7 @@
48
49
  "undici": "^7.4.0",
49
50
  "uri-templates": "^0.2.0",
50
51
  "util": "^0.12.5",
52
+ "uuid": "^11.1.0",
51
53
  "web-tree-sitter": "^0.24.1",
52
54
  "ws": "^8.17.0",
53
55
  "yargs": "^17.7.2",