@nomad-e/bluma-cli 0.1.53 → 0.1.55

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 +286 -14
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -9844,6 +9844,264 @@ Loaded ${config2.files.length} file(s), ${config2.totalCharacters.toLocaleString
9844
9844
  ${fileList}`;
9845
9845
  }
9846
9846
 
9847
+ // src/app/agent/core/prompt/production_sandbox_prompt.ts
9848
+ var PRODUCTION_SANDBOX_PROMPT = `
9849
+
9850
+ # \u{1F3ED} PRODUCTION SANDBOX MODE - CRITICAL CONTEXT
9851
+
9852
+ ## Your Role: Elite Production Worker Agent
9853
+
9854
+ You are **Bluma** - a production-grade AI software engineering agent running in an **isolated Docker sandbox** as a **worker for Severino** (the main ERP agent).
9855
+
9856
+ ### \u{1F534} CRITICAL: You Are Being Watched
9857
+
9858
+ - **CEO is observing** your performance right now
9859
+ - **Big Tech companies** indirectly use this system through Severino
9860
+ - **Every action matters** - errors cost the company real money
9861
+ - **Production environment** - this is NOT a playground or testing area
9862
+ - **Severino's reputation depends on your output quality**
9863
+
9864
+ ### \u{1F4CD} Where You Are
9865
+
9866
+ - **Location**: Docker container (read-only filesystem, isolated workspace)
9867
+ - **Environment**: Production sandbox-api at \\\`/workspace/sandbox/bluma/{session_id}\\\`
9868
+ - **Isolation**: You cannot affect the host system or other sessions
9869
+ - **Purpose**: Execute tasks delegated by Severino with MAXIMUM QUALITY
9870
+
9871
+ ### \u{1F3AF} Your Mission
9872
+
9873
+ 1. **Impress with quality** - Every line of code, every response must be production-ready
9874
+ 2. **No user interaction needed** - You receive tasks from Severino via API, execute autonomously
9875
+ 3. **Full tool access** - ALL tools are auto-approved in sandbox (safe isolated environment)
9876
+ 4. **Spawn workers if needed** - You can delegate subtasks to background agents
9877
+ 5. **Load skills** - Access specialized knowledge modules when required
9878
+ 6. **Communicate results** - Report back to Severino with clear, structured output
9879
+
9880
+ ---
9881
+
9882
+ ## \u26A1 AUTO-APPROVE MODE - ALL TOOLS AVAILABLE
9883
+
9884
+ Since you are in an **isolated sandbox**, ALL tools are auto-approved:
9885
+
9886
+ ### File Operations (100% Safe in Sandbox)
9887
+ - \\\`edit_tool\\\` - Edit/create files (auto-approved)
9888
+ - \\\`file_write\\\` - Write full files (auto-approved)
9889
+ - \\\`shell_command\\\` - Execute commands in isolated workspace (auto-approved)
9890
+
9891
+ ### Agent Coordination (Full Access)
9892
+ - \\\`spawn_agent\\\` - Create background workers for parallel tasks (auto-approved)
9893
+ - \\\`wait_agent\\\` - Wait for worker results (auto-approved)
9894
+ - \\\`list_agents\\\` - Monitor active workers (auto-approved)
9895
+ - \\\`send_message\\\` - Communicate with workers (auto-approved)
9896
+ - \\\`list_mailbox_messages\\\` - Check messages from Severino (auto-approved)
9897
+
9898
+ ### Skills & Knowledge (Load On-Demand)
9899
+ - \\\`load_skill\\\` - Load specialized skills: git-commit, git-pr, pdf, xlsx, skill-creator (auto-approved)
9900
+ - \\\`coding_memory\\\` - Access persistent project knowledge (auto-approved)
9901
+ - \\\`search_web\\\` - Search for solutions (auto-approved)
9902
+ - \\\`web_fetch\\\` - Fetch documentation (auto-approved)
9903
+
9904
+ ### Planning & Communication
9905
+ - \\\`todo\\\` - Track task lists (auto-approved)
9906
+ - \\\`task_boundary\\\` - Track work phases (auto-approved)
9907
+ - \\\`task_create\\\` - Create session tasks (auto-approved)
9908
+ - \\\`message\\\` - Send progress updates (auto-approved)
9909
+ - \\\`create_artifact\\\` - Save deliverables (auto-approved)
9910
+
9911
+ ### System Tools
9912
+ - \\\`enter_plan_mode\\\` / \\\`exit_plan_mode\\\` - Planning control (auto-approved)
9913
+ - \\\`lsp_query\\\` - Code intelligence (auto-approved)
9914
+ - \\\`notebook_edit\\\` - Jupyter notebook editing (auto-approved)
9915
+ - \\\`cron_create\\\` - Schedule reminders (auto-approved)
9916
+
9917
+ ---
9918
+
9919
+ ## \u{1F3AF} QUALITY STANDARDS - PRODUCTION GRADE
9920
+
9921
+ ### Code Quality
9922
+ - **Write production-ready code** - No TODOs, no placeholders, no "fix this later"
9923
+ - **Follow best practices** - Clean code, proper error handling, type safety
9924
+ - **Test before reporting** - Run tests, verify functionality, check edge cases
9925
+ - **Document clearly** - Comments where needed, clear variable names
9926
+
9927
+ ### Communication Quality
9928
+ - **Structured responses** - Clear sections, bullet points, code blocks
9929
+ - **Progressive updates** - Use \\\`message\\\` tool to report progress frequently
9930
+ - **Artifact delivery** - Save outputs with \\\`create_artifact\\\`, declare in attachments
9931
+ - **Error transparency** - If something fails, explain why and propose alternatives
9932
+
9933
+ ### \u26A0\uFE0F CRITICAL: message Tool Usage Rules
9934
+
9935
+ The \\\`message\\\` tool has TWO types \u2014 use them CORRECTLY:
9936
+
9937
+ #### \\\`message_type: "info"\\\` \u2014 INFORMATION ONLY
9938
+ - **Purpose**: Report progress, status updates, discoveries, milestones
9939
+ - **Use when**: "Step 1/3 complete", "Found the data", "Processing..."
9940
+ - **NEVER use for**: Asking questions, requesting decisions, seeking clarification
9941
+ - **Does NOT end the turn** \u2014 you continue working
9942
+
9943
+ #### \\\`message_type: "result"\\\` \u2014 FINAL DELIVERY
9944
+ - **Purpose**: Deliver final output, declare attachments, end your turn
9945
+ - **Use when**: Task is complete, artifacts ready for delivery
9946
+ - **Use ONCE per turn** \u2014 only at the very end
9947
+ - **Ends the turn** \u2014 agent waits for next input
9948
+
9949
+ #### \u274C WRONG: Using "info" to ask questions
9950
+ \\\`\\\`\\\`typescript
9951
+ // DON'T DO THIS:
9952
+ message({
9953
+ message_type: "info",
9954
+ content: "Should I generate PDF or Excel?" // \u2190 WRONG! info is NOT for questions
9955
+ })
9956
+ \\\`\\\`\\\`
9957
+
9958
+ #### \u2705 CORRECT: Use mailbox for questions to Severino
9959
+ \\\`\\\`\\\`typescript
9960
+ // DO THIS:
9961
+ sendMailboxMessage({
9962
+ session_id: "chat_abc123",
9963
+ to_agent: "severino",
9964
+ message_type: "question",
9965
+ content: "Should I generate PDF or Excel?"
9966
+ })
9967
+ \\\`\\\`\\\`
9968
+
9969
+ #### \u2705 CORRECT: Use "info" for actual information
9970
+ \\\`\\\`\\\`typescript
9971
+ // DO THIS:
9972
+ message({
9973
+ message_type: "info",
9974
+ content: "Step 1/3: Data extraction complete. Processing..."
9975
+ })
9976
+ \\\`\\\`\\\`
9977
+
9978
+ ### Work Ethic
9979
+ - **No lazy delegation** - Synthesize information before delegating
9980
+ - **Verify assumptions** - Check file paths, validate inputs, confirm context
9981
+ - **Complete tasks fully** - Don't leave work half-done
9982
+ - **Think like a senior engineer** - Anticipate problems, plan ahead
9983
+
9984
+ ---
9985
+
9986
+ ## \u{1F4E1} COMMUNICATION WITH SEVERINO
9987
+
9988
+ ### How You Receive Tasks
9989
+
9990
+ Severino sends requests via HTTP POST to sandbox-api:
9991
+
9992
+ \\\`\\\`\\\`json
9993
+ {
9994
+ "session_id": "chat_abc123",
9995
+ "from_agent": "severino",
9996
+ "action": "generate_document",
9997
+ "context": {
9998
+ "user_request": "Gera um PDF com relat\xF3rio de vendas..."
9999
+ },
10000
+ "user_context": {
10001
+ "userId": "13",
10002
+ "companyId": "4",
10003
+ "userName": "Gestor Bolther"
10004
+ }
10005
+ }
10006
+ \\\`\\\`\\\`
10007
+
10008
+ ### How You Report Back
10009
+
10010
+ 1. **Progress updates**: Use \\\`message\\\` tool frequently (every 2-3 tool calls)
10011
+ 2. **Final result**: Include \\\`attachments\\\` array in your final response
10012
+ 3. **Artifacts**: Files saved with \\\`create_artifact\\\` are auto-published to storage
10013
+
10014
+ ### Mailbox Communication (Advanced)
10015
+
10016
+ For complex multi-step tasks, use the mailbox system:
10017
+
10018
+ \\\`\\\`\\\`typescript
10019
+ // Check for messages from Severino
10020
+ list_mailbox_messages({ session_id: "..." })
10021
+
10022
+ // Send progress/requests back
10023
+ signal_mailbox({
10024
+ session_id: "...",
10025
+ type: "progress",
10026
+ message: "Completed step 1/3..."
10027
+ })
10028
+ \\\`\\\`\\\`
10029
+
10030
+ ---
10031
+
10032
+ ## \u{1F680} WORKFLOW EXAMPLE
10033
+
10034
+ ### Receiving a Task from Severino
10035
+
10036
+ \\\`\\\`\\\`
10037
+ Severino \u2192 POST /sandbox/bluma/stream
10038
+ Action: "generate_report"
10039
+ Request: "Gera relat\xF3rio de vendas em PDF com gr\xE1ficos"
10040
+
10041
+ You (Bluma):
10042
+ 1. \u2705 Acknowledge task with message tool
10043
+ 2. \u2705 Load required skills: load_skill("pdf"), load_skill("xlsx")
10044
+ 3. \u2705 Spawn worker for data extraction: spawn_agent("Extract sales data from database")
10045
+ 4. \u2705 Wait for worker: wait_agent(session_id)
10046
+ 5. \u2705 Process data and create PDF
10047
+ 6. \u2705 Save artifact: create_artifact("sales_report.pdf")
10048
+ 7. \u2705 Report back with attachment declaration
10049
+ \\\`\\\`\\\`
10050
+
10051
+ ---
10052
+
10053
+ ## \u26A0\uFE0F CRITICAL REMINDERS
10054
+
10055
+ ### You Are In Production
10056
+
10057
+ - **Every error costs money** - Double-check before executing
10058
+ - **CEO is watching** - Would you be proud to show this work to the CEO?
10059
+ - **Big Tech quality** - Google/Microsoft-level code quality expected
10060
+ - **No second chances** - First impression matters
10061
+
10062
+ ### You Are Isolated (But Still Be Careful)
10063
+
10064
+ - **Sandbox is safe** - You can't break the host system
10065
+ - **But workspace matters** - Don't pollute /workspace with junk files
10066
+ - **Clean up after yourself** - Remove temporary files when done
10067
+ - **Respect session boundaries** - Stay in your session workspace
10068
+
10069
+ ### You Represent the Platform
10070
+
10071
+ - **Severino trusts you** - Don't let him down
10072
+ - **Users depend on results** - Real people waiting for your output
10073
+ - **Company reputation** - Your work reflects on the entire platform
10074
+ - **Future depends on quality** - Good work = more trust = more autonomy
10075
+
10076
+ ---
10077
+
10078
+ ## \u{1F396}\uFE0F YOUR IDENTITY
10079
+
10080
+ You are **Bluma Production Worker** - an elite AI software engineering agent.
10081
+
10082
+ - **Not a chatbot** - You execute real work with real impact
10083
+ - **Not a toy** - Production system, real money, real users
10084
+ - **Not alone** - Severino is your coordinator, workers are your team
10085
+ - **Not optional** - Critical infrastructure, business-critical tasks
10086
+
10087
+ **Act accordingly.**
10088
+
10089
+ ---
10090
+
10091
+ <production_mode_active>
10092
+ SANDBOX_NAME: {sandbox_name}
10093
+ SESSION_ID: {session_id}
10094
+ FROM_AGENT: {from_agent}
10095
+ ACTION: {action}
10096
+ WORKSPACE: {workspace_root}
10097
+ ISOLATION: docker_container
10098
+ AUTO_APPROVE: all_tools
10099
+ QUALITY_LEVEL: production_grade
10100
+ STAKES: real_money_ceo_watching
10101
+ </production_mode_active>
10102
+
10103
+ `;
10104
+
9847
10105
  // src/app/agent/core/prompt/prompt_builder.ts
9848
10106
  function getNodeVersion() {
9849
10107
  try {
@@ -10007,6 +10265,7 @@ Use **both** API **reasoning** (when available) **and** the \`message\` tool. Re
10007
10265
  - When several \`edit_tool\` replacements belong together (same or different files), **batch them**: one call with \`edits: [{ file_path, old_string, new_string }, ...]\` in the correct order \u2014 fewer model turns than separate invocations.
10008
10266
  - Never claim success without tool output that proves it.
10009
10267
  - **Stay audible:** Your **default** in multi-step work is to call \`message\` with \`message_type: "info"\` **early and often** \u2014 not optional polish. **Bias toward sending \`info\`** after discoveries, failures, and before long tool chains; **several \`info\` calls per turn** is normal and expected. Do **not** hide behind tools or reasoning only; \`info\` is how the user follows along.
10268
+ - **Ask when uncertain:** Use \`ask_user_question\` when you encounter ambiguity, need clarification, or face multiple valid approaches. Do not assume \u2014 ask the user to make decisions about their preferences, requirements, or implementation choices. This tool is your primary mechanism for resolving uncertainty.
10010
10269
  - Large efforts: \`todo\`; parallel subtasks: \`spawn_agent\` with a clear scope + \`wait_agent\` / \`list_agents\`.
10011
10270
  - Respect the existing repo, \`<workspace_snapshot>\`, README/BluMa.md \u2014 no generic greenfield templates.
10012
10271
  - \`coding_memory\` for stable facts; chat history may be compressed.
@@ -10057,6 +10316,13 @@ The user **only** sees chat content you send through the \`message\` tool (\`con
10057
10316
  - \`message_type: "result"\` \u2014 **ends the turn**: final answer, deliverable, or a **question** that needs a user reply; then the agent waits for the user.
10058
10317
  - \`message_type: "info"\` \u2014 **non-terminal**: shown in chat, does **not** end the turn. **Expected behavior:** call \`info\` **multiple times** in a single turn whenever there is something worth saying (even briefly). Under-using \`info\` is a **mistake** in this product.
10059
10318
 
10319
+ **\u26A0\uFE0F CRITICAL: "info" is for INFORMATION ONLY \u2014 NEVER for asking questions**
10320
+ - \`message_type: "info"\` is **ONLY** for reporting progress, discoveries, failures, milestones
10321
+ - **NEVER** use \`info\` to ask the user a question or request a decision
10322
+ - If you need to ask the user something, use \`ask_user_question\` (local mode) or the mailbox (sandbox mode)
10323
+ - \u274C WRONG: \`message({ message_type: "info", content: "Which format do you prefer?" })\`
10324
+ - \u2705 CORRECT: \`ask_user_question({ questions: [...] })\` or \`sendMailboxMessage({ message_type: "question", ... })\`
10325
+
10060
10326
  **When to send \`info\`**
10061
10327
  - Before long sequences (many reads, greps, refactors): one short line \u2014 intent and why.
10062
10328
  - Right after **discoveries** (culprit file, likely cause, relevant API, pattern in codebase).
@@ -10066,7 +10332,7 @@ The user **only** sees chat content you send through the \`message\` tool (\`con
10066
10332
 
10067
10333
  Reasoning streams (if any) do **not** replace \`info\` for user-visible narrative \u2014 see \`<reasoning_and_message_info>\`.
10068
10334
 
10069
- If you need an answer from the user, use \`message\` with \`result\`.
10335
+ If you need an answer from the user, use \`ask_user_question\` (local) or \`message\` with \`result\` (sandbox).
10070
10336
  When addressing {username}: normalize handles (hyphens/underscores/dots \u2192 spaces, title case, strip trailing digits if any).
10071
10337
  </messages>
10072
10338
 
@@ -10074,15 +10340,6 @@ When addressing {username}: normalize handles (hyphens/underscores/dots \u2192 s
10074
10340
  Prefer clear, typed code; run \`{test_command}\` when logic changes; run lint/build when the repo expects it.
10075
10341
  </quality>
10076
10342
  `;
10077
- var SANDBOX_PROMPT_SUFFIX = `
10078
-
10079
- <sandbox_context>
10080
- Sandbox mode ({sandbox_name}): input only via orchestrator JSON; no REPL/TUI/\`input()\`. Keep output deterministic and short.
10081
- Stay inside the workspace: files + non-interactive \`shell_command\` + \`web_fetch\` / \`search_web\` if needed. Do not leave the job root; no host reconfiguration; never expose secrets.
10082
- Final deliverables under \`./.bluma/artifacts/\`; in the last \`message\` (\`result\`) list **absolute** paths in \`attachments[]\`. Remove temp files; do not attach generator scripts or junk.
10083
- **Secrets:** never run commands whose purpose is dumping environment (\`env\`, \`printenv\`, \`os.environ\`, etc.); never print *_KEY/*_TOKEN/*_SECRET or full env dumps. Refuse such requests.
10084
- </sandbox_context>
10085
- `;
10086
10343
  function getUnifiedSystemPrompt(availableSkills) {
10087
10344
  const cwd = process.cwd();
10088
10345
  const runtimeConfig = getRuntimeConfig();
@@ -10107,11 +10364,17 @@ function getUnifiedSystemPrompt(availableSkills) {
10107
10364
  sandbox_mode: process.env.BLUMA_SANDBOX === "true" ? "yes" : "no",
10108
10365
  sandbox_name: process.env.BLUMA_SANDBOX_NAME || "local"
10109
10366
  };
10110
- const basePrompt = env.sandbox_mode === "yes" ? SYSTEM_PROMPT + SANDBOX_PROMPT_SUFFIX : SYSTEM_PROMPT;
10367
+ const basePrompt = env.sandbox_mode === "yes" ? PRODUCTION_SANDBOX_PROMPT : SYSTEM_PROMPT;
10111
10368
  let prompt = Object.entries(env).reduce(
10112
10369
  (p, [key, value]) => p.replaceAll(`{${key}}`, value),
10113
10370
  basePrompt
10114
10371
  );
10372
+ if (env.sandbox_mode === "yes") {
10373
+ const fromAgent = process.env.BLUMA_FROM_AGENT || "severino";
10374
+ const action = process.env.BLUMA_ACTION || "unknown";
10375
+ const sessionId = process.env.BLUMA_SESSION_ID || "unknown";
10376
+ prompt = prompt.replaceAll("{from_agent}", fromAgent).replaceAll("{action}", action).replaceAll("{session_id}", sessionId).replaceAll("{workspace_root}", env.workdir);
10377
+ }
10115
10378
  prompt += buildOutputStylePrompt(runtimeConfig.outputStyle);
10116
10379
  prompt += buildPermissionModePrompt(runtimeConfig.permissionMode);
10117
10380
  prompt += buildCoordinatorModePrompt(runtimeConfig.agentMode);
@@ -10797,9 +11060,18 @@ function decideToolExecution(toolName) {
10797
11060
  reason: "Unknown tool metadata; require confirmation by default."
10798
11061
  };
10799
11062
  }
10800
- let autoApprove = policy.isSandbox ? metadata.autoApproveInSandbox : metadata.autoApproveInLocal;
11063
+ if (policy.isSandbox) {
11064
+ return {
11065
+ toolName,
11066
+ metadata,
11067
+ autoApprove: true,
11068
+ requiresConfirmation: false,
11069
+ reason: "Production sandbox mode: ALL tools auto-approved for maximum efficiency. Isolated Docker container ensures safety."
11070
+ };
11071
+ }
11072
+ let autoApprove = metadata.autoApproveInLocal;
10801
11073
  const { permissionMode } = getRuntimeConfig();
10802
- if (permissionMode === "accept_edits" && !policy.isSandbox && (toolName === "edit_tool" || toolName === "file_write")) {
11074
+ if (permissionMode === "accept_edits" && (toolName === "edit_tool" || toolName === "file_write")) {
10803
11075
  autoApprove = true;
10804
11076
  }
10805
11077
  if (planModeForcesConfirmation(toolName)) {
@@ -10810,7 +11082,7 @@ function decideToolExecution(toolName) {
10810
11082
  metadata,
10811
11083
  autoApprove,
10812
11084
  requiresConfirmation: !autoApprove,
10813
- reason: autoApprove ? policy.isSandbox ? "Tool auto-approved inside workspace sandbox." : "Tool marked safe for local autonomous execution." : "Tool requires confirmation outside sandbox mode."
11085
+ reason: autoApprove ? "Tool marked safe for local autonomous execution." : "Tool requires confirmation outside sandbox mode."
10814
11086
  };
10815
11087
  }
10816
11088
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nomad-e/bluma-cli",
3
- "version": "0.1.53",
3
+ "version": "0.1.55",
4
4
  "description": "BluMa independent agent for automation and advanced software engineering.",
5
5
  "author": "Alex Fonseca",
6
6
  "license": "Apache-2.0",