saico 2.2.1 → 2.2.3

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.
package/context.js CHANGED
@@ -72,6 +72,36 @@ class Context {
72
72
  // Overridable: extending classes provide current state summary
73
73
  getStateSummary() { return ''; }
74
74
 
75
+ // Recursively collect state summaries from child tasks that have no context
76
+ // (no msg Q), stopping at children that do have one.
77
+ _collectChildStateSummaries(task) {
78
+ if (!task.child || !task.child.size) return '';
79
+ const parts = [];
80
+ for (const child of task.child) {
81
+ if (child.context) continue; // has its own Q — boundary, stop here
82
+ if (typeof child.getStateSummary === 'function') {
83
+ const s = child.getStateSummary();
84
+ if (s) parts.push(s);
85
+ }
86
+ const nested = this._collectChildStateSummaries(child);
87
+ if (nested) parts.push(nested);
88
+ }
89
+ return parts.join('\n');
90
+ }
91
+
92
+ // Internal (not overridable): own getStateSummary() + summaries from all
93
+ // contextless descendants, stopping at the first child that has its own Q.
94
+ _getStateSummary() {
95
+ const parts = [];
96
+ const own = this.getStateSummary();
97
+ if (own) parts.push(own);
98
+ if (this.task) {
99
+ const childSummaries = this._collectChildStateSummaries(this.task);
100
+ if (childSummaries) parts.push(childSummaries);
101
+ }
102
+ return parts.join('\n');
103
+ }
104
+
75
105
  // Snapshot all public (non-underscore) task properties for dirty detection.
76
106
  // Mirrors the observable proxy convention: _ prefix = internal, ignored.
77
107
  // Does NOT call serialize() — that is for persistence, not dirty detection.
@@ -808,7 +838,7 @@ class Context {
808
838
  if (add_tag) prompt.tag = ctx.tag;
809
839
  fullQueue.push(prompt);
810
840
  }
811
- const ctxSummary = ctx.getStateSummary();
841
+ const ctxSummary = ctx._getStateSummary();
812
842
  if (ctxSummary)
813
843
  fullQueue.push({role: 'system', content: '[State Summary]\n' + ctxSummary});
814
844
  }
@@ -817,7 +847,7 @@ class Context {
817
847
  if (add_tag) prompt.tag = this.tag;
818
848
  fullQueue.push(prompt);
819
849
  }
820
- const stateSummary = this.getStateSummary();
850
+ const stateSummary = this._getStateSummary();
821
851
  if (stateSummary)
822
852
  fullQueue.push({role: 'system', content: '[State Summary]\n' + stateSummary});
823
853
 
package/itask.js CHANGED
@@ -78,7 +78,7 @@ function Itask(opt, states){
78
78
 
79
79
  EventEmitter.call(this);
80
80
  opt = opt || {};
81
- this.id = makeId(10);
81
+ this.id = opt.id || makeId(10);
82
82
  this.name = opt.name;
83
83
  this.cancelable = !!opt.cancel;
84
84
  this.info = opt.info || {};
@@ -746,6 +746,10 @@ Itask.prototype.closeContext = async function closeContext(){
746
746
  await this.context.close();
747
747
  };
748
748
 
749
+ // Overridable: contextless tasks can provide a state summary that bubbles up
750
+ // into the nearest ancestor context's _getStateSummary().
751
+ Itask.prototype.getStateSummary = function getStateSummary(){ return ''; };
752
+
749
753
  // Reference to Context class (set by index.js to avoid circular dependency)
750
754
  Itask.Context = null;
751
755
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saico",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "main": "index.js",
5
5
  "type": "commonjs",
6
6
  "description": "Hierarchical AI Conversation Orchestrator - Task hierarchy with conversation contexts",
package/sid.js CHANGED
@@ -38,6 +38,8 @@ class Sid extends Itask {
38
38
  token_limit: opt.token_limit,
39
39
  max_depth: opt.max_depth,
40
40
  max_tool_repetition: opt.max_tool_repetition,
41
+ queue_limit: opt.queue_limit,
42
+ min_chat_messages: opt.min_chat_messages,
41
43
  ...opt.sessionConfig
42
44
  };
43
45
 
@@ -53,6 +55,8 @@ class Sid extends Itask {
53
55
  token_limit: this.sessionConfig.token_limit,
54
56
  max_depth: this.sessionConfig.max_depth,
55
57
  max_tool_repetition: this.sessionConfig.max_tool_repetition,
58
+ queue_limit: this.sessionConfig.queue_limit,
59
+ min_chat_messages: this.sessionConfig.min_chat_messages,
56
60
  tool_handler: opt.tool_handler,
57
61
  functions: opt.functions,
58
62
  sequential_mode: opt.sequential_mode,
@@ -162,6 +166,8 @@ class Sid extends Itask {
162
166
  token_limit: opt.token_limit || this.sessionConfig.token_limit,
163
167
  max_depth: opt.max_depth || this.sessionConfig.max_depth,
164
168
  max_tool_repetition: opt.max_tool_repetition || this.sessionConfig.max_tool_repetition,
169
+ queue_limit: opt.queue_limit ?? this.sessionConfig.queue_limit,
170
+ min_chat_messages: opt.min_chat_messages ?? this.sessionConfig.min_chat_messages,
165
171
  tool_handler: opt.tool_handler || this.tool_handler,
166
172
  functions: opt.functions || this.functions
167
173
  });