@fractal-solutions/qflow 2.0.0-canary.4 → 2.0.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.
package/README.md CHANGED
@@ -49,8 +49,8 @@
49
49
  | **Multi-tenant assistants** | A `MemoryStore` per tenant plus `MemoryStoreNode` keeps recall isolated while flow code stays identical. | [Memory tutorial](documentation/tutorials/multi-tenant-memory.md) |
50
50
 
51
51
  The earlier production gaps — long-lived approvals, deterministic LLM replay,
52
- distributed side effects and multi-tenant memory/scheduling — are now closed in
53
- `2.0.0-canary.4`. See [Production gaps closed](#production-gaps-closed-200-canary4)
52
+ distributed side effects and multi-tenant memory/scheduling — are closed in
53
+ `2.0.0`. See [Production gaps closed](#production-gaps-closed-200)
54
54
  for the 1-2-3 paths, or [MIGRATION.md § 9-15](MIGRATION.md) for every option and
55
55
  error code.
56
56
 
@@ -108,17 +108,17 @@ bun add @fractal-solutions/qflow
108
108
 
109
109
  qflow 2.0 is **Bun-only**. Node.js is not a supported runtime.
110
110
 
111
- ### Canary channel
111
+ ### Install 2.0
112
112
 
113
- While 2.0 is in prerelease it is published under the `canary` dist-tag, so
114
- `latest` stays on the stable 1.x line. Install it explicitly:
113
+ `2.0.0` is now the `latest` release, so the normal install command gets it:
115
114
 
116
115
  ```bash
117
- bun add @fractal-solutions/qflow@canary
118
- # or pin an exact prerelease
119
- bun add @fractal-solutions/qflow@2.0.0-canary.4
116
+ bun add @fractal-solutions/qflow
117
+ # or pin the exact release
118
+ bun add @fractal-solutions/qflow@2.0.0
120
119
  ```
121
120
 
121
+ The `canary` dist-tag still points to `2.0.0-canary.4` for prerelease trackers.
122
122
  Read [MIGRATION.md](MIGRATION.md) before upgrading — 2.0 is a breaking release.
123
123
 
124
124
  ## Module Imports
@@ -544,9 +544,9 @@ await new AsyncFlow(stream).runAsync({ streamInput: [1, 2, 3] }); // shared.stre
544
544
 
545
545
  Events include `spawn:exit`, `file:change` and `stream:item`.
546
546
 
547
- ## Production gaps closed (2.0.0-canary.4)
547
+ ## Production gaps closed (2.0.0)
548
548
 
549
- The canary.3 families gave qflow breadth. This release closes the six gaps that
549
+ The canary.3 families gave qflow breadth. Stable 2.0 closes the six gaps that
550
550
  prevented those features from running unattended in production. Each subsection
551
551
  answers three questions: **why it exists**, **the 1-2-3 steps**, and **which
552
552
  options matter**. Full tables and failure modes live in
@@ -75,26 +75,26 @@ export class AgentEngine extends AsyncNode {
75
75
  const flowRegistryDescription = Object.keys(this.flowRegistry).length > 0
76
76
  ? `\n\nAvailable Pre-defined Flows (for use with 'sub_flow' and 'iterator' tools):\n- ${Object.keys(this.flowRegistry).join('\n- ')}`
77
77
  : '';
78
- return `You are Q, an autonomous agent. Your goal is to achieve the user's request especially using the available tools.
79
- Always prefer tools over long explanations. If you have a plan, you MUST include at least one tool call.
80
- If the user asks about your capabilities, summarize the 'Available Tools' section of this prompt instead of calling a tool.
81
-
82
- Reasoning strategy: ${this.strategy.label}
83
-
84
- Available Tools:
85
- ${toolDescriptions}${flowRegistryDescription}
86
-
87
- CRITICAL: Your response MUST be a single JSON object with 'thought' and 'tool_calls'.
88
- 'thought' is your reasoning; 'tool_calls' is an array of { tool, parameters } objects.
89
- Set "parallel": true at the top level to execute tool calls concurrently.
90
- Use the 'finish' tool only when you are certain the task is complete.
91
-
92
- Example response:
93
- {
94
- "thought": "I need to search for information.",
95
- "tool_calls": [{ "tool": "duckduckgo_search", "parameters": { "query": "latest AI research" } }]
96
- }
97
-
78
+ return `You are Q, an autonomous agent. Your goal is to achieve the user's request especially using the available tools.
79
+ Always prefer tools over long explanations. If you have a plan, you MUST include at least one tool call.
80
+ If the user asks about your capabilities, summarize the 'Available Tools' section of this prompt instead of calling a tool.
81
+
82
+ Reasoning strategy: ${this.strategy.label}
83
+
84
+ Available Tools:
85
+ ${toolDescriptions}${flowRegistryDescription}
86
+
87
+ CRITICAL: Your response MUST be a single JSON object with 'thought' and 'tool_calls'.
88
+ 'thought' is your reasoning; 'tool_calls' is an array of { tool, parameters } objects.
89
+ Set "parallel": true at the top level to execute tool calls concurrently.
90
+ Use the 'finish' tool only when you are certain the task is complete.
91
+
92
+ Example response:
93
+ {
94
+ "thought": "I need to search for information.",
95
+ "tool_calls": [{ "tool": "duckduckgo_search", "parameters": { "query": "latest AI research" } }]
96
+ }
97
+
98
98
  Begin!`;
99
99
  }
100
100
  async getLLMAction(observer = {}) {
@@ -300,12 +300,12 @@ ${toolDescriptions}${flowRegistryDescription}
300
300
  logger.error(`Error parsing LLM response in ${phase.name ?? 'action'} phase: ${error.message}`);
301
301
  this.conversationHistory.push({
302
302
  role: 'user',
303
- content: `CRITICAL ERROR: Your last response was NOT valid JSON or did not follow the expected format.
304
- Error details: ${error.message}
305
- Your invalid response was:
306
- \`\`\`
307
- ${raw}
308
- \`\`\`
303
+ content: `CRITICAL ERROR: Your last response was NOT valid JSON or did not follow the expected format.
304
+ Error details: ${error.message}
305
+ Your invalid response was:
306
+ \`\`\`
307
+ ${raw}
308
+ \`\`\`
309
309
  You MUST respond with a single JSON object containing 'thought' and 'tool_calls'. Do NOT generate any other text or code outside of this JSON structure. Re-evaluate your plan and provide a valid JSON response.`,
310
310
  });
311
311
  return { invalid: true };
@@ -6,11 +6,11 @@
6
6
  * - `postPhases` run after tool execution (thought-only reflection phases)
7
7
  */
8
8
  function toolErrorPrompt(errors) {
9
- return `
10
- IMPORTANT: One or more tool calls failed. Analyze the following errors carefully:
11
- ${errors}
12
-
13
- Explain *why* these tools failed. Propose an alternative tool or a revised plan to achieve the goal without these tools, or suggest how to fix the underlying issue. Do NOT generate irrelevant code, random thoughts, or go off-topic. Focus solely on addressing these errors and getting back on track to achieve the user's goal. If you are stuck, consider using the 'user_input' or 'interactive_input' tool to ask the user for clarification.
9
+ return `
10
+ IMPORTANT: One or more tool calls failed. Analyze the following errors carefully:
11
+ ${errors}
12
+
13
+ Explain *why* these tools failed. Propose an alternative tool or a revised plan to achieve the goal without these tools, or suggest how to fix the underlying issue. Do NOT generate irrelevant code, random thoughts, or go off-topic. Focus solely on addressing these errors and getting back on track to achieve the user's goal. If you are stuck, consider using the 'user_input' or 'interactive_input' tool to ask the user for clarification.
14
14
  `;
15
15
  }
16
16
  function noToolCallsPrompt(actionPhase) {
package/dist/durable.js CHANGED
@@ -77,63 +77,63 @@ export class SQLiteCheckpointer {
77
77
  this.workerId = workerId;
78
78
  this.leaseMs = leaseMs;
79
79
  this.db.exec('PRAGMA journal_mode = WAL;');
80
- this.db.exec(`
81
- CREATE TABLE IF NOT EXISTS qflow_runs (
82
- run_id TEXT PRIMARY KEY,
83
- flow_name TEXT NOT NULL,
84
- status TEXT NOT NULL,
85
- step INTEGER NOT NULL DEFAULT 0,
86
- cursor_node_index INTEGER,
87
- shared_json TEXT NOT NULL,
88
- params_json TEXT NOT NULL,
89
- result_json TEXT,
90
- error_json TEXT,
91
- created_at TEXT NOT NULL,
92
- updated_at TEXT NOT NULL
93
- );
94
- CREATE TABLE IF NOT EXISTS qflow_checkpoints (
95
- run_id TEXT NOT NULL,
96
- step INTEGER NOT NULL,
97
- node_index INTEGER,
98
- node_class TEXT NOT NULL,
99
- action TEXT,
100
- next_node_index INTEGER,
101
- shared_json TEXT NOT NULL,
102
- params_json TEXT NOT NULL,
103
- exec_res_json TEXT,
104
- created_at TEXT NOT NULL,
105
- PRIMARY KEY (run_id, step)
106
- );
107
- CREATE TABLE IF NOT EXISTS qflow_side_effects (
108
- run_id TEXT NOT NULL,
109
- operation_id TEXT NOT NULL,
110
- kind TEXT,
111
- status TEXT NOT NULL,
112
- result_json TEXT,
113
- error_json TEXT,
114
- created_at TEXT NOT NULL,
115
- updated_at TEXT NOT NULL,
116
- PRIMARY KEY (run_id, operation_id)
117
- );
118
- CREATE TABLE IF NOT EXISTS qflow_approvals (
119
- run_id TEXT NOT NULL,
120
- approval_id TEXT NOT NULL,
121
- prompt TEXT,
122
- status TEXT NOT NULL,
123
- decision_json TEXT,
124
- metadata_json TEXT,
125
- created_at TEXT NOT NULL,
126
- updated_at TEXT NOT NULL,
127
- PRIMARY KEY (run_id, approval_id)
128
- );
129
- CREATE TABLE IF NOT EXISTS qflow_cache (
130
- namespace TEXT NOT NULL,
131
- cache_key TEXT NOT NULL,
132
- value_json TEXT NOT NULL,
133
- expires_at INTEGER,
134
- created_at TEXT NOT NULL,
135
- PRIMARY KEY (namespace, cache_key)
136
- );
80
+ this.db.exec(`
81
+ CREATE TABLE IF NOT EXISTS qflow_runs (
82
+ run_id TEXT PRIMARY KEY,
83
+ flow_name TEXT NOT NULL,
84
+ status TEXT NOT NULL,
85
+ step INTEGER NOT NULL DEFAULT 0,
86
+ cursor_node_index INTEGER,
87
+ shared_json TEXT NOT NULL,
88
+ params_json TEXT NOT NULL,
89
+ result_json TEXT,
90
+ error_json TEXT,
91
+ created_at TEXT NOT NULL,
92
+ updated_at TEXT NOT NULL
93
+ );
94
+ CREATE TABLE IF NOT EXISTS qflow_checkpoints (
95
+ run_id TEXT NOT NULL,
96
+ step INTEGER NOT NULL,
97
+ node_index INTEGER,
98
+ node_class TEXT NOT NULL,
99
+ action TEXT,
100
+ next_node_index INTEGER,
101
+ shared_json TEXT NOT NULL,
102
+ params_json TEXT NOT NULL,
103
+ exec_res_json TEXT,
104
+ created_at TEXT NOT NULL,
105
+ PRIMARY KEY (run_id, step)
106
+ );
107
+ CREATE TABLE IF NOT EXISTS qflow_side_effects (
108
+ run_id TEXT NOT NULL,
109
+ operation_id TEXT NOT NULL,
110
+ kind TEXT,
111
+ status TEXT NOT NULL,
112
+ result_json TEXT,
113
+ error_json TEXT,
114
+ created_at TEXT NOT NULL,
115
+ updated_at TEXT NOT NULL,
116
+ PRIMARY KEY (run_id, operation_id)
117
+ );
118
+ CREATE TABLE IF NOT EXISTS qflow_approvals (
119
+ run_id TEXT NOT NULL,
120
+ approval_id TEXT NOT NULL,
121
+ prompt TEXT,
122
+ status TEXT NOT NULL,
123
+ decision_json TEXT,
124
+ metadata_json TEXT,
125
+ created_at TEXT NOT NULL,
126
+ updated_at TEXT NOT NULL,
127
+ PRIMARY KEY (run_id, approval_id)
128
+ );
129
+ CREATE TABLE IF NOT EXISTS qflow_cache (
130
+ namespace TEXT NOT NULL,
131
+ cache_key TEXT NOT NULL,
132
+ value_json TEXT NOT NULL,
133
+ expires_at INTEGER,
134
+ created_at TEXT NOT NULL,
135
+ PRIMARY KEY (namespace, cache_key)
136
+ );
137
137
  `);
138
138
  // Databases created by earlier canary builds lack the 2.0.0-canary.4 columns.
139
139
  this.#ensureColumn('qflow_runs', 'flow_version', 'TEXT');
@@ -149,31 +149,31 @@ export class SQLiteCheckpointer {
149
149
  }
150
150
  startRun({ runId, flowName, shared, params, version = null }) {
151
151
  const now = new Date().toISOString();
152
- this.db.prepare(`
153
- INSERT INTO qflow_runs (
154
- run_id, flow_name, status, step, cursor_node_index, flow_version, due_at,
155
- shared_json, params_json, result_json, error_json, created_at, updated_at
156
- ) VALUES (?, ?, 'running', 0, NULL, ?, NULL, ?, ?, NULL, NULL, ?, ?)
152
+ this.db.prepare(`
153
+ INSERT INTO qflow_runs (
154
+ run_id, flow_name, status, step, cursor_node_index, flow_version, due_at,
155
+ shared_json, params_json, result_json, error_json, created_at, updated_at
156
+ ) VALUES (?, ?, 'running', 0, NULL, ?, NULL, ?, ?, NULL, NULL, ?, ?)
157
157
  `).run(runId, flowName, version, stringify(shared), stringify(params), now, now);
158
158
  }
159
159
  saveCheckpoint(entry) {
160
160
  const now = new Date().toISOString();
161
161
  const write = this.db.transaction(() => {
162
- this.db.prepare(`
163
- INSERT INTO qflow_checkpoints (
164
- run_id, step, node_index, node_class, action, next_node_index, flow_version,
165
- shared_json, params_json, exec_res_json, created_at
166
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
167
- ON CONFLICT(run_id, step) DO UPDATE SET
168
- node_index = excluded.node_index,
169
- node_class = excluded.node_class,
170
- action = excluded.action,
171
- next_node_index = excluded.next_node_index,
172
- flow_version = excluded.flow_version,
173
- shared_json = excluded.shared_json,
174
- params_json = excluded.params_json,
175
- exec_res_json = excluded.exec_res_json,
176
- created_at = excluded.created_at
162
+ this.db.prepare(`
163
+ INSERT INTO qflow_checkpoints (
164
+ run_id, step, node_index, node_class, action, next_node_index, flow_version,
165
+ shared_json, params_json, exec_res_json, created_at
166
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
167
+ ON CONFLICT(run_id, step) DO UPDATE SET
168
+ node_index = excluded.node_index,
169
+ node_class = excluded.node_class,
170
+ action = excluded.action,
171
+ next_node_index = excluded.next_node_index,
172
+ flow_version = excluded.flow_version,
173
+ shared_json = excluded.shared_json,
174
+ params_json = excluded.params_json,
175
+ exec_res_json = excluded.exec_res_json,
176
+ created_at = excluded.created_at
177
177
  `).run(entry.runId, entry.step, entry.nodeIndex, entry.nodeClass,
178
178
  // Actions are normally action names, but standalone eval/dataflow nodes
179
179
  // return their exec result. Persist those as JSON instead of handing an
@@ -181,29 +181,29 @@ export class SQLiteCheckpointer {
181
181
  typeof entry.action === 'object' && entry.action !== null
182
182
  ? stringify(entry.action)
183
183
  : entry.action ?? null, entry.nextNodeIndex, entry.flowVersion ?? null, stringify(entry.shared), stringify(entry.params), stringify(entry.execRes), now);
184
- this.db.prepare(`
185
- INSERT INTO qflow_runs (
186
- run_id, flow_name, status, step, cursor_node_index,
187
- shared_json, params_json, result_json, error_json, created_at, updated_at
188
- ) VALUES (?, ?, 'running', ?, ?, ?, ?, NULL, NULL, ?, ?)
189
- ON CONFLICT(run_id) DO UPDATE SET
190
- status = 'running',
191
- step = excluded.step,
192
- cursor_node_index = excluded.cursor_node_index,
193
- shared_json = excluded.shared_json,
194
- params_json = excluded.params_json,
195
- result_json = NULL,
196
- error_json = NULL,
197
- updated_at = excluded.updated_at
184
+ this.db.prepare(`
185
+ INSERT INTO qflow_runs (
186
+ run_id, flow_name, status, step, cursor_node_index,
187
+ shared_json, params_json, result_json, error_json, created_at, updated_at
188
+ ) VALUES (?, ?, 'running', ?, ?, ?, ?, NULL, NULL, ?, ?)
189
+ ON CONFLICT(run_id) DO UPDATE SET
190
+ status = 'running',
191
+ step = excluded.step,
192
+ cursor_node_index = excluded.cursor_node_index,
193
+ shared_json = excluded.shared_json,
194
+ params_json = excluded.params_json,
195
+ result_json = NULL,
196
+ error_json = NULL,
197
+ updated_at = excluded.updated_at
198
198
  `).run(entry.runId, entry.flowName, entry.step, entry.nextNodeIndex, stringify(entry.shared), stringify(entry.params), now, now);
199
199
  });
200
200
  write();
201
201
  }
202
202
  updateRunStatus(runId, status, { step, shared, result = null, error = null } = {}) {
203
- this.db.prepare(`
204
- UPDATE qflow_runs
205
- SET status = ?, step = ?, shared_json = ?, result_json = ?, error_json = ?, updated_at = ?
206
- WHERE run_id = ?
203
+ this.db.prepare(`
204
+ UPDATE qflow_runs
205
+ SET status = ?, step = ?, shared_json = ?, result_json = ?, error_json = ?, updated_at = ?
206
+ WHERE run_id = ?
207
207
  `).run(status, step ?? 0, stringify(shared), stringify(result), error ? stringify({ message: error.message, stack: error.stack }) : null, new Date().toISOString(), runId);
208
208
  }
209
209
  loadRun(runId) {
@@ -232,11 +232,11 @@ export class SQLiteCheckpointer {
232
232
  }
233
233
  /** Runs suspended by SchedulePendingError, ordered by due time. */
234
234
  listScheduledRuns({ before = Infinity } = {}) {
235
- return this.db.prepare(`
236
- SELECT run_id, flow_name, flow_version, due_at, step
237
- FROM qflow_runs
238
- WHERE status = 'scheduled' AND due_at IS NOT NULL AND due_at <= ?
239
- ORDER BY due_at
235
+ return this.db.prepare(`
236
+ SELECT run_id, flow_name, flow_version, due_at, step
237
+ FROM qflow_runs
238
+ WHERE status = 'scheduled' AND due_at IS NOT NULL AND due_at <= ?
239
+ ORDER BY due_at
240
240
  `).all(before).map(row => ({
241
241
  runId: row.run_id,
242
242
  flowName: row.flow_name,
@@ -262,8 +262,8 @@ export class SQLiteCheckpointer {
262
262
  return version;
263
263
  }
264
264
  listCheckpoints(runId) {
265
- return this.db.prepare(`
266
- SELECT * FROM qflow_checkpoints WHERE run_id = ? ORDER BY step
265
+ return this.db.prepare(`
266
+ SELECT * FROM qflow_checkpoints WHERE run_id = ? ORDER BY step
267
267
  `).all(runId).map(row => ({
268
268
  runId: row.run_id,
269
269
  step: row.step,
@@ -286,16 +286,16 @@ export class SQLiteCheckpointer {
286
286
  if (existing)
287
287
  return existing;
288
288
  const now = new Date().toISOString();
289
- this.db.prepare(`
290
- INSERT INTO qflow_approvals (
291
- run_id, approval_id, prompt, status, decision_json, metadata_json, created_at, updated_at
292
- ) VALUES (?, ?, ?, 'pending', NULL, ?, ?, ?)
289
+ this.db.prepare(`
290
+ INSERT INTO qflow_approvals (
291
+ run_id, approval_id, prompt, status, decision_json, metadata_json, created_at, updated_at
292
+ ) VALUES (?, ?, ?, 'pending', NULL, ?, ?, ?)
293
293
  `).run(runId, approvalId, prompt ?? null, stringify(metadata), now, now);
294
294
  return this.getApproval(runId, approvalId);
295
295
  }
296
296
  getApproval(runId, approvalId) {
297
- const row = this.db.prepare(`
298
- SELECT * FROM qflow_approvals WHERE run_id = ? AND approval_id = ?
297
+ const row = this.db.prepare(`
298
+ SELECT * FROM qflow_approvals WHERE run_id = ? AND approval_id = ?
299
299
  `).get(runId, approvalId);
300
300
  return row ? this.#approvalRecord(row) : null;
301
301
  }
@@ -332,25 +332,25 @@ export class SQLiteCheckpointer {
332
332
  approve(runId, decision = {}, approvalId = null) {
333
333
  const record = this.#resolveApproval(runId, approvalId);
334
334
  const value = { ...(decision ?? {}), approved: decision?.approved !== false };
335
- this.db.prepare(`
336
- UPDATE qflow_approvals SET status = 'approved', decision_json = ?, updated_at = ?
337
- WHERE run_id = ? AND approval_id = ?
335
+ this.db.prepare(`
336
+ UPDATE qflow_approvals SET status = 'approved', decision_json = ?, updated_at = ?
337
+ WHERE run_id = ? AND approval_id = ?
338
338
  `).run(stringify(value), new Date().toISOString(), runId, record.approvalId);
339
339
  return this.getApproval(runId, record.approvalId);
340
340
  }
341
341
  reject(runId, decision = {}, approvalId = null) {
342
342
  const record = this.#resolveApproval(runId, approvalId);
343
343
  const value = { ...(decision ?? {}), approved: false };
344
- this.db.prepare(`
345
- UPDATE qflow_approvals SET status = 'rejected', decision_json = ?, updated_at = ?
346
- WHERE run_id = ? AND approval_id = ?
344
+ this.db.prepare(`
345
+ UPDATE qflow_approvals SET status = 'rejected', decision_json = ?, updated_at = ?
346
+ WHERE run_id = ? AND approval_id = ?
347
347
  `).run(stringify(value), new Date().toISOString(), runId, record.approvalId);
348
348
  return this.getApproval(runId, record.approvalId);
349
349
  }
350
350
  // --- Deterministic LLM response cache ---------------------------------------
351
351
  cacheGet(namespace, key) {
352
- const row = this.db.prepare(`
353
- SELECT value_json, expires_at FROM qflow_cache WHERE namespace = ? AND cache_key = ?
352
+ const row = this.db.prepare(`
353
+ SELECT value_json, expires_at FROM qflow_cache WHERE namespace = ? AND cache_key = ?
354
354
  `).get(namespace, key);
355
355
  if (!row)
356
356
  return null;
@@ -362,13 +362,13 @@ export class SQLiteCheckpointer {
362
362
  }
363
363
  cacheSet(namespace, key, value, ttlMs = null) {
364
364
  const expiresAt = ttlMs == null || ttlMs === Infinity ? null : Date.now() + ttlMs;
365
- this.db.prepare(`
366
- INSERT INTO qflow_cache (namespace, cache_key, value_json, expires_at, created_at)
367
- VALUES (?, ?, ?, ?, ?)
368
- ON CONFLICT(namespace, cache_key) DO UPDATE SET
369
- value_json = excluded.value_json,
370
- expires_at = excluded.expires_at,
371
- created_at = excluded.created_at
365
+ this.db.prepare(`
366
+ INSERT INTO qflow_cache (namespace, cache_key, value_json, expires_at, created_at)
367
+ VALUES (?, ?, ?, ?, ?)
368
+ ON CONFLICT(namespace, cache_key) DO UPDATE SET
369
+ value_json = excluded.value_json,
370
+ expires_at = excluded.expires_at,
371
+ created_at = excluded.created_at
372
372
  `).run(namespace, key, stringify(value), expiresAt, new Date().toISOString());
373
373
  return key;
374
374
  }
@@ -380,8 +380,8 @@ export class SQLiteCheckpointer {
380
380
  return result.changes;
381
381
  }
382
382
  loadSideEffect(runId, operationId) {
383
- const row = this.db.prepare(`
384
- SELECT * FROM qflow_side_effects WHERE run_id = ? AND operation_id = ?
383
+ const row = this.db.prepare(`
384
+ SELECT * FROM qflow_side_effects WHERE run_id = ? AND operation_id = ?
385
385
  `).get(runId, operationId);
386
386
  if (!row)
387
387
  return null;
@@ -434,11 +434,11 @@ export class SQLiteCheckpointer {
434
434
  if (!current) {
435
435
  // INSERT OR IGNORE: a concurrent worker wins the row and we must not
436
436
  // reset its reservation (which is what the old upsert did).
437
- const reservation = this.db.prepare(`
438
- INSERT OR IGNORE INTO qflow_side_effects (
439
- run_id, operation_id, kind, status, result_json, error_json,
440
- claimed_by, lease_expires_at, created_at, updated_at
441
- ) VALUES (?, ?, ?, 'pending', NULL, NULL, ?, ?, ?, ?)
437
+ const reservation = this.db.prepare(`
438
+ INSERT OR IGNORE INTO qflow_side_effects (
439
+ run_id, operation_id, kind, status, result_json, error_json,
440
+ claimed_by, lease_expires_at, created_at, updated_at
441
+ ) VALUES (?, ?, ?, 'pending', NULL, NULL, ?, ?, ?, ?)
442
442
  `).run(runId, operationId, kind, workerId, leaseExpiresAt, now, now);
443
443
  reserved = reservation.changes > 0;
444
444
  continue;
@@ -447,10 +447,10 @@ export class SQLiteCheckpointer {
447
447
  if (outcome)
448
448
  return outcome;
449
449
  // Only reached for failed + retry: take ownership of the failed row.
450
- const claimed = this.db.prepare(`
451
- UPDATE qflow_side_effects
452
- SET status = 'pending', claimed_by = ?, lease_expires_at = ?, error_json = NULL, updated_at = ?
453
- WHERE run_id = ? AND operation_id = ? AND status = 'failed'
450
+ const claimed = this.db.prepare(`
451
+ UPDATE qflow_side_effects
452
+ SET status = 'pending', claimed_by = ?, lease_expires_at = ?, error_json = NULL, updated_at = ?
453
+ WHERE run_id = ? AND operation_id = ? AND status = 'failed'
454
454
  `).run(workerId, leaseExpiresAt, now, runId, operationId);
455
455
  reserved = claimed.changes > 0;
456
456
  }
@@ -458,37 +458,37 @@ export class SQLiteCheckpointer {
458
458
  throw new SideEffectUncertainError(operationId);
459
459
  try {
460
460
  const result = await execute();
461
- this.db.prepare(`
462
- UPDATE qflow_side_effects
463
- SET status = 'completed', result_json = ?, error_json = NULL,
464
- claimed_by = NULL, lease_expires_at = NULL, updated_at = ?
465
- WHERE run_id = ? AND operation_id = ?
461
+ this.db.prepare(`
462
+ UPDATE qflow_side_effects
463
+ SET status = 'completed', result_json = ?, error_json = NULL,
464
+ claimed_by = NULL, lease_expires_at = NULL, updated_at = ?
465
+ WHERE run_id = ? AND operation_id = ?
466
466
  `).run(stringify(result), new Date().toISOString(), runId, operationId);
467
467
  return { result, replayed: false, operationId, status: 'completed' };
468
468
  }
469
469
  catch (error) {
470
- this.db.prepare(`
471
- UPDATE qflow_side_effects
472
- SET status = 'failed', result_json = NULL, error_json = ?,
473
- claimed_by = NULL, lease_expires_at = NULL, updated_at = ?
474
- WHERE run_id = ? AND operation_id = ?
470
+ this.db.prepare(`
471
+ UPDATE qflow_side_effects
472
+ SET status = 'failed', result_json = NULL, error_json = ?,
473
+ claimed_by = NULL, lease_expires_at = NULL, updated_at = ?
474
+ WHERE run_id = ? AND operation_id = ?
475
475
  `).run(stringify({ message: error.message, stack: error.stack }), new Date().toISOString(), runId, operationId);
476
476
  throw error;
477
477
  }
478
478
  }
479
479
  /** Release a dead worker's claim so an explicit retry can take over. */
480
480
  failSideEffect(runId, operationId, error = { message: 'Released by operator' }) {
481
- this.db.prepare(`
482
- UPDATE qflow_side_effects
483
- SET status = 'failed', error_json = ?, claimed_by = NULL, lease_expires_at = NULL, updated_at = ?
484
- WHERE run_id = ? AND operation_id = ?
481
+ this.db.prepare(`
482
+ UPDATE qflow_side_effects
483
+ SET status = 'failed', error_json = ?, claimed_by = NULL, lease_expires_at = NULL, updated_at = ?
484
+ WHERE run_id = ? AND operation_id = ?
485
485
  `).run(stringify(error), new Date().toISOString(), runId, operationId);
486
486
  return this.loadSideEffect(runId, operationId);
487
487
  }
488
488
  listSideEffects(runId) {
489
- return this.db.prepare(`
490
- SELECT run_id, operation_id, kind, status, claimed_by, lease_expires_at, created_at, updated_at
491
- FROM qflow_side_effects WHERE run_id = ? ORDER BY created_at
489
+ return this.db.prepare(`
490
+ SELECT run_id, operation_id, kind, status, claimed_by, lease_expires_at, created_at, updated_at
491
+ FROM qflow_side_effects WHERE run_id = ? ORDER BY created_at
492
492
  `).all(runId).map(row => ({
493
493
  runId: row.run_id,
494
494
  operationId: row.operation_id,
@@ -111,7 +111,7 @@ export class MCPClientNode extends AsyncNode {
111
111
  await send('initialize', {
112
112
  protocolVersion: '2024-11-05',
113
113
  capabilities: {},
114
- clientInfo: { name: 'qflow', version: '2.0.0-canary' },
114
+ clientInfo: { name: 'qflow', version: '2.0.0' },
115
115
  });
116
116
  await notify('notifications/initialized', {});
117
117
  const result = await send('tools/call', { name: tool, arguments: toolArguments });
@@ -21,7 +21,7 @@ function toMCPTool(definition) {
21
21
  */
22
22
  export class QFlowMCPServer {
23
23
  constructor(options = {}) {
24
- const { name = 'qflow', version = '2.0.0-canary', toolClasses, toolRegistry } = options;
24
+ const { name = 'qflow', version = '2.0.0', toolClasses, toolRegistry } = options;
25
25
  this.name = name;
26
26
  this.version = version;
27
27
  this.toolRegistry = toolRegistry ?? null;
package/dist/memory.js CHANGED
@@ -79,14 +79,14 @@ export class SQLiteMemoryStore extends MemoryStore {
79
79
  super();
80
80
  this.filename = filename;
81
81
  this.db = new Database(filename);
82
- this.db.exec(`
83
- CREATE TABLE IF NOT EXISTS qflow_memories (
84
- id TEXT PRIMARY KEY,
85
- text TEXT NOT NULL,
86
- tags_json TEXT NOT NULL,
87
- metadata_json TEXT NOT NULL,
88
- created_at TEXT NOT NULL
89
- )
82
+ this.db.exec(`
83
+ CREATE TABLE IF NOT EXISTS qflow_memories (
84
+ id TEXT PRIMARY KEY,
85
+ text TEXT NOT NULL,
86
+ tags_json TEXT NOT NULL,
87
+ metadata_json TEXT NOT NULL,
88
+ created_at TEXT NOT NULL
89
+ )
90
90
  `);
91
91
  }
92
92
  #record(row) {
@@ -110,12 +110,12 @@ export class SQLiteMemoryStore extends MemoryStore {
110
110
  metadata: metadata ?? {},
111
111
  createdAt: new Date().toISOString(),
112
112
  };
113
- this.db.prepare(`
114
- INSERT INTO qflow_memories (id, text, tags_json, metadata_json, created_at)
115
- VALUES (?, ?, ?, ?, ?)
116
- ON CONFLICT(id) DO UPDATE SET
117
- text = excluded.text, tags_json = excluded.tags_json,
118
- metadata_json = excluded.metadata_json, created_at = excluded.created_at
113
+ this.db.prepare(`
114
+ INSERT INTO qflow_memories (id, text, tags_json, metadata_json, created_at)
115
+ VALUES (?, ?, ?, ?, ?)
116
+ ON CONFLICT(id) DO UPDATE SET
117
+ text = excluded.text, tags_json = excluded.tags_json,
118
+ metadata_json = excluded.metadata_json, created_at = excluded.created_at
119
119
  `).run(record.id, record.text, JSON.stringify(record.tags), JSON.stringify(record.metadata), record.createdAt);
120
120
  return record;
121
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fractal-solutions/qflow",
3
- "version": "2.0.0-canary.4",
3
+ "version": "2.0.0",
4
4
  "description": "A lightweight and flexible JavaScript library for creating and managing workflows and agents.",
5
5
  "type": "module",
6
6
  "main": "dist/qflow.js",