busybits 2.0.1 → 2.1.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 (30) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +5 -1
  3. package/README.md +11 -0
  4. package/dist/build.json +2 -2
  5. package/dist/cli/busybits.js +266 -15
  6. package/dist/client/bundle/app-BXRp9yel.js +24 -0
  7. package/dist/client/bundle/{app-CoDOLwxe.css → app-Y2N0l58V.css} +1 -1
  8. package/dist/client/bundle/city-SSVRvwxu.js +1 -0
  9. package/dist/client/bundle/{daystats-CJyNq6hu.js → daystats-B5wgtYEK.js} +1 -1
  10. package/dist/client/bundle/{dom-slmnBOjx.js → dom-DTwIMOMe.js} +1 -1
  11. package/dist/client/bundle/{en-BQQEHqmG.js → en-C1UkXkY6.js} +22 -2
  12. package/dist/client/bundle/{es-BgBoKwEe.js → es-DrTXrvU-.js} +22 -2
  13. package/dist/client/bundle/{format-CvlPqloO.js → format-COWnO8aN.js} +1 -1
  14. package/dist/client/bundle/{fr-PI_gjIFq.js → fr-DSvgQnax.js} +22 -2
  15. package/dist/client/bundle/{main-DTHUta25.js → main-CjRdSA5N.js} +2 -2
  16. package/dist/client/bundle/{ptypane-9pL54zR0.js → ptypane-BU6MDOyh.js} +1 -1
  17. package/dist/client/bundle/{room-name-Bv6N672f.js → room-name-DefEKN7q.js} +1 -1
  18. package/dist/client/bundle/{simulator-B45JPgSp.js → simulator-BhSq5TwZ.js} +1 -1
  19. package/dist/client/bundle/world-model-D6tSJZPE.js +1 -0
  20. package/dist/client/bundle/{world-stream-CUfry7aL.js → world-stream-pGb-glkT.js} +1 -1
  21. package/dist/client/index.html +1 -1
  22. package/dist/server/index.js +997 -432
  23. package/mod/habblaud/.claude-plugin/plugin.json +1 -1
  24. package/mod/habblaud-mensagens/.claude-plugin/plugin.json +1 -1
  25. package/mod/habblaud-permissoes/.claude-plugin/plugin.json +1 -1
  26. package/mod/habblaud-pi/package.json +1 -1
  27. package/package.json +2 -1
  28. package/dist/client/bundle/app-QYGBa260.js +0 -24
  29. package/dist/client/bundle/city-UYDbxWIy.js +0 -1
  30. package/dist/client/bundle/world-model-BgjMjmrp.js +0 -1
