saico 2.9.0 → 2.9.1
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/README.md +9 -7
- package/package.json +1 -1
- package/saico.js +14 -11
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Saico -
|
|
1
|
+
# Saico - Simple AI-Agent Conversation Orchestrator
|
|
2
2
|
|
|
3
3
|
Saico is a Node.js library for building AI agents with hierarchical conversations, automatic context aggregation, and enterprise-grade tool calling. It manages nested task trees where each node can have its own message queue, system prompt, tools, and state — and the library automatically assembles the full payload sent to the LLM by walking the tree.
|
|
4
4
|
|
|
@@ -210,7 +210,7 @@ new Saico({
|
|
|
210
210
|
// Storage
|
|
211
211
|
redis: true, // Set false to skip Redis proxy
|
|
212
212
|
key: 'custom-redis-key',
|
|
213
|
-
store: 'my-table', // Table name for instance persistence (closeSession/
|
|
213
|
+
store: 'my-table', // Table name for instance persistence (store/closeSession/restore)
|
|
214
214
|
dynamodb: { // DynamoDB config (creates instance-level adapter)
|
|
215
215
|
region: 'us-east-1',
|
|
216
216
|
credentials: { accessKeyId: '...', secretAccessKey: '...' },
|
|
@@ -258,10 +258,11 @@ agent.getSessionInfo();
|
|
|
258
258
|
// userData, uptime
|
|
259
259
|
// }
|
|
260
260
|
|
|
261
|
-
await agent.
|
|
261
|
+
await agent.store(); // save to registered backend independently
|
|
262
|
+
await agent.closeSession(); // store + cancel task
|
|
262
263
|
|
|
263
264
|
// Restore from registered backend
|
|
264
|
-
const restored = await Saico.
|
|
265
|
+
const restored = await Saico.restore(agent.id, { store: 'sessions' });
|
|
265
266
|
```
|
|
266
267
|
|
|
267
268
|
## Database Access
|
|
@@ -312,8 +313,9 @@ const json = await agent.serialize();
|
|
|
312
313
|
const restored = await Saico.deserialize(json);
|
|
313
314
|
|
|
314
315
|
// Durable persistence (uses registered backend + opt.store table name)
|
|
315
|
-
await agent.
|
|
316
|
-
|
|
316
|
+
await agent.store(); // save independently
|
|
317
|
+
await agent.closeSession(); // store + cancel task
|
|
318
|
+
const restored2 = await Saico.restore(agent.id, { store: 'sessions' });
|
|
317
319
|
```
|
|
318
320
|
|
|
319
321
|
`prepareForStorage()` automatically picks up all non-underscore properties (id, name, prompt, userData, sessionConfig, tm_create, isolate, etc.) and produces compressed chat_history for the msgs Q.
|
|
@@ -405,7 +407,7 @@ saico/
|
|
|
405
407
|
npm test
|
|
406
408
|
```
|
|
407
409
|
|
|
408
|
-
300 tests covering Saico lifecycle, msgs Q ownership, spawn/spawnAndRun, task hierarchy, message handling, tool calls, DB adapters, async serialization, prepareForStorage, backend registration, persistence (closeSession/
|
|
410
|
+
300 tests covering Saico lifecycle, msgs Q ownership, spawn/spawnAndRun, task hierarchy, message handling, tool calls, DB adapters, async serialization, prepareForStorage, backend registration, persistence (store/closeSession/restore via registered backend), storage integration, and full hierarchy flows.
|
|
409
411
|
|
|
410
412
|
## Requirements
|
|
411
413
|
|
package/package.json
CHANGED
package/saico.js
CHANGED
|
@@ -501,19 +501,22 @@ class Saico {
|
|
|
501
501
|
}
|
|
502
502
|
|
|
503
503
|
/**
|
|
504
|
-
*
|
|
504
|
+
* Save instance state to registered backend under _storeName.
|
|
505
|
+
*/
|
|
506
|
+
async store() {
|
|
507
|
+
if (!this._storeName) return;
|
|
508
|
+
const backend = Saico.getBackend();
|
|
509
|
+
if (!backend) return;
|
|
510
|
+
const data = await this.prepareForStorage();
|
|
511
|
+
await backend.put(data, this._storeName);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Close the session — cancel task. Call store() first if persistence needed.
|
|
505
516
|
*/
|
|
506
517
|
async closeSession() {
|
|
507
518
|
if (!this._task) return;
|
|
508
|
-
|
|
509
|
-
if (this._storeName && this.msgs) {
|
|
510
|
-
const backend = Saico.getBackend();
|
|
511
|
-
if (backend) {
|
|
512
|
-
const data = await this.prepareForStorage();
|
|
513
|
-
await backend.put(data, this._storeName);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
|
|
519
|
+
await this.store();
|
|
517
520
|
this._task._ecancel();
|
|
518
521
|
}
|
|
519
522
|
|
|
@@ -718,7 +721,7 @@ class Saico {
|
|
|
718
721
|
* @param {Object} opt - Options (store: table name, backend, functions, states, etc.)
|
|
719
722
|
* @returns {Promise<Saico|null>}
|
|
720
723
|
*/
|
|
721
|
-
static async
|
|
724
|
+
static async restore(id, opt = {}) {
|
|
722
725
|
const backend = opt.backend || Saico.getBackend();
|
|
723
726
|
if (!backend)
|
|
724
727
|
throw new Error('No backend registered. Call Saico.registerBackend() first.');
|