@j-o-r/hello-dave 0.0.5 → 0.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 (127) hide show
  1. package/CHANGELOG.md +13 -26
  2. package/README.md +161 -522
  3. package/README.md.bak +144 -449
  4. package/{examples → agents}/ask_agent.js +5 -5
  5. package/{examples → agents}/codeserver.sh +14 -14
  6. package/{examples → agents}/daisy_agent.js +5 -5
  7. package/{examples → agents}/docs_agent.js +5 -5
  8. package/{examples → agents}/gpt_agent.js +5 -5
  9. package/{examples → agents}/grok_agent.js +5 -5
  10. package/agents/memory_agent.js +263 -0
  11. package/{examples → agents}/npm_agent.js +5 -5
  12. package/{examples → agents}/prompt_agent.js +5 -5
  13. package/agents/spawn_agent.js +137 -0
  14. package/{examples → agents}/test_agent.js +6 -8
  15. package/{examples → agents}/todo_agent.js +5 -5
  16. package/bin/codeDave +58 -0
  17. package/bin/dave.js +114 -96
  18. package/lib/AgentClient.js +111 -67
  19. package/lib/AgentManager.js +111 -80
  20. package/lib/AgentServer.js +144 -104
  21. package/lib/Cli.js +126 -93
  22. package/lib/Prompt.js +38 -5
  23. package/lib/Session.js +102 -79
  24. package/lib/ToolSet.js +79 -60
  25. package/lib/fafs.js +54 -19
  26. package/lib/genericToolset.js +109 -213
  27. package/lib/wsCli.js +50 -19
  28. package/lib/wsIO.js +11 -17
  29. package/package.json +2 -2
  30. package/types/AgentClient.d.ts +69 -35
  31. package/types/AgentManager.d.ts +50 -56
  32. package/types/AgentServer.d.ts +63 -16
  33. package/types/Cli.d.ts +56 -10
  34. package/types/Prompt.d.ts +36 -4
  35. package/types/Session.d.ts +23 -9
  36. package/types/ToolSet.d.ts +49 -32
  37. package/types/fafs.d.ts +68 -25
  38. package/types/wsCli.d.ts +14 -0
  39. package/types/wsIO.d.ts +9 -5
  40. package/utils/search_sessions.sh +100 -53
  41. package/README.md.backup +0 -269
  42. package/README.md.bak.1774780058 +0 -338
  43. package/README.md.bak2 +0 -531
  44. package/bin/spawn_agent.js +0 -293
  45. package/docs.bak.1774780058/agent-manager.md +0 -167
  46. package/docs.bak.1774780058/agent-manager.md.bak +0 -137
  47. package/docs.bak.1774780058/agent-manager.md.bak2 +0 -157
  48. package/docs.bak.1774780058/codeserver-pattern.md +0 -191
  49. package/docs.bak.1774780058/path-resolution-best-practices.md +0 -104
  50. package/docs.bak.1774780058/project-overview.md +0 -67
  51. package/docs.bak.1774780058/project-overview.md.bak +0 -67
  52. package/docs.bak.1774780058/prompt-class.md +0 -141
  53. package/docs.bak.1774780058/prompt-class.md.bak +0 -142
  54. package/docs.bak.1774780058/tools-syntax-validation.md +0 -121
  55. package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +0 -125
  56. package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +0 -125
  57. package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +0 -106
  58. package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +0 -106
  59. package/docs.bak.1774780058/toolset.md +0 -164
  60. package/docs.bak.1774780058/toolset.md.bak +0 -94
  61. package/docs.bak.1774780058/toolset.md.bak3 +0 -161
  62. package/docs.bak.1774780058/toolset.md.bak4 +0 -161
  63. package/docs.bak.1774780058/toolset.md.bak5 +0 -161
  64. package/docs.bak.1774780058/toolset.md.bak6 +0 -163
  65. package/docs.bak.1774780058/toolset.md.bak_path +0 -163
  66. package/docs.bak.1774780058/toolset.md.bak_syntax +0 -161
  67. package/docs.bak.1774780058/xai-responses.md +0 -111
  68. package/docs.bak.1774780058/xai-responses.md.bak +0 -107
  69. package/docs.bak.1774780058/xai-responses.md.bak2 +0 -107
  70. package/docs.bak.1774780058/xai_collections.md +0 -106
  71. package/examples/memory_agent.js +0 -152
  72. package/examples.bak.1774780058/ask_agent.js +0 -114
  73. package/examples.bak.1774780058/code_agent.js +0 -149
  74. package/examples.bak.1774780058/coderev_agent.js +0 -72
  75. package/examples.bak.1774780058/codeserver.sh +0 -47
  76. package/examples.bak.1774780058/daisy_agent.js +0 -177
  77. package/examples.bak.1774780058/docs_agent.js +0 -119
  78. package/examples.bak.1774780058/gpt_agent.js +0 -109
  79. package/examples.bak.1774780058/grok_agent.js +0 -98
  80. package/examples.bak.1774780058/memory_agent.js +0 -112
  81. package/examples.bak.1774780058/npm_agent.js +0 -175
  82. package/examples.bak.1774780058/prompt_agent.js +0 -112
  83. package/examples.bak.1774780058/readme_agent.js +0 -144
  84. package/examples.bak.1774780058/spawn_agent.js +0 -263
  85. package/examples.bak.1774780058/test_agent.js +0 -162
  86. package/examples.bak.1774780058/todo_agent.js +0 -138
  87. package/lib/genericToolset.js.bak_syntax +0 -402
  88. package/scenarios.bak.1774780058/data/eval_node_message.json +0 -9
  89. package/scenarios.bak.1774780058/data/hist_oa.json +0 -66
  90. package/scenarios.bak.1774780058/data/o3_response1.json +0 -96
  91. package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +0 -112
  92. package/scenarios.bak.1774780058/data/tool_oa.json +0 -96
  93. package/scenarios.bak.1774780058/data/tool_xai.json +0 -59
  94. package/scenarios.bak.1774780058/data/tool_xai2.json +0 -40
  95. package/scenarios.bak.1774780058/data/xai-response-1.json +0 -59
  96. package/scenarios.bak.1774780058/data/xai-response-2.json +0 -10
  97. package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +0 -59
  98. package/scenarios.bak.1774780058/data/xai_search_response.json +0 -58
  99. package/scenarios.bak.1774780058/environment.js +0 -10
  100. package/scenarios.bak.1774780058/example.js +0 -17
  101. package/scenarios.bak.1774780058/genericToolset.test.js +0 -182
  102. package/scenarios.bak.1774780058/grok.js +0 -113
  103. package/scenarios.bak.1774780058/memory-tools.js +0 -51
  104. package/scenarios.bak.1774780058/openai-o3.js +0 -137
  105. package/scenarios.bak.1774780058/openai-prompt.js +0 -155
  106. package/scenarios.bak.1774780058/openai-session.js +0 -148
  107. package/scenarios.bak.1774780058/openai.js +0 -102
  108. package/scenarios.bak.1774780058/prompt.js +0 -118
  109. package/scenarios.bak.1774780058/promptFishbowl.js +0 -76
  110. package/scenarios.bak.1774780058/search.brave.com.js +0 -25
  111. package/scenarios.bak.1774780058/sh.js +0 -15
  112. package/scenarios.bak.1774780058/test-wsio.js +0 -26
  113. package/scenarios.bak.1774780058/testToolset.js +0 -42
  114. package/scenarios.bak.1774780058/toolset.js +0 -16
  115. package/scenarios.bak.1774780058/toolset.test.js +0 -141
  116. package/scenarios.bak.1774780058/write_file_syntax.test.js +0 -145
  117. package/scenarios.bak.1774780058/write_file_validation/README.md +0 -30
  118. package/scenarios.bak.1774780058/write_file_validation/bad.js +0 -3
  119. package/scenarios.bak.1774780058/write_file_validation/good.js +0 -4
  120. package/scenarios.bak.1774780058/write_file_validation/test.sh +0 -43
  121. package/scenarios.bak.1774780058/wsClient.js +0 -69
  122. package/scenarios.bak.1774780058/xai_responses.integration.test.js +0 -57
  123. package/scenarios.bak.1774780058/xai_responses.test.js +0 -154
  124. package/scenarios.bak.1774780058/xaicoll.js +0 -50
  125. package/scenarios.bak.1774780058/xaifiles.js +0 -48
  126. /package/{examples → agents}/code_agent.js +0 -0
  127. /package/{examples → agents}/readme_agent.js +0 -0
