goblin-agents 3.0.0 → 3.1.0

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/llm/aiAgent.js +25 -7
  2. package/package.json +1 -1
@@ -596,15 +596,33 @@ class AiAgent extends Elf {
596
596
 
597
597
  /**
598
598
  * Set chat session context, model and level of reasoning
599
- * @param {*} contextId
600
- * @param {string} context
601
- * @param {string} model
602
- * @param {string} reasoning
599
+ * @param {string} contextId
600
+ * @param {string} [context]
601
+ * @param {string} [model]
602
+ * @param {string|boolean} [reasoning]
603
603
  */
604
604
  async setContext(contextId, context, model, reasoning) {
605
605
  this.logic.setContext(contextId, context, model, reasoning);
606
606
  }
607
607
 
608
+ /**
609
+ * Retrieves the configuration associated with a chat context.
610
+ *
611
+ * Falls back to the global settings when no context-specific
612
+ * configuration is available.
613
+ *
614
+ * @param {string} contextId - Unique identifier of the chat context.
615
+ * @returns {Promise<{context: string, model: string, reasoning: string|boolean}>}
616
+ * The context content, selected model, and reasoning level.
617
+ */
618
+ async getContext(contextId) {
619
+ const context = this.state.contexts[contextId] || '';
620
+ const model = this.state.models[contextId] || this.state.model;
621
+ const reasoning =
622
+ this.state.reasonings[contextId] || this.state.reasoning || false;
623
+ return {context, model, reasoning};
624
+ }
625
+
608
626
  async chat(contextId, question, userDesktopId) {
609
627
  const logger = Logger.get(contextId, this);
610
628
 
@@ -613,9 +631,9 @@ class AiAgent extends Elf {
613
631
 
614
632
  await this._loadProvider();
615
633
  const contextMessages = this.state.messages[contextId] || [];
616
- const context = this.state.contexts[contextId];
617
- const reasoning = this.state.reasonings[contextId];
618
- const model = this.state.models[contextId];
634
+ const context = this.state.contexts[contextId] || null;
635
+ const reasoning = this.state.reasonings[contextId] || this.state.reasoning;
636
+ const model = this.state.models[contextId] || this.state.model;
619
637
 
620
638
  let systemPrompt = this.state.prompt || '';
621
639
  if (context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goblin-agents",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "AI Agents framework",
5
5
  "author": "Epsitec SA",
6
6
  "contributors": [