@nomad-e/bluma-cli 0.1.64 → 0.1.66

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/main.js +49 -7
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -8530,15 +8530,30 @@ async function task_output(params) {
8530
8530
 
8531
8531
  // src/app/agent/core/context-api/token_counter.ts
8532
8532
  import { getEncoding } from "js-tiktoken";
8533
+ import { createHash } from "crypto";
8533
8534
  var MESSAGE_OVERHEAD_TOKENS = 4;
8534
8535
  var CONVERSATION_BASE_OVERHEAD = 3;
8535
8536
  var cachedEncoding = null;
8537
+ var tokenCountCache = null;
8536
8538
  function getO200kEncoding() {
8537
8539
  if (!cachedEncoding) {
8538
8540
  cachedEncoding = getEncoding("o200k_base");
8539
8541
  }
8540
8542
  return cachedEncoding;
8541
8543
  }
8544
+ function hashHistory(messages) {
8545
+ const hash = createHash("sha256");
8546
+ hash.update(`len:${messages.length}:`);
8547
+ for (const msg of messages) {
8548
+ const m = msg;
8549
+ hash.update(`role:${m.role ?? ""}:`);
8550
+ hash.update(`content:${JSON.stringify(m.content ?? "")}:`);
8551
+ hash.update(`tool_calls:${JSON.stringify(m.tool_calls ?? "")}:`);
8552
+ hash.update(`tool_call_id:${m.tool_call_id ?? ""}:`);
8553
+ hash.update(`name:${m.name ?? ""}:`);
8554
+ }
8555
+ return hash.digest("hex");
8556
+ }
8542
8557
  function messageBodyForTokens(msg) {
8543
8558
  const c = msg.content;
8544
8559
  if (c == null) {
@@ -8563,10 +8578,16 @@ function messageExtraForTokens(msg) {
8563
8578
  }
8564
8579
  return parts.join("\0");
8565
8580
  }
8566
- function countTokens(messages) {
8581
+ function countTokens(messages, useCache = true) {
8567
8582
  if (messages.length === 0) {
8568
8583
  return CONVERSATION_BASE_OVERHEAD;
8569
8584
  }
8585
+ if (useCache) {
8586
+ const currentHash = hashHistory(messages);
8587
+ if (tokenCountCache && tokenCountCache.hash === currentHash) {
8588
+ return tokenCountCache.count;
8589
+ }
8590
+ }
8570
8591
  const enc = getO200kEncoding();
8571
8592
  let total = CONVERSATION_BASE_OVERHEAD;
8572
8593
  for (const msg of messages) {
@@ -8576,8 +8597,14 @@ function countTokens(messages) {
8576
8597
  const nExtra = extra ? enc.encode(extra).length : 0;
8577
8598
  total += nBody + nExtra + MESSAGE_OVERHEAD_TOKENS;
8578
8599
  }
8600
+ if (useCache) {
8601
+ tokenCountCache = { hash: hashHistory(messages), count: total };
8602
+ }
8579
8603
  return total;
8580
8604
  }
8605
+ function clearTokenCountCache() {
8606
+ tokenCountCache = null;
8607
+ }
8581
8608
 
8582
8609
  // src/app/agent/tools/natives/ctx_inspect.ts
8583
8610
  async function ctx_inspect(args = {}) {
@@ -12660,10 +12687,20 @@ const result = await deployApp({
12660
12687
 
12661
12688
  **What it does:**
12662
12689
  1. Validates project (checks \\\`package.json\\\` and \\\`next\\\` dependency)
12663
- 2. Creates ZIP (excludes \\\`node_modules\\\`, \\\`.next\\\`, \\\`.env\\\`, \\\`.git\\\`)
12690
+ 2. Creates ZIP **excluding heavy/unnecessary files**:
12691
+ - \\\`node_modules\\\` (NUNCA incluir - o Severino faz install no deploy)
12692
+ - \\\`.next\\\` (build artifacts, regenerado no servidor)
12693
+ - \\\`.env\\\`, \\\`.env.local\\\` (seguran\xE7a)
12694
+ - \\\`.git\\\`, \\\`.DS_Store\\\`, \\\`*.log\\\`
12664
12695
  3. Uploads to \\\`POST {severinoUrl}/api/v1/deploy\\\`
12665
12696
  4. Returns \\\`appId\\\` and live URL
12666
12697
 
12698
+ **\u26A0\uFE0F CRITICAL: NUNCA zipar \\\`node_modules\\\`**
12699
+ - O ZIP deve conter **apenas c\xF3digo fonte e configs**
12700
+ - \\\`node_modules\\\` \xE9 recriado no servidor com \\\`npm install\\\`
12701
+ - Incluir \\\`node_modules\\\` = ZIP de 200MB+ = deploy falha
12702
+ - A tool \\\`deploy_app\\\` j\xE1 exclui automaticamente, mas se fizeres ZIP manual: **exclui \\\`node_modules\\\`**
12703
+
12667
12704
  **Important:** The deploy is **asynchronous** - status starts as \\\`'building'\\\`. The app will be ready in ~30-60 seconds.
12668
12705
 
12669
12706
  ---
@@ -13429,8 +13466,9 @@ async function createApiContextWindow(fullHistory, currentAnchor, compressedTurn
13429
13466
  const thresholdTokens = tokenBudget * compressThreshold;
13430
13467
  let pendingSlices = turnSlices.slice(sliceCount, recentStart);
13431
13468
  let pendingFlat = pendingSlices.flat();
13469
+ clearTokenCountCache();
13432
13470
  let messages = buildContextMessages(systemMessages, anchor, pendingFlat, recentFlat);
13433
- let tokens = countTokens(messages);
13471
+ let tokens = countTokens(messages, true);
13434
13472
  while (tokens >= thresholdTokens && pendingSlices.length > 0) {
13435
13473
  try {
13436
13474
  anchor = await compressToAnchor(
@@ -13448,8 +13486,9 @@ async function createApiContextWindow(fullHistory, currentAnchor, compressedTurn
13448
13486
  pendingSlices = [];
13449
13487
  pendingFlat = [];
13450
13488
  }
13489
+ clearTokenCountCache();
13451
13490
  messages = buildContextMessages(systemMessages, anchor, pendingFlat, recentFlat);
13452
- tokens = countTokens(messages);
13491
+ tokens = countTokens(messages, true);
13453
13492
  }
13454
13493
  return {
13455
13494
  messages,
@@ -14878,7 +14917,8 @@ ${editData.error.display}`;
14878
14917
  });
14879
14918
  await this.notifyFactorTurnEndIfNeeded("empty_reply_exhausted");
14880
14919
  this.eventBus.emit("backend_message", { type: "done", status: "failed" });
14881
- process.exit(1);
14920
+ this.emptyAssistantReplySteps = 0;
14921
+ this.directTextProtocolSteps = 0;
14882
14922
  return;
14883
14923
  }
14884
14924
  await this._continueConversation();
@@ -15012,7 +15052,8 @@ ${editData.error.display}`;
15012
15052
  });
15013
15053
  await this.notifyFactorTurnEndIfNeeded("protocol_direct_text_exhausted");
15014
15054
  this.emitTurnCompleted();
15015
- process.exit(1);
15055
+ this.emptyAssistantReplySteps = 0;
15056
+ this.directTextProtocolSteps = 0;
15016
15057
  return;
15017
15058
  }
15018
15059
  const feedback = this.feedbackSystem.generateFeedback({
@@ -15100,7 +15141,8 @@ ${editData.error.display}`;
15100
15141
  });
15101
15142
  await this.notifyFactorTurnEndIfNeeded("protocol_direct_text_exhausted");
15102
15143
  this.emitTurnCompleted();
15103
- process.exit(1);
15144
+ this.emptyAssistantReplySteps = 0;
15145
+ this.directTextProtocolSteps = 0;
15104
15146
  return;
15105
15147
  }
15106
15148
  const feedback = this.feedbackSystem.generateFeedback({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nomad-e/bluma-cli",
3
- "version": "0.1.64",
3
+ "version": "0.1.66",
4
4
  "description": "BluMa independent agent for automation and advanced software engineering.",
5
5
  "author": "Alex Fonseca",
6
6
  "license": "Apache-2.0",