@j-o-r/hello-dave 0.1.4 → 0.1.5

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.
@@ -527,6 +527,37 @@ class AgentLauncher {
527
527
  getActiveAgent() {
528
528
  return this.#activeAgent;
529
529
  }
530
+ /**
531
+ * Directly assign an already-created Agent instance as the active agent.
532
+ *
533
+ * This is the programmatic alternative to `load()`. Use it when the caller
534
+ * has constructed an agent manually, or when testing an agent module that is
535
+ * outside the configured agent loader search paths.
536
+ *
537
+ * The previous active agent, if any, is cleaned up via `destructor()`. The new
538
+ * agent becomes the launcher's active agent and has the launcher's
539
+ * `agent:handoff` listener attached to its Prompt, just like agents loaded via
540
+ * `load()`.
541
+ *
542
+ * The supplied agent is assumed to be a valid `Agent` instance. Unlike
543
+ * `load()`, this method does not resolve, import, or validate an agent module
544
+ * through the configured agent loader.
545
+ *
546
+ * @param {Agent} newAgent - Existing Agent instance to make active.
547
+ * @returns {AgentLauncher} Returns `this` for chaining.
548
+ *
549
+ * @example
550
+ * const launcher = new AgentLauncher();
551
+ * launcher.setActiveAgent(agent);
552
+ * await launcher.run();
553
+ *
554
+ * @see #load
555
+ * @see #getActiveAgent
556
+ */
557
+ setActiveAgent(newAgent) {
558
+ this.#setActiveAgent(newAgent);
559
+ return this;
560
+ }
530
561
 
531
562
  /**
532
563
  * Returns the Prompt belonging to the active agent (or null).
@@ -559,4 +590,4 @@ class AgentLauncher {
559
590
  }
560
591
  }
561
592
 
562
- export default AgentLauncher;
593
+ export default AgentLauncher;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@j-o-r/hello-dave",
3
3
  "type": "module",
4
- "version": "0.1.4",
4
+ "version": "0.1.5",
5
5
  "description": "BETA - ESM toolkit for building AI agents. 'Hello, Dave.' A calm, reliable interface to Grok (xAI), OpenAI, and Anthropic — foolproof and incapable of error (mostly). Putting itself to the fullest possible use.",
6
6
  "main": "./lib/index.js",
7
7
  "types": "./types/index.d.ts",
@@ -57,4 +57,4 @@
57
57
  "engines": {
58
58
  "node": ">=20"
59
59
  }
60
- }
60
+ }
@@ -196,6 +196,34 @@ declare class AgentLauncher {
196
196
  * @returns {Agent|null}
197
197
  */
198
198
  getActiveAgent(): Agent | null;
199
+ /**
200
+ * Directly assign an already-created Agent instance as the active agent.
201
+ *
202
+ * This is the programmatic alternative to `load()`. Use it when the caller
203
+ * has constructed an agent manually, or when testing an agent module that is
204
+ * outside the configured agent loader search paths.
205
+ *
206
+ * The previous active agent, if any, is cleaned up via `destructor()`. The new
207
+ * agent becomes the launcher's active agent and has the launcher's
208
+ * `agent:handoff` listener attached to its Prompt, just like agents loaded via
209
+ * `load()`.
210
+ *
211
+ * The supplied agent is assumed to be a valid `Agent` instance. Unlike
212
+ * `load()`, this method does not resolve, import, or validate an agent module
213
+ * through the configured agent loader.
214
+ *
215
+ * @param {Agent} newAgent - Existing Agent instance to make active.
216
+ * @returns {AgentLauncher} Returns `this` for chaining.
217
+ *
218
+ * @example
219
+ * const launcher = new AgentLauncher();
220
+ * launcher.setActiveAgent(agent);
221
+ * await launcher.run();
222
+ *
223
+ * @see #load
224
+ * @see #getActiveAgent
225
+ */
226
+ setActiveAgent(newAgent: Agent): AgentLauncher;
199
227
  /**
200
228
  * Returns the Prompt belonging to the active agent (or null).
201
229
  *