boxsafe 1.0.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.
Files changed (118) hide show
  1. package/.directory +2 -0
  2. package/.env.example +3 -0
  3. package/AUDIT_LANG.md +45 -0
  4. package/BOXSAFE_VERSION_NOTES.md +14 -0
  5. package/README.md +4 -0
  6. package/TODO.md +130 -0
  7. package/adapters/index.ts +27 -0
  8. package/adapters/primary/cli-adapter.ts +56 -0
  9. package/adapters/secondary/filesystem/node-filesystem.ts +307 -0
  10. package/adapters/secondary/system/configuration.ts +147 -0
  11. package/ai/caller.ts +42 -0
  12. package/ai/label.ts +33 -0
  13. package/ai/modelConfig.ts +236 -0
  14. package/ai/provider.ts +111 -0
  15. package/boxsafe.config.json +68 -0
  16. package/core/auth/dasktop/cred/CRED.md +112 -0
  17. package/core/auth/dasktop/cred/credLinux.ts +82 -0
  18. package/core/auth/dasktop/cred/credWin.ts +2 -0
  19. package/core/config/defaults/boxsafeDefaults.ts +67 -0
  20. package/core/config/defaults/index.ts +1 -0
  21. package/core/config/loadConfig.ts +133 -0
  22. package/core/loop/about.md +13 -0
  23. package/core/loop/boxConfig.ts +20 -0
  24. package/core/loop/buildExecCommand.ts +76 -0
  25. package/core/loop/cmd/execode.ts +121 -0
  26. package/core/loop/cmd/test.js +3 -0
  27. package/core/loop/execLoop.ts +341 -0
  28. package/core/loop/git/VERSIONING.md +17 -0
  29. package/core/loop/git/commands.ts +11 -0
  30. package/core/loop/git/gitClient.ts +78 -0
  31. package/core/loop/git/index.ts +99 -0
  32. package/core/loop/git/runVersionControlRunner.ts +33 -0
  33. package/core/loop/initNavigator.ts +44 -0
  34. package/core/loop/initTasksManager.ts +35 -0
  35. package/core/loop/runValidation.ts +25 -0
  36. package/core/loop/tasks/AGENT-TASKS.md +36 -0
  37. package/core/loop/tasks/index.ts +96 -0
  38. package/core/loop/toolCalls.ts +168 -0
  39. package/core/loop/toolDispatcher.ts +146 -0
  40. package/core/loop/traceLogger.ts +106 -0
  41. package/core/loop/types.ts +26 -0
  42. package/core/loop/versionControlAdapter.ts +36 -0
  43. package/core/loop/waterfall.ts +404 -0
  44. package/core/loop/writeArtifactAtomically.ts +13 -0
  45. package/core/navigate/NAVIGATE.md +186 -0
  46. package/core/navigate/about.md +128 -0
  47. package/core/navigate/examples.ts +367 -0
  48. package/core/navigate/handler.ts +148 -0
  49. package/core/navigate/index.ts +32 -0
  50. package/core/navigate/navigate.test.ts +372 -0
  51. package/core/navigate/navigator.ts +437 -0
  52. package/core/navigate/types.ts +132 -0
  53. package/core/navigate/utils.ts +146 -0
  54. package/core/paths/paths.ts +33 -0
  55. package/core/ports/index.ts +271 -0
  56. package/core/segments/CONVENTIONS.md +30 -0
  57. package/core/segments/loop/index.ts +18 -0
  58. package/core/segments/map.ts +56 -0
  59. package/core/segments/navigate/index.ts +20 -0
  60. package/core/segments/versionControl/index.ts +18 -0
  61. package/core/util/logger.ts +128 -0
  62. package/docs/AGENT-TASKS.md +36 -0
  63. package/docs/ARQUITETURA_CORRECAO.md +121 -0
  64. package/docs/CONVENTIONS.md +30 -0
  65. package/docs/CRED.md +112 -0
  66. package/docs/L_RAG.md +567 -0
  67. package/docs/NAVIGATE.md +186 -0
  68. package/docs/PRIMARY_ACTORS.md +78 -0
  69. package/docs/SECONDARY_ACTORS.md +174 -0
  70. package/docs/VERSIONING.md +17 -0
  71. package/docs/boxsafe.config.md +472 -0
  72. package/eslint.config.mts +15 -0
  73. package/main.ts +53 -0
  74. package/memo/generated/codelog.md +13 -0
  75. package/memo/state/tasks/state.json +6 -0
  76. package/memo/state/tasks/tasks/task_001.md +2 -0
  77. package/memo/states-logs/logs.txt +7 -0
  78. package/memo/states-logs/trace-mljvrxvi-9g0k4q.jsonl +11 -0
  79. package/memo/states-logs/trace-mljvvc9j-pe9ekj.jsonl +11 -0
  80. package/memo/states-logs/trace-mljvvm1c-wbnqzp.jsonl +11 -0
  81. package/memo/states-logs/trace-mljxecwn-9xh3nw.jsonl +11 -0
  82. package/memo/states-logs/trace-mljxqkfm-ipijik.jsonl +11 -0
  83. package/memo/states-logs/trace-mljxwtrw-3fanky.jsonl +11 -0
  84. package/memo/states-logs/trace-mljxzen3-m8iinh.jsonl +11 -0
  85. package/memo/states-logs/trace-mljyucef-td6odn.jsonl +11 -0
  86. package/memo/states-logs/trace-mljyuprw-b1a6f4.jsonl +11 -0
  87. package/memo/states-logs/trace-mljyvefl-b6yoce.jsonl +11 -0
  88. package/memo/states-logs/trace-mljyxjo4-n7ibj2.jsonl +13 -0
  89. package/memo/states-logs/trace-mljziez5-8drqtn.jsonl +13 -0
  90. package/memo/states-logs/trace-mljziulp-dtd03z.jsonl +13 -0
  91. package/memo/states-logs/trace-mljzjwrq-1p2krb.jsonl +13 -0
  92. package/memo/states-logs/trace-mljzl0i7-b1cqa6.jsonl +13 -0
  93. package/memo/states-logs/trace-mljzmlk6-7kdyls.jsonl +13 -0
  94. package/memo/states-logs/trace-mlk0oj25-xa3dcu.jsonl +13 -0
  95. package/memo/states-logs/trace-mlk1x59q-713huj.jsonl +14 -0
  96. package/memo/states-logs/trace-mlk22dz8-7fd6hq.jsonl +14 -0
  97. package/memo/states-logs/trace-mlk241uy-wmx907.jsonl +14 -0
  98. package/memo/states-logs/trace-mlk2bf5r-yoh1vg.jsonl +15 -0
  99. package/package.json +44 -0
  100. package/pnpm-workspace.yaml +4 -0
  101. package/prompt_improvement_example.md +55 -0
  102. package/remove.txt +1 -0
  103. package/tests/adapters.test.ts +128 -0
  104. package/tests/extractCode.test.ts +26 -0
  105. package/tests/integration.test.ts +83 -0
  106. package/tests/loadConfig.test.ts +25 -0
  107. package/tests/navigatorBoundary.test.ts +17 -0
  108. package/tests/ports.test.ts +84 -0
  109. package/tests/runAllTests.ts +49 -0
  110. package/tests/toolCalls.test.ts +149 -0
  111. package/tests/waterfall.test.ts +52 -0
  112. package/tsconfig.json +32 -0
  113. package/tsup.config.ts +17 -0
  114. package/types.d.ts +96 -0
  115. package/util/ANSI.ts +29 -0
  116. package/util/extractCode.ts +217 -0
  117. package/util/extractToolCalls.ts +80 -0
  118. package/util/logger.ts +125 -0
