@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
package/lib/Cli.js CHANGED
@@ -1,38 +1,42 @@
1
1
  import cli from '@j-o-r/cli';
2
2
  import { SH } from '@j-o-r/sh';
3
3
  // import audio2text from './tts/openai.com/generate.js';
4
+
4
5
  /**
5
- * @typedef {import('./API/openai.com/reponses/text.js').request} OARequest
6
- * @typedef {import('./API/x.ai/text.js').request} XRequest
7
- * @typedef {import('./API/anthropic.com/text.js').request} ANTHRequest
8
- *
9
- * @typedef {import('./API/x.ai/text.js').XOptions} XOptions
10
- * @typedef {import('./API/openai.com/reponses/text.js').OAOptions} OAOptions
11
- * @typedef {import('./API/anthropic.com/text.js').ANTHOptions} ANTHOptions
12
- *
13
- * @typedef {import('./Prompt.js').default} Prompt
14
- * @typedef {import('./Session.js').default} Session
15
- * @typedef {import('./ToolSet.js').default} ToolSet
16
- */
6
+ * @typedef {import('./API/openai.com/reponses/text.js').request} OARequest
7
+ * @typedef {import('./API/x.ai/text.js').request} XRequest
8
+ * @typedef {import('./API/anthropic.com/text.js').request} ANTHRequest
9
+ *
10
+ * @typedef {import('./API/x.ai/text.js').XOptions} XOptions
11
+ * @typedef {import('./API/openai.com/reponses/text.js').OAOptions} OAOptions
12
+ * @typedef {import('./API/anthropic.com/text.js').ANTHOptions} ANTHOptions
13
+ *
14
+ * @typedef {import('./Prompt.js').default} Prompt
15
+ * @typedef {import('./Session.js').default} Session
16
+ * @typedef {import('./ToolSet.js').default} ToolSet
17
+ */
17
18
  /**
19
+ * Configuration options for initializing the Cli class.
18
20
  * @typedef {Object} CLIOptions
19
- * @property {Prompt} prompt - The prompt session
20
- * @property {Session} session - Session Cache
21
- * @property {ToolSet} [toolset] - The toolset
22
- * @property {string} [description] - Custom introduction message.
23
- * @property {string} [help] - Custom help message.
21
+ * @property {Prompt} prompt - The Prompt instance for handling AI interactions.
22
+ * @property {Session} session - The Session instance for managing conversation history.
23
+ * @property {ToolSet} [toolset] - Optional ToolSet for tool integrations.
24
+ * @property {string} [description] - Custom introduction message (appended to default INTRO).
25
+ * @property {string} [help] - Custom help message (overrides default HELP).
24
26
  */
25
27
 
26
-
28
+ /** @const {string} Short introduction with basic shortcuts. */
27
29
  const INTRO = `
28
30
  Use:
29
31
  - "ALT + d" to exit.
30
32
  - "ALT + k" Show shortcuts /help
31
33
  `;
32
34
 
35
+ /** @const {string} Error message template (customizable via options.help). */
33
36
  const ERROR = `
34
- `
37
+ `;
35
38
 
39
+ /** @const {string} Full help text with shortcuts and prompt commands. */
36
40
  const HELP = `
37
41
 
38
42
  Use:
