@wrongstack/core 0.256.1 → 0.257.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/defaults/index.d.ts +1 -1
- package/dist/defaults/index.js +128 -22
- package/dist/defaults/index.js.map +1 -1
- package/dist/execution/index.js +107 -20
- package/dist/execution/index.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +144 -38
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.js +9 -8
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/models/index.js +9 -8
- package/dist/models/index.js.map +1 -1
- package/dist/sdd/index.js +7 -2
- package/dist/sdd/index.js.map +1 -1
- package/dist/{secret-vault-BkYkJWQs.d.ts → secret-vault-gxtFZYBt.d.ts} +7 -0
- package/dist/security/index.d.ts +1 -1
- package/dist/security/index.js +23 -9
- package/dist/security/index.js.map +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +137 -36
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.js +9 -8
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
package/dist/utils/index.js
CHANGED
|
@@ -1004,12 +1004,15 @@ function getCachedEstimate(key, compute) {
|
|
|
1004
1004
|
const existing = ESTIMATE_CACHE.get(key);
|
|
1005
1005
|
if (existing !== void 0) return existing;
|
|
1006
1006
|
if (ESTIMATE_CACHE.size >= ESTIMATE_CACHE_MAX_SIZE) {
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1007
|
+
let evicted = 0;
|
|
1008
|
+
const maxEvict = Math.floor(ESTIMATE_CACHE_MAX_SIZE / 4);
|
|
1009
|
+
for (const k of ESTIMATE_CACHE.keys()) {
|
|
1010
|
+
if (evicted >= maxEvict) break;
|
|
1011
|
+
ESTIMATE_CACHE.delete(k);
|
|
1012
|
+
evicted++;
|
|
1010
1013
|
}
|
|
1011
1014
|
}
|
|
1012
|
-
const estimate = compute();
|
|
1015
|
+
const estimate = compute(key);
|
|
1013
1016
|
ESTIMATE_CACHE.set(key, estimate);
|
|
1014
1017
|
return estimate;
|
|
1015
1018
|
}
|
|
@@ -1018,13 +1021,11 @@ function estimateToolInputTokens(input) {
|
|
|
1018
1021
|
if (input === null || typeof input !== "object") {
|
|
1019
1022
|
return RoughTokenEstimate(String(input));
|
|
1020
1023
|
}
|
|
1021
|
-
|
|
1022
|
-
return getCachedEstimate(key, () => RoughTokenEstimate(key));
|
|
1024
|
+
return getCachedEstimate(JSON.stringify(input), (key) => RoughTokenEstimate(key));
|
|
1023
1025
|
}
|
|
1024
1026
|
function estimateToolResultTokens(content) {
|
|
1025
1027
|
if (typeof content === "string") return RoughTokenEstimate(content);
|
|
1026
|
-
|
|
1027
|
-
return getCachedEstimate(key, () => RoughTokenEstimate(key));
|
|
1028
|
+
return getCachedEstimate(JSON.stringify(content), (key) => RoughTokenEstimate(key));
|
|
1028
1029
|
}
|
|
1029
1030
|
function estimateTextTokens(text) {
|
|
1030
1031
|
return RoughTokenEstimate(text);
|