@@ -4,65 +4,76 @@ const TIMEOUT = 30000;
4
4
  const MAX_INTERVALS = 20; // 10 minutes (30 sec * 20)
5
5
 
6
6
  let ws;
7
+
8
+ /**
9
+ * @module lib/AgentServer
10
+ * @exports default AgentServer
11
+ * Dynamic WebSocket server for AI agents. Registers connected clients as dynamic tool calls in the Prompt's ToolSet.
12
+ * Handles authentication, user/agent messages, sessions, resets, and broadcasts.
13
+ */
14
+
7
15
  /**
8
- @typedef {import('../node_modules/@j-o-r/apiserver/types/ClientWrapper.d.ts').ClientWrapper} Client
9
- @typedef {import('./Prompt.js').default} Prompt
10
- @typedef {import('./ToolSet.js').default} ToolSet
11
- @typedef {import('./Session.js').default} Session
12
- */
16
+ * @typedef {import('@j-o-r/apiserver/types/ClientWrapper.d.ts').ClientWrapper} Client
17
+ * @typedef {import('./Prompt.js').default} Prompt
18
+ * @typedef {import('./ToolSet.js').default} ToolSet
19
+ * @typedef {import('./Session.js').default} Session
20
+ */
13
21
  /**
14
- * @type {string|object} messageContent
15
- */
22
+ * @typedef {string|object} MessageContent
23
+ */
16
24
  /**
17
- * @type {Object} message
18
- * @property {string} action
19
- * @property {messageContent} content
20
- */
25
+ * @typedef {Object} Message
26
+ * @property {string} action - Action type (must be in ACTIONS).
27
+ * @property {MessageContent} [content]
28
+ * @property {string} [id]
29
+ */
21
30
  /**
22
- * @typedef {(conn: import('@j-o-r/apiserver/types/WebSocketServer.js').WebSocketConnection, req: any) => Promise<boolean>} AuthFunction
23
- */
31
+ * @typedef {(conn: import('@j-o-r/apiserver/types/WebSocketServer.js').WebSocketConnection, req: any) => Promise&lt;boolean&gt;} AuthFunction
32
+ */
24
33
  /**
25
- * @typedef {Object} AgentServerOptions
26
- * @property {string} name
27
- * @property {string} secret - server access secret
28
- * @property {string} description
29
- * @property {Prompt} prompt
30
- * @property {Session} session
31
- * @property {AuthFunction} [auth]
32
- * @property {number} [port] - default 8000
33
- * @property {boolean} [debug = false]
34
- */
34
+ * @typedef {Object} AgentServerOptions
35
+ * @property {string} name - Server/agent name.
36
+ * @property {string} secret - Access secret (matches client secrets).
37
+ * @property {string} description - Server description.
38
+ * @property {Prompt} prompt - Prompt instance.
39
+ * @property {Session} session - Session manager.
40
+ * @property {AuthFunction} [auth] - Custom auth function.
41
+ * @property {number} [port=8000] - Listen port (&gt;=1024).
42
+ * @property {boolean} [debug=false] - Verbose logging.
43
+ * @example { name: 'main-agent', prompt: myPrompt, session: mySession, secret: 'abc', port: 8001 }
44
+ */
35
45
 
