@ellyco/agentic 0.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 (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +560 -0
  3. package/dist/graphs/graph.d.ts +218 -0
  4. package/dist/graphs/graph.d.ts.map +1 -0
  5. package/dist/graphs/graph.js +334 -0
  6. package/dist/graphs/graph.js.map +1 -0
  7. package/dist/graphs/index.d.ts +7 -0
  8. package/dist/graphs/index.d.ts.map +1 -0
  9. package/dist/graphs/index.js +15 -0
  10. package/dist/graphs/index.js.map +1 -0
  11. package/dist/graphs/iterator.d.ts +138 -0
  12. package/dist/graphs/iterator.d.ts.map +1 -0
  13. package/dist/graphs/iterator.js +184 -0
  14. package/dist/graphs/iterator.js.map +1 -0
  15. package/dist/graphs/merge-state.d.ts +22 -0
  16. package/dist/graphs/merge-state.d.ts.map +1 -0
  17. package/dist/graphs/merge-state.js +56 -0
  18. package/dist/graphs/merge-state.js.map +1 -0
  19. package/dist/graphs/node-sequence.d.ts +63 -0
  20. package/dist/graphs/node-sequence.d.ts.map +1 -0
  21. package/dist/graphs/node-sequence.js +84 -0
  22. package/dist/graphs/node-sequence.js.map +1 -0
  23. package/dist/graphs/registry.d.ts +5 -0
  24. package/dist/graphs/registry.d.ts.map +1 -0
  25. package/dist/graphs/registry.js +6 -0
  26. package/dist/graphs/registry.js.map +1 -0
  27. package/dist/graphs/runtime-context.d.ts +189 -0
  28. package/dist/graphs/runtime-context.d.ts.map +1 -0
  29. package/dist/graphs/runtime-context.js +254 -0
  30. package/dist/graphs/runtime-context.js.map +1 -0
  31. package/dist/graphs/state-machine.d.ts +105 -0
  32. package/dist/graphs/state-machine.d.ts.map +1 -0
  33. package/dist/graphs/state-machine.js +130 -0
  34. package/dist/graphs/state-machine.js.map +1 -0
  35. package/dist/graphs/store/base-store.d.ts +90 -0
  36. package/dist/graphs/store/base-store.d.ts.map +1 -0
  37. package/dist/graphs/store/base-store.js +50 -0
  38. package/dist/graphs/store/base-store.js.map +1 -0
  39. package/dist/graphs/store/sqlite-store.d.ts +88 -0
  40. package/dist/graphs/store/sqlite-store.d.ts.map +1 -0
  41. package/dist/graphs/store/sqlite-store.js +109 -0
  42. package/dist/graphs/store/sqlite-store.js.map +1 -0
  43. package/dist/graphs/store/stored-run.d.ts +77 -0
  44. package/dist/graphs/store/stored-run.d.ts.map +1 -0
  45. package/dist/graphs/store/stored-run.js +88 -0
  46. package/dist/graphs/store/stored-run.js.map +1 -0
  47. package/dist/graphs/types.d.ts +15 -0
  48. package/dist/graphs/types.d.ts.map +1 -0
  49. package/dist/graphs/types.js +3 -0
  50. package/dist/graphs/types.js.map +1 -0
  51. package/dist/messages/index.d.ts +6 -0
  52. package/dist/messages/index.d.ts.map +1 -0
  53. package/dist/messages/index.js +19 -0
  54. package/dist/messages/index.js.map +1 -0
  55. package/dist/messages/message.d.ts +143 -0
  56. package/dist/messages/message.d.ts.map +1 -0
  57. package/dist/messages/message.js +172 -0
  58. package/dist/messages/message.js.map +1 -0
  59. package/dist/messages/tool.d.ts +160 -0
  60. package/dist/messages/tool.d.ts.map +1 -0
  61. package/dist/messages/tool.js +173 -0
  62. package/dist/messages/tool.js.map +1 -0
  63. package/dist/models/BaseModel.d.ts +232 -0
  64. package/dist/models/BaseModel.d.ts.map +1 -0
  65. package/dist/models/BaseModel.js +247 -0
  66. package/dist/models/BaseModel.js.map +1 -0
  67. package/dist/models/BedrockModel.d.ts +112 -0
  68. package/dist/models/BedrockModel.d.ts.map +1 -0
  69. package/dist/models/BedrockModel.js +315 -0
  70. package/dist/models/BedrockModel.js.map +1 -0
  71. package/dist/models/TestModel.d.ts +135 -0
  72. package/dist/models/TestModel.d.ts.map +1 -0
  73. package/dist/models/TestModel.js +191 -0
  74. package/dist/models/TestModel.js.map +1 -0
  75. package/dist/nodes/function-node.d.ts +59 -0
  76. package/dist/nodes/function-node.d.ts.map +1 -0
  77. package/dist/nodes/function-node.js +72 -0
  78. package/dist/nodes/function-node.js.map +1 -0
  79. package/dist/nodes/index.d.ts +4 -0
  80. package/dist/nodes/index.d.ts.map +1 -0
  81. package/dist/nodes/index.js +9 -0
  82. package/dist/nodes/index.js.map +1 -0
  83. package/dist/nodes/interrupt-node.d.ts +51 -0
  84. package/dist/nodes/interrupt-node.d.ts.map +1 -0
  85. package/dist/nodes/interrupt-node.js +65 -0
  86. package/dist/nodes/interrupt-node.js.map +1 -0
  87. package/dist/nodes/model-node.d.ts +72 -0
  88. package/dist/nodes/model-node.d.ts.map +1 -0
  89. package/dist/nodes/model-node.js +80 -0
  90. package/dist/nodes/model-node.js.map +1 -0
  91. package/dist/nodes/types.d.ts +5 -0
  92. package/dist/nodes/types.d.ts.map +1 -0
  93. package/dist/nodes/types.js +3 -0
  94. package/dist/nodes/types.js.map +1 -0
  95. package/dist/tools.d.ts +65 -0
  96. package/dist/tools.d.ts.map +1 -0
  97. package/dist/tools.js +56 -0
  98. package/dist/tools.js.map +1 -0
  99. package/dist/types.d.ts +17 -0
  100. package/dist/types.d.ts.map +1 -0
  101. package/dist/types.js +3 -0
  102. package/dist/types.js.map +1 -0
  103. package/package.json +32 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine.js","sourceRoot":"","sources":["../../src/graphs/state-machine.ts"],"names":[],"mappings":";;;AAAA,mCAA4C;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAa,YAAoF,SAAQ,aAAW;IAChH;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,IAAY,EAAE,IAAiC;QACnD,IAAI,IAAI,KAAK,aAAK,IAAI,IAAI,KAAK,WAAG,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,QAAQ,IAAI,cAAc,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,QAAQ,IAAI,iBAAiB,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACxB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,IAAY,EAAE,EAAU;QAC5B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,kBAAkB,CACd,IAAY,EACZ,EAAK,EACL,IAA6B;QAE7B,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACX,8CAA8C,IAAI,EAAE,CACvD,CAAC;QACN,CAAC;QACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QACjC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACnC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;OAMG;IACO,gBAAgB,CAAC,KAAQ;QAC/B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;;OAMG;IACO,gBAAgB,CAAC,SAAqB;QAC5C,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AAzGD,oCAyGC"}
@@ -0,0 +1,90 @@
1
+ import { StoredRun } from "./stored-run";
2
+ /**
3
+ * Abstract base class for storing and retrieving graph run state.
4
+ * Implementations persist graph state between interruptions, enabling resumable workflows.
5
+ *
6
+ * @abstract
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Create a custom store implementation
11
+ * class MyCustomStore extends BaseStore {
12
+ * async save(runId: string, cursor: string, state: object): Promise<void> {
13
+ * // Custom persistence logic
14
+ * }
15
+ * async load(runId: string): Promise<{ cursor: string, state: object }> {
16
+ * // Custom retrieval logic
17
+ * }
18
+ * // ... implement other methods
19
+ * }
20
+ *
21
+ * // Use with graph
22
+ * const store = new MyCustomStore();
23
+ * const result = await graph.invoke(state, { store });
24
+ * ```
25
+ */
26
+ export declare abstract class BaseStore {
27
+ /**
28
+ * Saves the state and cursor position of a run.
29
+ *
30
+ * @abstract
31
+ * @param {string} runId - Unique run identifier
32
+ * @param {string} cursor - Position in the graph (encoded path through nodes)
33
+ * @param {object} state - Complete state at this point
34
+ * @returns {Promise<void>}
35
+ */
36
+ abstract save(runId: string, cursor: string, state: object): Promise<void>;
37
+ /**
38
+ * Checks if a run exists in the store.
39
+ *
40
+ * @abstract
41
+ * @param {string} runId - Unique run identifier
42
+ * @returns {Promise<boolean>} True if the run exists
43
+ */
44
+ abstract exists(runId: string): Promise<boolean>;
45
+ /**
46
+ * Loads the saved state and cursor for a run.
47
+ *
48
+ * @abstract
49
+ * @param {string} runId - Unique run identifier
50
+ * @returns {Promise<{cursor: string, state: object}>} The saved cursor and state
51
+ * @throws {Error} If the run is not found
52
+ */
53
+ abstract load(runId: string): Promise<{
54
+ cursor: string;
55
+ state: object;
56
+ }>;
57
+ /**
58
+ * Deletes a run from the store.
59
+ *
60
+ * @abstract
61
+ * @param {string} runId - Unique run identifier
62
+ * @returns {Promise<void>}
63
+ */
64
+ abstract delete(runId: string): Promise<void>;
65
+ /**
66
+ * Closes the store and releases resources.
67
+ * Called when the store is no longer needed.
68
+ *
69
+ * @abstract
70
+ * @returns {Promise<void>}
71
+ */
72
+ abstract dispose(): Promise<void>;
73
+ /**
74
+ * Gets a StoredRun wrapper for a specific run ID.
75
+ *
76
+ * @param {string} runId - Unique run identifier
77
+ * @returns {StoredRun} Wrapper for interacting with this specific run
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const storedRun = store.getStoredRun("run-123");
82
+ * if (await storedRun.exists()) {
83
+ * const loaded = await storedRun.load();
84
+ * console.log(loaded.state);
85
+ * }
86
+ * ```
87
+ */
88
+ getStoredRun(runId: string): StoredRun;
89
+ }
90
+ //# sourceMappingURL=base-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-store.d.ts","sourceRoot":"","sources":["../../../src/graphs/store/base-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,8BAAsB,SAAS;IAC3B;;;;;;;;OAQG;IACH,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1E;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAEhD;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAExE;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE7C;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAEjC;;;;;;;;;;;;;;OAcG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS;CAGzC"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseStore = void 0;
4
+ const stored_run_1 = require("./stored-run");
5
+ /**
6
+ * Abstract base class for storing and retrieving graph run state.
7
+ * Implementations persist graph state between interruptions, enabling resumable workflows.
8
+ *
9
+ * @abstract
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * // Create a custom store implementation
14
+ * class MyCustomStore extends BaseStore {
15
+ * async save(runId: string, cursor: string, state: object): Promise<void> {
16
+ * // Custom persistence logic
17
+ * }
18
+ * async load(runId: string): Promise<{ cursor: string, state: object }> {
19
+ * // Custom retrieval logic
20
+ * }
21
+ * // ... implement other methods
22
+ * }
23
+ *
24
+ * // Use with graph
25
+ * const store = new MyCustomStore();
26
+ * const result = await graph.invoke(state, { store });
27
+ * ```
28
+ */
29
+ class BaseStore {
30
+ /**
31
+ * Gets a StoredRun wrapper for a specific run ID.
32
+ *
33
+ * @param {string} runId - Unique run identifier
34
+ * @returns {StoredRun} Wrapper for interacting with this specific run
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const storedRun = store.getStoredRun("run-123");
39
+ * if (await storedRun.exists()) {
40
+ * const loaded = await storedRun.load();
41
+ * console.log(loaded.state);
42
+ * }
43
+ * ```
44
+ */
45
+ getStoredRun(runId) {
46
+ return new stored_run_1.StoredRun(runId, this);
47
+ }
48
+ }
49
+ exports.BaseStore = BaseStore;
50
+ //# sourceMappingURL=base-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-store.js","sourceRoot":"","sources":["../../../src/graphs/store/base-store.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAsB,SAAS;IAiD3B;;;;;;;;;;;;;;OAcG;IACH,YAAY,CAAC,KAAa;QACtB,OAAO,IAAI,sBAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;CACJ;AAnED,8BAmEC"}
@@ -0,0 +1,88 @@
1
+ import { BaseStore } from "./base-store";
2
+ import { Database } from "better-sqlite3";
3
+ /**
4
+ * A store implementation using SQLite for persistent storage of graph run state.
5
+ * Provides reliable checkpoint-based resumption across sessions.
6
+ *
7
+ * @class SQLiteStore
8
+ * @extends {BaseStore}
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import Database from "better-sqlite3";
13
+ *
14
+ * // Create or open a database
15
+ * const db = new Database("runs.db");
16
+ * const store = new SQLiteStore(db, "graph_runs");
17
+ *
18
+ * // Use with graph for persistent execution
19
+ * const result = await graph.invoke(initialState, { store });
20
+ *
21
+ * // Later, resume from checkpoint
22
+ * if (result.exitReason === "interrupt") {
23
+ * const result2 = await graph.invoke(result.state, { store, resumeFrom: result.cursor });
24
+ * }
25
+ *
26
+ * // Clean up
27
+ * await store.dispose();
28
+ * ```
29
+ */
30
+ export declare class SQLiteStore extends BaseStore {
31
+ private readonly db;
32
+ private readonly tableName;
33
+ /**
34
+ * Creates a new SQLite store.
35
+ * Automatically creates the table if it doesn't exist.
36
+ *
37
+ * @param {Database} db - The SQLite database connection
38
+ * @param {string} [tableName="runs"] - Name of the table for storing runs
39
+ */
40
+ constructor(db: Database, tableName?: string);
41
+ /**
42
+ * Saves the state and cursor for a run.
43
+ * Creates a new record or updates existing one.
44
+ *
45
+ * @async
46
+ * @param {string} runId - Unique run identifier
47
+ * @param {string} cursor - Encoded graph position
48
+ * @param {object} state - State to persist
49
+ * @returns {Promise<void>}
50
+ */
51
+ save(runId: string, cursor: string, state: object): Promise<void>;
52
+ /**
53
+ * Checks if a run exists in the store.
54
+ *
55
+ * @async
56
+ * @param {string} runId - Unique run identifier
57
+ * @returns {Promise<boolean>} True if the run exists
58
+ */
59
+ exists(runId: string): Promise<boolean>;
60
+ /**
61
+ * Loads the saved state and cursor for a run.
62
+ *
63
+ * @async
64
+ * @param {string} runId - Unique run identifier
65
+ * @returns {Promise<{cursor: string, state: object}>} The saved checkpoint
66
+ * @throws {Error} If the run is not found
67
+ */
68
+ load(runId: string): Promise<{
69
+ cursor: string;
70
+ state: object;
71
+ }>;
72
+ /**
73
+ * Deletes a run from the store.
74
+ *
75
+ * @async
76
+ * @param {string} runId - Unique run identifier
77
+ * @returns {Promise<void>}
78
+ */
79
+ delete(runId: string): Promise<void>;
80
+ /**
81
+ * Closes the database connection and releases resources.
82
+ *
83
+ * @async
84
+ * @returns {Promise<void>}
85
+ */
86
+ dispose(): Promise<void>;
87
+ }
88
+ //# sourceMappingURL=sqlite-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-store.d.ts","sourceRoot":"","sources":["../../../src/graphs/store/sqlite-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,WAAY,SAAQ,SAAS;IAS1B,OAAO,CAAC,QAAQ,CAAC,EAAE;IAAY,OAAO,CAAC,QAAQ,CAAC,SAAS;IAPrE;;;;;;OAMG;gBAC0B,EAAE,EAAE,QAAQ,EAAmB,SAAS,GAAE,MAAe;IAKtF;;;;;;;;;OASG;IACG,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOvE;;;;;;OAMG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK7C;;;;;;;OAOG;IACG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAQrE;;;;;;OAMG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAGjC"}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SQLiteStore = void 0;
4
+ const base_store_1 = require("./base-store");
5
+ /**
6
+ * A store implementation using SQLite for persistent storage of graph run state.
7
+ * Provides reliable checkpoint-based resumption across sessions.
8
+ *
9
+ * @class SQLiteStore
10
+ * @extends {BaseStore}
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import Database from "better-sqlite3";
15
+ *
16
+ * // Create or open a database
17
+ * const db = new Database("runs.db");
18
+ * const store = new SQLiteStore(db, "graph_runs");
19
+ *
20
+ * // Use with graph for persistent execution
21
+ * const result = await graph.invoke(initialState, { store });
22
+ *
23
+ * // Later, resume from checkpoint
24
+ * if (result.exitReason === "interrupt") {
25
+ * const result2 = await graph.invoke(result.state, { store, resumeFrom: result.cursor });
26
+ * }
27
+ *
28
+ * // Clean up
29
+ * await store.dispose();
30
+ * ```
31
+ */
32
+ class SQLiteStore extends base_store_1.BaseStore {
33
+ db;
34
+ tableName;
35
+ /**
36
+ * Creates a new SQLite store.
37
+ * Automatically creates the table if it doesn't exist.
38
+ *
39
+ * @param {Database} db - The SQLite database connection
40
+ * @param {string} [tableName="runs"] - Name of the table for storing runs
41
+ */
42
+ constructor(db, tableName = "runs") {
43
+ super();
44
+ this.db = db;
45
+ this.tableName = tableName;
46
+ this.db.prepare(`CREATE TABLE IF NOT EXISTS ${this.tableName} (run_id TEXT PRIMARY KEY, cursor TEXT, state TEXT)`).run();
47
+ }
48
+ /**
49
+ * Saves the state and cursor for a run.
50
+ * Creates a new record or updates existing one.
51
+ *
52
+ * @async
53
+ * @param {string} runId - Unique run identifier
54
+ * @param {string} cursor - Encoded graph position
55
+ * @param {object} state - State to persist
56
+ * @returns {Promise<void>}
57
+ */
58
+ async save(runId, cursor, state) {
59
+ this.db.prepare(`INSERT INTO ${this.tableName} (run_id, cursor, state) VALUES (?, ?, ?)
60
+ ON CONFLICT(run_id) DO UPDATE SET cursor = excluded.cursor, state = excluded.state`).run(runId, cursor, JSON.stringify(state));
61
+ }
62
+ /**
63
+ * Checks if a run exists in the store.
64
+ *
65
+ * @async
66
+ * @param {string} runId - Unique run identifier
67
+ * @returns {Promise<boolean>} True if the run exists
68
+ */
69
+ async exists(runId) {
70
+ const result = this.db.prepare(`SELECT 1 FROM ${this.tableName} WHERE run_id = ?`).get(runId);
71
+ return result !== undefined;
72
+ }
73
+ /**
74
+ * Loads the saved state and cursor for a run.
75
+ *
76
+ * @async
77
+ * @param {string} runId - Unique run identifier
78
+ * @returns {Promise<{cursor: string, state: object}>} The saved checkpoint
79
+ * @throws {Error} If the run is not found
80
+ */
81
+ async load(runId) {
82
+ const result = this.db.prepare(`SELECT cursor, state FROM ${this.tableName} WHERE run_id = ?`).get(runId);
83
+ if (!result) {
84
+ throw new Error(`Run ${runId} not found`);
85
+ }
86
+ return { cursor: result.cursor, state: JSON.parse(result.state) };
87
+ }
88
+ /**
89
+ * Deletes a run from the store.
90
+ *
91
+ * @async
92
+ * @param {string} runId - Unique run identifier
93
+ * @returns {Promise<void>}
94
+ */
95
+ async delete(runId) {
96
+ this.db.prepare(`DELETE FROM ${this.tableName} WHERE run_id = ?`).run(runId);
97
+ }
98
+ /**
99
+ * Closes the database connection and releases resources.
100
+ *
101
+ * @async
102
+ * @returns {Promise<void>}
103
+ */
104
+ async dispose() {
105
+ this.db.close();
106
+ }
107
+ }
108
+ exports.SQLiteStore = SQLiteStore;
109
+ //# sourceMappingURL=sqlite-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-store.js","sourceRoot":"","sources":["../../../src/graphs/store/sqlite-store.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAGzC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,WAAY,SAAQ,sBAAS;IAST;IAA+B;IAP5D;;;;;;OAMG;IACH,YAA6B,EAAY,EAAmB,YAAoB,MAAM;QAClF,KAAK,EAAE,CAAC;QADiB,OAAE,GAAF,EAAE,CAAU;QAAmB,cAAS,GAAT,SAAS,CAAiB;QAElF,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,8BAA8B,IAAI,CAAC,SAAS,qDAAqD,CAAC,CAAC,GAAG,EAAE,CAAC;IAC7H,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,IAAI,CAAC,KAAa,EAAE,MAAc,EAAE,KAAa;QACnD,IAAI,CAAC,EAAE,CAAC,OAAO,CACX,eAAe,IAAI,CAAC,SAAS;gGACuD,CACvF,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAC,KAAa;QACtB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,iBAAiB,IAAI,CAAC,SAAS,mBAAmB,CAAC,CAAC,GAAG,CAAC,KAAK,CAAsD,CAAC;QACnJ,OAAO,MAAM,KAAK,SAAS,CAAC;IAChC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CAAC,KAAa;QACpB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,6BAA6B,IAAI,CAAC,SAAS,mBAAmB,CAAC,CAAC,GAAG,CAAC,KAAK,CAAsD,CAAC;QAC/J,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,OAAO,KAAK,YAAY,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IACtE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAC,KAAa;QACtB,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,eAAe,IAAI,CAAC,SAAS,mBAAmB,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACjF,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAO;QACT,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;CACJ;AA/ED,kCA+EC"}
@@ -0,0 +1,77 @@
1
+ import { BaseStore } from "./base-store";
2
+ /**
3
+ * Wrapper for interacting with a specific run's stored state and cursor.
4
+ * Provides a convenient interface for saving, loading, and managing individual runs.
5
+ *
6
+ * @class StoredRun
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const storedRun = store.getStoredRun("run-123");
11
+ *
12
+ * // Check if run exists
13
+ * if (await storedRun.exists()) {
14
+ * const { cursor, state } = await storedRun.load();
15
+ * console.log("Previously interrupted at:", cursor);
16
+ * }
17
+ *
18
+ * // Save run state
19
+ * await storedRun.save("node-5", { data: "updated" });
20
+ *
21
+ * // Clean up when done
22
+ * await storedRun.delete();
23
+ * ```
24
+ */
25
+ export declare class StoredRun {
26
+ readonly runId: string;
27
+ private readonly store;
28
+ /**
29
+ * Creates a wrapper for a specific run.
30
+ *
31
+ * @param {string} runId - Unique identifier for this run
32
+ * @param {BaseStore} store - The underlying store implementation
33
+ */
34
+ constructor(runId: string, store: BaseStore);
35
+ /**
36
+ * Saves the current state and cursor position of this run.
37
+ *
38
+ * @param {string} cursor - Encoded position in the graph
39
+ * @param {object} state - Complete state at this checkpoint
40
+ * @returns {Promise<void>}
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * await storedRun.save("node-process", { count: 42, data: [...] });
45
+ * ```
46
+ */
47
+ save(cursor: string, state: object): Promise<void>;
48
+ /**
49
+ * Checks if this run has been saved to the store.
50
+ *
51
+ * @returns {Promise<boolean>} True if the run exists
52
+ */
53
+ exists(): Promise<boolean>;
54
+ /**
55
+ * Loads the saved state and cursor for this run.
56
+ *
57
+ * @returns {Promise<{cursor: string, state: object}>} The saved checkpoint
58
+ * @throws {Error} If the run does not exist
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const { cursor, state } = await storedRun.load();
63
+ * // Resume from cursor: await graph.invoke(state, { resumeFrom: cursor });
64
+ * ```
65
+ */
66
+ load(): Promise<{
67
+ cursor: string;
68
+ state: object;
69
+ }>;
70
+ /**
71
+ * Deletes this run from the store.
72
+ *
73
+ * @returns {Promise<void>}
74
+ */
75
+ delete(): Promise<void>;
76
+ }
77
+ //# sourceMappingURL=stored-run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-run.d.ts","sourceRoot":"","sources":["../../../src/graphs/store/stored-run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,SAAS;aAOU,KAAK,EAAE,MAAM;IAAE,OAAO,CAAC,QAAQ,CAAC,KAAK;IANjE;;;;;OAKG;gBACyB,KAAK,EAAE,MAAM,EAAmB,KAAK,EAAE,SAAS;IAG5E;;;;;;;;;;;OAWG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAIhC;;;;;;;;;;;OAWG;IACG,IAAI,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAIxD;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StoredRun = void 0;
4
+ /**
5
+ * Wrapper for interacting with a specific run's stored state and cursor.
6
+ * Provides a convenient interface for saving, loading, and managing individual runs.
7
+ *
8
+ * @class StoredRun
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const storedRun = store.getStoredRun("run-123");
13
+ *
14
+ * // Check if run exists
15
+ * if (await storedRun.exists()) {
16
+ * const { cursor, state } = await storedRun.load();
17
+ * console.log("Previously interrupted at:", cursor);
18
+ * }
19
+ *
20
+ * // Save run state
21
+ * await storedRun.save("node-5", { data: "updated" });
22
+ *
23
+ * // Clean up when done
24
+ * await storedRun.delete();
25
+ * ```
26
+ */
27
+ class StoredRun {
28
+ runId;
29
+ store;
30
+ /**
31
+ * Creates a wrapper for a specific run.
32
+ *
33
+ * @param {string} runId - Unique identifier for this run
34
+ * @param {BaseStore} store - The underlying store implementation
35
+ */
36
+ constructor(runId, store) {
37
+ this.runId = runId;
38
+ this.store = store;
39
+ }
40
+ /**
41
+ * Saves the current state and cursor position of this run.
42
+ *
43
+ * @param {string} cursor - Encoded position in the graph
44
+ * @param {object} state - Complete state at this checkpoint
45
+ * @returns {Promise<void>}
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * await storedRun.save("node-process", { count: 42, data: [...] });
50
+ * ```
51
+ */
52
+ async save(cursor, state) {
53
+ await this.store.save(this.runId, cursor, state);
54
+ }
55
+ /**
56
+ * Checks if this run has been saved to the store.
57
+ *
58
+ * @returns {Promise<boolean>} True if the run exists
59
+ */
60
+ async exists() {
61
+ return await this.store.exists(this.runId);
62
+ }
63
+ /**
64
+ * Loads the saved state and cursor for this run.
65
+ *
66
+ * @returns {Promise<{cursor: string, state: object}>} The saved checkpoint
67
+ * @throws {Error} If the run does not exist
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const { cursor, state } = await storedRun.load();
72
+ * // Resume from cursor: await graph.invoke(state, { resumeFrom: cursor });
73
+ * ```
74
+ */
75
+ async load() {
76
+ return await this.store.load(this.runId);
77
+ }
78
+ /**
79
+ * Deletes this run from the store.
80
+ *
81
+ * @returns {Promise<void>}
82
+ */
83
+ async delete() {
84
+ await this.store.delete(this.runId);
85
+ }
86
+ }
87
+ exports.StoredRun = StoredRun;
88
+ //# sourceMappingURL=stored-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-run.js","sourceRoot":"","sources":["../../../src/graphs/store/stored-run.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,SAAS;IAOU;IAAgC;IAN5D;;;;;OAKG;IACH,YAA4B,KAAa,EAAmB,KAAgB;QAAhD,UAAK,GAAL,KAAK,CAAQ;QAAmB,UAAK,GAAL,KAAK,CAAW;IAC5E,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,KAAa;QACpC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM;QACR,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,IAAI;QACN,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM;QACR,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACJ;AA3DD,8BA2DC"}
@@ -0,0 +1,15 @@
1
+ interface EndResult<S> {
2
+ runId: string;
3
+ state: S;
4
+ exitReason: "end";
5
+ }
6
+ interface InterruptResult<S> {
7
+ runId: string;
8
+ state: S;
9
+ exitReason: "interrupt";
10
+ exitMessage: string;
11
+ cursor: string;
12
+ }
13
+ export type GraphResult<S> = EndResult<S> | InterruptResult<S>;
14
+ export {};
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/graphs/types.ts"],"names":[],"mappings":"AAAA,UAAU,SAAS,CAAC,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;IACT,UAAU,EAAE,KAAK,CAAC;CACrB;AAED,UAAU,eAAe,CAAC,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;IACT,UAAU,EAAE,WAAW,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/graphs/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { BaseMessage } from "./message";
2
+ import { ToolUse } from "./tool";
3
+ export type ModelMessages = BaseMessage | ToolUse;
4
+ export * from "./message";
5
+ export * from "./tool";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,OAAO,CAAC;AAElD,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./message"), exports);
18
+ __exportStar(require("./tool"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAKA,4CAA0B;AAC1B,yCAAuB"}