replicas-engine 0.1.175 → 0.1.179

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.
Files changed (2) hide show
  1. package/dist/src/index.js +27 -6
  2. 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: {
@@ -157,7 +174,7 @@ var PLANS = {
157
174
  "Unlimited automations",
158
175
  "Higher API rate limits",
159
176
  "Warm pools and warm hooks",
160
- "Auto-upgraded sandbox resources (32 GB disk, 16 GB memory)",
177
+ "Auto-upgraded sandbox resources (4 vCPU, 32 GB disk, 16 GB memory)",
161
178
  "Shared Slack support channel"
162
179
  ]
163
180
  },
@@ -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-v20";
395
+ var DAYTONA_SNAPSHOT_ID = "16-05-2026-royal-york-v23";
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 percentage = Number.isFinite(usage.percentage) ? usage.percentage : maxTokens && maxTokens > 0 ? usage.totalTokens / maxTokens * 100 : 0;
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: usage.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: maxTokens && maxTokens > 0 ? category.tokens / maxTokens * 100 : 0,
3334
+ percentage: percentage(category.tokens, maxTokens),
3314
3335
  color: category.color,
3315
3336
  ...category.isDeferred !== void 0 ? { isDeferred: category.isDeferred } : {}
3316
3337
  })),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.175",
3
+ "version": "0.1.179",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",