@fractal-solutions/qflow 1.0.40 → 1.0.42

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.
@@ -244,7 +244,7 @@ When the user explicitly indicates they are done, use the 'finish' tool. Do not
244
244
 
245
245
  **IMPORTANT:** If you have a plan that requires action, you MUST include at least one tool call. An empty 'tool_calls' array means no action.
246
246
  If new instructions are given after a finish proposal, treat them as your updated goal and update your memory.
247
- Tell user how far you've gone using system notifications and KEEP THE USER INVOLVED using interactive input (or user input if interactive input not available).
247
+ Tell user how far you've gone using system notifications and KEEP THE USER INVOLVED using interactive input (or user input if interactive input not available) and OFTEN CHECK YOUR MEMORY to ensure alignmemt.
248
248
 
249
249
  Begin!`;
250
250
  }
@@ -117,6 +117,11 @@ export function getToolDefinitions(): ({
117
117
  branch?: undefined;
118
118
  remote?: undefined;
119
119
  output?: undefined;
120
+ adapter?: undefined;
121
+ connection?: undefined;
122
+ table?: undefined;
123
+ where?: undefined;
124
+ operations?: undefined;
120
125
  };
121
126
  required: string[];
122
127
  };
@@ -249,6 +254,11 @@ export function getToolDefinitions(): ({
249
254
  branch?: undefined;
250
255
  remote?: undefined;
251
256
  output?: undefined;
257
+ adapter?: undefined;
258
+ connection?: undefined;
259
+ table?: undefined;
260
+ where?: undefined;
261
+ operations?: undefined;
252
262
  };
253
263
  required: string[];
254
264
  };
@@ -362,6 +372,11 @@ export function getToolDefinitions(): ({
362
372
  branch?: undefined;
363
373
  remote?: undefined;
364
374
  output?: undefined;
375
+ adapter?: undefined;
376
+ connection?: undefined;
377
+ table?: undefined;
378
+ where?: undefined;
379
+ operations?: undefined;
365
380
  };
366
381
  required: string[];
367
382
  };
@@ -472,6 +487,11 @@ export function getToolDefinitions(): ({
472
487
  branch?: undefined;
473
488
  remote?: undefined;
474
489
  output?: undefined;
490
+ adapter?: undefined;
491
+ connection?: undefined;
492
+ table?: undefined;
493
+ where?: undefined;
494
+ operations?: undefined;
475
495
  };
476
496
  required: string[];
477
497
  };
@@ -592,6 +612,11 @@ export function getToolDefinitions(): ({
592
612
  branch?: undefined;
593
613
  remote?: undefined;
594
614
  output?: undefined;
615
+ adapter?: undefined;
616
+ connection?: undefined;
617
+ table?: undefined;
618
+ where?: undefined;
619
+ operations?: undefined;
595
620
  };
596
621
  required: string[];
597
622
  };
@@ -699,6 +724,11 @@ export function getToolDefinitions(): ({
699
724
  branch?: undefined;
700
725
  remote?: undefined;
701
726
  output?: undefined;
727
+ adapter?: undefined;
728
+ connection?: undefined;
729
+ table?: undefined;
730
+ where?: undefined;
731
+ operations?: undefined;
702
732
  };
703
733
  required: string[];
704
734
  };
@@ -818,6 +848,11 @@ export function getToolDefinitions(): ({
818
848
  branch?: undefined;
819
849
  remote?: undefined;
820
850
  output?: undefined;
851
+ adapter?: undefined;
852
+ connection?: undefined;
853
+ table?: undefined;
854
+ where?: undefined;
855
+ operations?: undefined;
821
856
  };
822
857
  required: string[];
823
858
  };
@@ -931,6 +966,11 @@ export function getToolDefinitions(): ({
931
966
  branch?: undefined;
932
967
  remote?: undefined;
933
968
  output?: undefined;
969
+ adapter?: undefined;
970
+ connection?: undefined;
971
+ table?: undefined;
972
+ where?: undefined;
973
+ operations?: undefined;
934
974
  };
935
975
  required: string[];
936
976
  };
@@ -1054,6 +1094,11 @@ export function getToolDefinitions(): ({
1054
1094
  branch?: undefined;
1055
1095
  remote?: undefined;
1056
1096
  output?: undefined;
1097
+ adapter?: undefined;
1098
+ connection?: undefined;
1099
+ table?: undefined;
1100
+ where?: undefined;
1101
+ operations?: undefined;
1057
1102
  };
1058
1103
  required: string[];
1059
1104
  };
@@ -1182,6 +1227,11 @@ export function getToolDefinitions(): ({
1182
1227
  branch?: undefined;
1183
1228
  remote?: undefined;
1184
1229
  output?: undefined;
1230
+ adapter?: undefined;
1231
+ connection?: undefined;
1232
+ table?: undefined;
1233
+ where?: undefined;
1234
+ operations?: undefined;
1185
1235
  };
1186
1236
  required: string[];
1187
1237
  };
@@ -1298,6 +1348,11 @@ export function getToolDefinitions(): ({
1298
1348
  branch?: undefined;
1299
1349
  remote?: undefined;
1300
1350
  output?: undefined;
1351
+ adapter?: undefined;
1352
+ connection?: undefined;
1353
+ table?: undefined;
1354
+ where?: undefined;
1355
+ operations?: undefined;
1301
1356
  };
1302
1357
  required: string[];
1303
1358
  };
@@ -1405,6 +1460,11 @@ export function getToolDefinitions(): ({
1405
1460
  branch?: undefined;
1406
1461
  remote?: undefined;
1407
1462
  output?: undefined;
1463
+ adapter?: undefined;
1464
+ connection?: undefined;
1465
+ table?: undefined;
1466
+ where?: undefined;
1467
+ operations?: undefined;
1408
1468
  };
1409
1469
  required: string[];
1410
1470
  };
@@ -1525,6 +1585,11 @@ export function getToolDefinitions(): ({
1525
1585
  branch?: undefined;
1526
1586
  remote?: undefined;
1527
1587
  output?: undefined;
1588
+ adapter?: undefined;
1589
+ connection?: undefined;
1590
+ table?: undefined;
1591
+ where?: undefined;
1592
+ operations?: undefined;
1528
1593
  };
1529
1594
  required: string[];
1530
1595
  };
@@ -1647,6 +1712,11 @@ export function getToolDefinitions(): ({
1647
1712
  branch?: undefined;
1648
1713
  remote?: undefined;
1649
1714
  output?: undefined;
1715
+ adapter?: undefined;
1716
+ connection?: undefined;
1717
+ table?: undefined;
1718
+ where?: undefined;
1719
+ operations?: undefined;
1650
1720
  };
1651
1721
  required: string[];
1652
1722
  };
@@ -1767,6 +1837,11 @@ export function getToolDefinitions(): ({
1767
1837
  branch?: undefined;
1768
1838
  remote?: undefined;
1769
1839
  output?: undefined;
1840
+ adapter?: undefined;
1841
+ connection?: undefined;
1842
+ table?: undefined;
1843
+ where?: undefined;
1844
+ operations?: undefined;
1770
1845
  };
1771
1846
  required: string[];
1772
1847
  };
@@ -1886,6 +1961,11 @@ export function getToolDefinitions(): ({
1886
1961
  branch?: undefined;
1887
1962
  remote?: undefined;
1888
1963
  output?: undefined;
1964
+ adapter?: undefined;
1965
+ connection?: undefined;
1966
+ table?: undefined;
1967
+ where?: undefined;
1968
+ operations?: undefined;
1889
1969
  };
1890
1970
  required: string[];
1891
1971
  };
@@ -2004,6 +2084,11 @@ export function getToolDefinitions(): ({
2004
2084
  branch?: undefined;
2005
2085
  remote?: undefined;
2006
2086
  output?: undefined;
2087
+ adapter?: undefined;
2088
+ connection?: undefined;
2089
+ table?: undefined;
2090
+ where?: undefined;
2091
+ operations?: undefined;
2007
2092
  };
2008
2093
  required: string[];
2009
2094
  };
@@ -2136,6 +2221,11 @@ export function getToolDefinitions(): ({
2136
2221
  branch?: undefined;
2137
2222
  remote?: undefined;
2138
2223
  output?: undefined;
2224
+ adapter?: undefined;
2225
+ connection?: undefined;
2226
+ table?: undefined;
2227
+ where?: undefined;
2228
+ operations?: undefined;
2139
2229
  };
2140
2230
  required: string[];
2141
2231
  };
@@ -2268,6 +2358,11 @@ export function getToolDefinitions(): ({
2268
2358
  branch?: undefined;
2269
2359
  remote?: undefined;
2270
2360
  output?: undefined;
2361
+ adapter?: undefined;
2362
+ connection?: undefined;
2363
+ table?: undefined;
2364
+ where?: undefined;
2365
+ operations?: undefined;
2271
2366
  };
2272
2367
  required: string[];
2273
2368
  };
@@ -2385,6 +2480,11 @@ export function getToolDefinitions(): ({
2385
2480
  branch?: undefined;
2386
2481
  remote?: undefined;
2387
2482
  output?: undefined;
2483
+ adapter?: undefined;
2484
+ connection?: undefined;
2485
+ table?: undefined;
2486
+ where?: undefined;
2487
+ operations?: undefined;
2388
2488
  };
2389
2489
  required: string[];
2390
2490
  };
@@ -2520,6 +2620,11 @@ export function getToolDefinitions(): ({
2520
2620
  branch?: undefined;
2521
2621
  remote?: undefined;
2522
2622
  output?: undefined;
2623
+ adapter?: undefined;
2624
+ connection?: undefined;
2625
+ table?: undefined;
2626
+ where?: undefined;
2627
+ operations?: undefined;
2523
2628
  };
2524
2629
  required: string[];
2525
2630
  };
@@ -2639,6 +2744,11 @@ export function getToolDefinitions(): ({
2639
2744
  branch?: undefined;
2640
2745
  remote?: undefined;
2641
2746
  output?: undefined;
2747
+ adapter?: undefined;
2748
+ connection?: undefined;
2749
+ table?: undefined;
2750
+ where?: undefined;
2751
+ operations?: undefined;
2642
2752
  };
2643
2753
  required: string[];
2644
2754
  };
@@ -2746,6 +2856,11 @@ export function getToolDefinitions(): ({
2746
2856
  branch?: undefined;
2747
2857
  remote?: undefined;
2748
2858
  output?: undefined;
2859
+ adapter?: undefined;
2860
+ connection?: undefined;
2861
+ table?: undefined;
2862
+ where?: undefined;
2863
+ operations?: undefined;
2749
2864
  };
2750
2865
  required: string[];
2751
2866
  };
@@ -2859,6 +2974,11 @@ export function getToolDefinitions(): ({
2859
2974
  branch?: undefined;
2860
2975
  remote?: undefined;
2861
2976
  output?: undefined;
2977
+ adapter?: undefined;
2978
+ connection?: undefined;
2979
+ table?: undefined;
2980
+ where?: undefined;
2981
+ operations?: undefined;
2862
2982
  };
2863
2983
  required: string[];
2864
2984
  };
@@ -2966,6 +3086,11 @@ export function getToolDefinitions(): ({
2966
3086
  branch?: undefined;
2967
3087
  remote?: undefined;
2968
3088
  output?: undefined;
3089
+ adapter?: undefined;
3090
+ connection?: undefined;
3091
+ table?: undefined;
3092
+ where?: undefined;
3093
+ operations?: undefined;
2969
3094
  };
2970
3095
  required: string[];
2971
3096
  };
@@ -3073,6 +3198,11 @@ export function getToolDefinitions(): ({
3073
3198
  branch?: undefined;
3074
3199
  remote?: undefined;
3075
3200
  output?: undefined;
3201
+ adapter?: undefined;
3202
+ connection?: undefined;
3203
+ table?: undefined;
3204
+ where?: undefined;
3205
+ operations?: undefined;
3076
3206
  };
3077
3207
  required: string[];
3078
3208
  };
@@ -3183,6 +3313,11 @@ export function getToolDefinitions(): ({
3183
3313
  branch?: undefined;
3184
3314
  remote?: undefined;
3185
3315
  output?: undefined;
3316
+ adapter?: undefined;
3317
+ connection?: undefined;
3318
+ table?: undefined;
3319
+ where?: undefined;
3320
+ operations?: undefined;
3186
3321
  };
3187
3322
  required: string[];
3188
3323
  };
@@ -3290,6 +3425,11 @@ export function getToolDefinitions(): ({
3290
3425
  branch?: undefined;
3291
3426
  remote?: undefined;
3292
3427
  output?: undefined;
3428
+ adapter?: undefined;
3429
+ connection?: undefined;
3430
+ table?: undefined;
3431
+ where?: undefined;
3432
+ operations?: undefined;
3293
3433
  };
3294
3434
  required: string[];
3295
3435
  };
@@ -3430,6 +3570,11 @@ export function getToolDefinitions(): ({
3430
3570
  branch?: undefined;
3431
3571
  remote?: undefined;
3432
3572
  output?: undefined;
3573
+ adapter?: undefined;
3574
+ connection?: undefined;
3575
+ table?: undefined;
3576
+ where?: undefined;
3577
+ operations?: undefined;
3433
3578
  };
3434
3579
  required: string[];
3435
3580
  };
@@ -3537,6 +3682,11 @@ export function getToolDefinitions(): ({
3537
3682
  branch?: undefined;
3538
3683
  remote?: undefined;
3539
3684
  output?: undefined;
3685
+ adapter?: undefined;
3686
+ connection?: undefined;
3687
+ table?: undefined;
3688
+ where?: undefined;
3689
+ operations?: undefined;
3540
3690
  };
3541
3691
  required: string[];
3542
3692
  };
@@ -3650,6 +3800,11 @@ export function getToolDefinitions(): ({
3650
3800
  branch?: undefined;
3651
3801
  remote?: undefined;
3652
3802
  output?: undefined;
3803
+ adapter?: undefined;
3804
+ connection?: undefined;
3805
+ table?: undefined;
3806
+ where?: undefined;
3807
+ operations?: undefined;
3653
3808
  };
3654
3809
  required: string[];
3655
3810
  };
@@ -3763,6 +3918,11 @@ export function getToolDefinitions(): ({
3763
3918
  branch?: undefined;
3764
3919
  remote?: undefined;
3765
3920
  output?: undefined;
3921
+ adapter?: undefined;
3922
+ connection?: undefined;
3923
+ table?: undefined;
3924
+ where?: undefined;
3925
+ operations?: undefined;
3766
3926
  };
3767
3927
  required: string[];
3768
3928
  };
@@ -3873,6 +4033,11 @@ export function getToolDefinitions(): ({
3873
4033
  branch?: undefined;
3874
4034
  remote?: undefined;
3875
4035
  output?: undefined;
4036
+ adapter?: undefined;
4037
+ connection?: undefined;
4038
+ table?: undefined;
4039
+ where?: undefined;
4040
+ operations?: undefined;
3876
4041
  };
3877
4042
  required: string[];
3878
4043
  };
@@ -3983,6 +4148,11 @@ export function getToolDefinitions(): ({
3983
4148
  branch?: undefined;
3984
4149
  remote?: undefined;
3985
4150
  output?: undefined;
4151
+ adapter?: undefined;
4152
+ connection?: undefined;
4153
+ table?: undefined;
4154
+ where?: undefined;
4155
+ operations?: undefined;
3986
4156
  };
3987
4157
  required: string[];
3988
4158
  };
@@ -4103,6 +4273,11 @@ export function getToolDefinitions(): ({
4103
4273
  branch?: undefined;
4104
4274
  remote?: undefined;
4105
4275
  output?: undefined;
4276
+ adapter?: undefined;
4277
+ connection?: undefined;
4278
+ table?: undefined;
4279
+ where?: undefined;
4280
+ operations?: undefined;
4106
4281
  };
4107
4282
  required: string[];
4108
4283
  };
@@ -4232,6 +4407,11 @@ export function getToolDefinitions(): ({
4232
4407
  shared?: undefined;
4233
4408
  items?: undefined;
4234
4409
  output?: undefined;
4410
+ adapter?: undefined;
4411
+ connection?: undefined;
4412
+ table?: undefined;
4413
+ where?: undefined;
4414
+ operations?: undefined;
4235
4415
  };
4236
4416
  required: string[];
4237
4417
  };
@@ -4346,6 +4526,11 @@ export function getToolDefinitions(): ({
4346
4526
  branch?: undefined;
4347
4527
  remote?: undefined;
4348
4528
  output?: undefined;
4529
+ adapter?: undefined;
4530
+ connection?: undefined;
4531
+ table?: undefined;
4532
+ where?: undefined;
4533
+ operations?: undefined;
4349
4534
  };
4350
4535
  required: string[];
4351
4536
  };
@@ -4453,6 +4638,146 @@ export function getToolDefinitions(): ({
4453
4638
  files?: undefined;
4454
4639
  branch?: undefined;
4455
4640
  remote?: undefined;
4641
+ adapter?: undefined;
4642
+ connection?: undefined;
4643
+ table?: undefined;
4644
+ where?: undefined;
4645
+ operations?: undefined;
4646
+ };
4647
+ required: string[];
4648
+ };
4649
+ } | {
4650
+ name: string;
4651
+ description: string;
4652
+ parameters: {
4653
+ type: string;
4654
+ properties: {
4655
+ adapter: {
4656
+ type: string;
4657
+ enum: string[];
4658
+ description: string;
4659
+ };
4660
+ connection: {
4661
+ type: string;
4662
+ description: string;
4663
+ };
4664
+ action: {
4665
+ type: string;
4666
+ enum: string[];
4667
+ description: string;
4668
+ };
4669
+ query: {
4670
+ type: string;
4671
+ description: string;
4672
+ };
4673
+ table: {
4674
+ type: string;
4675
+ description: string;
4676
+ };
4677
+ data: {
4678
+ type: string;
4679
+ description: string;
4680
+ };
4681
+ where: {
4682
+ type: string;
4683
+ description: string;
4684
+ };
4685
+ operations: {
4686
+ type: string;
4687
+ description: string;
4688
+ };
4689
+ prompt?: undefined;
4690
+ model?: undefined;
4691
+ hfToken?: undefined;
4692
+ temperature?: undefined;
4693
+ max_new_tokens?: undefined;
4694
+ baseUrl?: undefined;
4695
+ content?: undefined;
4696
+ id?: undefined;
4697
+ metadata?: undefined;
4698
+ memoryPath?: undefined;
4699
+ embeddingModel?: undefined;
4700
+ embeddingBaseUrl?: undefined;
4701
+ topK?: undefined;
4702
+ text?: undefined;
4703
+ input?: undefined;
4704
+ transformFunction?: undefined;
4705
+ apiKey?: undefined;
4706
+ siteUrl?: undefined;
4707
+ siteTitle?: undefined;
4708
+ type?: undefined;
4709
+ selector?: undefined;
4710
+ jsonPath?: undefined;
4711
+ regex?: undefined;
4712
+ group?: undefined;
4713
+ filePath?: undefined;
4714
+ outputDir?: undefined;
4715
+ pageRange?: undefined;
4716
+ password?: undefined;
4717
+ operation?: undefined;
4718
+ provider?: undefined;
4719
+ params?: undefined;
4720
+ imagePath?: undefined;
4721
+ portPath?: undefined;
4722
+ baudRate?: undefined;
4723
+ dataToWrite?: undefined;
4724
+ timeout?: undefined;
4725
+ port?: undefined;
4726
+ path?: undefined;
4727
+ flow?: undefined;
4728
+ sharedSecret?: undefined;
4729
+ responseStatus?: undefined;
4730
+ responseBody?: undefined;
4731
+ schedule?: undefined;
4732
+ flowParams?: undefined;
4733
+ imagePaths?: undefined;
4734
+ title?: undefined;
4735
+ description?: undefined;
4736
+ voice?: undefined;
4737
+ outputFilePath?: undefined;
4738
+ inputPath?: undefined;
4739
+ outputPath?: undefined;
4740
+ format?: undefined;
4741
+ startTime?: undefined;
4742
+ duration?: undefined;
4743
+ resolution?: undefined;
4744
+ frameTime?: undefined;
4745
+ ffmpegArgs?: undefined;
4746
+ host?: undefined;
4747
+ username?: undefined;
4748
+ privateKey?: undefined;
4749
+ passphrase?: undefined;
4750
+ command?: undefined;
4751
+ schema?: undefined;
4752
+ schemaPath?: undefined;
4753
+ sheetName?: undefined;
4754
+ headerRow?: undefined;
4755
+ range?: undefined;
4756
+ startRow?: undefined;
4757
+ numRows?: undefined;
4758
+ newSheetName?: undefined;
4759
+ formats?: undefined;
4760
+ code?: undefined;
4761
+ args?: undefined;
4762
+ requireConfirmation?: undefined;
4763
+ cseId?: undefined;
4764
+ directoryPath?: undefined;
4765
+ url?: undefined;
4766
+ method?: undefined;
4767
+ headers?: undefined;
4768
+ body?: undefined;
4769
+ auth?: undefined;
4770
+ defaultValue?: undefined;
4771
+ message?: undefined;
4772
+ icon?: undefined;
4773
+ shared?: undefined;
4774
+ items?: undefined;
4775
+ repoPath?: undefined;
4776
+ remoteUrl?: undefined;
4777
+ files?: undefined;
4778
+ branch?: undefined;
4779
+ remote?: undefined;
4780
+ output?: undefined;
4456
4781
  };
4457
4782
  required: string[];
4458
4783
  };
@@ -1058,6 +1058,50 @@ export function getToolDefinitions() {
1058
1058
  },
1059
1059
  required: ["output"]
1060
1060
  }
1061
+ },
1062
+ {
1063
+ name: "database",
1064
+ description: "Interacts with a database.",
1065
+ parameters: {
1066
+ type: "object",
1067
+ properties: {
1068
+ adapter: {
1069
+ type: "string",
1070
+ enum: ["sqlite", "postgres", "mysql"],
1071
+ description: "The database adapter to use."
1072
+ },
1073
+ connection: {
1074
+ type: "string",
1075
+ description: "The connection string for the database."
1076
+ },
1077
+ action: {
1078
+ type: "string",
1079
+ enum: ["query", "insert", "bulk_insert", "update", "delete", "transaction"],
1080
+ description: "The action to perform."
1081
+ },
1082
+ query: {
1083
+ type: "string",
1084
+ description: "The SQL query to execute (for the 'query' action)."
1085
+ },
1086
+ table: {
1087
+ type: "string",
1088
+ description: "The name of the table to operate on."
1089
+ },
1090
+ data: {
1091
+ type: "object",
1092
+ description: "The data to insert or update."
1093
+ },
1094
+ where: {
1095
+ type: "string",
1096
+ description: "The WHERE clause for 'update' and 'delete' actions."
1097
+ },
1098
+ operations: {
1099
+ type: "array",
1100
+ description: "An array of operations to execute within a transaction."
1101
+ }
1102
+ },
1103
+ required: ["adapter", "connection", "action"]
1104
+ }
1061
1105
  }
1062
1106
  ];
1063
1107
  }
@@ -0,0 +1,6 @@
1
+ export class DatabaseNode extends AsyncNode {
2
+ execAsync(prepRes: any, shared: any): Promise<any>;
3
+ postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
4
+ #private;
5
+ }
6
+ import { AsyncNode } from '../qflow.js';
@@ -0,0 +1,89 @@
1
+ import { AsyncNode } from '../qflow.js';
2
+ import { SQL } from 'bun';
3
+ import { Database as SQLiteDatabase } from 'bun:sqlite';
4
+ export class DatabaseNode extends AsyncNode {
5
+ #db = null;
6
+ async prepAsync(shared) {
7
+ const { connection, adapter } = this.params;
8
+ if (!shared.db_connections) {
9
+ shared.db_connections = {};
10
+ }
11
+ if (shared.db_connections[connection]) {
12
+ this.#db = shared.db_connections[connection];
13
+ }
14
+ else {
15
+ if (adapter === 'sqlite') {
16
+ this.#db = new SQLiteDatabase(connection);
17
+ }
18
+ else {
19
+ this.#db = new SQL(connection || process.env.DATABASE_URL);
20
+ }
21
+ shared.db_connections[connection] = this.#db;
22
+ }
23
+ }
24
+ async execAsync(prepRes, shared) {
25
+ const { action, query, table, data, where, operations } = this.params;
26
+ if (this.#db instanceof SQLiteDatabase) {
27
+ // bun:sqlite logic
28
+ switch (action) {
29
+ case 'query':
30
+ return this.#db.query(query).all();
31
+ case 'insert':
32
+ const keys = Object.keys(data).map(k => k.replace('$', '')).join(', ');
33
+ const values = Object.keys(data).map(k => k).join(', ');
34
+ const statement = this.#db.prepare(`INSERT INTO ${table} (${keys}) VALUES (${values})`);
35
+ return statement.run(data);
36
+ case 'bulk_insert':
37
+ const bulkKeys = Object.keys(data[0]).map(k => k.replace('$', '')).join(', ');
38
+ const bulkValues = Object.keys(data[0]).map(k => k).join(', ');
39
+ const bulkStatement = this.#db.prepare(`INSERT INTO ${table} (${bulkKeys}) VALUES (${bulkValues})`);
40
+ return this.#db.transaction(items => {
41
+ for (const item of items)
42
+ bulkStatement.run(item);
43
+ })(data);
44
+ case 'update':
45
+ const setClause = Object.keys(data).map(k => `${k.replace('$', '')} = ${k}`).join(', ');
46
+ const updateStatement = this.#db.prepare(`UPDATE ${table} SET ${setClause} WHERE ${where}`);
47
+ return updateStatement.run(data);
48
+ case 'delete':
49
+ const deleteStatement = this.#db.prepare(`DELETE FROM ${table} WHERE ${where}`);
50
+ return deleteStatement.run();
51
+ case 'transaction':
52
+ return this.#db.transaction(() => {
53
+ for (const op of operations) {
54
+ this.#db.run(op.query, op.params);
55
+ }
56
+ })();
57
+ default:
58
+ throw new Error(`Unsupported database action for sqlite: ${action}`);
59
+ }
60
+ }
61
+ else {
62
+ // bun:sql logic
63
+ switch (action) {
64
+ case 'query':
65
+ return this.#db.query(query);
66
+ case 'insert':
67
+ return this.#db.query `INSERT INTO ${this.#db(table)} ${this.#db(data)}`;
68
+ case 'bulk_insert':
69
+ return this.#db.query `INSERT INTO ${this.#db(table)} ${this.#db(data)}`;
70
+ case 'update':
71
+ return this.#db.query `UPDATE ${this.#db(table)} SET ${this.#db(data)} WHERE ${this.#db.unsafe(where)}`;
72
+ case 'delete':
73
+ return this.#db.query `DELETE FROM ${this.#db(table)} WHERE ${this.#db.unsafe(where)}`;
74
+ case 'transaction':
75
+ return this.#db.begin(async (tx) => {
76
+ for (const op of operations) {
77
+ await tx.query(op.query, op.params);
78
+ }
79
+ });
80
+ default:
81
+ throw new Error(`Unsupported database action for bun:sql: ${action}`);
82
+ }
83
+ }
84
+ }
85
+ async postAsync(shared, prepRes, execRes) {
86
+ shared.db_result = execRes;
87
+ return 'default';
88
+ }
89
+ }
@@ -36,3 +36,4 @@ export * from "../agent/agent.js";
36
36
  export * from "./subflow.js";
37
37
  export * from "./iterator.js";
38
38
  export * from "./openrouter_llm.js";
39
+ export * from "./database.js";
@@ -36,3 +36,4 @@ export * from '../agent/agent.js';
36
36
  export * from './subflow.js';
37
37
  export * from './iterator.js';
38
38
  export * from './openrouter_llm.js';
39
+ export * from './database.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fractal-solutions/qflow",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "A lightweight and flexible JavaScript library for creating and managing workflows and agents.",
5
5
  "main": "dist/qflow.js",
6
6
  "types": "dist/qflow.d.ts",