@yugenlab/vaayu 0.1.10 → 0.1.11
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/chunks/{agentic-tool-loop-2FZK72JO.js → agentic-tool-loop-O3NUV7KG.js} +1 -1
- package/chunks/{chunk-UZ6OIVEC.js → chunk-2OBLQJYJ.js} +1 -1
- package/chunks/{chunk-O4KV7TFP.js → chunk-3AYSJ7WB.js} +30 -18
- package/chunks/{chunk-U62ABYKD.js → chunk-67DXWEKG.js} +3 -3
- package/chunks/{chunk-6556EKOB.js → chunk-7AYYXHYZ.js} +25 -24
- package/chunks/{chunk-JGI4SDWS.js → chunk-7XV5ISV7.js} +7 -5
- package/chunks/{chunk-JAWZ7ANC.js → chunk-A3HOZBC5.js} +11 -7
- package/chunks/{chunk-VJHNE47S.js → chunk-D46QTN3G.js} +63 -82
- package/chunks/{chunk-PRXQW76U.js → chunk-EG37M4QL.js} +17 -6
- package/chunks/{chunk-77725AR7.js → chunk-F6RNEGFX.js} +82 -53
- package/chunks/{chunk-MJ74G5RB.js → chunk-G2QREGXK.js} +2 -2
- package/chunks/{chunk-AS3DJFY3.js → chunk-JZTFJE7M.js} +39 -39
- package/chunks/{chunk-OT4G2L46.js → chunk-LJUEMPLG.js} +202 -154
- package/chunks/{chunk-C76USAC5.js → chunk-QFGAB4XD.js} +13 -5
- package/chunks/{chunk-M7THR63C.js → chunk-QV4GPIPT.js} +74 -65
- package/chunks/{chunk-YJRXLRTE.js → chunk-V2ZIKDN4.js} +9 -8
- package/chunks/{chunk-AGK3A7R7.js → chunk-VCUJES75.js} +791 -677
- package/chunks/{chunk-N22M7D4P.js → chunk-W4PVGBUH.js} +86 -97
- package/chunks/{chunk-TND3MU4Z.js → chunk-Z576WVLG.js} +74 -66
- package/chunks/{chunk-HIYHTWFW.js → chunk-ZYY6N3SP.js} +90 -118
- package/chunks/{consolidation-indexer-VKQ6DNU3.js → consolidation-indexer-VIWOP6VO.js} +8 -8
- package/chunks/{day-consolidation-BH3QU2SZ.js → day-consolidation-HMHSXIOM.js} +4 -4
- package/chunks/{src-Y3TGMINC.js → dist-CY5NX2IK.js} +17 -17
- package/chunks/graphrag-T2QWNX57.js +14 -0
- package/chunks/{hierarchical-temporal-search-PVHVA3NZ.js → hierarchical-temporal-search-U6DG74IR.js} +2 -2
- package/chunks/hybrid-search-BYTXCOXP.js +20 -0
- package/chunks/{memory-store-A6WOWLWC.js → memory-store-LEERUQGL.js} +3 -3
- package/chunks/periodic-consolidation-D6SSKZ7H.js +11 -0
- package/chunks/{postgres-WLH3D5HG.js → postgres-7GZDDX77.js} +2 -2
- package/chunks/{recall-ZNL4DJ2L.js → recall-LNRQVATQ.js} +7 -7
- package/chunks/search-BIODUW2P.js +19 -0
- package/chunks/{session-store-3BRPGC6P.js → session-store-O3TS7DUY.js} +5 -5
- package/chunks/{sqlite-DHUQGPR5.js → sqlite-7BC4DJTN.js} +2 -2
- package/chunks/{vasana-engine-MU25OQ23.js → vasana-engine-BJFHJVGM.js} +4 -4
- package/gateway.js +31592 -24973
- package/package.json +1 -1
- package/pair-cli.js +1 -1
- package/chunks/graphrag-D7OXWAWD.js +0 -14
- package/chunks/hybrid-search-G2NAJKJ7.js +0 -20
- package/chunks/periodic-consolidation-LMYMNS4Q.js +0 -11
- package/chunks/search-35JMSGUT.js +0 -19
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DatabaseManager
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-67DXWEKG.js";
|
|
4
4
|
|
|
5
|
-
// ../chitragupta/packages/smriti/
|
|
5
|
+
// ../chitragupta/packages/smriti/dist/vasana-bocpd.js
|
|
6
6
|
var FNV_OFFSET = 2166136261;
|
|
7
7
|
var FNV_PRIME = 16777619;
|
|
8
8
|
function fnv1a(input) {
|
|
@@ -35,11 +35,14 @@ var HARD_CEILINGS = {
|
|
|
35
35
|
stabilityWindow: 100
|
|
36
36
|
};
|
|
37
37
|
function logsumexp(xs) {
|
|
38
|
-
if (xs.length === 0)
|
|
38
|
+
if (xs.length === 0)
|
|
39
|
+
return -Infinity;
|
|
39
40
|
const m = Math.max(...xs);
|
|
40
|
-
if (m === -Infinity)
|
|
41
|
+
if (m === -Infinity)
|
|
42
|
+
return -Infinity;
|
|
41
43
|
let s = 0;
|
|
42
|
-
for (let i = 0; i < xs.length; i++)
|
|
44
|
+
for (let i = 0; i < xs.length; i++)
|
|
45
|
+
s += Math.exp(xs[i] - m);
|
|
43
46
|
return m + Math.log(s);
|
|
44
47
|
}
|
|
45
48
|
function lgamma(z) {
|
|
@@ -54,10 +57,12 @@ function lgamma(z) {
|
|
|
54
57
|
9984369578019572e-21,
|
|
55
58
|
15056327351493116e-23
|
|
56
59
|
];
|
|
57
|
-
if (z < 0.5)
|
|
60
|
+
if (z < 0.5)
|
|
61
|
+
return Math.log(Math.PI / Math.sin(Math.PI * z)) - lgamma(1 - z);
|
|
58
62
|
z -= 1;
|
|
59
63
|
let x = c[0];
|
|
60
|
-
for (let i = 1; i < 9; i++)
|
|
64
|
+
for (let i = 1; i < 9; i++)
|
|
65
|
+
x += c[i] / (z + i);
|
|
61
66
|
const t = z + 7.5;
|
|
62
67
|
return 0.5 * Math.log(2 * Math.PI) + (z + 0.5) * Math.log(t) - t + Math.log(x);
|
|
63
68
|
}
|
|
@@ -98,7 +103,8 @@ function updateBOCPD(st, x, cfg) {
|
|
|
98
103
|
}
|
|
99
104
|
newLR[0] = logsumexp(cpTerms);
|
|
100
105
|
const logZ = logsumexp(newLR);
|
|
101
|
-
for (let i = 0; i <= n; i++)
|
|
106
|
+
for (let i = 0; i <= n; i++)
|
|
107
|
+
newLR[i] -= logZ;
|
|
102
108
|
const newS = new Array(n + 1);
|
|
103
109
|
newS[0] = {
|
|
104
110
|
mu: cfg.priorMu,
|
|
@@ -121,12 +127,14 @@ function updateBOCPD(st, x, cfg) {
|
|
|
121
127
|
const idx = newLR.map((lp, i) => ({ lp, i })).sort((a, b) => b.lp - a.lp);
|
|
122
128
|
const keep = new Set(idx.slice(0, cfg.maxRunLength).map((e) => e.i));
|
|
123
129
|
const pR = [], pS = [];
|
|
124
|
-
for (let i = 0; i <= n; i++)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
130
|
+
for (let i = 0; i <= n; i++)
|
|
131
|
+
if (keep.has(i)) {
|
|
132
|
+
pR.push(newLR[i]);
|
|
133
|
+
pS.push(newS[i]);
|
|
134
|
+
}
|
|
128
135
|
const norm = logsumexp(pR);
|
|
129
|
-
for (let i = 0; i < pR.length; i++)
|
|
136
|
+
for (let i = 0; i < pR.length; i++)
|
|
137
|
+
pR[i] -= norm;
|
|
130
138
|
st.logR = pR;
|
|
131
139
|
st.stats = pS;
|
|
132
140
|
} else {
|
|
@@ -135,7 +143,8 @@ function updateBOCPD(st, x, cfg) {
|
|
|
135
143
|
}
|
|
136
144
|
st.totalObs++;
|
|
137
145
|
const cpProb = st.logR.length > 0 ? Math.exp(st.logR[0]) : 0;
|
|
138
|
-
if (!st.recentCpProbs)
|
|
146
|
+
if (!st.recentCpProbs)
|
|
147
|
+
st.recentCpProbs = [];
|
|
139
148
|
st.recentCpProbs.push(cpProb);
|
|
140
149
|
if (st.recentCpProbs.length > cfg.anomalyRevertWindow) {
|
|
141
150
|
st.recentCpProbs.shift();
|
|
@@ -150,13 +159,11 @@ function serializeBOCPD(states, obs) {
|
|
|
150
159
|
function deserializeBOCPD(raw) {
|
|
151
160
|
return {
|
|
152
161
|
states: new Map(Object.entries(raw.features)),
|
|
153
|
-
obs: new Map(
|
|
154
|
-
Object.entries(raw.observations).map(([k, v]) => [k, Array.isArray(v) ? v : []])
|
|
155
|
-
)
|
|
162
|
+
obs: new Map(Object.entries(raw.observations).map(([k, v]) => [k, Array.isArray(v) ? v : []]))
|
|
156
163
|
};
|
|
157
164
|
}
|
|
158
165
|
|
|
159
|
-
// ../chitragupta/packages/smriti/
|
|
166
|
+
// ../chitragupta/packages/smriti/dist/vasana-engine.js
|
|
160
167
|
var VasanaEngine = class {
|
|
161
168
|
cfg;
|
|
162
169
|
states = /* @__PURE__ */ new Map();
|
|
@@ -175,10 +182,12 @@ var VasanaEngine = class {
|
|
|
175
182
|
/** Observe a samskara: extract features and update BOCPD state per dimension. */
|
|
176
183
|
observe(samskara) {
|
|
177
184
|
for (const [feat, val] of this.extractFeatures(samskara)) {
|
|
178
|
-
if (!this.states.has(feat))
|
|
185
|
+
if (!this.states.has(feat))
|
|
186
|
+
this.states.set(feat, initBOCPD(this.cfg));
|
|
179
187
|
const buf = this.obs.get(feat) ?? [];
|
|
180
188
|
buf.push(val);
|
|
181
|
-
if (buf.length > this.cfg.windowSize)
|
|
189
|
+
if (buf.length > this.cfg.windowSize)
|
|
190
|
+
buf.splice(0, buf.length - this.cfg.windowSize);
|
|
182
191
|
this.obs.set(feat, buf);
|
|
183
192
|
updateBOCPD(this.states.get(feat), val, this.cfg);
|
|
184
193
|
}
|
|
@@ -188,12 +197,10 @@ var VasanaEngine = class {
|
|
|
188
197
|
const now = Date.now();
|
|
189
198
|
const res = { created: [], reinforced: [], pending: [], changePoints: [], anomalies: [], timestamp: now };
|
|
190
199
|
const db = DatabaseManager.instance().get("agent");
|
|
191
|
-
const rows = db.prepare(
|
|
192
|
-
`SELECT id, session_id, pattern_type, pattern_content, observation_count,
|
|
200
|
+
const rows = db.prepare(`SELECT id, session_id, pattern_type, pattern_content, observation_count,
|
|
193
201
|
confidence, pramana_type, project, created_at, updated_at
|
|
194
202
|
FROM samskaras WHERE project = ? OR project IS NULL
|
|
195
|
-
ORDER BY updated_at DESC LIMIT ?`
|
|
196
|
-
).all(project, this.cfg.windowSize * 10);
|
|
203
|
+
ORDER BY updated_at DESC LIMIT ?`).all(project, this.cfg.windowSize * 10);
|
|
197
204
|
for (const [key, ids] of this.clusterSamskaras(rows)) {
|
|
198
205
|
const feat = `cluster:${key}`;
|
|
199
206
|
const st = this.states.get(feat);
|
|
@@ -265,7 +272,8 @@ var VasanaEngine = class {
|
|
|
265
272
|
/** Reinforce with diminishing returns: delta = 0.1 / (1 + ln(1 + count)). */
|
|
266
273
|
reinforce(vasanaId) {
|
|
267
274
|
const v = this.loadVasana(vasanaId);
|
|
268
|
-
if (!v)
|
|
275
|
+
if (!v)
|
|
276
|
+
return;
|
|
269
277
|
v.strength = Math.min(1, v.strength + 0.1 / (1 + Math.log(1 + v.reinforcementCount)));
|
|
270
278
|
v.reinforcementCount++;
|
|
271
279
|
v.lastActivated = v.updatedAt = Date.now();
|
|
@@ -274,19 +282,18 @@ var VasanaEngine = class {
|
|
|
274
282
|
/** Weaken by fixed decrement. */
|
|
275
283
|
weaken(vasanaId) {
|
|
276
284
|
const v = this.loadVasana(vasanaId);
|
|
277
|
-
if (!v)
|
|
285
|
+
if (!v)
|
|
286
|
+
return;
|
|
278
287
|
v.strength = Math.max(0, v.strength - 0.15);
|
|
279
288
|
v.updatedAt = Date.now();
|
|
280
289
|
this.saveVasana(v);
|
|
281
290
|
}
|
|
282
291
|
/** Get vasanas for a project (includes global), sorted by strength desc. */
|
|
283
292
|
getVasanas(project, topK = 20) {
|
|
284
|
-
const rows = DatabaseManager.instance().get("agent").prepare(
|
|
285
|
-
`SELECT id,name,description,valence,strength,stability,source_samskaras,
|
|
293
|
+
const rows = DatabaseManager.instance().get("agent").prepare(`SELECT id,name,description,valence,strength,stability,source_samskaras,
|
|
286
294
|
project,created_at,updated_at,last_activated,activation_count
|
|
287
295
|
FROM vasanas WHERE project=? OR project IS NULL OR project='__global__'
|
|
288
|
-
ORDER BY strength DESC LIMIT ?`
|
|
289
|
-
).all(project, topK);
|
|
296
|
+
ORDER BY strength DESC LIMIT ?`).all(project, topK);
|
|
290
297
|
return rows.map((r) => this.toVasana(r));
|
|
291
298
|
}
|
|
292
299
|
/** Promote project vasanas to global when found in >= promotionMinProjects. */
|
|
@@ -294,12 +301,10 @@ var VasanaEngine = class {
|
|
|
294
301
|
const now = Date.now();
|
|
295
302
|
const res = { promoted: [], projectSources: {}, timestamp: now };
|
|
296
303
|
const db = DatabaseManager.instance().get("agent");
|
|
297
|
-
const rows = db.prepare(
|
|
298
|
-
`SELECT id,name,description,valence,strength,stability,source_samskaras,
|
|
304
|
+
const rows = db.prepare(`SELECT id,name,description,valence,strength,stability,source_samskaras,
|
|
299
305
|
project,created_at,updated_at,last_activated,activation_count
|
|
300
306
|
FROM vasanas WHERE project IS NOT NULL AND project!='__global__' AND strength>=0.4
|
|
301
|
-
ORDER BY name`
|
|
302
|
-
).all();
|
|
307
|
+
ORDER BY name`).all();
|
|
303
308
|
const byName = /* @__PURE__ */ new Map();
|
|
304
309
|
for (const r of rows) {
|
|
305
310
|
const k = r.name.toLowerCase();
|
|
@@ -307,12 +312,16 @@ var VasanaEngine = class {
|
|
|
307
312
|
}
|
|
308
313
|
for (const [tendency, group] of byName) {
|
|
309
314
|
const projects = new Set(group.map((r) => r.project));
|
|
310
|
-
if (projects.size < this.cfg.promotionMinProjects)
|
|
311
|
-
|
|
315
|
+
if (projects.size < this.cfg.promotionMinProjects)
|
|
316
|
+
continue;
|
|
317
|
+
if (db.prepare(`SELECT 1 FROM vasanas WHERE name=? AND (project IS NULL OR project='__global__')`).get(tendency))
|
|
318
|
+
continue;
|
|
312
319
|
const allSrc = [];
|
|
313
|
-
for (const r of group)
|
|
320
|
+
for (const r of group)
|
|
321
|
+
allSrc.push(...jsonArr(r.source_samskaras));
|
|
314
322
|
const votes = { positive: 0, negative: 0, neutral: 0 };
|
|
315
|
-
for (const r of group)
|
|
323
|
+
for (const r of group)
|
|
324
|
+
votes[r.valence]++;
|
|
316
325
|
const valence = ["positive", "negative", "neutral"].reduce((a, b) => votes[a] >= votes[b] ? a : b);
|
|
317
326
|
const gv = {
|
|
318
327
|
id: fnv1a(tendency + ":__global__"),
|
|
@@ -344,32 +353,31 @@ var VasanaEngine = class {
|
|
|
344
353
|
let deleted = 0;
|
|
345
354
|
for (const r of rows) {
|
|
346
355
|
const elapsed = now - (r.last_activated ?? now);
|
|
347
|
-
if (elapsed <= 0)
|
|
356
|
+
if (elapsed <= 0)
|
|
357
|
+
continue;
|
|
348
358
|
const s = r.strength * Math.exp(-Math.LN2 * elapsed / hl);
|
|
349
359
|
if (s < 0.01) {
|
|
350
360
|
db.prepare(`DELETE FROM vasanas WHERE id=?`).run(r.id);
|
|
351
361
|
deleted++;
|
|
352
|
-
} else
|
|
362
|
+
} else
|
|
363
|
+
db.prepare(`UPDATE vasanas SET strength=?,updated_at=? WHERE id=?`).run(s, now, r.id);
|
|
353
364
|
}
|
|
354
365
|
return deleted;
|
|
355
366
|
}
|
|
356
367
|
/** Persist BOCPD state (run-length distributions + observations) to SQLite. */
|
|
357
368
|
persist() {
|
|
358
369
|
const json = JSON.stringify(serializeBOCPD(this.states, this.obs));
|
|
359
|
-
DatabaseManager.instance().get("agent").prepare(
|
|
360
|
-
`INSERT OR REPLACE INTO consolidation_rules
|
|
370
|
+
DatabaseManager.instance().get("agent").prepare(`INSERT OR REPLACE INTO consolidation_rules
|
|
361
371
|
(id, category, rule_text, confidence, source_sessions, created_at, updated_at, hit_count, project)
|
|
362
372
|
VALUES ((SELECT id FROM consolidation_rules WHERE category='bocpd_state' AND project='__vasana_engine__'),
|
|
363
|
-
'bocpd_state',?,1.0,NULL,?,?,1,'__vasana_engine__')`
|
|
364
|
-
).run(json, Date.now(), Date.now());
|
|
373
|
+
'bocpd_state',?,1.0,NULL,?,?,1,'__vasana_engine__')`).run(json, Date.now(), Date.now());
|
|
365
374
|
}
|
|
366
375
|
/** Restore BOCPD state from SQLite. No-op if nothing persisted. */
|
|
367
376
|
restore() {
|
|
368
|
-
const row = DatabaseManager.instance().get("agent").prepare(
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
if (!row) return;
|
|
377
|
+
const row = DatabaseManager.instance().get("agent").prepare(`SELECT rule_text FROM consolidation_rules
|
|
378
|
+
WHERE category='bocpd_state' AND project='__vasana_engine__' LIMIT 1`).get();
|
|
379
|
+
if (!row)
|
|
380
|
+
return;
|
|
373
381
|
try {
|
|
374
382
|
const raw = JSON.parse(row.rule_text);
|
|
375
383
|
const { states, obs } = deserializeBOCPD(raw);
|
|
@@ -392,9 +400,11 @@ var VasanaEngine = class {
|
|
|
392
400
|
* - Otherwise -> stable
|
|
393
401
|
*/
|
|
394
402
|
classifyDeviation(st) {
|
|
395
|
-
if (st.logR.length === 0)
|
|
403
|
+
if (st.logR.length === 0)
|
|
404
|
+
return "stable";
|
|
396
405
|
const cpProb = Math.exp(st.logR[0]);
|
|
397
|
-
if (cpProb <= this.cfg.changePointThreshold)
|
|
406
|
+
if (cpProb <= this.cfg.changePointThreshold)
|
|
407
|
+
return "stable";
|
|
398
408
|
const recent = st.recentCpProbs ?? [cpProb];
|
|
399
409
|
const exceedCount = recent.filter((p) => p > this.cfg.changePointThreshold).length;
|
|
400
410
|
const ratio = exceedCount / Math.max(1, recent.length);
|
|
@@ -404,7 +414,8 @@ var VasanaEngine = class {
|
|
|
404
414
|
return "anomaly";
|
|
405
415
|
}
|
|
406
416
|
stabilityScore(st) {
|
|
407
|
-
if (st.logR.length === 0)
|
|
417
|
+
if (st.logR.length === 0)
|
|
418
|
+
return 0;
|
|
408
419
|
return Math.max(0, Math.min(1, 1 - Math.exp(st.logR[0])));
|
|
409
420
|
}
|
|
410
421
|
// ── Feature Extraction & Validation ──────────────────────────────────
|
|
@@ -426,25 +437,31 @@ var VasanaEngine = class {
|
|
|
426
437
|
}
|
|
427
438
|
/** 70/30 holdout: fraction of test points within 1.5 sigma of train mean. */
|
|
428
439
|
holdoutValidation(obs) {
|
|
429
|
-
if (obs.length < 4)
|
|
440
|
+
if (obs.length < 4)
|
|
441
|
+
return 0;
|
|
430
442
|
const si = Math.floor(obs.length * this.cfg.holdoutTrainRatio);
|
|
431
443
|
const train = obs.slice(0, si), test = obs.slice(si);
|
|
432
|
-
if (!train.length || !test.length)
|
|
444
|
+
if (!train.length || !test.length)
|
|
445
|
+
return 0;
|
|
433
446
|
const mu = train.reduce((a, b) => a + b, 0) / train.length;
|
|
434
447
|
const std = Math.sqrt(train.reduce((a, v) => a + (v - mu) ** 2, 0) / train.length + 1e-10);
|
|
435
448
|
let ok = 0;
|
|
436
|
-
for (const v of test)
|
|
449
|
+
for (const v of test)
|
|
450
|
+
if (Math.abs(v - mu) <= 1.5 * std)
|
|
451
|
+
ok++;
|
|
437
452
|
return ok / test.length;
|
|
438
453
|
}
|
|
439
454
|
assignValence(rows) {
|
|
440
455
|
let pos = 0, neg = 0;
|
|
441
456
|
for (const r of rows) {
|
|
442
|
-
if (r.pattern_type === "correction")
|
|
457
|
+
if (r.pattern_type === "correction")
|
|
458
|
+
neg += r.confidence;
|
|
443
459
|
else if (r.pattern_type !== "tool-sequence" || r.confidence > 0.6)
|
|
444
460
|
pos += r.confidence * (r.pattern_type === "tool-sequence" ? 0.5 : 1);
|
|
445
461
|
}
|
|
446
462
|
const tot = pos + neg;
|
|
447
|
-
if (tot < 0.1)
|
|
463
|
+
if (tot < 0.1)
|
|
464
|
+
return "neutral";
|
|
448
465
|
return pos / tot > 0.6 ? "positive" : neg / tot > 0.6 ? "negative" : "neutral";
|
|
449
466
|
}
|
|
450
467
|
clusterSamskaras(rows) {
|
|
@@ -462,50 +479,21 @@ var VasanaEngine = class {
|
|
|
462
479
|
// reinforcementCount->activation_count, lastActivated->last_activated
|
|
463
480
|
saveVasana(v) {
|
|
464
481
|
const db = DatabaseManager.instance().get("agent");
|
|
465
|
-
const existing = db.prepare(
|
|
466
|
-
`SELECT id FROM vasanas WHERE name=? AND (project=? OR (project IS NULL AND ?='__global__'))`
|
|
467
|
-
).get(v.tendency, v.project, v.project);
|
|
482
|
+
const existing = db.prepare(`SELECT id FROM vasanas WHERE name=? AND (project=? OR (project IS NULL AND ?='__global__'))`).get(v.tendency, v.project, v.project);
|
|
468
483
|
if (existing) {
|
|
469
|
-
db.prepare(
|
|
470
|
-
|
|
471
|
-
source_samskaras=?,updated_at=?,last_activated=?,activation_count=? WHERE id=?`
|
|
472
|
-
).run(
|
|
473
|
-
v.description,
|
|
474
|
-
v.valence,
|
|
475
|
-
v.strength,
|
|
476
|
-
v.stability,
|
|
477
|
-
JSON.stringify(v.sourceSamskaras),
|
|
478
|
-
v.updatedAt,
|
|
479
|
-
v.lastActivated,
|
|
480
|
-
v.reinforcementCount,
|
|
481
|
-
existing.id
|
|
482
|
-
);
|
|
484
|
+
db.prepare(`UPDATE vasanas SET description=?,valence=?,strength=?,stability=?,
|
|
485
|
+
source_samskaras=?,updated_at=?,last_activated=?,activation_count=? WHERE id=?`).run(v.description, v.valence, v.strength, v.stability, JSON.stringify(v.sourceSamskaras), v.updatedAt, v.lastActivated, v.reinforcementCount, existing.id);
|
|
483
486
|
} else {
|
|
484
|
-
db.prepare(
|
|
485
|
-
|
|
486
|
-
project,created_at,updated_at,last_activated,activation_count) VALUES (?,?,?,?,?,?,?,?,?,?,?)`
|
|
487
|
-
).run(
|
|
488
|
-
v.tendency,
|
|
489
|
-
v.description,
|
|
490
|
-
v.valence,
|
|
491
|
-
v.strength,
|
|
492
|
-
v.stability,
|
|
493
|
-
JSON.stringify(v.sourceSamskaras),
|
|
494
|
-
v.project === "__global__" ? null : v.project,
|
|
495
|
-
v.createdAt,
|
|
496
|
-
v.updatedAt,
|
|
497
|
-
v.lastActivated,
|
|
498
|
-
v.reinforcementCount
|
|
499
|
-
);
|
|
487
|
+
db.prepare(`INSERT INTO vasanas (name,description,valence,strength,stability,source_samskaras,
|
|
488
|
+
project,created_at,updated_at,last_activated,activation_count) VALUES (?,?,?,?,?,?,?,?,?,?,?)`).run(v.tendency, v.description, v.valence, v.strength, v.stability, JSON.stringify(v.sourceSamskaras), v.project === "__global__" ? null : v.project, v.createdAt, v.updatedAt, v.lastActivated, v.reinforcementCount);
|
|
500
489
|
}
|
|
501
490
|
this.cache.set(v.id, v);
|
|
502
491
|
}
|
|
503
492
|
loadVasana(vid) {
|
|
504
|
-
if (this.cache.has(vid))
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
project,created_at,updated_at,last_activated,activation_count FROM vasanas`
|
|
508
|
-
).all();
|
|
493
|
+
if (this.cache.has(vid))
|
|
494
|
+
return this.cache.get(vid);
|
|
495
|
+
const rows = DatabaseManager.instance().get("agent").prepare(`SELECT id,name,description,valence,strength,stability,source_samskaras,
|
|
496
|
+
project,created_at,updated_at,last_activated,activation_count FROM vasanas`).all();
|
|
509
497
|
for (const r of rows) {
|
|
510
498
|
const v = this.toVasana(r);
|
|
511
499
|
this.cache.set(v.id, v);
|
|
@@ -532,7 +520,8 @@ var VasanaEngine = class {
|
|
|
532
520
|
}
|
|
533
521
|
};
|
|
534
522
|
function jsonArr(s) {
|
|
535
|
-
if (!s)
|
|
523
|
+
if (!s)
|
|
524
|
+
return [];
|
|
536
525
|
try {
|
|
537
526
|
const p = JSON.parse(s);
|
|
538
527
|
return Array.isArray(p) ? p : [];
|
|
@@ -554,4 +543,4 @@ export {
|
|
|
554
543
|
deserializeBOCPD,
|
|
555
544
|
VasanaEngine
|
|
556
545
|
};
|
|
557
|
-
//# sourceMappingURL=chunk-
|
|
546
|
+
//# sourceMappingURL=chunk-W4PVGBUH.js.map
|