agentic-qe 3.6.5 → 3.6.7
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/.claude/helpers/statusline-v3.cjs +7 -1
- package/.claude/skills/skills-manifest.json +1 -1
- package/package.json +1 -1
- package/v3/CHANGELOG.md +45 -0
- package/v3/dist/cli/bundle.js +2629 -2046
- package/v3/dist/cli/commands/hooks.d.ts.map +1 -1
- package/v3/dist/cli/commands/hooks.js +189 -46
- package/v3/dist/cli/commands/hooks.js.map +1 -1
- package/v3/dist/cli/commands/learning.d.ts.map +1 -1
- package/v3/dist/cli/commands/learning.js +15 -14
- package/v3/dist/cli/commands/learning.js.map +1 -1
- package/v3/dist/coordination/dynamic-scaling/dynamic-scaler.d.ts +21 -0
- package/v3/dist/coordination/dynamic-scaling/dynamic-scaler.d.ts.map +1 -1
- package/v3/dist/coordination/dynamic-scaling/dynamic-scaler.js +76 -0
- package/v3/dist/coordination/dynamic-scaling/dynamic-scaler.js.map +1 -1
- package/v3/dist/coordination/mincut/mincut-persistence.d.ts +4 -0
- package/v3/dist/coordination/mincut/mincut-persistence.d.ts.map +1 -1
- package/v3/dist/coordination/mincut/mincut-persistence.js +30 -0
- package/v3/dist/coordination/mincut/mincut-persistence.js.map +1 -1
- package/v3/dist/coordination/mincut/time-crystal.d.ts +22 -0
- package/v3/dist/coordination/mincut/time-crystal.d.ts.map +1 -1
- package/v3/dist/coordination/mincut/time-crystal.js +95 -0
- package/v3/dist/coordination/mincut/time-crystal.js.map +1 -1
- package/v3/dist/domains/code-intelligence/coordinator.d.ts.map +1 -1
- package/v3/dist/domains/code-intelligence/coordinator.js +6 -3
- package/v3/dist/domains/code-intelligence/coordinator.js.map +1 -1
- package/v3/dist/domains/code-intelligence/services/knowledge-graph.d.ts.map +1 -1
- package/v3/dist/domains/code-intelligence/services/knowledge-graph.js +19 -34
- package/v3/dist/domains/code-intelligence/services/knowledge-graph.js.map +1 -1
- package/v3/dist/domains/coverage-analysis/services/hnsw-index.d.ts.map +1 -1
- package/v3/dist/domains/coverage-analysis/services/hnsw-index.js +5 -3
- package/v3/dist/domains/coverage-analysis/services/hnsw-index.js.map +1 -1
- package/v3/dist/domains/security-compliance/services/scanners/sast-scanner.d.ts.map +1 -1
- package/v3/dist/domains/security-compliance/services/scanners/sast-scanner.js +7 -3
- package/v3/dist/domains/security-compliance/services/scanners/sast-scanner.js.map +1 -1
- package/v3/dist/early-exit/early-exit-controller.d.ts +20 -0
- package/v3/dist/early-exit/early-exit-controller.d.ts.map +1 -1
- package/v3/dist/early-exit/early-exit-controller.js +72 -0
- package/v3/dist/early-exit/early-exit-controller.js.map +1 -1
- package/v3/dist/feedback/coverage-learner.d.ts +19 -0
- package/v3/dist/feedback/coverage-learner.d.ts.map +1 -1
- package/v3/dist/feedback/coverage-learner.js +134 -0
- package/v3/dist/feedback/coverage-learner.js.map +1 -1
- package/v3/dist/feedback/feedback-loop.d.ts +10 -1
- package/v3/dist/feedback/feedback-loop.d.ts.map +1 -1
- package/v3/dist/feedback/feedback-loop.js +20 -1
- package/v3/dist/feedback/feedback-loop.js.map +1 -1
- package/v3/dist/feedback/index.d.ts +1 -1
- package/v3/dist/feedback/index.d.ts.map +1 -1
- package/v3/dist/feedback/index.js +1 -1
- package/v3/dist/feedback/index.js.map +1 -1
- package/v3/dist/feedback/test-outcome-tracker.d.ts +19 -0
- package/v3/dist/feedback/test-outcome-tracker.d.ts.map +1 -1
- package/v3/dist/feedback/test-outcome-tracker.js +114 -0
- package/v3/dist/feedback/test-outcome-tracker.js.map +1 -1
- package/v3/dist/governance/compliance-reporter.d.ts +13 -0
- package/v3/dist/governance/compliance-reporter.d.ts.map +1 -1
- package/v3/dist/governance/compliance-reporter.js +63 -0
- package/v3/dist/governance/compliance-reporter.js.map +1 -1
- package/v3/dist/governance/continue-gate-integration.d.ts +8 -0
- package/v3/dist/governance/continue-gate-integration.d.ts.map +1 -1
- package/v3/dist/governance/continue-gate-integration.js +50 -2
- package/v3/dist/governance/continue-gate-integration.js.map +1 -1
- package/v3/dist/governance/evolution-pipeline-integration.d.ts +13 -0
- package/v3/dist/governance/evolution-pipeline-integration.d.ts.map +1 -1
- package/v3/dist/governance/evolution-pipeline-integration.js +53 -0
- package/v3/dist/governance/evolution-pipeline-integration.js.map +1 -1
- package/v3/dist/index.d.ts +1 -1
- package/v3/dist/index.d.ts.map +1 -1
- package/v3/dist/index.js +1 -1
- package/v3/dist/index.js.map +1 -1
- package/v3/dist/init/phases/07-hooks.d.ts.map +1 -1
- package/v3/dist/init/phases/07-hooks.js +26 -5
- package/v3/dist/init/phases/07-hooks.js.map +1 -1
- package/v3/dist/integrations/embeddings/cache/EmbeddingCache.js +2 -2
- package/v3/dist/integrations/embeddings/cache/EmbeddingCache.js.map +1 -1
- package/v3/dist/integrations/ruvector/ast-complexity.d.ts +8 -0
- package/v3/dist/integrations/ruvector/ast-complexity.d.ts.map +1 -1
- package/v3/dist/integrations/ruvector/ast-complexity.js +45 -0
- package/v3/dist/integrations/ruvector/ast-complexity.js.map +1 -1
- package/v3/dist/integrations/ruvector/attention-wrapper.d.ts +18 -1
- package/v3/dist/integrations/ruvector/attention-wrapper.d.ts.map +1 -1
- package/v3/dist/integrations/ruvector/attention-wrapper.js +60 -2
- package/v3/dist/integrations/ruvector/attention-wrapper.js.map +1 -1
- package/v3/dist/integrations/ruvector/coverage-router.d.ts +8 -0
- package/v3/dist/integrations/ruvector/coverage-router.d.ts.map +1 -1
- package/v3/dist/integrations/ruvector/coverage-router.js +45 -0
- package/v3/dist/integrations/ruvector/coverage-router.js.map +1 -1
- package/v3/dist/integrations/ruvector/diff-risk-classifier.d.ts +8 -0
- package/v3/dist/integrations/ruvector/diff-risk-classifier.d.ts.map +1 -1
- package/v3/dist/integrations/ruvector/diff-risk-classifier.js +45 -0
- package/v3/dist/integrations/ruvector/diff-risk-classifier.js.map +1 -1
- package/v3/dist/integrations/ruvector/graph-boundaries.d.ts +8 -0
- package/v3/dist/integrations/ruvector/graph-boundaries.d.ts.map +1 -1
- package/v3/dist/integrations/ruvector/graph-boundaries.js +45 -0
- package/v3/dist/integrations/ruvector/graph-boundaries.js.map +1 -1
- package/v3/dist/integrations/ruvector/index.d.ts.map +1 -1
- package/v3/dist/integrations/ruvector/index.js +5 -20
- package/v3/dist/integrations/ruvector/index.js.map +1 -1
- package/v3/dist/integrations/ruvector/persistent-q-router.d.ts +7 -3
- package/v3/dist/integrations/ruvector/persistent-q-router.d.ts.map +1 -1
- package/v3/dist/integrations/ruvector/persistent-q-router.js +7 -3
- package/v3/dist/integrations/ruvector/persistent-q-router.js.map +1 -1
- package/v3/dist/integrations/ruvector/q-learning-router.d.ts +13 -0
- package/v3/dist/integrations/ruvector/q-learning-router.d.ts.map +1 -1
- package/v3/dist/integrations/ruvector/q-learning-router.js +67 -0
- package/v3/dist/integrations/ruvector/q-learning-router.js.map +1 -1
- package/v3/dist/kernel/hybrid-backend.d.ts +1 -0
- package/v3/dist/kernel/hybrid-backend.d.ts.map +1 -1
- package/v3/dist/kernel/hybrid-backend.js +39 -0
- package/v3/dist/kernel/hybrid-backend.js.map +1 -1
- package/v3/dist/kernel/unified-memory.d.ts +1 -0
- package/v3/dist/kernel/unified-memory.d.ts.map +1 -1
- package/v3/dist/kernel/unified-memory.js +118 -7
- package/v3/dist/kernel/unified-memory.js.map +1 -1
- package/v3/dist/learning/experience-capture-middleware.d.ts.map +1 -1
- package/v3/dist/learning/experience-capture-middleware.js +45 -18
- package/v3/dist/learning/experience-capture-middleware.js.map +1 -1
- package/v3/dist/learning/pattern-store.d.ts.map +1 -1
- package/v3/dist/learning/pattern-store.js +13 -60
- package/v3/dist/learning/pattern-store.js.map +1 -1
- package/v3/dist/learning/qe-reasoning-bank.d.ts.map +1 -1
- package/v3/dist/learning/qe-reasoning-bank.js +18 -4
- package/v3/dist/learning/qe-reasoning-bank.js.map +1 -1
- package/v3/dist/learning/sqlite-persistence.d.ts.map +1 -1
- package/v3/dist/learning/sqlite-persistence.js +1 -2
- package/v3/dist/learning/sqlite-persistence.js.map +1 -1
- package/v3/dist/learning/token-tracker.d.ts +23 -0
- package/v3/dist/learning/token-tracker.d.ts.map +1 -1
- package/v3/dist/learning/token-tracker.js +91 -0
- package/v3/dist/learning/token-tracker.js.map +1 -1
- package/v3/dist/learning/v2-to-v3-migration.d.ts.map +1 -1
- package/v3/dist/learning/v2-to-v3-migration.js +1 -2
- package/v3/dist/learning/v2-to-v3-migration.js.map +1 -1
- package/v3/dist/mcp/bundle.js +1077 -974
- package/v3/dist/mcp/tools/coherence/audit.js +1 -1
- package/v3/dist/routing/routing-feedback.d.ts +21 -0
- package/v3/dist/routing/routing-feedback.d.ts.map +1 -1
- package/v3/dist/routing/routing-feedback.js +95 -0
- package/v3/dist/routing/routing-feedback.js.map +1 -1
- package/v3/dist/shared/sql-safety.d.ts.map +1 -1
- package/v3/dist/shared/sql-safety.js +2 -0
- package/v3/dist/shared/sql-safety.js.map +1 -1
- package/v3/package.json +1 -1
package/v3/dist/mcp/bundle.js
CHANGED
|
@@ -14,7 +14,7 @@ var __require = /* @__PURE__ */ ((x67) => typeof require !== "undefined" ? requi
|
|
|
14
14
|
var __esm = (fn, res) => function __init() {
|
|
15
15
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
16
16
|
};
|
|
17
|
-
var __commonJS = (cb, mod) => function
|
|
17
|
+
var __commonJS = (cb, mod) => function __require9() {
|
|
18
18
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
19
|
};
|
|
20
20
|
var __export = (target, all) => {
|
|
@@ -3888,696 +3888,6 @@ var init_types = __esm({
|
|
|
3888
3888
|
}
|
|
3889
3889
|
});
|
|
3890
3890
|
|
|
3891
|
-
// node_modules/fast-json-patch/commonjs/helpers.js
|
|
3892
|
-
var require_helpers = __commonJS({
|
|
3893
|
-
"node_modules/fast-json-patch/commonjs/helpers.js"(exports) {
|
|
3894
|
-
var __extends = exports && exports.__extends || /* @__PURE__ */ (function() {
|
|
3895
|
-
var extendStatics = function(d74, b68) {
|
|
3896
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d75, b69) {
|
|
3897
|
-
d75.__proto__ = b69;
|
|
3898
|
-
} || function(d75, b69) {
|
|
3899
|
-
for (var p74 in b69) if (b69.hasOwnProperty(p74)) d75[p74] = b69[p74];
|
|
3900
|
-
};
|
|
3901
|
-
return extendStatics(d74, b68);
|
|
3902
|
-
};
|
|
3903
|
-
return function(d74, b68) {
|
|
3904
|
-
extendStatics(d74, b68);
|
|
3905
|
-
function __() {
|
|
3906
|
-
this.constructor = d74;
|
|
3907
|
-
}
|
|
3908
|
-
d74.prototype = b68 === null ? Object.create(b68) : (__.prototype = b68.prototype, new __());
|
|
3909
|
-
};
|
|
3910
|
-
})();
|
|
3911
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3912
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3913
|
-
function hasOwnProperty(obj, key) {
|
|
3914
|
-
return _hasOwnProperty.call(obj, key);
|
|
3915
|
-
}
|
|
3916
|
-
exports.hasOwnProperty = hasOwnProperty;
|
|
3917
|
-
function _objectKeys(obj) {
|
|
3918
|
-
if (Array.isArray(obj)) {
|
|
3919
|
-
var keys_1 = new Array(obj.length);
|
|
3920
|
-
for (var k68 = 0; k68 < keys_1.length; k68++) {
|
|
3921
|
-
keys_1[k68] = "" + k68;
|
|
3922
|
-
}
|
|
3923
|
-
return keys_1;
|
|
3924
|
-
}
|
|
3925
|
-
if (Object.keys) {
|
|
3926
|
-
return Object.keys(obj);
|
|
3927
|
-
}
|
|
3928
|
-
var keys = [];
|
|
3929
|
-
for (var i58 in obj) {
|
|
3930
|
-
if (hasOwnProperty(obj, i58)) {
|
|
3931
|
-
keys.push(i58);
|
|
3932
|
-
}
|
|
3933
|
-
}
|
|
3934
|
-
return keys;
|
|
3935
|
-
}
|
|
3936
|
-
exports._objectKeys = _objectKeys;
|
|
3937
|
-
function _deepClone(obj) {
|
|
3938
|
-
switch (typeof obj) {
|
|
3939
|
-
case "object":
|
|
3940
|
-
return JSON.parse(JSON.stringify(obj));
|
|
3941
|
-
//Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5
|
|
3942
|
-
case "undefined":
|
|
3943
|
-
return null;
|
|
3944
|
-
//this is how JSON.stringify behaves for array items
|
|
3945
|
-
default:
|
|
3946
|
-
return obj;
|
|
3947
|
-
}
|
|
3948
|
-
}
|
|
3949
|
-
exports._deepClone = _deepClone;
|
|
3950
|
-
function isInteger(str) {
|
|
3951
|
-
var i58 = 0;
|
|
3952
|
-
var len = str.length;
|
|
3953
|
-
var charCode;
|
|
3954
|
-
while (i58 < len) {
|
|
3955
|
-
charCode = str.charCodeAt(i58);
|
|
3956
|
-
if (charCode >= 48 && charCode <= 57) {
|
|
3957
|
-
i58++;
|
|
3958
|
-
continue;
|
|
3959
|
-
}
|
|
3960
|
-
return false;
|
|
3961
|
-
}
|
|
3962
|
-
return true;
|
|
3963
|
-
}
|
|
3964
|
-
exports.isInteger = isInteger;
|
|
3965
|
-
function escapePathComponent2(path21) {
|
|
3966
|
-
if (path21.indexOf("/") === -1 && path21.indexOf("~") === -1)
|
|
3967
|
-
return path21;
|
|
3968
|
-
return path21.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
3969
|
-
}
|
|
3970
|
-
exports.escapePathComponent = escapePathComponent2;
|
|
3971
|
-
function unescapePathComponent2(path21) {
|
|
3972
|
-
return path21.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
3973
|
-
}
|
|
3974
|
-
exports.unescapePathComponent = unescapePathComponent2;
|
|
3975
|
-
function _getPathRecursive(root, obj) {
|
|
3976
|
-
var found;
|
|
3977
|
-
for (var key in root) {
|
|
3978
|
-
if (hasOwnProperty(root, key)) {
|
|
3979
|
-
if (root[key] === obj) {
|
|
3980
|
-
return escapePathComponent2(key) + "/";
|
|
3981
|
-
} else if (typeof root[key] === "object") {
|
|
3982
|
-
found = _getPathRecursive(root[key], obj);
|
|
3983
|
-
if (found != "") {
|
|
3984
|
-
return escapePathComponent2(key) + "/" + found;
|
|
3985
|
-
}
|
|
3986
|
-
}
|
|
3987
|
-
}
|
|
3988
|
-
}
|
|
3989
|
-
return "";
|
|
3990
|
-
}
|
|
3991
|
-
exports._getPathRecursive = _getPathRecursive;
|
|
3992
|
-
function getPath(root, obj) {
|
|
3993
|
-
if (root === obj) {
|
|
3994
|
-
return "/";
|
|
3995
|
-
}
|
|
3996
|
-
var path21 = _getPathRecursive(root, obj);
|
|
3997
|
-
if (path21 === "") {
|
|
3998
|
-
throw new Error("Object not found in root");
|
|
3999
|
-
}
|
|
4000
|
-
return "/" + path21;
|
|
4001
|
-
}
|
|
4002
|
-
exports.getPath = getPath;
|
|
4003
|
-
function hasUndefined(obj) {
|
|
4004
|
-
if (obj === void 0) {
|
|
4005
|
-
return true;
|
|
4006
|
-
}
|
|
4007
|
-
if (obj) {
|
|
4008
|
-
if (Array.isArray(obj)) {
|
|
4009
|
-
for (var i_1 = 0, len = obj.length; i_1 < len; i_1++) {
|
|
4010
|
-
if (hasUndefined(obj[i_1])) {
|
|
4011
|
-
return true;
|
|
4012
|
-
}
|
|
4013
|
-
}
|
|
4014
|
-
} else if (typeof obj === "object") {
|
|
4015
|
-
var objKeys = _objectKeys(obj);
|
|
4016
|
-
var objKeysLength = objKeys.length;
|
|
4017
|
-
for (var i58 = 0; i58 < objKeysLength; i58++) {
|
|
4018
|
-
if (hasUndefined(obj[objKeys[i58]])) {
|
|
4019
|
-
return true;
|
|
4020
|
-
}
|
|
4021
|
-
}
|
|
4022
|
-
}
|
|
4023
|
-
}
|
|
4024
|
-
return false;
|
|
4025
|
-
}
|
|
4026
|
-
exports.hasUndefined = hasUndefined;
|
|
4027
|
-
function patchErrorMessageFormatter(message, args) {
|
|
4028
|
-
var messageParts = [message];
|
|
4029
|
-
for (var key in args) {
|
|
4030
|
-
var value = typeof args[key] === "object" ? JSON.stringify(args[key], null, 2) : args[key];
|
|
4031
|
-
if (typeof value !== "undefined") {
|
|
4032
|
-
messageParts.push(key + ": " + value);
|
|
4033
|
-
}
|
|
4034
|
-
}
|
|
4035
|
-
return messageParts.join("\n");
|
|
4036
|
-
}
|
|
4037
|
-
var PatchError = (
|
|
4038
|
-
/** @class */
|
|
4039
|
-
(function(_super) {
|
|
4040
|
-
__extends(PatchError2, _super);
|
|
4041
|
-
function PatchError2(message, name, index, operation, tree) {
|
|
4042
|
-
var _newTarget = this.constructor;
|
|
4043
|
-
var _this = _super.call(this, patchErrorMessageFormatter(message, { name, index, operation, tree })) || this;
|
|
4044
|
-
_this.name = name;
|
|
4045
|
-
_this.index = index;
|
|
4046
|
-
_this.operation = operation;
|
|
4047
|
-
_this.tree = tree;
|
|
4048
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
4049
|
-
_this.message = patchErrorMessageFormatter(message, { name, index, operation, tree });
|
|
4050
|
-
return _this;
|
|
4051
|
-
}
|
|
4052
|
-
return PatchError2;
|
|
4053
|
-
})(Error)
|
|
4054
|
-
);
|
|
4055
|
-
exports.PatchError = PatchError;
|
|
4056
|
-
}
|
|
4057
|
-
});
|
|
4058
|
-
|
|
4059
|
-
// node_modules/fast-json-patch/commonjs/core.js
|
|
4060
|
-
var require_core = __commonJS({
|
|
4061
|
-
"node_modules/fast-json-patch/commonjs/core.js"(exports) {
|
|
4062
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4063
|
-
var helpers_js_1 = require_helpers();
|
|
4064
|
-
exports.JsonPatchError = helpers_js_1.PatchError;
|
|
4065
|
-
exports.deepClone = helpers_js_1._deepClone;
|
|
4066
|
-
var objOps = {
|
|
4067
|
-
add: function(obj, key, document) {
|
|
4068
|
-
obj[key] = this.value;
|
|
4069
|
-
return { newDocument: document };
|
|
4070
|
-
},
|
|
4071
|
-
remove: function(obj, key, document) {
|
|
4072
|
-
var removed = obj[key];
|
|
4073
|
-
delete obj[key];
|
|
4074
|
-
return { newDocument: document, removed };
|
|
4075
|
-
},
|
|
4076
|
-
replace: function(obj, key, document) {
|
|
4077
|
-
var removed = obj[key];
|
|
4078
|
-
obj[key] = this.value;
|
|
4079
|
-
return { newDocument: document, removed };
|
|
4080
|
-
},
|
|
4081
|
-
move: function(obj, key, document) {
|
|
4082
|
-
var removed = getValueByPointer2(document, this.path);
|
|
4083
|
-
if (removed) {
|
|
4084
|
-
removed = helpers_js_1._deepClone(removed);
|
|
4085
|
-
}
|
|
4086
|
-
var originalValue = applyOperation3(document, { op: "remove", path: this.from }).removed;
|
|
4087
|
-
applyOperation3(document, { op: "add", path: this.path, value: originalValue });
|
|
4088
|
-
return { newDocument: document, removed };
|
|
4089
|
-
},
|
|
4090
|
-
copy: function(obj, key, document) {
|
|
4091
|
-
var valueToCopy = getValueByPointer2(document, this.from);
|
|
4092
|
-
applyOperation3(document, { op: "add", path: this.path, value: helpers_js_1._deepClone(valueToCopy) });
|
|
4093
|
-
return { newDocument: document };
|
|
4094
|
-
},
|
|
4095
|
-
test: function(obj, key, document) {
|
|
4096
|
-
return { newDocument: document, test: _areEquals(obj[key], this.value) };
|
|
4097
|
-
},
|
|
4098
|
-
_get: function(obj, key, document) {
|
|
4099
|
-
this.value = obj[key];
|
|
4100
|
-
return { newDocument: document };
|
|
4101
|
-
}
|
|
4102
|
-
};
|
|
4103
|
-
var arrOps = {
|
|
4104
|
-
add: function(arr, i58, document) {
|
|
4105
|
-
if (helpers_js_1.isInteger(i58)) {
|
|
4106
|
-
arr.splice(i58, 0, this.value);
|
|
4107
|
-
} else {
|
|
4108
|
-
arr[i58] = this.value;
|
|
4109
|
-
}
|
|
4110
|
-
return { newDocument: document, index: i58 };
|
|
4111
|
-
},
|
|
4112
|
-
remove: function(arr, i58, document) {
|
|
4113
|
-
var removedList = arr.splice(i58, 1);
|
|
4114
|
-
return { newDocument: document, removed: removedList[0] };
|
|
4115
|
-
},
|
|
4116
|
-
replace: function(arr, i58, document) {
|
|
4117
|
-
var removed = arr[i58];
|
|
4118
|
-
arr[i58] = this.value;
|
|
4119
|
-
return { newDocument: document, removed };
|
|
4120
|
-
},
|
|
4121
|
-
move: objOps.move,
|
|
4122
|
-
copy: objOps.copy,
|
|
4123
|
-
test: objOps.test,
|
|
4124
|
-
_get: objOps._get
|
|
4125
|
-
};
|
|
4126
|
-
function getValueByPointer2(document, pointer) {
|
|
4127
|
-
if (pointer == "") {
|
|
4128
|
-
return document;
|
|
4129
|
-
}
|
|
4130
|
-
var getOriginalDestination = { op: "_get", path: pointer };
|
|
4131
|
-
applyOperation3(document, getOriginalDestination);
|
|
4132
|
-
return getOriginalDestination.value;
|
|
4133
|
-
}
|
|
4134
|
-
exports.getValueByPointer = getValueByPointer2;
|
|
4135
|
-
function applyOperation3(document, operation, validateOperation2, mutateDocument, banPrototypeModifications, index) {
|
|
4136
|
-
if (validateOperation2 === void 0) {
|
|
4137
|
-
validateOperation2 = false;
|
|
4138
|
-
}
|
|
4139
|
-
if (mutateDocument === void 0) {
|
|
4140
|
-
mutateDocument = true;
|
|
4141
|
-
}
|
|
4142
|
-
if (banPrototypeModifications === void 0) {
|
|
4143
|
-
banPrototypeModifications = true;
|
|
4144
|
-
}
|
|
4145
|
-
if (index === void 0) {
|
|
4146
|
-
index = 0;
|
|
4147
|
-
}
|
|
4148
|
-
if (validateOperation2) {
|
|
4149
|
-
if (typeof validateOperation2 == "function") {
|
|
4150
|
-
validateOperation2(operation, 0, document, operation.path);
|
|
4151
|
-
} else {
|
|
4152
|
-
validator(operation, 0);
|
|
4153
|
-
}
|
|
4154
|
-
}
|
|
4155
|
-
if (operation.path === "") {
|
|
4156
|
-
var returnValue = { newDocument: document };
|
|
4157
|
-
if (operation.op === "add") {
|
|
4158
|
-
returnValue.newDocument = operation.value;
|
|
4159
|
-
return returnValue;
|
|
4160
|
-
} else if (operation.op === "replace") {
|
|
4161
|
-
returnValue.newDocument = operation.value;
|
|
4162
|
-
returnValue.removed = document;
|
|
4163
|
-
return returnValue;
|
|
4164
|
-
} else if (operation.op === "move" || operation.op === "copy") {
|
|
4165
|
-
returnValue.newDocument = getValueByPointer2(document, operation.from);
|
|
4166
|
-
if (operation.op === "move") {
|
|
4167
|
-
returnValue.removed = document;
|
|
4168
|
-
}
|
|
4169
|
-
return returnValue;
|
|
4170
|
-
} else if (operation.op === "test") {
|
|
4171
|
-
returnValue.test = _areEquals(document, operation.value);
|
|
4172
|
-
if (returnValue.test === false) {
|
|
4173
|
-
throw new exports.JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
|
|
4174
|
-
}
|
|
4175
|
-
returnValue.newDocument = document;
|
|
4176
|
-
return returnValue;
|
|
4177
|
-
} else if (operation.op === "remove") {
|
|
4178
|
-
returnValue.removed = document;
|
|
4179
|
-
returnValue.newDocument = null;
|
|
4180
|
-
return returnValue;
|
|
4181
|
-
} else if (operation.op === "_get") {
|
|
4182
|
-
operation.value = document;
|
|
4183
|
-
return returnValue;
|
|
4184
|
-
} else {
|
|
4185
|
-
if (validateOperation2) {
|
|
4186
|
-
throw new exports.JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document);
|
|
4187
|
-
} else {
|
|
4188
|
-
return returnValue;
|
|
4189
|
-
}
|
|
4190
|
-
}
|
|
4191
|
-
} else {
|
|
4192
|
-
if (!mutateDocument) {
|
|
4193
|
-
document = helpers_js_1._deepClone(document);
|
|
4194
|
-
}
|
|
4195
|
-
var path21 = operation.path || "";
|
|
4196
|
-
var keys = path21.split("/");
|
|
4197
|
-
var obj = document;
|
|
4198
|
-
var t50 = 1;
|
|
4199
|
-
var len = keys.length;
|
|
4200
|
-
var existingPathFragment = void 0;
|
|
4201
|
-
var key = void 0;
|
|
4202
|
-
var validateFunction = void 0;
|
|
4203
|
-
if (typeof validateOperation2 == "function") {
|
|
4204
|
-
validateFunction = validateOperation2;
|
|
4205
|
-
} else {
|
|
4206
|
-
validateFunction = validator;
|
|
4207
|
-
}
|
|
4208
|
-
while (true) {
|
|
4209
|
-
key = keys[t50];
|
|
4210
|
-
if (key && key.indexOf("~") != -1) {
|
|
4211
|
-
key = helpers_js_1.unescapePathComponent(key);
|
|
4212
|
-
}
|
|
4213
|
-
if (banPrototypeModifications && (key == "__proto__" || key == "prototype" && t50 > 0 && keys[t50 - 1] == "constructor")) {
|
|
4214
|
-
throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");
|
|
4215
|
-
}
|
|
4216
|
-
if (validateOperation2) {
|
|
4217
|
-
if (existingPathFragment === void 0) {
|
|
4218
|
-
if (obj[key] === void 0) {
|
|
4219
|
-
existingPathFragment = keys.slice(0, t50).join("/");
|
|
4220
|
-
} else if (t50 == len - 1) {
|
|
4221
|
-
existingPathFragment = operation.path;
|
|
4222
|
-
}
|
|
4223
|
-
if (existingPathFragment !== void 0) {
|
|
4224
|
-
validateFunction(operation, 0, document, existingPathFragment);
|
|
4225
|
-
}
|
|
4226
|
-
}
|
|
4227
|
-
}
|
|
4228
|
-
t50++;
|
|
4229
|
-
if (Array.isArray(obj)) {
|
|
4230
|
-
if (key === "-") {
|
|
4231
|
-
key = obj.length;
|
|
4232
|
-
} else {
|
|
4233
|
-
if (validateOperation2 && !helpers_js_1.isInteger(key)) {
|
|
4234
|
-
throw new exports.JsonPatchError("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", index, operation, document);
|
|
4235
|
-
} else if (helpers_js_1.isInteger(key)) {
|
|
4236
|
-
key = ~~key;
|
|
4237
|
-
}
|
|
4238
|
-
}
|
|
4239
|
-
if (t50 >= len) {
|
|
4240
|
-
if (validateOperation2 && operation.op === "add" && key > obj.length) {
|
|
4241
|
-
throw new exports.JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", index, operation, document);
|
|
4242
|
-
}
|
|
4243
|
-
var returnValue = arrOps[operation.op].call(operation, obj, key, document);
|
|
4244
|
-
if (returnValue.test === false) {
|
|
4245
|
-
throw new exports.JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
|
|
4246
|
-
}
|
|
4247
|
-
return returnValue;
|
|
4248
|
-
}
|
|
4249
|
-
} else {
|
|
4250
|
-
if (t50 >= len) {
|
|
4251
|
-
var returnValue = objOps[operation.op].call(operation, obj, key, document);
|
|
4252
|
-
if (returnValue.test === false) {
|
|
4253
|
-
throw new exports.JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
|
|
4254
|
-
}
|
|
4255
|
-
return returnValue;
|
|
4256
|
-
}
|
|
4257
|
-
}
|
|
4258
|
-
obj = obj[key];
|
|
4259
|
-
if (validateOperation2 && t50 < len && (!obj || typeof obj !== "object")) {
|
|
4260
|
-
throw new exports.JsonPatchError("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", index, operation, document);
|
|
4261
|
-
}
|
|
4262
|
-
}
|
|
4263
|
-
}
|
|
4264
|
-
}
|
|
4265
|
-
exports.applyOperation = applyOperation3;
|
|
4266
|
-
function applyPatch3(document, patch, validateOperation2, mutateDocument, banPrototypeModifications) {
|
|
4267
|
-
if (mutateDocument === void 0) {
|
|
4268
|
-
mutateDocument = true;
|
|
4269
|
-
}
|
|
4270
|
-
if (banPrototypeModifications === void 0) {
|
|
4271
|
-
banPrototypeModifications = true;
|
|
4272
|
-
}
|
|
4273
|
-
if (validateOperation2) {
|
|
4274
|
-
if (!Array.isArray(patch)) {
|
|
4275
|
-
throw new exports.JsonPatchError("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
|
|
4276
|
-
}
|
|
4277
|
-
}
|
|
4278
|
-
if (!mutateDocument) {
|
|
4279
|
-
document = helpers_js_1._deepClone(document);
|
|
4280
|
-
}
|
|
4281
|
-
var results = new Array(patch.length);
|
|
4282
|
-
for (var i58 = 0, length_1 = patch.length; i58 < length_1; i58++) {
|
|
4283
|
-
results[i58] = applyOperation3(document, patch[i58], validateOperation2, true, banPrototypeModifications, i58);
|
|
4284
|
-
document = results[i58].newDocument;
|
|
4285
|
-
}
|
|
4286
|
-
results.newDocument = document;
|
|
4287
|
-
return results;
|
|
4288
|
-
}
|
|
4289
|
-
exports.applyPatch = applyPatch3;
|
|
4290
|
-
function applyReducer(document, operation, index) {
|
|
4291
|
-
var operationResult = applyOperation3(document, operation);
|
|
4292
|
-
if (operationResult.test === false) {
|
|
4293
|
-
throw new exports.JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
|
|
4294
|
-
}
|
|
4295
|
-
return operationResult.newDocument;
|
|
4296
|
-
}
|
|
4297
|
-
exports.applyReducer = applyReducer;
|
|
4298
|
-
function validator(operation, index, document, existingPathFragment) {
|
|
4299
|
-
if (typeof operation !== "object" || operation === null || Array.isArray(operation)) {
|
|
4300
|
-
throw new exports.JsonPatchError("Operation is not an object", "OPERATION_NOT_AN_OBJECT", index, operation, document);
|
|
4301
|
-
} else if (!objOps[operation.op]) {
|
|
4302
|
-
throw new exports.JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document);
|
|
4303
|
-
} else if (typeof operation.path !== "string") {
|
|
4304
|
-
throw new exports.JsonPatchError("Operation `path` property is not a string", "OPERATION_PATH_INVALID", index, operation, document);
|
|
4305
|
-
} else if (operation.path.indexOf("/") !== 0 && operation.path.length > 0) {
|
|
4306
|
-
throw new exports.JsonPatchError('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", index, operation, document);
|
|
4307
|
-
} else if ((operation.op === "move" || operation.op === "copy") && typeof operation.from !== "string") {
|
|
4308
|
-
throw new exports.JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", index, operation, document);
|
|
4309
|
-
} else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && operation.value === void 0) {
|
|
4310
|
-
throw new exports.JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", index, operation, document);
|
|
4311
|
-
} else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && helpers_js_1.hasUndefined(operation.value)) {
|
|
4312
|
-
throw new exports.JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", index, operation, document);
|
|
4313
|
-
} else if (document) {
|
|
4314
|
-
if (operation.op == "add") {
|
|
4315
|
-
var pathLen = operation.path.split("/").length;
|
|
4316
|
-
var existingPathLen = existingPathFragment.split("/").length;
|
|
4317
|
-
if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {
|
|
4318
|
-
throw new exports.JsonPatchError("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", index, operation, document);
|
|
4319
|
-
}
|
|
4320
|
-
} else if (operation.op === "replace" || operation.op === "remove" || operation.op === "_get") {
|
|
4321
|
-
if (operation.path !== existingPathFragment) {
|
|
4322
|
-
throw new exports.JsonPatchError("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", index, operation, document);
|
|
4323
|
-
}
|
|
4324
|
-
} else if (operation.op === "move" || operation.op === "copy") {
|
|
4325
|
-
var existingValue = { op: "_get", path: operation.from, value: void 0 };
|
|
4326
|
-
var error = validate3([existingValue], document);
|
|
4327
|
-
if (error && error.name === "OPERATION_PATH_UNRESOLVABLE") {
|
|
4328
|
-
throw new exports.JsonPatchError("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", index, operation, document);
|
|
4329
|
-
}
|
|
4330
|
-
}
|
|
4331
|
-
}
|
|
4332
|
-
}
|
|
4333
|
-
exports.validator = validator;
|
|
4334
|
-
function validate3(sequence, document, externalValidator) {
|
|
4335
|
-
try {
|
|
4336
|
-
if (!Array.isArray(sequence)) {
|
|
4337
|
-
throw new exports.JsonPatchError("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
|
|
4338
|
-
}
|
|
4339
|
-
if (document) {
|
|
4340
|
-
applyPatch3(helpers_js_1._deepClone(document), helpers_js_1._deepClone(sequence), externalValidator || true);
|
|
4341
|
-
} else {
|
|
4342
|
-
externalValidator = externalValidator || validator;
|
|
4343
|
-
for (var i58 = 0; i58 < sequence.length; i58++) {
|
|
4344
|
-
externalValidator(sequence[i58], i58, document, void 0);
|
|
4345
|
-
}
|
|
4346
|
-
}
|
|
4347
|
-
} catch (e20) {
|
|
4348
|
-
if (e20 instanceof exports.JsonPatchError) {
|
|
4349
|
-
return e20;
|
|
4350
|
-
} else {
|
|
4351
|
-
throw e20;
|
|
4352
|
-
}
|
|
4353
|
-
}
|
|
4354
|
-
}
|
|
4355
|
-
exports.validate = validate3;
|
|
4356
|
-
function _areEquals(a37, b68) {
|
|
4357
|
-
if (a37 === b68)
|
|
4358
|
-
return true;
|
|
4359
|
-
if (a37 && b68 && typeof a37 == "object" && typeof b68 == "object") {
|
|
4360
|
-
var arrA = Array.isArray(a37), arrB = Array.isArray(b68), i58, length, key;
|
|
4361
|
-
if (arrA && arrB) {
|
|
4362
|
-
length = a37.length;
|
|
4363
|
-
if (length != b68.length)
|
|
4364
|
-
return false;
|
|
4365
|
-
for (i58 = length; i58-- !== 0; )
|
|
4366
|
-
if (!_areEquals(a37[i58], b68[i58]))
|
|
4367
|
-
return false;
|
|
4368
|
-
return true;
|
|
4369
|
-
}
|
|
4370
|
-
if (arrA != arrB)
|
|
4371
|
-
return false;
|
|
4372
|
-
var keys = Object.keys(a37);
|
|
4373
|
-
length = keys.length;
|
|
4374
|
-
if (length !== Object.keys(b68).length)
|
|
4375
|
-
return false;
|
|
4376
|
-
for (i58 = length; i58-- !== 0; )
|
|
4377
|
-
if (!b68.hasOwnProperty(keys[i58]))
|
|
4378
|
-
return false;
|
|
4379
|
-
for (i58 = length; i58-- !== 0; ) {
|
|
4380
|
-
key = keys[i58];
|
|
4381
|
-
if (!_areEquals(a37[key], b68[key]))
|
|
4382
|
-
return false;
|
|
4383
|
-
}
|
|
4384
|
-
return true;
|
|
4385
|
-
}
|
|
4386
|
-
return a37 !== a37 && b68 !== b68;
|
|
4387
|
-
}
|
|
4388
|
-
exports._areEquals = _areEquals;
|
|
4389
|
-
}
|
|
4390
|
-
});
|
|
4391
|
-
|
|
4392
|
-
// node_modules/fast-json-patch/commonjs/duplex.js
|
|
4393
|
-
var require_duplex = __commonJS({
|
|
4394
|
-
"node_modules/fast-json-patch/commonjs/duplex.js"(exports) {
|
|
4395
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4396
|
-
var helpers_js_1 = require_helpers();
|
|
4397
|
-
var core_js_1 = require_core();
|
|
4398
|
-
var beforeDict = /* @__PURE__ */ new WeakMap();
|
|
4399
|
-
var Mirror = (
|
|
4400
|
-
/** @class */
|
|
4401
|
-
/* @__PURE__ */ (function() {
|
|
4402
|
-
function Mirror2(obj) {
|
|
4403
|
-
this.observers = /* @__PURE__ */ new Map();
|
|
4404
|
-
this.obj = obj;
|
|
4405
|
-
}
|
|
4406
|
-
return Mirror2;
|
|
4407
|
-
})()
|
|
4408
|
-
);
|
|
4409
|
-
var ObserverInfo = (
|
|
4410
|
-
/** @class */
|
|
4411
|
-
/* @__PURE__ */ (function() {
|
|
4412
|
-
function ObserverInfo2(callback, observer) {
|
|
4413
|
-
this.callback = callback;
|
|
4414
|
-
this.observer = observer;
|
|
4415
|
-
}
|
|
4416
|
-
return ObserverInfo2;
|
|
4417
|
-
})()
|
|
4418
|
-
);
|
|
4419
|
-
function getMirror(obj) {
|
|
4420
|
-
return beforeDict.get(obj);
|
|
4421
|
-
}
|
|
4422
|
-
function getObserverFromMirror(mirror, callback) {
|
|
4423
|
-
return mirror.observers.get(callback);
|
|
4424
|
-
}
|
|
4425
|
-
function removeObserverFromMirror(mirror, observer) {
|
|
4426
|
-
mirror.observers.delete(observer.callback);
|
|
4427
|
-
}
|
|
4428
|
-
function unobserve3(root, observer) {
|
|
4429
|
-
observer.unobserve();
|
|
4430
|
-
}
|
|
4431
|
-
exports.unobserve = unobserve3;
|
|
4432
|
-
function observe3(obj, callback) {
|
|
4433
|
-
var patches = [];
|
|
4434
|
-
var observer;
|
|
4435
|
-
var mirror = getMirror(obj);
|
|
4436
|
-
if (!mirror) {
|
|
4437
|
-
mirror = new Mirror(obj);
|
|
4438
|
-
beforeDict.set(obj, mirror);
|
|
4439
|
-
} else {
|
|
4440
|
-
var observerInfo = getObserverFromMirror(mirror, callback);
|
|
4441
|
-
observer = observerInfo && observerInfo.observer;
|
|
4442
|
-
}
|
|
4443
|
-
if (observer) {
|
|
4444
|
-
return observer;
|
|
4445
|
-
}
|
|
4446
|
-
observer = {};
|
|
4447
|
-
mirror.value = helpers_js_1._deepClone(obj);
|
|
4448
|
-
if (callback) {
|
|
4449
|
-
observer.callback = callback;
|
|
4450
|
-
observer.next = null;
|
|
4451
|
-
var dirtyCheck = function() {
|
|
4452
|
-
generate2(observer);
|
|
4453
|
-
};
|
|
4454
|
-
var fastCheck = function() {
|
|
4455
|
-
clearTimeout(observer.next);
|
|
4456
|
-
observer.next = setTimeout(dirtyCheck);
|
|
4457
|
-
};
|
|
4458
|
-
if (typeof window !== "undefined") {
|
|
4459
|
-
window.addEventListener("mouseup", fastCheck);
|
|
4460
|
-
window.addEventListener("keyup", fastCheck);
|
|
4461
|
-
window.addEventListener("mousedown", fastCheck);
|
|
4462
|
-
window.addEventListener("keydown", fastCheck);
|
|
4463
|
-
window.addEventListener("change", fastCheck);
|
|
4464
|
-
}
|
|
4465
|
-
}
|
|
4466
|
-
observer.patches = patches;
|
|
4467
|
-
observer.object = obj;
|
|
4468
|
-
observer.unobserve = function() {
|
|
4469
|
-
generate2(observer);
|
|
4470
|
-
clearTimeout(observer.next);
|
|
4471
|
-
removeObserverFromMirror(mirror, observer);
|
|
4472
|
-
if (typeof window !== "undefined") {
|
|
4473
|
-
window.removeEventListener("mouseup", fastCheck);
|
|
4474
|
-
window.removeEventListener("keyup", fastCheck);
|
|
4475
|
-
window.removeEventListener("mousedown", fastCheck);
|
|
4476
|
-
window.removeEventListener("keydown", fastCheck);
|
|
4477
|
-
window.removeEventListener("change", fastCheck);
|
|
4478
|
-
}
|
|
4479
|
-
};
|
|
4480
|
-
mirror.observers.set(callback, new ObserverInfo(callback, observer));
|
|
4481
|
-
return observer;
|
|
4482
|
-
}
|
|
4483
|
-
exports.observe = observe3;
|
|
4484
|
-
function generate2(observer, invertible) {
|
|
4485
|
-
if (invertible === void 0) {
|
|
4486
|
-
invertible = false;
|
|
4487
|
-
}
|
|
4488
|
-
var mirror = beforeDict.get(observer.object);
|
|
4489
|
-
_generate(mirror.value, observer.object, observer.patches, "", invertible);
|
|
4490
|
-
if (observer.patches.length) {
|
|
4491
|
-
core_js_1.applyPatch(mirror.value, observer.patches);
|
|
4492
|
-
}
|
|
4493
|
-
var temp = observer.patches;
|
|
4494
|
-
if (temp.length > 0) {
|
|
4495
|
-
observer.patches = [];
|
|
4496
|
-
if (observer.callback) {
|
|
4497
|
-
observer.callback(temp);
|
|
4498
|
-
}
|
|
4499
|
-
}
|
|
4500
|
-
return temp;
|
|
4501
|
-
}
|
|
4502
|
-
exports.generate = generate2;
|
|
4503
|
-
function _generate(mirror, obj, patches, path21, invertible) {
|
|
4504
|
-
if (obj === mirror) {
|
|
4505
|
-
return;
|
|
4506
|
-
}
|
|
4507
|
-
if (typeof obj.toJSON === "function") {
|
|
4508
|
-
obj = obj.toJSON();
|
|
4509
|
-
}
|
|
4510
|
-
var newKeys = helpers_js_1._objectKeys(obj);
|
|
4511
|
-
var oldKeys = helpers_js_1._objectKeys(mirror);
|
|
4512
|
-
var changed = false;
|
|
4513
|
-
var deleted = false;
|
|
4514
|
-
for (var t50 = oldKeys.length - 1; t50 >= 0; t50--) {
|
|
4515
|
-
var key = oldKeys[t50];
|
|
4516
|
-
var oldVal = mirror[key];
|
|
4517
|
-
if (helpers_js_1.hasOwnProperty(obj, key) && !(obj[key] === void 0 && oldVal !== void 0 && Array.isArray(obj) === false)) {
|
|
4518
|
-
var newVal = obj[key];
|
|
4519
|
-
if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null && Array.isArray(oldVal) === Array.isArray(newVal)) {
|
|
4520
|
-
_generate(oldVal, newVal, patches, path21 + "/" + helpers_js_1.escapePathComponent(key), invertible);
|
|
4521
|
-
} else {
|
|
4522
|
-
if (oldVal !== newVal) {
|
|
4523
|
-
changed = true;
|
|
4524
|
-
if (invertible) {
|
|
4525
|
-
patches.push({ op: "test", path: path21 + "/" + helpers_js_1.escapePathComponent(key), value: helpers_js_1._deepClone(oldVal) });
|
|
4526
|
-
}
|
|
4527
|
-
patches.push({ op: "replace", path: path21 + "/" + helpers_js_1.escapePathComponent(key), value: helpers_js_1._deepClone(newVal) });
|
|
4528
|
-
}
|
|
4529
|
-
}
|
|
4530
|
-
} else if (Array.isArray(mirror) === Array.isArray(obj)) {
|
|
4531
|
-
if (invertible) {
|
|
4532
|
-
patches.push({ op: "test", path: path21 + "/" + helpers_js_1.escapePathComponent(key), value: helpers_js_1._deepClone(oldVal) });
|
|
4533
|
-
}
|
|
4534
|
-
patches.push({ op: "remove", path: path21 + "/" + helpers_js_1.escapePathComponent(key) });
|
|
4535
|
-
deleted = true;
|
|
4536
|
-
} else {
|
|
4537
|
-
if (invertible) {
|
|
4538
|
-
patches.push({ op: "test", path: path21, value: mirror });
|
|
4539
|
-
}
|
|
4540
|
-
patches.push({ op: "replace", path: path21, value: obj });
|
|
4541
|
-
changed = true;
|
|
4542
|
-
}
|
|
4543
|
-
}
|
|
4544
|
-
if (!deleted && newKeys.length == oldKeys.length) {
|
|
4545
|
-
return;
|
|
4546
|
-
}
|
|
4547
|
-
for (var t50 = 0; t50 < newKeys.length; t50++) {
|
|
4548
|
-
var key = newKeys[t50];
|
|
4549
|
-
if (!helpers_js_1.hasOwnProperty(mirror, key) && obj[key] !== void 0) {
|
|
4550
|
-
patches.push({ op: "add", path: path21 + "/" + helpers_js_1.escapePathComponent(key), value: helpers_js_1._deepClone(obj[key]) });
|
|
4551
|
-
}
|
|
4552
|
-
}
|
|
4553
|
-
}
|
|
4554
|
-
function compare2(tree1, tree2, invertible) {
|
|
4555
|
-
if (invertible === void 0) {
|
|
4556
|
-
invertible = false;
|
|
4557
|
-
}
|
|
4558
|
-
var patches = [];
|
|
4559
|
-
_generate(tree1, tree2, patches, "", invertible);
|
|
4560
|
-
return patches;
|
|
4561
|
-
}
|
|
4562
|
-
exports.compare = compare2;
|
|
4563
|
-
}
|
|
4564
|
-
});
|
|
4565
|
-
|
|
4566
|
-
// node_modules/fast-json-patch/index.js
|
|
4567
|
-
var require_fast_json_patch = __commonJS({
|
|
4568
|
-
"node_modules/fast-json-patch/index.js"(exports) {
|
|
4569
|
-
var core = require_core();
|
|
4570
|
-
Object.assign(exports, core);
|
|
4571
|
-
var duplex = require_duplex();
|
|
4572
|
-
Object.assign(exports, duplex);
|
|
4573
|
-
var helpers = require_helpers();
|
|
4574
|
-
exports.JsonPatchError = helpers.PatchError;
|
|
4575
|
-
exports.deepClone = helpers._deepClone;
|
|
4576
|
-
exports.escapePathComponent = helpers.escapePathComponent;
|
|
4577
|
-
exports.unescapePathComponent = helpers.unescapePathComponent;
|
|
4578
|
-
}
|
|
4579
|
-
});
|
|
4580
|
-
|
|
4581
3891
|
// src/kernel/constants.ts
|
|
4582
3892
|
var MEMORY_CONSTANTS, HNSW_CONSTANTS, AGENT_CONSTANTS, EVENT_BUS_CONSTANTS;
|
|
4583
3893
|
var init_constants = __esm({
|
|
@@ -4715,6 +4025,51 @@ var init_vector_math = __esm({
|
|
|
4715
4025
|
}
|
|
4716
4026
|
});
|
|
4717
4027
|
|
|
4028
|
+
// native-require:better-sqlite3
|
|
4029
|
+
var better_sqlite3_exports = {};
|
|
4030
|
+
__export(better_sqlite3_exports, {
|
|
4031
|
+
DotProductAttention: () => DotProductAttention,
|
|
4032
|
+
FlashAttention: () => FlashAttention,
|
|
4033
|
+
HyperbolicAttention: () => HyperbolicAttention,
|
|
4034
|
+
LinearAttention: () => LinearAttention,
|
|
4035
|
+
MoEAttention: () => MoEAttention,
|
|
4036
|
+
MultiHeadAttention: () => MultiHeadAttention,
|
|
4037
|
+
RuvectorLayer: () => RuvectorLayer,
|
|
4038
|
+
SonaEngine: () => SonaEngine,
|
|
4039
|
+
TensorCompress: () => TensorCompress,
|
|
4040
|
+
default: () => better_sqlite3_default,
|
|
4041
|
+
differentiableSearch: () => differentiableSearch,
|
|
4042
|
+
getCompressionLevel: () => getCompressionLevel,
|
|
4043
|
+
hierarchicalForward: () => hierarchicalForward,
|
|
4044
|
+
init: () => init,
|
|
4045
|
+
pipeline: () => pipeline
|
|
4046
|
+
});
|
|
4047
|
+
import { createRequire } from "module";
|
|
4048
|
+
var __require2, __mod, better_sqlite3_default, RuvectorLayer, TensorCompress, differentiableSearch, hierarchicalForward, getCompressionLevel, init, FlashAttention, DotProductAttention, MultiHeadAttention, HyperbolicAttention, LinearAttention, MoEAttention, SonaEngine, pipeline;
|
|
4049
|
+
var init_better_sqlite3 = __esm({
|
|
4050
|
+
"native-require:better-sqlite3"() {
|
|
4051
|
+
__require2 = createRequire(import.meta.url);
|
|
4052
|
+
__mod = __require2("better-sqlite3");
|
|
4053
|
+
better_sqlite3_default = __mod;
|
|
4054
|
+
({
|
|
4055
|
+
RuvectorLayer,
|
|
4056
|
+
TensorCompress,
|
|
4057
|
+
differentiableSearch,
|
|
4058
|
+
hierarchicalForward,
|
|
4059
|
+
getCompressionLevel,
|
|
4060
|
+
init,
|
|
4061
|
+
FlashAttention,
|
|
4062
|
+
DotProductAttention,
|
|
4063
|
+
MultiHeadAttention,
|
|
4064
|
+
HyperbolicAttention,
|
|
4065
|
+
LinearAttention,
|
|
4066
|
+
MoEAttention,
|
|
4067
|
+
SonaEngine,
|
|
4068
|
+
pipeline
|
|
4069
|
+
} = __mod || {});
|
|
4070
|
+
}
|
|
4071
|
+
});
|
|
4072
|
+
|
|
4718
4073
|
// src/migrations/20260120_add_hypergraph_tables.ts
|
|
4719
4074
|
function isMigrationApplied(db) {
|
|
4720
4075
|
try {
|
|
@@ -4824,6 +4179,10 @@ var init_sql_safety = __esm({
|
|
|
4824
4179
|
"mincut_observations",
|
|
4825
4180
|
// SONA tables
|
|
4826
4181
|
"sona_patterns",
|
|
4182
|
+
// Feedback loop tables
|
|
4183
|
+
"test_outcomes",
|
|
4184
|
+
"routing_outcomes",
|
|
4185
|
+
"coverage_sessions",
|
|
4827
4186
|
// Sync tables
|
|
4828
4187
|
"patterns",
|
|
4829
4188
|
// Hypergraph tables
|
|
@@ -5759,7 +5118,6 @@ __export(unified_memory_exports, {
|
|
|
5759
5118
|
resetUnifiedMemory: () => resetUnifiedMemory,
|
|
5760
5119
|
validateTableName: () => validateTableName
|
|
5761
5120
|
});
|
|
5762
|
-
import Database from "better-sqlite3";
|
|
5763
5121
|
import * as fs from "fs";
|
|
5764
5122
|
import * as path from "path";
|
|
5765
5123
|
function findProjectRoot(startDir = process.cwd()) {
|
|
@@ -5769,12 +5127,16 @@ function findProjectRoot(startDir = process.cwd()) {
|
|
|
5769
5127
|
let dir = startDir;
|
|
5770
5128
|
const root = path.parse(dir).root;
|
|
5771
5129
|
let checkDir = dir;
|
|
5130
|
+
let topmostAqeDir = null;
|
|
5772
5131
|
while (checkDir !== root) {
|
|
5773
5132
|
if (fs.existsSync(path.join(checkDir, ".agentic-qe"))) {
|
|
5774
|
-
|
|
5133
|
+
topmostAqeDir = checkDir;
|
|
5775
5134
|
}
|
|
5776
5135
|
checkDir = path.dirname(checkDir);
|
|
5777
5136
|
}
|
|
5137
|
+
if (topmostAqeDir) {
|
|
5138
|
+
return topmostAqeDir;
|
|
5139
|
+
}
|
|
5778
5140
|
checkDir = dir;
|
|
5779
5141
|
while (checkDir !== root) {
|
|
5780
5142
|
if (fs.existsSync(path.join(checkDir, ".git"))) {
|
|
@@ -5839,10 +5201,11 @@ function registerExitHandlers() {
|
|
|
5839
5201
|
process.exit(0);
|
|
5840
5202
|
});
|
|
5841
5203
|
}
|
|
5842
|
-
var DEFAULT_UNIFIED_MEMORY_CONFIG, SCHEMA_VERSION, SCHEMA_VERSION_TABLE, KV_STORE_SCHEMA, VECTORS_SCHEMA, RL_QVALUES_SCHEMA, GOAP_SCHEMA, DREAM_SCHEMA, QE_PATTERNS_SCHEMA, MINCUT_SCHEMA, SONA_PATTERNS_SCHEMA, BinaryHeap, InMemoryHNSWIndex, UnifiedMemoryManager, exitHandlersRegistered;
|
|
5204
|
+
var DEFAULT_UNIFIED_MEMORY_CONFIG, SCHEMA_VERSION, SCHEMA_VERSION_TABLE, KV_STORE_SCHEMA, VECTORS_SCHEMA, RL_QVALUES_SCHEMA, GOAP_SCHEMA, DREAM_SCHEMA, QE_PATTERNS_SCHEMA, MINCUT_SCHEMA, SONA_PATTERNS_SCHEMA, FEEDBACK_SCHEMA, BinaryHeap, InMemoryHNSWIndex, UnifiedMemoryManager, exitHandlersRegistered;
|
|
5843
5205
|
var init_unified_memory = __esm({
|
|
5844
5206
|
"src/kernel/unified-memory.ts"() {
|
|
5845
5207
|
"use strict";
|
|
5208
|
+
init_better_sqlite3();
|
|
5846
5209
|
init_vector_math();
|
|
5847
5210
|
init_add_hypergraph_tables();
|
|
5848
5211
|
init_constants();
|
|
@@ -5858,7 +5221,7 @@ var init_unified_memory = __esm({
|
|
|
5858
5221
|
busyTimeout: MEMORY_CONSTANTS.BUSY_TIMEOUT_MS,
|
|
5859
5222
|
vectorDimensions: MEMORY_CONSTANTS.DEFAULT_VECTOR_DIMENSIONS
|
|
5860
5223
|
};
|
|
5861
|
-
SCHEMA_VERSION =
|
|
5224
|
+
SCHEMA_VERSION = 8;
|
|
5862
5225
|
SCHEMA_VERSION_TABLE = `
|
|
5863
5226
|
CREATE TABLE IF NOT EXISTS schema_version (
|
|
5864
5227
|
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
@@ -6110,15 +5473,14 @@ var init_unified_memory = __esm({
|
|
|
6110
5473
|
FOREIGN KEY (pattern_id) REFERENCES qe_patterns(id) ON DELETE CASCADE
|
|
6111
5474
|
);
|
|
6112
5475
|
|
|
6113
|
-
-- Pattern usage history
|
|
5476
|
+
-- Pattern usage history (no FK \u2014 used as analytics log by hooks with synthetic IDs)
|
|
6114
5477
|
CREATE TABLE IF NOT EXISTS qe_pattern_usage (
|
|
6115
5478
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
6116
5479
|
pattern_id TEXT NOT NULL,
|
|
6117
5480
|
success INTEGER NOT NULL,
|
|
6118
5481
|
metrics_json TEXT,
|
|
6119
5482
|
feedback TEXT,
|
|
6120
|
-
created_at TEXT DEFAULT (datetime('now'))
|
|
6121
|
-
FOREIGN KEY (pattern_id) REFERENCES qe_patterns(id) ON DELETE CASCADE
|
|
5483
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
6122
5484
|
);
|
|
6123
5485
|
|
|
6124
5486
|
-- Learning trajectories
|
|
@@ -6330,6 +5692,81 @@ var init_unified_memory = __esm({
|
|
|
6330
5692
|
CREATE INDEX IF NOT EXISTS idx_sona_patterns_domain ON sona_patterns(domain);
|
|
6331
5693
|
CREATE INDEX IF NOT EXISTS idx_sona_patterns_confidence ON sona_patterns(confidence DESC);
|
|
6332
5694
|
CREATE INDEX IF NOT EXISTS idx_sona_patterns_updated ON sona_patterns(updated_at DESC);
|
|
5695
|
+
`;
|
|
5696
|
+
FEEDBACK_SCHEMA = `
|
|
5697
|
+
-- Test outcomes (ADR-023: Quality Feedback Loop)
|
|
5698
|
+
CREATE TABLE IF NOT EXISTS test_outcomes (
|
|
5699
|
+
id TEXT PRIMARY KEY,
|
|
5700
|
+
test_id TEXT NOT NULL,
|
|
5701
|
+
test_name TEXT NOT NULL,
|
|
5702
|
+
generated_by TEXT NOT NULL,
|
|
5703
|
+
pattern_id TEXT,
|
|
5704
|
+
framework TEXT NOT NULL,
|
|
5705
|
+
language TEXT NOT NULL,
|
|
5706
|
+
domain TEXT NOT NULL,
|
|
5707
|
+
passed INTEGER NOT NULL,
|
|
5708
|
+
error_message TEXT,
|
|
5709
|
+
coverage_lines REAL DEFAULT 0,
|
|
5710
|
+
coverage_branches REAL DEFAULT 0,
|
|
5711
|
+
coverage_functions REAL DEFAULT 0,
|
|
5712
|
+
mutation_score REAL,
|
|
5713
|
+
execution_time_ms REAL NOT NULL,
|
|
5714
|
+
flaky INTEGER DEFAULT 0,
|
|
5715
|
+
flakiness_score REAL,
|
|
5716
|
+
maintainability_score REAL NOT NULL,
|
|
5717
|
+
complexity REAL,
|
|
5718
|
+
lines_of_code INTEGER,
|
|
5719
|
+
assertion_count INTEGER,
|
|
5720
|
+
file_path TEXT,
|
|
5721
|
+
source_file_path TEXT,
|
|
5722
|
+
metadata_json TEXT,
|
|
5723
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
5724
|
+
);
|
|
5725
|
+
CREATE INDEX IF NOT EXISTS idx_test_outcomes_pattern ON test_outcomes(pattern_id);
|
|
5726
|
+
CREATE INDEX IF NOT EXISTS idx_test_outcomes_agent ON test_outcomes(generated_by);
|
|
5727
|
+
CREATE INDEX IF NOT EXISTS idx_test_outcomes_domain ON test_outcomes(domain);
|
|
5728
|
+
CREATE INDEX IF NOT EXISTS idx_test_outcomes_created ON test_outcomes(created_at);
|
|
5729
|
+
|
|
5730
|
+
-- Routing outcomes (ADR-022: Adaptive QE Agent Routing)
|
|
5731
|
+
CREATE TABLE IF NOT EXISTS routing_outcomes (
|
|
5732
|
+
id TEXT PRIMARY KEY,
|
|
5733
|
+
task_json TEXT NOT NULL,
|
|
5734
|
+
decision_json TEXT NOT NULL,
|
|
5735
|
+
used_agent TEXT NOT NULL,
|
|
5736
|
+
followed_recommendation INTEGER NOT NULL,
|
|
5737
|
+
success INTEGER NOT NULL,
|
|
5738
|
+
quality_score REAL NOT NULL,
|
|
5739
|
+
duration_ms REAL NOT NULL,
|
|
5740
|
+
error TEXT,
|
|
5741
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
5742
|
+
);
|
|
5743
|
+
CREATE INDEX IF NOT EXISTS idx_routing_outcomes_agent ON routing_outcomes(used_agent);
|
|
5744
|
+
CREATE INDEX IF NOT EXISTS idx_routing_outcomes_created ON routing_outcomes(created_at);
|
|
5745
|
+
|
|
5746
|
+
-- Coverage sessions (ADR-023: Coverage Learning)
|
|
5747
|
+
CREATE TABLE IF NOT EXISTS coverage_sessions (
|
|
5748
|
+
id TEXT PRIMARY KEY,
|
|
5749
|
+
target_path TEXT NOT NULL,
|
|
5750
|
+
agent_id TEXT NOT NULL,
|
|
5751
|
+
technique TEXT NOT NULL,
|
|
5752
|
+
before_lines REAL DEFAULT 0,
|
|
5753
|
+
before_branches REAL DEFAULT 0,
|
|
5754
|
+
before_functions REAL DEFAULT 0,
|
|
5755
|
+
after_lines REAL DEFAULT 0,
|
|
5756
|
+
after_branches REAL DEFAULT 0,
|
|
5757
|
+
after_functions REAL DEFAULT 0,
|
|
5758
|
+
tests_generated INTEGER DEFAULT 0,
|
|
5759
|
+
tests_passed INTEGER DEFAULT 0,
|
|
5760
|
+
gaps_json TEXT,
|
|
5761
|
+
duration_ms REAL NOT NULL,
|
|
5762
|
+
started_at TEXT NOT NULL,
|
|
5763
|
+
completed_at TEXT NOT NULL,
|
|
5764
|
+
context_json TEXT,
|
|
5765
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
5766
|
+
);
|
|
5767
|
+
CREATE INDEX IF NOT EXISTS idx_coverage_sessions_technique ON coverage_sessions(technique);
|
|
5768
|
+
CREATE INDEX IF NOT EXISTS idx_coverage_sessions_agent ON coverage_sessions(agent_id);
|
|
5769
|
+
CREATE INDEX IF NOT EXISTS idx_coverage_sessions_created ON coverage_sessions(created_at);
|
|
6333
5770
|
`;
|
|
6334
5771
|
BinaryHeap = class {
|
|
6335
5772
|
data = [];
|
|
@@ -6669,6 +6106,7 @@ var init_unified_memory = __esm({
|
|
|
6669
6106
|
db = null;
|
|
6670
6107
|
config;
|
|
6671
6108
|
initialized = false;
|
|
6109
|
+
vectorsLoaded = false;
|
|
6672
6110
|
initPromise = null;
|
|
6673
6111
|
preparedStatements = /* @__PURE__ */ new Map();
|
|
6674
6112
|
vectorIndex = new InMemoryHNSWIndex();
|
|
@@ -6737,7 +6175,7 @@ var init_unified_memory = __esm({
|
|
|
6737
6175
|
if (!fs.existsSync(dir)) {
|
|
6738
6176
|
fs.mkdirSync(dir, { recursive: true });
|
|
6739
6177
|
}
|
|
6740
|
-
this.db = new
|
|
6178
|
+
this.db = new better_sqlite3_default(this.config.dbPath);
|
|
6741
6179
|
if (this.config.walMode) {
|
|
6742
6180
|
this.db.pragma("journal_mode = WAL");
|
|
6743
6181
|
}
|
|
@@ -6746,7 +6184,7 @@ var init_unified_memory = __esm({
|
|
|
6746
6184
|
this.db.pragma(`busy_timeout = ${this.config.busyTimeout}`);
|
|
6747
6185
|
this.db.pragma("foreign_keys = ON");
|
|
6748
6186
|
await this.runMigrations();
|
|
6749
|
-
|
|
6187
|
+
this.vectorsLoaded = false;
|
|
6750
6188
|
this.initialized = true;
|
|
6751
6189
|
console.log(`[UnifiedMemory] Initialized: ${this.config.dbPath}`);
|
|
6752
6190
|
this.warnIfDuplicateDatabases();
|
|
@@ -6867,6 +6305,9 @@ var init_unified_memory = __esm({
|
|
|
6867
6305
|
if (currentVersion < 7) {
|
|
6868
6306
|
this.db.exec(SONA_PATTERNS_SCHEMA);
|
|
6869
6307
|
}
|
|
6308
|
+
if (currentVersion < 8) {
|
|
6309
|
+
this.db.exec(FEEDBACK_SCHEMA);
|
|
6310
|
+
}
|
|
6870
6311
|
this.db.prepare(`
|
|
6871
6312
|
INSERT OR REPLACE INTO schema_version (id, version, migrated_at)
|
|
6872
6313
|
VALUES (1, ?, datetime('now'))
|
|
@@ -6880,6 +6321,7 @@ var init_unified_memory = __esm({
|
|
|
6880
6321
|
* Load all vectors from SQLite into HNSW index
|
|
6881
6322
|
*/
|
|
6882
6323
|
async loadVectorIndex() {
|
|
6324
|
+
if (this.vectorsLoaded) return;
|
|
6883
6325
|
if (!this.db) throw new Error("Database not initialized");
|
|
6884
6326
|
this.vectorIndex.clear();
|
|
6885
6327
|
const rows = this.db.prepare(
|
|
@@ -6889,6 +6331,7 @@ var init_unified_memory = __esm({
|
|
|
6889
6331
|
const embedding = this.bufferToFloatArray(row2.embedding, row2.dimensions);
|
|
6890
6332
|
this.vectorIndex.add(row2.id, embedding);
|
|
6891
6333
|
}
|
|
6334
|
+
this.vectorsLoaded = true;
|
|
6892
6335
|
console.log(`[UnifiedMemory] Loaded ${rows.length} vectors into HNSW index`);
|
|
6893
6336
|
}
|
|
6894
6337
|
// ============================================================================
|
|
@@ -7012,6 +6455,9 @@ var init_unified_memory = __esm({
|
|
|
7012
6455
|
*/
|
|
7013
6456
|
async vectorSearch(query, k68 = 10, namespace) {
|
|
7014
6457
|
this.ensureInitialized();
|
|
6458
|
+
if (!this.vectorsLoaded) {
|
|
6459
|
+
await this.loadVectorIndex();
|
|
6460
|
+
}
|
|
7015
6461
|
const results = this.vectorIndex.search(query, k68 * 2);
|
|
7016
6462
|
if (results.length === 0) return [];
|
|
7017
6463
|
const ids = results.map((r54) => r54.id);
|
|
@@ -7416,6 +6862,51 @@ var init_unified_memory = __esm({
|
|
|
7416
6862
|
}
|
|
7417
6863
|
});
|
|
7418
6864
|
|
|
6865
|
+
// native-require:@xenova/transformers
|
|
6866
|
+
var transformers_exports = {};
|
|
6867
|
+
__export(transformers_exports, {
|
|
6868
|
+
DotProductAttention: () => DotProductAttention2,
|
|
6869
|
+
FlashAttention: () => FlashAttention2,
|
|
6870
|
+
HyperbolicAttention: () => HyperbolicAttention2,
|
|
6871
|
+
LinearAttention: () => LinearAttention2,
|
|
6872
|
+
MoEAttention: () => MoEAttention2,
|
|
6873
|
+
MultiHeadAttention: () => MultiHeadAttention2,
|
|
6874
|
+
RuvectorLayer: () => RuvectorLayer2,
|
|
6875
|
+
SonaEngine: () => SonaEngine2,
|
|
6876
|
+
TensorCompress: () => TensorCompress2,
|
|
6877
|
+
default: () => transformers_default,
|
|
6878
|
+
differentiableSearch: () => differentiableSearch2,
|
|
6879
|
+
getCompressionLevel: () => getCompressionLevel2,
|
|
6880
|
+
hierarchicalForward: () => hierarchicalForward2,
|
|
6881
|
+
init: () => init2,
|
|
6882
|
+
pipeline: () => pipeline2
|
|
6883
|
+
});
|
|
6884
|
+
import { createRequire as createRequire2 } from "module";
|
|
6885
|
+
var __require3, __mod2, transformers_default, RuvectorLayer2, TensorCompress2, differentiableSearch2, hierarchicalForward2, getCompressionLevel2, init2, FlashAttention2, DotProductAttention2, MultiHeadAttention2, HyperbolicAttention2, LinearAttention2, MoEAttention2, SonaEngine2, pipeline2;
|
|
6886
|
+
var init_transformers = __esm({
|
|
6887
|
+
"native-require:@xenova/transformers"() {
|
|
6888
|
+
__require3 = createRequire2(import.meta.url);
|
|
6889
|
+
__mod2 = __require3("@xenova/transformers");
|
|
6890
|
+
transformers_default = __mod2;
|
|
6891
|
+
({
|
|
6892
|
+
RuvectorLayer: RuvectorLayer2,
|
|
6893
|
+
TensorCompress: TensorCompress2,
|
|
6894
|
+
differentiableSearch: differentiableSearch2,
|
|
6895
|
+
hierarchicalForward: hierarchicalForward2,
|
|
6896
|
+
getCompressionLevel: getCompressionLevel2,
|
|
6897
|
+
init: init2,
|
|
6898
|
+
FlashAttention: FlashAttention2,
|
|
6899
|
+
DotProductAttention: DotProductAttention2,
|
|
6900
|
+
MultiHeadAttention: MultiHeadAttention2,
|
|
6901
|
+
HyperbolicAttention: HyperbolicAttention2,
|
|
6902
|
+
LinearAttention: LinearAttention2,
|
|
6903
|
+
MoEAttention: MoEAttention2,
|
|
6904
|
+
SonaEngine: SonaEngine2,
|
|
6905
|
+
pipeline: pipeline2
|
|
6906
|
+
} = __mod2 || {});
|
|
6907
|
+
}
|
|
6908
|
+
});
|
|
6909
|
+
|
|
7419
6910
|
// src/learning/real-embeddings.ts
|
|
7420
6911
|
var real_embeddings_exports = {};
|
|
7421
6912
|
__export(real_embeddings_exports, {
|
|
@@ -7439,11 +6930,11 @@ async function initializeModel(config = {}) {
|
|
|
7439
6930
|
const fullConfig = { ...DEFAULT_EMBEDDING_CONFIG, ...config };
|
|
7440
6931
|
initPromise = (async () => {
|
|
7441
6932
|
try {
|
|
7442
|
-
const transformers = await
|
|
7443
|
-
|
|
6933
|
+
const transformers = await Promise.resolve().then(() => (init_transformers(), transformers_exports));
|
|
6934
|
+
pipeline3 = transformers.pipeline;
|
|
7444
6935
|
console.log(`[RealEmbeddings] Loading model: ${fullConfig.modelName}`);
|
|
7445
6936
|
const startTime = performance.now();
|
|
7446
|
-
embeddingModel = await
|
|
6937
|
+
embeddingModel = await pipeline3("feature-extraction", fullConfig.modelName, {
|
|
7447
6938
|
quantized: fullConfig.quantized
|
|
7448
6939
|
});
|
|
7449
6940
|
const loadTime = performance.now() - startTime;
|
|
@@ -7561,19 +7052,19 @@ function getEmbeddingDimension() {
|
|
|
7561
7052
|
return 384;
|
|
7562
7053
|
}
|
|
7563
7054
|
function resetInitialization() {
|
|
7564
|
-
|
|
7055
|
+
pipeline3 = null;
|
|
7565
7056
|
embeddingModel = null;
|
|
7566
7057
|
initPromise = null;
|
|
7567
7058
|
initializationFailed = false;
|
|
7568
7059
|
failureReason = "";
|
|
7569
7060
|
embeddingCache.clear();
|
|
7570
7061
|
}
|
|
7571
|
-
var
|
|
7062
|
+
var pipeline3, embeddingModel, initPromise, initializationFailed, failureReason, DEFAULT_EMBEDDING_CONFIG, embeddingCache, CACHE_TTL_MS;
|
|
7572
7063
|
var init_real_embeddings = __esm({
|
|
7573
7064
|
"src/learning/real-embeddings.ts"() {
|
|
7574
7065
|
"use strict";
|
|
7575
7066
|
init_vector_math();
|
|
7576
|
-
|
|
7067
|
+
pipeline3 = null;
|
|
7577
7068
|
embeddingModel = null;
|
|
7578
7069
|
initPromise = null;
|
|
7579
7070
|
initializationFailed = false;
|
|
@@ -9408,8 +8899,52 @@ Format your response with: verdict (confirmed/rejected/uncertain), confidence (0
|
|
|
9408
8899
|
}
|
|
9409
8900
|
});
|
|
9410
8901
|
|
|
8902
|
+
// native-require:@ruvector/sona
|
|
8903
|
+
var sona_exports = {};
|
|
8904
|
+
__export(sona_exports, {
|
|
8905
|
+
DotProductAttention: () => DotProductAttention3,
|
|
8906
|
+
FlashAttention: () => FlashAttention3,
|
|
8907
|
+
HyperbolicAttention: () => HyperbolicAttention3,
|
|
8908
|
+
LinearAttention: () => LinearAttention3,
|
|
8909
|
+
MoEAttention: () => MoEAttention3,
|
|
8910
|
+
MultiHeadAttention: () => MultiHeadAttention3,
|
|
8911
|
+
RuvectorLayer: () => RuvectorLayer3,
|
|
8912
|
+
SonaEngine: () => SonaEngine3,
|
|
8913
|
+
TensorCompress: () => TensorCompress3,
|
|
8914
|
+
default: () => sona_default,
|
|
8915
|
+
differentiableSearch: () => differentiableSearch3,
|
|
8916
|
+
getCompressionLevel: () => getCompressionLevel3,
|
|
8917
|
+
hierarchicalForward: () => hierarchicalForward3,
|
|
8918
|
+
init: () => init3,
|
|
8919
|
+
pipeline: () => pipeline4
|
|
8920
|
+
});
|
|
8921
|
+
import { createRequire as createRequire3 } from "module";
|
|
8922
|
+
var __require4, __mod3, sona_default, RuvectorLayer3, TensorCompress3, differentiableSearch3, hierarchicalForward3, getCompressionLevel3, init3, FlashAttention3, DotProductAttention3, MultiHeadAttention3, HyperbolicAttention3, LinearAttention3, MoEAttention3, SonaEngine3, pipeline4;
|
|
8923
|
+
var init_sona = __esm({
|
|
8924
|
+
"native-require:@ruvector/sona"() {
|
|
8925
|
+
__require4 = createRequire3(import.meta.url);
|
|
8926
|
+
__mod3 = __require4("@ruvector/sona");
|
|
8927
|
+
sona_default = __mod3;
|
|
8928
|
+
({
|
|
8929
|
+
RuvectorLayer: RuvectorLayer3,
|
|
8930
|
+
TensorCompress: TensorCompress3,
|
|
8931
|
+
differentiableSearch: differentiableSearch3,
|
|
8932
|
+
hierarchicalForward: hierarchicalForward3,
|
|
8933
|
+
getCompressionLevel: getCompressionLevel3,
|
|
8934
|
+
init: init3,
|
|
8935
|
+
FlashAttention: FlashAttention3,
|
|
8936
|
+
DotProductAttention: DotProductAttention3,
|
|
8937
|
+
MultiHeadAttention: MultiHeadAttention3,
|
|
8938
|
+
HyperbolicAttention: HyperbolicAttention3,
|
|
8939
|
+
LinearAttention: LinearAttention3,
|
|
8940
|
+
MoEAttention: MoEAttention3,
|
|
8941
|
+
SonaEngine: SonaEngine3,
|
|
8942
|
+
pipeline: pipeline4
|
|
8943
|
+
} = __mod3 || {});
|
|
8944
|
+
}
|
|
8945
|
+
});
|
|
8946
|
+
|
|
9411
8947
|
// src/integrations/ruvector/sona-wrapper.ts
|
|
9412
|
-
import { SonaEngine } from "@ruvector/sona";
|
|
9413
8948
|
function createQESONA(config) {
|
|
9414
8949
|
return new QESONA(config);
|
|
9415
8950
|
}
|
|
@@ -9423,6 +8958,7 @@ var DEFAULT_QE_SONA_CONFIG, QESONAPatternRegistry, QESONA;
|
|
|
9423
8958
|
var init_sona_wrapper = __esm({
|
|
9424
8959
|
"src/integrations/ruvector/sona-wrapper.ts"() {
|
|
9425
8960
|
"use strict";
|
|
8961
|
+
init_sona();
|
|
9426
8962
|
DEFAULT_QE_SONA_CONFIG = {
|
|
9427
8963
|
hiddenDim: 256,
|
|
9428
8964
|
embeddingDim: 384,
|
|
@@ -9546,7 +9082,7 @@ var init_sona_wrapper = __esm({
|
|
|
9546
9082
|
qualityThreshold: this.config.qualityThreshold,
|
|
9547
9083
|
enableSimd: this.config.enableSimd
|
|
9548
9084
|
};
|
|
9549
|
-
this.engine =
|
|
9085
|
+
this.engine = SonaEngine3.withConfig(jsConfig);
|
|
9550
9086
|
this.registry = new QESONAPatternRegistry(this.config.maxPatterns ?? 1e4);
|
|
9551
9087
|
}
|
|
9552
9088
|
/**
|
|
@@ -10172,15 +9708,52 @@ var init_unified_persistence = __esm({
|
|
|
10172
9708
|
}
|
|
10173
9709
|
});
|
|
10174
9710
|
|
|
9711
|
+
// native-require:@ruvector/attention
|
|
9712
|
+
var attention_exports = {};
|
|
9713
|
+
__export(attention_exports, {
|
|
9714
|
+
DotProductAttention: () => DotProductAttention4,
|
|
9715
|
+
FlashAttention: () => FlashAttention4,
|
|
9716
|
+
HyperbolicAttention: () => HyperbolicAttention4,
|
|
9717
|
+
LinearAttention: () => LinearAttention4,
|
|
9718
|
+
MoEAttention: () => MoEAttention4,
|
|
9719
|
+
MultiHeadAttention: () => MultiHeadAttention4,
|
|
9720
|
+
RuvectorLayer: () => RuvectorLayer4,
|
|
9721
|
+
SonaEngine: () => SonaEngine4,
|
|
9722
|
+
TensorCompress: () => TensorCompress4,
|
|
9723
|
+
default: () => attention_default,
|
|
9724
|
+
differentiableSearch: () => differentiableSearch4,
|
|
9725
|
+
getCompressionLevel: () => getCompressionLevel4,
|
|
9726
|
+
hierarchicalForward: () => hierarchicalForward4,
|
|
9727
|
+
init: () => init4,
|
|
9728
|
+
pipeline: () => pipeline5
|
|
9729
|
+
});
|
|
9730
|
+
import { createRequire as createRequire4 } from "module";
|
|
9731
|
+
var __require5, __mod4, attention_default, RuvectorLayer4, TensorCompress4, differentiableSearch4, hierarchicalForward4, getCompressionLevel4, init4, FlashAttention4, DotProductAttention4, MultiHeadAttention4, HyperbolicAttention4, LinearAttention4, MoEAttention4, SonaEngine4, pipeline5;
|
|
9732
|
+
var init_attention = __esm({
|
|
9733
|
+
"native-require:@ruvector/attention"() {
|
|
9734
|
+
__require5 = createRequire4(import.meta.url);
|
|
9735
|
+
__mod4 = __require5("@ruvector/attention");
|
|
9736
|
+
attention_default = __mod4;
|
|
9737
|
+
({
|
|
9738
|
+
RuvectorLayer: RuvectorLayer4,
|
|
9739
|
+
TensorCompress: TensorCompress4,
|
|
9740
|
+
differentiableSearch: differentiableSearch4,
|
|
9741
|
+
hierarchicalForward: hierarchicalForward4,
|
|
9742
|
+
getCompressionLevel: getCompressionLevel4,
|
|
9743
|
+
init: init4,
|
|
9744
|
+
FlashAttention: FlashAttention4,
|
|
9745
|
+
DotProductAttention: DotProductAttention4,
|
|
9746
|
+
MultiHeadAttention: MultiHeadAttention4,
|
|
9747
|
+
HyperbolicAttention: HyperbolicAttention4,
|
|
9748
|
+
LinearAttention: LinearAttention4,
|
|
9749
|
+
MoEAttention: MoEAttention4,
|
|
9750
|
+
SonaEngine: SonaEngine4,
|
|
9751
|
+
pipeline: pipeline5
|
|
9752
|
+
} = __mod4 || {});
|
|
9753
|
+
}
|
|
9754
|
+
});
|
|
9755
|
+
|
|
10175
9756
|
// src/integrations/ruvector/attention-wrapper.ts
|
|
10176
|
-
import {
|
|
10177
|
-
FlashAttention,
|
|
10178
|
-
DotProductAttention,
|
|
10179
|
-
MultiHeadAttention,
|
|
10180
|
-
HyperbolicAttention,
|
|
10181
|
-
LinearAttention,
|
|
10182
|
-
MoEAttention
|
|
10183
|
-
} from "@ruvector/attention";
|
|
10184
9757
|
function getOptimalBlockConfig(seqLength) {
|
|
10185
9758
|
if (seqLength <= 128) {
|
|
10186
9759
|
return { queryChunkSize: 128, kvChunkSize: 128 };
|
|
@@ -10238,6 +9811,8 @@ var QE_FLASH_ATTENTION_CONFIG, QE_SONA_CONFIG, QE_PERFORMANCE_TARGETS, Attention
|
|
|
10238
9811
|
var init_attention_wrapper = __esm({
|
|
10239
9812
|
"src/integrations/ruvector/attention-wrapper.ts"() {
|
|
10240
9813
|
"use strict";
|
|
9814
|
+
init_attention();
|
|
9815
|
+
init_unified_memory();
|
|
10241
9816
|
QE_FLASH_ATTENTION_CONFIG = {
|
|
10242
9817
|
"test-similarity": {
|
|
10243
9818
|
dim: 384,
|
|
@@ -10331,31 +9906,39 @@ var init_attention_wrapper = __esm({
|
|
|
10331
9906
|
static create(config) {
|
|
10332
9907
|
switch (config.strategy) {
|
|
10333
9908
|
case "flash":
|
|
10334
|
-
return new
|
|
9909
|
+
return new FlashAttention4(config.dim, config.blockSize);
|
|
10335
9910
|
case "dot-product":
|
|
10336
|
-
return new
|
|
9911
|
+
return new DotProductAttention4(config.dim);
|
|
10337
9912
|
case "multi-head":
|
|
10338
|
-
return new
|
|
9913
|
+
return new MultiHeadAttention4(config.dim, config.numHeads ?? 8);
|
|
10339
9914
|
case "hyperbolic":
|
|
10340
|
-
return new
|
|
9915
|
+
return new HyperbolicAttention4(config.dim, config.curvature);
|
|
10341
9916
|
case "linear":
|
|
10342
|
-
return new
|
|
9917
|
+
return new LinearAttention4(config.dim, config.features);
|
|
10343
9918
|
case "moe":
|
|
10344
|
-
return
|
|
9919
|
+
return MoEAttention4.simple(
|
|
10345
9920
|
config.dim,
|
|
10346
9921
|
config.moeConfig?.numExperts ?? 8,
|
|
10347
9922
|
config.moeConfig?.topK ?? 2
|
|
10348
9923
|
);
|
|
10349
9924
|
default:
|
|
10350
|
-
return new
|
|
9925
|
+
return new FlashAttention4(config.dim, config.blockSize);
|
|
10351
9926
|
}
|
|
10352
9927
|
}
|
|
10353
9928
|
};
|
|
10354
|
-
QEFlashAttention = class {
|
|
9929
|
+
QEFlashAttention = class _QEFlashAttention {
|
|
10355
9930
|
attention;
|
|
10356
9931
|
config;
|
|
10357
9932
|
workload;
|
|
10358
9933
|
metrics = [];
|
|
9934
|
+
// kv_store persistence
|
|
9935
|
+
db = null;
|
|
9936
|
+
persistCount = 0;
|
|
9937
|
+
static KV_NAMESPACE = "attention-metrics";
|
|
9938
|
+
static KV_TTL = 3600;
|
|
9939
|
+
// 1 hour
|
|
9940
|
+
static PERSIST_INTERVAL = 10;
|
|
9941
|
+
// every 10 operations
|
|
10359
9942
|
constructor(workload, customConfig) {
|
|
10360
9943
|
this.workload = workload;
|
|
10361
9944
|
const baseConfig = QE_FLASH_ATTENTION_CONFIG[workload];
|
|
@@ -10366,10 +9949,18 @@ var init_attention_wrapper = __esm({
|
|
|
10366
9949
|
this.attention = AttentionFactory.create(this.config);
|
|
10367
9950
|
}
|
|
10368
9951
|
/**
|
|
10369
|
-
* Initialize Flash Attention
|
|
9952
|
+
* Initialize Flash Attention and kv_store persistence
|
|
10370
9953
|
* Note: @ruvector/attention doesn't require async initialization
|
|
10371
9954
|
*/
|
|
10372
9955
|
async initialize() {
|
|
9956
|
+
try {
|
|
9957
|
+
this.db = getUnifiedMemory();
|
|
9958
|
+
if (!this.db.isInitialized()) await this.db.initialize();
|
|
9959
|
+
await this.loadFromKv();
|
|
9960
|
+
} catch (error) {
|
|
9961
|
+
console.warn("[QEFlashAttention] DB init failed, using memory-only:", error instanceof Error ? error.message : String(error));
|
|
9962
|
+
this.db = null;
|
|
9963
|
+
}
|
|
10373
9964
|
}
|
|
10374
9965
|
/**
|
|
10375
9966
|
* Compute Flash Attention using @ruvector/attention
|
|
@@ -10388,20 +9979,20 @@ var init_attention_wrapper = __esm({
|
|
|
10388
9979
|
const keys = this.splitMatrix(K58, seqLen, dim);
|
|
10389
9980
|
const values = this.splitMatrix(V45, seqLen, dim);
|
|
10390
9981
|
let output;
|
|
10391
|
-
if (this.attention instanceof
|
|
9982
|
+
if (this.attention instanceof FlashAttention4) {
|
|
10392
9983
|
output = this.attention.compute(query, keys, values);
|
|
10393
|
-
} else if (this.attention instanceof
|
|
9984
|
+
} else if (this.attention instanceof DotProductAttention4) {
|
|
10394
9985
|
output = this.attention.compute(query, keys, values);
|
|
10395
|
-
} else if (this.attention instanceof
|
|
9986
|
+
} else if (this.attention instanceof MultiHeadAttention4) {
|
|
10396
9987
|
output = this.attention.compute(query, keys, values);
|
|
10397
|
-
} else if (this.attention instanceof
|
|
9988
|
+
} else if (this.attention instanceof HyperbolicAttention4) {
|
|
10398
9989
|
output = this.attention.compute(query, keys, values);
|
|
10399
|
-
} else if (this.attention instanceof
|
|
9990
|
+
} else if (this.attention instanceof LinearAttention4) {
|
|
10400
9991
|
output = this.attention.compute(query, keys, values);
|
|
10401
|
-
} else if (this.attention instanceof
|
|
9992
|
+
} else if (this.attention instanceof MoEAttention4) {
|
|
10402
9993
|
output = this.attention.compute(query, keys, values);
|
|
10403
9994
|
} else {
|
|
10404
|
-
const fallback = new
|
|
9995
|
+
const fallback = new FlashAttention4(this.config.dim);
|
|
10405
9996
|
output = fallback.compute(query, keys, values);
|
|
10406
9997
|
}
|
|
10407
9998
|
const endTime = performance.now();
|
|
@@ -10414,6 +10005,7 @@ var init_attention_wrapper = __esm({
|
|
|
10414
10005
|
throughput: seqLen * seqLen / ((endTime - startTime) / 1e3),
|
|
10415
10006
|
peakMemoryMB: endMemory
|
|
10416
10007
|
});
|
|
10008
|
+
this.maybePersistToKv();
|
|
10417
10009
|
return output;
|
|
10418
10010
|
}
|
|
10419
10011
|
/**
|
|
@@ -10580,6 +10172,49 @@ var init_attention_wrapper = __esm({
|
|
|
10580
10172
|
this.metrics = [];
|
|
10581
10173
|
}
|
|
10582
10174
|
// ========================================================================
|
|
10175
|
+
// kv_store Persistence
|
|
10176
|
+
// ========================================================================
|
|
10177
|
+
/**
|
|
10178
|
+
* Persist metrics snapshot to kv_store
|
|
10179
|
+
*/
|
|
10180
|
+
async persistToKv() {
|
|
10181
|
+
if (!this.db) return;
|
|
10182
|
+
const kvKey = `attention-metrics-${this.workload}`;
|
|
10183
|
+
const snapshot = {
|
|
10184
|
+
workload: this.workload,
|
|
10185
|
+
metrics: this.metrics.slice(-50),
|
|
10186
|
+
savedAt: Date.now()
|
|
10187
|
+
};
|
|
10188
|
+
await this.db.kvSet(
|
|
10189
|
+
kvKey,
|
|
10190
|
+
snapshot,
|
|
10191
|
+
_QEFlashAttention.KV_NAMESPACE,
|
|
10192
|
+
_QEFlashAttention.KV_TTL
|
|
10193
|
+
);
|
|
10194
|
+
}
|
|
10195
|
+
/**
|
|
10196
|
+
* Load metrics snapshot from kv_store
|
|
10197
|
+
*/
|
|
10198
|
+
async loadFromKv() {
|
|
10199
|
+
if (!this.db) return;
|
|
10200
|
+
const kvKey = `attention-metrics-${this.workload}`;
|
|
10201
|
+
const snapshot = await this.db.kvGet(kvKey, _QEFlashAttention.KV_NAMESPACE);
|
|
10202
|
+
if (snapshot?.metrics?.length) {
|
|
10203
|
+
this.metrics = snapshot.metrics;
|
|
10204
|
+
}
|
|
10205
|
+
}
|
|
10206
|
+
/**
|
|
10207
|
+
* Track operations and persist periodically
|
|
10208
|
+
*/
|
|
10209
|
+
maybePersistToKv() {
|
|
10210
|
+
this.persistCount++;
|
|
10211
|
+
if (this.persistCount >= _QEFlashAttention.PERSIST_INTERVAL) {
|
|
10212
|
+
this.persistCount = 0;
|
|
10213
|
+
this.persistToKv().catch(() => {
|
|
10214
|
+
});
|
|
10215
|
+
}
|
|
10216
|
+
}
|
|
10217
|
+
// ========================================================================
|
|
10583
10218
|
// Private Helper Methods
|
|
10584
10219
|
// ========================================================================
|
|
10585
10220
|
/**
|
|
@@ -10602,36 +10237,73 @@ var init_attention_wrapper = __esm({
|
|
|
10602
10237
|
}
|
|
10603
10238
|
});
|
|
10604
10239
|
|
|
10240
|
+
// native-require:@ruvector/gnn
|
|
10241
|
+
var gnn_exports = {};
|
|
10242
|
+
__export(gnn_exports, {
|
|
10243
|
+
DotProductAttention: () => DotProductAttention5,
|
|
10244
|
+
FlashAttention: () => FlashAttention5,
|
|
10245
|
+
HyperbolicAttention: () => HyperbolicAttention5,
|
|
10246
|
+
LinearAttention: () => LinearAttention5,
|
|
10247
|
+
MoEAttention: () => MoEAttention5,
|
|
10248
|
+
MultiHeadAttention: () => MultiHeadAttention5,
|
|
10249
|
+
RuvectorLayer: () => RuvectorLayer5,
|
|
10250
|
+
SonaEngine: () => SonaEngine5,
|
|
10251
|
+
TensorCompress: () => TensorCompress5,
|
|
10252
|
+
default: () => gnn_default,
|
|
10253
|
+
differentiableSearch: () => differentiableSearch5,
|
|
10254
|
+
getCompressionLevel: () => getCompressionLevel5,
|
|
10255
|
+
hierarchicalForward: () => hierarchicalForward5,
|
|
10256
|
+
init: () => init5,
|
|
10257
|
+
pipeline: () => pipeline6
|
|
10258
|
+
});
|
|
10259
|
+
import { createRequire as createRequire5 } from "module";
|
|
10260
|
+
var __require6, __mod5, gnn_default, RuvectorLayer5, TensorCompress5, differentiableSearch5, hierarchicalForward5, getCompressionLevel5, init5, FlashAttention5, DotProductAttention5, MultiHeadAttention5, HyperbolicAttention5, LinearAttention5, MoEAttention5, SonaEngine5, pipeline6;
|
|
10261
|
+
var init_gnn = __esm({
|
|
10262
|
+
"native-require:@ruvector/gnn"() {
|
|
10263
|
+
__require6 = createRequire5(import.meta.url);
|
|
10264
|
+
__mod5 = __require6("@ruvector/gnn");
|
|
10265
|
+
gnn_default = __mod5;
|
|
10266
|
+
({
|
|
10267
|
+
RuvectorLayer: RuvectorLayer5,
|
|
10268
|
+
TensorCompress: TensorCompress5,
|
|
10269
|
+
differentiableSearch: differentiableSearch5,
|
|
10270
|
+
hierarchicalForward: hierarchicalForward5,
|
|
10271
|
+
getCompressionLevel: getCompressionLevel5,
|
|
10272
|
+
init: init5,
|
|
10273
|
+
FlashAttention: FlashAttention5,
|
|
10274
|
+
DotProductAttention: DotProductAttention5,
|
|
10275
|
+
MultiHeadAttention: MultiHeadAttention5,
|
|
10276
|
+
HyperbolicAttention: HyperbolicAttention5,
|
|
10277
|
+
LinearAttention: LinearAttention5,
|
|
10278
|
+
MoEAttention: MoEAttention5,
|
|
10279
|
+
SonaEngine: SonaEngine5,
|
|
10280
|
+
pipeline: pipeline6
|
|
10281
|
+
} = __mod5 || {});
|
|
10282
|
+
}
|
|
10283
|
+
});
|
|
10284
|
+
|
|
10605
10285
|
// src/integrations/ruvector/gnn-wrapper.ts
|
|
10606
10286
|
var gnn_wrapper_exports = {};
|
|
10607
10287
|
__export(gnn_wrapper_exports, {
|
|
10608
10288
|
GNNLayerFactory: () => GNNLayerFactory,
|
|
10609
10289
|
QEGNNEmbeddingIndex: () => QEGNNEmbeddingIndex,
|
|
10610
10290
|
QEGNNIndexFactory: () => QEGNNIndexFactory,
|
|
10611
|
-
RuvectorLayer: () =>
|
|
10612
|
-
TensorCompress: () =>
|
|
10291
|
+
RuvectorLayer: () => RuvectorLayer5,
|
|
10292
|
+
TensorCompress: () => TensorCompress5,
|
|
10613
10293
|
TensorCompressionFactory: () => TensorCompressionFactory,
|
|
10614
10294
|
batchDifferentiableSearch: () => batchDifferentiableSearch,
|
|
10615
|
-
differentiableSearch: () =>
|
|
10616
|
-
getCompressionLevel: () =>
|
|
10617
|
-
hierarchicalForward: () =>
|
|
10618
|
-
init: () =>
|
|
10295
|
+
differentiableSearch: () => differentiableSearch5,
|
|
10296
|
+
getCompressionLevel: () => getCompressionLevel5,
|
|
10297
|
+
hierarchicalForward: () => hierarchicalForward5,
|
|
10298
|
+
init: () => init5,
|
|
10619
10299
|
initGNN: () => initGNN,
|
|
10620
10300
|
toFloat32Array: () => toFloat32Array2,
|
|
10621
10301
|
toIEmbedding: () => toIEmbedding,
|
|
10622
10302
|
toNumberArray: () => toNumberArray2
|
|
10623
10303
|
});
|
|
10624
|
-
import {
|
|
10625
|
-
RuvectorLayer,
|
|
10626
|
-
TensorCompress,
|
|
10627
|
-
differentiableSearch,
|
|
10628
|
-
hierarchicalForward,
|
|
10629
|
-
getCompressionLevel,
|
|
10630
|
-
init
|
|
10631
|
-
} from "@ruvector/gnn";
|
|
10632
10304
|
function initGNN() {
|
|
10633
10305
|
if (!gnnInitialized) {
|
|
10634
|
-
const result =
|
|
10306
|
+
const result = init5();
|
|
10635
10307
|
gnnInitialized = true;
|
|
10636
10308
|
return result;
|
|
10637
10309
|
}
|
|
@@ -10672,7 +10344,7 @@ function batchDifferentiableSearch(queries, candidateEmbeddings, k68, temperatur
|
|
|
10672
10344
|
);
|
|
10673
10345
|
for (const query of queries) {
|
|
10674
10346
|
const queryFloat32 = query instanceof Float32Array ? query : new Float32Array(query);
|
|
10675
|
-
const result =
|
|
10347
|
+
const result = differentiableSearch5(
|
|
10676
10348
|
queryFloat32,
|
|
10677
10349
|
candidatesFloat32,
|
|
10678
10350
|
k68,
|
|
@@ -10689,6 +10361,7 @@ var gnnInitialized, QEGNNEmbeddingIndex, QEGNNIndexFactory, GNNLayerFactory, Ten
|
|
|
10689
10361
|
var init_gnn_wrapper = __esm({
|
|
10690
10362
|
"src/integrations/ruvector/gnn-wrapper.ts"() {
|
|
10691
10363
|
"use strict";
|
|
10364
|
+
init_gnn();
|
|
10692
10365
|
gnnInitialized = false;
|
|
10693
10366
|
QEGNNEmbeddingIndex = class {
|
|
10694
10367
|
indexes;
|
|
@@ -10708,7 +10381,7 @@ var init_gnn_wrapper = __esm({
|
|
|
10708
10381
|
this.indexes = /* @__PURE__ */ new Map();
|
|
10709
10382
|
this.nextId = /* @__PURE__ */ new Map();
|
|
10710
10383
|
this.gnnLayers = /* @__PURE__ */ new Map();
|
|
10711
|
-
this.compressor = new
|
|
10384
|
+
this.compressor = new TensorCompress5();
|
|
10712
10385
|
initGNN();
|
|
10713
10386
|
}
|
|
10714
10387
|
/**
|
|
@@ -10769,7 +10442,7 @@ var init_gnn_wrapper = __esm({
|
|
|
10769
10442
|
}
|
|
10770
10443
|
const queryFloat32 = new Float32Array(query.vector);
|
|
10771
10444
|
const candidateFloat32s = candidates.map((c70) => new Float32Array(c70.vector));
|
|
10772
|
-
const result =
|
|
10445
|
+
const result = differentiableSearch5(
|
|
10773
10446
|
queryFloat32,
|
|
10774
10447
|
candidateFloat32s,
|
|
10775
10448
|
Math.min(k68, candidates.length),
|
|
@@ -10792,7 +10465,7 @@ var init_gnn_wrapper = __esm({
|
|
|
10792
10465
|
const candidateVectors = candidates.map(
|
|
10793
10466
|
(c70) => new Float32Array(c70.embedding.vector)
|
|
10794
10467
|
);
|
|
10795
|
-
const result =
|
|
10468
|
+
const result = differentiableSearch5(
|
|
10796
10469
|
queryVector,
|
|
10797
10470
|
candidateVectors,
|
|
10798
10471
|
Math.min(k68, candidates.length),
|
|
@@ -10813,7 +10486,7 @@ var init_gnn_wrapper = __esm({
|
|
|
10813
10486
|
if (!this.gnnLayers.has(layerKey)) {
|
|
10814
10487
|
const layers = [];
|
|
10815
10488
|
for (const config of layerConfigs) {
|
|
10816
|
-
const layer2 = new
|
|
10489
|
+
const layer2 = new RuvectorLayer5(
|
|
10817
10490
|
config.inputDim,
|
|
10818
10491
|
config.hiddenDim,
|
|
10819
10492
|
config.heads,
|
|
@@ -10829,7 +10502,7 @@ var init_gnn_wrapper = __esm({
|
|
|
10829
10502
|
const layerEmbeddingsFloat32 = layerEmbeddings.map(
|
|
10830
10503
|
(layer2) => layer2.map((emb) => new Float32Array(emb))
|
|
10831
10504
|
);
|
|
10832
|
-
return Array.from(
|
|
10505
|
+
return Array.from(hierarchicalForward5(
|
|
10833
10506
|
queryFloat32,
|
|
10834
10507
|
layerEmbeddingsFloat32,
|
|
10835
10508
|
[gnnLayerJson]
|
|
@@ -10844,7 +10517,7 @@ var init_gnn_wrapper = __esm({
|
|
|
10844
10517
|
* - Cold data (low access): product quantization
|
|
10845
10518
|
*/
|
|
10846
10519
|
compressEmbedding(embedding, accessFreq) {
|
|
10847
|
-
const rawLevel =
|
|
10520
|
+
const rawLevel = getCompressionLevel5(accessFreq);
|
|
10848
10521
|
const levelMap = {
|
|
10849
10522
|
"none": "none",
|
|
10850
10523
|
"half": "half",
|
|
@@ -10890,7 +10563,7 @@ var init_gnn_wrapper = __esm({
|
|
|
10890
10563
|
* Get compression level for access frequency
|
|
10891
10564
|
*/
|
|
10892
10565
|
getCompressionLevelForFrequency(accessFreq) {
|
|
10893
|
-
return
|
|
10566
|
+
return getCompressionLevel5(accessFreq);
|
|
10894
10567
|
}
|
|
10895
10568
|
/**
|
|
10896
10569
|
* Get index statistics
|
|
@@ -11034,7 +10707,7 @@ var init_gnn_wrapper = __esm({
|
|
|
11034
10707
|
static getLayer(config) {
|
|
11035
10708
|
const key = `${config.inputDim}-${config.hiddenDim}-${config.heads}-${config.dropout}`;
|
|
11036
10709
|
if (!this.layers.has(key)) {
|
|
11037
|
-
const layer = new
|
|
10710
|
+
const layer = new RuvectorLayer5(
|
|
11038
10711
|
config.inputDim,
|
|
11039
10712
|
config.hiddenDim,
|
|
11040
10713
|
config.heads,
|
|
@@ -11048,7 +10721,7 @@ var init_gnn_wrapper = __esm({
|
|
|
11048
10721
|
* Create layer from JSON
|
|
11049
10722
|
*/
|
|
11050
10723
|
static layerFromJson(json) {
|
|
11051
|
-
return
|
|
10724
|
+
return RuvectorLayer5.fromJson(json);
|
|
11052
10725
|
}
|
|
11053
10726
|
/**
|
|
11054
10727
|
* Clear cached layers
|
|
@@ -11058,7 +10731,7 @@ var init_gnn_wrapper = __esm({
|
|
|
11058
10731
|
}
|
|
11059
10732
|
};
|
|
11060
10733
|
TensorCompressionFactory = class {
|
|
11061
|
-
static compressor = new
|
|
10734
|
+
static compressor = new TensorCompress5();
|
|
11062
10735
|
/**
|
|
11063
10736
|
* Compress tensor with specific level
|
|
11064
10737
|
*/
|
|
@@ -11084,7 +10757,7 @@ var init_gnn_wrapper = __esm({
|
|
|
11084
10757
|
* Get compression level for frequency
|
|
11085
10758
|
*/
|
|
11086
10759
|
static getLevel(accessFreq) {
|
|
11087
|
-
return
|
|
10760
|
+
return getCompressionLevel5(accessFreq);
|
|
11088
10761
|
}
|
|
11089
10762
|
};
|
|
11090
10763
|
}
|
|
@@ -11101,14 +10774,14 @@ __export(wrappers_exports, {
|
|
|
11101
10774
|
QE_FLASH_ATTENTION_CONFIG: () => QE_FLASH_ATTENTION_CONFIG,
|
|
11102
10775
|
QE_PERFORMANCE_TARGETS: () => QE_PERFORMANCE_TARGETS,
|
|
11103
10776
|
QE_SONA_CONFIG: () => QE_SONA_CONFIG,
|
|
11104
|
-
RuvectorDotProductAttention: () =>
|
|
11105
|
-
RuvectorFlashAttention: () =>
|
|
11106
|
-
RuvectorHyperbolicAttention: () =>
|
|
11107
|
-
RuvectorLayer: () =>
|
|
11108
|
-
RuvectorLinearAttention: () =>
|
|
11109
|
-
RuvectorMoEAttention: () =>
|
|
11110
|
-
RuvectorMultiHeadAttention: () =>
|
|
11111
|
-
TensorCompress: () =>
|
|
10777
|
+
RuvectorDotProductAttention: () => DotProductAttention4,
|
|
10778
|
+
RuvectorFlashAttention: () => FlashAttention4,
|
|
10779
|
+
RuvectorHyperbolicAttention: () => HyperbolicAttention4,
|
|
10780
|
+
RuvectorLayer: () => RuvectorLayer5,
|
|
10781
|
+
RuvectorLinearAttention: () => LinearAttention4,
|
|
10782
|
+
RuvectorMoEAttention: () => MoEAttention4,
|
|
10783
|
+
RuvectorMultiHeadAttention: () => MultiHeadAttention4,
|
|
10784
|
+
TensorCompress: () => TensorCompress5,
|
|
11112
10785
|
TensorCompressionFactory: () => TensorCompressionFactory,
|
|
11113
10786
|
batchComputeAttention: () => batchComputeAttention,
|
|
11114
10787
|
batchDifferentiableSearch: () => batchDifferentiableSearch,
|
|
@@ -11116,14 +10789,14 @@ __export(wrappers_exports, {
|
|
|
11116
10789
|
createDomainQESONA: () => createDomainQESONA,
|
|
11117
10790
|
createQEFlashAttention: () => createQEFlashAttention,
|
|
11118
10791
|
createQESONA: () => createQESONA,
|
|
11119
|
-
differentiableSearch: () =>
|
|
11120
|
-
getCompressionLevel: () =>
|
|
10792
|
+
differentiableSearch: () => differentiableSearch5,
|
|
10793
|
+
getCompressionLevel: () => getCompressionLevel5,
|
|
11121
10794
|
getOptimalBlockConfig: () => getOptimalBlockConfig,
|
|
11122
10795
|
getQEFlashAttentionConfig: () => getQEFlashAttentionConfig,
|
|
11123
10796
|
getRuvectorPackageVersions: () => getRuvectorPackageVersions,
|
|
11124
10797
|
getWorkloadTypes: () => getWorkloadTypes,
|
|
11125
|
-
hierarchicalForward: () =>
|
|
11126
|
-
init: () =>
|
|
10798
|
+
hierarchicalForward: () => hierarchicalForward5,
|
|
10799
|
+
init: () => init5,
|
|
11127
10800
|
initAllRuvectorPackages: () => initAllRuvectorPackages,
|
|
11128
10801
|
initGNN: () => initGNN,
|
|
11129
10802
|
toFloat32Array: () => toFloat32Array,
|
|
@@ -11142,17 +10815,17 @@ function getRuvectorPackageVersions() {
|
|
|
11142
10815
|
function checkRuvectorPackagesAvailable() {
|
|
11143
10816
|
const results = { sona: false, attention: false, gnn: false, all: false };
|
|
11144
10817
|
try {
|
|
11145
|
-
|
|
10818
|
+
init_sona();
|
|
11146
10819
|
results.sona = true;
|
|
11147
10820
|
} catch {
|
|
11148
10821
|
}
|
|
11149
10822
|
try {
|
|
11150
|
-
|
|
10823
|
+
init_attention();
|
|
11151
10824
|
results.attention = true;
|
|
11152
10825
|
} catch {
|
|
11153
10826
|
}
|
|
11154
10827
|
try {
|
|
11155
|
-
const gnn =
|
|
10828
|
+
const gnn = (init_gnn(), __toCommonJS(gnn_exports));
|
|
11156
10829
|
gnn.init();
|
|
11157
10830
|
const testQuery = new Float32Array([0.1, 0.2, 0.3]);
|
|
11158
10831
|
const testCandidates = [new Float32Array([0.1, 0.2, 0.3]), new Float32Array([0.4, 0.5, 0.6])];
|
|
@@ -11340,8 +11013,6 @@ var init_hnsw_index = __esm({
|
|
|
11340
11013
|
const embedding = this.vectorToEmbedding(vector, key, metadata);
|
|
11341
11014
|
this.ruvectorIndex.addEmbedding(embedding, label);
|
|
11342
11015
|
this.vectorStore.set(key, vector);
|
|
11343
|
-
const fullKey = this.buildKey(key);
|
|
11344
|
-
await this.memory.storeVector(fullKey, vector, metadata);
|
|
11345
11016
|
this.stats.insertOperations++;
|
|
11346
11017
|
this.stats.vectorCount++;
|
|
11347
11018
|
}
|
|
@@ -15286,12 +14957,12 @@ __export(agent_booster_wasm_exports, {
|
|
|
15286
14957
|
transform: () => transform,
|
|
15287
14958
|
warmup: () => warmup
|
|
15288
14959
|
});
|
|
15289
|
-
import { createRequire } from "module";
|
|
14960
|
+
import { createRequire as createRequire6 } from "module";
|
|
15290
14961
|
async function loadWasm() {
|
|
15291
14962
|
if (wasmModule) return true;
|
|
15292
14963
|
if (loadError) return false;
|
|
15293
14964
|
try {
|
|
15294
|
-
const require3 =
|
|
14965
|
+
const require3 = createRequire6(import.meta.url);
|
|
15295
14966
|
wasmModule = require3("./agent_booster_wasm.js");
|
|
15296
14967
|
if (!wasmModule) {
|
|
15297
14968
|
throw new Error("WASM module loaded but is null");
|
|
@@ -16782,6 +16453,51 @@ var init_qe_guidance = __esm({
|
|
|
16782
16453
|
}
|
|
16783
16454
|
});
|
|
16784
16455
|
|
|
16456
|
+
// native-require:hnswlib-node
|
|
16457
|
+
var hnswlib_node_exports = {};
|
|
16458
|
+
__export(hnswlib_node_exports, {
|
|
16459
|
+
DotProductAttention: () => DotProductAttention6,
|
|
16460
|
+
FlashAttention: () => FlashAttention6,
|
|
16461
|
+
HyperbolicAttention: () => HyperbolicAttention6,
|
|
16462
|
+
LinearAttention: () => LinearAttention6,
|
|
16463
|
+
MoEAttention: () => MoEAttention6,
|
|
16464
|
+
MultiHeadAttention: () => MultiHeadAttention6,
|
|
16465
|
+
RuvectorLayer: () => RuvectorLayer6,
|
|
16466
|
+
SonaEngine: () => SonaEngine6,
|
|
16467
|
+
TensorCompress: () => TensorCompress6,
|
|
16468
|
+
default: () => hnswlib_node_default,
|
|
16469
|
+
differentiableSearch: () => differentiableSearch6,
|
|
16470
|
+
getCompressionLevel: () => getCompressionLevel6,
|
|
16471
|
+
hierarchicalForward: () => hierarchicalForward6,
|
|
16472
|
+
init: () => init6,
|
|
16473
|
+
pipeline: () => pipeline7
|
|
16474
|
+
});
|
|
16475
|
+
import { createRequire as createRequire7 } from "module";
|
|
16476
|
+
var __require7, __mod6, hnswlib_node_default, RuvectorLayer6, TensorCompress6, differentiableSearch6, hierarchicalForward6, getCompressionLevel6, init6, FlashAttention6, DotProductAttention6, MultiHeadAttention6, HyperbolicAttention6, LinearAttention6, MoEAttention6, SonaEngine6, pipeline7;
|
|
16477
|
+
var init_hnswlib_node = __esm({
|
|
16478
|
+
"native-require:hnswlib-node"() {
|
|
16479
|
+
__require7 = createRequire7(import.meta.url);
|
|
16480
|
+
__mod6 = __require7("hnswlib-node");
|
|
16481
|
+
hnswlib_node_default = __mod6;
|
|
16482
|
+
({
|
|
16483
|
+
RuvectorLayer: RuvectorLayer6,
|
|
16484
|
+
TensorCompress: TensorCompress6,
|
|
16485
|
+
differentiableSearch: differentiableSearch6,
|
|
16486
|
+
hierarchicalForward: hierarchicalForward6,
|
|
16487
|
+
getCompressionLevel: getCompressionLevel6,
|
|
16488
|
+
init: init6,
|
|
16489
|
+
FlashAttention: FlashAttention6,
|
|
16490
|
+
DotProductAttention: DotProductAttention6,
|
|
16491
|
+
MultiHeadAttention: MultiHeadAttention6,
|
|
16492
|
+
HyperbolicAttention: HyperbolicAttention6,
|
|
16493
|
+
LinearAttention: LinearAttention6,
|
|
16494
|
+
MoEAttention: MoEAttention6,
|
|
16495
|
+
SonaEngine: SonaEngine6,
|
|
16496
|
+
pipeline: pipeline7
|
|
16497
|
+
} = __mod6 || {});
|
|
16498
|
+
}
|
|
16499
|
+
});
|
|
16500
|
+
|
|
16785
16501
|
// src/integrations/agentic-flow/model-router/types.ts
|
|
16786
16502
|
var TIER_METADATA, DEFAULT_BUDGET_CONFIG, DEFAULT_ROUTER_CONFIG, ModelRouterError, BudgetExceededError, ComplexityAnalysisError, RoutingTimeoutError;
|
|
16787
16503
|
var init_types5 = __esm({
|
|
@@ -18602,7 +18318,7 @@ var init_pattern_store = __esm({
|
|
|
18602
18318
|
init_qe_patterns();
|
|
18603
18319
|
DEFAULT_PATTERN_STORE_CONFIG = {
|
|
18604
18320
|
namespace: "qe-patterns",
|
|
18605
|
-
embeddingDimension:
|
|
18321
|
+
embeddingDimension: 768,
|
|
18606
18322
|
hnsw: {
|
|
18607
18323
|
M: 16,
|
|
18608
18324
|
efConstruction: 200,
|
|
@@ -18740,29 +18456,6 @@ var init_pattern_store = __esm({
|
|
|
18740
18456
|
* Load existing patterns from memory with timeout protection
|
|
18741
18457
|
*/
|
|
18742
18458
|
async loadPatterns() {
|
|
18743
|
-
try {
|
|
18744
|
-
const timeoutMs = 5e3;
|
|
18745
|
-
const searchPromise = this.memory.search(`${this.config.namespace}:pattern:*`, 1e4);
|
|
18746
|
-
const timeoutPromise = new Promise(
|
|
18747
|
-
(_56, reject) => setTimeout(() => reject(new Error("Pattern load timeout")), timeoutMs)
|
|
18748
|
-
);
|
|
18749
|
-
const keys = await Promise.race([searchPromise, timeoutPromise]);
|
|
18750
|
-
const BATCH_SIZE = 50;
|
|
18751
|
-
for (let i58 = 0; i58 < keys.length; i58 += BATCH_SIZE) {
|
|
18752
|
-
const batch = keys.slice(i58, i58 + BATCH_SIZE);
|
|
18753
|
-
const patterns = await Promise.all(
|
|
18754
|
-
batch.map((key) => this.memory.get(key).catch(() => null))
|
|
18755
|
-
);
|
|
18756
|
-
for (const pattern of patterns) {
|
|
18757
|
-
if (pattern) {
|
|
18758
|
-
this.indexPattern(pattern);
|
|
18759
|
-
}
|
|
18760
|
-
}
|
|
18761
|
-
}
|
|
18762
|
-
console.log(`[PatternStore] Loaded ${this.patternCache.size} patterns`);
|
|
18763
|
-
} catch (error) {
|
|
18764
|
-
console.log(`[PatternStore] Starting fresh (no existing patterns loaded): ${error instanceof Error ? error.message : "unknown error"}`);
|
|
18765
|
-
}
|
|
18766
18459
|
}
|
|
18767
18460
|
/**
|
|
18768
18461
|
* Index a pattern in local caches
|
|
@@ -18810,10 +18503,6 @@ var init_pattern_store = __esm({
|
|
|
18810
18503
|
if (domainCount >= this.config.maxPatternsPerDomain) {
|
|
18811
18504
|
await this.cleanupDomain(pattern.qeDomain);
|
|
18812
18505
|
}
|
|
18813
|
-
const key = `${this.config.namespace}:pattern:${pattern.id}`;
|
|
18814
|
-
await this.memory.set(key, pattern, {
|
|
18815
|
-
persist: true
|
|
18816
|
-
});
|
|
18817
18506
|
this.indexPattern(pattern);
|
|
18818
18507
|
if (pattern.embedding) {
|
|
18819
18508
|
const hnsw = await this.ensureHNSW();
|
|
@@ -18910,15 +18599,7 @@ var init_pattern_store = __esm({
|
|
|
18910
18599
|
if (!this.initialized) {
|
|
18911
18600
|
await this.initialize();
|
|
18912
18601
|
}
|
|
18913
|
-
|
|
18914
|
-
if (cached) return cached;
|
|
18915
|
-
const key = `${this.config.namespace}:pattern:${id}`;
|
|
18916
|
-
const pattern = await this.memory.get(key);
|
|
18917
|
-
if (pattern) {
|
|
18918
|
-
this.indexPattern(pattern);
|
|
18919
|
-
return pattern;
|
|
18920
|
-
}
|
|
18921
|
-
return null;
|
|
18602
|
+
return this.patternCache.get(id) ?? null;
|
|
18922
18603
|
}
|
|
18923
18604
|
/**
|
|
18924
18605
|
* Search for patterns
|
|
@@ -19115,10 +18796,6 @@ var init_pattern_store = __esm({
|
|
|
19115
18796
|
if (shouldPromote && updated.tier === "short-term") {
|
|
19116
18797
|
await this.promote(id);
|
|
19117
18798
|
} else {
|
|
19118
|
-
const key = `${this.config.namespace}:pattern:${id}`;
|
|
19119
|
-
await this.memory.set(key, updated, {
|
|
19120
|
-
persist: true
|
|
19121
|
-
});
|
|
19122
18799
|
this.patternCache.set(id, updated);
|
|
19123
18800
|
}
|
|
19124
18801
|
return ok(void 0);
|
|
@@ -19142,10 +18819,6 @@ var init_pattern_store = __esm({
|
|
|
19142
18819
|
};
|
|
19143
18820
|
this.tierIndex.get("short-term")?.delete(id);
|
|
19144
18821
|
this.tierIndex.get("long-term")?.add(id);
|
|
19145
|
-
const key = `${this.config.namespace}:pattern:${id}`;
|
|
19146
|
-
await this.memory.set(key, promoted, {
|
|
19147
|
-
persist: true
|
|
19148
|
-
});
|
|
19149
18822
|
this.patternCache.set(id, promoted);
|
|
19150
18823
|
console.log(
|
|
19151
18824
|
`[PatternStore] Promoted pattern ${id} (${pattern.name}) to long-term storage`
|
|
@@ -19161,8 +18834,6 @@ var init_pattern_store = __esm({
|
|
|
19161
18834
|
return err(new Error(`Pattern not found: ${id}`));
|
|
19162
18835
|
}
|
|
19163
18836
|
this.unindexPattern(pattern);
|
|
19164
|
-
const key = `${this.config.namespace}:pattern:${id}`;
|
|
19165
|
-
await this.memory.delete(key);
|
|
19166
18837
|
if (this.hnswIndex !== null) {
|
|
19167
18838
|
try {
|
|
19168
18839
|
await this.hnswIndex.delete(id);
|
|
@@ -19329,7 +19000,7 @@ var init_qe_reasoning_bank = __esm({
|
|
|
19329
19000
|
enableLearning: true,
|
|
19330
19001
|
enableGuidance: true,
|
|
19331
19002
|
enableRouting: true,
|
|
19332
|
-
embeddingDimension:
|
|
19003
|
+
embeddingDimension: 768,
|
|
19333
19004
|
useONNXEmbeddings: true,
|
|
19334
19005
|
// ADR-051: Enable ONNX embeddings by default
|
|
19335
19006
|
maxRoutingCandidates: 10,
|
|
@@ -19429,7 +19100,15 @@ var init_qe_reasoning_bank = __esm({
|
|
|
19429
19100
|
await this.loadPretrainedPatterns();
|
|
19430
19101
|
this.initialized = true;
|
|
19431
19102
|
try {
|
|
19432
|
-
|
|
19103
|
+
const SEED_FLAG_KEY = "reasoning-bank:cross-domain-seeded";
|
|
19104
|
+
const alreadySeeded = await this.memory.get(SEED_FLAG_KEY);
|
|
19105
|
+
if (!alreadySeeded) {
|
|
19106
|
+
await this.memory.set(SEED_FLAG_KEY, true);
|
|
19107
|
+
await this.seedCrossDomainPatterns();
|
|
19108
|
+
} else {
|
|
19109
|
+
const stats = await this.patternStore.getStats();
|
|
19110
|
+
console.log(`[QEReasoningBank] Cross-domain transfer already complete (${stats.totalPatterns} patterns)`);
|
|
19111
|
+
}
|
|
19433
19112
|
} catch (error) {
|
|
19434
19113
|
console.warn("[QEReasoningBank] Cross-domain seeding failed (non-fatal):", error);
|
|
19435
19114
|
}
|
|
@@ -20329,7 +20008,8 @@ On promotion:
|
|
|
20329
20008
|
outcome.metrics ? JSON.stringify(outcome.metrics) : null,
|
|
20330
20009
|
outcome.feedback || null
|
|
20331
20010
|
);
|
|
20332
|
-
} catch {
|
|
20011
|
+
} catch (analyticsError) {
|
|
20012
|
+
console.warn(`[QEReasoningBank] Analytics write failed: ${analyticsError instanceof Error ? analyticsError.message : String(analyticsError)}`);
|
|
20333
20013
|
}
|
|
20334
20014
|
if (result.success) {
|
|
20335
20015
|
this.stats.learningOutcomes++;
|
|
@@ -20870,15 +20550,15 @@ var init_trajectory_bridge = __esm({
|
|
|
20870
20550
|
try {
|
|
20871
20551
|
const { join: join26 } = await import("path");
|
|
20872
20552
|
const { existsSync: existsSync18, mkdirSync: mkdirSync6 } = await import("fs");
|
|
20873
|
-
const { createRequire:
|
|
20874
|
-
const require3 =
|
|
20875
|
-
const
|
|
20553
|
+
const { createRequire: createRequire11 } = await import("module");
|
|
20554
|
+
const require3 = createRequire11(import.meta.url);
|
|
20555
|
+
const Database = require3("better-sqlite3");
|
|
20876
20556
|
const dbPath = join26(this.options.projectRoot, ".agentic-qe", "trajectories.db");
|
|
20877
20557
|
const dir = join26(this.options.projectRoot, ".agentic-qe");
|
|
20878
20558
|
if (!existsSync18(dir)) {
|
|
20879
20559
|
mkdirSync6(dir, { recursive: true });
|
|
20880
20560
|
}
|
|
20881
|
-
const db = new
|
|
20561
|
+
const db = new Database(dbPath);
|
|
20882
20562
|
db.exec(`
|
|
20883
20563
|
CREATE TABLE IF NOT EXISTS trajectories (
|
|
20884
20564
|
id TEXT PRIMARY KEY,
|
|
@@ -23303,22 +22983,22 @@ var init_category_adapter = __esm({
|
|
|
23303
22983
|
* @param pipeline - The pipeline to verify
|
|
23304
22984
|
* @returns Type verification result
|
|
23305
22985
|
*/
|
|
23306
|
-
verifyPipeline(
|
|
22986
|
+
verifyPipeline(pipeline9) {
|
|
23307
22987
|
const startTime = Date.now();
|
|
23308
22988
|
this.clear();
|
|
23309
|
-
this.addType(
|
|
23310
|
-
this.addType(
|
|
23311
|
-
for (const element of
|
|
22989
|
+
this.addType(pipeline9.inputType, this.inferSchema(pipeline9.inputType));
|
|
22990
|
+
this.addType(pipeline9.outputType, this.inferSchema(pipeline9.outputType));
|
|
22991
|
+
for (const element of pipeline9.elements) {
|
|
23312
22992
|
this.addType(element.inputType, this.inferSchema(element.inputType));
|
|
23313
22993
|
this.addType(element.outputType, this.inferSchema(element.outputType));
|
|
23314
22994
|
}
|
|
23315
|
-
for (const element of
|
|
22995
|
+
for (const element of pipeline9.elements) {
|
|
23316
22996
|
this.addMorphism(element.inputType, element.outputType, element.name);
|
|
23317
22997
|
}
|
|
23318
|
-
const path21 = this.buildCompositionPath(
|
|
22998
|
+
const path21 = this.buildCompositionPath(pipeline9);
|
|
23319
22999
|
const compositionValid = this.verifyComposition(path21);
|
|
23320
23000
|
const mismatches = this.checkTypeConsistency();
|
|
23321
|
-
const warnings = this.generateWarnings(
|
|
23001
|
+
const warnings = this.generateWarnings(pipeline9, compositionValid, mismatches);
|
|
23322
23002
|
const durationMs = Date.now() - startTime;
|
|
23323
23003
|
const result = {
|
|
23324
23004
|
isValid: compositionValid && mismatches.length === 0,
|
|
@@ -23328,7 +23008,7 @@ var init_category_adapter = __esm({
|
|
|
23328
23008
|
usedFallback: false
|
|
23329
23009
|
};
|
|
23330
23010
|
this.logger.info("Verified pipeline", {
|
|
23331
|
-
pipelineId:
|
|
23011
|
+
pipelineId: pipeline9.id,
|
|
23332
23012
|
isValid: result.isValid,
|
|
23333
23013
|
mismatchCount: mismatches.length,
|
|
23334
23014
|
warningCount: warnings.length,
|
|
@@ -23339,16 +23019,16 @@ var init_category_adapter = __esm({
|
|
|
23339
23019
|
/**
|
|
23340
23020
|
* Build a composition path from a pipeline
|
|
23341
23021
|
*/
|
|
23342
|
-
buildCompositionPath(
|
|
23343
|
-
const path21 = [
|
|
23344
|
-
for (const element of
|
|
23022
|
+
buildCompositionPath(pipeline9) {
|
|
23023
|
+
const path21 = [pipeline9.inputType];
|
|
23024
|
+
for (const element of pipeline9.elements) {
|
|
23345
23025
|
if (element.inputType !== path21[path21.length - 1]) {
|
|
23346
23026
|
path21.push(element.inputType);
|
|
23347
23027
|
}
|
|
23348
23028
|
path21.push(element.outputType);
|
|
23349
23029
|
}
|
|
23350
|
-
if (path21[path21.length - 1] !==
|
|
23351
|
-
path21.push(
|
|
23030
|
+
if (path21[path21.length - 1] !== pipeline9.outputType) {
|
|
23031
|
+
path21.push(pipeline9.outputType);
|
|
23352
23032
|
}
|
|
23353
23033
|
return path21;
|
|
23354
23034
|
}
|
|
@@ -23394,21 +23074,21 @@ var init_category_adapter = __esm({
|
|
|
23394
23074
|
/**
|
|
23395
23075
|
* Generate warnings for potential issues
|
|
23396
23076
|
*/
|
|
23397
|
-
generateWarnings(
|
|
23077
|
+
generateWarnings(pipeline9, compositionValid, mismatches) {
|
|
23398
23078
|
const warnings = [];
|
|
23399
23079
|
if (!compositionValid) {
|
|
23400
23080
|
warnings.push(
|
|
23401
|
-
`Pipeline '${
|
|
23081
|
+
`Pipeline '${pipeline9.id}' has an invalid composition chain. Types do not connect properly from input to output.`
|
|
23402
23082
|
);
|
|
23403
23083
|
}
|
|
23404
|
-
for (const element of
|
|
23084
|
+
for (const element of pipeline9.elements) {
|
|
23405
23085
|
if (element.inputType === "any" || element.outputType === "any") {
|
|
23406
23086
|
warnings.push(
|
|
23407
23087
|
`Element '${element.name}' uses 'any' type, which bypasses type safety.`
|
|
23408
23088
|
);
|
|
23409
23089
|
}
|
|
23410
23090
|
}
|
|
23411
|
-
for (const element of
|
|
23091
|
+
for (const element of pipeline9.elements) {
|
|
23412
23092
|
if (element.inputType.includes("<T>") || element.outputType.includes("<T>")) {
|
|
23413
23093
|
warnings.push(
|
|
23414
23094
|
`Element '${element.name}' has unconstrained generic types.`
|
|
@@ -24358,21 +24038,21 @@ var init_coherence_service = __esm({
|
|
|
24358
24038
|
/**
|
|
24359
24039
|
* Verify type consistency in a pipeline
|
|
24360
24040
|
*/
|
|
24361
|
-
async verifyTypes(
|
|
24041
|
+
async verifyTypes(pipeline9) {
|
|
24362
24042
|
this.ensureInitialized();
|
|
24363
24043
|
if (this.categoryAdapter?.isInitialized()) {
|
|
24364
|
-
return this.categoryAdapter.verifyPipeline(
|
|
24044
|
+
return this.categoryAdapter.verifyPipeline(pipeline9);
|
|
24365
24045
|
}
|
|
24366
|
-
return this.verifyTypesWithFallback(
|
|
24046
|
+
return this.verifyTypesWithFallback(pipeline9);
|
|
24367
24047
|
}
|
|
24368
24048
|
/**
|
|
24369
24049
|
* Fallback type verification using simple matching
|
|
24370
24050
|
*/
|
|
24371
|
-
verifyTypesWithFallback(
|
|
24051
|
+
verifyTypesWithFallback(pipeline9) {
|
|
24372
24052
|
const startTime = Date.now();
|
|
24373
24053
|
const mismatches = [];
|
|
24374
|
-
let currentType =
|
|
24375
|
-
for (const element of
|
|
24054
|
+
let currentType = pipeline9.inputType;
|
|
24055
|
+
for (const element of pipeline9.elements) {
|
|
24376
24056
|
if (element.inputType !== currentType && currentType !== "any") {
|
|
24377
24057
|
mismatches.push({
|
|
24378
24058
|
location: element.name,
|
|
@@ -24383,10 +24063,10 @@ var init_coherence_service = __esm({
|
|
|
24383
24063
|
}
|
|
24384
24064
|
currentType = element.outputType;
|
|
24385
24065
|
}
|
|
24386
|
-
if (currentType !==
|
|
24066
|
+
if (currentType !== pipeline9.outputType && currentType !== "any") {
|
|
24387
24067
|
mismatches.push({
|
|
24388
24068
|
location: "pipeline output",
|
|
24389
|
-
expected:
|
|
24069
|
+
expected: pipeline9.outputType,
|
|
24390
24070
|
actual: currentType,
|
|
24391
24071
|
severity: "critical"
|
|
24392
24072
|
});
|
|
@@ -24754,8 +24434,53 @@ var init_coherence_service = __esm({
|
|
|
24754
24434
|
}
|
|
24755
24435
|
});
|
|
24756
24436
|
|
|
24437
|
+
// native-require:prime-radiant-advanced-wasm
|
|
24438
|
+
var prime_radiant_advanced_wasm_exports = {};
|
|
24439
|
+
__export(prime_radiant_advanced_wasm_exports, {
|
|
24440
|
+
DotProductAttention: () => DotProductAttention7,
|
|
24441
|
+
FlashAttention: () => FlashAttention7,
|
|
24442
|
+
HyperbolicAttention: () => HyperbolicAttention7,
|
|
24443
|
+
LinearAttention: () => LinearAttention7,
|
|
24444
|
+
MoEAttention: () => MoEAttention7,
|
|
24445
|
+
MultiHeadAttention: () => MultiHeadAttention7,
|
|
24446
|
+
RuvectorLayer: () => RuvectorLayer7,
|
|
24447
|
+
SonaEngine: () => SonaEngine7,
|
|
24448
|
+
TensorCompress: () => TensorCompress7,
|
|
24449
|
+
default: () => prime_radiant_advanced_wasm_default,
|
|
24450
|
+
differentiableSearch: () => differentiableSearch7,
|
|
24451
|
+
getCompressionLevel: () => getCompressionLevel7,
|
|
24452
|
+
hierarchicalForward: () => hierarchicalForward7,
|
|
24453
|
+
init: () => init7,
|
|
24454
|
+
pipeline: () => pipeline8
|
|
24455
|
+
});
|
|
24456
|
+
import { createRequire as createRequire8 } from "module";
|
|
24457
|
+
var __require8, __mod7, prime_radiant_advanced_wasm_default, RuvectorLayer7, TensorCompress7, differentiableSearch7, hierarchicalForward7, getCompressionLevel7, init7, FlashAttention7, DotProductAttention7, MultiHeadAttention7, HyperbolicAttention7, LinearAttention7, MoEAttention7, SonaEngine7, pipeline8;
|
|
24458
|
+
var init_prime_radiant_advanced_wasm = __esm({
|
|
24459
|
+
"native-require:prime-radiant-advanced-wasm"() {
|
|
24460
|
+
__require8 = createRequire8(import.meta.url);
|
|
24461
|
+
__mod7 = __require8("prime-radiant-advanced-wasm");
|
|
24462
|
+
prime_radiant_advanced_wasm_default = __mod7;
|
|
24463
|
+
({
|
|
24464
|
+
RuvectorLayer: RuvectorLayer7,
|
|
24465
|
+
TensorCompress: TensorCompress7,
|
|
24466
|
+
differentiableSearch: differentiableSearch7,
|
|
24467
|
+
hierarchicalForward: hierarchicalForward7,
|
|
24468
|
+
getCompressionLevel: getCompressionLevel7,
|
|
24469
|
+
init: init7,
|
|
24470
|
+
FlashAttention: FlashAttention7,
|
|
24471
|
+
DotProductAttention: DotProductAttention7,
|
|
24472
|
+
MultiHeadAttention: MultiHeadAttention7,
|
|
24473
|
+
HyperbolicAttention: HyperbolicAttention7,
|
|
24474
|
+
LinearAttention: LinearAttention7,
|
|
24475
|
+
MoEAttention: MoEAttention7,
|
|
24476
|
+
SonaEngine: SonaEngine7,
|
|
24477
|
+
pipeline: pipeline8
|
|
24478
|
+
} = __mod7 || {});
|
|
24479
|
+
}
|
|
24480
|
+
});
|
|
24481
|
+
|
|
24757
24482
|
// src/integrations/coherence/wasm-loader.ts
|
|
24758
|
-
import { createRequire as
|
|
24483
|
+
import { createRequire as createRequire9 } from "node:module";
|
|
24759
24484
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
24760
24485
|
import { dirname as dirname4, join as join18 } from "node:path";
|
|
24761
24486
|
import { readFileSync as readFileSync11, existsSync as existsSync13 } from "node:fs";
|
|
@@ -25016,7 +24741,7 @@ var init_wasm_loader = __esm({
|
|
|
25016
24741
|
return false;
|
|
25017
24742
|
}
|
|
25018
24743
|
try {
|
|
25019
|
-
const require3 =
|
|
24744
|
+
const require3 = createRequire9(import.meta.url);
|
|
25020
24745
|
const wasmPaths = [
|
|
25021
24746
|
(() => {
|
|
25022
24747
|
try {
|
|
@@ -25224,13 +24949,13 @@ var init_wasm_loader = __esm({
|
|
|
25224
24949
|
async attemptLoad() {
|
|
25225
24950
|
let require3;
|
|
25226
24951
|
try {
|
|
25227
|
-
require3 =
|
|
24952
|
+
require3 = createRequire9(import.meta.url);
|
|
25228
24953
|
} catch {
|
|
25229
24954
|
require3 = globalThis.require || (await import("module")).createRequire(__filename);
|
|
25230
24955
|
}
|
|
25231
24956
|
let wasmModule2;
|
|
25232
24957
|
try {
|
|
25233
|
-
wasmModule2 = await
|
|
24958
|
+
wasmModule2 = await Promise.resolve().then(() => (init_prime_radiant_advanced_wasm(), prime_radiant_advanced_wasm_exports));
|
|
25234
24959
|
} catch (importError) {
|
|
25235
24960
|
try {
|
|
25236
24961
|
wasmModule2 = require3("prime-radiant-advanced-wasm");
|
|
@@ -30599,7 +30324,7 @@ function createEventAdapter(config = {}) {
|
|
|
30599
30324
|
}
|
|
30600
30325
|
|
|
30601
30326
|
// src/adapters/ag-ui/json-patch.ts
|
|
30602
|
-
|
|
30327
|
+
import * as fastJsonPatch from "fast-json-patch";
|
|
30603
30328
|
|
|
30604
30329
|
// src/adapters/ag-ui/backpressure-handler.ts
|
|
30605
30330
|
var DEFAULT_CONFIG7 = {
|
|
@@ -31253,6 +30978,7 @@ var HybridMemoryBackend = class {
|
|
|
31253
30978
|
unifiedMemory = null;
|
|
31254
30979
|
config;
|
|
31255
30980
|
cleanupInterval;
|
|
30981
|
+
cleanupCount = 0;
|
|
31256
30982
|
initialized = false;
|
|
31257
30983
|
constructor(config) {
|
|
31258
30984
|
this.config = {
|
|
@@ -31469,6 +31195,31 @@ var HybridMemoryBackend = class {
|
|
|
31469
31195
|
if (this.unifiedMemory?.isInitialized()) {
|
|
31470
31196
|
try {
|
|
31471
31197
|
await this.unifiedMemory.kvCleanupExpired();
|
|
31198
|
+
const db = this.unifiedMemory.getDatabase();
|
|
31199
|
+
try {
|
|
31200
|
+
const expired = db.prepare("DELETE FROM kv_store WHERE expires_at IS NOT NULL AND expires_at < ?").run(Date.now());
|
|
31201
|
+
if (expired.changes > 0) {
|
|
31202
|
+
console.log(`[HybridBackend] Expired ${expired.changes} kv_store entries`);
|
|
31203
|
+
}
|
|
31204
|
+
} catch (e20) {
|
|
31205
|
+
}
|
|
31206
|
+
this.cleanupCount++;
|
|
31207
|
+
if (this.cleanupCount % 10 === 0) {
|
|
31208
|
+
try {
|
|
31209
|
+
const kvCount = db.prepare("SELECT COUNT(*) as cnt FROM kv_store").get();
|
|
31210
|
+
if (kvCount.cnt > 5e3) {
|
|
31211
|
+
const deleted = db.prepare(`
|
|
31212
|
+
DELETE FROM kv_store WHERE rowid NOT IN (
|
|
31213
|
+
SELECT rowid FROM kv_store ORDER BY rowid DESC LIMIT 5000
|
|
31214
|
+
)
|
|
31215
|
+
`).run();
|
|
31216
|
+
if (deleted.changes > 0) {
|
|
31217
|
+
console.log(`[HybridBackend] kv_store retention: pruned ${deleted.changes} rows (kept 5000)`);
|
|
31218
|
+
}
|
|
31219
|
+
}
|
|
31220
|
+
} catch (e20) {
|
|
31221
|
+
}
|
|
31222
|
+
}
|
|
31472
31223
|
} catch (error) {
|
|
31473
31224
|
console.warn("[HybridBackend] Cleanup failed:", error);
|
|
31474
31225
|
}
|
|
@@ -43707,11 +43458,19 @@ var isConstitutionalEnforcerEnabled = () => governanceFlags.isGateEnabled("const
|
|
|
43707
43458
|
var isStrictMode = () => governanceFlags.getFlags().global.strictMode;
|
|
43708
43459
|
|
|
43709
43460
|
// src/governance/continue-gate-integration.ts
|
|
43710
|
-
|
|
43461
|
+
init_unified_memory();
|
|
43462
|
+
var ContinueGateIntegration = class _ContinueGateIntegration {
|
|
43711
43463
|
actionHistory = /* @__PURE__ */ new Map();
|
|
43712
43464
|
throttledAgents = /* @__PURE__ */ new Map();
|
|
43713
43465
|
guidanceContinueGate = null;
|
|
43714
43466
|
initialized = false;
|
|
43467
|
+
db = null;
|
|
43468
|
+
persistCount = 0;
|
|
43469
|
+
static KV_NAMESPACE = "continue-gate-actions";
|
|
43470
|
+
static KV_KEY = "snapshot";
|
|
43471
|
+
static PERSIST_INTERVAL = 20;
|
|
43472
|
+
static KV_TTL = 3600;
|
|
43473
|
+
// 1 hour
|
|
43715
43474
|
/**
|
|
43716
43475
|
* Initialize the ContinueGate integration
|
|
43717
43476
|
*
|
|
@@ -43722,8 +43481,48 @@ var ContinueGateIntegration = class {
|
|
|
43722
43481
|
*/
|
|
43723
43482
|
async initialize() {
|
|
43724
43483
|
if (this.initialized) return;
|
|
43484
|
+
try {
|
|
43485
|
+
this.db = getUnifiedMemory();
|
|
43486
|
+
if (!this.db.isInitialized()) await this.db.initialize();
|
|
43487
|
+
await this.loadFromKv();
|
|
43488
|
+
} catch (error) {
|
|
43489
|
+
console.warn("[ContinueGateIntegration] DB init failed, using memory-only:", error instanceof Error ? error.message : String(error));
|
|
43490
|
+
this.db = null;
|
|
43491
|
+
}
|
|
43725
43492
|
this.initialized = true;
|
|
43726
43493
|
}
|
|
43494
|
+
async loadFromKv() {
|
|
43495
|
+
if (!this.db) return;
|
|
43496
|
+
const data = await this.db.kvGet(_ContinueGateIntegration.KV_KEY, _ContinueGateIntegration.KV_NAMESPACE);
|
|
43497
|
+
if (data) {
|
|
43498
|
+
for (const [agentId, actions] of data.actionHistory) {
|
|
43499
|
+
this.actionHistory.set(agentId, actions);
|
|
43500
|
+
}
|
|
43501
|
+
const now = Date.now();
|
|
43502
|
+
for (const [agentId, until] of data.throttledAgents) {
|
|
43503
|
+
if (until > now) this.throttledAgents.set(agentId, until);
|
|
43504
|
+
}
|
|
43505
|
+
console.log("[ContinueGateIntegration] Loaded state from DB");
|
|
43506
|
+
}
|
|
43507
|
+
}
|
|
43508
|
+
async persistSnapshot() {
|
|
43509
|
+
if (!this.db) return;
|
|
43510
|
+
try {
|
|
43511
|
+
await this.db.kvSet(
|
|
43512
|
+
_ContinueGateIntegration.KV_KEY,
|
|
43513
|
+
{
|
|
43514
|
+
actionHistory: Array.from(this.actionHistory.entries()).map(
|
|
43515
|
+
([agentId, actions]) => [agentId, actions.slice(-50)]
|
|
43516
|
+
),
|
|
43517
|
+
throttledAgents: Array.from(this.throttledAgents.entries())
|
|
43518
|
+
},
|
|
43519
|
+
_ContinueGateIntegration.KV_NAMESPACE,
|
|
43520
|
+
_ContinueGateIntegration.KV_TTL
|
|
43521
|
+
);
|
|
43522
|
+
} catch (error) {
|
|
43523
|
+
console.warn("[ContinueGateIntegration] Persist failed:", error instanceof Error ? error.message : String(error));
|
|
43524
|
+
}
|
|
43525
|
+
}
|
|
43727
43526
|
/**
|
|
43728
43527
|
* Record an agent action for loop detection
|
|
43729
43528
|
*/
|
|
@@ -43735,6 +43534,11 @@ var ContinueGateIntegration = class {
|
|
|
43735
43534
|
history.shift();
|
|
43736
43535
|
}
|
|
43737
43536
|
this.actionHistory.set(action.agentId, history);
|
|
43537
|
+
this.persistCount++;
|
|
43538
|
+
if (this.persistCount % _ContinueGateIntegration.PERSIST_INTERVAL === 0) {
|
|
43539
|
+
this.persistSnapshot().catch(() => {
|
|
43540
|
+
});
|
|
43541
|
+
}
|
|
43738
43542
|
}
|
|
43739
43543
|
/**
|
|
43740
43544
|
* Evaluate whether an agent should continue
|
|
@@ -45013,6 +44817,7 @@ var DeterministicGatewayIntegration = class {
|
|
|
45013
44817
|
var deterministicGatewayIntegration = new DeterministicGatewayIntegration();
|
|
45014
44818
|
|
|
45015
44819
|
// src/governance/evolution-pipeline-integration.ts
|
|
44820
|
+
init_unified_memory();
|
|
45016
44821
|
function isEvolutionPipelineEnabled() {
|
|
45017
44822
|
const flags = governanceFlags.getFlags();
|
|
45018
44823
|
if (!flags.global.enableAllGates) return false;
|
|
@@ -45028,11 +44833,18 @@ function getEvolutionFlags() {
|
|
|
45028
44833
|
learningRate: 0.1
|
|
45029
44834
|
};
|
|
45030
44835
|
}
|
|
45031
|
-
var EvolutionPipelineIntegration = class {
|
|
44836
|
+
var EvolutionPipelineIntegration = class _EvolutionPipelineIntegration {
|
|
45032
44837
|
rules = /* @__PURE__ */ new Map();
|
|
45033
44838
|
variantTests = /* @__PURE__ */ new Map();
|
|
45034
44839
|
taskOutcomes = /* @__PURE__ */ new Map();
|
|
45035
44840
|
initialized = false;
|
|
44841
|
+
// KV persistence
|
|
44842
|
+
db = null;
|
|
44843
|
+
persistCount = 0;
|
|
44844
|
+
static NAMESPACE = "rule-evolution";
|
|
44845
|
+
static TTL_SECONDS = 604800;
|
|
44846
|
+
// 7 days
|
|
44847
|
+
static PERSIST_INTERVAL = 10;
|
|
45036
44848
|
// Statistics
|
|
45037
44849
|
stats = {
|
|
45038
44850
|
autoPromotions: 0,
|
|
@@ -45050,6 +44862,14 @@ var EvolutionPipelineIntegration = class {
|
|
|
45050
44862
|
*/
|
|
45051
44863
|
async initialize() {
|
|
45052
44864
|
if (this.initialized) return;
|
|
44865
|
+
try {
|
|
44866
|
+
this.db = getUnifiedMemory();
|
|
44867
|
+
if (!this.db.isInitialized()) await this.db.initialize();
|
|
44868
|
+
await this.loadFromKv();
|
|
44869
|
+
} catch (error) {
|
|
44870
|
+
console.warn("[EvolutionPipeline] DB init failed, using memory-only:", error instanceof Error ? error.message : String(error));
|
|
44871
|
+
this.db = null;
|
|
44872
|
+
}
|
|
45053
44873
|
this.initialized = true;
|
|
45054
44874
|
this.logEvent("initialize", "Evolution Pipeline initialized");
|
|
45055
44875
|
}
|
|
@@ -45071,6 +44891,7 @@ var EvolutionPipelineIntegration = class {
|
|
|
45071
44891
|
record.applications.push(application);
|
|
45072
44892
|
this.pruneApplicationHistory(record);
|
|
45073
44893
|
this.checkAutoPromotionDemotion(ruleId);
|
|
44894
|
+
this.persistSnapshot();
|
|
45074
44895
|
this.logEvent("rule_application", `Rule ${ruleId} applied: ${success ? "success" : "failure"}`);
|
|
45075
44896
|
}
|
|
45076
44897
|
/**
|
|
@@ -45495,6 +45316,36 @@ var EvolutionPipelineIntegration = class {
|
|
|
45495
45316
|
this.rules.delete(ruleId);
|
|
45496
45317
|
}
|
|
45497
45318
|
// ============================================================================
|
|
45319
|
+
// KV Persistence
|
|
45320
|
+
// ============================================================================
|
|
45321
|
+
/**
|
|
45322
|
+
* Load rules snapshot from KV store
|
|
45323
|
+
*/
|
|
45324
|
+
async loadFromKv() {
|
|
45325
|
+
if (!this.db) return;
|
|
45326
|
+
const data = await this.db.kvGet("snapshot", _EvolutionPipelineIntegration.NAMESPACE);
|
|
45327
|
+
if (data) {
|
|
45328
|
+
for (const [key, record] of Object.entries(data)) {
|
|
45329
|
+
this.rules.set(key, record);
|
|
45330
|
+
}
|
|
45331
|
+
}
|
|
45332
|
+
}
|
|
45333
|
+
/**
|
|
45334
|
+
* Persist rules snapshot to KV store on interval
|
|
45335
|
+
*/
|
|
45336
|
+
persistSnapshot() {
|
|
45337
|
+
if (!this.db) return;
|
|
45338
|
+
this.persistCount++;
|
|
45339
|
+
if (this.persistCount % _EvolutionPipelineIntegration.PERSIST_INTERVAL !== 0) return;
|
|
45340
|
+
try {
|
|
45341
|
+
const snapshot = Object.fromEntries(this.rules);
|
|
45342
|
+
this.db.kvSet("snapshot", snapshot, _EvolutionPipelineIntegration.NAMESPACE, _EvolutionPipelineIntegration.TTL_SECONDS).catch(() => {
|
|
45343
|
+
});
|
|
45344
|
+
} catch (error) {
|
|
45345
|
+
console.warn("[EvolutionPipeline] Persist failed:", error instanceof Error ? error.message : String(error));
|
|
45346
|
+
}
|
|
45347
|
+
}
|
|
45348
|
+
// ============================================================================
|
|
45498
45349
|
// Private Helpers
|
|
45499
45350
|
// ============================================================================
|
|
45500
45351
|
/**
|
|
@@ -47839,6 +47690,7 @@ var ProofEnvelopeIntegration = class {
|
|
|
47839
47690
|
var proofEnvelopeIntegration = new ProofEnvelopeIntegration();
|
|
47840
47691
|
|
|
47841
47692
|
// src/governance/compliance-reporter.ts
|
|
47693
|
+
init_unified_memory();
|
|
47842
47694
|
var DEFAULT_COMPLIANCE_REPORTER_FLAGS = {
|
|
47843
47695
|
enabled: true,
|
|
47844
47696
|
autoRecordViolations: true,
|
|
@@ -47855,7 +47707,7 @@ var SEVERITY_WEIGHTS = {
|
|
|
47855
47707
|
var DEFAULT_SCORE = 100;
|
|
47856
47708
|
var SCORE_DECAY_RATE = 0.5;
|
|
47857
47709
|
var TREND_THRESHOLD = 5;
|
|
47858
|
-
var ComplianceReporter = class {
|
|
47710
|
+
var ComplianceReporter = class _ComplianceReporter {
|
|
47859
47711
|
violations = /* @__PURE__ */ new Map();
|
|
47860
47712
|
alertThresholds = /* @__PURE__ */ new Map();
|
|
47861
47713
|
proofIntegration;
|
|
@@ -47863,6 +47715,13 @@ var ComplianceReporter = class {
|
|
|
47863
47715
|
initialized = false;
|
|
47864
47716
|
scoreHistory = [];
|
|
47865
47717
|
alertListeners = /* @__PURE__ */ new Set();
|
|
47718
|
+
// KV persistence
|
|
47719
|
+
db = null;
|
|
47720
|
+
persistCount = 0;
|
|
47721
|
+
static NAMESPACE = "compliance-audit";
|
|
47722
|
+
static TTL_SECONDS = 2592e3;
|
|
47723
|
+
// 30 days
|
|
47724
|
+
static PERSIST_INTERVAL = 10;
|
|
47866
47725
|
/**
|
|
47867
47726
|
* Create a new ComplianceReporter instance
|
|
47868
47727
|
*
|
|
@@ -47878,6 +47737,14 @@ var ComplianceReporter = class {
|
|
|
47878
47737
|
*/
|
|
47879
47738
|
async initialize() {
|
|
47880
47739
|
if (this.initialized) return;
|
|
47740
|
+
try {
|
|
47741
|
+
this.db = getUnifiedMemory();
|
|
47742
|
+
if (!this.db.isInitialized()) await this.db.initialize();
|
|
47743
|
+
await this.loadFromKv();
|
|
47744
|
+
} catch (error) {
|
|
47745
|
+
console.warn("[ComplianceReporter] DB init failed, using memory-only:", error instanceof Error ? error.message : String(error));
|
|
47746
|
+
this.db = null;
|
|
47747
|
+
}
|
|
47881
47748
|
if (!this.proofIntegration.isInitialized()) {
|
|
47882
47749
|
await this.proofIntegration.initialize();
|
|
47883
47750
|
}
|
|
@@ -47946,6 +47813,7 @@ var ComplianceReporter = class {
|
|
|
47946
47813
|
if (this.flags.alertOnCritical && violation.severity === "critical") {
|
|
47947
47814
|
this.triggerAlert(violation.gate, "Critical violation detected", "critical");
|
|
47948
47815
|
}
|
|
47816
|
+
this.persistSnapshot();
|
|
47949
47817
|
this.cleanupOldViolations();
|
|
47950
47818
|
return id;
|
|
47951
47819
|
}
|
|
@@ -48034,14 +47902,14 @@ var ComplianceReporter = class {
|
|
|
48034
47902
|
*/
|
|
48035
47903
|
calculateScore(timeWindow) {
|
|
48036
47904
|
const now = Date.now();
|
|
48037
|
-
const
|
|
47905
|
+
const window = timeWindow ?? {
|
|
48038
47906
|
start: now - 24 * 60 * 60 * 1e3,
|
|
48039
47907
|
// Last 24 hours
|
|
48040
47908
|
end: now
|
|
48041
47909
|
};
|
|
48042
47910
|
const violations = this.getViolations({
|
|
48043
|
-
startTime:
|
|
48044
|
-
endTime:
|
|
47911
|
+
startTime: window.start,
|
|
47912
|
+
endTime: window.end
|
|
48045
47913
|
});
|
|
48046
47914
|
const overall = this.calculateOverallScore(violations);
|
|
48047
47915
|
const byGate = {};
|
|
@@ -48056,14 +47924,14 @@ var ComplianceReporter = class {
|
|
|
48056
47924
|
byAgent[agentId] = this.calculateOverallScore(agentViols);
|
|
48057
47925
|
}
|
|
48058
47926
|
}
|
|
48059
|
-
const trend = this.calculateTrend(
|
|
47927
|
+
const trend = this.calculateTrend(window);
|
|
48060
47928
|
const resolvedCount = violations.filter((v62) => v62.resolved).length;
|
|
48061
47929
|
const score = {
|
|
48062
47930
|
overall,
|
|
48063
47931
|
byGate,
|
|
48064
47932
|
byAgent,
|
|
48065
47933
|
trend,
|
|
48066
|
-
period:
|
|
47934
|
+
period: window,
|
|
48067
47935
|
totalViolations: violations.length,
|
|
48068
47936
|
resolvedViolations: resolvedCount
|
|
48069
47937
|
};
|
|
@@ -48375,6 +48243,45 @@ var ComplianceReporter = class {
|
|
|
48375
48243
|
this.initialized = false;
|
|
48376
48244
|
}
|
|
48377
48245
|
// ============================================================================
|
|
48246
|
+
// KV Persistence
|
|
48247
|
+
// ============================================================================
|
|
48248
|
+
/**
|
|
48249
|
+
* Load violations and score history from KV store
|
|
48250
|
+
*/
|
|
48251
|
+
async loadFromKv() {
|
|
48252
|
+
if (!this.db) return;
|
|
48253
|
+
const data = await this.db.kvGet("snapshot", _ComplianceReporter.NAMESPACE);
|
|
48254
|
+
if (data) {
|
|
48255
|
+
if (data.violations) {
|
|
48256
|
+
for (const [key, violation] of Object.entries(data.violations)) {
|
|
48257
|
+
this.violations.set(key, violation);
|
|
48258
|
+
}
|
|
48259
|
+
}
|
|
48260
|
+
if (data.scoreHistory) {
|
|
48261
|
+
this.scoreHistory = data.scoreHistory;
|
|
48262
|
+
}
|
|
48263
|
+
}
|
|
48264
|
+
}
|
|
48265
|
+
/**
|
|
48266
|
+
* Persist violations and score history to KV store on interval
|
|
48267
|
+
*/
|
|
48268
|
+
persistSnapshot() {
|
|
48269
|
+
if (!this.db) return;
|
|
48270
|
+
this.persistCount++;
|
|
48271
|
+
if (this.persistCount % _ComplianceReporter.PERSIST_INTERVAL !== 0) return;
|
|
48272
|
+
try {
|
|
48273
|
+
const violationEntries = Array.from(this.violations.entries()).slice(-500);
|
|
48274
|
+
const snapshot = {
|
|
48275
|
+
violations: Object.fromEntries(violationEntries),
|
|
48276
|
+
scoreHistory: this.scoreHistory.slice(-100)
|
|
48277
|
+
};
|
|
48278
|
+
this.db.kvSet("snapshot", snapshot, _ComplianceReporter.NAMESPACE, _ComplianceReporter.TTL_SECONDS).catch(() => {
|
|
48279
|
+
});
|
|
48280
|
+
} catch (error) {
|
|
48281
|
+
console.warn("[ComplianceReporter] Persist failed:", error instanceof Error ? error.message : String(error));
|
|
48282
|
+
}
|
|
48283
|
+
}
|
|
48284
|
+
// ============================================================================
|
|
48378
48285
|
// Private Methods
|
|
48379
48286
|
// ============================================================================
|
|
48380
48287
|
/**
|
|
@@ -83277,13 +83184,6 @@ var KnowledgeGraphService = class {
|
|
|
83277
83184
|
async clear() {
|
|
83278
83185
|
this.nodeCache.clear();
|
|
83279
83186
|
this.edgeIndex.clear();
|
|
83280
|
-
const nodePattern = `${this.config.namespace}:node:*`;
|
|
83281
|
-
const edgePattern = `${this.config.namespace}:edge:*`;
|
|
83282
|
-
const nodeKeys = await this.memory.search(nodePattern, this.config.maxNodes);
|
|
83283
|
-
const edgeKeys = await this.memory.search(edgePattern, this.config.maxNodes * 10);
|
|
83284
|
-
for (const key of [...nodeKeys, ...edgeKeys]) {
|
|
83285
|
-
await this.memory.delete(key);
|
|
83286
|
-
}
|
|
83287
83187
|
}
|
|
83288
83188
|
// ============================================================================
|
|
83289
83189
|
// ADR-051: LLM Enhancement Methods
|
|
@@ -83518,26 +83418,18 @@ ${JSON.stringify(results.map((n61) => ({ id: n61.id, label: n61.label, propertie
|
|
|
83518
83418
|
await this.createEdge(sourceId, targetId, rel.type);
|
|
83519
83419
|
edgesCreated++;
|
|
83520
83420
|
}
|
|
83521
|
-
|
|
83522
|
-
|
|
83523
|
-
|
|
83524
|
-
relationships.designPatterns
|
|
83525
|
-
|
|
83526
|
-
)
|
|
83527
|
-
|
|
83528
|
-
|
|
83529
|
-
|
|
83530
|
-
|
|
83531
|
-
|
|
83532
|
-
|
|
83533
|
-
);
|
|
83534
|
-
}
|
|
83535
|
-
if (relationships.dependencyImpacts.length > 0) {
|
|
83536
|
-
await this.memory.set(
|
|
83537
|
-
`${this.config.namespace}:impacts:${fileNodeId}`,
|
|
83538
|
-
relationships.dependencyImpacts,
|
|
83539
|
-
{ namespace: this.config.namespace }
|
|
83540
|
-
);
|
|
83421
|
+
const node = this.nodeCache.get(fileNodeId);
|
|
83422
|
+
if (node) {
|
|
83423
|
+
if (relationships.designPatterns.length > 0) {
|
|
83424
|
+
node.properties.designPatterns = relationships.designPatterns;
|
|
83425
|
+
}
|
|
83426
|
+
if (relationships.architecturalBoundaries.length > 0) {
|
|
83427
|
+
node.properties.architecturalBoundaries = relationships.architecturalBoundaries;
|
|
83428
|
+
}
|
|
83429
|
+
if (relationships.dependencyImpacts.length > 0) {
|
|
83430
|
+
node.properties.dependencyImpacts = relationships.dependencyImpacts;
|
|
83431
|
+
}
|
|
83432
|
+
this.nodeCache.set(fileNodeId, node);
|
|
83541
83433
|
}
|
|
83542
83434
|
return edgesCreated;
|
|
83543
83435
|
}
|
|
@@ -83587,9 +83479,6 @@ ${JSON.stringify(results.map((n61) => ({ id: n61.id, label: n61.label, propertie
|
|
|
83587
83479
|
target: targetId,
|
|
83588
83480
|
type
|
|
83589
83481
|
};
|
|
83590
|
-
await this.memory.set(`${this.config.namespace}:edge:${edgeId}`, edge, {
|
|
83591
|
-
namespace: this.config.namespace
|
|
83592
|
-
});
|
|
83593
83482
|
const sourceEdges = this.edgeIndex.get(sourceId) || [];
|
|
83594
83483
|
sourceEdges.push(edge);
|
|
83595
83484
|
this.edgeIndex.set(sourceId, sourceEdges);
|
|
@@ -83601,12 +83490,8 @@ ${JSON.stringify(results.map((n61) => ({ id: n61.id, label: n61.label, propertie
|
|
|
83601
83490
|
if (firstKey) {
|
|
83602
83491
|
this.nodeCache.delete(firstKey);
|
|
83603
83492
|
this.edgeIndex.delete(firstKey);
|
|
83604
|
-
await this.memory.delete(`${this.config.namespace}:node:${firstKey}`);
|
|
83605
83493
|
}
|
|
83606
83494
|
}
|
|
83607
|
-
await this.memory.set(`${this.config.namespace}:node:${node.id}`, node, {
|
|
83608
|
-
namespace: this.config.namespace
|
|
83609
|
-
});
|
|
83610
83495
|
this.nodeCache.set(node.id, node);
|
|
83611
83496
|
}
|
|
83612
83497
|
async extractEntities(filePath) {
|
|
@@ -83997,11 +83882,7 @@ ${JSON.stringify(results.map((n61) => ({ id: n61.id, label: n61.label, propertie
|
|
|
83997
83882
|
return true;
|
|
83998
83883
|
});
|
|
83999
83884
|
}
|
|
84000
|
-
async storeIndexMetadata(
|
|
84001
|
-
await this.memory.set(`${this.config.namespace}:metadata:index`, metadata, {
|
|
84002
|
-
namespace: this.config.namespace,
|
|
84003
|
-
persist: true
|
|
84004
|
-
});
|
|
83885
|
+
async storeIndexMetadata(_metadata) {
|
|
84005
83886
|
}
|
|
84006
83887
|
async generateEmbedding(entity) {
|
|
84007
83888
|
const text2 = `${entity.type} ${entity.name} ${entity.visibility}${entity.isAsync ? " async" : ""}`;
|
|
@@ -87099,15 +86980,17 @@ var CodeIntelligenceCoordinator = class {
|
|
|
87099
86980
|
*/
|
|
87100
86981
|
async initializeHypergraph() {
|
|
87101
86982
|
try {
|
|
87102
|
-
const
|
|
87103
|
-
const dbPath = this.config.hypergraphDbPath || ".agentic-qe/hypergraph.db";
|
|
86983
|
+
const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
|
|
87104
86984
|
const fs19 = await import("fs");
|
|
87105
86985
|
const path21 = await import("path");
|
|
86986
|
+
const { findProjectRoot: findProjectRoot2 } = await Promise.resolve().then(() => (init_unified_memory(), unified_memory_exports));
|
|
86987
|
+
const projectRoot = findProjectRoot2();
|
|
86988
|
+
const dbPath = this.config.hypergraphDbPath || path21.join(projectRoot, ".agentic-qe", "hypergraph.db");
|
|
87106
86989
|
const dir = path21.dirname(dbPath);
|
|
87107
86990
|
if (!fs19.existsSync(dir)) {
|
|
87108
86991
|
fs19.mkdirSync(dir, { recursive: true });
|
|
87109
86992
|
}
|
|
87110
|
-
this.hypergraphDb = new
|
|
86993
|
+
this.hypergraphDb = new Database(dbPath);
|
|
87111
86994
|
this.hypergraph = await createHypergraphEngine({
|
|
87112
86995
|
db: this.hypergraphDb,
|
|
87113
86996
|
maxTraversalDepth: 10,
|
|
@@ -89732,17 +89615,22 @@ var SASTScanner = class {
|
|
|
89732
89615
|
* Store scan results in memory
|
|
89733
89616
|
*/
|
|
89734
89617
|
async storeScanResults(scanId, scanType, vulnerabilities, summary) {
|
|
89618
|
+
const scanSummary = {
|
|
89619
|
+
scanId,
|
|
89620
|
+
scanType,
|
|
89621
|
+
summary,
|
|
89622
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
89623
|
+
vulnerabilityCount: vulnerabilities.length,
|
|
89624
|
+
// Keep only critical/high vulnerabilities in stored result
|
|
89625
|
+
criticalVulnerabilities: vulnerabilities.filter(
|
|
89626
|
+
(v62) => v62.severity === "critical" || v62.severity === "high"
|
|
89627
|
+
)
|
|
89628
|
+
};
|
|
89735
89629
|
await this.memory.set(
|
|
89736
89630
|
`security:scan:${scanId}`,
|
|
89737
|
-
|
|
89738
|
-
|
|
89739
|
-
|
|
89740
|
-
vulnerabilities,
|
|
89741
|
-
summary,
|
|
89742
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
89743
|
-
},
|
|
89744
|
-
{ namespace: "security-compliance", ttl: 86400 * 7 }
|
|
89745
|
-
// 7 days
|
|
89631
|
+
scanSummary,
|
|
89632
|
+
{ namespace: "security-compliance", ttl: 86400 * 2 }
|
|
89633
|
+
// 2 days (reduced from 7)
|
|
89746
89634
|
);
|
|
89747
89635
|
}
|
|
89748
89636
|
// ==========================================================================
|
|
@@ -119522,8 +119410,34 @@ var MinCutPersistence = class {
|
|
|
119522
119410
|
JSON.stringify(snapshot.vertices),
|
|
119523
119411
|
JSON.stringify(snapshot.edges)
|
|
119524
119412
|
);
|
|
119413
|
+
await this.enforceRetention();
|
|
119525
119414
|
return id;
|
|
119526
119415
|
}
|
|
119416
|
+
/**
|
|
119417
|
+
* Enforce retention limits on snapshots and history to prevent DB bloat (Issue #258)
|
|
119418
|
+
*/
|
|
119419
|
+
async enforceRetention(maxSnapshots = 200) {
|
|
119420
|
+
const db = this.memory.getDatabase();
|
|
119421
|
+
if (!db) return 0;
|
|
119422
|
+
const countRow = db.prepare("SELECT COUNT(*) as count FROM mincut_snapshots").get();
|
|
119423
|
+
if (!countRow || countRow.count <= maxSnapshots) return 0;
|
|
119424
|
+
const deleteCount = countRow.count - maxSnapshots;
|
|
119425
|
+
db.prepare(`
|
|
119426
|
+
DELETE FROM mincut_snapshots WHERE id IN (
|
|
119427
|
+
SELECT id FROM mincut_snapshots ORDER BY created_at ASC LIMIT ?
|
|
119428
|
+
)
|
|
119429
|
+
`).run(deleteCount);
|
|
119430
|
+
const historyCount = db.prepare("SELECT COUNT(*) as count FROM mincut_history").get();
|
|
119431
|
+
if (historyCount.count > 500) {
|
|
119432
|
+
const historyDelete = historyCount.count - 500;
|
|
119433
|
+
db.prepare(`
|
|
119434
|
+
DELETE FROM mincut_history WHERE id IN (
|
|
119435
|
+
SELECT id FROM mincut_history ORDER BY created_at ASC LIMIT ?
|
|
119436
|
+
)
|
|
119437
|
+
`).run(historyDelete);
|
|
119438
|
+
}
|
|
119439
|
+
return deleteCount;
|
|
119440
|
+
}
|
|
119527
119441
|
/**
|
|
119528
119442
|
* Get a snapshot by ID
|
|
119529
119443
|
*/
|
|
@@ -125507,7 +125421,8 @@ var DEFAULT_DYNAMIC_SCALING_CONFIG = {
|
|
|
125507
125421
|
|
|
125508
125422
|
// src/coordination/dynamic-scaling/dynamic-scaler.ts
|
|
125509
125423
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
125510
|
-
|
|
125424
|
+
init_unified_memory();
|
|
125425
|
+
var DynamicScaler = class _DynamicScaler {
|
|
125511
125426
|
config;
|
|
125512
125427
|
policy;
|
|
125513
125428
|
metricsHistory = [];
|
|
@@ -125518,6 +125433,13 @@ var DynamicScaler = class {
|
|
|
125518
125433
|
totalDecisions = 0;
|
|
125519
125434
|
currentAgents;
|
|
125520
125435
|
lastDecision;
|
|
125436
|
+
// KV store persistence (Tier 2)
|
|
125437
|
+
db = null;
|
|
125438
|
+
persistCount = 0;
|
|
125439
|
+
static KV_NAMESPACE = "scaling-metrics";
|
|
125440
|
+
static KV_KEY = "dynamic-scaler-snapshot";
|
|
125441
|
+
static PERSIST_INTERVAL = 10;
|
|
125442
|
+
static KV_TTL = 7200;
|
|
125521
125443
|
/**
|
|
125522
125444
|
* Create a new DynamicScaler.
|
|
125523
125445
|
*
|
|
@@ -125543,6 +125465,11 @@ var DynamicScaler = class {
|
|
|
125543
125465
|
if (this.metricsHistory.length > this.config.metricsHistorySize) {
|
|
125544
125466
|
this.metricsHistory.shift();
|
|
125545
125467
|
}
|
|
125468
|
+
this.persistCount++;
|
|
125469
|
+
if (this.persistCount % _DynamicScaler.PERSIST_INTERVAL === 0) {
|
|
125470
|
+
this.persistSnapshot().catch(() => {
|
|
125471
|
+
});
|
|
125472
|
+
}
|
|
125546
125473
|
}
|
|
125547
125474
|
// --------------------------------------------------------------------------
|
|
125548
125475
|
// Evaluation
|
|
@@ -125740,6 +125667,23 @@ var DynamicScaler = class {
|
|
|
125740
125667
|
// --------------------------------------------------------------------------
|
|
125741
125668
|
// Lifecycle
|
|
125742
125669
|
// --------------------------------------------------------------------------
|
|
125670
|
+
/**
|
|
125671
|
+
* Initialize persistence layer and load last snapshot from KV store.
|
|
125672
|
+
* Safe to call multiple times; will not throw on DB failure.
|
|
125673
|
+
*/
|
|
125674
|
+
async initialize() {
|
|
125675
|
+
try {
|
|
125676
|
+
this.db = getUnifiedMemory();
|
|
125677
|
+
if (!this.db.isInitialized()) await this.db.initialize();
|
|
125678
|
+
await this.loadFromKv();
|
|
125679
|
+
} catch (error) {
|
|
125680
|
+
console.warn(
|
|
125681
|
+
"[DynamicScaler] DB init failed, using memory-only:",
|
|
125682
|
+
error instanceof Error ? error.message : String(error)
|
|
125683
|
+
);
|
|
125684
|
+
this.db = null;
|
|
125685
|
+
}
|
|
125686
|
+
}
|
|
125743
125687
|
/**
|
|
125744
125688
|
* Release internal buffers. The scaler should not be used after disposal.
|
|
125745
125689
|
*/
|
|
@@ -125755,8 +125699,8 @@ var DynamicScaler = class {
|
|
|
125755
125699
|
* Returns zero-valued metrics if no samples have been recorded.
|
|
125756
125700
|
*/
|
|
125757
125701
|
getAverageMetrics() {
|
|
125758
|
-
const
|
|
125759
|
-
if (
|
|
125702
|
+
const window = this.metricsHistory.slice(-this.policy.sampleWindowSize);
|
|
125703
|
+
if (window.length === 0) {
|
|
125760
125704
|
return {
|
|
125761
125705
|
queueDepth: 0,
|
|
125762
125706
|
activeAgents: this.currentAgents,
|
|
@@ -125767,7 +125711,7 @@ var DynamicScaler = class {
|
|
|
125767
125711
|
timestamp: Date.now()
|
|
125768
125712
|
};
|
|
125769
125713
|
}
|
|
125770
|
-
const avg = (fn) =>
|
|
125714
|
+
const avg = (fn) => window.reduce((sum, m74) => sum + fn(m74), 0) / window.length;
|
|
125771
125715
|
return {
|
|
125772
125716
|
queueDepth: Math.round(avg((m74) => m74.queueDepth)),
|
|
125773
125717
|
activeAgents: Math.round(avg((m74) => m74.activeAgents)),
|
|
@@ -125780,12 +125724,68 @@ var DynamicScaler = class {
|
|
|
125780
125724
|
}
|
|
125781
125725
|
/**
|
|
125782
125726
|
* Record a scaling event, evicting the oldest when the history cap is hit.
|
|
125727
|
+
* Triggers periodic persistence to KV store.
|
|
125783
125728
|
*/
|
|
125784
125729
|
recordEvent(event) {
|
|
125785
125730
|
this.events.push(event);
|
|
125786
125731
|
if (this.events.length > this.config.decisionHistorySize) {
|
|
125787
125732
|
this.events.shift();
|
|
125788
125733
|
}
|
|
125734
|
+
this.persistCount++;
|
|
125735
|
+
if (this.persistCount % _DynamicScaler.PERSIST_INTERVAL === 0) {
|
|
125736
|
+
this.persistSnapshot().catch(() => {
|
|
125737
|
+
});
|
|
125738
|
+
}
|
|
125739
|
+
}
|
|
125740
|
+
/**
|
|
125741
|
+
* Load last persisted snapshot from KV store into in-memory state.
|
|
125742
|
+
*/
|
|
125743
|
+
async loadFromKv() {
|
|
125744
|
+
if (!this.db) return;
|
|
125745
|
+
try {
|
|
125746
|
+
const snapshot = await this.db.kvGet(_DynamicScaler.KV_KEY, _DynamicScaler.KV_NAMESPACE);
|
|
125747
|
+
if (snapshot) {
|
|
125748
|
+
if (Array.isArray(snapshot.metricsHistory)) {
|
|
125749
|
+
for (const m74 of snapshot.metricsHistory) {
|
|
125750
|
+
this.metricsHistory.push(m74);
|
|
125751
|
+
}
|
|
125752
|
+
}
|
|
125753
|
+
if (Array.isArray(snapshot.events)) {
|
|
125754
|
+
for (const e20 of snapshot.events) {
|
|
125755
|
+
this.events.push(e20);
|
|
125756
|
+
}
|
|
125757
|
+
}
|
|
125758
|
+
}
|
|
125759
|
+
} catch (error) {
|
|
125760
|
+
console.warn(
|
|
125761
|
+
"[DynamicScaler] Failed to load KV snapshot:",
|
|
125762
|
+
error instanceof Error ? error.message : String(error)
|
|
125763
|
+
);
|
|
125764
|
+
}
|
|
125765
|
+
}
|
|
125766
|
+
/**
|
|
125767
|
+
* Persist a trimmed snapshot of metricsHistory and events to KV store.
|
|
125768
|
+
* Keeps only the last 50 entries of each to limit storage size.
|
|
125769
|
+
*/
|
|
125770
|
+
async persistSnapshot() {
|
|
125771
|
+
if (!this.db) return;
|
|
125772
|
+
try {
|
|
125773
|
+
const snapshot = {
|
|
125774
|
+
metricsHistory: this.metricsHistory.slice(-50),
|
|
125775
|
+
events: this.events.slice(-50)
|
|
125776
|
+
};
|
|
125777
|
+
await this.db.kvSet(
|
|
125778
|
+
_DynamicScaler.KV_KEY,
|
|
125779
|
+
snapshot,
|
|
125780
|
+
_DynamicScaler.KV_NAMESPACE,
|
|
125781
|
+
_DynamicScaler.KV_TTL
|
|
125782
|
+
);
|
|
125783
|
+
} catch (error) {
|
|
125784
|
+
console.warn(
|
|
125785
|
+
"[DynamicScaler] Failed to persist KV snapshot:",
|
|
125786
|
+
error instanceof Error ? error.message : String(error)
|
|
125787
|
+
);
|
|
125788
|
+
}
|
|
125789
125789
|
}
|
|
125790
125790
|
};
|
|
125791
125791
|
function createDynamicScaler(initialAgents, config) {
|
|
@@ -128036,9 +128036,9 @@ init_esm_node();
|
|
|
128036
128036
|
init_real_embeddings();
|
|
128037
128037
|
|
|
128038
128038
|
// src/learning/sqlite-persistence.ts
|
|
128039
|
+
init_better_sqlite3();
|
|
128039
128040
|
init_esm_node();
|
|
128040
128041
|
init_unified_memory();
|
|
128041
|
-
import Database2 from "better-sqlite3";
|
|
128042
128042
|
var DEFAULT_SQLITE_CONFIG = {
|
|
128043
128043
|
// LEGACY: Ignored when useUnified=true (the default). All data goes to memory.db
|
|
128044
128044
|
dbPath: ".agentic-qe/memory.db",
|
|
@@ -128078,7 +128078,7 @@ var SQLitePatternStore = class {
|
|
|
128078
128078
|
if (!fs19.existsSync(dir)) {
|
|
128079
128079
|
fs19.mkdirSync(dir, { recursive: true });
|
|
128080
128080
|
}
|
|
128081
|
-
this.db = new
|
|
128081
|
+
this.db = new better_sqlite3_default(this.config.dbPath);
|
|
128082
128082
|
if (this.config.walMode) {
|
|
128083
128083
|
this.db.pragma("journal_mode = WAL");
|
|
128084
128084
|
}
|
|
@@ -128140,8 +128140,7 @@ var SQLitePatternStore = class {
|
|
|
128140
128140
|
success INTEGER NOT NULL,
|
|
128141
128141
|
metrics_json TEXT,
|
|
128142
128142
|
feedback TEXT,
|
|
128143
|
-
created_at TEXT DEFAULT (datetime('now'))
|
|
128144
|
-
FOREIGN KEY (pattern_id) REFERENCES qe_patterns(id) ON DELETE CASCADE
|
|
128143
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
128145
128144
|
);
|
|
128146
128145
|
|
|
128147
128146
|
-- Learning trajectories
|
|
@@ -128909,7 +128908,7 @@ var RealQEReasoningBank = class {
|
|
|
128909
128908
|
*/
|
|
128910
128909
|
async initializeHNSW() {
|
|
128911
128910
|
try {
|
|
128912
|
-
const hnswModule = await
|
|
128911
|
+
const hnswModule = await Promise.resolve().then(() => (init_hnswlib_node(), hnswlib_node_exports));
|
|
128913
128912
|
const HierarchicalNSW2 = hnswModule.default?.HierarchicalNSW || hnswModule.HierarchicalNSW;
|
|
128914
128913
|
if (typeof HierarchicalNSW2 !== "function") {
|
|
128915
128914
|
throw new Error("HierarchicalNSW not found in hnswlib-node module");
|
|
@@ -130121,8 +130120,8 @@ init_unified_memory();
|
|
|
130121
130120
|
init_real_embeddings();
|
|
130122
130121
|
|
|
130123
130122
|
// src/integrations/embeddings/index/HNSWIndex.ts
|
|
130124
|
-
|
|
130125
|
-
var { HierarchicalNSW } =
|
|
130123
|
+
init_hnswlib_node();
|
|
130124
|
+
var { HierarchicalNSW } = hnswlib_node_default;
|
|
130126
130125
|
var HNSWEmbeddingIndex = class {
|
|
130127
130126
|
indexes;
|
|
130128
130127
|
config;
|
|
@@ -136059,6 +136058,7 @@ var EarlyExitTokenOptimizer = class {
|
|
|
136059
136058
|
init_pattern_store();
|
|
136060
136059
|
|
|
136061
136060
|
// src/learning/token-tracker.ts
|
|
136061
|
+
init_unified_memory();
|
|
136062
136062
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
136063
136063
|
var DEFAULT_COST_CONFIG = {
|
|
136064
136064
|
costPerInputToken: 3e-3 / 1e3,
|
|
@@ -136072,7 +136072,7 @@ var DEFAULT_PERSISTENCE_CONFIG2 = {
|
|
|
136072
136072
|
// Auto-save every minute
|
|
136073
136073
|
maxMetricsInMemory: 1e4
|
|
136074
136074
|
};
|
|
136075
|
-
var TokenMetricsCollectorImpl = class {
|
|
136075
|
+
var TokenMetricsCollectorImpl = class _TokenMetricsCollectorImpl {
|
|
136076
136076
|
taskMetrics = [];
|
|
136077
136077
|
agentMetrics = /* @__PURE__ */ new Map();
|
|
136078
136078
|
domainMetrics = /* @__PURE__ */ new Map();
|
|
@@ -136088,6 +136088,15 @@ var TokenMetricsCollectorImpl = class {
|
|
|
136088
136088
|
persistenceConfig = DEFAULT_PERSISTENCE_CONFIG2;
|
|
136089
136089
|
autoSaveTimer = null;
|
|
136090
136090
|
isDirty = false;
|
|
136091
|
+
// kv_store persistence
|
|
136092
|
+
db = null;
|
|
136093
|
+
kvPersistCount = 0;
|
|
136094
|
+
static KV_NAMESPACE = "token-usage-metrics";
|
|
136095
|
+
static KV_KEY = "token-tracker-snapshot";
|
|
136096
|
+
static KV_TTL = 604800;
|
|
136097
|
+
// 7 days
|
|
136098
|
+
static KV_PERSIST_INTERVAL = 10;
|
|
136099
|
+
// every 10 operations
|
|
136091
136100
|
constructor() {
|
|
136092
136101
|
this.sessionId = `session-${Date.now()}-${randomUUID7().substring(0, 8)}`;
|
|
136093
136102
|
this.sessionStartTime = Date.now();
|
|
@@ -136502,6 +136511,88 @@ var TokenMetricsCollectorImpl = class {
|
|
|
136502
136511
|
return this.isDirty;
|
|
136503
136512
|
}
|
|
136504
136513
|
// ============================================================================
|
|
136514
|
+
// kv_store Persistence
|
|
136515
|
+
// ============================================================================
|
|
136516
|
+
/**
|
|
136517
|
+
* Initialize kv_store persistence and restore snapshot if available.
|
|
136518
|
+
* This supplements the existing file-based persistence.
|
|
136519
|
+
*/
|
|
136520
|
+
async initializeDb() {
|
|
136521
|
+
try {
|
|
136522
|
+
this.db = getUnifiedMemory();
|
|
136523
|
+
if (!this.db.isInitialized()) await this.db.initialize();
|
|
136524
|
+
await this.loadFromKv();
|
|
136525
|
+
} catch (error) {
|
|
136526
|
+
console.warn("[TokenMetricsCollector] DB init failed, using memory-only:", error instanceof Error ? error.message : String(error));
|
|
136527
|
+
this.db = null;
|
|
136528
|
+
}
|
|
136529
|
+
}
|
|
136530
|
+
/**
|
|
136531
|
+
* Persist current state snapshot to kv_store
|
|
136532
|
+
*/
|
|
136533
|
+
async persistToKv() {
|
|
136534
|
+
if (!this.db) return;
|
|
136535
|
+
const snapshot = {
|
|
136536
|
+
version: "1.0.0",
|
|
136537
|
+
sessionId: this.sessionId,
|
|
136538
|
+
sessionStartTime: this.sessionStartTime,
|
|
136539
|
+
taskMetrics: this.taskMetrics.slice(-this.persistenceConfig.maxMetricsInMemory),
|
|
136540
|
+
optimizationStats: {
|
|
136541
|
+
cacheHits: this.cacheHits,
|
|
136542
|
+
earlyExits: this.earlyExits,
|
|
136543
|
+
totalTokensSaved: this.totalTokensSaved,
|
|
136544
|
+
totalPatternsReused: this.totalPatternsReused
|
|
136545
|
+
},
|
|
136546
|
+
lastSavedAt: Date.now()
|
|
136547
|
+
};
|
|
136548
|
+
await this.db.kvSet(
|
|
136549
|
+
_TokenMetricsCollectorImpl.KV_KEY,
|
|
136550
|
+
snapshot,
|
|
136551
|
+
_TokenMetricsCollectorImpl.KV_NAMESPACE,
|
|
136552
|
+
_TokenMetricsCollectorImpl.KV_TTL
|
|
136553
|
+
);
|
|
136554
|
+
}
|
|
136555
|
+
/**
|
|
136556
|
+
* Load state snapshot from kv_store
|
|
136557
|
+
*/
|
|
136558
|
+
async loadFromKv() {
|
|
136559
|
+
if (!this.db) return false;
|
|
136560
|
+
const snapshot = await this.db.kvGet(
|
|
136561
|
+
_TokenMetricsCollectorImpl.KV_KEY,
|
|
136562
|
+
_TokenMetricsCollectorImpl.KV_NAMESPACE
|
|
136563
|
+
);
|
|
136564
|
+
if (!snapshot) return false;
|
|
136565
|
+
if (!snapshot.version || !snapshot.version.startsWith("1.")) {
|
|
136566
|
+
console.warn("[TokenMetricsCollector] Incompatible kv_store data version, skipping load");
|
|
136567
|
+
return false;
|
|
136568
|
+
}
|
|
136569
|
+
const historicalMetrics = snapshot.taskMetrics || [];
|
|
136570
|
+
this.taskMetrics = [...historicalMetrics, ...this.taskMetrics];
|
|
136571
|
+
this.cacheHits += snapshot.optimizationStats?.cacheHits || 0;
|
|
136572
|
+
this.earlyExits += snapshot.optimizationStats?.earlyExits || 0;
|
|
136573
|
+
this.totalTokensSaved += snapshot.optimizationStats?.totalTokensSaved || 0;
|
|
136574
|
+
this.totalPatternsReused += snapshot.optimizationStats?.totalPatternsReused || 0;
|
|
136575
|
+
for (const metric of historicalMetrics) {
|
|
136576
|
+
this.updateAgentMetrics(metric.agentId, metric.usage, metric.patternReused, metric.tokensSaved || 0);
|
|
136577
|
+
this.updateDomainMetrics(metric.domain, metric.usage);
|
|
136578
|
+
}
|
|
136579
|
+
if (this.taskMetrics.length > this.persistenceConfig.maxMetricsInMemory) {
|
|
136580
|
+
this.taskMetrics = this.taskMetrics.slice(-this.persistenceConfig.maxMetricsInMemory);
|
|
136581
|
+
}
|
|
136582
|
+
return true;
|
|
136583
|
+
}
|
|
136584
|
+
/**
|
|
136585
|
+
* Track state changes and persist to kv_store periodically
|
|
136586
|
+
*/
|
|
136587
|
+
maybePersistToKv() {
|
|
136588
|
+
this.kvPersistCount++;
|
|
136589
|
+
if (this.kvPersistCount >= _TokenMetricsCollectorImpl.KV_PERSIST_INTERVAL) {
|
|
136590
|
+
this.kvPersistCount = 0;
|
|
136591
|
+
this.persistToKv().catch(() => {
|
|
136592
|
+
});
|
|
136593
|
+
}
|
|
136594
|
+
}
|
|
136595
|
+
// ============================================================================
|
|
136505
136596
|
// Private Helper Methods
|
|
136506
136597
|
// ============================================================================
|
|
136507
136598
|
ensureInitialized() {
|
|
@@ -144647,8 +144738,8 @@ function getSharedGOAPPlanner() {
|
|
|
144647
144738
|
}
|
|
144648
144739
|
|
|
144649
144740
|
// src/planning/plan-executor.ts
|
|
144741
|
+
init_better_sqlite3();
|
|
144650
144742
|
init_unified_memory();
|
|
144651
|
-
import Database3 from "better-sqlite3";
|
|
144652
144743
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
144653
144744
|
var DEFAULT_CONFIG71 = {
|
|
144654
144745
|
maxRetries: 2,
|
|
@@ -144680,7 +144771,7 @@ var PlanExecutor = class {
|
|
|
144680
144771
|
this.spawner = spawner;
|
|
144681
144772
|
this.config = { ...DEFAULT_CONFIG71, ...config };
|
|
144682
144773
|
if (!this.config.useUnified) {
|
|
144683
|
-
this.db = new
|
|
144774
|
+
this.db = new better_sqlite3_default(dbPath ?? ":memory:");
|
|
144684
144775
|
this.db.pragma("journal_mode = WAL");
|
|
144685
144776
|
}
|
|
144686
144777
|
}
|
|
@@ -144700,7 +144791,7 @@ var PlanExecutor = class {
|
|
|
144700
144791
|
console.log(`[PlanExecutor] Using unified storage: ${this.unifiedMemory.getDbPath()}`);
|
|
144701
144792
|
} catch (error) {
|
|
144702
144793
|
console.warn("[PlanExecutor] Failed to initialize unified storage, falling back to in-memory:", error);
|
|
144703
|
-
this.db = new (await
|
|
144794
|
+
this.db = new (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default(":memory:");
|
|
144704
144795
|
this.db.pragma("journal_mode = WAL");
|
|
144705
144796
|
this.unifiedMemory = null;
|
|
144706
144797
|
this.createTables();
|
|
@@ -145872,6 +145963,9 @@ var GOAPStatusTool = class extends MCPToolBase {
|
|
|
145872
145963
|
}
|
|
145873
145964
|
};
|
|
145874
145965
|
|
|
145966
|
+
// src/coordination/mincut/time-crystal.ts
|
|
145967
|
+
init_unified_memory();
|
|
145968
|
+
|
|
145875
145969
|
// src/mcp/tools/mincut/index.ts
|
|
145876
145970
|
var MINCUT_TOOL_NAMES = {
|
|
145877
145971
|
HEALTH: "qe/mincut/health",
|
|
@@ -146608,7 +146702,7 @@ init_real_embeddings();
|
|
|
146608
146702
|
init_types();
|
|
146609
146703
|
|
|
146610
146704
|
// src/learning/v2-to-v3-migration.ts
|
|
146611
|
-
|
|
146705
|
+
init_better_sqlite3();
|
|
146612
146706
|
|
|
146613
146707
|
// src/learning/qe-unified-memory.ts
|
|
146614
146708
|
init_hnsw_index();
|
|
@@ -147036,7 +147130,7 @@ function createMemoryAuditor(coherenceService, eventBus, config) {
|
|
|
147036
147130
|
}
|
|
147037
147131
|
|
|
147038
147132
|
// src/learning/metrics-tracker.ts
|
|
147039
|
-
|
|
147133
|
+
init_better_sqlite3();
|
|
147040
147134
|
init_qe_patterns();
|
|
147041
147135
|
|
|
147042
147136
|
// src/mcp/tools/coherence/audit.ts
|
|
@@ -147121,7 +147215,7 @@ var CoherenceAuditTool = class extends MCPToolBase {
|
|
|
147121
147215
|
const memory = await getSharedMemoryBackend();
|
|
147122
147216
|
const patternStore = createPatternStore(memory, {
|
|
147123
147217
|
namespace,
|
|
147124
|
-
embeddingDimension:
|
|
147218
|
+
embeddingDimension: 768
|
|
147125
147219
|
});
|
|
147126
147220
|
await patternStore.initialize();
|
|
147127
147221
|
const searchResult = await patternStore.search("", {
|
|
@@ -152232,24 +152326,49 @@ async function doInitialize() {
|
|
|
152232
152326
|
await memoryManager.initialize();
|
|
152233
152327
|
const db = memoryManager.getDatabase();
|
|
152234
152328
|
if (db) {
|
|
152329
|
+
let needsCreate = false;
|
|
152330
|
+
const tableExists = db.prepare(
|
|
152331
|
+
"SELECT COUNT(*) as cnt FROM sqlite_master WHERE type='table' AND name='captured_experiences'"
|
|
152332
|
+
).get().cnt > 0;
|
|
152333
|
+
if (tableExists) {
|
|
152334
|
+
const columns = db.prepare("PRAGMA table_info(captured_experiences)").all();
|
|
152335
|
+
const colNames = new Set(columns.map((c70) => c70.name));
|
|
152336
|
+
if (!colNames.has("success") || !colNames.has("task")) {
|
|
152337
|
+
db.exec("ALTER TABLE captured_experiences RENAME TO captured_experiences_v2_backup");
|
|
152338
|
+
needsCreate = true;
|
|
152339
|
+
} else {
|
|
152340
|
+
if (!colNames.has("domain")) {
|
|
152341
|
+
db.exec("ALTER TABLE captured_experiences ADD COLUMN domain TEXT NOT NULL DEFAULT ''");
|
|
152342
|
+
}
|
|
152343
|
+
if (!colNames.has("source")) {
|
|
152344
|
+
db.exec("ALTER TABLE captured_experiences ADD COLUMN source TEXT DEFAULT 'middleware'");
|
|
152345
|
+
}
|
|
152346
|
+
}
|
|
152347
|
+
} else {
|
|
152348
|
+
needsCreate = true;
|
|
152349
|
+
}
|
|
152350
|
+
if (needsCreate) {
|
|
152351
|
+
db.exec(`
|
|
152352
|
+
CREATE TABLE IF NOT EXISTS captured_experiences (
|
|
152353
|
+
id TEXT PRIMARY KEY,
|
|
152354
|
+
task TEXT NOT NULL,
|
|
152355
|
+
agent TEXT NOT NULL,
|
|
152356
|
+
domain TEXT NOT NULL DEFAULT '',
|
|
152357
|
+
success INTEGER NOT NULL DEFAULT 0,
|
|
152358
|
+
quality REAL NOT NULL DEFAULT 0.5,
|
|
152359
|
+
duration_ms INTEGER NOT NULL DEFAULT 0,
|
|
152360
|
+
model_tier INTEGER,
|
|
152361
|
+
routing_json TEXT,
|
|
152362
|
+
steps_json TEXT,
|
|
152363
|
+
result_json TEXT,
|
|
152364
|
+
error TEXT,
|
|
152365
|
+
started_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
152366
|
+
completed_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
152367
|
+
source TEXT DEFAULT 'middleware'
|
|
152368
|
+
);
|
|
152369
|
+
`);
|
|
152370
|
+
}
|
|
152235
152371
|
db.exec(`
|
|
152236
|
-
CREATE TABLE IF NOT EXISTS captured_experiences (
|
|
152237
|
-
id TEXT PRIMARY KEY,
|
|
152238
|
-
task TEXT NOT NULL,
|
|
152239
|
-
agent TEXT NOT NULL,
|
|
152240
|
-
domain TEXT NOT NULL,
|
|
152241
|
-
success INTEGER NOT NULL DEFAULT 0,
|
|
152242
|
-
quality REAL NOT NULL DEFAULT 0.5,
|
|
152243
|
-
duration_ms INTEGER NOT NULL DEFAULT 0,
|
|
152244
|
-
model_tier INTEGER,
|
|
152245
|
-
routing_json TEXT,
|
|
152246
|
-
steps_json TEXT,
|
|
152247
|
-
result_json TEXT,
|
|
152248
|
-
error TEXT,
|
|
152249
|
-
started_at TEXT NOT NULL,
|
|
152250
|
-
completed_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
152251
|
-
source TEXT DEFAULT 'middleware'
|
|
152252
|
-
);
|
|
152253
152372
|
CREATE INDEX IF NOT EXISTS idx_captured_exp_domain ON captured_experiences(domain);
|
|
152254
152373
|
CREATE INDEX IF NOT EXISTS idx_captured_exp_success ON captured_experiences(success);
|
|
152255
152374
|
CREATE INDEX IF NOT EXISTS idx_captured_exp_agent ON captured_experiences(agent);
|
|
@@ -159640,7 +159759,7 @@ function createHTTPServer(config) {
|
|
|
159640
159759
|
}
|
|
159641
159760
|
|
|
159642
159761
|
// src/mcp/entry.ts
|
|
159643
|
-
import { createRequire as
|
|
159762
|
+
import { createRequire as createRequire10 } from "module";
|
|
159644
159763
|
|
|
159645
159764
|
// src/init/token-bootstrap.ts
|
|
159646
159765
|
import * as path20 from "path";
|
|
@@ -160851,7 +160970,7 @@ function createInfraHealingOrchestratorSync(options) {
|
|
|
160851
160970
|
import { readFileSync as readFileSync14 } from "node:fs";
|
|
160852
160971
|
import { resolve as resolve8, dirname as dirname9 } from "node:path";
|
|
160853
160972
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
160854
|
-
var require2 =
|
|
160973
|
+
var require2 = createRequire10(import.meta.url);
|
|
160855
160974
|
var pkg = require2("../../package.json");
|
|
160856
160975
|
var server = null;
|
|
160857
160976
|
var httpServer = null;
|
|
@@ -160968,19 +161087,3 @@ async function main() {
|
|
|
160968
161087
|
}
|
|
160969
161088
|
}
|
|
160970
161089
|
main();
|
|
160971
|
-
/*! Bundled license information:
|
|
160972
|
-
|
|
160973
|
-
fast-json-patch/commonjs/helpers.js:
|
|
160974
|
-
(*!
|
|
160975
|
-
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
160976
|
-
* (c) 2017-2022 Joachim Wester
|
|
160977
|
-
* MIT licensed
|
|
160978
|
-
*)
|
|
160979
|
-
|
|
160980
|
-
fast-json-patch/commonjs/duplex.js:
|
|
160981
|
-
(*!
|
|
160982
|
-
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
160983
|
-
* (c) 2017-2021 Joachim Wester
|
|
160984
|
-
* MIT license
|
|
160985
|
-
*)
|
|
160986
|
-
*/
|