46
+ /** @const @type {readonly string[]} Supported WebSocket message actions. Use .includes() for validation. */
36
47
  const ACTIONS = [
37
48
  // Agent / Toolset function calls
38
- 'agent_introduction', // Describe your task, your purpose and usage. This is a reaction on a 'introduce' requests
39
- 'agent_error', // Message error
40
- 'agent_query', // doing a query
41
- 'agent_response', // Doing an response on a query
42
- // Regular user interaction
43
- 'user_introduction', // Websocket client connection on open
44
- 'user_request', // A client user request
45
- 'server_response', // A reponse to a user request
46
- 'server_error', // A reponse to a user request
47
- 'user_reset', // User requests a new session
48
- 'user_sessionlist', // Request a list of sessions
49
- 'user_loadsession', // Request to load a session
50
- 'user_info', // User request server info
49
+ 'agent_introduction', // Client introduces as tool
50
+ 'agent_error', // Agent error response
51
+ 'agent_query', // Query to agent
52
+ 'agent_response', // Agent response
53
+ // User interactions
54
+ 'user_introduction', // Client connect
55
+ 'user_request', // User query
56
+ 'server_response', // Server response to user
57
+ 'server_error', // Server error to user
58
+ 'user_reset', // Reset session
59
+ 'user_sessionlist', // List sessions
60
+ 'user_loadsession', // Load session
61
+ 'user_info', // Server info
51
62
  ];
