replicas-engine 0.1.174 → 0.1.178
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/src/index.js +26 -5
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -111,6 +111,23 @@ function detectLanguageByPath(filePath) {
|
|
|
111
111
|
return EXT_TO_LANGUAGE[ext] ?? null;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
// ../shared/src/context-usage.ts
|
|
115
|
+
function clampPercentage(value) {
|
|
116
|
+
if (!Number.isFinite(value)) return 0;
|
|
117
|
+
if (value < 0) return 0;
|
|
118
|
+
if (value > 100) return 100;
|
|
119
|
+
return value;
|
|
120
|
+
}
|
|
121
|
+
function percentage(tokens, maxTokens) {
|
|
122
|
+
if (!maxTokens || maxTokens <= 0) return 0;
|
|
123
|
+
return clampPercentage(tokens / maxTokens * 100);
|
|
124
|
+
}
|
|
125
|
+
function clampTokensToWindow(rawTokens, maxTokens) {
|
|
126
|
+
if (!maxTokens || maxTokens <= 0) return { totalTokens: rawTokens };
|
|
127
|
+
if (rawTokens <= maxTokens) return { totalTokens: rawTokens };
|
|
128
|
+
return { totalTokens: maxTokens, totalProcessedTokens: rawTokens };
|
|
129
|
+
}
|
|
130
|
+
|
|
114
131
|
// ../shared/src/pricing.ts
|
|
115
132
|
var PLANS = {
|
|
116
133
|
hobby: {
|
|
@@ -375,7 +392,7 @@ function parseReplicasConfigString(content, filename) {
|
|
|
375
392
|
}
|
|
376
393
|
|
|
377
394
|
// ../shared/src/engine/environment.ts
|
|
378
|
-
var DAYTONA_SNAPSHOT_ID = "15-05-2026-royal-york-
|
|
395
|
+
var DAYTONA_SNAPSHOT_ID = "15-05-2026-royal-york-v22";
|
|
379
396
|
|
|
380
397
|
// ../shared/src/engine/types.ts
|
|
381
398
|
var DEFAULT_CHAT_TITLES = {
|
|
@@ -3298,19 +3315,23 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
3298
3315
|
}
|
|
3299
3316
|
buildContextUsagePayload(usage) {
|
|
3300
3317
|
const maxTokens = Number.isFinite(usage.maxTokens) ? usage.maxTokens : null;
|
|
3301
|
-
const
|
|
3318
|
+
const rawPercentage = Number.isFinite(usage.percentage) ? usage.percentage : maxTokens && maxTokens > 0 ? usage.totalTokens / maxTokens * 100 : 0;
|
|
3319
|
+
const clamped = clampTokensToWindow(usage.totalTokens, maxTokens);
|
|
3302
3320
|
return {
|
|
3303
3321
|
provider: this.getContextUsageProvider(),
|
|
3304
3322
|
source: "claude_context",
|
|
3305
3323
|
model: usage.model,
|
|
3306
|
-
totalTokens:
|
|
3324
|
+
totalTokens: clamped.totalTokens,
|
|
3325
|
+
...clamped.totalProcessedTokens !== void 0 ? { totalProcessedTokens: clamped.totalProcessedTokens } : {},
|
|
3307
3326
|
maxTokens,
|
|
3308
3327
|
rawMaxTokens: Number.isFinite(usage.rawMaxTokens) ? usage.rawMaxTokens : maxTokens,
|
|
3309
|
-
percentage,
|
|
3328
|
+
percentage: clampPercentage(rawPercentage),
|
|
3329
|
+
compactsAutomatically: usage.isAutoCompactEnabled === true,
|
|
3330
|
+
...typeof usage.autoCompactThreshold === "number" && Number.isFinite(usage.autoCompactThreshold) ? { autoCompactThreshold: usage.autoCompactThreshold } : {},
|
|
3310
3331
|
categories: usage.categories.map((category) => ({
|
|
3311
3332
|
name: category.name,
|
|
3312
3333
|
tokens: category.tokens,
|
|
3313
|
-
percentage:
|
|
3334
|
+
percentage: percentage(category.tokens, maxTokens),
|
|
3314
3335
|
color: category.color,
|
|
3315
3336
|
...category.isDeferred !== void 0 ? { isDeferred: category.isDeferred } : {}
|
|
3316
3337
|
})),
|