@@ -57,23 +61,24 @@ e.g. >edit< , >paste< , >#!bash [command]<
57
61
  `;
58
62
 
59
63
  /**
60
- * Copy text to the clipboard
61
- * @param {string} text
62
- * @retruns {Promise<string>}
63
- */
64
- const copyToClipboard = async (text) => {
65
- if (typeof text !== 'string') return;
66
- if (text === '') text = ' ';
67
- const prams = [
68
- '-selection',
69
- 'clipboard'
70
- ]
71
- return SH`xclip ${prams}`.options({ stdio: 'inherit' }).run(text);
72
- }
73
-
74
-
75
- /**
76
- * CLILoader class for handling CLI-based interactions with AI models.
64
+ * CLI Interface for interactive AI conversations.
65
+ *
66
+ * Integrates with {@link Prompt}, {@link Session}, and optionally {@link ToolSet} to provide a terminal-based chat interface.
67
+ * Supports keyboard shortcuts (Alt + key), session management, error handling, and real-time message streaming.
68
+ *
69
+ * Key features:
70
+ * - Rich text output with roles (user/assistant/util/error/log).
71
+ * - Event-driven updates from Prompt (messages, truncated, finished).
72
+ * - Built-in help, reset, load session, copy last message (Alt+m).
73
+ * - Customizable intro/help via options.
74
+ *
75
+ * @example
76
+ * const cli = new Cli({ prompt: myPrompt, session: mySession });
77
+ * await cli.start('Hello, AI!');
78
+ *
79
+ * @fires Prompt#message
80
+ * @fires Prompt#truncated
81
+ * @fires Prompt#finished
77
82
  */
78
83
  class Cli {
79
84
  #HELP = HELP;
@@ -84,22 +89,30 @@ class Cli {
84
89
  #prompt;
85
90
  #description = '';
86
91
  #lastMessage = '';
92
+
87
93
  /**
88
- * Creates an instance of CLILoader.
89
- * @param {CLIOptions} options - The options to configure the CLILoader.
94
+ * Initializes the Cli instance with required Prompt and Session.
95
+ * Sets up CLI roles, key mappings, and event listeners on Prompt.
96
+ * @param {CLIOptions} options - Configuration options.
97
+ * @throws {Error} If required prompt or session is missing.
90
98
  */
91
99
  constructor(options) {
100
+ if (!options.prompt || !options.session) {
101
+ throw new Error('Cli requires valid prompt and session options.');
102
+ }
92
103
  this.#prompt = options.prompt;
93
104
  this.#session = options.session;
94
- this.#description = (options.description) ? options.description + INTRO : INTRO;
95
- this.#HELP = (options.help) ? options.help : HELP;
105
+ this.#description = options.description ? options.description + '\n\n' + INTRO : INTRO;
106
+ this.#HELP = options.help || HELP;
96
107
  this.#setupCLI();
97
108
  }
98
109
 
99
- #setupCLI = () => {
110
+ /** @private */
111
+ #setupCLI() {
100
112
  cli.setRole('assistant', `${this.#session.name}: > `, 'brightGreen');
101
113
  cli.setRole('util', ``, 'brightYellow');
102
114
  cli.setRole('error', ``, 'red');
115
+ cli.setRole('log', '', 'brightBlue');
103
116
  // @ts-ignore
104
117
  cli.inputHandler = async (s, role) => await this.#handleInput(s, role);
105
118
  cli.registerKeyMappings([
@@ -109,34 +122,31 @@ class Cli {
109
122
  await this.reset();
110
123
  }
111
124
  },
112
- { // load a previous ssession
125
+ { // load a previous session
113
126
  name: 's', ctrl: false, meta: true, shift: false, handler: async () => {
114
127
  await this.loadSession();
115
128
  }
116
129
  },
117
- { // load a previous ssession
130
+ { // show session/prompt info
118
131
  name: 'i', ctrl: false, meta: true, shift: false, handler: async () => {
119
132
  this.printInfo();
120
- // cli.focus('user', true);
121
133
  }
122
134
  },
123
135
  { // Copy last message to clipboard
124
136
  name: 'm', ctrl: false, meta: true, shift: false, handler: async () => {
125
137
  await copyToClipboard(this.#lastMessage);
126
138
  cli.focus('util');
127
- cli.write('copied');
128
- // cli.focus('user', true);
139
+ cli.write('Last message copied to clipboard.');
129
140
  }
130
141
  },
131
142
  { // Show help /keys
132
143
  name: 'k', ctrl: false, meta: true, shift: false, handler: async () => {
133
- cli.focus('util')
134
- cli.write(HELP)
135
- // cli.focus('user', true);
144
+ cli.focus('util');
145
+ cli.write(this.#HELP);
136
146
  }
137
147
  }
138
148
  ]);
139
- // Write messages
149
+ // Event listeners for Prompt updates
140
150
  this.#prompt.on('message', (msg) => {
141
151
  let write = false;
142
152
  if (msg.role === 'reasoning') {
@@ -150,7 +160,7 @@ class Cli {
150
160
  cli.write(content);
151
161
  write = true;
152
162
  } else if (msg.role === 'assistant') {
153
- if (msg.content[0].type === 'text') {
163
+ if (msg.content[0]?.type === 'text') {
154
164
  const content = this.#prompt.contentToString(msg.content);
155
165
  if (content.trim() !== '') {
156
166
  cli.focus('assistant');
@@ -160,63 +170,67 @@ class Cli {
160
170
  }
161
171
  }
162
172
  if (write) {
163
- cli.startSpinner();
173
+ cli.startSpinner();
164
174
  }
165
175
  });
166
176
  this.#prompt.on('truncated', () => {
167
177
  cli.focus('log');
168
- cli.write(`--- prompt truncated ---`);
169
- // cli.startSpinner();
178
+ cli.write('--- prompt truncated ---');
170
179
  });
171
180
  this.#prompt.on('finished', () => {
172
181
  cli.focus('user', true);
173
182
  });
174
- // console.log(this.#prompt);
175
183
  }
176
184
 
177
185
  /**
178
- * @param {string} s
179
- * @param {string} role
186
+ * Handles user input, processes via Prompt.call(), captures last message, and manages errors.
187
+ * Only processes 'user' role inputs.
188
+ * @private
189
+ * @param {string} s - Input string.
190
+ * @param {string} role - Input role (e.g., 'user').
180
191
  */
181
192
  async #handleInput(s, role) {
182
- if (!s || s === '') {
183
- return;
184
- }
185
- // Only accept a users input
186
- if (role === 'user') {
187
- cli.startSpinner();
188
- try {
189
- this.#lastMessage = await this.#prompt.call(s)
190
- } catch (error) {
191
- // @ts-ignore
192
- await this.#handleError(error);
193
- }
193
+ if (!s || s.trim() === '') return;
194
+ if (role !== 'user') return;
195
+ cli.startSpinner();
196
+ try {
197
+ this.#lastMessage = await this.#prompt.call(s);
198
+ } catch (error) {
199
+ await this.#handleError(error);
194
200
  }
195
201
  }
196
202
 
197
203
  /**
198
- * @param {Error} error
204
+ * Displays error message and focuses back to user input.
205
+ * @private
206
+ * @param {Error} error - The error to handle.
199
207
  */
200
208
  async #handleError(error) {
201
- cli.error(error);
209
+ cli.error(error.message || error);
202
210
  cli.focus('util');
203
- cli.write(this.#ERROR);
204
- // this.reset();
211
+ cli.write(this.#ERROR || 'An error occurred. Try Alt+r to reset.');
205
212
  cli.focus('user', true);
206
213
  }
207
214
 
208
- printInfo() {
215
+ /**
216
+ * Prints detailed info about current session and prompt, plus description.
217
+ * Triggered by Alt+i.
218
+ */
219
+ printInfo() {
209
220
  const sessionInfo = this.#session.info();
210
221
  const promptInfo = this.#prompt.info();
211
- const info = `\nSESSION\n${sessionInfo}\nPROMPT\n${promptInfo}\n${this.#description}`;
222
+ const info = `\nSESSION\n${sessionInfo}\n\nPROMPT\n${promptInfo}\n\n${this.#description}`;
212
223
  cli.focus('util');
213
224
  cli.write(info);
214
- }
225
+ }
215
226
 
216
227
  /**
217
- * Starts the CLI interaction.
218
- * @param {string} [s] - optional user string/question
228
+ * Starts the CLI: Shows intro/description, focuses user input, optionally processes initial message.
229
+ * @param {string} [s] - Optional initial user message to process.
219
230
  * @returns {Promise<void>}
231
+ * @example
232
+ * await cli.start(); // Interactive mode
233
+ * await cli.start('What is the weather?'); // Start with query
220
234
  */
221
235
  async start(s) {
222
236
  cli.focus('util');
@@ -226,11 +240,17 @@ class Cli {
226
240
  await this.#handleInput(s, 'user');
227
241
  }
228
242
  }
243
+
244
+ /**
245
+ * Loads a previous session by user selection, replays non-sticky messages, and triggers request.
246
+ * Lists sessions in reverse chronological order + 'NONE'.
247
+ * Triggered by Alt+s.
248
+ * @returns {Promise<void>}
249
+ */
229
250
  async loadSession() {
230
- // Last session last
231
- const sess = this.#session.sessionList().reverse();
232
- sess.push('NONE');
233
- const selected = await cli.select('Select your session: ', sess);
251
+ const sessions = this.#session.sessionList().reverse();
252
+ sessions.push('NONE');
253
+ const selected = await cli.select('Select session: ', sessions);
234
254
  if (!selected || selected === 'NONE') {
235
255
  cli.focus('user', true);
236
256
  return;
@@ -239,25 +259,38 @@ class Cli {
239
259
  const messages = this.#session.set(selected);
240
260
  this.#prompt.messages = messages;
241
261
  messages.forEach((msg) => {
242
- if (!msg.sticky) {
243
- if (['user', 'assistant', 'reasoning', 'log'].includes(msg.role)) {
244
- const content = this.#prompt.contentToString(msg.content);
245
- // @ts-ignore
246
- cli.focus(msg.role);
247
- cli.write(content);
248
- }
262
+ if (!msg.sticky && ['user', 'assistant', 'reasoning', 'log'].includes(msg.role)) {
263
+ const content = this.#prompt.contentToString(msg.content);
264
+ cli.focus(msg.role);
265
+ cli.write(content);
249
266
  }
250
267
  });
251
268
  cli.startSpinner();
252
269
  await this.#prompt.triggerRequest();
253
- // cli.focus('user', true);
254
270
  }
271
+
272
+ /**
273
+ * Resets the prompt (clears context), reprints info, triggered by Alt+r.
274
+ * @returns {Promise<void>}
275
+ */
255
276
  async reset() {
256
- this.#prompt.reset();
257
- // this.start();
277
+ await this.#prompt.reset();
258
278
  this.printInfo();
259
- // cli.focus('user', true);
279
+ cli.focus('user', true);
260
280
  }
261
281
  }
262
282
 
283
+ /**
284
+ * Copies text to the system clipboard using xclip.
285
+ * @param {string} text - Text to copy (non-empty string).
286
+ * @returns {Promise<void>}
287
+ * @throws {Error} If xclip fails or invalid input.
288
+ */
289
+ const copyToClipboard = async (text) => {
290
+ if (typeof text !== 'string' || text === '') return;
291
+ const params = ['-selection', 'clipboard'];
292
+ await SH`xclip ${params}`.options({ stdio: 'inherit' }).run(text);
293
+ };
294
+
263
295
  export default Cli;
296
+ export { copyToClipboard };
package/lib/Prompt.js CHANGED
@@ -290,13 +290,46 @@ const isValidFunctionResponse = (msg) => {
290
290
  }
291
291
  return false
292
292
  }
293
+
293
294
  /**
294
- *
295
- * @fires Prompt#add
296
- * Event: message added
295
+ * Manages a conversation history of standardized AI messages (text, image, audio, tool calls/responses)
296
+ * across different LLM providers (OpenAI, xAI, Anthropic). Inspired by OpenAI's chat format but extended.
297
+ *
298
+ * Key features:
299
+ * - Message validation and ordering (roles: system, user, assistant, tool, reasoning, log)
300
+ * - Context window management with automatic truncation (preserves sticky base prompts)
301
+ * - ToolSet integration via adapters for function calls
302
+ * - Token counting, records for billing/optimization
303
+ * - Event-driven lifecycle (e.g., 'message', 'start', 'finished', tool events)
304
+ *
305
+ * Typical usage:
306
+ * const prompt = new Prompt(4096);
307
+ * prompt.setAdaptor(openaiHandler, toolset, options);
308
+ * prompt.add('system', 'You are helpful.', true);
309
+ * const response = await prompt.call('Hello!');
310
+ *
311
+ * @extends {EventEmitter}
312
+ * @property {number} contextLength - Maximum token limit (getter)
313
+ * @property {Message[]} messages - Copy of conversation history (getter/setter)
314
+ * @property {ToolSet|null} toolset - Current toolset (getter)
315
+ * @property {boolean} hasSystemprompt - Whether system prompt exists (getter)
316
+ * @property {string} system_prompt - System prompt text (getter)
297
317
  *
298
- * @event Prompt#add
299
- * @type {Message}
318
+ * @fires Prompt#start - Emitted when a request starts
319
+ * @fires Prompt#retrigger - Retrigger after message import
320
+ * @fires Prompt#finished - Request completed
321
+ * @fires Prompt#message - New message added to history
322
+ * @fires Prompt#record - Token usage record added
323
+ * @fires Prompt#truncated - Messages truncated due to context limit
324
+ * @fires Prompt#reset - Non-sticky messages cleared
325
+ * @fires Prompt#ready - Call/trigger ready
326
+ * @fires Prompt#error - Error occurred
327
+ * @fires Prompt#warning - Warning issued (e.g., token overflow)
328
+ * @fires Prompt#tool_request - Tool call initiated
329
+ * @fires Prompt#tool_response - Tool call completed
330
+ * @fires Prompt#tool_error - Tool call failed
331
+ * @fires Prompt#http_request - HTTP tool request starts
332
+ * @fires Prompt#http_response - HTTP tool response received
300
333
  */
301
334
  class Prompt extends EventEmitter {
302
335
  #tokenCount = 0;