@@ -17,7 +17,7 @@ function applyBusybitsAliases(env) {
17
17
  applyBusybitsAliases(process.env);
18
18
 
19
19
  // server/index.ts
20
- import { existsSync as existsSync13, readFileSync as readFileSync29 } from "node:fs";
20
+ import { existsSync as existsSync13, readFileSync as readFileSync30 } from "node:fs";
21
21
  import http4 from "node:http";
22
22
  import { join as join33 } from "node:path";
23
23
 
@@ -3662,7 +3662,7 @@ var EN = {
3662
3662
  "Estilo padr\xE3o salvo para novos agentes.": "Default style saved for new agents.",
3663
3663
  "Estilo padr\xE3o restaurado para aleat\xF3rio.": "Default style restored to random.",
3664
3664
  "N\xE3o foi poss\xEDvel salvar o estilo padr\xE3o (erro {0}).": "Could not save the default style (error {0}).",
3665
- 'Uso: busybits <comando> [op\xE7\xF5es]\n\nComandos:\n setup instala ou atualiza as extens\xF5es e servi\xE7os do Busybits\n start inicia o servidor em primeiro plano\n status mostra o estado da instala\xE7\xE3o e dos servi\xE7os\n update atualiza o Busybits para a vers\xE3o mais recente\n uninstall remove extens\xF5es e servi\xE7os instalados\n pair emparelha esta m\xE1quina como sat\xE9lite de um Busybits central\n\nOp\xE7\xF5es de setup:\n --service instala e inicia o servi\xE7o de usu\xE1rio (systemd/launchd)\n --port <n> porta do servidor\n --no-claude n\xE3o mexe no Claude Code\n --no-pi n\xE3o mexe no Pi\n --no-codex n\xE3o mexe nos hooks do Codex\n --dry-run s\xF3 mostra o que seria feito\n --after-update usado por "busybits update": reinicia o servi\xE7o mesmo sem mudan\xE7a na unidade\n --rebuild refaz o build (instala\xE7\xE3o a partir de um clone)\n --ignore-node ignora a verifica\xE7\xE3o da vers\xE3o do Node\n\nOp\xE7\xF5es de update:\n --check s\xF3 mostra a vers\xE3o atual e a mais recente\n --rollback volta para a vers\xE3o anterior\n --to <vers\xE3o> atualiza para essa vers\xE3o em vez da mais recente\n --global atualiza tamb\xE9m o busybits global (npm i -g)\n\nOp\xE7\xF5es de uninstall:\n --purge apaga tamb\xE9m os dados do Busybits\n --dry-run s\xF3 mostra o que seria feito\n\nOp\xE7\xF5es de pair:\n --pairing <texto> texto de pareamento da central (padr\xE3o: entrada padr\xE3o)\n --label <nome> como esta m\xE1quina aparece no escrit\xF3rio\n --codex-wait instala os hooks do Codex com espera pela sua resposta\n\nOp\xE7\xF5es globais:\n --help, -h mostra esta ajuda\n --version, -v mostra a vers\xE3o instalada': 'Usage: busybits <command> [options]\n\nCommands:\n setup install or update Busybits extensions and services\n start start the server in the foreground\n status show status of installed components and services\n update update Busybits to the latest version\n uninstall remove installed extensions and services\n pair pair this machine as a satellite to a central Busybits\n\nOptions for setup:\n --service install and start the user service (systemd/launchd)\n --port <n> server port\n --no-claude leave Claude Code alone\n --no-pi leave Pi alone\n --no-codex leave the Codex hooks alone\n --dry-run only show what would be done\n --after-update used by "busybits update": restart the service even if the unit did not change\n --rebuild rebuild (install from a clone)\n --ignore-node skip the Node version check\n\nOptions for update:\n --check only shows the current and the latest version\n --rollback goes back to the previous version\n --to <version> updates to that version instead of the latest\n --global also updates the global busybits (npm i -g)\n\nOptions for uninstall:\n --purge also delete the Busybits data\n --dry-run only show what would be done\n\nOptions for pair:\n --pairing <text> pairing text from the central (default: standard input)\n --label <name> how this machine appears in the office\n --codex-wait install the Codex hooks and wait for your answer\n\nGlobal options:\n --help, -h show this help\n --version, -v show installed version',
3665
+ 'Uso: busybits <comando> [op\xE7\xF5es]\n\nComandos:\n setup instala ou atualiza as extens\xF5es e servi\xE7os do Busybits\n start inicia o servidor em primeiro plano\n status mostra o estado da instala\xE7\xE3o e dos servi\xE7os\n update atualiza o Busybits para a vers\xE3o mais recente\n uninstall remove extens\xF5es e servi\xE7os instalados\n pair emparelha esta m\xE1quina como sat\xE9lite de um Busybits central\n post deixa um item na mesa do seu escrit\xF3rio (a caixa de entrada)\n\nOp\xE7\xF5es de setup:\n --service instala e inicia o servi\xE7o de usu\xE1rio (systemd/launchd)\n --port <n> porta do servidor\n --no-claude n\xE3o mexe no Claude Code\n --no-pi n\xE3o mexe no Pi\n --no-codex n\xE3o mexe nos hooks do Codex\n --dry-run s\xF3 mostra o que seria feito\n --after-update usado por "busybits update": reinicia o servi\xE7o mesmo sem mudan\xE7a na unidade\n --rebuild refaz o build (instala\xE7\xE3o a partir de um clone)\n --ignore-node ignora a verifica\xE7\xE3o da vers\xE3o do Node\n\nOp\xE7\xF5es de update:\n --check s\xF3 mostra a vers\xE3o atual e a mais recente\n --rollback volta para a vers\xE3o anterior\n --to <vers\xE3o> atualiza para essa vers\xE3o em vez da mais recente\n --global atualiza tamb\xE9m o busybits global (npm i -g)\n\nOp\xE7\xF5es de uninstall:\n --purge apaga tamb\xE9m os dados do Busybits\n --dry-run s\xF3 mostra o que seria feito\n\nOp\xE7\xF5es de pair:\n --pairing <texto> texto de pareamento da central (padr\xE3o: entrada padr\xE3o)\n --label <nome> como esta m\xE1quina aparece no escrit\xF3rio\n --codex-wait instala os hooks do Codex com espera pela sua resposta\n\nOp\xE7\xF5es de post:\n --title <texto> t\xEDtulo do item (obrigat\xF3rio)\n --body <texto> detalhes em texto simples\n --link <url> link http(s) que o item abre\n --key <chave> a mesma chave atualiza o item (e o reabre se estava resolvido)\n --source <nome> quem est\xE1 deixando o item (aparece quando n\xE3o \xE9 um agente)\n\nOp\xE7\xF5es globais:\n --help, -h mostra esta ajuda\n --version, -v mostra a vers\xE3o instalada': 'Usage: busybits <command> [options]\n\nCommands:\n setup install or update Busybits extensions and services\n start start the server in the foreground\n status show status of installed components and services\n update update Busybits to the latest version\n uninstall remove installed extensions and services\n pair pair this machine as a satellite to a central Busybits\n post leave an item on your office desk (the inbox)\n\nOptions for setup:\n --service install and start the user service (systemd/launchd)\n --port <n> server port\n --no-claude leave Claude Code alone\n --no-pi leave Pi alone\n --no-codex leave the Codex hooks alone\n --dry-run only show what would be done\n --after-update used by "busybits update": restart the service even if the unit did not change\n --rebuild rebuild (install from a clone)\n --ignore-node skip the Node version check\n\nOptions for update:\n --check only shows the current and the latest version\n --rollback goes back to the previous version\n --to <version> updates to that version instead of the latest\n --global also updates the global busybits (npm i -g)\n\nOptions for uninstall:\n --purge also delete the Busybits data\n --dry-run only show what would be done\n\nOptions for pair:\n --pairing <text> pairing text from the central (default: standard input)\n --label <name> how this machine appears in the office\n --codex-wait install the Codex hooks and wait for your answer\n\nOptions for post:\n --title <text> item title (required)\n --body <text> details as plain text\n --link <url> http(s) link the item opens\n --key <key> the same key updates the item (and reopens it if it was resolved)\n --source <name> who is leaving the item (shown when it is not an agent)\n\nGlobal options:\n --help, -h show this help\n --version, -v show installed version',
3666
3666
  "No Windows, use scripts/windows/install-satellite.ps1 a partir de um clone (o busybits ainda n\xE3o instala servi\xE7o no Windows).": "On Windows, use scripts/windows/install-satellite.ps1 from a clone (busybits does not install a service on Windows yet).",
3667
3667
  "comando desconhecido: {0}": "unknown command: {0}",
3668
3668
  "{0} precisa de um valor": "{0} needs a value",
@@ -3686,7 +3686,46 @@ var EN = {
3686
3686
  "Voltei para a v{0}.": "Went back to v{0}.",
3687
3687
  "a vers\xE3o {0} n\xE3o tem um payload completo em {1}": "version {0} has no complete payload in {1}",
3688
3688
  "O Busybits precisa do Node 22.12+ ou 24, e nenhum foi encontrado. Instale um (por exemplo com o nvm: nvm install 24) e rode de novo.": "Busybits needs Node 22.12+ or 24, and none was found. Install one (for example with nvm: nvm install 24) and run it again.",
3689
- "servi\xE7o antigo {0} removido": "old service {0} removed"
3689
+ "servi\xE7o antigo {0} removido": "old service {0} removed",
3690
+ "os itens da mesa s\xF3 s\xE3o resolvidos pelo pr\xF3prio computador (http://localhost ou http://127.0.0.1)": "desk items are only resolved from the computer itself (http://localhost or http://127.0.0.1)",
3691
+ "s\xF3 o pr\xF3prio computador deixa itens na mesa (http://localhost ou http://127.0.0.1)": "only the computer itself leaves items on the desk (http://localhost or http://127.0.0.1)",
3692
+ "a mesa s\xF3 vale pelo pr\xF3prio computador ou pelo acesso remoto com login": "the desk only works from the computer itself or through remote access with login",
3693
+ "a mesa j\xE1 tem {0} itens abertos: resolva alguns antes de deixar outros": "the desk already has {0} open items: resolve some before leaving more",
3694
+ "item n\xE3o encontrado": "item not found",
3695
+ "inbox.json ileg\xEDvel ({0}); come\xE7ando sem itens.": "inbox.json unreadable ({0}); starting with no items.",
3696
+ "corpo inv\xE1lido": "invalid body",
3697
+ "t\xEDtulo obrigat\xF3rio": "title required",
3698
+ "t\xEDtulo longo demais (m\xE1x. {0} caracteres)": "title too long (max {0} characters)",
3699
+ "texto inv\xE1lido": "invalid text",
3700
+ "texto longo demais (m\xE1x. {0} KB)": "text too long (max {0} KB)",
3701
+ "link inv\xE1lido": "invalid link",
3702
+ "o link precisa ser http ou https": "the link must be http or https",
3703
+ "chave inv\xE1lida": "invalid key",
3704
+ "chave longa demais (m\xE1x. {0} caracteres)": "key too long (max {0} characters)",
3705
+ "origem inv\xE1lida": "invalid source",
3706
+ "ancestrais inv\xE1lidos": "invalid ancestors",
3707
+ 'Uso: busybits post --title <texto> [op\xE7\xF5es]\n\nDeixa um item na mesa do seu escrit\xF3rio (o painel "Mesa" abre ao clicar no monte de pap\xE9is).\n\nOp\xE7\xF5es:\n --title <texto> t\xEDtulo do item (obrigat\xF3rio, at\xE9 200 caracteres)\n --body <texto> detalhes em texto simples (at\xE9 8 KB)\n --link <url> link http(s) que o item abre\n --key <chave> a mesma chave atualiza o item em vez de duplicar (e o reabre se j\xE1 estava resolvido)\n --source <nome> quem est\xE1 deixando o item (aparece quando n\xE3o \xE9 um agente)\n\nExemplo:\n busybits post --title "ROO7-1234 rejeitado no QA" --link https://example.com/ROO7-1234 --key ROO7-1234': 'Usage: busybits post --title <text> [options]\n\nLeaves an item on your office desk (the "Desk" panel opens when you click the stack of papers).\n\nOptions:\n --title <text> item title (required, up to 200 characters)\n --body <text> details as plain text (up to 8 KB)\n --link <url> http(s) link the item opens\n --key <key> the same key updates the item instead of duplicating it (and reopens it if it was already resolved)\n --source <name> who is leaving the item (shown when it is not an agent)\n\nExample:\n busybits post --title "ROO7-1234 rejected in QA" --link https://example.com/ROO7-1234 --key ROO7-1234',
3708
+ "falta --title": "missing --title",
3709
+ "N\xE3o consegui falar com o Busybits na porta {0}. Ele est\xE1 rodando? (busybits start; outra porta: HABBLAUD_PORT)": "Could not reach Busybits on port {0}. Is it running? (busybits start; another port: HABBLAUD_PORT)",
3710
+ "O Busybits recusou o item ({0}): {1}": "Busybits refused the item ({0}): {1}",
3711
+ "Item reaberto na mesa: {0}": "Item reopened on the desk: {0}",
3712
+ "Item atualizado na mesa: {0}": "Item updated on the desk: {0}",
3713
+ "Item deixado na mesa: {0}": "Item left on the desk: {0}",
3714
+ "A mesa s\xF3 funciona com o escrit\xF3rio ao vivo.": "The desk only works with the live office.",
3715
+ "N\xE3o foi poss\xEDvel resolver o item (erro {0}).": "Could not resolve the item (error {0}).",
3716
+ "um agente": "an agent",
3717
+ "um script": "a script",
3718
+ "resolvido {0}": "resolved {0}",
3719
+ "de {0}": "from {0}",
3720
+ "Resolver": "Resolve",
3721
+ "Nada por aqui.": "Nothing here.",
3722
+ "Sua mesa est\xE1 limpa: nada esperando.": "Your desk is clear: nothing waiting.",
3723
+ "Ocultar resolvidos": "Hide resolved",
3724
+ "Mostrar resolvidos ({0})": "Show resolved ({0})",
3725
+ "Itens deixados na sua mesa. Clique para abrir.": "Items left on your desk. Click to open.",
3726
+ "na mesa": "on desk",
3727
+ "Na sua mesa": "On your desk",
3728
+ "Mensageiro": "Courier"
3690
3729
  };
3691
3730
 
3692
3731
  // shared/locales/es.ts
@@ -7325,7 +7364,7 @@ var ES = {
7325
7364
  "Estilo padr\xE3o salvo para novos agentes.": "Estilo predeterminado guardado para nuevos agentes.",
7326
7365
  "Estilo padr\xE3o restaurado para aleat\xF3rio.": "Estilo predeterminado restaurado a aleatorio.",
7327
7366
  "N\xE3o foi poss\xEDvel salvar o estilo padr\xE3o (erro {0}).": "No se pudo guardar el estilo predeterminado (error {0}).",
7328
- 'Uso: busybits <comando> [op\xE7\xF5es]\n\nComandos:\n setup instala ou atualiza as extens\xF5es e servi\xE7os do Busybits\n start inicia o servidor em primeiro plano\n status mostra o estado da instala\xE7\xE3o e dos servi\xE7os\n update atualiza o Busybits para a vers\xE3o mais recente\n uninstall remove extens\xF5es e servi\xE7os instalados\n pair emparelha esta m\xE1quina como sat\xE9lite de um Busybits central\n\nOp\xE7\xF5es de setup:\n --service instala e inicia o servi\xE7o de usu\xE1rio (systemd/launchd)\n --port <n> porta do servidor\n --no-claude n\xE3o mexe no Claude Code\n --no-pi n\xE3o mexe no Pi\n --no-codex n\xE3o mexe nos hooks do Codex\n --dry-run s\xF3 mostra o que seria feito\n --after-update usado por "busybits update": reinicia o servi\xE7o mesmo sem mudan\xE7a na unidade\n --rebuild refaz o build (instala\xE7\xE3o a partir de um clone)\n --ignore-node ignora a verifica\xE7\xE3o da vers\xE3o do Node\n\nOp\xE7\xF5es de update:\n --check s\xF3 mostra a vers\xE3o atual e a mais recente\n --rollback volta para a vers\xE3o anterior\n --to <vers\xE3o> atualiza para essa vers\xE3o em vez da mais recente\n --global atualiza tamb\xE9m o busybits global (npm i -g)\n\nOp\xE7\xF5es de uninstall:\n --purge apaga tamb\xE9m os dados do Busybits\n --dry-run s\xF3 mostra o que seria feito\n\nOp\xE7\xF5es de pair:\n --pairing <texto> texto de pareamento da central (padr\xE3o: entrada padr\xE3o)\n --label <nome> como esta m\xE1quina aparece no escrit\xF3rio\n --codex-wait instala os hooks do Codex com espera pela sua resposta\n\nOp\xE7\xF5es globais:\n --help, -h mostra esta ajuda\n --version, -v mostra a vers\xE3o instalada': 'Uso: busybits <comando> [opciones]\n\nComandos:\n setup instala o actualiza las extensiones y servicios de Busybits\n start inicia el servidor en primer plano\n status muestra el estado de la instalaci\xF3n y los servicios\n update actualiza Busybits a la \xFAltima versi\xF3n\n uninstall desinstala extensiones y servicios instalados\n pair empareja este equipo como sat\xE9lite de un Busybits central\n\nOpciones de setup:\n --service instala e inicia el servicio de usuario (systemd/launchd)\n --port <n> puerto del servidor\n --no-claude no toca Claude Code\n --no-pi no toca Pi\n --no-codex no toca los hooks de Codex\n --dry-run solo muestra lo que se har\xEDa\n --after-update usado por "busybits update": reinicia el servicio aunque la unidad no haya cambiado\n --rebuild recompila (instalaci\xF3n desde un clon)\n --ignore-node omite la comprobaci\xF3n de la versi\xF3n de Node\n\nOpciones de update:\n --check solo muestra la versi\xF3n actual y la \xFAltima\n --rollback vuelve a la versi\xF3n anterior\n --to <versi\xF3n> actualiza a esa versi\xF3n en lugar de la \xFAltima\n --global actualiza tambi\xE9n el busybits global (npm i -g)\n\nOpciones de uninstall:\n --purge borra tambi\xE9n los datos de Busybits\n --dry-run solo muestra lo que se har\xEDa\n\nOpciones de pair:\n --pairing <texto> texto de emparejamiento de la central (por defecto: entrada est\xE1ndar)\n --label <nombre> c\xF3mo aparece esta m\xE1quina en la oficina\n --codex-wait instala los hooks de Codex y espera su respuesta\n\nOpciones globales:\n --help, -h muestra esta ayuda\n --version, -v muestra la versi\xF3n instalada',
7367
+ 'Uso: busybits <comando> [op\xE7\xF5es]\n\nComandos:\n setup instala ou atualiza as extens\xF5es e servi\xE7os do Busybits\n start inicia o servidor em primeiro plano\n status mostra o estado da instala\xE7\xE3o e dos servi\xE7os\n update atualiza o Busybits para a vers\xE3o mais recente\n uninstall remove extens\xF5es e servi\xE7os instalados\n pair emparelha esta m\xE1quina como sat\xE9lite de um Busybits central\n post deixa um item na mesa do seu escrit\xF3rio (a caixa de entrada)\n\nOp\xE7\xF5es de setup:\n --service instala e inicia o servi\xE7o de usu\xE1rio (systemd/launchd)\n --port <n> porta do servidor\n --no-claude n\xE3o mexe no Claude Code\n --no-pi n\xE3o mexe no Pi\n --no-codex n\xE3o mexe nos hooks do Codex\n --dry-run s\xF3 mostra o que seria feito\n --after-update usado por "busybits update": reinicia o servi\xE7o mesmo sem mudan\xE7a na unidade\n --rebuild refaz o build (instala\xE7\xE3o a partir de um clone)\n --ignore-node ignora a verifica\xE7\xE3o da vers\xE3o do Node\n\nOp\xE7\xF5es de update:\n --check s\xF3 mostra a vers\xE3o atual e a mais recente\n --rollback volta para a vers\xE3o anterior\n --to <vers\xE3o> atualiza para essa vers\xE3o em vez da mais recente\n --global atualiza tamb\xE9m o busybits global (npm i -g)\n\nOp\xE7\xF5es de uninstall:\n --purge apaga tamb\xE9m os dados do Busybits\n --dry-run s\xF3 mostra o que seria feito\n\nOp\xE7\xF5es de pair:\n --pairing <texto> texto de pareamento da central (padr\xE3o: entrada padr\xE3o)\n --label <nome> como esta m\xE1quina aparece no escrit\xF3rio\n --codex-wait instala os hooks do Codex com espera pela sua resposta\n\nOp\xE7\xF5es de post:\n --title <texto> t\xEDtulo do item (obrigat\xF3rio)\n --body <texto> detalhes em texto simples\n --link <url> link http(s) que o item abre\n --key <chave> a mesma chave atualiza o item (e o reabre se estava resolvido)\n --source <nome> quem est\xE1 deixando o item (aparece quando n\xE3o \xE9 um agente)\n\nOp\xE7\xF5es globais:\n --help, -h mostra esta ajuda\n --version, -v mostra a vers\xE3o instalada': 'Uso: busybits <comando> [opciones]\n\nComandos:\n setup instala o actualiza las extensiones y servicios de Busybits\n start inicia el servidor en primer plano\n status muestra el estado de la instalaci\xF3n y los servicios\n update actualiza Busybits a la \xFAltima versi\xF3n\n uninstall desinstala extensiones y servicios instalados\n pair empareja este equipo como sat\xE9lite de un Busybits central\n post deja un elemento en el escritorio de tu oficina (la bandeja)\n\nOpciones de setup:\n --service instala e inicia el servicio de usuario (systemd/launchd)\n --port <n> puerto del servidor\n --no-claude no toca Claude Code\n --no-pi no toca Pi\n --no-codex no toca los hooks de Codex\n --dry-run solo muestra lo que se har\xEDa\n --after-update usado por "busybits update": reinicia el servicio aunque la unidad no haya cambiado\n --rebuild recompila (instalaci\xF3n desde un clon)\n --ignore-node omite la comprobaci\xF3n de la versi\xF3n de Node\n\nOpciones de update:\n --check solo muestra la versi\xF3n actual y la \xFAltima\n --rollback vuelve a la versi\xF3n anterior\n --to <versi\xF3n> actualiza a esa versi\xF3n en lugar de la \xFAltima\n --global actualiza tambi\xE9n el busybits global (npm i -g)\n\nOpciones de uninstall:\n --purge borra tambi\xE9n los datos de Busybits\n --dry-run solo muestra lo que se har\xEDa\n\nOpciones de pair:\n --pairing <texto> texto de emparejamiento de la central (por defecto: entrada est\xE1ndar)\n --label <nombre> c\xF3mo aparece esta m\xE1quina en la oficina\n --codex-wait instala los hooks de Codex y espera su respuesta\n\nOpciones de post:\n --title <texto> t\xEDtulo del elemento (obligatorio)\n --body <texto> detalles en texto simple\n --link <url> enlace http(s) que abre el elemento\n --key <clave> la misma clave actualiza el elemento (y lo reabre si estaba resuelto)\n --source <nombre> qui\xE9n deja el elemento (se muestra cuando no es un agente)\n\nOpciones globales:\n --help, -h muestra esta ayuda\n --version, -v muestra la versi\xF3n instalada',
7329
7368
  "No Windows, use scripts/windows/install-satellite.ps1 a partir de um clone (o busybits ainda n\xE3o instala servi\xE7o no Windows).": "En Windows, usa scripts/windows/install-satellite.ps1 desde un clon (busybits a\xFAn no instala servicio en Windows).",
7330
7369
  "comando desconhecido: {0}": "comando desconocido: {0}",
7331
7370
  "{0} precisa de um valor": "{0} necesita un valor",
@@ -7349,7 +7388,46 @@ var ES = {
7349
7388
  "Voltei para a v{0}.": "Volv\xED a la v{0}.",
7350
7389
  "a vers\xE3o {0} n\xE3o tem um payload completo em {1}": "la versi\xF3n {0} no tiene un payload completo en {1}",
7351
7390
  "O Busybits precisa do Node 22.12+ ou 24, e nenhum foi encontrado. Instale um (por exemplo com o nvm: nvm install 24) e rode de novo.": "Busybits necesita Node 22.12+ o 24, y no se encontr\xF3 ninguno. Instala uno (por ejemplo con nvm: nvm install 24) y ejec\xFAtalo de nuevo.",
7352
- "servi\xE7o antigo {0} removido": "servicio antiguo {0} eliminado"
7391
+ "servi\xE7o antigo {0} removido": "servicio antiguo {0} eliminado",
7392
+ "os itens da mesa s\xF3 s\xE3o resolvidos pelo pr\xF3prio computador (http://localhost ou http://127.0.0.1)": "los elementos del escritorio solo se resuelven desde el propio ordenador (http://localhost o http://127.0.0.1)",
7393
+ "s\xF3 o pr\xF3prio computador deixa itens na mesa (http://localhost ou http://127.0.0.1)": "solo el propio ordenador deja elementos en el escritorio (http://localhost o http://127.0.0.1)",
7394
+ "a mesa s\xF3 vale pelo pr\xF3prio computador ou pelo acesso remoto com login": "el escritorio solo vale desde el propio ordenador o por el acceso remoto con inicio de sesi\xF3n",
7395
+ "a mesa j\xE1 tem {0} itens abertos: resolva alguns antes de deixar outros": "el escritorio ya tiene {0} elementos abiertos: resuelve algunos antes de dejar m\xE1s",
7396
+ "item n\xE3o encontrado": "elemento no encontrado",
7397
+ "inbox.json ileg\xEDvel ({0}); come\xE7ando sem itens.": "inbox.json ilegible ({0}); empezando sin elementos.",
7398
+ "corpo inv\xE1lido": "cuerpo inv\xE1lido",
7399
+ "t\xEDtulo obrigat\xF3rio": "t\xEDtulo obligatorio",
7400
+ "t\xEDtulo longo demais (m\xE1x. {0} caracteres)": "t\xEDtulo demasiado largo (m\xE1x. {0} caracteres)",
7401
+ "texto inv\xE1lido": "texto inv\xE1lido",
7402
+ "texto longo demais (m\xE1x. {0} KB)": "texto demasiado largo (m\xE1x. {0} KB)",
7403
+ "link inv\xE1lido": "enlace inv\xE1lido",
7404
+ "o link precisa ser http ou https": "el enlace debe ser http o https",
7405
+ "chave inv\xE1lida": "clave inv\xE1lida",
7406
+ "chave longa demais (m\xE1x. {0} caracteres)": "clave demasiado larga (m\xE1x. {0} caracteres)",
7407
+ "origem inv\xE1lida": "origen inv\xE1lido",
7408
+ "ancestrais inv\xE1lidos": "ancestros inv\xE1lidos",
7409
+ 'Uso: busybits post --title <texto> [op\xE7\xF5es]\n\nDeixa um item na mesa do seu escrit\xF3rio (o painel "Mesa" abre ao clicar no monte de pap\xE9is).\n\nOp\xE7\xF5es:\n --title <texto> t\xEDtulo do item (obrigat\xF3rio, at\xE9 200 caracteres)\n --body <texto> detalhes em texto simples (at\xE9 8 KB)\n --link <url> link http(s) que o item abre\n --key <chave> a mesma chave atualiza o item em vez de duplicar (e o reabre se j\xE1 estava resolvido)\n --source <nome> quem est\xE1 deixando o item (aparece quando n\xE3o \xE9 um agente)\n\nExemplo:\n busybits post --title "ROO7-1234 rejeitado no QA" --link https://example.com/ROO7-1234 --key ROO7-1234': 'Uso: busybits post --title <texto> [opciones]\n\nDeja un elemento en el escritorio de tu oficina (el panel "Escritorio" se abre al hacer clic en la pila de papeles).\n\nOpciones:\n --title <texto> t\xEDtulo del elemento (obligatorio, hasta 200 caracteres)\n --body <texto> detalles en texto simple (hasta 8 KB)\n --link <url> enlace http(s) que abre el elemento\n --key <clave> la misma clave actualiza el elemento en lugar de duplicarlo (y lo reabre si ya estaba resuelto)\n --source <nombre> qui\xE9n deja el elemento (se muestra cuando no es un agente)\n\nEjemplo:\n busybits post --title "ROO7-1234 rechazado en QA" --link https://example.com/ROO7-1234 --key ROO7-1234',
7410
+ "falta --title": "falta --title",
7411
+ "N\xE3o consegui falar com o Busybits na porta {0}. Ele est\xE1 rodando? (busybits start; outra porta: HABBLAUD_PORT)": "No pude hablar con Busybits en el puerto {0}. \xBFEst\xE1 en marcha? (busybits start; otro puerto: HABBLAUD_PORT)",
7412
+ "O Busybits recusou o item ({0}): {1}": "Busybits rechaz\xF3 el elemento ({0}): {1}",
7413
+ "Item reaberto na mesa: {0}": "Elemento reabierto en el escritorio: {0}",
7414
+ "Item atualizado na mesa: {0}": "Elemento actualizado en el escritorio: {0}",
7415
+ "Item deixado na mesa: {0}": "Elemento dejado en el escritorio: {0}",
7416
+ "A mesa s\xF3 funciona com o escrit\xF3rio ao vivo.": "El escritorio solo funciona con la oficina en vivo.",
7417
+ "N\xE3o foi poss\xEDvel resolver o item (erro {0}).": "No se pudo resolver el elemento (error {0}).",
7418
+ "um agente": "un agente",
7419
+ "um script": "un script",
7420
+ "resolvido {0}": "resuelto {0}",
7421
+ "de {0}": "de {0}",
7422
+ "Resolver": "Resolver",
7423
+ "Nada por aqui.": "Nada por aqu\xED.",
7424
+ "Sua mesa est\xE1 limpa: nada esperando.": "Tu escritorio est\xE1 despejado: nada esperando.",
7425
+ "Ocultar resolvidos": "Ocultar resueltos",
7426
+ "Mostrar resolvidos ({0})": "Mostrar resueltos ({0})",
7427
+ "Itens deixados na sua mesa. Clique para abrir.": "Elementos dejados en tu escritorio. Haz clic para abrir.",
7428
+ "na mesa": "en el escritorio",
7429
+ "Na sua mesa": "En tu escritorio",
7430
+ "Mensageiro": "Mensajero"
7353
7431
  };
7354
7432
 
7355
7433
  // shared/locales/fr.ts
@@ -11003,7 +11081,7 @@ var FR = {
11003
11081
  "Estilo padr\xE3o salvo para novos agentes.": "Style par d\xE9faut enregistr\xE9 pour les nouveaux agents.",
11004
11082
  "Estilo padr\xE3o restaurado para aleat\xF3rio.": "Style par d\xE9faut restaur\xE9 \xE0 al\xE9atoire.",
11005
11083
  "N\xE3o foi poss\xEDvel salvar o estilo padr\xE3o (erro {0}).": "Impossible d'enregistrer le style par d\xE9faut (erreur {0}).",
11006
- 'Uso: busybits <comando> [op\xE7\xF5es]\n\nComandos:\n setup instala ou atualiza as extens\xF5es e servi\xE7os do Busybits\n start inicia o servidor em primeiro plano\n status mostra o estado da instala\xE7\xE3o e dos servi\xE7os\n update atualiza o Busybits para a vers\xE3o mais recente\n uninstall remove extens\xF5es e servi\xE7os instalados\n pair emparelha esta m\xE1quina como sat\xE9lite de um Busybits central\n\nOp\xE7\xF5es de setup:\n --service instala e inicia o servi\xE7o de usu\xE1rio (systemd/launchd)\n --port <n> porta do servidor\n --no-claude n\xE3o mexe no Claude Code\n --no-pi n\xE3o mexe no Pi\n --no-codex n\xE3o mexe nos hooks do Codex\n --dry-run s\xF3 mostra o que seria feito\n --after-update usado por "busybits update": reinicia o servi\xE7o mesmo sem mudan\xE7a na unidade\n --rebuild refaz o build (instala\xE7\xE3o a partir de um clone)\n --ignore-node ignora a verifica\xE7\xE3o da vers\xE3o do Node\n\nOp\xE7\xF5es de update:\n --check s\xF3 mostra a vers\xE3o atual e a mais recente\n --rollback volta para a vers\xE3o anterior\n --to <vers\xE3o> atualiza para essa vers\xE3o em vez da mais recente\n --global atualiza tamb\xE9m o busybits global (npm i -g)\n\nOp\xE7\xF5es de uninstall:\n --purge apaga tamb\xE9m os dados do Busybits\n --dry-run s\xF3 mostra o que seria feito\n\nOp\xE7\xF5es de pair:\n --pairing <texto> texto de pareamento da central (padr\xE3o: entrada padr\xE3o)\n --label <nome> como esta m\xE1quina aparece no escrit\xF3rio\n --codex-wait instala os hooks do Codex com espera pela sua resposta\n\nOp\xE7\xF5es globais:\n --help, -h mostra esta ajuda\n --version, -v mostra a vers\xE3o instalada': "Utilisation\xA0: busybits <commande> [options]\n\nCommandes\xA0:\n setup installe ou met \xE0 jour les extensions et services Busybits\n start d\xE9marre le serveur au premier plan\n status affiche l'\xE9tat de l'installation et des services\n update met \xE0 jour Busybits vers la derni\xE8re version\n uninstall supprime les extensions et services install\xE9s\n pair associe cette machine comme satellite d'un Busybits central\n\nOptions de setup :\n --service installe et d\xE9marre le service utilisateur (systemd/launchd)\n --port <n> port du serveur\n --no-claude ne touche pas \xE0 Claude Code\n --no-pi ne touche pas \xE0 Pi\n --no-codex ne touche pas aux hooks Codex\n --dry-run montre seulement ce qui serait fait\n --after-update utilis\xE9 par \xAB busybits update \xBB : red\xE9marre le service m\xEAme si l'unit\xE9 n'a pas chang\xE9\n --rebuild recompile (installation depuis un clone)\n --ignore-node ignore la v\xE9rification de la version de Node\n\nOptions de update :\n --check affiche seulement la version actuelle et la derni\xE8re\n --rollback revient \xE0 la version pr\xE9c\xE9dente\n --to <version> met \xE0 jour vers cette version au lieu de la derni\xE8re\n --global met aussi \xE0 jour le busybits global (npm i -g)\n\nOptions de uninstall :\n --purge supprime aussi les donn\xE9es de Busybits\n --dry-run montre seulement ce qui serait fait\n\nOptions de pair :\n --pairing <texte> texte d'appairage de la centrale (par d\xE9faut : entr\xE9e standard)\n --label <nom> comment cette machine appara\xEEt dans le bureau\n --codex-wait installe les hooks Codex et attend votre r\xE9ponse\n\nOptions globales\xA0:\n --help, -h affiche cette aide\n --version, -v affiche la version install\xE9e",
11084
+ 'Uso: busybits <comando> [op\xE7\xF5es]\n\nComandos:\n setup instala ou atualiza as extens\xF5es e servi\xE7os do Busybits\n start inicia o servidor em primeiro plano\n status mostra o estado da instala\xE7\xE3o e dos servi\xE7os\n update atualiza o Busybits para a vers\xE3o mais recente\n uninstall remove extens\xF5es e servi\xE7os instalados\n pair emparelha esta m\xE1quina como sat\xE9lite de um Busybits central\n post deixa um item na mesa do seu escrit\xF3rio (a caixa de entrada)\n\nOp\xE7\xF5es de setup:\n --service instala e inicia o servi\xE7o de usu\xE1rio (systemd/launchd)\n --port <n> porta do servidor\n --no-claude n\xE3o mexe no Claude Code\n --no-pi n\xE3o mexe no Pi\n --no-codex n\xE3o mexe nos hooks do Codex\n --dry-run s\xF3 mostra o que seria feito\n --after-update usado por "busybits update": reinicia o servi\xE7o mesmo sem mudan\xE7a na unidade\n --rebuild refaz o build (instala\xE7\xE3o a partir de um clone)\n --ignore-node ignora a verifica\xE7\xE3o da vers\xE3o do Node\n\nOp\xE7\xF5es de update:\n --check s\xF3 mostra a vers\xE3o atual e a mais recente\n --rollback volta para a vers\xE3o anterior\n --to <vers\xE3o> atualiza para essa vers\xE3o em vez da mais recente\n --global atualiza tamb\xE9m o busybits global (npm i -g)\n\nOp\xE7\xF5es de uninstall:\n --purge apaga tamb\xE9m os dados do Busybits\n --dry-run s\xF3 mostra o que seria feito\n\nOp\xE7\xF5es de pair:\n --pairing <texto> texto de pareamento da central (padr\xE3o: entrada padr\xE3o)\n --label <nome> como esta m\xE1quina aparece no escrit\xF3rio\n --codex-wait instala os hooks do Codex com espera pela sua resposta\n\nOp\xE7\xF5es de post:\n --title <texto> t\xEDtulo do item (obrigat\xF3rio)\n --body <texto> detalhes em texto simples\n --link <url> link http(s) que o item abre\n --key <chave> a mesma chave atualiza o item (e o reabre se estava resolvido)\n --source <nome> quem est\xE1 deixando o item (aparece quando n\xE3o \xE9 um agente)\n\nOp\xE7\xF5es globais:\n --help, -h mostra esta ajuda\n --version, -v mostra a vers\xE3o instalada': "Utilisation\xA0: busybits <commande> [options]\n\nCommandes\xA0:\n setup installe ou met \xE0 jour les extensions et services Busybits\n start d\xE9marre le serveur au premier plan\n status affiche l'\xE9tat de l'installation et des services\n update met \xE0 jour Busybits vers la derni\xE8re version\n uninstall supprime les extensions et services install\xE9s\n pair associe cette machine comme satellite d'un Busybits central\n post d\xE9pose un \xE9l\xE9ment sur le bureau de votre bureau (la bo\xEEte de r\xE9ception)\n\nOptions de setup :\n --service installe et d\xE9marre le service utilisateur (systemd/launchd)\n --port <n> port du serveur\n --no-claude ne touche pas \xE0 Claude Code\n --no-pi ne touche pas \xE0 Pi\n --no-codex ne touche pas aux hooks Codex\n --dry-run montre seulement ce qui serait fait\n --after-update utilis\xE9 par \xAB busybits update \xBB : red\xE9marre le service m\xEAme si l'unit\xE9 n'a pas chang\xE9\n --rebuild recompile (installation depuis un clone)\n --ignore-node ignore la v\xE9rification de la version de Node\n\nOptions de update :\n --check affiche seulement la version actuelle et la derni\xE8re\n --rollback revient \xE0 la version pr\xE9c\xE9dente\n --to <version> met \xE0 jour vers cette version au lieu de la derni\xE8re\n --global met aussi \xE0 jour le busybits global (npm i -g)\n\nOptions de uninstall :\n --purge supprime aussi les donn\xE9es de Busybits\n --dry-run montre seulement ce qui serait fait\n\nOptions de pair :\n --pairing <texte> texte d'appairage de la centrale (par d\xE9faut : entr\xE9e standard)\n --label <nom> comment cette machine appara\xEEt dans le bureau\n --codex-wait installe les hooks Codex et attend votre r\xE9ponse\n\nOptions de post :\n --title <texte> titre de l'\xE9l\xE9ment (obligatoire)\n --body <texte> d\xE9tails en texte simple\n --link <url> lien http(s) que l'\xE9l\xE9ment ouvre\n --key <cl\xE9> la m\xEAme cl\xE9 met \xE0 jour l'\xE9l\xE9ment (et le rouvre s'il \xE9tait r\xE9solu)\n --source <nom> qui d\xE9pose l'\xE9l\xE9ment (affich\xE9 quand ce n'est pas un agent)\n\nOptions globales\xA0:\n --help, -h affiche cette aide\n --version, -v affiche la version install\xE9e",
11007
11085
  "No Windows, use scripts/windows/install-satellite.ps1 a partir de um clone (o busybits ainda n\xE3o instala servi\xE7o no Windows).": "Sous Windows, utilisez scripts/windows/install-satellite.ps1 depuis un clone (busybits n'installe pas encore de service sous Windows).",
11008
11086
  "comando desconhecido: {0}": "commande inconnue\xA0: {0}",
11009
11087
  "{0} precisa de um valor": "{0} n\xE9cessite une valeur",
@@ -11027,7 +11105,58 @@ var FR = {
11027
11105
  "Voltei para a v{0}.": "Retour \xE0 la v{0}.",
11028
11106
  "a vers\xE3o {0} n\xE3o tem um payload completo em {1}": "la version {0} n'a pas de payload complet dans {1}",
11029
11107
  "O Busybits precisa do Node 22.12+ ou 24, e nenhum foi encontrado. Instale um (por exemplo com o nvm: nvm install 24) e rode de novo.": "Busybits a besoin de Node 22.12+ ou 24, et aucun n'a \xE9t\xE9 trouv\xE9. Installez-en un (par exemple avec nvm : nvm install 24) et relancez.",
11030
- "servi\xE7o antigo {0} removido": "ancien service {0} supprim\xE9"
11108
+ "servi\xE7o antigo {0} removido": "ancien service {0} supprim\xE9",
11109
+ "os itens da mesa s\xF3 s\xE3o resolvidos pelo pr\xF3prio computador (http://localhost ou http://127.0.0.1)": "les \xE9l\xE9ments du bureau ne se r\xE9solvent que depuis l'ordinateur lui-m\xEAme (http://localhost ou http://127.0.0.1)",
11110
+ "s\xF3 o pr\xF3prio computador deixa itens na mesa (http://localhost ou http://127.0.0.1)": "seul l'ordinateur lui-m\xEAme d\xE9pose des \xE9l\xE9ments sur le bureau (http://localhost ou http://127.0.0.1)",
11111
+ "a mesa s\xF3 vale pelo pr\xF3prio computador ou pelo acesso remoto com login": "le bureau ne fonctionne que depuis l'ordinateur lui-m\xEAme ou par l'acc\xE8s \xE0 distance avec connexion",
11112
+ "a mesa j\xE1 tem {0} itens abertos: resolva alguns antes de deixar outros": "le bureau a d\xE9j\xE0 {0} \xE9l\xE9ments ouverts : r\xE9solvez-en avant d'en d\xE9poser d'autres",
11113
+ "item n\xE3o encontrado": "\xE9l\xE9ment introuvable",
11114
+ "inbox.json ileg\xEDvel ({0}); come\xE7ando sem itens.": "inbox.json illisible ({0}) ; d\xE9marrage sans \xE9l\xE9ments.",
11115
+ "corpo inv\xE1lido": "corps invalide",
11116
+ "t\xEDtulo obrigat\xF3rio": "titre obligatoire",
11117
+ "t\xEDtulo longo demais (m\xE1x. {0} caracteres)": "titre trop long (max {0} caract\xE8res)",
11118
+ "texto inv\xE1lido": "texte invalide",
11119
+ "texto longo demais (m\xE1x. {0} KB)": "texte trop long (max {0} Ko)",
11120
+ "link inv\xE1lido": "lien invalide",
11121
+ "o link precisa ser http ou https": "le lien doit \xEAtre http ou https",
11122
+ "chave inv\xE1lida": "cl\xE9 invalide",
11123
+ "chave longa demais (m\xE1x. {0} caracteres)": "cl\xE9 trop longue (max {0} caract\xE8res)",
11124
+ "origem inv\xE1lida": "source invalide",
11125
+ "ancestrais inv\xE1lidos": "anc\xEAtres invalides",
11126
+ 'Uso: busybits post --title <texto> [op\xE7\xF5es]\n\nDeixa um item na mesa do seu escrit\xF3rio (o painel "Mesa" abre ao clicar no monte de pap\xE9is).\n\nOp\xE7\xF5es:\n --title <texto> t\xEDtulo do item (obrigat\xF3rio, at\xE9 200 caracteres)\n --body <texto> detalhes em texto simples (at\xE9 8 KB)\n --link <url> link http(s) que o item abre\n --key <chave> a mesma chave atualiza o item em vez de duplicar (e o reabre se j\xE1 estava resolvido)\n --source <nome> quem est\xE1 deixando o item (aparece quando n\xE3o \xE9 um agente)\n\nExemplo:\n busybits post --title "ROO7-1234 rejeitado no QA" --link https://example.com/ROO7-1234 --key ROO7-1234': `Utilisation : busybits post --title <texte> [options]
11127
+
11128
+ D\xE9pose un \xE9l\xE9ment sur le bureau de votre bureau (le panneau \xAB Bureau \xBB s'ouvre en cliquant sur la pile de papiers).
11129
+
11130
+ Options :
11131
+ --title <texte> titre de l'\xE9l\xE9ment (obligatoire, jusqu'\xE0 200 caract\xE8res)
11132
+ --body <texte> d\xE9tails en texte simple (jusqu'\xE0 8 Ko)
11133
+ --link <url> lien http(s) que l'\xE9l\xE9ment ouvre
11134
+ --key <cl\xE9> la m\xEAme cl\xE9 met \xE0 jour l'\xE9l\xE9ment au lieu de le dupliquer (et le rouvre s'il \xE9tait d\xE9j\xE0 r\xE9solu)
11135
+ --source <nom> qui d\xE9pose l'\xE9l\xE9ment (affich\xE9 quand ce n'est pas un agent)
11136
+
11137
+ Exemple :
11138
+ busybits post --title "ROO7-1234 rejet\xE9 en QA" --link https://example.com/ROO7-1234 --key ROO7-1234`,
11139
+ "falta --title": "--title manquant",
11140
+ "N\xE3o consegui falar com o Busybits na porta {0}. Ele est\xE1 rodando? (busybits start; outra porta: HABBLAUD_PORT)": "Impossible de joindre Busybits sur le port {0}. Est-il lanc\xE9 ? (busybits start ; autre port : HABBLAUD_PORT)",
11141
+ "O Busybits recusou o item ({0}): {1}": "Busybits a refus\xE9 l'\xE9l\xE9ment ({0}) : {1}",
11142
+ "Item reaberto na mesa: {0}": "\xC9l\xE9ment rouvert sur le bureau : {0}",
11143
+ "Item atualizado na mesa: {0}": "\xC9l\xE9ment mis \xE0 jour sur le bureau : {0}",
11144
+ "Item deixado na mesa: {0}": "\xC9l\xE9ment d\xE9pos\xE9 sur le bureau : {0}",
11145
+ "A mesa s\xF3 funciona com o escrit\xF3rio ao vivo.": "Le bureau ne fonctionne qu'avec le bureau en direct.",
11146
+ "N\xE3o foi poss\xEDvel resolver o item (erro {0}).": "Impossible de r\xE9soudre l'\xE9l\xE9ment (erreur {0}).",
11147
+ "um agente": "un agent",
11148
+ "um script": "un script",
11149
+ "resolvido {0}": "r\xE9solu {0}",
11150
+ "de {0}": "de {0}",
11151
+ "Resolver": "R\xE9soudre",
11152
+ "Nada por aqui.": "Rien ici.",
11153
+ "Sua mesa est\xE1 limpa: nada esperando.": "Votre bureau est d\xE9gag\xE9 : rien en attente.",
11154
+ "Ocultar resolvidos": "Masquer les r\xE9solus",
11155
+ "Mostrar resolvidos ({0})": "Afficher les r\xE9solus ({0})",
11156
+ "Itens deixados na sua mesa. Clique para abrir.": "\xC9l\xE9ments laiss\xE9s sur votre bureau. Cliquez pour ouvrir.",
11157
+ "na mesa": "sur le bureau",
11158
+ "Na sua mesa": "Sur votre bureau",
11159
+ "Mensageiro": "Coursier"
11031
11160
  };
11032
11161
 
11033
11162
  // shared/locales/all.ts
@@ -11219,10 +11348,10 @@ var ALIAS_TOOLS = {
11219
11348
  dir: /\bCODEX_HOME=(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))/
11220
11349
  }
11221
11350
  };
11222
- function parseToolAliases(text2, home, tool) {
11351
+ function parseToolAliases(text3, home, tool) {
11223
11352
  const { invokes, dir: dirRe } = ALIAS_TOOLS[tool];
11224
11353
  const out = [];
11225
- for (const line2 of text2.split(/\r?\n/)) {
11354
+ for (const line2 of text3.split(/\r?\n/)) {
11226
11355
  const m = ALIAS_RE.exec(line2);
11227
11356
  if (!m) continue;
11228
11357
  const body2 = m[2] ?? m[3]?.replace(/\\(.)/g, "$1") ?? "";
@@ -12067,12 +12196,12 @@ function readBody(req, max = 8 * 1024) {
12067
12196
  });
12068
12197
  }
12069
12198
  var CA_PATH = "/remote/ca.crt";
12070
- function esc(text2) {
12071
- return text2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
12199
+ function esc(text3) {
12200
+ return text3.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
12072
12201
  }
12073
12202
  function loginPage(opts) {
12074
12203
  const ca = opts.caDownload ? `<p class="ca">${esc(tr("Primeira vez neste celular?"))} <a href="${CA_PATH}" download="habblaud-ca.crt">${esc(tr("Instale o certificado do Habblaud"))}</a> ${esc(tr("para tirar o aviso de seguran\xE7a (confira a impress\xE3o digital que o npm run remote:setup mostrou)."))}</p>` : "";
12075
- const js = (text2) => JSON.stringify(text2).replace(/</g, "\\u003c");
12204
+ const js = (text3) => JSON.stringify(text3).replace(/</g, "\\u003c");
12076
12205
  return `<!doctype html>
12077
12206
  <html lang="${getLocale()}">
12078
12207
  <head>
@@ -12432,6 +12561,11 @@ function namespaceDelivery(machine, d) {
12432
12561
  function namespaceDetail(machine, d) {
12433
12562
  return { ...d, agent: namespaceAgent(machine, d.agent) };
12434
12563
  }
12564
+ function namespaceInboxItem(machine, i) {
12565
+ const out = { ...i, id: pre(machine, i.id), machine };
12566
+ if (i.from.kind === "agent") out.from = { kind: "agent", agentId: pre(machine, i.from.agentId) };
12567
+ return out;
12568
+ }
12435
12569
  function namespaceState(machine, s2) {
12436
12570
  const online = machine.state === "online";
12437
12571
  const id = machine.id;
@@ -12607,9 +12741,9 @@ function userEnvFile(env = process.env, home = env.HOME || homedir3()) {
12607
12741
  if (explicit) return resolve3(explicit.replace(/^~(?=\/|$)/, home));
12608
12742
  return join4(env.XDG_CONFIG_HOME?.trim() || join4(home, ".config"), "habblaud", "env");
12609
12743
  }
12610
- function parseEnvFile(text2) {
12744
+ function parseEnvFile(text3) {
12611
12745
  const out = {};
12612
- for (const raw of text2.split(/\r?\n/)) {
12746
+ for (const raw of text3.split(/\r?\n/)) {
12613
12747
  const line2 = raw.trim().replace(/^export\s+/, "");
12614
12748
  if (!line2 || line2.startsWith("#")) continue;
12615
12749
  const eq = line2.indexOf("=");
@@ -12624,14 +12758,14 @@ function parseEnvFile(text2) {
12624
12758
  }
12625
12759
  function applyUserEnvFile(env = process.env, home = env.HOME || homedir3()) {
12626
12760
  const file = userEnvFile(env, home);
12627
- let text2;
12761
+ let text3;
12628
12762
  try {
12629
- text2 = readFileSync4(file, "utf8");
12763
+ text3 = readFileSync4(file, "utf8");
12630
12764
  } catch {
12631
12765
  return void 0;
12632
12766
  }
12633
12767
  const keys = [];
12634
- for (const [k, v] of Object.entries(parseEnvFile(text2))) {
12768
+ for (const [k, v] of Object.entries(parseEnvFile(text3))) {
12635
12769
  if (env[k] !== void 0) continue;
12636
12770
  env[k] = v;
12637
12771
  keys.push(k);
@@ -12851,11 +12985,11 @@ function domainOf(url) {
12851
12985
  function str3(v) {
12852
12986
  return typeof v === "string" ? v : "";
12853
12987
  }
12854
- function make(kind, icon, text2, detail) {
12988
+ function make(kind, icon, text3, detail) {
12855
12989
  return {
12856
12990
  kind,
12857
12991
  icon,
12858
- text: truncate(maskSecrets(text2.slice(0, MAX_TEXT * 8)), MAX_TEXT),
12992
+ text: truncate(maskSecrets(text3.slice(0, MAX_TEXT * 8)), MAX_TEXT),
12859
12993
  ...detail ? { detail: truncate(maskSecrets(detail.slice(0, MAX_DETAIL * 4)), MAX_DETAIL) } : {}
12860
12994
  };
12861
12995
  }
@@ -13245,9 +13379,9 @@ function describeWords(w, depth) {
13245
13379
  if (!w.length) return void 0;
13246
13380
  const prog = basename3(w[0]);
13247
13381
  const args = w.slice(1);
13248
- const text2 = w.join(" ");
13382
+ const text3 = w.join(" ");
13249
13383
  const mk = (kind, icon, t) => make(kind, icon, t);
13250
- if (/\b(vitest|jest|pytest|phpunit|mocha|ava|rspec)\b|\b(go|cargo|deno|bun)\s+test\b|playwright\s+test|\b(npm|pnpm|yarn|bun)\s+(run\s+)?test\b|\bnode\s+--test\b|-m\s+(pytest|unittest)\b/.test(text2)) {
13384
+ if (/\b(vitest|jest|pytest|phpunit|mocha|ava|rspec)\b|\b(go|cargo|deno|bun)\s+test\b|playwright\s+test|\b(npm|pnpm|yarn|bun)\s+(run\s+)?test\b|\bnode\s+--test\b|-m\s+(pytest|unittest)\b/.test(text3)) {
13251
13385
  return mk("test", "\u{1F9EA}", tr("Rodando testes"));
13252
13386
  }
13253
13387
  if (prog === "git") {
@@ -13258,19 +13392,19 @@ function describeWords(w, depth) {
13258
13392
  return mk("git", icon, t);
13259
13393
  }
13260
13394
  if (prog === "gh") return mk("git", "\u{1F419}", tr("GitHub CLI: gh {0}", [args.slice(0, 2).join(" ")]).trim());
13261
- if (/\b(npm|pnpm|yarn|bun)\s+(i|install|add|ci)\b|\bpip3?\s+install\b|\bbrew\s+install\b|\bcomposer\s+(install|require)\b|\bpoetry\s+(add|install)\b|\bcargo\s+add\b|\bgo\s+get\b|\buv\s+(add|sync|pip\s+install)\b/.test(text2)) {
13395
+ if (/\b(npm|pnpm|yarn|bun)\s+(i|install|add|ci)\b|\bpip3?\s+install\b|\bbrew\s+install\b|\bcomposer\s+(install|require)\b|\bpoetry\s+(add|install)\b|\bcargo\s+add\b|\bgo\s+get\b|\buv\s+(add|sync|pip\s+install)\b/.test(text3)) {
13262
13396
  return mk("run", "\u{1F4E6}", tr("Instalando depend\xEAncias"));
13263
13397
  }
13264
- if (prog === "tsc" && args.includes("--noEmit") || /\b(npm|pnpm|yarn|bun)\s+(run\s+)?(typecheck|type-check|check-types)\b/.test(text2)) {
13398
+ if (prog === "tsc" && args.includes("--noEmit") || /\b(npm|pnpm|yarn|bun)\s+(run\s+)?(typecheck|type-check|check-types)\b/.test(text3)) {
13265
13399
  return mk("run", "\u{1F50D}", tr("Conferindo os tipos (TypeScript)"));
13266
13400
  }
13267
- if (/\b(npm|pnpm|yarn|bun)\s+(run\s+)?build\b|\bvite\s+build\b|^tsc\b|\bwebpack\b|\bcargo\s+build\b|\bgo\s+build\b|^make\b|\bgradle\b|\bmvn\b|\besbuild\b|\brollup\b/.test(text2)) {
13401
+ if (/\b(npm|pnpm|yarn|bun)\s+(run\s+)?build\b|\bvite\s+build\b|^tsc\b|\bwebpack\b|\bcargo\s+build\b|\bgo\s+build\b|^make\b|\bgradle\b|\bmvn\b|\besbuild\b|\brollup\b/.test(text3)) {
13268
13402
  return mk("run", "\u{1F3D7}\uFE0F", tr("Compilando o projeto"));
13269
13403
  }
13270
- if (/\b(npm|pnpm|yarn|bun)\s+(run\s+)?(dev|start|serve|preview)\b|^vite(\s|$)(?!build)|^(next|nuxt|astro)\s+dev\b|^expo\s+start\b|^nodemon\b|^tsx\s+watch\b/.test(text2)) {
13271
- return mk("run", "\u25B6\uFE0F", /\bpreview\b/.test(text2) ? tr("Subindo o preview do build") : tr("Subindo o servidor de dev"));
13404
+ if (/\b(npm|pnpm|yarn|bun)\s+(run\s+)?(dev|start|serve|preview)\b|^vite(\s|$)(?!build)|^(next|nuxt|astro)\s+dev\b|^expo\s+start\b|^nodemon\b|^tsx\s+watch\b/.test(text3)) {
13405
+ return mk("run", "\u25B6\uFE0F", /\bpreview\b/.test(text3) ? tr("Subindo o preview do build") : tr("Subindo o servidor de dev"));
13272
13406
  }
13273
- if (/\b(eslint|prettier|ruff|black|biome|rubocop|phpcs|stylelint|oxlint)\b|\b(npm|pnpm|yarn)\s+(run\s+)?(lint|format)\b/.test(text2)) {
13407
+ if (/\b(eslint|prettier|ruff|black|biome|rubocop|phpcs|stylelint|oxlint)\b|\b(npm|pnpm|yarn)\s+(run\s+)?(lint|format)\b/.test(text3)) {
13274
13408
  return mk("run", "\u{1F9F9}", tr("Rodando o linter"));
13275
13409
  }
13276
13410
  if (/^(npm|pnpm|yarn|bun)$/.test(prog) && args[0] === "run" && args[1]) return mk("run", "\u25B6\uFE0F", tr("Rodando o script {0}", [args[1]]));
@@ -13343,8 +13477,8 @@ function describeWords(w, depth) {
13343
13477
  if (/^(\.{0,2}\/|~\/)/.test(w[0]) || /\.(sh|bash|zsh|py|rb|mjs|js|ts)$/.test(w[0])) return mk("run", "\u25B6\uFE0F", tr("Executando {0}", [prog]));
13344
13478
  return void 0;
13345
13479
  }
13346
- function describeLine(text2, depth) {
13347
- const lines = text2.replace(/\\\r?\n/g, " ").split(/\r?\n/);
13480
+ function describeLine(text3, depth) {
13481
+ const lines = text3.replace(/\\\r?\n/g, " ").split(/\r?\n/);
13348
13482
  for (let li = 0; li < lines.length; li++) {
13349
13483
  const line2 = lines[li].trim();
13350
13484
  if (!line2 || line2.startsWith("#")) continue;
@@ -13393,8 +13527,8 @@ function describeCommand(command, description) {
13393
13527
  const desc = description?.trim();
13394
13528
  if (desc && looksPortuguese(desc)) return make("run", "\u{1F4BB}", desc, detail);
13395
13529
  const prog = basename3(found.prog ?? "");
13396
- const text2 = /^[A-Za-z][\w.+-]{0,23}$/.test(prog) ? tr("Rodando {0}", [prog]) : tr("Rodando um comando no terminal");
13397
- return make("run", "\u{1F4BB}", text2, desc ? `${desc} \u2014 ${detail}` : detail);
13530
+ const text3 = /^[A-Za-z][\w.+-]{0,23}$/.test(prog) ? tr("Rodando {0}", [prog]) : tr("Rodando um comando no terminal");
13531
+ return make("run", "\u{1F4BB}", text3, desc ? `${desc} \u2014 ${detail}` : detail);
13398
13532
  }
13399
13533
  function humanize(id) {
13400
13534
  return id.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").trim().toLowerCase();
@@ -13530,8 +13664,8 @@ function describeTool(name, rawInput) {
13530
13664
  return make("other", "\u{1F6E0}\uFE0F", tr("Usando {0}", [name]));
13531
13665
  }
13532
13666
  }
13533
- function describePrompt(text2) {
13534
- return make("prompt", "\u{1F4E8}", tr("Nova tarefa: \u201C{0}\u201D", [truncate(text2, 30)]), text2);
13667
+ function describePrompt(text3) {
13668
+ return make("prompt", "\u{1F4E8}", tr("Nova tarefa: \u201C{0}\u201D", [truncate(text3, 30)]), text3);
13535
13669
  }
13536
13670
  function formatDuration(ms) {
13537
13671
  const s2 = Math.round(ms / 1e3);
@@ -13563,7 +13697,7 @@ function fitLabel(prefix, label, suffix = "") {
13563
13697
  }
13564
13698
  var SPECIAL = {
13565
13699
  think: () => make("think", "\u{1F4AD}", tr("Pensando\u2026")),
13566
- respond: (text2) => make("respond", "\u{1F4AC}", tr("Escrevendo a resposta"), text2),
13700
+ respond: (text3) => make("respond", "\u{1F4AC}", tr("Escrevendo a resposta"), text3),
13567
13701
  turnDone: (ms) => make("done", "\u2705", ms ? tr("Concluiu em {0}", [formatDuration(ms)]) : tr("Concluiu")),
13568
13702
  error: (tool, detail) => make("error", "\u26A0\uFE0F", tool ? tr("Erro em {0}", [tool]) : tr("Algo deu errado"), detail),
13569
13703
  interrupted: () => make("wait", "\u270B", tr("Interrompido por voc\xEA")),
@@ -13669,9 +13803,9 @@ function readSubagentMeta(metaPath) {
13669
13803
  }
13670
13804
  }
13671
13805
  var JOURNAL_DONE = /^(completed?|finished|done|failed|errored|error|killed|cancell?ed|stopped|succeeded|result)$/i;
13672
- function parseJournal(text2) {
13806
+ function parseJournal(text3) {
13673
13807
  const out = /* @__PURE__ */ new Map();
13674
- for (const line2 of text2.split("\n")) {
13808
+ for (const line2 of text3.split("\n")) {
13675
13809
  if (!line2.trim()) continue;
13676
13810
  let j;
13677
13811
  try {
@@ -13974,8 +14108,8 @@ function scriptSegments(command) {
13974
14108
  let q = null;
13975
14109
  let depth = 0;
13976
14110
  const cut3 = (end, next) => {
13977
- const text2 = src.slice(start, end).trim();
13978
- if (text2) segs.push({ words: shellWords(text2), next });
14111
+ const text3 = src.slice(start, end).trim();
14112
+ if (text3) segs.push({ words: shellWords(text3), next });
13979
14113
  else if (segs.length && next) segs[segs.length - 1].next = next;
13980
14114
  };
13981
14115
  for (let i = 0; i < src.length; i++) {
@@ -14188,8 +14322,8 @@ function ciFromJson(j) {
14188
14322
  }
14189
14323
  return void 0;
14190
14324
  }
14191
- function parseJson(text2) {
14192
- const t = text2.trim();
14325
+ function parseJson(text3) {
14326
+ const t = text3.trim();
14193
14327
  if (!t || t[0] !== "{" && t[0] !== "[" || t.length > 2e5) return void 0;
14194
14328
  try {
14195
14329
  return JSON.parse(t);
@@ -14197,10 +14331,10 @@ function parseJson(text2) {
14197
14331
  return void 0;
14198
14332
  }
14199
14333
  }
14200
- function ciFromText(text2, ops) {
14334
+ function ciFromText(text3, ops) {
14201
14335
  const run3 = ops.includes("run_watch") || ops.includes("run_view");
14202
14336
  if (run3) {
14203
- const h = RUN_HEADER.exec(text2);
14337
+ const h = RUN_HEADER.exec(text3);
14204
14338
  if (h?.[1] === "*") return "pending";
14205
14339
  if (h) {
14206
14340
  const r = { result: h[1] === "\u2713" || h[1] === "\u2714" ? "passed" : "failed", branch: h[2] };
@@ -14208,14 +14342,14 @@ function ciFromText(text2, ops) {
14208
14342
  if (wf) r.workflow = wf;
14209
14343
  return r;
14210
14344
  }
14211
- const d = RUN_DONE.exec(text2);
14345
+ const d = RUN_DONE.exec(text3);
14212
14346
  const c = d ? conclusion(d[2]) : void 0;
14213
14347
  if (d && c) return { result: c, workflow: d[1].slice(0, 40) };
14214
14348
  }
14215
- const whole = parseJson(text2);
14349
+ const whole = parseJson(text3);
14216
14350
  const fromWhole = whole === void 0 ? void 0 : ciFromJson(whole);
14217
14351
  if (fromWhole) return fromWhole;
14218
- const lines = text2.split("\n").map((l) => l.trim()).filter(Boolean);
14352
+ const lines = text3.split("\n").map((l) => l.trim()).filter(Boolean);
14219
14353
  if (run3) {
14220
14354
  for (const l of lines.slice(0, 20)) {
14221
14355
  const j = parseJson(l);
@@ -14228,16 +14362,16 @@ function ciFromText(text2, ops) {
14228
14362
  if (c && ops.includes("run_view")) return { result: c };
14229
14363
  }
14230
14364
  if (ops.includes("pr_checks")) {
14231
- if (/\bAll checks were successful\b/.test(text2)) return { result: "passed" };
14232
- if (/\bSome checks were not successful\b/.test(text2) || /\b[1-9]\d* failing\b/.test(text2)) return { result: "failed" };
14233
- if (/\bSome checks are still pending\b/.test(text2)) return "pending";
14365
+ if (/\bAll checks were successful\b/.test(text3)) return { result: "passed" };
14366
+ if (/\bSome checks were not successful\b/.test(text3) || /\b[1-9]\d* failing\b/.test(text3)) return { result: "failed" };
14367
+ if (/\bSome checks are still pending\b/.test(text3)) return "pending";
14234
14368
  const states = lines.map((l) => /^(.+?)\t(pass|fail|pending|skipping|cancel)\t/.exec(l)).filter((m) => !!m).map((m) => ({ name: m[1], state: m[2] }));
14235
14369
  return aggregateChecks(states);
14236
14370
  }
14237
14371
  return void 0;
14238
14372
  }
14239
- function exitCodeOf(text2) {
14240
- const m = /^Exit code (\d+)/.exec(text2.trimStart());
14373
+ function exitCodeOf(text3) {
14374
+ const m = /^Exit code (\d+)/.exec(text3.trimStart());
14241
14375
  return m ? Number(m[1]) : void 0;
14242
14376
  }
14243
14377
  function ciFromExit(call2, code2) {
@@ -14281,41 +14415,41 @@ function gitOperationEvent(call2, tur) {
14281
14415
  return void 0;
14282
14416
  }
14283
14417
  function detectGitHubResult(call2, r) {
14284
- let text2 = textOf(r.content);
14285
- if (!text2 && typeof r.tur.stdout === "string") text2 = `${r.tur.stdout}
14418
+ let text3 = textOf(r.content);
14419
+ if (!text3 && typeof r.tur.stdout === "string") text3 = `${r.tur.stdout}
14286
14420
  ${typeof r.tur.stderr === "string" ? r.tur.stderr : ""}`;
14287
- text2 = text2.slice(0, 2e5);
14421
+ text3 = text3.slice(0, 2e5);
14288
14422
  const ops = call2.ops;
14289
- if (call2.tool !== "Bash") return mcpEvent(call2, text2, r.isError, r.branch);
14423
+ if (call2.tool !== "Bash") return mcpEvent(call2, text3, r.isError, r.branch);
14290
14424
  if (!r.isError) {
14291
14425
  const fromOp = gitOperationEvent(call2, r.tur);
14292
14426
  if (fromOp) return fromOp;
14293
14427
  }
14294
- if (ops.includes("pr_merge") && !call2.auto && !r.isError && !MERGE_FAIL.test(text2)) {
14428
+ if (ops.includes("pr_merge") && !call2.auto && !r.isError && !MERGE_FAIL.test(text3)) {
14295
14429
  const ev = { kind: "pr_merged" };
14296
- const n2 = call2.number ?? num2(/\bpull request (?:[\w.-]+\/[\w.-]+)?#(\d+)/i.exec(text2)?.[1]);
14430
+ const n2 = call2.number ?? num2(/\bpull request (?:[\w.-]+\/[\w.-]+)?#(\d+)/i.exec(text3)?.[1]);
14297
14431
  if (n2 !== void 0) ev.number = n2;
14298
14432
  if (call2.repo) ev.repo = call2.repo;
14299
14433
  return ev;
14300
14434
  }
14301
- if (ops.includes("pr_create") && !r.isError && !PR_EXISTS.test(text2)) {
14302
- const urls = [...text2.matchAll(PR_URL)];
14435
+ if (ops.includes("pr_create") && !r.isError && !PR_EXISTS.test(text3)) {
14436
+ const urls = [...text3.matchAll(PR_URL)];
14303
14437
  const m = urls.at(-1);
14304
14438
  if (m) return { kind: "pr_opened", number: Number(m[2]), repo: m[1], url: m[0] };
14305
14439
  }
14306
14440
  if (ops.includes("release_create") && !call2.draft && !r.isError) {
14307
- const m = RELEASE_URL.exec(text2);
14441
+ const m = RELEASE_URL.exec(text3);
14308
14442
  if (m && !m[2].startsWith("untagged-")) return { kind: "release", tag: safeDecode(m[2]).slice(0, 60), repo: m[1], url: m[0] };
14309
14443
  }
14310
14444
  if (ops.some((o) => o === "run_watch" || o === "run_view" || o === "pr_checks")) {
14311
- const read = ciFromText(text2, ops);
14312
- const code2 = r.isError ? exitCodeOf(text2) : 0;
14445
+ const read = ciFromText(text3, ops);
14446
+ const code2 = r.isError ? exitCodeOf(text3) : 0;
14313
14447
  const ci = read === "pending" ? void 0 : read ?? (code2 !== void 0 ? ciFromExit(call2, code2) : void 0);
14314
14448
  if (ci) return ciEvent(call2, ci, r.branch);
14315
14449
  }
14316
- if (ops.includes("push") && !call2.noPush && !PUSH_FAIL.test(text2)) {
14317
- const to = PUSH_TO.exec(text2);
14318
- const m = to ? PUSH_OK.exec(text2.slice(to.index)) : null;
14450
+ if (ops.includes("push") && !call2.noPush && !PUSH_FAIL.test(text3)) {
14451
+ const to = PUSH_TO.exec(text3);
14452
+ const m = to ? PUSH_OK.exec(text3.slice(to.index)) : null;
14319
14453
  if (m) return { kind: "push", branch: m[1].replace(/^refs\/heads\//, "") };
14320
14454
  }
14321
14455
  return void 0;
@@ -14327,13 +14461,13 @@ function safeDecode(s2) {
14327
14461
  return s2;
14328
14462
  }
14329
14463
  }
14330
- function mcpEvent(call2, text2, isError, branch) {
14464
+ function mcpEvent(call2, text3, isError, branch) {
14331
14465
  if (isError) return void 0;
14332
14466
  const op = call2.ops[0];
14333
- const j = parseJson(text2);
14467
+ const j = parseJson(text3);
14334
14468
  const o = j && typeof j === "object" && !Array.isArray(j) ? j : void 0;
14335
14469
  if (op === "pr_create") {
14336
- const m = [...text2.matchAll(PR_URL)][0];
14470
+ const m = [...text3.matchAll(PR_URL)][0];
14337
14471
  const n2 = (m ? Number(m[2]) : void 0) ?? num2(o?.number);
14338
14472
  if (n2 === void 0) return void 0;
14339
14473
  const ev = { kind: "pr_opened", number: n2 };
@@ -14343,7 +14477,7 @@ function mcpEvent(call2, text2, isError, branch) {
14343
14477
  return ev;
14344
14478
  }
14345
14479
  if (op === "pr_merge") {
14346
- const merged = o ? o.merged === true : /\bmerged\b/i.test(text2) && !MERGE_FAIL.test(text2);
14480
+ const merged = o ? o.merged === true : /\bmerged\b/i.test(text3) && !MERGE_FAIL.test(text3);
14347
14481
  if (!merged) return void 0;
14348
14482
  const ev = { kind: "pr_merged" };
14349
14483
  if (call2.number !== void 0) ev.number = call2.number;
@@ -14723,8 +14857,8 @@ function firstLine(s2, max = 140) {
14723
14857
  const line2 = s2.split("\n").find((l) => l.trim());
14724
14858
  return line2 ? truncate(line2.replace(/<\/?[a-z_-]+>/gi, ""), max) : void 0;
14725
14859
  }
14726
- function parseTaskNotification(text2) {
14727
- const tag = (name) => new RegExp(`<${name}>([\\s\\S]*?)</${name}>`).exec(text2)?.[1]?.trim() || void 0;
14860
+ function parseTaskNotification(text3) {
14861
+ const tag = (name) => new RegExp(`<${name}>([\\s\\S]*?)</${name}>`).exec(text3)?.[1]?.trim() || void 0;
14728
14862
  return {
14729
14863
  taskId: tag("task-id") ?? tag("task_id"),
14730
14864
  toolUseId: tag("tool-use-id") ?? tag("tool_use_id"),
@@ -14944,8 +15078,8 @@ var LineParser = class {
14944
15078
  if (cur?.kind === "think" && (cur.msgId === msgId || this.at - cur.at < 3e4)) return;
14945
15079
  this.push(SPECIAL.think(), { suffix, msgId });
14946
15080
  } else if (b.type === "text") {
14947
- const text2 = str5(b.text);
14948
- if (text2) this.push(SPECIAL.respond(text2), { suffix, msgId });
15081
+ const text3 = str5(b.text);
15082
+ if (text3) this.push(SPECIAL.respond(text3), { suffix, msgId });
14949
15083
  } else if (b.type === "tool_use") {
14950
15084
  this.toolUse(b, suffix, msgId);
14951
15085
  }
@@ -15080,15 +15214,15 @@ var LineParser = class {
15080
15214
  this.push(SPECIAL.interrupted(), { suffix: ":int" });
15081
15215
  }
15082
15216
  userText(raw) {
15083
- const text2 = raw.trimStart();
15084
- if (!text2) return;
15085
- if (text2.includes("<task-notification>")) return this.notification(text2, true);
15086
- if (INTERRUPTED.test(text2)) return this.interrupted();
15087
- if (SYSTEM_TAG.test(text2) || text2.startsWith("Caveat:")) return;
15088
- let prompt = text2;
15089
- if (/^<command-(name|message|args)>/.test(text2)) {
15090
- const cmd = /<command-name>([\s\S]*?)<\/command-name>/.exec(text2)?.[1]?.trim();
15091
- const args = /<command-args>([\s\S]*?)<\/command-args>/.exec(text2)?.[1]?.trim() ?? "";
15217
+ const text3 = raw.trimStart();
15218
+ if (!text3) return;
15219
+ if (text3.includes("<task-notification>")) return this.notification(text3, true);
15220
+ if (INTERRUPTED.test(text3)) return this.interrupted();
15221
+ if (SYSTEM_TAG.test(text3) || text3.startsWith("Caveat:")) return;
15222
+ let prompt = text3;
15223
+ if (/^<command-(name|message|args)>/.test(text3)) {
15224
+ const cmd = /<command-name>([\s\S]*?)<\/command-name>/.exec(text3)?.[1]?.trim();
15225
+ const args = /<command-args>([\s\S]*?)<\/command-args>/.exec(text3)?.[1]?.trim() ?? "";
15092
15226
  if (!cmd || LOCAL_COMMANDS.has(cmd)) return;
15093
15227
  prompt = `${cmd} ${args}`.trim();
15094
15228
  }
@@ -15096,8 +15230,8 @@ var LineParser = class {
15096
15230
  this.meta("lastPrompt", truncate(maskSecrets(prompt.slice(0, 1e3)), 200));
15097
15231
  this.push(describePrompt(prompt));
15098
15232
  }
15099
- notification(text2, withActivity) {
15100
- const n2 = parseTaskNotification(text2);
15233
+ notification(text3, withActivity) {
15234
+ const n2 = parseTaskNotification(text3);
15101
15235
  const sig = { type: "notification" };
15102
15236
  if (n2.toolUseId) sig.toolUseId = n2.toolUseId;
15103
15237
  if (n2.taskId) sig.taskId = n2.taskId;
@@ -15207,9 +15341,9 @@ var LineParser = class {
15207
15341
  }
15208
15342
  }
15209
15343
  };
15210
- function forkDirective(text2) {
15211
- const end = text2.lastIndexOf("</fork-boilerplate>");
15212
- const rest = end >= 0 ? text2.slice(end + "</fork-boilerplate>".length) : text2;
15344
+ function forkDirective(text3) {
15345
+ const end = text3.lastIndexOf("</fork-boilerplate>");
15346
+ const rest = end >= 0 ? text3.slice(end + "</fork-boilerplate>".length) : text3;
15213
15347
  return rest.trim().replace(/^your directive:\s*/i, "").trim();
15214
15348
  }
15215
15349
  var PRESCAN_MIN_CHARS = 64 * 1024;
@@ -15414,8 +15548,8 @@ function marked(p) {
15414
15548
  \u2026` : p.text;
15415
15549
  }
15416
15550
  function oneLine(raw, max, reminders = true) {
15417
- const { text: text2, cut: cut3 } = safeText(raw, max * 4 + TAIL_GUARD * 2, reminders);
15418
- const lines = text2.split("\n");
15551
+ const { text: text3, cut: cut3 } = safeText(raw, max * 4 + TAIL_GUARD * 2, reminders);
15552
+ const lines = text3.split("\n");
15419
15553
  const i = lines.findIndex((l) => l.trim());
15420
15554
  if (i < 0) return "";
15421
15555
  const line2 = truncate(lines[i], max);
@@ -15427,10 +15561,10 @@ function lineAndDetail(raw, max = SYSTEM_TEXT_MAX) {
15427
15561
  return line2.endsWith("\u2026") ? { line: line2, detail: raw } : { line: line2 };
15428
15562
  }
15429
15563
  var TAGS = /* @__PURE__ */ new Map();
15430
- function inner(text2, tag) {
15564
+ function inner(text3, tag) {
15431
15565
  let re = TAGS.get(tag);
15432
15566
  if (!re) TAGS.set(tag, re = new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`));
15433
- return re.exec(text2)?.[1];
15567
+ return re.exec(text3)?.[1];
15434
15568
  }
15435
15569
  function relPath(p, cwd) {
15436
15570
  if (!cwd || !p.startsWith("/")) return p;
@@ -15467,8 +15601,8 @@ function jsonInput(input, omit = [], cwd) {
15467
15601
  }
15468
15602
  return textInput(json, "json");
15469
15603
  }
15470
- function prefixLines(text2, prefix, budget, sourceCut) {
15471
- const src = text2.replace(/\n$/, "");
15604
+ function prefixLines(text3, prefix, budget, sourceCut) {
15605
+ const src = text3.replace(/\n$/, "");
15472
15606
  const out = [];
15473
15607
  let used = 0;
15474
15608
  let start = 0;
@@ -15497,8 +15631,8 @@ function diffText(oldRaw, newRaw, budget = INPUT_MAX) {
15497
15631
  return [oldPart, newPart].filter(Boolean).join("\n");
15498
15632
  }
15499
15633
  function diffInput(oldRaw, newRaw) {
15500
- const text2 = diffText(oldRaw, newRaw);
15501
- return text2 ? { input: text2, inputKind: "diff" } : {};
15634
+ const text3 = diffText(oldRaw, newRaw);
15635
+ return text3 ? { input: text3, inputKind: "diff" } : {};
15502
15636
  }
15503
15637
  var TODO_MARK = { completed: "\u2612", in_progress: "\u25D0", pending: "\u2610" };
15504
15638
  var TASK_STATUS = { completed: tr("conclu\xEDda"), in_progress: tr("em andamento"), pending: "pendente", deleted: "removida" };
@@ -15531,8 +15665,8 @@ function toolView(name, input, cwd) {
15531
15665
  case "MultiEdit": {
15532
15666
  const edits = Array.isArray(input.edits) ? input.edits.map(rec2).filter((e) => !!e) : [];
15533
15667
  const per = Math.max(200, Math.floor(INPUT_MAX / Math.max(1, edits.length)));
15534
- const text2 = edits.slice(0, 12).map((e) => diffText(typeof e.old_string === "string" ? e.old_string : "", typeof e.new_string === "string" ? e.new_string : "", per)).filter(Boolean).join("\n@@\n");
15535
- return { title: titled("MultiEdit", rel2), ...text2 ? { input: marked(clip(text2, INPUT_MAX)), inputKind: "diff" } : {} };
15668
+ const text3 = edits.slice(0, 12).map((e) => diffText(typeof e.old_string === "string" ? e.old_string : "", typeof e.new_string === "string" ? e.new_string : "", per)).filter(Boolean).join("\n@@\n");
15669
+ return { title: titled("MultiEdit", rel2), ...text3 ? { input: marked(clip(text3, INPUT_MAX)), inputKind: "diff" } : {} };
15536
15670
  }
15537
15671
  case "Write":
15538
15672
  return { title: titled("Write", rel2), ...diffInput("", typeof input.content === "string" ? input.content : "") };
@@ -15666,13 +15800,13 @@ var Parser = class {
15666
15800
  }
15667
15801
  // ---------------------------------------------------------------- entradas
15668
15802
  userEntry(c, raw) {
15669
- const text2 = marked(prepare(raw, TEXT_MAX));
15670
- if (text2) this.emit({ kind: "user", id: `${c.uuid}:u`, at: c.at, text: text2 });
15803
+ const text3 = marked(prepare(raw, TEXT_MAX));
15804
+ if (text3) this.emit({ kind: "user", id: `${c.uuid}:u`, at: c.at, text: text3 });
15671
15805
  }
15672
15806
  /** `text` deve vir numa linha só (oneLine) ou ser fixo; a máscara aqui é a última garantia. */
15673
- sys(c, text2, o = {}) {
15674
- if (!text2) return;
15675
- const e = { kind: "system", id: `${c.uuid}${o.suffix ?? ":s"}`, at: c.at, text: maskSecrets(text2), level: o.level ?? "info" };
15807
+ sys(c, text3, o = {}) {
15808
+ if (!text3) return;
15809
+ const e = { kind: "system", id: `${c.uuid}${o.suffix ?? ":s"}`, at: c.at, text: maskSecrets(text3), level: o.level ?? "info" };
15676
15810
  if (o.turnDone) {
15677
15811
  e.turnDone = true;
15678
15812
  e.doneLabel = tr("pronto {0}", ["{0}"]);
@@ -15695,8 +15829,8 @@ var Parser = class {
15695
15829
  if (j.isMeta === true) return;
15696
15830
  const content = rec2(j.message)?.content;
15697
15831
  if (j.isCompactSummary === true) {
15698
- const text2 = typeof content === "string" ? content : resultText(content);
15699
- this.sys(c, tr("Resumo da conversa compactada"), { detail: text2 });
15832
+ const text3 = typeof content === "string" ? content : resultText(content);
15833
+ this.sys(c, tr("Resumo da conversa compactada"), { detail: text3 });
15700
15834
  return;
15701
15835
  }
15702
15836
  if (typeof content === "string") return this.userText(c, content);
@@ -15724,59 +15858,59 @@ var Parser = class {
15724
15858
  if (texts.length || images && !results) this.userText(c, texts.join("\n"), results ? 0 : images);
15725
15859
  }
15726
15860
  userText(c, raw, images = 0) {
15727
- const text2 = (raw.includes("<system-reminder>") ? raw.replace(REMINDER, "") : raw).trim();
15861
+ const text3 = (raw.includes("<system-reminder>") ? raw.replace(REMINDER, "") : raw).trim();
15728
15862
  const pics = images ? Array.from({ length: Math.min(images, 10) }, () => tr("[imagem]")).join(" ") : "";
15729
- if (!text2) {
15863
+ if (!text3) {
15730
15864
  if (pics) this.userEntry(c, pics);
15731
15865
  return;
15732
15866
  }
15733
- if (text2.startsWith("<task-notification>")) return this.notification(c, text2);
15734
- if (INTERRUPTED2.test(text2)) return this.sys(c, tr("Interrompido pelo usu\xE1rio"), { level: "warn" });
15735
- if (text2.startsWith("Caveat:")) return;
15736
- const tag = /^<([a-z][\w-]*)/.exec(text2)?.[1];
15867
+ if (text3.startsWith("<task-notification>")) return this.notification(c, text3);
15868
+ if (INTERRUPTED2.test(text3)) return this.sys(c, tr("Interrompido pelo usu\xE1rio"), { level: "warn" });
15869
+ if (text3.startsWith("Caveat:")) return;
15870
+ const tag = /^<([a-z][\w-]*)/.exec(text3)?.[1];
15737
15871
  switch (tag) {
15738
15872
  case "command-name":
15739
15873
  case "command-message":
15740
15874
  case "command-args": {
15741
- const msg = inner(text2, "command-message")?.trim();
15742
- const name = inner(text2, "command-name")?.trim() || (msg ? `/${msg}` : void 0);
15875
+ const msg = inner(text3, "command-message")?.trim();
15876
+ const name = inner(text3, "command-name")?.trim() || (msg ? `/${msg}` : void 0);
15743
15877
  if (!name) return;
15744
15878
  const cmd = name.startsWith("/") ? name : `/${name}`;
15745
15879
  this.lastCommand = cmd;
15746
- this.userEntry(c, `${cmd} ${inner(text2, "command-args")?.trim() ?? ""}`.trim());
15880
+ this.userEntry(c, `${cmd} ${inner(text3, "command-args")?.trim() ?? ""}`.trim());
15747
15881
  return;
15748
15882
  }
15749
15883
  case "local-command-stdout":
15750
15884
  case "local-command-stderr":
15751
15885
  case "command-stdout":
15752
15886
  case "command-stderr": {
15753
- const out = OUTPUT_TAGS.map((t) => inner(text2, t)?.trim()).filter(Boolean).join("\n");
15887
+ const out = OUTPUT_TAGS.map((t) => inner(text3, t)?.trim()).filter(Boolean).join("\n");
15754
15888
  if (out) this.sys(c, this.lastCommand ? tr("Sa\xEDda de {0}", [this.lastCommand]) : tr("Sa\xEDda do comando"), { detail: out });
15755
15889
  return;
15756
15890
  }
15757
15891
  case "bash-input": {
15758
- const cmd = inner(text2, "bash-input")?.trim();
15892
+ const cmd = inner(text3, "bash-input")?.trim();
15759
15893
  if (cmd) this.userEntry(c, `! ${cmd}`);
15760
15894
  return;
15761
15895
  }
15762
15896
  case "bash-stdout":
15763
15897
  case "bash-stderr": {
15764
- const out = [inner(text2, "bash-stdout"), inner(text2, "bash-stderr")].map((x) => x?.trim()).filter(Boolean).join("\n");
15898
+ const out = [inner(text3, "bash-stdout"), inner(text3, "bash-stderr")].map((x) => x?.trim()).filter(Boolean).join("\n");
15765
15899
  this.sys(c, tr("Sa\xEDda do comando"), { detail: out || tr("(sem sa\xEDda)") });
15766
15900
  return;
15767
15901
  }
15768
15902
  case "scheduled-task": {
15769
- const body2 = text2.replace(/^<scheduled-task\b[^>]*>/, "").replace(/<\/scheduled-task>\s*$/, "");
15903
+ const body2 = text3.replace(/^<scheduled-task\b[^>]*>/, "").replace(/<\/scheduled-task>\s*$/, "");
15770
15904
  if (body2.trim()) this.userEntry(c, body2);
15771
15905
  return;
15772
15906
  }
15773
15907
  case "fork-boilerplate": {
15774
- const directive = forkDirective(text2);
15908
+ const directive = forkDirective(text3);
15775
15909
  if (directive) this.userEntry(c, directive);
15776
15910
  return;
15777
15911
  }
15778
15912
  case "user-memory-input": {
15779
- const memory = inner(text2, "user-memory-input")?.trim();
15913
+ const memory = inner(text3, "user-memory-input")?.trim();
15780
15914
  if (memory) this.userEntry(c, `# ${memory}`);
15781
15915
  return;
15782
15916
  }
@@ -15786,14 +15920,14 @@ var Parser = class {
15786
15920
  default:
15787
15921
  break;
15788
15922
  }
15789
- this.userEntry(c, pics && !/\[Image\b/.test(text2) ? `${text2}
15790
- ${pics}` : text2);
15923
+ this.userEntry(c, pics && !/\[Image\b/.test(text3) ? `${text3}
15924
+ ${pics}` : text3);
15791
15925
  }
15792
- notification(c, text2) {
15793
- const n2 = parseTaskNotification(text2);
15926
+ notification(c, text3) {
15927
+ const n2 = parseTaskNotification(text3);
15794
15928
  const status2 = n2.status?.toLowerCase();
15795
- const result = inner(text2, "result")?.trim();
15796
- const event = inner(text2, "event")?.trim();
15929
+ const result = inner(text3, "result")?.trim();
15930
+ const event = inner(text3, "event")?.trim();
15797
15931
  let label = tr("Notifica\xE7\xE3o de tarefa em segundo plano");
15798
15932
  let level = "info";
15799
15933
  if (status2 === "completed") label = tr("Tarefa em segundo plano conclu\xEDda");
@@ -15852,8 +15986,8 @@ ${pics}` : text2);
15852
15986
  }
15853
15987
  const synthetic = m.model === "<synthetic>";
15854
15988
  if (c.j.isApiErrorMessage === true || synthetic && str6(c.j.error)) {
15855
- const text2 = blocks.map((b) => rec2(b)?.text).filter((t) => typeof t === "string").join("\n");
15856
- return this.sysContent(c, text2 || tr("Erro da API"), "error");
15989
+ const text3 = blocks.map((b) => rec2(b)?.text).filter((t) => typeof t === "string").join("\n");
15990
+ return this.sysContent(c, text3 || tr("Erro da API"), "error");
15857
15991
  }
15858
15992
  const msgId = str6(m.id) ?? c.uuid;
15859
15993
  blocks.forEach((raw, i) => {
@@ -15868,8 +16002,8 @@ ${pics}` : text2);
15868
16002
  if (!NO_RESPONSE.test(t.trim())) this.sysContent(c, t, "info", void 0, `:${i}`);
15869
16003
  return;
15870
16004
  }
15871
- const text2 = marked(prepare(t, TEXT_MAX));
15872
- if (text2) this.emit({ kind: "assistant", id, at: c.at, text: text2 });
16005
+ const text3 = marked(prepare(t, TEXT_MAX));
16006
+ if (text3) this.emit({ kind: "assistant", id, at: c.at, text: text3 });
15873
16007
  return;
15874
16008
  }
15875
16009
  case "thinking":
@@ -15879,8 +16013,8 @@ ${pics}` : text2);
15879
16013
  if (this.repeated(msgId, `k${t.length}:${t.slice(0, 64)}:${sig.length}:${sig.slice(-24)}`)) return;
15880
16014
  const e = { kind: "thinking", id, at: c.at };
15881
16015
  if (b.type === "thinking" && t.trim()) {
15882
- const text2 = marked(prepare(t, THINKING_MAX));
15883
- if (text2) e.text = text2;
16016
+ const text3 = marked(prepare(t, THINKING_MAX));
16017
+ if (text3) e.text = text3;
15884
16018
  }
15885
16019
  this.emit(e);
15886
16020
  return;
@@ -15939,9 +16073,9 @@ ${pics}` : text2);
15939
16073
  attachment(c) {
15940
16074
  const a = rec2(c.j.attachment);
15941
16075
  if (!a || a.type !== "queued_command" || a.isMeta === true || c.j.isMeta === true) return;
15942
- let text2 = "";
16076
+ let text3 = "";
15943
16077
  let images = 0;
15944
- if (typeof a.prompt === "string") text2 = a.prompt;
16078
+ if (typeof a.prompt === "string") text3 = a.prompt;
15945
16079
  else if (Array.isArray(a.prompt)) {
15946
16080
  const texts = [];
15947
16081
  for (const raw of a.prompt) {
@@ -15949,11 +16083,11 @@ ${pics}` : text2);
15949
16083
  if (b?.type === "text" && typeof b.text === "string") texts.push(b.text);
15950
16084
  else if (b?.type === "image") images++;
15951
16085
  }
15952
- text2 = texts.join("\n");
16086
+ text3 = texts.join("\n");
15953
16087
  }
15954
- if (text2.trimStart().startsWith("<task-notification>")) return this.notification(c, text2.trim());
16088
+ if (text3.trimStart().startsWith("<task-notification>")) return this.notification(c, text3.trim());
15955
16089
  if (a.commandMode !== void 0 && a.commandMode !== "prompt") return;
15956
- this.userText(c, text2, images);
16090
+ this.userText(c, text3, images);
15957
16091
  }
15958
16092
  };
15959
16093
  function createTerminalParser() {
@@ -17199,8 +17333,8 @@ async function readSessionMeta(path, size) {
17199
17333
  function isTitleLine(line2) {
17200
17334
  return TITLE_MARKERS.some((m) => line2.includes(m));
17201
17335
  }
17202
- function splitLines(text2, dropFirst, dropLast) {
17203
- const lines = text2.split("\n");
17336
+ function splitLines(text3, dropFirst, dropLast) {
17337
+ const lines = text3.split("\n");
17204
17338
  if (dropFirst) lines.shift();
17205
17339
  if (dropLast) lines.pop();
17206
17340
  return lines.map((l) => l.replace(/\r$/, "")).filter((l) => l.trim());
@@ -18231,6 +18365,96 @@ function checkFile(path, fs = { realpath: process.platform === "win32" ? realpat
18231
18365
  // server/central/hub.ts
18232
18366
  import { randomBytes as randomBytes3 } from "node:crypto";
18233
18367
 
18368
+ // shared/inbox.ts
18369
+ var INBOX_TITLE_MAX = 200;
18370
+ var INBOX_BODY_MAX_BYTES = 8 * 1024;
18371
+ var INBOX_KEY_MAX = 128;
18372
+ var INBOX_SOURCE_MAX = 64;
18373
+ var INBOX_LINK_MAX = 2048;
18374
+ var INBOX_OPEN_MAX = 200;
18375
+ var INBOX_RESOLVED_KEEP_MS = 7 * 24 * 60 * 60 * 1e3;
18376
+ var INBOX_RESOLVED_SHOWN = 20;
18377
+ var INBOX_ANCESTORS_MAX = 64;
18378
+ var utf8Len = (s2) => new TextEncoder().encode(s2).length;
18379
+ var BAD = /* @__PURE__ */ Symbol("bad");
18380
+ function text2(v) {
18381
+ if (v === void 0 || v === null) return void 0;
18382
+ return typeof v === "string" ? v : BAD;
18383
+ }
18384
+ function isHttpUrl(v) {
18385
+ try {
18386
+ const u = new URL(v);
18387
+ return u.protocol === "http:" || u.protocol === "https:";
18388
+ } catch {
18389
+ return false;
18390
+ }
18391
+ }
18392
+ function parseInboxPost(raw) {
18393
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return { ok: false, error: tr("corpo inv\xE1lido") };
18394
+ const r = raw;
18395
+ const rawTitle = text2(r.title);
18396
+ const title = typeof rawTitle === "string" ? rawTitle.trim() : "";
18397
+ if (!title) return { ok: false, error: tr("t\xEDtulo obrigat\xF3rio") };
18398
+ if (title.length > INBOX_TITLE_MAX) return { ok: false, error: tr("t\xEDtulo longo demais (m\xE1x. {0} caracteres)", [INBOX_TITLE_MAX]) };
18399
+ const post = { title, ancestors: [] };
18400
+ const body2 = text2(r.body);
18401
+ if (body2 === BAD) return { ok: false, error: tr("texto inv\xE1lido") };
18402
+ if (body2 !== void 0 && body2.trim()) {
18403
+ if (utf8Len(body2) > INBOX_BODY_MAX_BYTES) return { ok: false, error: tr("texto longo demais (m\xE1x. {0} KB)", [INBOX_BODY_MAX_BYTES / 1024]) };
18404
+ post.body = body2;
18405
+ }
18406
+ const rawLink = text2(r.link);
18407
+ if (rawLink === BAD) return { ok: false, error: tr("link inv\xE1lido") };
18408
+ const link = rawLink?.trim();
18409
+ if (link) {
18410
+ if (link.length > INBOX_LINK_MAX || !isHttpUrl(link)) return { ok: false, error: tr("o link precisa ser http ou https") };
18411
+ post.link = link;
18412
+ }
18413
+ const rawKey = text2(r.key);
18414
+ if (rawKey === BAD) return { ok: false, error: tr("chave inv\xE1lida") };
18415
+ const key = rawKey?.trim();
18416
+ if (key) {
18417
+ if (key.length > INBOX_KEY_MAX) return { ok: false, error: tr("chave longa demais (m\xE1x. {0} caracteres)", [INBOX_KEY_MAX]) };
18418
+ post.key = key;
18419
+ }
18420
+ const rawSource = text2(r.source);
18421
+ if (rawSource === BAD) return { ok: false, error: tr("origem inv\xE1lida") };
18422
+ const source = rawSource?.trim();
18423
+ if (source) post.source = source.slice(0, INBOX_SOURCE_MAX);
18424
+ if (r.ancestors !== void 0) {
18425
+ if (!Array.isArray(r.ancestors)) return { ok: false, error: tr("ancestrais inv\xE1lidos") };
18426
+ post.ancestors = r.ancestors.filter((n2) => Number.isInteger(n2) && n2 > 0).slice(0, INBOX_ANCESTORS_MAX);
18427
+ }
18428
+ return { ok: true, post };
18429
+ }
18430
+ var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
18431
+ var num5 = (v) => typeof v === "number" && Number.isFinite(v);
18432
+ function parseSender(v) {
18433
+ if (!isObj(v)) return void 0;
18434
+ if (v.kind === "agent" && typeof v.agentId === "string" && v.agentId) return { kind: "agent", agentId: v.agentId };
18435
+ if (v.kind === "script" && (v.name === void 0 || typeof v.name === "string")) return { kind: "script", ...typeof v.name === "string" ? { name: v.name } : {} };
18436
+ return void 0;
18437
+ }
18438
+ function parseInboxItem(v) {
18439
+ if (!isObj(v)) return void 0;
18440
+ const from = parseSender(v.from);
18441
+ if (typeof v.id !== "string" || !v.id || typeof v.title !== "string" || !v.title || !from) return void 0;
18442
+ if (v.status !== "open" && v.status !== "resolved") return void 0;
18443
+ if (!num5(v.createdAt) || !num5(v.updatedAt)) return void 0;
18444
+ const item = { id: v.id, title: v.title.slice(0, INBOX_TITLE_MAX), from, scope: "local", status: v.status, createdAt: v.createdAt, updatedAt: v.updatedAt };
18445
+ if (typeof v.key === "string" && v.key) item.key = v.key.slice(0, INBOX_KEY_MAX);
18446
+ if (typeof v.body === "string" && utf8Len(v.body) <= INBOX_BODY_MAX_BYTES) item.body = v.body;
18447
+ if (typeof v.link === "string" && v.link.length <= INBOX_LINK_MAX && isHttpUrl(v.link)) item.link = v.link;
18448
+ if (num5(v.resolvedAt)) item.resolvedAt = v.resolvedAt;
18449
+ if (typeof v.machine === "string" && v.machine) item.machine = v.machine;
18450
+ return item;
18451
+ }
18452
+ function visibleInbox(items, resolvedShown = INBOX_RESOLVED_SHOWN) {
18453
+ const open3 = items.filter((i) => i.status === "open").sort((a, b) => b.updatedAt - a.updatedAt);
18454
+ const done = items.filter((i) => i.status === "resolved").sort((a, b) => (b.resolvedAt ?? b.updatedAt) - (a.resolvedAt ?? a.updatedAt)).slice(0, resolvedShown);
18455
+ return [...open3, ...done];
18456
+ }
18457
+
18234
18458
  // server/host-wait.ts
18235
18459
  var HOST_WAIT_MS = 2e4;
18236
18460
  var HostWait = class {
@@ -18282,11 +18506,11 @@ async function pollWithWait(wait, take, ms, signal) {
18282
18506
  }
18283
18507
 
18284
18508
  // shared/perf.ts
18285
- var num5 = (v) => typeof v === "number" && Number.isFinite(v);
18509
+ var num6 = (v) => typeof v === "number" && Number.isFinite(v);
18286
18510
  var rec3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
18287
- var allNum = (o, keys) => rec3(o) && keys.every((k) => num5(o[k]));
18511
+ var allNum = (o, keys) => rec3(o) && keys.every((k) => num6(o[k]));
18288
18512
  function parsePerfSample(body2) {
18289
- if (!rec3(body2) || !num5(body2.at) || !num5(body2.uptime)) return void 0;
18513
+ if (!rec3(body2) || !num6(body2.at) || !num6(body2.uptime)) return void 0;
18290
18514
  const { cpu, memory, eventLoop, work } = body2;
18291
18515
  if (!allNum(cpu, ["oneCore", "allCores"]) || !allNum(memory, ["rss", "heapUsed", "external"])) return void 0;
18292
18516
  if (!allNum(eventLoop, ["p50", "p99", "max"])) return void 0;
@@ -18497,27 +18721,31 @@ var DELIVERED_GRACE_MS = 5e3;
18497
18721
  var SEEN_MAX2 = 1e3;
18498
18722
  var TICK_MS = 1e3;
18499
18723
  var weigh = (a) => (a.type === "message.send" ? a.text.length + a.images.reduce((n2, i) => n2 + i.data.length, 0) : 0) + 512;
18500
- var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
18724
+ var isObj2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
18501
18725
  var isStr = (v) => typeof v === "string";
18502
18726
  var bad = () => {
18503
18727
  throw new HttpError(400, tr("JSON inv\xE1lido"));
18504
18728
  };
18505
- var all = (v, ok) => Array.isArray(v) && v.every((x) => isObj(x) && ok(x));
18729
+ var all = (v, ok) => Array.isArray(v) && v.every((x) => isObj2(x) && ok(x));
18506
18730
  function validState(body2) {
18507
- if (!isObj(body2) || body2.protocol !== 1 || !isStr(body2.boot) || !body2.boot || typeof body2.seq !== "number" || !Number.isFinite(body2.seq)) return bad();
18731
+ if (!isObj2(body2) || body2.protocol !== 1 || !isStr(body2.boot) || !body2.boot || typeof body2.seq !== "number" || !Number.isFinite(body2.seq)) return bad();
18508
18732
  const s2 = body2.snapshot;
18509
- if (!isObj(s2)) return bad();
18733
+ if (!isObj2(s2)) return bad();
18510
18734
  if (!all(s2.rooms, (r) => isStr(r.id) && isStr(r.name) && isStr(r.path)) || !all(s2.agents, (a) => isStr(a.id) && isStr(a.roomId) && isStr(a.account)) || !all(s2.accounts, (a) => isStr(a.id) && isStr(a.name)))
18511
18735
  return bad();
18512
- if (!all(body2.feed, (f) => isStr(f.id) && isStr(f.agentId) && isStr(f.roomId)) || !all(body2.notices, (n2) => isStr(n2.id)) || !all(body2.relayed, (r) => isStr(r.actionId) && isObj(r.message) && isStr(r.message.id) && isStr(r.message.agentId)))
18736
+ if (!all(body2.feed, (f) => isStr(f.id) && isStr(f.agentId) && isStr(f.roomId)) || !all(body2.notices, (n2) => isStr(n2.id)) || !all(body2.relayed, (r) => isStr(r.actionId) && isObj2(r.message) && isStr(r.message.id) && isStr(r.message.agentId)))
18513
18737
  return bad();
18738
+ if (body2.inbox !== void 0) {
18739
+ if (!Array.isArray(body2.inbox)) return bad();
18740
+ body2.inbox = body2.inbox.map(parseInboxItem).filter((i) => !!i).slice(0, INBOX_OPEN_MAX + INBOX_RESOLVED_SHOWN);
18741
+ }
18514
18742
  if (body2.ptys !== void 0) {
18515
18743
  const ptys2 = body2.ptys;
18516
- if (!isObj(ptys2) || !isObj(ptys2.status) || typeof ptys2.status.enabled !== "boolean" || !Array.isArray(ptys2.list))
18744
+ if (!isObj2(ptys2) || !isObj2(ptys2.status) || typeof ptys2.status.enabled !== "boolean" || !Array.isArray(ptys2.list))
18517
18745
  return bad();
18518
- const num10 = (v) => v === void 0 || typeof v === "number" && Number.isFinite(v);
18746
+ const num11 = (v) => v === void 0 || typeof v === "number" && Number.isFinite(v);
18519
18747
  ptys2.list = ptys2.list.filter(
18520
- (p) => isObj(p) && isStr(p.id) && isStr(p.agentId) && isStr(p.account) && isStr(p.cwd) && typeof p.pid === "number" && Number.isFinite(p.pid) && num10(p.startedAt) && num10(p.exitedAt) && num10(p.exitCode) && (p.fromAgent === void 0 || isStr(p.fromAgent)) && (p.resumed === void 0 || isStr(p.resumed))
18748
+ (p) => isObj2(p) && isStr(p.id) && isStr(p.agentId) && isStr(p.account) && isStr(p.cwd) && typeof p.pid === "number" && Number.isFinite(p.pid) && num11(p.startedAt) && num11(p.exitedAt) && num11(p.exitCode) && (p.fromAgent === void 0 || isStr(p.fromAgent)) && (p.resumed === void 0 || isStr(p.resumed))
18521
18749
  ).slice(0, 32);
18522
18750
  }
18523
18751
  return body2;
@@ -18536,6 +18764,9 @@ var CentralHub = class {
18536
18764
  relayedCbs = /* @__PURE__ */ new Set();
18537
18765
  ptyOutputCbs = /* @__PURE__ */ new Set();
18538
18766
  satellitePerf = /* @__PURE__ */ new Map();
18767
+ /** Per machine: id -> "status:updatedAt" of the inbox items seen; tells a live arrival from the first sight. */
18768
+ inboxSeen = /* @__PURE__ */ new Map();
18769
+ inboxCbs = /* @__PURE__ */ new Set();
18539
18770
  ticker;
18540
18771
  counter = 0;
18541
18772
  constructor(opts) {
@@ -18590,6 +18821,49 @@ var CentralHub = class {
18590
18821
  }
18591
18822
  return out;
18592
18823
  }
18824
+ /**
18825
+ * The office inbox items of the paired machines the office still shows, ids prefixed and `machine` set. An offline
18826
+ * machine keeps its items on the desk (they are still there); resolving one then fails as "offline".
18827
+ */
18828
+ inboxItems() {
18829
+ const now = this.now();
18830
+ const out = [];
18831
+ for (const [id, e] of this.entries) {
18832
+ if (now - e.at >= HIDE_AFTER_MS || !e.state.inbox) continue;
18833
+ for (const i of e.state.inbox) out.push(namespaceInboxItem(id, i));
18834
+ }
18835
+ return out;
18836
+ }
18837
+ /** Called when a machine's inbox changed; `arrived` is a new (or reopened) open item seen live. */
18838
+ onInbox(cb) {
18839
+ this.inboxCbs.add(cb);
18840
+ return () => void this.inboxCbs.delete(cb);
18841
+ }
18842
+ /** The satellite confirmed the resolve: show it now instead of at its next state. */
18843
+ markInboxResolved(machine, localId) {
18844
+ const e = this.entries.get(machine);
18845
+ const item = e?.state.inbox?.find((i) => i.id === localId);
18846
+ if (!item || item.status === "resolved") return;
18847
+ const at = this.now();
18848
+ item.status = "resolved";
18849
+ item.resolvedAt = at;
18850
+ item.updatedAt = at;
18851
+ this.inboxSeen.get(machine)?.set(item.id, `resolved:${item.updatedAt}`);
18852
+ for (const cb of this.inboxCbs) cb();
18853
+ }
18854
+ noteInbox(machine, items) {
18855
+ const seen = this.inboxSeen.get(machine);
18856
+ const next = new Map(items.map((i) => [i.id, `${i.status}:${i.updatedAt}`]));
18857
+ this.inboxSeen.set(machine, next);
18858
+ let changed = next.size !== (seen?.size ?? 0);
18859
+ let arrived;
18860
+ for (const i of items) {
18861
+ const before = seen?.get(i.id);
18862
+ if (before !== next.get(i.id)) changed = true;
18863
+ if (seen && i.status === "open" && (before === void 0 || before.startsWith("resolved:")) && !arrived) arrived = namespaceInboxItem(machine, i);
18864
+ }
18865
+ if (changed || arrived) for (const cb of this.inboxCbs) cb(arrived);
18866
+ }
18593
18867
  isOnline(machine) {
18594
18868
  const e = this.entries.get(machine);
18595
18869
  return !!e && this.now() - e.at < OFFLINE_AFTER_MS;
@@ -18667,6 +18941,7 @@ var CentralHub = class {
18667
18941
  const freshNotices = notices.filter((n2) => this.remember(entry.noticeSeen, n2.id));
18668
18942
  if (freshFeed.length || freshNotices.length) this.office.addRemoteFrames(freshFeed, freshNotices);
18669
18943
  for (const r of s2.relayed) for (const cb of this.relayedCbs) cb(m.id, r);
18944
+ if (s2.inbox || this.inboxSeen.has(m.id)) this.noteInbox(m.id, s2.inbox ?? []);
18670
18945
  this.office.markDirty();
18671
18946
  return reply2();
18672
18947
  }
@@ -18706,7 +18981,7 @@ var CentralHub = class {
18706
18981
  }
18707
18982
  results(m, body2) {
18708
18983
  this.assertPaired(m);
18709
- if (!isObj(body2) || !all(body2.results, (r) => isStr(r.actionId) && typeof r.ok === "boolean")) bad();
18984
+ if (!isObj2(body2) || !all(body2.results, (r) => isStr(r.actionId) && typeof r.ok === "boolean")) bad();
18710
18985
  for (const r of body2.results) {
18711
18986
  const p = this.pending.get(r.actionId);
18712
18987
  if (!p || p.machine !== m.id) continue;
@@ -18717,7 +18992,7 @@ var CentralHub = class {
18717
18992
  ptyOutput(m, ptyId, body2) {
18718
18993
  this.assertPaired(m);
18719
18994
  if (!/^p\d+-\d+$/.test(ptyId)) return bad();
18720
- if (!isObj(body2)) return bad();
18995
+ if (!isObj2(body2)) return bad();
18721
18996
  const sequence = body2.sequence;
18722
18997
  if (typeof sequence !== "number" || !Number.isSafeInteger(sequence) || sequence < 1) return bad();
18723
18998
  let output;
@@ -18860,6 +19135,7 @@ var CentralHub = class {
18860
19135
  revoke(id) {
18861
19136
  this.machines.revoke(id);
18862
19137
  this.entries.delete(id);
19138
+ if (this.inboxSeen.delete(id)) for (const cb of this.inboxCbs) cb();
18863
19139
  this.satellitePerf.delete(id);
18864
19140
  for (const p of [...this.pending.values()]) if (p.machine === id) this.fail(p, "revoked");
18865
19141
  this.closeReads(id, new HubError("revoked"));
@@ -18921,9 +19197,9 @@ var CentralHub = class {
18921
19197
 
18922
19198
  // server/central/reads.ts
18923
19199
  var BUFFER_TIMEOUT_MS = 3e4;
18924
- var isObj2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
19200
+ var isObj3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
18925
19201
  function rewriteIds(machine, body2, kind) {
18926
- if (!isObj2(body2)) throw new Error("corpo inesperado");
19202
+ if (!isObj3(body2)) throw new Error("corpo inesperado");
18927
19203
  switch (kind) {
18928
19204
  case "detail":
18929
19205
  return namespaceDetail(machine, body2);
@@ -19616,6 +19892,24 @@ function createApiHandler(deps) {
19616
19892
  } else deps.attention(req, res, path);
19617
19893
  return true;
19618
19894
  }
19895
+ if (path === "/api/inbox" || path.startsWith("/api/inbox/")) {
19896
+ if (!deps.inbox) {
19897
+ req.resume();
19898
+ sendJson2(res, 404, { error: tr("rota desconhecida") });
19899
+ } else if (isRead) {
19900
+ if (!attentionAllowed(req)) sendJson2(res, 403, { error: tr("a mesa s\xF3 vale pelo pr\xF3prio computador ou pelo acesso remoto com login") });
19901
+ else deps.inbox(req, res, path);
19902
+ } else if (path !== "/api/inbox") {
19903
+ if (!trusted(req, "messages")) {
19904
+ req.resume();
19905
+ sendJson2(res, 403, { error: denied(req, tr("os itens da mesa s\xF3 s\xE3o resolvidos pelo pr\xF3prio computador (http://localhost ou http://127.0.0.1)")) });
19906
+ } else deps.inbox(req, res, path);
19907
+ } else if (isRemote(req) || !isLoopbackHost(req.headers.host) || !deps.inDocker && !isLoopbackAddress(req.socket.remoteAddress)) {
19908
+ req.resume();
19909
+ sendJson2(res, 403, { error: tr("s\xF3 o pr\xF3prio computador deixa itens na mesa (http://localhost ou http://127.0.0.1)") });
19910
+ } else deps.inbox(req, res, path);
19911
+ return true;
19912
+ }
19619
19913
  if (path === "/api/avatar") {
19620
19914
  if (!deps.avatar) {
19621
19915
  req.resume();
@@ -20396,16 +20690,16 @@ function centralCertTargets(name, ips) {
20396
20690
  var MESSAGE_MAX = 2e4;
20397
20691
  var MESSAGE_TOOL = "HabblaudMessage";
20398
20692
  var DETAIL_MAX2 = 300;
20399
- function describeMessage(text2, images = 0) {
20400
- const typed = truncate(maskSecrets(text2.slice(0, DETAIL_MAX2 * 4)), DETAIL_MAX2);
20693
+ function describeMessage(text3, images = 0) {
20694
+ const typed = truncate(maskSecrets(text3.slice(0, DETAIL_MAX2 * 4)), DETAIL_MAX2);
20401
20695
  const extra = images > 0 ? images === 1 ? tr("com 1 imagem") : tr("com {0} imagens", [images]) : "";
20402
20696
  const detail = typed && extra ? `${typed} \xB7 ${extra}` : typed || extra;
20403
20697
  return { kind: "communicate", icon: "\u2709\uFE0F", text: tr("Mensagem pelo Habblaud"), tool: MESSAGE_TOOL, ...detail ? { detail } : {} };
20404
20698
  }
20405
20699
  var MESSAGE_IMAGES_MAX = 8;
20406
20700
  var MESSAGE_IMAGE_BYTES_MAX = 15 * 1024 * 1024;
20407
- function isSlashCommand(text2) {
20408
- return /^\s*\/[^\s/]+(?:\s[\s\S]*)?$/.test(text2);
20701
+ function isSlashCommand(text3) {
20702
+ return /^\s*\/[^\s/]+(?:\s[\s\S]*)?$/.test(text3);
20409
20703
  }
20410
20704
 
20411
20705
  // server/messages/registry.ts
@@ -20598,7 +20892,7 @@ var MessageRegistry = class {
20598
20892
  let open3 = 0;
20599
20893
  for (const e of this.messages.values()) if (e.msg.agentId === agent.id && !isFinal(e)) open3++;
20600
20894
  if (open3 >= MAX_OPEN2) return { error: "too-many" };
20601
- let text2 = typed;
20895
+ let text3 = typed;
20602
20896
  let files = 0;
20603
20897
  if (attachments2.length) {
20604
20898
  const images = this.opts.images;
@@ -20612,7 +20906,7 @@ var MessageRegistry = class {
20612
20906
  if (demo) images.discard(taken);
20613
20907
  else {
20614
20908
  try {
20615
- text2 = promptWithAttachments(typed, images.save(taken));
20909
+ text3 = promptWithAttachments(typed, images.save(taken));
20616
20910
  } catch (err) {
20617
20911
  log.warnOnce(`messages-images:${errMsg(err)}`, tr("Mensagens: n\xE3o deu para gravar as imagens ({0}).", [errMsg(err)]));
20618
20912
  return { error: "images", code: "write", reason: tr("n\xE3o deu para guardar as imagens no computador") };
@@ -20621,7 +20915,7 @@ var MessageRegistry = class {
20621
20915
  }
20622
20916
  const now = this.now();
20623
20917
  const id = `m-${now.toString(36)}-${++this.seq}-${randomBytes4(9).toString("base64url")}`;
20624
- const entry = { msg: { id, agentId: agent.id, status: "queued", createdAt: now, updatedAt: now }, text: text2, activity: describeMessage(typed, files), target: agent.sessionId };
20918
+ const entry = { msg: { id, agentId: agent.id, status: "queued", createdAt: now, updatedAt: now }, text: text3, activity: describeMessage(typed, files), target: agent.sessionId };
20625
20919
  if (demo) entry.demo = true;
20626
20920
  else if (real?.provider === "codex") entry.codex = true;
20627
20921
  this.messages.set(id, entry);
@@ -20898,7 +21192,7 @@ function createMessageRoutes(registry, remote) {
20898
21192
  if ("error" in r) return sendJson2(res, r.status, { error: r.error });
20899
21193
  sendJson2(res, 201, r);
20900
21194
  };
20901
- const inbox = async (req, res) => {
21195
+ const inbox2 = async (req, res) => {
20902
21196
  sendJson2(res, 200, { messages: registry.inbox(await readJson(req)) });
20903
21197
  };
20904
21198
  const ack = async (req, res) => {
@@ -20939,7 +21233,7 @@ function createMessageRoutes(registry, remote) {
20939
21233
  }).catch((err) => fail(res, err));
20940
21234
  return;
20941
21235
  }
20942
- if (path === "/api/mod/inbox") return post(req, res, inbox);
21236
+ if (path === "/api/mod/inbox") return post(req, res, inbox2);
20943
21237
  if (path === "/api/mod/inbox/ack") return post(req, res, ack);
20944
21238
  if (path === "/api/mod/commands") return post(req, res, commands);
20945
21239
  const c = COMMANDS.exec(path);
@@ -21020,7 +21314,7 @@ var RemoteMessages = class {
21020
21314
  send(raw) {
21021
21315
  const peek = raw?.agentId;
21022
21316
  if (typeof peek !== "string" || !parseRemoteId(peek)) return void 0;
21023
- const { agentId, text: text2, attachments: attachments2 } = parseSend(raw);
21317
+ const { agentId, text: text3, attachments: attachments2 } = parseSend(raw);
21024
21318
  const ref = parseRemoteId(agentId);
21025
21319
  if (!ref) return void 0;
21026
21320
  if (!this.hub.isOnline(ref.machine)) return { error: "unavailable", reason: ERR_MACHINE_OFFLINE2 };
@@ -21035,7 +21329,7 @@ var RemoteMessages = class {
21035
21329
  if (attachments2.length) {
21036
21330
  const store = this.images;
21037
21331
  if (!store) return { error: "images", code: "off", reason: tr("imagens desligadas") };
21038
- if (isSlashCommand(text2)) return { error: "images", code: "slash", reason: tr("comandos de barra n\xE3o levam imagens: tire as imagens ou mande o comando sozinho") };
21332
+ if (isSlashCommand(text3)) return { error: "images", code: "slash", reason: tr("comandos de barra n\xE3o levam imagens: tire as imagens ou mande o comando sozinho") };
21039
21333
  if (store.peekSize(attachments2) > REMOTE_IMAGES_MAX_BYTES) {
21040
21334
  return { error: "images", code: "size", reason: tr("as imagens passam de {0} MB: mande menos imagens", [REMOTE_IMAGES_MAX_BYTES / (1024 * 1024)]) };
21041
21335
  }
@@ -21050,7 +21344,7 @@ var RemoteMessages = class {
21050
21344
  const action = {
21051
21345
  type: "message.send",
21052
21346
  agentId: ref.local,
21053
- text: text2,
21347
+ text: text3,
21054
21348
  images
21055
21349
  };
21056
21350
  const q = this.hub.enqueue(ref.machine, action, { timeoutMs: QUEUED_TIMEOUT_MS2 });
@@ -21270,8 +21564,8 @@ function codexToolView(tool, input, cwd) {
21270
21564
  const more = files.length > 1 ? ` +${files.length - 1}` : "";
21271
21565
  const title = first ? `apply_patch(${line(relPath2(first.path, cwd), TITLE_ARG_MAX)}${more})` : "apply_patch";
21272
21566
  const name = first ? line(basename3(first.path), TEXT_MAX3) : "";
21273
- const [text2, icon] = files.length > 1 ? [tr("Editando {0} arquivos", [files.length]), "\u270F\uFE0F"] : first?.op === "Add" ? [tr("Criando {0}", [name]), "\u{1F4DD}"] : first?.op === "Delete" ? [tr("Apagando {0}", [name]), "\u{1F5D1}\uFE0F"] : [first ? tr("Editando {0}", [name]) : tr("Aplicando um patch"), "\u270F\uFE0F"];
21274
- return { title, text: truncate(text2, TEXT_MAX3), icon, ...shown(patch, "diff") };
21567
+ const [text3, icon] = files.length > 1 ? [tr("Editando {0} arquivos", [files.length]), "\u270F\uFE0F"] : first?.op === "Add" ? [tr("Criando {0}", [name]), "\u{1F4DD}"] : first?.op === "Delete" ? [tr("Apagando {0}", [name]), "\u{1F5D1}\uFE0F"] : [first ? tr("Editando {0}", [name]) : tr("Aplicando um patch"), "\u270F\uFE0F"];
21568
+ return { title, text: truncate(text3, TEXT_MAX3), icon, ...shown(patch, "diff") };
21275
21569
  }
21276
21570
  case "request_permissions": {
21277
21571
  const view = toolView(tool, input, cwd);
@@ -21432,8 +21726,8 @@ function askFormat(raw) {
21432
21726
  function askCount(raw) {
21433
21727
  if (!Array.isArray(raw)) return 0;
21434
21728
  return raw.filter((q) => {
21435
- const text2 = rec6(q)?.question;
21436
- return typeof text2 === "string" && !!text2.trim();
21729
+ const text3 = rec6(q)?.question;
21730
+ return typeof text3 === "string" && !!text3.trim();
21437
21731
  }).length;
21438
21732
  }
21439
21733
  function fitsFormat(f, a) {
@@ -21598,8 +21892,8 @@ var PermissionRegistry = class {
21598
21892
  const now = this.now();
21599
21893
  const id = `p-${now.toString(36)}-${++this.seq}-${randomBytes5(9).toString("base64url")}`;
21600
21894
  const view = "title" in desc ? desc : toolView(req.tool, req.input, req.cwd);
21601
- const text2 = only && req.promptTitle ? truncate(maskSecrets(req.promptTitle), 120) : desc.text;
21602
- const info = { id, tool: req.tool, title: view.title, text: text2, icon: desc.icon, createdAt: now, expiresAt: now + req.timeoutMs };
21895
+ const text3 = only && req.promptTitle ? truncate(maskSecrets(req.promptTitle), 120) : desc.text;
21896
+ const info = { id, tool: req.tool, title: view.title, text: text3, icon: desc.icon, createdAt: now, expiresAt: now + req.timeoutMs };
21603
21897
  if (codex2) info.provider = "codex";
21604
21898
  if (only) info.terminalOnly = true;
21605
21899
  if (view.input) info.input = view.input;
@@ -21628,8 +21922,8 @@ var PermissionRegistry = class {
21628
21922
  this.opts.office.addActivity(target.id, { id: `${target.id}#perm:${id}`, at: now, kind: "wait", icon: "\u2753", text: truncate(tr("Pergunta: {0}", [first]), 46), detail: truncate(all2, 300), tool: "PermissionRequest" }, false);
21629
21923
  this.opts.office.noticePermission(target.id, `${truncate(first, 120)}${by}`, "question");
21630
21924
  } else {
21631
- this.opts.office.addActivity(target.id, { id: `${target.id}#perm:${id}`, at: now, kind: "wait", icon: "\u{1F510}", text: truncate(tr("Pede permiss\xE3o: {0}", [text2]), 46), detail: view.title, tool: "PermissionRequest" }, false);
21632
- this.opts.office.noticePermission(target.id, only ? `${text2} \xB7 ${view.title}` : `${desc.text}${by}`);
21925
+ this.opts.office.addActivity(target.id, { id: `${target.id}#perm:${id}`, at: now, kind: "wait", icon: "\u{1F510}", text: truncate(tr("Pede permiss\xE3o: {0}", [text3]), 46), detail: view.title, tool: "PermissionRequest" }, false);
21926
+ this.opts.office.noticePermission(target.id, only ? `${text3} \xB7 ${view.title}` : `${desc.text}${by}`);
21633
21927
  }
21634
21928
  this.opts.office.markDirty();
21635
21929
  return { id, expiresAt: info.expiresAt + EXPIRY_GRACE_MS2 };
@@ -22086,8 +22380,8 @@ var CODE_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
22086
22380
  var LABEL_MAX = 40;
22087
22381
  var hashToken = (token) => createHash2("sha256").update(token, "utf8").digest("hex");
22088
22382
  function cleanLabel(label) {
22089
- const text2 = cleanMachineLabel(label).slice(0, LABEL_MAX).trim();
22090
- return text2 || void 0;
22383
+ const text3 = cleanMachineLabel(label).slice(0, LABEL_MAX).trim();
22384
+ return text3 || void 0;
22091
22385
  }
22092
22386
  var MachineStore = class {
22093
22387
  file;
@@ -22566,6 +22860,7 @@ var Satellite = class {
22566
22860
  applied;
22567
22861
  ptyProvider;
22568
22862
  maintenanceCallback;
22863
+ inbox;
22569
22864
  /** Aleatório por processo (P9): a central troca a parte da máquina quando ele muda. */
22570
22865
  boot = randomBytes7(9).toString("base64url");
22571
22866
  seq = Date.now();
@@ -22601,6 +22896,7 @@ var Satellite = class {
22601
22896
  this.now = opts.now ?? (() => performance.now());
22602
22897
  this.ptyProvider = opts.ptys ?? (() => void 0);
22603
22898
  this.maintenanceCallback = opts.maintenance ?? (() => void 0);
22899
+ this.inbox = opts.inbox;
22604
22900
  this.applied = new AppliedActions({ now: Date.now });
22605
22901
  }
22606
22902
  start() {
@@ -22618,6 +22914,7 @@ var Satellite = class {
22618
22914
  else this.notices = [...this.notices, data].slice(-NOTICE_KEEP);
22619
22915
  })
22620
22916
  );
22917
+ if (this.inbox) this.offs.push(this.inbox.onChange(() => this.schedule()));
22621
22918
  this.heartbeat = this.timers.setInterval(() => void this.post(), HEARTBEAT_MS);
22622
22919
  unref(this.heartbeat);
22623
22920
  this.maintenance = this.timers.setInterval(() => this.optsMaintenance(), 1e3);
@@ -22704,6 +23001,7 @@ var Satellite = class {
22704
23001
  const snap = this.snap ?? this.hub.current();
22705
23002
  const meta = { version: snap.meta.version };
22706
23003
  if (snap.meta.messages !== void 0) meta.messages = snap.meta.messages;
23004
+ const inbox2 = this.inbox?.items();
22707
23005
  return {
22708
23006
  protocol: 1,
22709
23007
  boot: this.boot,
@@ -22716,7 +23014,8 @@ var Satellite = class {
22716
23014
  },
22717
23015
  feed,
22718
23016
  notices,
22719
- relayed
23017
+ relayed,
23018
+ ...inbox2 ? { inbox: inbox2 } : {}
22720
23019
  };
22721
23020
  }
22722
23021
  ptys() {
@@ -23798,25 +24097,25 @@ function cut2(s2, max) {
23798
24097
  const sp = head.lastIndexOf(" ");
23799
24098
  return `${(sp > max * 0.6 ? head.slice(0, sp) : head).replace(/[\s,;:.-]+$/, "")}\u2026`;
23800
24099
  }
23801
- function paragraphs(text2) {
23802
- return text2.replace(/`{3}[\s\S]*?`{3}/g, "\n\n").split(/\n\s*\n/).map((p) => p.trim()).filter(Boolean);
24100
+ function paragraphs(text3) {
24101
+ return text3.replace(/`{3}[\s\S]*?`{3}/g, "\n\n").split(/\n\s*\n/).map((p) => p.trim()).filter(Boolean);
23803
24102
  }
23804
24103
  var isProse = (p) => !/^(\||#|>|[-*+]\s|\d+[.)]\s|`{3})/.test(p) && !/^[A-Z_ ]+:\s/.test(p);
23805
- function headlineOf(text2) {
23806
- const first = paragraphs(text2).find(isProse) ?? paragraphs(text2)[0] ?? "";
24104
+ function headlineOf(text3) {
24105
+ const first = paragraphs(text3).find(isProse) ?? paragraphs(text3)[0] ?? "";
23807
24106
  const plain = stripMarkdown(first);
23808
24107
  const m = /^(.+?[.!?])(\s|$)/.exec(plain);
23809
24108
  return cut2(m ? m[1] : plain, HEADLINE_MAX);
23810
24109
  }
23811
- function summaryOf(text2, headline) {
23812
- const paras = paragraphs(text2).filter(isProse);
24110
+ function summaryOf(text3, headline) {
24111
+ const paras = paragraphs(text3).filter(isProse);
23813
24112
  const last = paras[paras.length - 1];
23814
24113
  if (!last || paras.length < 2) return void 0;
23815
24114
  const plain = stripMarkdown(last);
23816
24115
  if (plain.length < 60 || plain.startsWith(headline.replace(/…$/, ""))) return void 0;
23817
24116
  return cut2(plain, SUMMARY_MAX2);
23818
24117
  }
23819
- function linkedFiles(text2, project, platform = process.platform) {
24118
+ function linkedFiles(text3, project, platform = process.platform) {
23820
24119
  const P = platform === "win32" ? win32 : posix;
23821
24120
  const out = /* @__PURE__ */ new Set();
23822
24121
  const add = (raw) => {
@@ -23836,8 +24135,8 @@ function linkedFiles(text2, project, platform = process.platform) {
23836
24135
  p = P.normalize(p);
23837
24136
  if (!pathProblem(p, platform)) out.add(p);
23838
24137
  };
23839
- for (const m of text2.matchAll(LINK_RE)) add(m[1]);
23840
- for (const m of text2.matchAll(BARE_RE)) add(m[1]);
24138
+ for (const m of text3.matchAll(LINK_RE)) add(m[1]);
24139
+ for (const m of text3.matchAll(BARE_RE)) add(m[1]);
23841
24140
  return [...out];
23842
24141
  }
23843
24142
  function newTurn(start) {
@@ -23982,13 +24281,13 @@ var DeliveryIndex = class {
23982
24281
  }
23983
24282
  }
23984
24283
  toDelivery(s2, t, files) {
23985
- const text2 = t.text.trim();
23986
- if (!t.tools || text2.length < MIN_TEXT || t.marksStop && !t.ended) return void 0;
24284
+ const text3 = t.text.trim();
24285
+ if (!t.tools || text3.length < MIN_TEXT || t.marksStop && !t.ended) return void 0;
23987
24286
  const id = `${s2.account}:${s2.sessionId}:${t.start.id}`;
23988
24287
  const attachments2 = [];
23989
24288
  const paths = /* @__PURE__ */ new Map();
23990
24289
  for (const f of t.files) if (!pathProblem(f.path) && !paths.has(f.path)) paths.set(f.path, f.caption);
23991
- for (const p of linkedFiles(text2, s2.project)) if (!paths.has(p)) paths.set(p, void 0);
24290
+ for (const p of linkedFiles(text3, s2.project)) if (!paths.has(p)) paths.set(p, void 0);
23992
24291
  for (const [path, caption] of paths) {
23993
24292
  const ft = fileType(path);
23994
24293
  if (!ft) continue;
@@ -24003,8 +24302,8 @@ var DeliveryIndex = class {
24003
24302
  files.set(aid, { kind: "capture", type: c.type, data: Buffer.from(c.data, "base64"), name });
24004
24303
  attachments2.push({ id: aid, name, kind: "image", caption: tr("Tela capturada pelo agente"), capture: true });
24005
24304
  });
24006
- const headline = headlineOf(text2);
24007
- const summary = summaryOf(text2, headline);
24305
+ const headline = headlineOf(text3);
24306
+ const summary = summaryOf(text3, headline);
24008
24307
  const agentName2 = s2.agentId ? this.opts.agentName?.(s2.agentId) : void 0;
24009
24308
  const provider = s2.provider;
24010
24309
  return {
@@ -24018,7 +24317,7 @@ var DeliveryIndex = class {
24018
24317
  request: cut2(stripMarkdown(t.start.text), REQUEST_MAX),
24019
24318
  headline,
24020
24319
  ...summary ? { summary } : {},
24021
- text: text2.slice(0, 4e4),
24320
+ text: text3.slice(0, 4e4),
24022
24321
  startedAt: t.start.at,
24023
24322
  finishedAt: t.textAt,
24024
24323
  tools: t.tools,
@@ -24029,7 +24328,7 @@ var DeliveryIndex = class {
24029
24328
  };
24030
24329
 
24031
24330
  // server/central/merge.ts
24032
- var isObj3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
24331
+ var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
24033
24332
  var partialOf = (r) => r.missing.length ? { partial: true, unavailable: r.missing } : {};
24034
24333
  function withoutRemote(snap) {
24035
24334
  return {
@@ -24051,9 +24350,9 @@ function addTotals(into, from) {
24051
24350
  }
24052
24351
  var cloneTotals = (t) => ({ ...t, ms: { ...t.ms }, counts: { ...t.counts } });
24053
24352
  function validDay(body2) {
24054
- if (!isObj3(body2) || !isObj3(body2.stats)) throw new Error("corpo inesperado");
24353
+ if (!isObj4(body2) || !isObj4(body2.stats)) throw new Error("corpo inesperado");
24055
24354
  const s2 = body2.stats;
24056
- if (!isObj3(s2.totals) || !isObj3(s2.totals.ms) || !isObj3(s2.totals.counts) || !Array.isArray(s2.rooms) || !Array.isArray(s2.accounts) || !Array.isArray(s2.hours) || !Array.isArray(s2.waits)) throw new Error("corpo inesperado");
24355
+ if (!isObj4(s2.totals) || !isObj4(s2.totals.ms) || !isObj4(s2.totals.counts) || !Array.isArray(s2.rooms) || !Array.isArray(s2.accounts) || !Array.isArray(s2.hours) || !Array.isArray(s2.waits)) throw new Error("corpo inesperado");
24057
24356
  return body2;
24058
24357
  }
24059
24358
  function mergeDayStats(local, remotes) {
@@ -24103,7 +24402,7 @@ function createCentralMerge(hub2, opts = {}) {
24103
24402
  const r = await fanOutAll(hub2, "/api/deliveries", {
24104
24403
  timeoutMs,
24105
24404
  map: (m, b) => {
24106
- if (!isObj3(b) || !Array.isArray(b.deliveries)) throw new Error("corpo inesperado");
24405
+ if (!isObj4(b) || !Array.isArray(b.deliveries)) throw new Error("corpo inesperado");
24107
24406
  return b.deliveries.map((d) => namespaceDelivery(m, d));
24108
24407
  }
24109
24408
  });
@@ -24116,7 +24415,7 @@ function createCentralMerge(hub2, opts = {}) {
24116
24415
  const r = await fanOutAll(hub2, "/api/sessions/recent", {
24117
24416
  timeoutMs,
24118
24417
  map: (m, b) => {
24119
- if (!isObj3(b) || !Array.isArray(b.sessions)) throw new Error("corpo inesperado");
24418
+ if (!isObj4(b) || !Array.isArray(b.sessions)) throw new Error("corpo inesperado");
24120
24419
  return b.sessions.map((s2) => namespaceSession(m, s2));
24121
24420
  }
24122
24421
  });
@@ -24137,7 +24436,7 @@ function createCentralMerge(hub2, opts = {}) {
24137
24436
  timeoutMs,
24138
24437
  search,
24139
24438
  map: (_m, b) => {
24140
- if (!isObj3(b) || !Array.isArray(b.days) || !b.days.every((d) => typeof d === "string")) throw new Error("corpo inesperado");
24439
+ if (!isObj4(b) || !Array.isArray(b.days) || !b.days.every((d) => typeof d === "string")) throw new Error("corpo inesperado");
24141
24440
  return b.days;
24142
24441
  }
24143
24442
  });
@@ -24648,8 +24947,8 @@ function demoCodexPermission(id, src, rng, now) {
24648
24947
  }
24649
24948
 
24650
24949
  // shared/demo/terminal.ts
24651
- function startsWithText(text2, key) {
24652
- return text2.startsWith(key.split("{0}")[0]) || text2.startsWith(tr(key, ["\0"]).split("\0")[0]);
24950
+ function startsWithText(text3, key) {
24951
+ return text3.startsWith(key.split("{0}")[0]) || text3.startsWith(tr(key, ["\0"]).split("\0")[0]);
24653
24952
  }
24654
24953
  var POOLS = {
24655
24954
  ts: ["src/app.ts", "src/utils/format.ts", "src/components/Item.tsx", "tests/app.test.ts"],
@@ -24665,7 +24964,7 @@ function pickFiles(pool, seed, n2) {
24665
24964
  return Array.from({ length: Math.min(n2, pool.length) }, (_, k) => pool[(seed + k) % pool.length]);
24666
24965
  }
24667
24966
  var pick = (arr, seed) => arr[seed % arr.length];
24668
- var num6 = (seed, min, max) => min + seed % (max - min + 1);
24967
+ var num7 = (seed, min, max) => min + seed % (max - min + 1);
24669
24968
  var hex = (seed) => seed.toString(16).padStart(8, "0").slice(0, 7);
24670
24969
  function rel(path, ctx) {
24671
24970
  return ctx.root && path.startsWith(`${ctx.root}/`) ? path.slice(ctx.root.length + 1) : path;
@@ -24754,7 +25053,7 @@ function editPair(file, seed) {
24754
25053
  function commandOutput(command, seed, ctx) {
24755
25054
  const branch = ctx.agent.gitBranch ?? "main";
24756
25055
  const [f1, f2] = pickFiles(ctx.pool, seed, 2);
24757
- const n2 = (min, max) => num6(seed, min, max);
25056
+ const n2 = (min, max) => num7(seed, min, max);
24758
25057
  const secs = `${n2(1, 9)}.${n2(10, 99)}`;
24759
25058
  if (/playwright\s+test/.test(command)) return `Running ${n2(8, 30)} tests using 4 workers
24760
25059
 
@@ -24827,7 +25126,7 @@ function isBackground(i, ctx) {
24827
25126
  }
24828
25127
  function shellCall(out, a, i, command, seed, ctx, output) {
24829
25128
  const bg = isBackground(i, ctx);
24830
- const result = bg ? ctx.codex ? tr("Comando rodando em segundo plano (sess\xE3o {0}).", [num6(seed, 1e3, 9999)]) : tr("Comando rodando em segundo plano (id b{0}). Voc\xEA recebe um aviso quando ele terminar.", [hex(seed)]) : output ?? commandOutput(command, seed, ctx);
25129
+ const result = bg ? ctx.codex ? tr("Comando rodando em segundo plano (sess\xE3o {0}).", [num7(seed, 1e3, 9999)]) : tr("Comando rodando em segundo plano (id b{0}). Voc\xEA recebe um aviso quando ele terminar.", [hex(seed)]) : output ?? commandOutput(command, seed, ctx);
24831
25130
  const firstLine5 = command.split("\n")[0];
24832
25131
  const tool = ctx.codex ? "Shell" : "Bash";
24833
25132
  call(out, a, tool, `${tool}(${firstLine5}${command.includes("\n") ? " \u2026" : ""})`, result, { input: command, inputKind: "command" });
@@ -24868,8 +25167,8 @@ function entriesFor(a, i, ctx, out) {
24868
25167
  out.push({ kind: "user", id: `${a.id}:u`, at: a.at, text: detail ?? quoted(a.text) ?? a.text });
24869
25168
  return;
24870
25169
  case "think": {
24871
- const text2 = startsWithText(a.text, tr("Pensando")) ? seed % 3 === 0 ? void 0 : pick(THOUGHTS, seed >>> 3) : tr("Os subagentes terminaram; vou juntar o que cada um encontrou.");
24872
- out.push(text2 ? { kind: "thinking", id: `${a.id}:k`, at: a.at, text: text2 } : { kind: "thinking", id: `${a.id}:k`, at: a.at });
25170
+ const text3 = startsWithText(a.text, tr("Pensando")) ? seed % 3 === 0 ? void 0 : pick(THOUGHTS, seed >>> 3) : tr("Os subagentes terminaram; vou juntar o que cada um encontrou.");
25171
+ out.push(text3 ? { kind: "thinking", id: `${a.id}:k`, at: a.at, text: text3 } : { kind: "thinking", id: `${a.id}:k`, at: a.at });
24873
25172
  return;
24874
25173
  }
24875
25174
  case "respond":
@@ -24912,7 +25211,7 @@ function entriesFor(a, i, ctx, out) {
24912
25211
  return;
24913
25212
  }
24914
25213
  const files = pickFiles(ctx.pool, seed, 1 + seed % 3);
24915
- const matches = files.map((f, k) => `${f}:${num6(hash32(`${a.id}:${k}`), 3, 180)}: ${/^\w+$/.test(pattern) ? `const resultado = ${pattern}(dados);` : pattern}`);
25214
+ const matches = files.map((f, k) => `${f}:${num7(hash32(`${a.id}:${k}`), 3, 180)}: ${/^\w+$/.test(pattern) ? `const resultado = ${pattern}(dados);` : pattern}`);
24916
25215
  if (ctx.codex) shellCall(out, a, i, `rg -n ${JSON.stringify(pattern)}`, seed, ctx, matches.join("\n"));
24917
25216
  else call(out, a, "Grep", `Grep(${pattern})`, matches.join("\n"), { input: '{\n "output_mode": "content"\n}', inputKind: "json" });
24918
25217
  return;
@@ -24975,8 +25274,8 @@ function entriesFor(a, i, ctx, out) {
24975
25274
  });
24976
25275
  return;
24977
25276
  case "done": {
24978
- const text2 = ctx.agent.kind === "sub" && ctx.agent.title ? tr("Entrega: {0}. Resumo enviado ao agente principal.", [ctx.agent.title]) : pick(SUMMARIES, seed);
24979
- out.push({ kind: "assistant", id: `${a.id}:a`, at: a.at, text: text2 });
25277
+ const text3 = ctx.agent.kind === "sub" && ctx.agent.title ? tr("Entrega: {0}. Resumo enviado ao agente principal.", [ctx.agent.title]) : pick(SUMMARIES, seed);
25278
+ out.push({ kind: "assistant", id: `${a.id}:a`, at: a.at, text: text3 });
24980
25279
  const took = /Concluiu em (.+)$/.exec(a.text)?.[1];
24981
25280
  if (took) out.push({ kind: "system", id: `${a.id}:s`, at: a.at, text: tr("Turno conclu\xEDdo em {0}", [took]), level: "info" });
24982
25281
  return;
@@ -25916,8 +26215,8 @@ function githubEventKey(ev) {
25916
26215
  }
25917
26216
  function describeGitHubEvent(ev, agentName2, roomName) {
25918
26217
  const pr = ev.number !== void 0 ? tr("o PR #{0}", [ev.number]) : tr("um PR");
25919
- const act = (icon, text2, detail, error = false) => {
25920
- const d = { kind: "git", icon, text: clean2(text2, MAX_TEXT4), tool: GITHUB_TOOL };
26218
+ const act = (icon, text3, detail, error = false) => {
26219
+ const d = { kind: "git", icon, text: clean2(text3, MAX_TEXT4), tool: GITHUB_TOOL };
25921
26220
  const det = detail ?? ev.url ?? ev.repo;
25922
26221
  if (det) d.detail = clean2(det, 300);
25923
26222
  if (error) d.error = true;
@@ -25969,8 +26268,8 @@ var RoomEffects = class {
25969
26268
  /** Aplica um evento à sala; true se o efeito visível mudou. */
25970
26269
  apply(roomId, ev, now, agentId) {
25971
26270
  const slots = this.rooms.get(roomId) ?? {};
25972
- const make2 = (kind, text2, ms) => {
25973
- const fx = { kind, text: text2, at: now, until: now + ms };
26271
+ const make2 = (kind, text3, ms) => {
26272
+ const fx = { kind, text: text3, at: now, until: now + ms };
25974
26273
  if (agentId) fx.agentId = agentId;
25975
26274
  return fx;
25976
26275
  };
@@ -26253,15 +26552,15 @@ var DemoSimulator = class {
26253
26552
  * atividade "Mensagem pelo Habblaud" e, se ele estava à toa, o próximo turno começa logo, como se respondesse.
26254
26553
  * false = agente desconhecido, subagente ou que já saiu.
26255
26554
  */
26256
- receiveMessage(agentId, text2, now = Date.now()) {
26555
+ receiveMessage(agentId, text3, now = Date.now()) {
26257
26556
  const a = this.agents.get(agentId);
26258
26557
  if (!a || a.info.kind !== "main" || a.removeAt !== void 0 || a.phase === "leaving") return false;
26259
26558
  if (a.info.provider === "codex") {
26260
- (a.inbox ??= []).push(text2);
26261
- a.inboxAt = Math.max(a.inboxAt ?? 0, now + (CODEX_QUEUE_MIN_MS + hash32(`${agentId}:${text2}:${now}`) % CODEX_QUEUE_SPREAD_MS) / this.speed);
26559
+ (a.inbox ??= []).push(text3);
26560
+ a.inboxAt = Math.max(a.inboxAt ?? 0, now + (CODEX_QUEUE_MIN_MS + hash32(`${agentId}:${text3}:${now}`) % CODEX_QUEUE_SPREAD_MS) / this.speed);
26262
26561
  return true;
26263
26562
  }
26264
- this.activity(a, now, describeMessage(text2));
26563
+ this.activity(a, now, describeMessage(text3));
26265
26564
  if (a.phase === "idle") a.phaseUntil = Math.min(a.phaseUntil, now + this.ms(1500, 3e3));
26266
26565
  return true;
26267
26566
  }
@@ -26637,7 +26936,7 @@ var DemoSimulator = class {
26637
26936
  if (a.removeAt !== void 0) return;
26638
26937
  if (a.info.kind === "sub") return this.stepSub(a, now);
26639
26938
  if (a.inbox?.length && a.phase === "idle" && now >= (a.inboxAt ?? 0)) {
26640
- for (const text2 of a.inbox.splice(0)) this.activity(a, now, describeMessage(text2));
26939
+ for (const text3 of a.inbox.splice(0)) this.activity(a, now, describeMessage(text3));
26641
26940
  a.phaseUntil = Math.min(a.phaseUntil, now + 1500 / this.speed);
26642
26941
  a.closeAt = Math.max(a.closeAt, now + 3e4 / this.speed);
26643
26942
  }
@@ -26919,8 +27218,8 @@ var DemoSimulator = class {
26919
27218
  });
26920
27219
  this.dirty = true;
26921
27220
  }
26922
- notice(now, level, text2, agentId, roomId) {
26923
- const n2 = { id: `${this.prefix}${this.tag}-n${++this.seq}`, level, text: text2, at: now };
27221
+ notice(now, level, text3, agentId, roomId) {
27222
+ const n2 = { id: `${this.prefix}${this.tag}-n${++this.seq}`, level, text: text3, at: now };
26924
27223
  if (agentId) n2.agentId = agentId;
26925
27224
  if (roomId) n2.roomId = roomId;
26926
27225
  this.pendingNotices.push(n2);
@@ -28183,8 +28482,8 @@ var Office = class {
28183
28482
  this.addActivity(id, act, true, { feed: live });
28184
28483
  if (!live || outcome === "killed") return;
28185
28484
  const room = this.roomName(info.roomId);
28186
- const text2 = outcome === "ok" ? tr("\u2705 {0}: shell terminou em {1} \u2014 {2}", [info.name, room, job.label]) : tr("\u274C {0}: shell falhou em {1} \u2014 {2}", [info.name, room, job.label]);
28187
- this.notice("shellDone", id, outcome === "ok" ? "success" : "warn", text2, info.roomId, { dedupeKey: `${id}|shellDone|${job.id}` });
28485
+ const text3 = outcome === "ok" ? tr("\u2705 {0}: shell terminou em {1} \u2014 {2}", [info.name, room, job.label]) : tr("\u274C {0}: shell falhou em {1} \u2014 {2}", [info.name, room, job.label]);
28486
+ this.notice("shellDone", id, outcome === "ok" ? "success" : "warn", text3, info.roomId, { dedupeKey: `${id}|shellDone|${job.id}` });
28188
28487
  }
28189
28488
  /**
28190
28489
  * Evento do GitHub visto no transcript (PR aberto/mergeado, push, CI, release; ver shared/github.ts):
@@ -28456,8 +28755,8 @@ var Office = class {
28456
28755
  const info = this.agents.get(id)?.info;
28457
28756
  if (!info) return;
28458
28757
  const room = this.roomName(info.roomId);
28459
- const text2 = kind === "question" ? tr("\u2753 {0} tem uma pergunta em {1}: {2}", [info.name, room, what]) : tr("\u{1F510} {0} pede permiss\xE3o em {1}: {2}", [info.name, room, what]);
28460
- this.notice("wait", id, "alert", text2, info.roomId);
28758
+ const text3 = kind === "question" ? tr("\u2753 {0} tem uma pergunta em {1}: {2}", [info.name, room, what]) : tr("\u{1F510} {0} pede permiss\xE3o em {1}: {2}", [info.name, room, what]);
28759
+ this.notice("wait", id, "alert", text3, info.roomId);
28461
28760
  this.markDirty();
28462
28761
  }
28463
28762
  /** Decisão para um pedido fictício do demo. true = o pedido era do demo (e foi respondido). */
@@ -28479,10 +28778,10 @@ var Office = class {
28479
28778
  return this.demoSnap?.agents.find((a) => a.id === id);
28480
28779
  }
28481
28780
  /** Entrega fictícia de uma mensagem a um agente do demo. false = ele já saiu (ou o demo foi desligado). */
28482
- deliverDemoMessage(agentId, text2) {
28781
+ deliverDemoMessage(agentId, text3) {
28483
28782
  if (!this.demo) return false;
28484
28783
  const now = this.now();
28485
- if (!this.demo.receiveMessage(agentId, text2, now)) return false;
28784
+ if (!this.demo.receiveMessage(agentId, text3, now)) return false;
28486
28785
  this.demoSnap = this.demo.snapshot(now);
28487
28786
  this.markDirty();
28488
28787
  return true;
@@ -28524,8 +28823,8 @@ var Office = class {
28524
28823
  else delete info.parts;
28525
28824
  info.custom = true;
28526
28825
  const room = this.roomName(info.roomId);
28527
- const text2 = before === input.name ? tr("\u270F\uFE0F {0} mudou de visual em {1}", [input.name, room]) : tr("\u270F\uFE0F {0} agora \xE9 {1} em {2}", [before, input.name, room]);
28528
- this.notice("character", id, "info", text2, info.roomId, { dedupeMs: 0 });
28826
+ const text3 = before === input.name ? tr("\u270F\uFE0F {0} mudou de visual em {1}", [input.name, room]) : tr("\u270F\uFE0F {0} agora \xE9 {1} em {2}", [before, input.name, room]);
28827
+ this.notice("character", id, "info", text3, info.roomId, { dedupeMs: 0 });
28529
28828
  this.markDirty();
28530
28829
  return { result: "ok" };
28531
28830
  }
@@ -28807,13 +29106,13 @@ var Office = class {
28807
29106
  for (let i = 0; i < ordered.length; i++) ordered[i].duplicateSession = { count: ordered.length, newest: i === ordered.length - 1 };
28808
29107
  if (!previous || previous.has(key) || this.booting) continue;
28809
29108
  const newest = ordered[ordered.length - 1];
28810
- const text2 = tr("\u{1F6A8} Intrus\xE3o! A conversa de {0} est\xE1 aberta em {1} terminais", [newest.name, ordered.length]);
28811
- const effect = { kind: "intrusion", text: text2, at: now, until: now + ALARM_MS, panicUntil: now + INTRUSION_PANIC_MS, agentIds: ordered.map((agent) => agent.id) };
29109
+ const text3 = tr("\u{1F6A8} Intrus\xE3o! A conversa de {0} est\xE1 aberta em {1} terminais", [newest.name, ordered.length]);
29110
+ const effect = { kind: "intrusion", text: text3, at: now, until: now + ALARM_MS, panicUntil: now + INTRUSION_PANIC_MS, agentIds: ordered.map((agent) => agent.id) };
28812
29111
  this.intrusions.set(key, effect);
28813
29112
  this.buildingEffect = effect;
28814
29113
  const id = `intrusion:${++this.seq}`;
28815
29114
  const roomName = rooms.find((room) => room.id === newest.roomId)?.name ?? newest.roomId;
28816
- const activity = { id, kind: "other", icon: "\u{1F6A8}", text: tr("Intrus\xE3o no pr\xE9dio"), detail: text2, at: now };
29115
+ const activity = { id, kind: "other", icon: "\u{1F6A8}", text: tr("Intrus\xE3o no pr\xE9dio"), detail: text3, at: now };
28817
29116
  this.pushFeed([{
28818
29117
  id,
28819
29118
  agentId: newest.id,
@@ -28823,7 +29122,7 @@ var Office = class {
28823
29122
  account: newest.account,
28824
29123
  activity
28825
29124
  }]);
28826
- this.pendingNotices.push({ id, level: "alert", text: text2, agentId: newest.id, roomId: newest.roomId, at: now });
29125
+ this.pendingNotices.push({ id, level: "alert", text: text3, agentId: newest.id, roomId: newest.roomId, at: now });
28827
29126
  }
28828
29127
  this.duplicateGroups = current2;
28829
29128
  for (const key of this.intrusions.keys()) if (!current2.has(key)) this.intrusions.delete(key);
@@ -28912,7 +29211,7 @@ var Office = class {
28912
29211
  this.feed.push(...items);
28913
29212
  if (this.feed.length > FEED_LIMIT) this.feed.splice(0, this.feed.length - FEED_LIMIT);
28914
29213
  }
28915
- notice(kind, key, level, text2, roomId, opts = {}) {
29214
+ notice(kind, key, level, text3, roomId, opts = {}) {
28916
29215
  if (this.booting) return;
28917
29216
  const now = this.now();
28918
29217
  const k = opts.dedupeKey ?? `${key}|${kind}`;
@@ -28923,7 +29222,7 @@ var Office = class {
28923
29222
  if (this.noticeAt.size > 2e3) {
28924
29223
  for (const [nk, t] of this.noticeAt) if (now - t > Math.max(NOTICE_DEDUPE_MS, SHELL_NOTICE_DEDUPE_MS)) this.noticeAt.delete(nk);
28925
29224
  }
28926
- const n2 = { id: `n-${now.toString(36)}-${++this.seq}`, level, text: text2, at: now };
29225
+ const n2 = { id: `n-${now.toString(36)}-${++this.seq}`, level, text: text3, at: now };
28927
29226
  if (kind !== "room") n2.agentId = key;
28928
29227
  if (roomId) n2.roomId = roomId;
28929
29228
  this.pendingNotices.push(n2);
@@ -29554,6 +29853,261 @@ function createAvatarRoutes(store, hub2) {
29554
29853
  };
29555
29854
  }
29556
29855
 
29856
+ // server/inbox/store.ts
29857
+ import { randomBytes as randomBytes9 } from "node:crypto";
29858
+ import { mkdirSync as mkdirSync13, readFileSync as readFileSync18, renameSync as renameSync12, writeFileSync as writeFileSync12 } from "node:fs";
29859
+ import { dirname as dirname11 } from "node:path";
29860
+ var InboxStore = class {
29861
+ constructor(file, opts = {}) {
29862
+ this.file = file;
29863
+ this.now = opts.now ?? Date.now;
29864
+ this.newId = opts.id ?? (() => randomBytes9(6).toString("hex"));
29865
+ this.items = this.load();
29866
+ this.dropOldResolved();
29867
+ }
29868
+ file;
29869
+ items;
29870
+ now;
29871
+ newId;
29872
+ listeners = /* @__PURE__ */ new Set();
29873
+ /** Every stored item (open and resolved), oldest first. */
29874
+ list() {
29875
+ return structuredClone(this.items);
29876
+ }
29877
+ get(id) {
29878
+ const i = this.items.find((x) => x.id === id);
29879
+ return i ? structuredClone(i) : void 0;
29880
+ }
29881
+ openCount() {
29882
+ return this.items.filter((i) => i.status === "open").length;
29883
+ }
29884
+ onChange(cb) {
29885
+ this.listeners.add(cb);
29886
+ return () => void this.listeners.delete(cb);
29887
+ }
29888
+ post(input, from) {
29889
+ const now = this.now();
29890
+ const existing = input.key ? this.items.find((i) => i.key === input.key) : void 0;
29891
+ const reopened = existing?.status === "resolved";
29892
+ if ((!existing || reopened) && this.openCount() >= INBOX_OPEN_MAX) return { error: "full" };
29893
+ let item;
29894
+ if (existing) {
29895
+ item = existing;
29896
+ item.title = input.title;
29897
+ if (input.body !== void 0) item.body = input.body;
29898
+ else delete item.body;
29899
+ if (input.link !== void 0) item.link = input.link;
29900
+ else delete item.link;
29901
+ item.from = from;
29902
+ item.status = "open";
29903
+ item.updatedAt = now;
29904
+ delete item.resolvedAt;
29905
+ } else {
29906
+ item = { id: this.newId(), title: input.title, from, scope: "local", status: "open", createdAt: now, updatedAt: now };
29907
+ if (input.key) item.key = input.key;
29908
+ if (input.body !== void 0) item.body = input.body;
29909
+ if (input.link !== void 0) item.link = input.link;
29910
+ this.items.push(item);
29911
+ }
29912
+ this.save();
29913
+ const created = !existing;
29914
+ const out = structuredClone(item);
29915
+ this.emit(created || reopened ? { kind: "arrived", item: out } : { kind: "changed" });
29916
+ return { item: out, created, reopened };
29917
+ }
29918
+ /** Marks the item resolved (idempotent); undefined for an unknown id. */
29919
+ resolve(id) {
29920
+ const item = this.items.find((i) => i.id === id);
29921
+ if (!item) return void 0;
29922
+ if (item.status === "open") {
29923
+ const now = this.now();
29924
+ item.status = "resolved";
29925
+ item.resolvedAt = now;
29926
+ item.updatedAt = now;
29927
+ this.save();
29928
+ this.emit({ kind: "changed" });
29929
+ }
29930
+ return structuredClone(item);
29931
+ }
29932
+ /** Drops resolved items older than 7 days; true when something was dropped. */
29933
+ purge() {
29934
+ if (!this.dropOldResolved()) return false;
29935
+ this.save();
29936
+ this.emit({ kind: "changed" });
29937
+ return true;
29938
+ }
29939
+ dropOldResolved() {
29940
+ const limit = this.now() - INBOX_RESOLVED_KEEP_MS;
29941
+ const before = this.items.length;
29942
+ this.items = this.items.filter((i) => !(i.status === "resolved" && (i.resolvedAt ?? i.updatedAt) <= limit));
29943
+ return this.items.length !== before;
29944
+ }
29945
+ emit(e) {
29946
+ for (const cb of this.listeners) cb(e);
29947
+ }
29948
+ load() {
29949
+ if (!this.file) return [];
29950
+ try {
29951
+ const j = JSON.parse(readFileSync18(this.file, "utf8"));
29952
+ if (!Array.isArray(j.items)) return [];
29953
+ return j.items.map(parseInboxItem).filter((i) => !!i);
29954
+ } catch (err) {
29955
+ if (err.code !== "ENOENT") log.warn(tr("inbox.json ileg\xEDvel ({0}); come\xE7ando sem itens.", [errMsg(err)]));
29956
+ return [];
29957
+ }
29958
+ }
29959
+ save() {
29960
+ if (!this.file) return;
29961
+ try {
29962
+ mkdirSync13(dirname11(this.file), { recursive: true });
29963
+ writeFileSync12(`${this.file}.tmp`, JSON.stringify({ version: 1, items: this.items }, null, 2));
29964
+ renameSync12(`${this.file}.tmp`, this.file);
29965
+ } catch (err) {
29966
+ log.warn(tr("N\xE3o consegui gravar {0}: {1}", [this.file, errMsg(err)]));
29967
+ }
29968
+ }
29969
+ };
29970
+
29971
+ // server/inbox/sender.ts
29972
+ var PID_ID = /:(\d+)$/;
29973
+ function senderFor(post, agents2) {
29974
+ const byPid = /* @__PURE__ */ new Map();
29975
+ for (const a of agents2) {
29976
+ if (a.parentId || a.id.startsWith("@")) continue;
29977
+ const m = PID_ID.exec(a.id);
29978
+ if (m) byPid.set(Number(m[1]), a.id);
29979
+ }
29980
+ for (const pid of post.ancestors) {
29981
+ const id = byPid.get(pid);
29982
+ if (id) return { kind: "agent", agentId: id };
29983
+ }
29984
+ return post.source ? { kind: "script", name: post.source } : { kind: "script" };
29985
+ }
29986
+
29987
+ // server/inbox/service.ts
29988
+ var InboxService = class {
29989
+ store;
29990
+ agents;
29991
+ remote;
29992
+ offRemote;
29993
+ frameCbs = /* @__PURE__ */ new Set();
29994
+ constructor(opts) {
29995
+ this.store = opts.store;
29996
+ this.agents = opts.agents;
29997
+ this.store.onChange((e) => this.emit(e.kind === "arrived" ? e.item : void 0));
29998
+ }
29999
+ /** Central: also list (and resolve) the items of the paired machines. */
30000
+ setRemote(remote) {
30001
+ this.offRemote?.();
30002
+ this.remote = remote;
30003
+ this.offRemote = remote?.onChange((arrived) => this.emit(arrived));
30004
+ }
30005
+ /** What the page shows: open items first, then the recently resolved ones. */
30006
+ frame(arrived) {
30007
+ const items = visibleInbox([...this.store.list(), ...this.remote?.items() ?? []]);
30008
+ return arrived ? { items, arrived } : { items };
30009
+ }
30010
+ onFrame(cb) {
30011
+ this.frameCbs.add(cb);
30012
+ return () => void this.frameCbs.delete(cb);
30013
+ }
30014
+ /** Leaves an item on this machine's desk; the sender comes from the CLI's process tree. */
30015
+ post(post) {
30016
+ return this.store.post(post, senderFor(post, this.agents()));
30017
+ }
30018
+ async resolve(id) {
30019
+ if (parseRemoteId(id)) return this.remote ? this.remote.resolve(id) : { ok: false, status: 404, error: "unknown" };
30020
+ const item = this.store.resolve(id);
30021
+ return item ? { ok: true, item } : { ok: false, status: 404, error: "unknown" };
30022
+ }
30023
+ emit(arrived) {
30024
+ if (!this.frameCbs.size) return;
30025
+ const f = this.frame(arrived);
30026
+ for (const cb of this.frameCbs) cb(f);
30027
+ }
30028
+ };
30029
+
30030
+ // server/inbox/http.ts
30031
+ var RESOLVE_ROUTE = /^\/api\/inbox\/([^/]+)\/resolve$/;
30032
+ function createInboxRoutes(service) {
30033
+ const fail3 = (res, err) => {
30034
+ if (res.headersSent) return void res.destroy();
30035
+ if (err instanceof HttpError) sendJson2(res, err.status, { error: err.message });
30036
+ else sendJson2(res, 500, { error: tr("erro interno") });
30037
+ };
30038
+ const post = async (req, res) => {
30039
+ const parsed = parseInboxPost(await readJson(req));
30040
+ if (!parsed.ok) throw new HttpError(400, parsed.error);
30041
+ const r = service.post(parsed.post);
30042
+ if ("error" in r) throw new HttpError(429, tr("a mesa j\xE1 tem {0} itens abertos: resolva alguns antes de deixar outros", [INBOX_OPEN_MAX]));
30043
+ sendJson2(res, r.created ? 201 : 200, { ok: true, item: r.item, created: r.created, ...r.created ? {} : { reopened: r.reopened } });
30044
+ };
30045
+ const resolve14 = async (res, id) => {
30046
+ const r = await service.resolve(id);
30047
+ if (!r.ok) throw new HttpError(r.status, r.status === 404 ? tr("item n\xE3o encontrado") : r.error);
30048
+ sendJson2(res, 200, { ok: true, ...r.item ? { item: r.item } : {} });
30049
+ };
30050
+ return (req, res, path) => {
30051
+ const method = req.method ?? "GET";
30052
+ const m = RESOLVE_ROUTE.exec(path);
30053
+ if (m) {
30054
+ if (method !== "POST") {
30055
+ res.setHeader("Allow", "POST");
30056
+ return sendJson2(res, 405, { error: tr("m\xE9todo n\xE3o permitido") });
30057
+ }
30058
+ let id;
30059
+ try {
30060
+ id = decodeURIComponent(m[1]);
30061
+ } catch {
30062
+ return sendJson2(res, 404, { error: tr("item n\xE3o encontrado") });
30063
+ }
30064
+ req.resume();
30065
+ resolve14(res, id).catch((err) => fail3(res, err));
30066
+ } else if (method === "GET" || method === "HEAD") sendJson2(res, 200, service.frame());
30067
+ else if (method === "POST") post(req, res).catch((err) => fail3(res, err));
30068
+ else {
30069
+ res.setHeader("Allow", "GET, POST");
30070
+ sendJson2(res, 405, { error: tr("m\xE9todo n\xE3o permitido") });
30071
+ }
30072
+ };
30073
+ }
30074
+
30075
+ // server/central/inbox.ts
30076
+ var RemoteInboxItems = class {
30077
+ constructor(hub2) {
30078
+ this.hub = hub2;
30079
+ }
30080
+ hub;
30081
+ items() {
30082
+ return this.hub.inboxItems();
30083
+ }
30084
+ onChange(cb) {
30085
+ return this.hub.onInbox(cb);
30086
+ }
30087
+ async resolve(id) {
30088
+ const ref = parseRemoteId(id);
30089
+ if (!ref) return { ok: false, status: 404, error: "unknown" };
30090
+ const q = this.hub.enqueue(ref.machine, { type: "inbox.resolve", itemId: ref.local });
30091
+ if ("error" in q) return { ok: false, status: 503, error: "offline" };
30092
+ try {
30093
+ const r = await q.result;
30094
+ if (!r.ok) return { ok: false, status: r.data === "not-found" ? 404 : r.status ?? 502, error: r.error ?? "failed" };
30095
+ } catch {
30096
+ return { ok: false, status: 504, error: "timeout" };
30097
+ }
30098
+ this.hub.markInboxResolved(ref.machine, ref.local);
30099
+ return { ok: true };
30100
+ }
30101
+ };
30102
+ function createInboxResolveHandler(opts) {
30103
+ return async (a, deadline) => {
30104
+ if (a.type !== "inbox.resolve") return { actionId: a.id, ok: false, error: "unsupported" };
30105
+ if (Date.now() > deadline) return { actionId: a.id, ok: false, error: "expired" };
30106
+ const item = opts.store.resolve(a.itemId);
30107
+ return item ? { actionId: a.id, ok: true, data: "ok" } : { actionId: a.id, ok: false, data: "not-found", status: 404, error: "not-found" };
30108
+ };
30109
+ }
30110
+
29557
30111
  // server/attention/drain.ts
29558
30112
  function drainAttention(relay, hub2) {
29559
30113
  for (const close of relay.expire()) hub2.broadcast("attention", close);
@@ -29691,8 +30245,8 @@ function findCodexBin(env, isExecutable = canExecute) {
29691
30245
  }
29692
30246
  return void 0;
29693
30247
  }
29694
- function queueArgs(thread, text2) {
29695
- return ["queue", `--thread=${thread}`, `--message=${text2}`];
30248
+ function queueArgs(thread, text3) {
30249
+ return ["queue", `--thread=${thread}`, `--message=${text3}`];
29696
30250
  }
29697
30251
  function firstLine2(s2) {
29698
30252
  const line2 = (s2 ?? "").split(/\r?\n/).map((l) => l.trim()).find(Boolean);
@@ -29720,7 +30274,7 @@ function createCodexQueueRunner(bin, opts = {}) {
29720
30274
  }
29721
30275
 
29722
30276
  // server/messages/images.ts
29723
- import { randomBytes as randomBytes9 } from "node:crypto";
30277
+ import { randomBytes as randomBytes10 } from "node:crypto";
29724
30278
  function sniffImage(data) {
29725
30279
  if (data.length >= 8 && data.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))) return { type: "image/png", ext: "png" };
29726
30280
  if (data.length >= 3 && data[0] === 255 && data[1] === 216 && data[2] === 255) return { type: "image/jpeg", ext: "jpg" };
@@ -29751,7 +30305,7 @@ var MessageImages = class {
29751
30305
  constructor(opts = {}) {
29752
30306
  this.store = opts.store ?? new AttachmentStore();
29753
30307
  this.root = opts.root;
29754
- this.folderId = opts.folderId ?? (() => randomBytes9(6).toString("hex"));
30308
+ this.folderId = opts.folderId ?? (() => randomBytes10(6).toString("hex"));
29755
30309
  this.write = opts.write ?? writeAttachments;
29756
30310
  }
29757
30311
  upload(raw) {
@@ -29919,7 +30473,7 @@ function rec8(v) {
29919
30473
  function str10(v) {
29920
30474
  return typeof v === "string" && v.trim() ? v : void 0;
29921
30475
  }
29922
- function num7(v) {
30476
+ function num8(v) {
29923
30477
  return typeof v === "number" && Number.isFinite(v) ? v : void 0;
29924
30478
  }
29925
30479
  function toMs3(v) {
@@ -29976,12 +30530,12 @@ function parseSessionMeta(payload, at) {
29976
30530
  var WINDOW_BY_MINUTES = { 300: "fiveHour", 10080: "sevenDay" };
29977
30531
  function usageWindow(raw) {
29978
30532
  const w = rec8(raw);
29979
- const minutes = num7(w?.window_minutes);
29980
- const used = num7(w?.used_percent);
30533
+ const minutes = num8(w?.window_minutes);
30534
+ const used = num8(w?.used_percent);
29981
30535
  const key = minutes !== void 0 ? WINDOW_BY_MINUTES[minutes] : void 0;
29982
30536
  if (!w || !key || used === void 0) return void 0;
29983
30537
  const window = { utilization: Math.min(100, Math.max(0, used)) };
29984
- const resets = num7(w.resets_at);
30538
+ const resets = num8(w.resets_at);
29985
30539
  if (resets !== void 0) window.resetsAt = resets < 1e12 ? Math.round(resets * 1e3) : Math.round(resets);
29986
30540
  return { key, window };
29987
30541
  }
@@ -30023,8 +30577,8 @@ function fileChanges(raw) {
30023
30577
  const p = str10(path);
30024
30578
  if (!p) return;
30025
30579
  const kind = changeKind(c.type ?? c.kind);
30026
- const text2 = str10(c.unified_diff) ?? str10(c.diff) ?? str10(c.content) ?? "";
30027
- const e = { path: p, kind, text: text2 };
30580
+ const text3 = str10(c.unified_diff) ?? str10(c.diff) ?? str10(c.content) ?? "";
30581
+ const e = { path: p, kind, text: text3 };
30028
30582
  const move = str10(c.move_path) ?? str10(rec8(c.kind)?.move_path);
30029
30583
  if (move) e.movePath = move;
30030
30584
  out.push(e);
@@ -30064,8 +30618,8 @@ function mcpName(server2, tool) {
30064
30618
  }
30065
30619
  function userMessagingText(server2, tool, args) {
30066
30620
  if (!/user_messag(?:e|ing)[_.]*send_message$/i.test(`${String(server2 ?? "")}__${String(tool ?? "")}`)) return void 0;
30067
- const text2 = rec8(args)?.text ?? parseArguments(args).text;
30068
- return typeof text2 === "string" && text2.trim() ? text2 : void 0;
30621
+ const text3 = rec8(args)?.text ?? parseArguments(args).text;
30622
+ return typeof text3 === "string" && text3.trim() ? text3 : void 0;
30069
30623
  }
30070
30624
  var DELIVERY_COMPLETE = "codex:code-mode-delivery:v1:complete";
30071
30625
  var DELIVERY_INCOMPLETE = "codex:code-mode-delivery:v1:incomplete:";
@@ -30073,16 +30627,16 @@ function deliveredMessage(line2) {
30073
30627
  const marker = str10(rec8(line2.metadata)?.delivered_assistant_message);
30074
30628
  const p = rec8(line2.payload);
30075
30629
  if (!marker || !p || p.type !== "message" || p.role !== "assistant") return void 0;
30076
- let text2 = "";
30077
- if (marker === DELIVERY_COMPLETE) text2 = contentText(p.content).text;
30078
- else if (marker.startsWith(DELIVERY_INCOMPLETE)) text2 = marker.slice(DELIVERY_INCOMPLETE.length);
30079
- if (!text2.trim()) return void 0;
30630
+ let text3 = "";
30631
+ if (marker === DELIVERY_COMPLETE) text3 = contentText(p.content).text;
30632
+ else if (marker.startsWith(DELIVERY_INCOMPLETE)) text3 = marker.slice(DELIVERY_INCOMPLETE.length);
30633
+ if (!text3.trim()) return void 0;
30080
30634
  const id = str10(p.id);
30081
- return id ? { id, text: text2 } : { text: text2 };
30635
+ return id ? { id, text: text3 } : { text: text3 };
30082
30636
  }
30083
- function describeCodexPrompt(text2) {
30084
- const shown2 = truncate(maskSecrets(text2.slice(0, 1e3)), 34);
30085
- return { ...describePrompt(text2), text: truncate(tr("Recebeu \u201C{0}\u201D", [shown2]), 46) };
30637
+ function describeCodexPrompt(text3) {
30638
+ const shown2 = truncate(maskSecrets(text3.slice(0, 1e3)), 34);
30639
+ return { ...describePrompt(text3), text: truncate(tr("Recebeu \u201C{0}\u201D", [shown2]), 46) };
30086
30640
  }
30087
30641
  var PLAN_STATUS = /* @__PURE__ */ new Set(["pending", "in_progress", "completed"]);
30088
30642
  function planTasks(args) {
@@ -30180,15 +30734,15 @@ function contentText(content) {
30180
30734
  return { text: texts.join(""), images };
30181
30735
  }
30182
30736
  function promptText(raw) {
30183
- const text2 = raw.trim();
30184
- if (!text2 || INJECTED.test(text2)) return "";
30185
- return text2;
30737
+ const text3 = raw.trim();
30738
+ if (!text3 || INJECTED.test(text3)) return "";
30739
+ return text3;
30186
30740
  }
30187
30741
  function outputOf(raw) {
30188
30742
  if (typeof raw === "string") {
30189
30743
  try {
30190
30744
  const j = rec8(JSON.parse(raw));
30191
- if (j && typeof j.output === "string") return { text: j.output, exitCode: num7(rec8(j.metadata)?.exit_code) };
30745
+ if (j && typeof j.output === "string") return { text: j.output, exitCode: num8(rec8(j.metadata)?.exit_code) };
30192
30746
  } catch {
30193
30747
  }
30194
30748
  const exit = /^Exit code:\s*(-?\d+)/m.exec(raw.slice(0, 500))?.[1];
@@ -30223,7 +30777,7 @@ var RolloutLineParser = class {
30223
30777
  * mais a posição dentro da linha. Uma releitura do arquivo gera as mesmas chaves (o Office não duplica).
30224
30778
  */
30225
30779
  autoKey() {
30226
- const ordinal = num7(this.j.ordinal);
30780
+ const ordinal = num8(this.j.ordinal);
30227
30781
  const base = ordinal !== void 0 ? `o${ordinal}` : `t${this.at.toString(36)}`;
30228
30782
  const n2 = this.autoKeys++;
30229
30783
  return n2 ? `${base}:${n2}` : base;
@@ -30293,7 +30847,7 @@ var RolloutLineParser = class {
30293
30847
  case "task_complete":
30294
30848
  case "turn_complete": {
30295
30849
  this.endTurn(false);
30296
- const ms = num7(p.duration_ms);
30850
+ const ms = num8(p.duration_ms);
30297
30851
  const err = rec8(p.error);
30298
30852
  const turn = str10(p.turn_id) ?? this.autoKey();
30299
30853
  if (err) this.push(SPECIAL.error(void 0, firstLine3(str10(err.message) ?? "")), { key: `${turn}:err`, current: false });
@@ -30316,8 +30870,8 @@ var RolloutLineParser = class {
30316
30870
  case "agent_message": {
30317
30871
  if (this.paginated()) return;
30318
30872
  this.s.mode ??= "legacy";
30319
- const text2 = str10(p.message);
30320
- if (text2) this.push(SPECIAL.respond(text2));
30873
+ const text3 = str10(p.message);
30874
+ if (text3) this.push(SPECIAL.respond(text3));
30321
30875
  this.progress();
30322
30876
  return;
30323
30877
  }
@@ -30326,7 +30880,7 @@ var RolloutLineParser = class {
30326
30880
  return this.think();
30327
30881
  case "exec_command_end":
30328
30882
  if (this.paginated()) return;
30329
- return this.command({ id: str10(p.call_id), command: p.command, exitCode: num7(p.exit_code), output: str10(p.aggregated_output) ?? str10(p.formatted_output) ?? str10(p.stdout) ?? "", status: str10(p.status) });
30883
+ return this.command({ id: str10(p.call_id), command: p.command, exitCode: num8(p.exit_code), output: str10(p.aggregated_output) ?? str10(p.formatted_output) ?? str10(p.stdout) ?? "", status: str10(p.status) });
30330
30884
  case "patch_apply_end":
30331
30885
  if (this.paginated()) return;
30332
30886
  return this.fileChange(str10(p.call_id), p.changes, p.success === false ? "failed" : str10(p.status));
@@ -30354,8 +30908,8 @@ var RolloutLineParser = class {
30354
30908
  tokens(p) {
30355
30909
  const total2 = rec8(rec8(p.info)?.total_token_usage);
30356
30910
  if (total2) {
30357
- const tin = num7(total2.input_tokens) ?? 0;
30358
- const tout = num7(total2.output_tokens) ?? 0;
30911
+ const tin = num8(total2.input_tokens) ?? 0;
30912
+ const tout = num8(total2.output_tokens) ?? 0;
30359
30913
  if (tin !== this.s.stats.tokensIn || tout !== this.s.stats.tokensOut) {
30360
30914
  this.s.stats.tokensIn = tin;
30361
30915
  this.s.stats.tokensOut = tout;
@@ -30377,13 +30931,13 @@ var RolloutLineParser = class {
30377
30931
  this.push(SPECIAL.think(), { key });
30378
30932
  }
30379
30933
  prompt(raw, images, key) {
30380
- const text2 = promptText(raw) || (images ? tr("[imagem]") : "");
30381
- if (!text2) return;
30934
+ const text3 = promptText(raw) || (images ? tr("[imagem]") : "");
30935
+ if (!text3) return;
30382
30936
  if (this.s.title === void 0) {
30383
- this.s.title = truncate(maskSecrets(text2.slice(0, 1e3)), TITLE_MAX2);
30937
+ this.s.title = truncate(maskSecrets(text3.slice(0, 1e3)), TITLE_MAX2);
30384
30938
  this.changed();
30385
30939
  }
30386
- this.push(describeCodexPrompt(text2), { key });
30940
+ this.push(describeCodexPrompt(text3), { key });
30387
30941
  }
30388
30942
  // ---------------------------------------------------------------- item_completed (paginated)
30389
30943
  item(item) {
@@ -30392,13 +30946,13 @@ var RolloutLineParser = class {
30392
30946
  switch (item.type) {
30393
30947
  case "UserMessage": {
30394
30948
  this.sawPaginated();
30395
- const { text: text2, images } = contentText(item.content);
30396
- return this.prompt(text2, images, id);
30949
+ const { text: text3, images } = contentText(item.content);
30950
+ return this.prompt(text3, images, id);
30397
30951
  }
30398
30952
  case "AgentMessage": {
30399
30953
  this.sawPaginated();
30400
- const text2 = contentText(item.content).text.trim();
30401
- if (text2) this.push(SPECIAL.respond(text2), { key: id });
30954
+ const text3 = contentText(item.content).text.trim();
30955
+ if (text3) this.push(SPECIAL.respond(text3), { key: id });
30402
30956
  this.progress();
30403
30957
  return;
30404
30958
  }
@@ -30410,7 +30964,7 @@ var RolloutLineParser = class {
30410
30964
  this.sawPaginated();
30411
30965
  this.s.stats.toolCalls++;
30412
30966
  this.changed();
30413
- return this.command({ id, command: item.command, exitCode: num7(item.exit_code), output: str10(item.aggregated_output) ?? "", status: str10(item.status) });
30967
+ return this.command({ id, command: item.command, exitCode: num8(item.exit_code), output: str10(item.aggregated_output) ?? "", status: str10(item.status) });
30414
30968
  case "FileChange":
30415
30969
  this.sawPaginated();
30416
30970
  this.s.stats.toolCalls++;
@@ -30836,7 +31390,7 @@ function rec9(v) {
30836
31390
  function str11(v) {
30837
31391
  return typeof v === "string" && v.trim() ? v : void 0;
30838
31392
  }
30839
- function num8(v) {
31393
+ function num9(v) {
30840
31394
  return typeof v === "number" && Number.isFinite(v) ? v : void 0;
30841
31395
  }
30842
31396
  function toMs4(v) {
@@ -30929,19 +31483,19 @@ var CodexTerminalParser = class {
30929
31483
  user(id, at, raw, images = 0) {
30930
31484
  const clean4 = promptText(raw);
30931
31485
  const pics = images ? Array.from({ length: Math.min(images, 10) }, () => tr("[imagem]")).join(" ") : "";
30932
- const text2 = marked(prepare([clean4, pics].filter(Boolean).join("\n"), TEXT_MAX));
30933
- if (text2) this.emit({ kind: "user", id: `${id}:u`, at, text: text2 });
31486
+ const text3 = marked(prepare([clean4, pics].filter(Boolean).join("\n"), TEXT_MAX));
31487
+ if (text3) this.emit({ kind: "user", id: `${id}:u`, at, text: text3 });
30934
31488
  }
30935
31489
  assistant(id, at, raw) {
30936
- const text2 = marked(prepare(raw, TEXT_MAX));
30937
- if (text2) this.emit({ kind: "assistant", id, at, text: text2 });
31490
+ const text3 = marked(prepare(raw, TEXT_MAX));
31491
+ if (text3) this.emit({ kind: "assistant", id, at, text: text3 });
30938
31492
  }
30939
31493
  thinking(id, at, raw) {
30940
- const text2 = raw.trim() ? marked(prepare(raw, THINKING_MAX)) : "";
30941
- this.emit(text2 ? { kind: "thinking", id, at, text: text2 } : { kind: "thinking", id, at });
31494
+ const text3 = raw.trim() ? marked(prepare(raw, THINKING_MAX)) : "";
31495
+ this.emit(text3 ? { kind: "thinking", id, at, text: text3 } : { kind: "thinking", id, at });
30942
31496
  }
30943
- sys(id, at, text2, o = {}) {
30944
- const e = { kind: "system", id: `${id}:s`, at, text: maskSecrets(text2), level: o.level ?? "info" };
31497
+ sys(id, at, text3, o = {}) {
31498
+ const e = { kind: "system", id: `${id}:s`, at, text: maskSecrets(text3), level: o.level ?? "info" };
30945
31499
  if (o.turnDone) {
30946
31500
  e.turnDone = true;
30947
31501
  e.doneLabel = tr("pronto {0}", ["{0}"]);
@@ -30974,7 +31528,7 @@ var CodexTerminalParser = class {
30974
31528
  return this.item(rec9(p.item), at, key);
30975
31529
  case "task_complete":
30976
31530
  case "turn_complete": {
30977
- const ms = num8(p.duration_ms);
31531
+ const ms = num9(p.duration_ms);
30978
31532
  const err = rec9(p.error);
30979
31533
  if (err) this.sys(`${str11(p.turn_id) ?? key}:err`, at, tr("Erro: {0}", [oneLine(str11(err.message) ?? tr("desconhecido"), 160)]), { level: "error" });
30980
31534
  if (ms !== void 0 && ms >= 0) this.sys(`${str11(p.turn_id) ?? key}:done`, at, tr("Turno conclu\xEDdo em {0}", [formatDuration(ms)]), { turnDone: true });
@@ -30997,7 +31551,7 @@ var CodexTerminalParser = class {
30997
31551
  return this.thinking(key, at, str11(p.text) ?? "");
30998
31552
  case "exec_command_end":
30999
31553
  if (this.mode === "paginated") return;
31000
- return this.command(str11(p.call_id) ?? key, at, p.command, str11(p.aggregated_output) ?? str11(p.formatted_output) ?? str11(p.stdout) ?? "", num8(p.exit_code), str11(p.status));
31554
+ return this.command(str11(p.call_id) ?? key, at, p.command, str11(p.aggregated_output) ?? str11(p.formatted_output) ?? str11(p.stdout) ?? "", num9(p.exit_code), str11(p.status));
31001
31555
  case "context_compacted":
31002
31556
  if (this.mode === "paginated") return;
31003
31557
  return this.sys(key, at, tr("Conversa compactada"));
@@ -31011,8 +31565,8 @@ var CodexTerminalParser = class {
31011
31565
  switch (item.type) {
31012
31566
  case "UserMessage": {
31013
31567
  this.mode ??= "paginated";
31014
- const { text: text2, images } = contentText(item.content);
31015
- return this.user(id, at, text2, images);
31568
+ const { text: text3, images } = contentText(item.content);
31569
+ return this.user(id, at, text3, images);
31016
31570
  }
31017
31571
  case "AgentMessage":
31018
31572
  this.mode ??= "paginated";
@@ -31024,7 +31578,7 @@ var CodexTerminalParser = class {
31024
31578
  }
31025
31579
  case "CommandExecution":
31026
31580
  this.mode ??= "paginated";
31027
- return this.command(id, at, item.command, str11(item.aggregated_output) ?? "", num8(item.exit_code), str11(item.status));
31581
+ return this.command(id, at, item.command, str11(item.aggregated_output) ?? "", num9(item.exit_code), str11(item.status));
31028
31582
  case "FileChange":
31029
31583
  this.mode ??= "paginated";
31030
31584
  return this.fileChange(id, at, item.changes, str11(item.status));
@@ -31059,8 +31613,8 @@ var CodexTerminalParser = class {
31059
31613
  this.tool(id, at, "Bash", toolView("Bash", { command }, this.cwd));
31060
31614
  if (status2 === "declined") return this.result(id, at, tr("Recusado pelo usu\xE1rio"), true);
31061
31615
  const failed = status2 === "failed" || exitCode !== void 0 && exitCode !== 0;
31062
- const text2 = failed && exitCode !== void 0 && exitCode !== 0 ? tr("C\xF3digo de sa\xEDda {0}\n{1}", [exitCode, output]) : output;
31063
- this.result(id, at, text2, failed);
31616
+ const text3 = failed && exitCode !== void 0 && exitCode !== 0 ? tr("C\xF3digo de sa\xEDda {0}\n{1}", [exitCode, output]) : output;
31617
+ this.result(id, at, text3, failed);
31064
31618
  }
31065
31619
  fileChange(id, at, raw, status2) {
31066
31620
  const changes = fileChanges(raw);
@@ -31108,9 +31662,9 @@ ${body2}`;
31108
31662
  case "custom_tool_call_output": {
31109
31663
  const id = str11(p.call_id);
31110
31664
  if (!id || !this.calls.has(id)) return;
31111
- const text2 = resultText2(p.output);
31112
- const exit = /^Exit code:\s*(-?\d+)/m.exec(text2.slice(0, 500))?.[1];
31113
- return this.result(id, at, text2, exit !== void 0 && exit !== "0");
31665
+ const text3 = resultText2(p.output);
31666
+ const exit = /^Exit code:\s*(-?\d+)/m.exec(text3.slice(0, 500))?.[1];
31667
+ return this.result(id, at, text3, exit !== void 0 && exit !== "0");
31114
31668
  }
31115
31669
  default:
31116
31670
  return;
@@ -32137,10 +32691,10 @@ async function scanPrefix2(path, end, idPrefix, keep) {
32137
32691
 
32138
32692
  // server/sources/gentle-shell/accounts.ts
32139
32693
  import { homedir as homedir6 } from "node:os";
32140
- import { basename as basename8, dirname as dirname11, join as join23, resolve as resolve10 } from "node:path";
32694
+ import { basename as basename8, dirname as dirname12, join as join23, resolve as resolve10 } from "node:path";
32141
32695
 
32142
32696
  // server/sources/gentle-shell/files.ts
32143
- import { closeSync as closeSync5, openSync as openSync5, readdirSync as readdirSync14, readFileSync as readFileSync18, readSync as readSync5, statSync as statSync20 } from "node:fs";
32697
+ import { closeSync as closeSync5, openSync as openSync5, readdirSync as readdirSync14, readFileSync as readFileSync19, readSync as readSync5, statSync as statSync20 } from "node:fs";
32144
32698
  import { join as join22 } from "node:path";
32145
32699
 
32146
32700
  // server/sources/gentle-shell/pi.ts
@@ -32150,7 +32704,7 @@ function rec11(v) {
32150
32704
  function str13(v) {
32151
32705
  return typeof v === "string" && v.trim() ? v : void 0;
32152
32706
  }
32153
- function num9(v) {
32707
+ function num10(v) {
32154
32708
  return typeof v === "number" && Number.isFinite(v) ? v : void 0;
32155
32709
  }
32156
32710
  function toMs5(v) {
@@ -32186,7 +32740,7 @@ function todoTasks(raw) {
32186
32740
  const t = rec11(r);
32187
32741
  const title = str13(t?.title);
32188
32742
  if (!t || !title) return;
32189
- out.push({ id: String(num9(t.id) ?? str13(t.id) ?? i + 1), title: truncate(maskSecrets(title.slice(0, 480)), 120), status: todoStatus(t.status) });
32743
+ out.push({ id: String(num10(t.id) ?? str13(t.id) ?? i + 1), title: truncate(maskSecrets(title.slice(0, 480)), 120), status: todoStatus(t.status) });
32190
32744
  });
32191
32745
  return out;
32192
32746
  }
@@ -32301,8 +32855,8 @@ var PiLineParser = class {
32301
32855
  }
32302
32856
  }
32303
32857
  user(id, m) {
32304
- const { text: text2, images } = contentText2(m.content);
32305
- const clean4 = text2.trim() || (images ? tr("[imagem]") : "");
32858
+ const { text: text3, images } = contentText2(m.content);
32859
+ const clean4 = text3.trim() || (images ? tr("[imagem]") : "");
32306
32860
  this.s.turnOpen = true;
32307
32861
  this.s.turnStartAt = this.at;
32308
32862
  this.s.pending.clear();
@@ -32326,8 +32880,8 @@ var PiLineParser = class {
32326
32880
  if (cur?.kind === "think" && this.at - cur.at < 3e4) return;
32327
32881
  this.push(SPECIAL.think(), `${id}:t${i}`);
32328
32882
  } else if (part.type === "text") {
32329
- const text2 = str13(part.text)?.trim();
32330
- if (text2) this.push(SPECIAL.respond(text2), `${id}:x${i}`);
32883
+ const text3 = str13(part.text)?.trim();
32884
+ if (text3) this.push(SPECIAL.respond(text3), `${id}:x${i}`);
32331
32885
  } else if (part.type === "toolCall") {
32332
32886
  this.toolCall(id, i, part);
32333
32887
  }
@@ -32348,9 +32902,9 @@ var PiLineParser = class {
32348
32902
  }
32349
32903
  usage(u) {
32350
32904
  if (!u) return;
32351
- const tin = (num9(u.input) ?? 0) + (num9(u.cacheRead) ?? 0) + (num9(u.cacheWrite) ?? 0);
32352
- const tout = num9(u.output) ?? 0;
32353
- const cost = num9(rec11(u.cost)?.total);
32905
+ const tin = (num10(u.input) ?? 0) + (num10(u.cacheRead) ?? 0) + (num10(u.cacheWrite) ?? 0);
32906
+ const tout = num10(u.output) ?? 0;
32907
+ const cost = num10(rec11(u.cost)?.total);
32354
32908
  this.s.stats.tokensIn += tin;
32355
32909
  this.s.stats.tokensOut += tout;
32356
32910
  if (cost !== void 0) this.s.stats.costUSD = (this.s.stats.costUSD ?? 0) + cost;
@@ -32438,8 +32992,8 @@ function parsePiHead(lines) {
32438
32992
  } else if (j.type === "message") {
32439
32993
  const m = rec11(j.message);
32440
32994
  if (m?.role !== "user") continue;
32441
- const { text: text2, images } = contentText2(m.content);
32442
- const clean4 = text2.trim() || (images ? tr("[imagem]") : "");
32995
+ const { text: text3, images } = contentText2(m.content);
32996
+ const clean4 = text3.trim() || (images ? tr("[imagem]") : "");
32443
32997
  if (clean4) {
32444
32998
  head.title = truncate(maskSecrets(clean4.slice(0, 1e3)), TITLE_MAX3);
32445
32999
  break;
@@ -32479,7 +33033,7 @@ function parseSessionFileName(name) {
32479
33033
  function readJson2(path, max) {
32480
33034
  try {
32481
33035
  if (statSync20(path).size > max) return void 0;
32482
- return JSON.parse(readFileSync18(path, "utf8"));
33036
+ return JSON.parse(readFileSync19(path, "utf8"));
32483
33037
  } catch {
32484
33038
  return void 0;
32485
33039
  }
@@ -32582,9 +33136,9 @@ function readFirstLine(path, max) {
32582
33136
  try {
32583
33137
  const buf = Buffer.alloc(max);
32584
33138
  const n2 = readSync5(fd, buf, 0, max, 0);
32585
- const text2 = buf.subarray(0, n2).toString("utf8");
32586
- const nl = text2.indexOf("\n");
32587
- return nl === -1 ? n2 < max ? text2 : void 0 : text2.slice(0, nl);
33139
+ const text3 = buf.subarray(0, n2).toString("utf8");
33140
+ const nl = text3.indexOf("\n");
33141
+ return nl === -1 ? n2 < max ? text3 : void 0 : text3.slice(0, nl);
32588
33142
  } finally {
32589
33143
  closeSync5(fd);
32590
33144
  }
@@ -32686,7 +33240,7 @@ function discoverGentleShellDirs(env = process.env, home = env.HOME || homedir6(
32686
33240
  function baseId(dir) {
32687
33241
  const d = resolve10(dir);
32688
33242
  const name = basename8(d);
32689
- if (name === "agent") return basename8(dirname11(d)) || name;
33243
+ if (name === "agent") return basename8(dirname12(d)) || name;
32690
33244
  return name || d;
32691
33245
  }
32692
33246
  function detectGentleShellAccounts(dirs, opts = {}) {
@@ -32782,9 +33336,9 @@ var GentleShellTerminalParser = class {
32782
33336
  if (m.role === "toolResult") return this.result(id, at, m);
32783
33337
  }
32784
33338
  user(id, at, m) {
32785
- const { text: text2, images } = contentText2(m.content);
33339
+ const { text: text3, images } = contentText2(m.content);
32786
33340
  const pics = images ? Array.from({ length: Math.min(images, 10) }, () => tr("[imagem]")).join(" ") : "";
32787
- const shown2 = marked(prepare([text2.trim(), pics].filter(Boolean).join("\n"), TEXT_MAX));
33341
+ const shown2 = marked(prepare([text3.trim(), pics].filter(Boolean).join("\n"), TEXT_MAX));
32788
33342
  if (shown2) this.emit({ kind: "user", id: `${id}:u`, at, text: shown2 });
32789
33343
  }
32790
33344
  assistant(id, at, m) {
@@ -32793,11 +33347,11 @@ var GentleShellTerminalParser = class {
32793
33347
  const part = rec11(raw);
32794
33348
  if (!part) return;
32795
33349
  if (part.type === "thinking") {
32796
- const text2 = str14(part.thinking)?.trim() ? marked(prepare(String(part.thinking), THINKING_MAX)) : "";
32797
- this.emit(text2 ? { kind: "thinking", id: `${id}:t${i}`, at, text: text2 } : { kind: "thinking", id: `${id}:t${i}`, at });
33350
+ const text3 = str14(part.thinking)?.trim() ? marked(prepare(String(part.thinking), THINKING_MAX)) : "";
33351
+ this.emit(text3 ? { kind: "thinking", id: `${id}:t${i}`, at, text: text3 } : { kind: "thinking", id: `${id}:t${i}`, at });
32798
33352
  } else if (part.type === "text") {
32799
- const text2 = marked(prepare(String(part.text ?? ""), TEXT_MAX));
32800
- if (text2) this.emit({ kind: "assistant", id: `${id}:x${i}`, at, text: text2 });
33353
+ const text3 = marked(prepare(String(part.text ?? ""), TEXT_MAX));
33354
+ if (text3) this.emit({ kind: "assistant", id: `${id}:x${i}`, at, text: text3 });
32801
33355
  } else if (part.type === "toolCall") {
32802
33356
  const name = str14(part.name);
32803
33357
  if (!name) return;
@@ -33206,9 +33760,9 @@ var GentleShellSource = class {
33206
33760
  };
33207
33761
 
33208
33762
  // server/sources/agent-hub/source.ts
33209
- import { closeSync as closeSync6, lstatSync as lstatSync2, openSync as openSync6, readFileSync as readFileSync20, readSync as readSync6, readdirSync as readdirSync15 } from "node:fs";
33763
+ import { closeSync as closeSync6, lstatSync as lstatSync2, openSync as openSync6, readFileSync as readFileSync21, readSync as readSync6, readdirSync as readdirSync15 } from "node:fs";
33210
33764
  import { lstat, readdir as readdir3 } from "node:fs/promises";
33211
- import { basename as basename9, dirname as dirname12, isAbsolute as isAbsolute5, join as join26, resolve as resolve12 } from "node:path";
33765
+ import { basename as basename9, dirname as dirname13, isAbsolute as isAbsolute5, join as join26, resolve as resolve12 } from "node:path";
33212
33766
 
33213
33767
  // server/sources/agent-hub/events/agy.ts
33214
33768
  function object(value) {
@@ -33359,18 +33913,18 @@ function adaptCopilotEvent(line2, offset) {
33359
33913
  }
33360
33914
 
33361
33915
  // server/sources/agent-hub/events/plain.ts
33362
- function adaptPlainChunk(text2, offset, at = Date.now()) {
33363
- if (!text2.trim()) return void 0;
33364
- return { id: `offset:${offset}`, at, ...SPECIAL.respond(text2) };
33916
+ function adaptPlainChunk(text3, offset, at = Date.now()) {
33917
+ if (!text3.trim()) return void 0;
33918
+ return { id: `offset:${offset}`, at, ...SPECIAL.respond(text3) };
33365
33919
  }
33366
- function adaptAgentHubEvent(agent, text2, offset) {
33367
- if (agent === "copilot") return adaptCopilotEvent(text2, offset);
33368
- if (agent === "agy") return adaptAgyEvent(text2, offset);
33369
- return adaptPlainChunk(text2, offset);
33920
+ function adaptAgentHubEvent(agent, text3, offset) {
33921
+ if (agent === "copilot") return adaptCopilotEvent(text3, offset);
33922
+ if (agent === "agy") return adaptAgyEvent(text3, offset);
33923
+ return adaptPlainChunk(text3, offset);
33370
33924
  }
33371
33925
 
33372
33926
  // server/sources/agent-hub/terminal.ts
33373
- import { lstatSync, readFileSync as readFileSync19 } from "node:fs";
33927
+ import { lstatSync, readFileSync as readFileSync20 } from "node:fs";
33374
33928
  import { join as join25 } from "node:path";
33375
33929
  var SEEN_MAX5 = 2e4;
33376
33930
  var MAX_PROMPT_BYTES = 128 * 1024;
@@ -33393,7 +33947,7 @@ function readPrompt(jobDir) {
33393
33947
  try {
33394
33948
  const st = lstatSync(path);
33395
33949
  if (!st.isFile() || st.size > MAX_PROMPT_BYTES) return void 0;
33396
- return readFileSync19(path, "utf8").trim() || void 0;
33950
+ return readFileSync20(path, "utf8").trim() || void 0;
33397
33951
  } catch {
33398
33952
  return void 0;
33399
33953
  }
@@ -33404,7 +33958,7 @@ function readResponse(jobDir) {
33404
33958
  try {
33405
33959
  const st = lstatSync(path);
33406
33960
  if (!st.isFile() || st.size > MAX_RESPONSE_BYTES) return void 0;
33407
- return readFileSync19(path, "utf8").trim() || void 0;
33961
+ return readFileSync20(path, "utf8").trim() || void 0;
33408
33962
  } catch {
33409
33963
  return void 0;
33410
33964
  }
@@ -33516,15 +34070,15 @@ var AgentHubTerminalParser = class {
33516
34070
  }
33517
34071
  if (type === "tool.execution_complete") {
33518
34072
  const callId = str15(data.toolCallId) ?? id;
33519
- let text2 = "";
34073
+ let text3 = "";
33520
34074
  const res = data.result;
33521
34075
  if (typeof res === "string") {
33522
- text2 = res;
34076
+ text3 = res;
33523
34077
  } else if (rec12(res)) {
33524
34078
  const r = res;
33525
- text2 = str15(r.content) ?? str15(r.output) ?? str15(r.text) ?? JSON.stringify(r);
34079
+ text3 = str15(r.content) ?? str15(r.output) ?? str15(r.text) ?? JSON.stringify(r);
33526
34080
  }
33527
- const p = prepare(text2, RESULT_MAX, RESULT_MAX_LINES);
34081
+ const p = prepare(text3, RESULT_MAX, RESULT_MAX_LINES);
33528
34082
  const entry = {
33529
34083
  kind: "result",
33530
34084
  id: `${callId}:r`,
@@ -33660,10 +34214,10 @@ var AgentHubTerminalParser = class {
33660
34214
  }
33661
34215
  }
33662
34216
  plain(raw) {
33663
- const text2 = raw.trim();
33664
- if (!text2) return;
34217
+ const text3 = raw.trim();
34218
+ if (!text3) return;
33665
34219
  const at = this.lastAt || this.now();
33666
- const p = prepare(text2, TEXT_MAX);
34220
+ const p = prepare(text3, TEXT_MAX);
33667
34221
  this.emit({
33668
34222
  kind: "assistant",
33669
34223
  id: `plain:${++this.seq}`,
@@ -33717,7 +34271,7 @@ function readPrompt2(jobDir) {
33717
34271
  try {
33718
34272
  const st = lstatSync2(path);
33719
34273
  if (!st.isFile() || st.size > MAX_PROMPT_BYTES2) return void 0;
33720
- return str16(readFileSync20(path, "utf8"));
34274
+ return str16(readFileSync21(path, "utf8"));
33721
34275
  } catch {
33722
34276
  return void 0;
33723
34277
  }
@@ -33839,7 +34393,7 @@ function deriveProject(cwd, repoRoot, repoName) {
33839
34393
  try {
33840
34394
  const st = lstatSync2(gitPath);
33841
34395
  if (st.isFile()) {
33842
- const content = readFileSync20(gitPath, "utf8");
34396
+ const content = readFileSync21(gitPath, "utf8");
33843
34397
  const match = /^gitdir:\s*(.+)$/m.exec(content);
33844
34398
  if (match) {
33845
34399
  let gitDir = match[1].trim();
@@ -33847,9 +34401,9 @@ function deriveProject(cwd, repoRoot, repoName) {
33847
34401
  gitDir = resolve12(candidate, gitDir);
33848
34402
  }
33849
34403
  try {
33850
- const commonRel = readFileSync20(join26(gitDir, "commondir"), "utf8").trim();
34404
+ const commonRel = readFileSync21(join26(gitDir, "commondir"), "utf8").trim();
33851
34405
  const commonDir = resolve12(gitDir, commonRel);
33852
- return basename9(dirname12(commonDir));
34406
+ return basename9(dirname13(commonDir));
33853
34407
  } catch {
33854
34408
  const wtMatch = /^(.*)[/\\]\.git[/\\]worktrees[/\\][^/\\]+$/.exec(gitDir);
33855
34409
  if (wtMatch) {
@@ -33980,7 +34534,7 @@ var AgentHubSource = class {
33980
34534
  if (!cached || cached.mtimeMs !== file.mtimeMs || cached.size !== file.size) {
33981
34535
  let job2;
33982
34536
  try {
33983
- job2 = parseJob(readFileSync20(file.path, "utf8"), file.name, file.mtimeMs, join26(this.opts.runsDir, file.name));
34537
+ job2 = parseJob(readFileSync21(file.path, "utf8"), file.name, file.mtimeMs, join26(this.opts.runsDir, file.name));
33984
34538
  } catch {
33985
34539
  job2 = void 0;
33986
34540
  }
@@ -34184,9 +34738,9 @@ var AgentHubSource = class {
34184
34738
  if (activity) this.addOutputActivity(tracker, id, activity);
34185
34739
  }
34186
34740
  } else if (lines.length) {
34187
- const text2 = `${lines.map(({ line: line2 }) => line2).join("\n")}
34741
+ const text3 = `${lines.map(({ line: line2 }) => line2).join("\n")}
34188
34742
  `;
34189
- const activity = adaptPlainChunk(text2, lines[0].offset, this.now());
34743
+ const activity = adaptPlainChunk(text3, lines[0].offset, this.now());
34190
34744
  if (activity) this.addOutputActivity(tracker, id, activity);
34191
34745
  }
34192
34746
  } catch {
@@ -34224,7 +34778,7 @@ var AgentHubSource = class {
34224
34778
  };
34225
34779
 
34226
34780
  // server/build.ts
34227
- import { readFileSync as readFileSync21, statSync as statSync21 } from "node:fs";
34781
+ import { readFileSync as readFileSync22, statSync as statSync21 } from "node:fs";
34228
34782
  import { join as join27 } from "node:path";
34229
34783
  var BUNDLE = /bundle\/(main-[\w-]+)\.js/;
34230
34784
  function createBuildReader(rootDir) {
@@ -34236,7 +34790,7 @@ function createBuildReader(rootDir) {
34236
34790
  const m = statSync21(file).mtimeMs;
34237
34791
  if (m !== mtime) {
34238
34792
  mtime = m;
34239
- id = BUNDLE.exec(readFileSync21(file, "utf8"))?.[1];
34793
+ id = BUNDLE.exec(readFileSync22(file, "utf8"))?.[1];
34240
34794
  }
34241
34795
  } catch {
34242
34796
  mtime = -1;
@@ -34248,7 +34802,7 @@ function createBuildReader(rootDir) {
34248
34802
  var UNKNOWN = { commit: "unknown", dirty: false };
34249
34803
  function readBuildInfo(rootDir) {
34250
34804
  try {
34251
- const raw = JSON.parse(readFileSync21(join27(rootDir, "dist", "build.json"), "utf8"));
34805
+ const raw = JSON.parse(readFileSync22(join27(rootDir, "dist", "build.json"), "utf8"));
34252
34806
  if (typeof raw.commit !== "string" || !/^([0-9a-f]{40}([0-9a-f]{24})?|unknown)$/.test(raw.commit) || typeof raw.dirty !== "boolean") return { ...UNKNOWN };
34253
34807
  const stamp2 = { commit: raw.commit, dirty: raw.dirty };
34254
34808
  if (typeof raw.builtAt === "string" && raw.builtAt.length <= 40) stamp2.builtAt = raw.builtAt;
@@ -34259,8 +34813,8 @@ function readBuildInfo(rootDir) {
34259
34813
  }
34260
34814
 
34261
34815
  // server/updates/checker.ts
34262
- import { mkdirSync as mkdirSync13, readFileSync as readFileSync22, renameSync as renameSync12, writeFileSync as writeFileSync12 } from "node:fs";
34263
- import { dirname as dirname13 } from "node:path";
34816
+ import { mkdirSync as mkdirSync14, readFileSync as readFileSync23, renameSync as renameSync13, writeFileSync as writeFileSync13 } from "node:fs";
34817
+ import { dirname as dirname14 } from "node:path";
34264
34818
 
34265
34819
  // server/updates/npm.ts
34266
34820
  var NPM_PACKAGE = "busybits";
@@ -34372,7 +34926,7 @@ var UpdateChecker = class {
34372
34926
  const pkg = this.opts.package;
34373
34927
  if (!this.opts.file || !this.enabled || !pkg) return;
34374
34928
  try {
34375
- const j = JSON.parse(readFileSync22(this.opts.file, "utf8"));
34929
+ const j = JSON.parse(readFileSync23(this.opts.file, "utf8"));
34376
34930
  if (j.package !== pkg || typeof j.checkedAt !== "number" || !Number.isFinite(j.checkedAt)) return;
34377
34931
  const latest = typeof j.latest === "string" && parseVersion(j.latest) ? j.latest : void 0;
34378
34932
  this.cache = {
@@ -34458,11 +35012,11 @@ var UpdateChecker = class {
34458
35012
  const file = this.opts.file;
34459
35013
  if (!file || !this.cache) return;
34460
35014
  try {
34461
- mkdirSync13(dirname13(file), { recursive: true });
35015
+ mkdirSync14(dirname14(file), { recursive: true });
34462
35016
  const tmp = `${file}.tmp`;
34463
- writeFileSync12(tmp, `${JSON.stringify(this.cache, null, 2)}
35017
+ writeFileSync13(tmp, `${JSON.stringify(this.cache, null, 2)}
34464
35018
  `);
34465
- renameSync12(tmp, file);
35019
+ renameSync13(tmp, file);
34466
35020
  } catch (err) {
34467
35021
  log.warnOnce("updates:save", tr("N\xE3o deu para gravar {0}: {1}.", [file, errMsg(err)]));
34468
35022
  }
@@ -34488,11 +35042,11 @@ function describeError(err) {
34488
35042
  }
34489
35043
 
34490
35044
  // server/updates/apply.ts
34491
- import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync15 } from "node:fs";
34492
- import { dirname as dirname14, join as join29 } from "node:path";
35045
+ import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync16 } from "node:fs";
35046
+ import { dirname as dirname15, join as join29 } from "node:path";
34493
35047
 
34494
35048
  // scripts/cli/layout.ts
34495
- import { cpSync, existsSync as existsSync11, mkdirSync as mkdirSync14, readdirSync as readdirSync16, readFileSync as readFileSync23, realpathSync as realpathSync6, renameSync as renameSync13, rmSync as rmSync6, statSync as statSync22, symlinkSync, writeFileSync as writeFileSync13 } from "node:fs";
35049
+ import { cpSync, existsSync as existsSync11, mkdirSync as mkdirSync15, readdirSync as readdirSync16, readFileSync as readFileSync24, realpathSync as realpathSync6, renameSync as renameSync14, rmSync as rmSync6, statSync as statSync22, symlinkSync, writeFileSync as writeFileSync14 } from "node:fs";
34496
35050
  import { isAbsolute as isAbsolute6, join as join28, relative as relative3, resolve as resolve13 } from "node:path";
34497
35051
  function layoutOf(dir) {
34498
35052
  return {
@@ -34508,7 +35062,7 @@ function layoutOf(dir) {
34508
35062
  }
34509
35063
  function readLockPid(l) {
34510
35064
  try {
34511
- const n2 = Number.parseInt(readFileSync23(l.lockFile, "utf8").trim(), 10);
35065
+ const n2 = Number.parseInt(readFileSync24(l.lockFile, "utf8").trim(), 10);
34512
35066
  return Number.isInteger(n2) && n2 > 0 ? n2 : void 0;
34513
35067
  } catch {
34514
35068
  return void 0;
@@ -34542,7 +35096,7 @@ async function startUpdate(o) {
34542
35096
  });
34543
35097
  if (failure) {
34544
35098
  try {
34545
- mkdirSync15(dirname14(o.layout.logFile), { recursive: true });
35099
+ mkdirSync16(dirname15(o.layout.logFile), { recursive: true });
34546
35100
  appendFileSync2(o.layout.logFile, `[${new Date(o.now ?? Date.now()).toISOString()}] could not start the update: ${failure.message}
34547
35101
  `);
34548
35102
  } catch {
@@ -34856,9 +35410,9 @@ var CONTROL3 = /[\x00-\x1f\x7f]/g;
34856
35410
  function clean3(s2, max) {
34857
35411
  return s2.replace(ANSI2, "").replace(CONTROL3, "").trim().slice(0, max);
34858
35412
  }
34859
- function parseJson2(text2) {
35413
+ function parseJson2(text3) {
34860
35414
  try {
34861
- return JSON.parse(text2);
35415
+ return JSON.parse(text3);
34862
35416
  } catch {
34863
35417
  return void 0;
34864
35418
  }
@@ -34891,8 +35445,8 @@ function createHerdrExec(bin, env, timeoutMs = HERDR_TIMEOUT_MS) {
34891
35445
  if (json !== void 0 && !errorOf(json)) return ok({ ok: true, json });
34892
35446
  const e2 = errorOf(json);
34893
35447
  if (e2) return ok({ ok: false, ...e2 });
34894
- const text2 = firstLine4(out, stderr);
34895
- return ok(text2 ? { ok: false, error: text2 } : { ok: false, error: tr("herdr: sa\xEDda inv\xE1lida"), code: "empty_output" });
35448
+ const text3 = firstLine4(out, stderr);
35449
+ return ok(text3 ? { ok: false, error: text3 } : { ok: false, error: tr("herdr: sa\xEDda inv\xE1lida"), code: "empty_output" });
34896
35450
  }
34897
35451
  const e = errorOf(parseJson2(stderr ?? "")) ?? errorOf(parseJson2(out ?? ""));
34898
35452
  if (e) return ok({ ok: false, ...e });
@@ -35031,8 +35585,8 @@ var HerdrClient = class {
35031
35585
  await this.call(["agent", "wait", paneId, "--until", "idle", "--until", "done", "--timeout", String(ms)], ms + TIMEOUT_SLACK_MS);
35032
35586
  }
35033
35587
  /** O texto vai depois de `--`: um pedido que começa com `-` não vira opção do herdr. */
35034
- async prompt(paneId, text2) {
35035
- await this.call(["agent", "prompt", paneId, text2]);
35588
+ async prompt(paneId, text3) {
35589
+ await this.call(["agent", "prompt", paneId, text3]);
35036
35590
  }
35037
35591
  /** Foca o agente do painel; se o herdr recusar, ao menos a aba. */
35038
35592
  async focus(pane) {
@@ -35176,17 +35730,17 @@ async function launchInHerdr(client, req, opts = {}) {
35176
35730
  };
35177
35731
  const takenNames = () => client.agentNames().catch(() => /* @__PURE__ */ new Set());
35178
35732
  const deliverToGentle = async (r, known, at) => {
35179
- const inbox = opts.inbox;
35180
- if (!inbox) return tr("o escrit\xF3rio n\xE3o tem a caixa de entrada de mensagens ligada");
35733
+ const inbox2 = opts.inbox;
35734
+ if (!inbox2) return tr("o escrit\xF3rio n\xE3o tem a caixa de entrada de mensagens ligada");
35181
35735
  const until = Math.min(now() + (opts.inboxWaitMs ?? INBOX_WAIT_MS), end);
35182
35736
  let why = tr("n\xE3o achei a sess\xE3o do Gentle Shell no escrit\xF3rio (a extens\xE3o habblaud-pi est\xE1 instalada e a sess\xE3o aberta?)");
35183
35737
  let wait = pollMs;
35184
35738
  for (; ; ) {
35185
35739
  if (state.over) return late2;
35186
35740
  try {
35187
- const agent = matchGentle(inbox.agents(), known, r.folder, at);
35741
+ const agent = matchGentle(inbox2.agents(), known, r.folder, at);
35188
35742
  if (agent) {
35189
- const res = inbox.send(agent.id, r.prompt);
35743
+ const res = inbox2.send(agent.id, r.prompt);
35190
35744
  if (res.ok) return void 0;
35191
35745
  why = res.reason;
35192
35746
  if (!res.retry) return why;
@@ -35343,8 +35897,8 @@ function startAttachmentsPruner(opts) {
35343
35897
  }
35344
35898
 
35345
35899
  // server/settings/attachments.ts
35346
- import { mkdirSync as mkdirSync16, readFileSync as readFileSync24, renameSync as renameSync14, writeFileSync as writeFileSync14 } from "node:fs";
35347
- import { dirname as dirname15 } from "node:path";
35900
+ import { mkdirSync as mkdirSync17, readFileSync as readFileSync25, renameSync as renameSync15, writeFileSync as writeFileSync15 } from "node:fs";
35901
+ import { dirname as dirname16 } from "node:path";
35348
35902
  var RETENTION_CHOICES = [1, 3, 7, 30];
35349
35903
  var DEFAULT_RETENTION_DAYS = 7;
35350
35904
  function parseRetention(raw) {
@@ -35372,7 +35926,7 @@ var AttachmentSettingsStore = class {
35372
35926
  load() {
35373
35927
  if (!this.file) return null;
35374
35928
  try {
35375
- return parseRetention(JSON.parse(readFileSync24(this.file, "utf8")));
35929
+ return parseRetention(JSON.parse(readFileSync25(this.file, "utf8")));
35376
35930
  } catch (err) {
35377
35931
  if (err.code !== "ENOENT") log.warn(tr("attachments.json ileg\xEDvel ({0}); usando o padr\xE3o de {1} dias.", [errMsg(err), DEFAULT_RETENTION_DAYS]));
35378
35932
  return null;
@@ -35381,9 +35935,9 @@ var AttachmentSettingsStore = class {
35381
35935
  save() {
35382
35936
  if (!this.file) return;
35383
35937
  try {
35384
- mkdirSync16(dirname15(this.file), { recursive: true });
35385
- writeFileSync14(`${this.file}.tmp`, JSON.stringify({ version: 1, ...this.current }, null, 2));
35386
- renameSync14(`${this.file}.tmp`, this.file);
35938
+ mkdirSync17(dirname16(this.file), { recursive: true });
35939
+ writeFileSync15(`${this.file}.tmp`, JSON.stringify({ version: 1, ...this.current }, null, 2));
35940
+ renameSync15(`${this.file}.tmp`, this.file);
35387
35941
  } catch (err) {
35388
35942
  log.warn(tr("N\xE3o consegui gravar {0}: {1}", [this.file, errMsg(err)]));
35389
35943
  }
@@ -35444,7 +35998,7 @@ function recentFolders(sessions, rooms, limit = FOLDERS_LIMIT) {
35444
35998
 
35445
35999
  // server/dictation/whisper.ts
35446
36000
  import { execFile as execFile6 } from "node:child_process";
35447
- import { existsSync as existsSync12, mkdtempSync as mkdtempSync2, readFileSync as readFileSync25, rmSync as rmSync8, writeFileSync as writeFileSync15 } from "node:fs";
36001
+ import { existsSync as existsSync12, mkdtempSync as mkdtempSync2, readFileSync as readFileSync26, rmSync as rmSync8, writeFileSync as writeFileSync16 } from "node:fs";
35448
36002
  import { homedir as homedir7, tmpdir } from "node:os";
35449
36003
  import { delimiter as delimiter2, join as join32 } from "node:path";
35450
36004
  var TRANSCRIBE_TIMEOUT_MS = 12e4;
@@ -35481,8 +36035,8 @@ function run2(bin, args, timeoutMs) {
35481
36035
  }
35482
36036
  function parseWhisperJson(raw) {
35483
36037
  const d = JSON.parse(raw);
35484
- const text2 = (d.transcription ?? []).map((t) => typeof t.text === "string" ? t.text : "").join(" ").replace(/\[(BLANK_AUDIO|MUSIC|Música|SILENCE)\]|\((?:silence|música|music)\)/gi, "").replace(/\s+/g, " ").trim();
35485
- return { text: text2, lang: typeof d.result?.language === "string" ? d.result.language : "" };
36038
+ const text3 = (d.transcription ?? []).map((t) => typeof t.text === "string" ? t.text : "").join(" ").replace(/\[(BLANK_AUDIO|MUSIC|Música|SILENCE)\]|\((?:silence|música|music)\)/gi, "").replace(/\s+/g, " ").trim();
36039
+ return { text: text3, lang: typeof d.result?.language === "string" ? d.result.language : "" };
35486
36040
  }
35487
36041
  function createWhisperTranscriber(setup, timeoutMs = TRANSCRIBE_TIMEOUT_MS) {
35488
36042
  return async (audio) => {
@@ -35490,14 +36044,14 @@ function createWhisperTranscriber(setup, timeoutMs = TRANSCRIBE_TIMEOUT_MS) {
35490
36044
  try {
35491
36045
  const input = join32(dir, "audio.in");
35492
36046
  const wav = join32(dir, "audio.wav");
35493
- writeFileSync15(input, audio, { mode: 384 });
36047
+ writeFileSync16(input, audio, { mode: 384 });
35494
36048
  const conv = await run2(setup.ffmpeg, ["-nostdin", "-loglevel", "error", "-y", "-i", input, "-ar", "16000", "-ac", "1", "-c:a", "pcm_s16le", wav], timeoutMs);
35495
36049
  if (!conv.ok) throw new Error(tr("n\xE3o deu para ler o \xE1udio ({0})", [conv.error]));
35496
36050
  const pass = async (lang) => {
35497
36051
  const out = join32(dir, `out-${lang}`);
35498
36052
  const r = await run2(setup.bin, ["-m", setup.model, "-l", lang, "-f", wav, "-nt", "-np", "-oj", "-of", out], timeoutMs);
35499
36053
  if (!r.ok) throw new Error(tr("o Whisper falhou ({0})", [r.error]));
35500
- return parseWhisperJson(readFileSync25(`${out}.json`, "utf8"));
36054
+ return parseWhisperJson(readFileSync26(`${out}.json`, "utf8"));
35501
36055
  };
35502
36056
  const first = await pass("auto");
35503
36057
  if (!first.lang || setup.langs.includes(first.lang) || !first.text) return first;
@@ -35511,7 +36065,7 @@ function createWhisperTranscriber(setup, timeoutMs = TRANSCRIBE_TIMEOUT_MS) {
35511
36065
 
35512
36066
  // server/deliveries/fetcher.ts
35513
36067
  import { randomUUID as randomUUID4 } from "node:crypto";
35514
- import { readFileSync as readFileSync26 } from "node:fs";
36068
+ import { readFileSync as readFileSync27 } from "node:fs";
35515
36069
  var HOST_PRESENCE_MS3 = 1e4;
35516
36070
  var WAIT_MS = 2e4;
35517
36071
  var CACHE_MAX_BYTES = 80 * 1024 * 1024;
@@ -35594,7 +36148,7 @@ var FileFetcher = class {
35594
36148
  const c = (this.opts.check ?? checkFile)(path);
35595
36149
  if ("error" in c) return { error: c.error, status: c.error === tr("arquivo n\xE3o encontrado") ? 404 : 403 };
35596
36150
  try {
35597
- const data = (this.opts.read ?? readFileSync26)(c.path);
36151
+ const data = (this.opts.read ?? readFileSync27)(c.path);
35598
36152
  this.remember(path, data);
35599
36153
  return { data };
35600
36154
  } catch {
@@ -35952,7 +36506,7 @@ function worldLastError(code2) {
35952
36506
  var RESYNC_GAP_MS = 5e3;
35953
36507
  var MAX_SCENE_PLAYERS = 200;
35954
36508
  var COORD_MAX = 1e6;
35955
- var isObj4 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
36509
+ var isObj5 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
35956
36510
  var isNum = (v) => typeof v === "number" && Number.isFinite(v);
35957
36511
  var DIRS = ["n", "s", "e", "w"];
35958
36512
  var isDir5 = (v) => typeof v === "string" && DIRS.includes(v);
@@ -35960,20 +36514,20 @@ var isId = (v) => typeof v === "string" && /^[\x21-\x7e]{1,64}$/.test(v);
35960
36514
  var isCount = (v) => isNum(v) && Number.isInteger(v) && v >= 0 && v <= 1e9;
35961
36515
  var CODE_TYPED = /^[A-Za-z0-9 _-]{1,16}$/;
35962
36516
  function parseCityStatus(v) {
35963
- if (!isObj4(v) || !isCount(v.lit)) return void 0;
36517
+ if (!isObj5(v) || !isCount(v.lit)) return void 0;
35964
36518
  const out = { lit: v.lit };
35965
36519
  const g = v.goal;
35966
- if (isObj4(g) && typeof g.id === "string" && g.id.length <= 64 && CITY_GOAL_IDS.includes(g.label) && isNum(g.target) && g.target > 0 && isNum(g.progress) && g.progress >= 0 && isNum(g.until)) {
36520
+ if (isObj5(g) && typeof g.id === "string" && g.id.length <= 64 && CITY_GOAL_IDS.includes(g.label) && isNum(g.target) && g.target > 0 && isNum(g.progress) && g.progress >= 0 && isNum(g.until)) {
35967
36521
  out.goal = { id: g.id, label: g.label, target: g.target, progress: g.progress, until: g.until };
35968
36522
  }
35969
36523
  if (isNum(v.tokensBand) && Number.isInteger(v.tokensBand) && v.tokensBand >= 0 && v.tokensBand <= 5) out.tokensBand = v.tokensBand;
35970
36524
  return out;
35971
36525
  }
35972
36526
  function parseAwaySummary(v) {
35973
- if (!isObj4(v) || typeof v.since !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(v.since) || !isCount(v.visits) || !isCount(v.likes)) return void 0;
36527
+ if (!isObj5(v) || typeof v.since !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(v.since) || !isCount(v.visits) || !isCount(v.likes)) return void 0;
35974
36528
  const stamps = [];
35975
36529
  for (const st of Array.isArray(v.stamps) ? v.stamps : []) {
35976
- if (!isObj4(st) || !STAMP_IDS.includes(st.stampId) || !isCount(st.count) || st.count === 0) continue;
36530
+ if (!isObj5(st) || !STAMP_IDS.includes(st.stampId) || !isCount(st.count) || st.count === 0) continue;
35977
36531
  if (stamps.some((x) => x.stampId === st.stampId)) continue;
35978
36532
  stamps.push({ stampId: st.stampId, count: st.count });
35979
36533
  }
@@ -35983,11 +36537,11 @@ function summaryHasNews(s2) {
35983
36537
  return !!s2 && (s2.visits > 0 || s2.likes > 0 || s2.stamps.some((x) => x.count > 0));
35984
36538
  }
35985
36539
  function position(v) {
35986
- if (!isObj4(v) || !isNum(v.x) || !isNum(v.y)) return void 0;
36540
+ if (!isObj5(v) || !isNum(v.x) || !isNum(v.y)) return void 0;
35987
36541
  return { x: v.x, y: v.y, dir: isDir5(v.dir) ? v.dir : "s", moving: v.moving === true };
35988
36542
  }
35989
36543
  function parseSceneCommand(v) {
35990
- if (!isObj4(v) || typeof v.t !== "string" || !WORLD_SCENE_COMMANDS.includes(v.t)) return null;
36544
+ if (!isObj5(v) || typeof v.t !== "string" || !WORLD_SCENE_COMMANDS.includes(v.t)) return null;
35991
36545
  switch (v.t) {
35992
36546
  case "move": {
35993
36547
  if (!isNum(v.x) || !isNum(v.y) || Math.abs(v.x) > COORD_MAX || Math.abs(v.y) > COORD_MAX) return null;
@@ -36045,18 +36599,18 @@ function reduceSceneBatch(cmds) {
36045
36599
  }
36046
36600
  function sceneMeFrom(welcome) {
36047
36601
  const me = welcome.me;
36048
- if (!isObj4(me) || !isId(me.id) || typeof me.name !== "string" || me.look !== "f" && me.look !== "m") return void 0;
36602
+ if (!isObj5(me) || !isId(me.id) || typeof me.name !== "string" || me.look !== "f" && me.look !== "m") return void 0;
36049
36603
  const out = {
36050
36604
  id: me.id,
36051
36605
  name: me.name,
36052
36606
  look: me.look,
36053
- parts: isObj4(me.parts) ? me.parts : {},
36607
+ parts: isObj5(me.parts) ? me.parts : {},
36054
36608
  traits: Array.isArray(me.traits) ? me.traits.filter((t) => typeof t === "string") : []
36055
36609
  };
36056
36610
  if (typeof me.intro === "string") out.intro = me.intro;
36057
36611
  if (typeof me.country === "string") out.country = me.country;
36058
36612
  const b = welcome.building;
36059
- if (isObj4(b) && isId(b.id)) out.buildingId = b.id;
36613
+ if (isObj5(b) && isId(b.id)) out.buildingId = b.id;
36060
36614
  return out;
36061
36615
  }
36062
36616
  var SceneState = class _SceneState {
@@ -36104,7 +36658,7 @@ var SceneState = class _SceneState {
36104
36658
  this.likesToday = void 0;
36105
36659
  this.summary = void 0;
36106
36660
  this.me = sceneMeFrom(msg);
36107
- const city = isObj4(msg.city) ? msg.city : void 0;
36661
+ const city = isObj5(msg.city) ? msg.city : void 0;
36108
36662
  const d = Array.isArray(city?.districts) ? city.districts[0] : void 0;
36109
36663
  this.district = typeof d === "string" ? d : void 0;
36110
36664
  }
@@ -36150,7 +36704,7 @@ var SceneState = class _SceneState {
36150
36704
  case "players": {
36151
36705
  if (!Array.isArray(msg.players)) return { forward: false };
36152
36706
  for (const e of msg.players) {
36153
- if (!isObj4(e) || !isId(e.id)) continue;
36707
+ if (!isObj5(e) || !isId(e.id)) continue;
36154
36708
  const pos = position(e.pos);
36155
36709
  if (!pos) continue;
36156
36710
  if (e.id === this.me?.id) {
@@ -36160,7 +36714,7 @@ var SceneState = class _SceneState {
36160
36714
  const p = this.players.get(e.id);
36161
36715
  if (!p) continue;
36162
36716
  p.pos = pos;
36163
- if (isObj4(e.greeting) && typeof e.greeting.id === "string" && isNum(e.greeting.until)) {
36717
+ if (isObj5(e.greeting) && typeof e.greeting.id === "string" && isNum(e.greeting.until)) {
36164
36718
  p.greeting = { id: e.greeting.id, until: e.greeting.until };
36165
36719
  }
36166
36720
  }
@@ -36168,7 +36722,7 @@ var SceneState = class _SceneState {
36168
36722
  }
36169
36723
  case "player.join": {
36170
36724
  const p = msg.player;
36171
- if (!isObj4(p) || !isId(p.id) || !position(p.pos) || p.id === this.me?.id) return { forward: false };
36725
+ if (!isObj5(p) || !isId(p.id) || !position(p.pos) || p.id === this.me?.id) return { forward: false };
36172
36726
  if (!this.players.has(p.id) && this.players.size >= MAX_SCENE_PLAYERS) return { forward: false };
36173
36727
  this.players.set(p.id, structuredClone(p));
36174
36728
  return { forward: true };
@@ -36186,7 +36740,7 @@ var SceneState = class _SceneState {
36186
36740
  }
36187
36741
  case "minimap": {
36188
36742
  if (!Array.isArray(msg.blocks)) return { forward: false };
36189
- this.minimap = msg.blocks.filter((b) => isObj4(b) && isNum(b.x) && isNum(b.y) && isNum(b.lit)).map((b) => ({ x: b.x, y: b.y, lit: b.lit }));
36743
+ this.minimap = msg.blocks.filter((b) => isObj5(b) && isNum(b.x) && isNum(b.y) && isNum(b.lit)).map((b) => ({ x: b.x, y: b.y, lit: b.lit }));
36190
36744
  return { forward: true };
36191
36745
  }
36192
36746
  case "afk":
@@ -36209,7 +36763,7 @@ var SceneState = class _SceneState {
36209
36763
  }
36210
36764
  case "profile": {
36211
36765
  const p = msg.player;
36212
- if (!isObj4(p) || !isId(p.id)) return { forward: false };
36766
+ if (!isObj5(p) || !isId(p.id)) return { forward: false };
36213
36767
  if (this.players.has(p.id) && position(p.pos)) this.players.set(p.id, structuredClone(p));
36214
36768
  return { forward: true };
36215
36769
  }
@@ -36283,7 +36837,7 @@ var SceneState = class _SceneState {
36283
36837
  area(msg) {
36284
36838
  if (!isId(msg.chunk) || !isNum(msg.rev) || !Array.isArray(msg.buildings)) return { forward: false };
36285
36839
  const buildings = /* @__PURE__ */ new Map();
36286
- for (const b of msg.buildings) if (isObj4(b) && isId(b.id)) buildings.set(b.id, structuredClone(b));
36840
+ for (const b of msg.buildings) if (isObj5(b) && isId(b.id)) buildings.set(b.id, structuredClone(b));
36287
36841
  this.chunks.set(msg.chunk, { rev: msg.rev, buildings });
36288
36842
  this.resyncAt.delete(msg.chunk);
36289
36843
  return { forward: true };
@@ -36296,7 +36850,7 @@ var SceneState = class _SceneState {
36296
36850
  if (!c) return this.gap(msg.chunk);
36297
36851
  if (msg.rev <= c.rev) return { forward: false };
36298
36852
  if (msg.rev !== c.rev + 1) return this.gap(msg.chunk);
36299
- const changes = msg.changes.filter((x) => isObj4(x) && isId(x.id));
36853
+ const changes = msg.changes.filter((x) => isObj5(x) && isId(x.id));
36300
36854
  if (changes.some((x) => x.lot === void 0 && !c.buildings.has(x.id))) return this.gap(msg.chunk);
36301
36855
  for (const x of changes) {
36302
36856
  const id = x.id;
@@ -36311,7 +36865,7 @@ var SceneState = class _SceneState {
36311
36865
  /** `building`: o interior inteiro, que substitui tudo (mesmo com `rev` menor). Daqui em diante estou dentro. */
36312
36866
  enterBuilding(msg) {
36313
36867
  const d = msg.detail;
36314
- if (!isNum(msg.rev) || !isObj4(d) || !isObj4(d.building) || !isId(d.building.id) || !Array.isArray(d.floors)) return { forward: false };
36868
+ if (!isNum(msg.rev) || !isObj5(d) || !isObj5(d.building) || !isId(d.building.id) || !Array.isArray(d.floors)) return { forward: false };
36315
36869
  this.inside = { id: d.building.id, rev: msg.rev, detail: structuredClone(d) };
36316
36870
  this.buildingResyncAt = void 0;
36317
36871
  return { forward: true };
@@ -36329,7 +36883,7 @@ var SceneState = class _SceneState {
36329
36883
  return { forward: false, resyncBuilding: inside.id };
36330
36884
  }
36331
36885
  if (msg.floors !== void 0 && !Array.isArray(msg.floors)) return { forward: false };
36332
- if (msg.building !== void 0 && (!isObj4(msg.building) || msg.building.id !== inside.id)) return { forward: false };
36886
+ if (msg.building !== void 0 && (!isObj5(msg.building) || msg.building.id !== inside.id)) return { forward: false };
36333
36887
  if (msg.visitors !== void 0 && !isNum(msg.visitors)) return { forward: false };
36334
36888
  const detail = inside.detail;
36335
36889
  if (msg.floors) detail.floors = structuredClone(msg.floors);
@@ -36375,7 +36929,7 @@ var SceneState = class _SceneState {
36375
36929
  var SUMMARY_SEEN_GRACE_MS = 2e4;
36376
36930
  var UNBLOCK_GRACE_MS = 6e4;
36377
36931
  var MAX_BLOCKED = 500;
36378
- var isObj5 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
36932
+ var isObj6 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
36379
36933
  var count = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0 && v <= 1e9 ? v : void 0;
36380
36934
  var ID_RE = /^[\x21-\x7e]{1,64}$/;
36381
36935
  var CODE_RE = /^HB-[2-9A-HJKMNP-TV-Z]{4}$/;
@@ -36391,10 +36945,10 @@ function summaryWithin(b, a) {
36391
36945
  return b.stamps.every((x) => x.count <= (a.stamps.find((y) => y.stampId === x.stampId)?.count ?? 0));
36392
36946
  }
36393
36947
  function parseMeBuilding(raw) {
36394
- if (!isObj5(raw) || !STATES.includes(raw.state)) return void 0;
36948
+ if (!isObj6(raw) || !STATES.includes(raw.state)) return void 0;
36395
36949
  const lot = raw.lot;
36396
- if (!isObj5(lot) || typeof lot.district !== "string" || lot.district.length > 32 || !Number.isInteger(lot.x) || !Number.isInteger(lot.y)) return void 0;
36397
- const a = isObj5(raw.agents) ? raw.agents : {};
36950
+ if (!isObj6(lot) || typeof lot.district !== "string" || lot.district.length > 32 || !Number.isInteger(lot.x) || !Number.isInteger(lot.y)) return void 0;
36951
+ const a = isObj6(raw.agents) ? raw.agents : {};
36398
36952
  const b = {
36399
36953
  state: raw.state,
36400
36954
  paused: raw.paused === true,
@@ -36404,7 +36958,7 @@ function parseMeBuilding(raw) {
36404
36958
  likes: count(raw.likes) ?? 0,
36405
36959
  firstOnlineMonth: typeof raw.firstOnlineMonth === "string" && /^\d{4}-\d{2}$/.test(raw.firstOnlineMonth) ? raw.firstOnlineMonth : ""
36406
36960
  };
36407
- if (isObj5(raw.tokens)) {
36961
+ if (isObj6(raw.tokens)) {
36408
36962
  const day = band(raw.tokens.day);
36409
36963
  const week = band(raw.tokens.week);
36410
36964
  if (day !== void 0 && week !== void 0) b.tokens = { day, week };
@@ -36421,7 +36975,7 @@ function parseBlocked(raw) {
36421
36975
  const out = [];
36422
36976
  for (const x of raw) {
36423
36977
  if (out.length >= MAX_BLOCKED) break;
36424
- if (!isObj5(x) || typeof x.id !== "string" || !ID_RE.test(x.id) || typeof x.name !== "string" || x.name.length > 64) continue;
36978
+ if (!isObj6(x) || typeof x.id !== "string" || !ID_RE.test(x.id) || typeof x.name !== "string" || x.name.length > 64) continue;
36425
36979
  if (!out.some((y) => y.id === x.id)) out.push({ id: x.id, name: x.name });
36426
36980
  }
36427
36981
  return out;
@@ -36580,7 +37134,7 @@ async function body(req, res) {
36580
37134
  sendError(res, status2, code2, err.message);
36581
37135
  return null;
36582
37136
  }
36583
- if (!isObj5(raw)) {
37137
+ if (!isObj6(raw)) {
36584
37138
  sendError(res, 400, "invalid", tr("esperado um objeto JSON"));
36585
37139
  return null;
36586
37140
  }
@@ -36616,8 +37170,8 @@ function socialRoutes(social) {
36616
37170
  }
36617
37171
 
36618
37172
  // server/world/settings.ts
36619
- import { chmodSync as chmodSync7, mkdirSync as mkdirSync17, readFileSync as readFileSync27, renameSync as renameSync15, rmSync as rmSync9, statSync as statSync24, writeFileSync as writeFileSync16 } from "node:fs";
36620
- import { dirname as dirname16 } from "node:path";
37173
+ import { chmodSync as chmodSync7, mkdirSync as mkdirSync18, readFileSync as readFileSync28, renameSync as renameSync16, rmSync as rmSync9, statSync as statSync24, writeFileSync as writeFileSync17 } from "node:fs";
37174
+ import { dirname as dirname17 } from "node:path";
36621
37175
  var DEVICE_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
36622
37176
  var TOKEN_RE = /^[A-Za-z0-9_-]{16,256}$/;
36623
37177
  var MAX_FILE = 64 * 1024;
@@ -36663,7 +37217,7 @@ var WorldSettingsStore = class {
36663
37217
  const st = statSync24(this.file);
36664
37218
  if (st.size > MAX_FILE) throw new Error("too large");
36665
37219
  if ((st.mode & 63) !== 0) chmodSync7(this.file, 384);
36666
- const raw = JSON.parse(readFileSync27(this.file, "utf8"));
37220
+ const raw = JSON.parse(readFileSync28(this.file, "utf8"));
36667
37221
  const obj4 = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
36668
37222
  if (isWorldThemeChoice(obj4.theme)) this.theme = obj4.theme;
36669
37223
  this.session = parseWorldSession(raw);
@@ -36726,10 +37280,10 @@ var WorldSettingsStore = class {
36726
37280
  }
36727
37281
  const tmp = `${this.file}.${process.pid}.tmp`;
36728
37282
  try {
36729
- mkdirSync17(dirname16(this.file), { recursive: true });
36730
- writeFileSync16(tmp, JSON.stringify(data), { mode: 384 });
37283
+ mkdirSync18(dirname17(this.file), { recursive: true });
37284
+ writeFileSync17(tmp, JSON.stringify(data), { mode: 384 });
36731
37285
  chmodSync7(tmp, 384);
36732
- renameSync15(tmp, this.file);
37286
+ renameSync16(tmp, this.file);
36733
37287
  log.clearOnce("world-write");
36734
37288
  return true;
36735
37289
  } catch (err) {
@@ -36938,7 +37492,7 @@ var WorldClient = class {
36938
37492
  const signal = o.signal ? AbortSignal.any([timeout, o.signal]) : timeout;
36939
37493
  const fail3 = (status2, code3, retryAfter) => retryAfter === void 0 ? { ok: false, status: status2, code: code3 } : { ok: false, status: status2, code: code3, retryAfter };
36940
37494
  let res;
36941
- let text2;
37495
+ let text3;
36942
37496
  try {
36943
37497
  res = await this.fetchImpl(`${this.base}${path}`, { method, headers, body: body2, redirect: "manual", signal });
36944
37498
  const length = Number(res.headers.get("content-length") ?? "0");
@@ -36946,16 +37500,16 @@ var WorldClient = class {
36946
37500
  await res.body?.cancel().catch(() => void 0);
36947
37501
  return fail3(502, CLIENT_ERROR.badResponse);
36948
37502
  }
36949
- text2 = await res.text();
37503
+ text3 = await res.text();
36950
37504
  } catch (err) {
36951
37505
  o.signal?.throwIfAborted();
36952
37506
  return err?.name === "TimeoutError" || timeout.aborted ? fail3(504, CLIENT_ERROR.timeout) : fail3(502, CLIENT_ERROR.unreachable);
36953
37507
  }
36954
- if (text2.length > max) return fail3(502, CLIENT_ERROR.badResponse);
37508
+ if (text3.length > max) return fail3(502, CLIENT_ERROR.badResponse);
36955
37509
  let raw;
36956
- if (text2.trim()) {
37510
+ if (text3.trim()) {
36957
37511
  try {
36958
- raw = JSON.parse(text2);
37512
+ raw = JSON.parse(text3);
36959
37513
  } catch {
36960
37514
  raw = void 0;
36961
37515
  if (res.ok) return fail3(502, CLIENT_ERROR.badResponse);
@@ -37392,8 +37946,8 @@ function createWorldRoutes(service, viewer, social) {
37392
37946
  }
37393
37947
 
37394
37948
  // server/world/uplink.ts
37395
- import { chmodSync as chmodSync8, mkdirSync as mkdirSync18, readFileSync as readFileSync28, renameSync as renameSync16, rmSync as rmSync10, writeFileSync as writeFileSync17 } from "node:fs";
37396
- import { dirname as dirname17 } from "node:path";
37949
+ import { chmodSync as chmodSync8, mkdirSync as mkdirSync19, readFileSync as readFileSync29, renameSync as renameSync17, rmSync as rmSync10, writeFileSync as writeFileSync18 } from "node:fs";
37950
+ import { dirname as dirname18 } from "node:path";
37397
37951
 
37398
37952
  // shared/world/appearance-flat.ts
37399
37953
  var SKINS = ["#ffe2cc", "#f6cfb0", "#eab894", "#d69f78", "#bd8560", "#9a6444", "#7a4a31", "#5a3623"];
@@ -37760,7 +38314,7 @@ function toWorldAgent(c, widOf, name, input) {
37760
38314
  }
37761
38315
 
37762
38316
  // server/world/ids.ts
37763
- import { randomBytes as randomBytes10, randomInt } from "node:crypto";
38317
+ import { randomBytes as randomBytes11, randomInt } from "node:crypto";
37764
38318
  var ID_LIFETIME_MS = 24 * 36e5;
37765
38319
  var ID_JITTER_MS = 6 * 36e5;
37766
38320
  var toHex = (b) => Array.from(b, (x) => x.toString(16).padStart(2, "0")).join("");
@@ -37772,7 +38326,7 @@ var WorldIds = class {
37772
38326
  bytes;
37773
38327
  jitter;
37774
38328
  constructor(opts = {}) {
37775
- this.bytes = opts.randomBytes ?? ((n2) => randomBytes10(n2));
38329
+ this.bytes = opts.randomBytes ?? ((n2) => randomBytes11(n2));
37776
38330
  this.jitter = opts.jitter ?? (() => randomInt(-ID_JITTER_MS, ID_JITTER_MS + 1));
37777
38331
  }
37778
38332
  floorId(roomId, now) {
@@ -38454,7 +39008,7 @@ var BuildingUplink = class {
38454
39008
  this.deviceId = s2?.deviceId;
38455
39009
  if (!file) return;
38456
39010
  try {
38457
- const raw = JSON.parse(readFileSync28(file, "utf8"));
39011
+ const raw = JSON.parse(readFileSync29(file, "utf8"));
38458
39012
  const ok = raw && typeof raw === "object" && typeof raw.deviceId === "string" && typeof raw.at === "number" && typeof raw.bytes === "number" && raw.uplink && typeof raw.uplink === "object" && Array.isArray(raw.uplink.floors);
38459
39013
  if (!ok || raw.deviceId !== s2?.deviceId) return this.removeLast();
38460
39014
  this.last = raw;
@@ -38466,10 +39020,10 @@ var BuildingUplink = class {
38466
39020
  if (!file || !this.last) return;
38467
39021
  const tmp = `${file}.${process.pid}.tmp`;
38468
39022
  try {
38469
- mkdirSync18(dirname17(file), { recursive: true });
38470
- writeFileSync17(tmp, JSON.stringify(this.last), { mode: 384 });
39023
+ mkdirSync19(dirname18(file), { recursive: true });
39024
+ writeFileSync18(tmp, JSON.stringify(this.last), { mode: 384 });
38471
39025
  chmodSync8(tmp, 384);
38472
- renameSync16(tmp, file);
39026
+ renameSync17(tmp, file);
38473
39027
  } catch (err) {
38474
39028
  try {
38475
39029
  rmSync10(tmp, { force: true });
@@ -39127,8 +39681,8 @@ var BuildingTokens = class {
39127
39681
  };
39128
39682
 
39129
39683
  // server/world/viewer.ts
39130
- import { randomBytes as randomBytes11 } from "node:crypto";
39131
- var isObj6 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
39684
+ import { randomBytes as randomBytes12 } from "node:crypto";
39685
+ var isObj7 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
39132
39686
  var WorldViewer = class {
39133
39687
  link;
39134
39688
  now;
@@ -39147,7 +39701,7 @@ var WorldViewer = class {
39147
39701
  this.state = new SceneState(this.now);
39148
39702
  this.pingMs = o.pingMs ?? 15e3;
39149
39703
  this.maxBuffered = o.maxBuffered ?? 1024 * 1024;
39150
- this.newId = o.streamId ?? (() => randomBytes11(12).toString("base64url"));
39704
+ this.newId = o.streamId ?? (() => randomBytes12(12).toString("base64url"));
39151
39705
  }
39152
39706
  /** Liga à conexão do prédio (que chama `opened`, `closed` e `message` daqui). */
39153
39707
  attach(link) {
@@ -39223,7 +39777,7 @@ var WorldViewer = class {
39223
39777
  /** POST /api/world/cmd {stream, cmds}. */
39224
39778
  command(body2) {
39225
39779
  const max = WORLD_SCENE_LIMITS.cmdsPerBatch;
39226
- if (!isObj6(body2) || typeof body2.stream !== "string" || !Array.isArray(body2.cmds) || body2.cmds.length === 0 || body2.cmds.length > max) {
39780
+ if (!isObj7(body2) || typeof body2.stream !== "string" || !Array.isArray(body2.cmds) || body2.cmds.length === 0 || body2.cmds.length > max) {
39227
39781
  return { ok: false, status: 400, code: "invalid" };
39228
39782
  }
39229
39783
  const s2 = this.streams.get(body2.stream);
@@ -39701,6 +40255,12 @@ hub.setInitialFrames(() => {
39701
40255
  });
39702
40256
  var avatar = new AvatarStore(join33(config.dataDir, "avatar.json"));
39703
40257
  hub.setInitialFrames(() => [["avatar", avatar.get()]]);
40258
+ var inboxStore = new InboxStore(join33(config.dataDir, "inbox.json"));
40259
+ var inbox = new InboxService({ store: inboxStore, agents: () => office.list() });
40260
+ inbox.onFrame((f) => hub.broadcast("inbox", f));
40261
+ hub.setInitialFrames(() => [["inbox", inbox.frame()]]);
40262
+ var inboxPurgeTimer = setInterval(() => inboxStore.purge(), 60 * 6e4);
40263
+ inboxPurgeTimer.unref();
39704
40264
  hub.setInitialFrames(() => [["defaultLook", defaultLook2.get()]]);
39705
40265
  var perfSampler = new PerfSampler({
39706
40266
  workCounters: {
@@ -39735,6 +40295,7 @@ if (config.satellite) {
39735
40295
  if (!registry) return { actionId: a.id, ok: false, error: tr("permiss\xF5es desligadas nesta m\xE1quina"), status: 403 };
39736
40296
  return createPermissionDecideHandler({ registry })(a, deadline);
39737
40297
  },
40298
+ "inbox.resolve": createInboxResolveHandler({ store: inboxStore }),
39738
40299
  // Leituras da central (detalhe, terminal, comandos, arquivos de entrega): cada uma é um GET na rota local desta máquina.
39739
40300
  ...createReadHandlers({ port: config.port, host: config.host, link: satelliteLink }),
39740
40301
  "pty.create": async (a, deadline) => remoteSatellitePtys?.handlers()["pty.create"]?.(a, deadline) ?? { actionId: a.id, ok: false, status: 503, error: ptyOff ?? tr("desligado nesta m\xE1quina") },
@@ -39751,7 +40312,8 @@ if (config.satellite) {
39751
40312
  handlers,
39752
40313
  perfSampler,
39753
40314
  ptys: () => remoteSatellitePtys,
39754
- maintenance: () => remoteSatellitePtys?.tick()
40315
+ maintenance: () => remoteSatellitePtys?.tick(),
40316
+ inbox: { items: () => visibleInbox(inboxStore.list()), onChange: (cb) => inboxStore.onChange(cb) }
39755
40317
  });
39756
40318
  }
39757
40319
  }
@@ -39872,8 +40434,8 @@ var providers = config.inDocker ? () => DOCKER_PROVIDERS.map((p) => ({ ...p }))
39872
40434
  };
39873
40435
  var gentleInbox = () => messages && {
39874
40436
  agents: () => office.list().filter((a) => a.provider === "gentle-shell" && a.kind === "main").map((a) => ({ id: a.id, cwd: office.roomPath(a.roomId), startedAt: a.startedAt })),
39875
- send: (agentId, text2) => {
39876
- const r = messages.send({ agentId, text: text2 });
40437
+ send: (agentId, text3) => {
40438
+ const r = messages.send({ agentId, text: text3 });
39877
40439
  if ("message" in r) return { ok: true };
39878
40440
  if (r.error === "unavailable") return { ok: false, retry: true, reason: r.reason };
39879
40441
  if (r.error === "too-many") return { ok: false, retry: false, reason: tr("o agente j\xE1 tem mensagens demais esperando") };
@@ -39898,7 +40460,7 @@ var messages = config.messages ? new MessageRegistry({
39898
40460
  office,
39899
40461
  images: messageImages,
39900
40462
  demoAgent: (id) => office.demoAgent(id),
39901
- demoDeliver: (id, text2) => office.deliverDemoMessage(id, text2),
40463
+ demoDeliver: (id, text3) => office.deliverDemoMessage(id, text3),
39902
40464
  codex: {
39903
40465
  run: codexBin ? createCodexQueueRunner(codexBin) : void 0,
39904
40466
  homeOf: (account) => accounts.entriesOf("codex").find((e) => e.id === account)?.detected.configDir
@@ -40006,6 +40568,7 @@ var api = createApiHandler({
40006
40568
  // Central: `remotePermissions` nasce mais abaixo; id que não é remoto cai no registro local.
40007
40569
  permissions: permissions ? createPermissionRoutes(permissions, config.central ? { detail: (id, res) => late.remotePermissions?.detail(id, res) ?? false, decide: async (id, raw) => late.remotePermissions?.decide(id, raw) } : void 0) : void 0,
40008
40570
  attention: createAttentionRoutes(attention, hub),
40571
+ inbox: createInboxRoutes(inbox),
40009
40572
  avatar: createAvatarRoutes(avatar, hub),
40010
40573
  defaultLook: createDefaultLookRoutes(defaultLook2, () => {
40011
40574
  late.office?.markDirty();
@@ -40185,6 +40748,7 @@ if (config.central) {
40185
40748
  late.remotePtys.start();
40186
40749
  late.centralRoutes = createCentralRoutes({ machines, hub: centralHub, name: central.name, port: central.port, fingerprint: () => caFingerprint(tlsPaths(central.tlsBase)) });
40187
40750
  late.remotePermissions = new RemotePermissions({ hub: centralHub });
40751
+ inbox.setRemote(new RemoteInboxItems(centralHub));
40188
40752
  centralHub.start();
40189
40753
  if (messages) {
40190
40754
  late.remoteMessages = new RemoteMessages({ hub: centralHub, office, images: messageImages });
@@ -40218,7 +40782,7 @@ if (config.central) {
40218
40782
  listener = startCentralListener({
40219
40783
  host: bind.host,
40220
40784
  port: central.port,
40221
- tls: { key: readFileSync29(paths.serverKey), cert: readFileSync29(paths.serverCert), ca: readFileSync29(paths.caCert) },
40785
+ tls: { key: readFileSync30(paths.serverKey), cert: readFileSync30(paths.serverCert), ca: readFileSync30(paths.caCert) },
40222
40786
  machines,
40223
40787
  routes: centralHub
40224
40788
  });
@@ -40326,6 +40890,7 @@ function shutdown(signal) {
40326
40890
  centralStopped = true;
40327
40891
  if (centralRetry) clearTimeout(centralRetry);
40328
40892
  if (remoteMessagesTimer) clearInterval(remoteMessagesTimer);
40893
+ clearInterval(inboxPurgeTimer);
40329
40894
  late.remoteMessages?.stop();
40330
40895
  late.remotePtys?.dispose();
40331
40896
  late.centralHub?.stop();