52
63
 
53
-
54
-
55
-
56
- // WS clients
64
+ // WS clients map: conn_id → agent name
57
65
  const clients = new Map();
58
- // Pending messages
59
- const pendingResponses = new Map(); // key: `${conn_id}:${msg_id}`, value: {resolve, reject}
66
+ // Pending responses: `${conn_id}:${msg_id}` → {resolve, reject, timer}
67
+ const pendingResponses = new Map();
60
68
 
61
69
  /**
62
- * Delete a client from the toolset
63
- * @param {ToolSet|void} toolset
64
- * @param {string} conn_id - Connection id
65
- */
70
+ * @function deleteClient
71
+ * @private
72
+ * Removes a client from the toolset and clients map.
73
+ * @param {ToolSet|null} toolset - Prompt's toolset.
74
+ * @param {string} conn_id - Connection ID.
75
+ * @returns {void}
76
+ */
66
77
  const deleteClient = (toolset, conn_id) => {
67
78
  if (!toolset) return;
68
79
  const name = clients.get(conn_id);
@@ -72,13 +83,19 @@ const deleteClient = (toolset, conn_id) => {
72
83
  toolset.delete(name);
73
84
  }
74
85
  }
75
- }
86
+ };
87
+
76
88
  /**
77
- * @param {ToolSet|void} toolset
78
- * @param {string} conn_id - Connection id
79
- * @param {string} name - logical name / task
80
- * @param {string} description of the logical name
81
- */
89
+ * @function addClient
90
+ * @private
91
+ * Registers a WS client as a dynamic tool in the toolset.
92
+ * Sends query via WS, awaits response with timeout.
93
+ * @param {ToolSet|null} toolset - Prompt's toolset.
94
+ * @param {string} conn_id - Connection ID.
95
+ * @param {string} name - Tool name.
96
+ * @param {string} description - Tool description.
97
+ * @returns {void}
98
+ */
82
99
  const addClient = (toolset, conn_id, name, description) => {
83
100
  if (!toolset) return;
84
101
  toolset.add(
@@ -89,7 +106,7 @@ const addClient = (toolset, conn_id, name, description) => {
89
106
  properties: {
90
107
  query: {
91
108
  type: 'string',
92
- description: `Command, question or query for this particulair expert well formed in natural language`
109
+ description: `Command, question or query for this particular expert well formed in natural language`
93
110
  }
94
111
  },
95
112
  required: ['query']
@@ -101,7 +118,6 @@ const addClient = (toolset, conn_id, name, description) => {
101
118
  const key = `${conn_id}:${msg_id}`;
102
119
  clients.set(conn_id, name);
103
120
 
104
- // Start timeout/interval and keep its handle so we can clear it on response
105
121
  let intervals = 0;
106
122
  const timer = setInterval(() => {
107
123
  intervals++;
@@ -114,7 +130,6 @@ const addClient = (toolset, conn_id, name, description) => {
114
130
  }
115
131
  }, TIMEOUT);
116
132
 
117
- // Store handlers and timer so onMessage can resolve/reject and clear the timer
118
133
  pendingResponses.set(key, { resolve, reject, timer });
119
134
 
120
135
  ws.sendToConnection(conn_id, JSON.stringify({
@@ -122,34 +137,66 @@ const addClient = (toolset, conn_id, name, description) => {
122
137
  id: msg_id,
123
138
  content: params.query
124
139
  }));
125
- }).then(response => (response));
126
- })
127
- }
140
+ });
141
+ }
142
+ );
143
+ };
128
144
 