@@ -0,0 +1,472 @@
1
+ # Documentação de Configuração
2
+
3
+ Este documento descreve todas as opções de configuração disponíveis no arquivo de configuração do agente.
4
+
5
+ ## Estrutura do Arquivo
6
+
7
+ O arquivo de configuração aceita os formatos `.json`, `.yml` ou `.yaml` e deve ser nomeado como `agent.config.json`, `agent.config.yml` ou `agent.config.yaml`.
8
+
9
+ ---
10
+
11
+ ## project
12
+
13
+ Define as configurações relacionadas ao projeto onde o agente irá trabalhar.
14
+
15
+ ### project.workspace
16
+ - **Tipo:** string
17
+ - **Obrigatório:** Sim
18
+ - **Descrição:** Caminho do diretório onde o agente tem permissão para escrever código. O agente terá acesso a todos os subdiretórios dentro deste caminho.
19
+ - **Exemplo:** `"./src"`, `"./app"`, `"./lib"`
20
+
21
+ ### project.testDir
22
+ - **Tipo:** string
23
+ - **Obrigatório:** Sim
24
+ - **Descrição:** Caminho do diretório raiz onde os comandos de execução e teste serão executados. Este é o diretório onde o agente irá rodar os comandos definidos em `commands.run` e `commands.test` para verificar se o código está funcionando corretamente.
25
+ - **Exemplo:** `"./"`, `"./backend"`, `"./frontend"`
26
+
27
+ ### project.versionControl
28
+
29
+ Configurações de controle de versão Git.
30
+
31
+ #### project.versionControl.before
32
+ - **Tipo:** boolean
33
+ - **Padrão:** false
34
+ - **Descrição:** Se true, cria um commit Git antes do agente começar a trabalhar. Isso permite reverter todas as mudanças caso algo dê errado.
35
+
36
+ #### project.versionControl.after
37
+ - **Tipo:** boolean
38
+ - **Padrão:** false
39
+ - **Descrição:** Se true, cria um commit Git automaticamente após o agente terminar o trabalho com sucesso.
40
+
41
+ #### project.versionControl.generateNotes
42
+ - **Tipo:** boolean
43
+ - **Padrão:** false
44
+ - **Descrição:** Se true, gera um arquivo de anotações documentando todas as mudanças feitas pelo agente, incluindo arquivos modificados, razões das mudanças e decisões tomadas. Este arquivo é útil para revisão e histórico.
45
+
46
+ ---
47
+
48
+ ## model
49
+
50
+ Configurações do modelo de linguagem que o agente utilizará.
51
+
52
+ ### model.primary
53
+
54
+ Define o modelo principal que será utilizado.
55
+
56
+ #### model.primary.provider
57
+ - **Tipo:** string
58
+ - **Obrigatório:** Sim
59
+ - **Valores aceitos:** `"google"`, `"anthropic"`, `"openai"`, `"ollama"`, `"llamacpp"`, `"openrouter"`
60
+ - **Descrição:** Provedor do modelo de linguagem. A escolha do provedor determina automaticamente se o modelo é local ou cloud. Provedores `"ollama"` e `"llamacpp"` são locais, os demais são cloud.
61
+
62
+ #### model.primary.name
63
+ - **Tipo:** string
64
+ - **Obrigatório:** Sim
65
+ - **Descrição:** Nome exato do modelo a ser utilizado. Para modelos cloud, use o nome oficial da API. Para modelos locais, use o nome do modelo no Ollama ou o nome do arquivo GGUF.
66
+ - **Exemplos cloud:** `"gemini-2.5-flash"`, `"claude-sonnet-4"`, `"gpt-4"`
67
+ - **Exemplos local:** `"llama3.2:3b"`, `"qwen-32b-q4.gguf"`
68
+
69
+ ### model.fallback
70
+ - **Tipo:** array
71
+ - **Padrão:** array vazio
72
+ - **Descrição:** Lista de modelos de backup que serão utilizados caso o modelo principal falhe ou atinja o limite de requisições. Cada item do array deve conter `provider` e `name`.
73
+ - **Exemplo de uso:**
74
+ ```json
75
+ "fallback": [
76
+ {
77
+ "provider": "google",
78
+ "name": "gemini-1.5-flash"
79
+ },
80
+ {
81
+ "provider": "anthropic",
82
+ "name": "claude-haiku-4"
83
+ }
84
+ ]
85
+ ```
86
+
87
+ ### model.endpoint
88
+ - **Tipo:** string ou null
89
+ - **Padrão:** null
90
+ - **Descrição:** URL do endpoint da API. Necessário apenas para modelos locais (`"ollama"` ou `"llamacpp"`). Para Ollama, tipicamente `"http://localhost:11434"`. Para llama.cpp, tipicamente `"http://127.0.0.1:8080"`. Para modelos cloud, deixe como null.
91
+
92
+ ### model.parameters
93
+ - **Tipo:** object
94
+ - **Padrão:** objeto vazio
95
+ - **Descrição:** Parâmetros avançados de inferência. Funciona apenas com o provedor `"llamacpp"`. Permite configurar opções como contexto, layers GPU, temperatura e outras configurações específicas do llama.cpp.
96
+ - **Exemplo de uso:**
97
+ ```json
98
+ "parameters": {
99
+ "n_ctx": 8192,
100
+ "n_gpu_layers": 35,
101
+ "temperature": 0.7,
102
+ "top_p": 0.9
103
+ }
104
+ ```
105
+
106
+ ---
107
+
108
+ ## smartRotation
109
+
110
+ Sistema de rotação inteligente de modelos baseado na complexidade da tarefa.
111
+
112
+ ### smartRotation.enabled
113
+ - **Tipo:** boolean
114
+ - **Padrão:** false
115
+ - **Descrição:** Ativa o sistema de rotação inteligente. Quando ativo, o agente avalia a complexidade da tarefa e escolhe automaticamente entre modelos simples e complexos para otimizar custo e performance. O sistema tenta modelos simples primeiro e escala para modelos complexos quando necessário.
116
+
117
+ ### smartRotation.simple
118
+ - **Tipo:** array
119
+ - **Padrão:** array vazio
120
+ - **Descrição:** Lista de modelos para tarefas simples como correções pequenas, formatação, tarefas repetitivas e mudanças triviais. O agente tentará esses modelos primeiro. Cada item pode ser uma string com o nome do modelo ou um objeto com `provider` e `name`.
121
+ - **Exemplo de uso:**
122
+ ```json
123
+ "simple": [
124
+ "llama3.2:3b",
125
+ "gemini-1.5-flash"
126
+ ]
127
+ ```
128
+
129
+ ### smartRotation.complex
130
+ - **Tipo:** array
131
+ - **Padrão:** array vazio
132
+ - **Descrição:** Lista de modelos para tarefas complexas como arquitetura de software, refatoração grande, debugging difícil e implementações avançadas. O sistema usa esses modelos quando tarefas simples falharem repetidamente ou quando a complexidade inicial for alta.
133
+ - **Exemplo de uso:**
134
+ ```json
135
+ "complex": [
136
+ "gemini-2.5-flash",
137
+ "claude-sonnet-4",
138
+ "gpt-4"
139
+ ]
140
+ ```
141
+
142
+ ---
143
+
144
+ ## limits
145
+
146
+ Configurações de limites de segurança para controlar o uso de recursos e prevenir execuções descontroladas.
147
+
148
+ ### limits.tokens
149
+ - **Tipo:** number ou string `"infinity"`
150
+ - **Padrão:** `"infinity"`
151
+ - **Descrição:** Limite máximo de tokens que o agente pode consumir durante toda a execução. Quando o limite é atingido, o agente para de executar. Use `"infinity"` para execução sem limites ou um número inteiro para definir o máximo de tokens permitidos.
152
+
153
+ ### limits.loops
154
+ - **Tipo:** number ou string `"infinity"`
155
+ - **Padrão:** `"infinity"`
156
+ - **Descrição:** Número máximo de iterações (loops) que o agente pode executar. Cada tentativa de gerar código, testar e corrigir conta como uma iteração. Previne loops infinitos. Use `"infinity"` para execução sem limites ou um número inteiro para o máximo de iterações.
157
+
158
+ ### limits.timeout
159
+
160
+ Configurações de timeout para execuções longas.
161
+
162
+ #### limits.timeout.enabled
163
+ - **Tipo:** boolean
164
+ - **Padrão:** false
165
+ - **Descrição:** Ativa o sistema de timeout. Quando ativo, monitora o tempo de execução do agente e aciona ações quando o limite de tempo é atingido.
166
+
167
+ #### limits.timeout.duration
168
+ - **Tipo:** string
169
+ - **Padrão:** `"1h"`
170
+ - **Descrição:** Tempo máximo de execução antes de acionar uma ação. Use sufixos `m` para minutos e `h` para horas.
171
+ - **Formatos aceitos:** `"30m"` (30 minutos), `"1h"` (1 hora), `"2h30m"` (2 horas e 30 minutos)
172
+
173
+ #### limits.timeout.notify
174
+ - **Tipo:** boolean
175
+ - **Padrão:** true
176
+ - **Descrição:** Define o comportamento ao atingir o timeout. Se true, envia uma notificação para o usuário perguntando se deseja continuar ou cancelar a execução. Se false, cancela automaticamente a execução ao atingir o timeout sem perguntar.
177
+
178
+ ---
179
+
180
+ ## sandbox
181
+
182
+ Configurações de isolamento de execução para testes seguros do código gerado.
183
+
184
+ ### sandbox.enabled
185
+ - **Tipo:** boolean
186
+ - **Padrão:** false
187
+ - **Descrição:** Ativa o modo sandbox. Quando ativo, o código é executado em um ambiente isolado antes de ser escrito no projeto real. O código só é aplicado ao projeto original após ser testado com sucesso no sandbox. Se desativado, o código é escrito diretamente no projeto sem isolamento.
188
+
189
+ ### sandbox.engine
190
+ - **Tipo:** string
191
+ - **Padrão:** `"docker"`
192
+ - **Valores aceitos:** `"docker"` (atualmente único suportado, preparado para expansão futura como `"podman"`, `"vm"`)
193
+ - **Descrição:** Motor de containerização utilizado para criar o ambiente isolado. Atualmente apenas Docker é suportado, mas a arquitetura permite adicionar outros motores no futuro.
194
+
195
+ ### sandbox.memory
196
+ - **Tipo:** string
197
+ - **Padrão:** `"512m"`
198
+ - **Descrição:** Limite de memória RAM alocada para o container do sandbox. Use sufixos `m` para megabytes ou `g` para gigabytes.
199
+ - **Exemplos:** `"256m"`, `"512m"`, `"1g"`, `"2g"`
200
+
201
+ ### sandbox.cpu
202
+ - **Tipo:** number
203
+ - **Padrão:** 0.5
204
+ - **Descrição:** Limite de CPU alocado para o container do sandbox. O valor representa o número de núcleos de CPU. Use valores decimais para frações de núcleo.
205
+ - **Exemplos:** `0.5` (meio núcleo), `1.0` (um núcleo completo), `2.0` (dois núcleos)
206
+
207
+ ### sandbox.network
208
+ - **Tipo:** string
209
+ - **Padrão:** `"none"`
210
+ - **Valores aceitos:** `"none"`, `"bridge"`, `"host"`
211
+ - **Descrição:** Configuração de rede do container sandbox. Use `"none"` para máximo isolamento (sem acesso à rede), `"bridge"` para acesso à rede isolado, ou `"host"` para acesso direto à rede do host.
212
+
213
+ ---
214
+
215
+ ## commands
216
+
217
+ Comandos que o agente executará para configurar, rodar e testar o projeto.
218
+
219
+ ### commands.setup
220
+ - **Tipo:** string ou null
221
+ - **Padrão:** null
222
+ - **Descrição:** Comando executado uma única vez no início para configurar o ambiente. Tipicamente usado para instalar dependências. Se null, nenhum comando de setup é executado.
223
+ - **Exemplos:** `"npm install"`, `"pip install -r requirements.txt"`, `"cargo build"`
224
+
225
+ ### commands.run
226
+ - **Tipo:** string
227
+ - **Obrigatório:** Sim
228
+ - **Descrição:** Comando executado para rodar o projeto e verificar se o código está funcionando. Este comando é executado no diretório `testDir` após cada mudança de código. O agente analisa a saída para determinar se houve sucesso ou erro.
229
+ - **Exemplos:** `"npm run dev"`, `"python main.py"`, `"cargo run"`, `"go run main.go"`
230
+
231
+ ### commands.test
232
+ - **Tipo:** string ou null
233
+ - **Padrão:** null
234
+ - **Descrição:** Comando opcional para executar testes automatizados. Se definido, será executado além do comando `run`. Se null, apenas o comando `run` é utilizado para validação.
235
+ - **Exemplos:** `"npm test"`, `"pytest"`, `"cargo test"`
236
+
237
+ ---
238
+
239
+ ## interface
240
+
241
+ Configurações de interface e canais de comunicação com o agente.
242
+
243
+ ### interface.channel
244
+ - **Tipo:** string
245
+ - **Padrão:** `"terminal"`
246
+ - **Valores aceitos:** `"terminal"`, `"web"`, `"json"`
247
+ - **Descrição:** Canal principal de comunicação com o agente. `"terminal"` para interface de linha de comando interativa, `"web"` para interface web local (localhost), `"json"` para passar o prompt diretamente no arquivo de configuração (modo não interativo).
248
+
249
+ ### interface.prompt
250
+ - **Tipo:** string ou null
251
+ - **Padrão:** null
252
+ - **Descrição:** Prompt inicial enviado ao agente. Use quando `channel` for `"json"` para execução não interativa. Se null, o agente espera por input do usuário através do canal escolhido.
253
+ - **Exemplo:** `"Crie um sistema de autenticação com JWT e bcrypt"`
254
+
255
+ ### interface.notifications
256
+
257
+ Configurações de notificações externas para alertas e avisos.
258
+
259
+ #### interface.notifications.whatsapp
260
+ - **Tipo:** boolean
261
+ - **Padrão:** false
262
+ - **Descrição:** Ativa notificações via WhatsApp. Requer configuração adicional de credenciais. Usado para enviar alertas quando timeout é atingido ou quando o agente precisa de ajuda.
263
+
264
+ #### interface.notifications.telegram
265
+ - **Tipo:** boolean
266
+ - **Padrão:** false
267
+ - **Descrição:** Ativa notificações via Telegram. Requer configuração adicional de bot token. Usado para enviar alertas quando timeout é atingido ou quando o agente precisa de ajuda.
268
+
269
+ #### interface.notifications.slack
270
+ - **Tipo:** boolean
271
+ - **Padrão:** false
272
+ - **Descrição:** Ativa notificações via Slack. Requer configuração adicional de webhook. Usado para enviar alertas quando timeout é atingido ou quando o agente precisa de ajuda.
273
+
274
+ #### interface.notifications.email
275
+ - **Tipo:** boolean
276
+ - **Padrão:** false
277
+ - **Descrição:** Ativa notificações via email. Requer configuração adicional de SMTP. Usado para enviar alertas quando timeout é atingido ou quando o agente precisa de ajuda.
278
+
279
+ ---
280
+
281
+ ## teach
282
+
283
+ Configurações de contexto adicional para ensinar o agente sobre padrões, documentações e convenções do projeto.
284
+
285
+ ### teach.urls
286
+ - **Tipo:** array de strings
287
+ - **Padrão:** array vazio
288
+ - **Descrição:** Lista de URLs de documentações externas que o agente deve ler antes de começar a trabalhar. O agente fará o download do conteúdo desses sites e usará como contexto adicional. Útil para fornecer documentação oficial de frameworks e bibliotecas.
289
+ - **Exemplo de uso:**
290
+ ```json
291
+ "urls": [
292
+ "https://docs.nestjs.com",
293
+ "https://react.dev/learn",
294
+ "https://docs.python.org/3/"
295
+ ]
296
+ ```
297
+
298
+ ### teach.files
299
+ - **Tipo:** array de strings
300
+ - **Padrão:** array vazio
301
+ - **Descrição:** Lista de caminhos para arquivos locais que o agente deve ler antes de começar. Suporta apenas arquivos de texto simples (`.txt`, `.md`, `.json`, `.yml`, `.yaml`). Útil para fornecer padrões de código, convenções do projeto e contexto específico.
302
+ - **Exemplo de uso:**
303
+ ```json
304
+ "files": [
305
+ "./CODING_STANDARDS.md",
306
+ "./ARCHITECTURE.md",
307
+ "./project-context.txt"
308
+ ]
309
+ ```
310
+
311
+ ---
312
+
313
+ ## Exemplos Completos
314
+
315
+ ### Exemplo 1: Configuração Minimalista Cloud
316
+ ```json
317
+ {
318
+ "project": {
319
+ "workspace": "./src",
320
+ "testDir": "./"
321
+ },
322
+ "model": {
323
+ "primary": {
324
+ "provider": "anthropic",
325
+ "name": "claude-sonnet-4"
326
+ }
327
+ },
328
+ "commands": {
329
+ "run": "npm start"
330
+ }
331
+ }
332
+ ```
333
+
334
+ ### Exemplo 2: Configuração Local com Ollama
335
+ ```json
336
+ {
337
+ "project": {
338
+ "workspace": "./src",
339
+ "testDir": "./",
340
+ "versionControl": {
341
+ "before": true,
342
+ "after": true,
343
+ "generateNotes": true
344
+ }
345
+ },
346
+ "model": {
347
+ "primary": {
348
+ "provider": "ollama",
349
+ "name": "qwen2.5-coder:32b"
350
+ },
351
+ "endpoint": "http://localhost:11434"
352
+ },
353
+ "sandbox": {
354
+ "enabled": true,
355
+ "engine": "docker",
356
+ "memory": "1g",
357
+ "cpu": 1.0,
358
+ "network": "none"
359
+ },
360
+ "commands": {
361
+ "setup": "npm install",
362
+ "run": "npm run dev",
363
+ "test": "npm test"
364
+ },
365
+ "teach": {
366
+ "files": ["./CODING_STANDARDS.md"]
367
+ }
368
+ }
369
+ ```
370
+
371
+ ### Exemplo 3: Configuração Avançada com Rotação Inteligente
372
+ ```json
373
+ {
374
+ "project": {
375
+ "workspace": "./src",
376
+ "testDir": "./",
377
+ "versionControl": {
378
+ "before": true,
379
+ "after": true,
380
+ "generateNotes": true
381
+ }
382
+ },
383
+ "model": {
384
+ "primary": {
385
+ "provider": "ollama",
386
+ "name": "llama3.2:3b"
387
+ },
388
+ "endpoint": "http://localhost:11434",
389
+ "fallback": [
390
+ {
391
+ "provider": "google",
392
+ "name": "gemini-2.5-flash"
393
+ },
394
+ {
395
+ "provider": "anthropic",
396
+ "name": "claude-sonnet-4"
397
+ }
398
+ ]
399
+ },
400
+ "smartRotation": {
401
+ "enabled": true,
402
+ "simple": ["llama3.2:3b", "gemini-1.5-flash"],
403
+ "complex": ["gemini-2.5-flash", "claude-sonnet-4"]
404
+ },
405
+ "limits": {
406
+ "tokens": 50000,
407
+ "loops": 100,
408
+ "timeout": {
409
+ "enabled": true,
410
+ "duration": "30m",
411
+ "notify": true
412
+ }
413
+ },
414
+ "sandbox": {
415
+ "enabled": true,
416
+ "engine": "docker",
417
+ "memory": "1g",
418
+ "cpu": 1.0,
419
+ "network": "bridge"
420
+ },
421
+ "commands": {
422
+ "setup": "npm install",
423
+ "run": "npm run dev",
424
+ "test": "npm test"
425
+ },
426
+ "interface": {
427
+ "channel": "web",
428
+ "notifications": {
429
+ "telegram": true
430
+ }
431
+ },
432
+ "teach": {
433
+ "urls": ["https://docs.nestjs.com"],
434
+ "files": ["./ARCHITECTURE.md", "./STANDARDS.json"]
435
+ }
436
+ }
437
+ ```
438
+
439
+ ### Exemplo 4: Configuração llama.cpp com Parâmetros Customizados
440
+ ```json
441
+ {
442
+ "project": {
443
+ "workspace": "./lib",
444
+ "testDir": "./"
445
+ },
446
+ "model": {
447
+ "primary": {
448
+ "provider": "llamacpp",
449
+ "name": "qwen-32b-q4.gguf"
450
+ },
451
+ "endpoint": "http://127.0.0.1:8080",
452
+ "parameters": {
453
+ "n_ctx": 8192,
454
+ "n_gpu_layers": 35,
455
+ "temperature": 0.7,
456
+ "top_p": 0.9,
457
+ "repeat_penalty": 1.1
458
+ }
459
+ },
460
+ "sandbox": {
461
+ "enabled": false
462
+ },
463
+ "commands": {
464
+ "setup": "pip install -r requirements.txt",
465
+ "run": "python main.py"
466
+ },
467
+ "teach": {
468
+ "urls": ["https://docs.python.org/3/"],
469
+ "files": ["./project-context.txt"]
470
+ }
471
+ }
472
+ ```
@@ -0,0 +1,15 @@
1
+ import js from "@eslint/js";
2
+ import globals from "globals";
3
+ import tseslint from "typescript-eslint";
4
+ import { defineConfig } from "eslint/config";
5
+
6
+ export default defineConfig([
7
+ {
8
+ ignores: [
9
+ "dist/**",
10
+ "node_modules/**",
11
+ ],
12
+ },
13
+ { files: ["**/*.{js,mjs,cjs,ts,mts,cts}"], plugins: { js }, extends: ["js/recommended"], languageOptions: { globals: globals.browser } },
14
+ tseslint.configs.recommended,
15
+ ]);
package/main.ts ADDED
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Main entry point for BoxSafe
3
+ *
4
+ * Tests the segmentation system with the loop segment.
5
+ */
6
+
7
+ import { initSegments } from "@core/segments/map";
8
+ import { Logger } from "@util/logger";
9
+ import type { LoopOptions } from "@core/loop/types";
10
+ import { LService, LModel } from "@ai/label";
11
+
12
+ const logger = Logger.createModuleLogger('Main');
13
+
14
+ async function main() {
15
+ logger.info(`Starting BoxSafe (minimal main)...`);
16
+
17
+ try {
18
+ // Initialize and obtain the segment runner and configuration
19
+ const { runSegment, BSConfig } = await initSegments();
20
+
21
+ // Build a minimal, typed options object for the loop segment.
22
+ // Note: do not apply project-specific heuristics here — defer to the segment.
23
+ const loops = BSConfig.limits?.loops;
24
+
25
+ const pathOutput = process.env.AGENT_OUTPUT_PATH ?? BSConfig.paths?.artifactOutput ?? "./out.ts";
26
+ const pathGeneratedMarkdown = process.env.BOXSAFE_MARKDOWN_PATH ?? BSConfig.paths?.generatedMarkdown ?? "./memo/generated/codelog.md";
27
+ const promptFromEnv = typeof process.env.BOXSAFE_PROMPT === 'string' ? process.env.BOXSAFE_PROMPT : undefined;
28
+ const opts: LoopOptions = {
29
+ service: (BSConfig.model?.primary?.provider ?? LService.GOOGLE) as LService,
30
+ model: (BSConfig.model?.primary?.name ?? LModel.GEMINI) as LModel,
31
+ initialPrompt: promptFromEnv ?? BSConfig.interface?.prompt ?? "",
32
+ cmd: BSConfig.commands?.run ?? "echo OK",
33
+ lang: "ts",
34
+ pathOutput,
35
+ pathGeneratedMarkdown,
36
+ workspace: BSConfig.project?.workspace ?? process.cwd(),
37
+ ...(loops ? { maxIterations: loops, limit: loops } : {}),
38
+ };
39
+
40
+ logger.info(`Running loop segment`);
41
+
42
+ // Delegate execution to the segment runner (keep main minimal)
43
+ const result = await runSegment("loop", opts);
44
+
45
+ logger.info(`Loop completed: ${JSON.stringify(result)}`);
46
+ process.exit(result?.ok ? 0 : 1);
47
+ } catch (err: any) {
48
+ logger.error(`Fatal error: ${err?.message ?? err}`);
49
+ process.exit(1);
50
+ }
51
+ }
52
+
53
+ main();
@@ -0,0 +1,13 @@
1
+ ```json-tool
2
+ {
3
+ "tool": "navigate",
4
+ "params": {
5
+ "op": "write",
6
+ "path": "lv_test.ts",
7
+ "content": "console.log(\"hello world\");"
8
+ }
9
+ }
10
+ ```
11
+ ```ts
12
+ console.log("hello world");
13
+ ```
@@ -0,0 +1,6 @@
1
+ {
2
+ "current": 1,
3
+ "done": [
4
+ true
5
+ ]
6
+ }
@@ -0,0 +1,2 @@
1
+ 1. criar um arquivo chamado test.js no root ./
2
+ 2. adiconar ao arquivo test.js um arlgoritimo para imprimeir hello world!
@@ -0,0 +1,7 @@
1
+ exitCode=0
2
+ signal=none
3
+ timedOut=false
4
+ stdout:
5
+ hello world
6
+
7
+ stderr:
@@ -0,0 +1,11 @@
1
+ {"ts":"2026-02-12T19:57:48.227Z","runId":"mljvrxvi-9g0k4q","event":"loop.start","data":{"service":"google","model":"gemini-2.5-flash","lang":"ts","maxIterations":1}}
2
+ {"ts":"2026-02-12T19:57:48.229Z","runId":"mljvrxvi-9g0k4q","event":"versionControl.before.start"}
3
+ {"ts":"2026-02-12T19:57:48.295Z","runId":"mljvrxvi-9g0k4q","event":"versionControl.before.ok","data":{"result":{"committed":true,"pushed":false}}}
4
+ {"ts":"2026-02-12T19:57:48.297Z","runId":"mljvrxvi-9g0k4q","iter":1,"event":"iteration.start"}
5
+ {"ts":"2026-02-12T19:57:48.297Z","runId":"mljvrxvi-9g0k4q","iter":1,"event":"llm.run.start"}
6
+ {"ts":"2026-02-12T19:57:48.351Z","runId":"mljvrxvi-9g0k4q","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":1}}
7
+ {"ts":"2026-02-12T19:57:48.552Z","runId":"mljvrxvi-9g0k4q","iter":1,"event":"llm.run.start"}
8
+ {"ts":"2026-02-12T19:57:48.557Z","runId":"mljvrxvi-9g0k4q","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":2}}
9
+ {"ts":"2026-02-12T19:57:48.958Z","runId":"mljvrxvi-9g0k4q","iter":1,"event":"llm.run.start"}
10
+ {"ts":"2026-02-12T19:57:48.963Z","runId":"mljvrxvi-9g0k4q","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":3}}
11
+ {"ts":"2026-02-12T19:57:48.964Z","runId":"mljvrxvi-9g0k4q","iter":1,"event":"iteration.failed","data":{"layer":"llm"}}
@@ -0,0 +1,11 @@
1
+ {"ts":"2026-02-12T20:00:26.845Z","runId":"mljvvc9j-pe9ekj","event":"loop.start","data":{"service":"google","model":"gemini-2.5-flash","lang":"ts","maxIterations":1}}
2
+ {"ts":"2026-02-12T20:00:26.847Z","runId":"mljvvc9j-pe9ekj","event":"versionControl.before.start"}
3
+ {"ts":"2026-02-12T20:00:26.919Z","runId":"mljvvc9j-pe9ekj","event":"versionControl.before.ok","data":{"result":{"committed":true,"pushed":false}}}
4
+ {"ts":"2026-02-12T20:00:26.922Z","runId":"mljvvc9j-pe9ekj","iter":1,"event":"iteration.start"}
5
+ {"ts":"2026-02-12T20:00:26.922Z","runId":"mljvvc9j-pe9ekj","iter":1,"event":"llm.run.start"}
6
+ {"ts":"2026-02-12T20:00:26.985Z","runId":"mljvvc9j-pe9ekj","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":1}}
7
+ {"ts":"2026-02-12T20:00:27.186Z","runId":"mljvvc9j-pe9ekj","iter":1,"event":"llm.run.start"}
8
+ {"ts":"2026-02-12T20:00:27.188Z","runId":"mljvvc9j-pe9ekj","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":2}}
9
+ {"ts":"2026-02-12T20:00:27.589Z","runId":"mljvvc9j-pe9ekj","iter":1,"event":"llm.run.start"}
10
+ {"ts":"2026-02-12T20:00:27.591Z","runId":"mljvvc9j-pe9ekj","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":3}}
11
+ {"ts":"2026-02-12T20:00:27.591Z","runId":"mljvvc9j-pe9ekj","iter":1,"event":"iteration.failed","data":{"layer":"llm"}}
@@ -0,0 +1,11 @@
1
+ {"ts":"2026-02-12T20:00:39.509Z","runId":"mljvvm1c-wbnqzp","event":"loop.start","data":{"service":"google","model":"gemini-2.5-flash","lang":"ts","maxIterations":1}}
2
+ {"ts":"2026-02-12T20:00:39.510Z","runId":"mljvvm1c-wbnqzp","event":"versionControl.before.start"}
3
+ {"ts":"2026-02-12T20:00:39.578Z","runId":"mljvvm1c-wbnqzp","event":"versionControl.before.ok","data":{"result":{"committed":true,"pushed":false}}}
4
+ {"ts":"2026-02-12T20:00:39.581Z","runId":"mljvvm1c-wbnqzp","iter":1,"event":"iteration.start"}
5
+ {"ts":"2026-02-12T20:00:39.581Z","runId":"mljvvm1c-wbnqzp","iter":1,"event":"llm.run.start"}
6
+ {"ts":"2026-02-12T20:00:39.641Z","runId":"mljvvm1c-wbnqzp","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":1}}
7
+ {"ts":"2026-02-12T20:00:39.842Z","runId":"mljvvm1c-wbnqzp","iter":1,"event":"llm.run.start"}
8
+ {"ts":"2026-02-12T20:00:39.845Z","runId":"mljvvm1c-wbnqzp","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":2}}
9
+ {"ts":"2026-02-12T20:00:40.246Z","runId":"mljvvm1c-wbnqzp","iter":1,"event":"llm.run.start"}
10
+ {"ts":"2026-02-12T20:00:40.251Z","runId":"mljvvm1c-wbnqzp","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":3}}
11
+ {"ts":"2026-02-12T20:00:40.253Z","runId":"mljvvm1c-wbnqzp","iter":1,"event":"iteration.failed","data":{"layer":"llm"}}
@@ -0,0 +1,11 @@
1
+ {"ts":"2026-02-12T20:43:13.756Z","runId":"mljxecwn-9xh3nw","event":"loop.start","data":{"service":"google","model":"gemini-2.5-flash","lang":"ts","maxIterations":1}}
2
+ {"ts":"2026-02-12T20:43:13.757Z","runId":"mljxecwn-9xh3nw","event":"versionControl.before.start"}
3
+ {"ts":"2026-02-12T20:43:13.823Z","runId":"mljxecwn-9xh3nw","event":"versionControl.before.ok","data":{"result":{"committed":true,"pushed":false}}}
4
+ {"ts":"2026-02-12T20:43:13.825Z","runId":"mljxecwn-9xh3nw","iter":1,"event":"iteration.start"}
5
+ {"ts":"2026-02-12T20:43:13.825Z","runId":"mljxecwn-9xh3nw","iter":1,"event":"llm.run.start"}
6
+ {"ts":"2026-02-12T20:43:13.876Z","runId":"mljxecwn-9xh3nw","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":1}}
7
+ {"ts":"2026-02-12T20:43:14.077Z","runId":"mljxecwn-9xh3nw","iter":1,"event":"llm.run.start"}
8
+ {"ts":"2026-02-12T20:43:14.082Z","runId":"mljxecwn-9xh3nw","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":2}}
9
+ {"ts":"2026-02-12T20:43:14.484Z","runId":"mljxecwn-9xh3nw","iter":1,"event":"llm.run.start"}
10
+ {"ts":"2026-02-12T20:43:14.488Z","runId":"mljxecwn-9xh3nw","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":3}}
11
+ {"ts":"2026-02-12T20:43:14.489Z","runId":"mljxecwn-9xh3nw","iter":1,"event":"iteration.failed","data":{"layer":"llm"}}
@@ -0,0 +1,11 @@
1
+ {"ts":"2026-02-12T20:52:43.383Z","runId":"mljxqkfm-ipijik","event":"loop.start","data":{"service":"google","model":"gemini-2.5-flash","lang":"ts","maxIterations":1}}
2
+ {"ts":"2026-02-12T20:52:43.385Z","runId":"mljxqkfm-ipijik","event":"versionControl.before.start"}
3
+ {"ts":"2026-02-12T20:52:43.460Z","runId":"mljxqkfm-ipijik","event":"versionControl.before.ok","data":{"result":{"committed":true,"pushed":false}}}
4
+ {"ts":"2026-02-12T20:52:43.462Z","runId":"mljxqkfm-ipijik","iter":1,"event":"iteration.start"}
5
+ {"ts":"2026-02-12T20:52:43.463Z","runId":"mljxqkfm-ipijik","iter":1,"event":"llm.run.start"}
6
+ {"ts":"2026-02-12T20:52:43.533Z","runId":"mljxqkfm-ipijik","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":1}}
7
+ {"ts":"2026-02-12T20:52:43.734Z","runId":"mljxqkfm-ipijik","iter":1,"event":"llm.run.start"}
8
+ {"ts":"2026-02-12T20:52:43.737Z","runId":"mljxqkfm-ipijik","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":2}}
9
+ {"ts":"2026-02-12T20:52:44.138Z","runId":"mljxqkfm-ipijik","iter":1,"event":"llm.run.start"}
10
+ {"ts":"2026-02-12T20:52:44.139Z","runId":"mljxqkfm-ipijik","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":3}}
11
+ {"ts":"2026-02-12T20:52:44.139Z","runId":"mljxqkfm-ipijik","iter":1,"event":"iteration.failed","data":{"layer":"llm"}}
@@ -0,0 +1,11 @@
1
+ {"ts":"2026-02-12T20:57:35.425Z","runId":"mljxwtrw-3fanky","event":"loop.start","data":{"service":"google","model":"gemini-2.5-flash","lang":"ts","maxIterations":1}}
2
+ {"ts":"2026-02-12T20:57:35.426Z","runId":"mljxwtrw-3fanky","event":"versionControl.before.start"}
3
+ {"ts":"2026-02-12T20:57:35.489Z","runId":"mljxwtrw-3fanky","event":"versionControl.before.ok","data":{"result":{"committed":true,"pushed":false}}}
4
+ {"ts":"2026-02-12T20:57:35.490Z","runId":"mljxwtrw-3fanky","iter":1,"event":"iteration.start"}
5
+ {"ts":"2026-02-12T20:57:35.491Z","runId":"mljxwtrw-3fanky","iter":1,"event":"llm.run.start"}
6
+ {"ts":"2026-02-12T20:57:35.546Z","runId":"mljxwtrw-3fanky","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":1}}
7
+ {"ts":"2026-02-12T20:57:35.747Z","runId":"mljxwtrw-3fanky","iter":1,"event":"llm.run.start"}
8
+ {"ts":"2026-02-12T20:57:35.751Z","runId":"mljxwtrw-3fanky","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":2}}
9
+ {"ts":"2026-02-12T20:57:36.153Z","runId":"mljxwtrw-3fanky","iter":1,"event":"llm.run.start"}
10
+ {"ts":"2026-02-12T20:57:36.157Z","runId":"mljxwtrw-3fanky","iter":1,"event":"llm.run.error","data":{"error":"Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.","attempt":3}}
11
+ {"ts":"2026-02-12T20:57:36.159Z","runId":"mljxwtrw-3fanky","iter":1,"event":"iteration.failed","data":{"layer":"llm"}}