129
- // Provide a toolset based on websocket calls
145
+ /**
146
+ * AgentServer: Core WebSocket server class.
147
+ * Exposes connected agents as tools; handles user CLI/WS interactions, auth, sessions.
148
+ * Starts on localhost; broadcasts resets.
149
+ * Logs events via console; emits via Prompt.
150
+ * @emits tool_request - Tool calls (via #prompt).
151
+ * @emits tool_error - Tool failures (via #prompt).
152
+ * @example
153
+ * const server = new AgentServer({
154
+ * name: 'main',
155
+ * prompt: myPrompt,
156
+ * session: mySession,
157
+ * secret: 'abc',
158
+ * port: 8000,
159
+ * debug: true
160
+ * });
161
+ */
130
162
  class AgentServer {
163
+ /** @private @type {boolean} */
131
164
  #debug = false;
165
+ /** @private @type {number} */
132
166
  #port = 8000;
167
+ /** @private @type {string} */
133
168
  #name = '';
134
- #secret = ''; // access secret
169
+ /** @private @type {string} */
170
+ #secret = '';
171
+ /** @private @type {string} */
135
172
  #description = '';
136
- /** @type {Prompt} */
137
- #prompt
138
- /** @type {Session} */
139
- #session
140
- /** @type {AuthFunction} */
173
+ /** @private @type {Prompt} */
174
+ #prompt;
175
+ /** @private @type {Session} */
176
+ #session;
177
+ /**
178
+ * @private
179
+ * Default auth: Checks 'wssrc_id' query param against #secret.
180
+ * @param {Object} conn - Connection object.
181
+ * @returns {Promise&lt;boolean&gt;}
182
+ */
141
183
  #auth = async (conn) => {
142
184
  const q = conn.client.query;
143
185
  const key = q.get('wssrc_id');
144
186
  return key === this.#secret;
145
- }
187
+ };
188
+
146
189
  /**
147
- * @param {AgentServerOptions} options
148
- */
190
+ * Initializes and starts the AgentServer.
191
+ * Validates port, sets up Prompt event logging, launches WS server.
192
+ * @param {AgentServerOptions} options - Server configuration.
193
+ * @throws {Error} If port &lt; 1024.
194
+ * @example See AgentServerOptions.
195
+ */
149
196
  constructor(options) {
150
197
  if (options.port) {
151
198
  if (options.port < 1024) {
152
- throw new Error('Port must be higher then 1024');
199
+ throw new Error('Port must be higher than 1024');
153
200
  }
154
201
  this.#port = options.port;
155
202
  }
@@ -161,12 +208,12 @@ class AgentServer {
161
208
  this.#description = options.description;
162
209
  this.#session = options.session;
163
210
  this.#prompt = options.prompt;
164
- this.#debug = options.debug;
165
- // LOG EVENTS
211
+ this.#debug = options.debug ?? false;
212
+
213
+ // Log Prompt events
166
214
  const events = Object.keys(this.#prompt.EVENTS);
167
215
  events.forEach((evt) => {
168
216
  this.#prompt.on(evt, (_msg) => {
169
- // log events
170
217
  console.log(`** ${this.#name} e:${evt}**`);
171
218
  if (evt === 'tool_request') {
172
219
  console.log(`tool execute: ${this.#name} ${_msg.name} ${_msg.call_id}`);
@@ -176,18 +223,19 @@ class AgentServer {
176
223
  }
177
224
  });
178
225
  });
179
- // start
226
+
227
+ // Async start
180
228
  (async () => {
181
229
  await this._start();
182
230
  })();
183
231
  }
232
+
184
233
  /**
185
- * @private
186
- * Returns a Dynamic Toolset
187
- * With registered WS clients as toolcalls
188
- * A deamon start on local host 127.0.0.1, always
189
- * @returns {Promise<void>}
190
- */
234
+ * @private
235
+ * Launches the WS server with handlers for messages, connections, closes.
236
+ * Defines HTTP / API index endpoint.
237
+ * @returns {Promise&lt;void&gt;}
238
+ */
191
239
  async _start() {
192
240
  const name = this.#name;
193
241
  const description = this.#description;
@@ -195,8 +243,8 @@ class AgentServer {
195
243
  const DEBUG = this.#debug;
196
244
  const API = {
197
245
  /**
198
- * @param {Client} client
199
- */
246
+ * @param {Client} client
247
+ */
200
248
  index: async (client) => {
201
249
  await client.serve(200, { name, description });
202
250
  }
@@ -205,18 +253,16 @@ class AgentServer {
205
253
  verbose: this.#debug,
206
254
  onMessage: async (conn, msg) => {
207
255
  if (!msg.action || !ACTIONS.includes(msg.action)) {
208
- console.log('Unkown action: ' + msg.action);
209
- deleteClient(this.#prompt.toolset, conn.id)
256
+ console.log('Unknown action: ' + msg.action);
257
+ deleteClient(this.#prompt.toolset, conn.id);
210
258
  ws.closeConnection(conn.id);
211
259
  return;
212
260
  }
213
261
  if (msg.action === 'agent_introduction') {
214
- // Register Toolset Agent
215
- // CLient is added as a Toolset function call
216
262
  const name = msg.name;
217
263
  const content = (typeof msg.content === 'string') ? msg.content : JSON.stringify(msg.content);
218
264
  if (!content) {
219
- deleteClient(this.#prompt.toolset, conn.id)
265
+ deleteClient(this.#prompt.toolset, conn.id);
220
266
  ws.closeConnection(conn.id);
221
267
  return;
222
268
  }
@@ -224,7 +270,7 @@ class AgentServer {
224
270
  return;
225
271
  }
226
272
  if (msg.action === 'agent_response') {
227
- const key = `${conn.id}:${msg.id}`; // Assume client includes original 'id' in response
273
+ const key = `${conn.id}:${msg.id}`;
228
274
  const pending = pendingResponses.get(key);
229
275
  if (pending) {
230
276
  try { clearInterval(pending.timer); } catch { }
@@ -234,7 +280,7 @@ class AgentServer {
234
280
  return;
235
281
  }
236
282
  if (msg.action === 'agent_error') {
237
- const key = `${conn.id}:${msg.id}`; // Assume client includes original 'id' in response
283
+ const key = `${conn.id}:${msg.id}`;
238
284
  const pending = pendingResponses.get(key);
239
285
  if (pending) {
240
286
  try { clearInterval(pending.timer); } catch { }
@@ -243,21 +289,17 @@ class AgentServer {
243
289
  }
244
290
  return;
245
291
  }
246
- // -------- USER INTERACTION --------------------------------------------------------
247
- // CLI / WS interaction to MAIN
292
+ // User interactions
248
293
  if (msg.action === 'user_request') {
249
- const action = `user_reponse`;
250
294
  const id = msg.id;
251
295
  if (!msg.content || msg.content.trim() === '') {
252
- // Empty message, empty reponse
253
296
  ws.sendToConnection(conn.id, JSON.stringify({
254
- action: 'user_response',
297
+ action: 'server_response',
255
298
  id,
256
299
  content: ''
257
300
  }));
258
301
  return;
259
302
  }
260
- // Bind to THIS prompt
261
303
  console.log(`user_request:>>\n${msg.content}\n`);
262
304
  try {
263
305
  const content = await this.#prompt.call(msg.content);
@@ -266,14 +308,14 @@ class AgentServer {
266
308
  id,
267
309
  content
268
310
  }));
269
- console.log(`server_reponse:>>\n${content}\n`);
311
+ console.log(`server_response:>>\n${content}\n`);
270
312
  } catch (e) {
271
313
  console.log(`server_error:>>\n`);
272
314
  console.error(e);
273
315
  ws.sendToConnection(conn.id, JSON.stringify({
274
316
  action: 'server_error',
275
317
  id,
276
- e
318
+ e: String(e)
277
319
  }));
278
320
  }
279
321
  }
@@ -296,7 +338,6 @@ class AgentServer {
296
338
  content: sess
297
339
  }));
298
340
  }
299
-
300
341
  if (msg.action === 'user_loadsession') {
301
342
  const id = msg.id;
302
343
  const selected = msg.content;
@@ -315,8 +356,7 @@ class AgentServer {
315
356
  }
316
357
  }
317
358
  }
318
- };
319
- // Resume execution
359
+ }
320
360
  await this.#prompt.triggerRequest();
321
361
  ws.sendToConnection(conn.id, JSON.stringify({
322
362
  action: 'server_sessionloaded',
@@ -341,10 +381,8 @@ class AgentServer {
341
381
  },
342
382
  onClose: async (conn, reason) => {
343
383
  deleteClient(this.#prompt.toolset, conn.id);
344
-
345
384
  },
346
385
  onError: async (conn, error) => {
347
- // console.error(error);
348
386
  deleteClient(this.#prompt.toolset, conn.id);
349
387
  ws.closeConnection(conn.id);
350
388
  }
@@ -352,10 +390,12 @@ class AgentServer {
352
390
  await server.create('v1', { port, host: '127.0.0.1', ws, strict: DEBUG, verbose: DEBUG }, API);
353
391
  console.log(`Websocket server: ws://127.0.0.1:${port}/ws`);
354
392
  }
393
+
355
394
  /**
356
- * Send a reset messages to all clients
357
- * reset will start a new session
358
- */
395
+ * Broadcasts a reset message to all connected clients (starts new sessions).
396
+ * @returns {void}
397
+ * @fires reset - Via underlying prompt/clients.
398
+ */
359
399
  resetAll() {
360
400
  ws.broadcast({ action: 'reset' });
361
401
  }