busybits 2.2.0 → 2.4.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +14 -0
- package/README.md +6 -0
- package/dist/build.json +2 -2
- package/dist/cli/busybits.js +72 -9
- package/dist/client/bundle/{app-BqhKcvbt.js → app-Chm8kKN4.js} +5 -5
- package/dist/client/bundle/{app-Y2N0l58V.css → app-Cn3BvqjA.css} +1 -1
- package/dist/client/bundle/{city-DMPsypEv.js → city-CdnZXWrk.js} +1 -1
- package/dist/client/bundle/{daystats-BJLg6u8w.js → daystats-BkQMrXRq.js} +1 -1
- package/dist/client/bundle/{dom-Co5ozWIR.js → dom-DWAK9rwv.js} +1 -1
- package/dist/client/bundle/{en-DRc2Oulk.js → en-BD-d_FWo.js} +2 -2
- package/dist/client/bundle/{es-DslAKAxR.js → es-ZgMlZ_LY.js} +2 -2
- package/dist/client/bundle/{format-k7wUh6fM.js → format-BejmJ6Mv.js} +1 -1
- package/dist/client/bundle/{fr-Chqn4K83.js → fr-DOSCFvER.js} +2 -2
- package/dist/client/bundle/{main-DBC-FPBX.js → main-CdDU0hle.js} +2 -2
- package/dist/client/bundle/{ptypane-UBqz8-gA.js → ptypane-CHGZb-H_.js} +1 -1
- package/dist/client/bundle/{room-name-B0XrI0hp.js → room-name-tykoJBug.js} +1 -1
- package/dist/client/bundle/{simulator-B0dhttuF.js → simulator-BjUGGls6.js} +1 -1
- package/dist/client/bundle/{world-model-DZTQjqjZ.js → world-model-Bi4Y820L.js} +1 -1
- package/dist/client/bundle/{world-stream-EkZAApmC.js → world-stream-1LIEwTsn.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/index.js +390 -42
- package/mod/habblaud/.claude-plugin/plugin.json +1 -1
- package/mod/habblaud-mensagens/.claude-plugin/plugin.json +1 -1
- package/mod/habblaud-permissoes/.claude-plugin/plugin.json +1 -1
- package/mod/habblaud-pi/package.json +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -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
|
|
20
|
+
import { existsSync as existsSync13, readFileSync as readFileSync31 } from "node:fs";
|
|
21
21
|
import http4 from "node:http";
|
|
22
22
|
import { join as join33 } from "node:path";
|
|
23
23
|
|
|
@@ -3483,12 +3483,21 @@ var EN = {
|
|
|
3483
3483
|
"Dire\xE7\xE3o": "Direction",
|
|
3484
3484
|
"\xE0 direita": "right",
|
|
3485
3485
|
"para baixo": "down",
|
|
3486
|
-
"
|
|
3486
|
+
"Para abrir em abas e pain\xE9is, abra o herdr": "To open in herdr tabs and panes, open herdr",
|
|
3487
3487
|
"O chat do Gentle Shell n\xE3o volta quando o herdr reinicia (veja herdr integration install pi)": "The Gentle Shell chat doesn't come back when herdr restarts (see herdr integration install pi)",
|
|
3488
3488
|
"Nova aba em": "New tab in",
|
|
3489
|
+
"Em uma nova janela de terminal": "In a new terminal window",
|
|
3490
|
+
"Aberto em uma nova janela de terminal.": "Opened in a new terminal window.",
|
|
3491
|
+
"Agente novo aberto numa janela de terminal.": "New agent opened in a terminal window.",
|
|
3492
|
+
"n\xE3o h\xE1 terminal dispon\xEDvel para abrir uma janela": "no terminal is available to open a window",
|
|
3493
|
+
"n\xE3o achei o osascript para abrir o Terminal": "osascript not found to open Terminal",
|
|
3494
|
+
"sem ambiente gr\xE1fico (DISPLAY ou WAYLAND_DISPLAY) para abrir um terminal": "no graphical session (DISPLAY or WAYLAND_DISPLAY) to open a terminal",
|
|
3495
|
+
"n\xE3o achei um terminal (defina $TERMINAL ou instale gnome-terminal, konsole, kitty, alacritty, wezterm, xfce4-terminal ou xterm)": "no terminal found (set $TERMINAL or install gnome-terminal, konsole, kitty, alacritty, wezterm, xfce4-terminal or xterm)",
|
|
3496
|
+
"o pedido ou a pasta tem caracteres (aspas, % ou quebra de linha) que o cmd.exe n\xE3o aceita com seguran\xE7a": "the request or folder has characters (quotes, % or line breaks) that cmd.exe cannot take safely",
|
|
3497
|
+
"o pedido ou a pasta tem caracteres de controle que o Terminal n\xE3o aceita com seguran\xE7a": "the request or folder has control characters that Terminal cannot take safely",
|
|
3489
3498
|
"Dividir painel": "Split pane",
|
|
3490
3499
|
"Onde abrir": "Where to open",
|
|
3491
|
-
|
|
3500
|
+
'Come\xE7a na hora uma sess\xE3o nova no computador, na pasta, com a ferramenta e no lugar escolhidos; as permiss\xF5es chegam aqui. Em segundo plano, pasta que o Claude Code ainda n\xE3o conhece abre no app do Claude e espera o Enter l\xE1. Sem herdr, "Em uma nova janela de terminal" abre o terminal do computador j\xE1 com a ferramenta rodando. Anexos v\xE3o para ~/.habblaud/attachments e o pedido leva os caminhos.': `Instantly starts a new session on the computer, in the chosen folder, tool and place; permissions come here. In the background, a folder Claude Code doesn't know yet opens in the Claude app and waits for Enter there. Without herdr, "In a new terminal window" opens the computer's terminal with the tool already running. Attachments go to ~/.habblaud/attachments and the request includes their paths.`,
|
|
3492
3501
|
"Escolha onde abrir.": "Choose where to open.",
|
|
3493
3502
|
"Aberto no herdr (painel {0}).": "Opened in herdr (pane {0}).",
|
|
3494
3503
|
"Agente novo aberto no herdr.": "New agent opened in herdr.",
|
|
@@ -3726,7 +3735,19 @@ var EN = {
|
|
|
3726
3735
|
"Itens deixados na sua mesa. Clique para abrir.": "Items left on your desk. Click to open.",
|
|
3727
3736
|
"na mesa": "on desk",
|
|
3728
3737
|
"Na sua mesa": "On your desk",
|
|
3729
|
-
"Mensageiro": "Courier"
|
|
3738
|
+
"Mensageiro": "Courier",
|
|
3739
|
+
"Padr\xE3o": "Default",
|
|
3740
|
+
"Padr\xE3o (ou escreva o modelo, ex.: gpt-5.5)": "Default (or type the model, e.g. gpt-5.5)",
|
|
3741
|
+
"Outro modelo": "Other model",
|
|
3742
|
+
"Carregando a lista de modelos\u2026": "Loading the model list\u2026",
|
|
3743
|
+
"Lista de modelos indispon\xEDvel: usa o padr\xE3o": "Model list unavailable: using the default",
|
|
3744
|
+
"Modelo inv\xE1lido: use letras, d\xEDgitos e . - _ / :": "Invalid model: use letters, digits and . - _ / :",
|
|
3745
|
+
"modelo inv\xE1lido": "invalid model",
|
|
3746
|
+
"modelo inv\xE1lido (use letras, d\xEDgitos e . - _ / :, at\xE9 {0} caracteres)": "invalid model (use letters, digits and . - _ / :, up to {0} characters)",
|
|
3747
|
+
"modelo desconhecido para o Claude Code": "unknown model for Claude Code",
|
|
3748
|
+
"a lista de modelos do Gentle Shell ainda n\xE3o carregou: abra o di\xE1logo de novo": "the Gentle Shell model list has not loaded yet: open the dialog again",
|
|
3749
|
+
"modelo desconhecido para o Gentle Shell": "unknown model for Gentle Shell",
|
|
3750
|
+
"no Docker o agente novo n\xE3o aceita escolher o modelo": "in Docker, a new agent cannot choose the model"
|
|
3730
3751
|
};
|
|
3731
3752
|
|
|
3732
3753
|
// shared/locales/es.ts
|
|
@@ -7186,12 +7207,21 @@ var ES = {
|
|
|
7186
7207
|
"Dire\xE7\xE3o": "Direcci\xF3n",
|
|
7187
7208
|
"\xE0 direita": "a la derecha",
|
|
7188
7209
|
"para baixo": "hacia abajo",
|
|
7189
|
-
"
|
|
7210
|
+
"Para abrir em abas e pain\xE9is, abra o herdr": "Para abrir en pesta\xF1as y paneles, abre herdr",
|
|
7190
7211
|
"O chat do Gentle Shell n\xE3o volta quando o herdr reinicia (veja herdr integration install pi)": "El chat de Gentle Shell no vuelve cuando herdr se reinicia (ver herdr integration install pi)",
|
|
7191
7212
|
"Nova aba em": "Pesta\xF1a nueva en",
|
|
7213
|
+
"Em uma nova janela de terminal": "En una ventana de terminal nueva",
|
|
7214
|
+
"Aberto em uma nova janela de terminal.": "Abierto en una ventana de terminal nueva.",
|
|
7215
|
+
"Agente novo aberto numa janela de terminal.": "Agente nuevo abierto en una ventana de terminal.",
|
|
7216
|
+
"n\xE3o h\xE1 terminal dispon\xEDvel para abrir uma janela": "no hay un terminal disponible para abrir una ventana",
|
|
7217
|
+
"n\xE3o achei o osascript para abrir o Terminal": "no se encontr\xF3 osascript para abrir Terminal",
|
|
7218
|
+
"sem ambiente gr\xE1fico (DISPLAY ou WAYLAND_DISPLAY) para abrir um terminal": "no hay entorno gr\xE1fico (DISPLAY o WAYLAND_DISPLAY) para abrir un terminal",
|
|
7219
|
+
"n\xE3o achei um terminal (defina $TERMINAL ou instale gnome-terminal, konsole, kitty, alacritty, wezterm, xfce4-terminal ou xterm)": "no se encontr\xF3 un terminal (define $TERMINAL o instala gnome-terminal, konsole, kitty, alacritty, wezterm, xfce4-terminal o xterm)",
|
|
7220
|
+
"o pedido ou a pasta tem caracteres (aspas, % ou quebra de linha) que o cmd.exe n\xE3o aceita com seguran\xE7a": "la solicitud o la carpeta tiene caracteres (comillas, % o saltos de l\xEDnea) que cmd.exe no acepta con seguridad",
|
|
7221
|
+
"o pedido ou a pasta tem caracteres de controle que o Terminal n\xE3o aceita com seguran\xE7a": "la solicitud o la carpeta tiene caracteres de control que Terminal no acepta con seguridad",
|
|
7192
7222
|
"Dividir painel": "Dividir panel",
|
|
7193
7223
|
"Onde abrir": "D\xF3nde abrir",
|
|
7194
|
-
|
|
7224
|
+
'Come\xE7a na hora uma sess\xE3o nova no computador, na pasta, com a ferramenta e no lugar escolhidos; as permiss\xF5es chegam aqui. Em segundo plano, pasta que o Claude Code ainda n\xE3o conhece abre no app do Claude e espera o Enter l\xE1. Sem herdr, "Em uma nova janela de terminal" abre o terminal do computador j\xE1 com a ferramenta rodando. Anexos v\xE3o para ~/.habblaud/attachments e o pedido leva os caminhos.': 'Inicia al instante una sesi\xF3n nueva en el equipo, en la carpeta, con la herramienta y en el lugar elegidos; los permisos llegan aqu\xED. En segundo plano, una carpeta que Claude Code a\xFAn no conoce se abre en la app de Claude y espera el Enter all\xED. Sin herdr, "En una ventana de terminal nueva" abre el terminal del equipo con la herramienta ya en marcha. Los adjuntos van a ~/.habblaud/attachments y la solicitud lleva sus rutas.',
|
|
7195
7225
|
"Escolha onde abrir.": "Elige d\xF3nde abrir.",
|
|
7196
7226
|
"Aberto no herdr (painel {0}).": "Abierto en herdr (panel {0}).",
|
|
7197
7227
|
"Agente novo aberto no herdr.": "Agente nuevo abierto en herdr.",
|
|
@@ -7429,7 +7459,19 @@ var ES = {
|
|
|
7429
7459
|
"Itens deixados na sua mesa. Clique para abrir.": "Elementos dejados en tu escritorio. Haz clic para abrir.",
|
|
7430
7460
|
"na mesa": "en el escritorio",
|
|
7431
7461
|
"Na sua mesa": "En tu escritorio",
|
|
7432
|
-
"Mensageiro": "Mensajero"
|
|
7462
|
+
"Mensageiro": "Mensajero",
|
|
7463
|
+
"Padr\xE3o": "Predeterminado",
|
|
7464
|
+
"Padr\xE3o (ou escreva o modelo, ex.: gpt-5.5)": "Predeterminado (o escribe el modelo, p. ej. gpt-5.5)",
|
|
7465
|
+
"Outro modelo": "Otro modelo",
|
|
7466
|
+
"Carregando a lista de modelos\u2026": "Cargando la lista de modelos\u2026",
|
|
7467
|
+
"Lista de modelos indispon\xEDvel: usa o padr\xE3o": "Lista de modelos no disponible: se usa el predeterminado",
|
|
7468
|
+
"Modelo inv\xE1lido: use letras, d\xEDgitos e . - _ / :": "Modelo no v\xE1lido: usa letras, d\xEDgitos y . - _ / :",
|
|
7469
|
+
"modelo inv\xE1lido": "modelo no v\xE1lido",
|
|
7470
|
+
"modelo inv\xE1lido (use letras, d\xEDgitos e . - _ / :, at\xE9 {0} caracteres)": "modelo no v\xE1lido (usa letras, d\xEDgitos y . - _ / :, hasta {0} caracteres)",
|
|
7471
|
+
"modelo desconhecido para o Claude Code": "modelo desconocido para Claude Code",
|
|
7472
|
+
"a lista de modelos do Gentle Shell ainda n\xE3o carregou: abra o di\xE1logo de novo": "la lista de modelos de Gentle Shell a\xFAn no se carg\xF3: abre el di\xE1logo de nuevo",
|
|
7473
|
+
"modelo desconhecido para o Gentle Shell": "modelo desconocido para Gentle Shell",
|
|
7474
|
+
"no Docker o agente novo n\xE3o aceita escolher o modelo": "en Docker, un agente nuevo no puede elegir el modelo"
|
|
7433
7475
|
};
|
|
7434
7476
|
|
|
7435
7477
|
// shared/locales/fr.ts
|
|
@@ -10897,12 +10939,21 @@ var FR = {
|
|
|
10897
10939
|
"Dire\xE7\xE3o": "Direction",
|
|
10898
10940
|
"\xE0 direita": "\xE0 droite",
|
|
10899
10941
|
"para baixo": "vers le bas",
|
|
10900
|
-
"
|
|
10942
|
+
"Para abrir em abas e pain\xE9is, abra o herdr": "Pour ouvrir dans des onglets et panneaux, ouvrez herdr",
|
|
10901
10943
|
"O chat do Gentle Shell n\xE3o volta quando o herdr reinicia (veja herdr integration install pi)": "Le chat de Gentle Shell ne revient pas quand herdr red\xE9marre (voir herdr integration install pi)",
|
|
10902
10944
|
"Nova aba em": "Nouvel onglet dans",
|
|
10945
|
+
"Em uma nova janela de terminal": "Dans une nouvelle fen\xEAtre de terminal",
|
|
10946
|
+
"Aberto em uma nova janela de terminal.": "Ouvert dans une nouvelle fen\xEAtre de terminal.",
|
|
10947
|
+
"Agente novo aberto numa janela de terminal.": "Nouvel agent ouvert dans une fen\xEAtre de terminal.",
|
|
10948
|
+
"n\xE3o h\xE1 terminal dispon\xEDvel para abrir uma janela": "aucun terminal disponible pour ouvrir une fen\xEAtre",
|
|
10949
|
+
"n\xE3o achei o osascript para abrir o Terminal": "osascript introuvable pour ouvrir Terminal",
|
|
10950
|
+
"sem ambiente gr\xE1fico (DISPLAY ou WAYLAND_DISPLAY) para abrir um terminal": "pas d'environnement graphique (DISPLAY ou WAYLAND_DISPLAY) pour ouvrir un terminal",
|
|
10951
|
+
"n\xE3o achei um terminal (defina $TERMINAL ou instale gnome-terminal, konsole, kitty, alacritty, wezterm, xfce4-terminal ou xterm)": "aucun terminal trouv\xE9 (d\xE9finissez $TERMINAL ou installez gnome-terminal, konsole, kitty, alacritty, wezterm, xfce4-terminal ou xterm)",
|
|
10952
|
+
"o pedido ou a pasta tem caracteres (aspas, % ou quebra de linha) que o cmd.exe n\xE3o aceita com seguran\xE7a": "la demande ou le dossier contient des caract\xE8res (guillemets, % ou sauts de ligne) que cmd.exe ne g\xE8re pas en s\xE9curit\xE9",
|
|
10953
|
+
"o pedido ou a pasta tem caracteres de controle que o Terminal n\xE3o aceita com seguran\xE7a": "la demande ou le dossier contient des caract\xE8res de contr\xF4le que Terminal ne g\xE8re pas en s\xE9curit\xE9",
|
|
10903
10954
|
"Dividir painel": "Diviser le panneau",
|
|
10904
10955
|
"Onde abrir": "O\xF9 ouvrir",
|
|
10905
|
-
|
|
10956
|
+
'Come\xE7a na hora uma sess\xE3o nova no computador, na pasta, com a ferramenta e no lugar escolhidos; as permiss\xF5es chegam aqui. Em segundo plano, pasta que o Claude Code ainda n\xE3o conhece abre no app do Claude e espera o Enter l\xE1. Sem herdr, "Em uma nova janela de terminal" abre o terminal do computador j\xE1 com a ferramenta rodando. Anexos v\xE3o para ~/.habblaud/attachments e o pedido leva os caminhos.': "Lance tout de suite une nouvelle session sur l'ordinateur, dans le dossier, avec l'outil et \xE0 l'endroit choisis ; les permissions arrivent ici. En arri\xE8re-plan, un dossier que Claude Code ne conna\xEEt pas encore s'ouvre dans l'app Claude et y attend Entr\xE9e. Sans herdr, \xAB Dans une nouvelle fen\xEAtre de terminal \xBB ouvre le terminal de l'ordinateur avec l'outil d\xE9j\xE0 lanc\xE9. Les pi\xE8ces jointes vont dans ~/.habblaud/attachments et la demande indique leurs chemins.",
|
|
10906
10957
|
"Escolha onde abrir.": "Choisissez o\xF9 ouvrir.",
|
|
10907
10958
|
"Aberto no herdr (painel {0}).": "Ouvert dans herdr (panneau {0}).",
|
|
10908
10959
|
"Agente novo aberto no herdr.": "Nouvel agent ouvert dans herdr.",
|
|
@@ -11159,7 +11210,19 @@ Exemple :
|
|
|
11159
11210
|
"Itens deixados na sua mesa. Clique para abrir.": "\xC9l\xE9ments laiss\xE9s sur votre bureau. Cliquez pour ouvrir.",
|
|
11160
11211
|
"na mesa": "sur le bureau",
|
|
11161
11212
|
"Na sua mesa": "Sur votre bureau",
|
|
11162
|
-
"Mensageiro": "Coursier"
|
|
11213
|
+
"Mensageiro": "Coursier",
|
|
11214
|
+
"Padr\xE3o": "Par d\xE9faut",
|
|
11215
|
+
"Padr\xE3o (ou escreva o modelo, ex.: gpt-5.5)": "Par d\xE9faut (ou saisissez le mod\xE8le, ex. gpt-5.5)",
|
|
11216
|
+
"Outro modelo": "Autre mod\xE8le",
|
|
11217
|
+
"Carregando a lista de modelos\u2026": "Chargement de la liste des mod\xE8les\u2026",
|
|
11218
|
+
"Lista de modelos indispon\xEDvel: usa o padr\xE3o": "Liste des mod\xE8les indisponible : le mod\xE8le par d\xE9faut est utilis\xE9",
|
|
11219
|
+
"Modelo inv\xE1lido: use letras, d\xEDgitos e . - _ / :": "Mod\xE8le invalide : utilisez des lettres, des chiffres et . - _ / :",
|
|
11220
|
+
"modelo inv\xE1lido": "mod\xE8le invalide",
|
|
11221
|
+
"modelo inv\xE1lido (use letras, d\xEDgitos e . - _ / :, at\xE9 {0} caracteres)": "mod\xE8le invalide (utilisez des lettres, des chiffres et . - _ / :, jusqu'\xE0 {0} caract\xE8res)",
|
|
11222
|
+
"modelo desconhecido para o Claude Code": "mod\xE8le inconnu pour Claude Code",
|
|
11223
|
+
"a lista de modelos do Gentle Shell ainda n\xE3o carregou: abra o di\xE1logo de novo": "la liste des mod\xE8les de Gentle Shell n'est pas encore charg\xE9e : rouvrez la bo\xEEte de dialogue",
|
|
11224
|
+
"modelo desconhecido para o Gentle Shell": "mod\xE8le inconnu pour Gentle Shell",
|
|
11225
|
+
"no Docker o agente novo n\xE3o aceita escolher o modelo": "dans Docker, un nouvel agent ne peut pas choisir le mod\xE8le"
|
|
11163
11226
|
};
|
|
11164
11227
|
|
|
11165
11228
|
// shared/locales/all.ts
|
|
@@ -20151,7 +20214,10 @@ function createApiHandler(deps) {
|
|
|
20151
20214
|
const herdr2 = deps.herdr;
|
|
20152
20215
|
const off = { available: false, reason: deps.inDocker ? tr("indispon\xEDvel no Docker") : tr("o herdr n\xE3o est\xE1 dispon\xEDvel") };
|
|
20153
20216
|
(herdr2 ? herdr2.status().catch(() => off) : Promise.resolve(off)).then(
|
|
20154
|
-
(h) =>
|
|
20217
|
+
(h) => {
|
|
20218
|
+
const terminal = deps.spawnWindow?.() ?? { available: false, reason: deps.inDocker ? tr("indispon\xEDvel no Docker") : tr("n\xE3o h\xE1 terminal dispon\xEDvel para abrir uma janela") };
|
|
20219
|
+
sendJson2(res, 200, { available: spawn2.available(), mode: spawn2.mode(), providers: providers2, herdr: h, terminal });
|
|
20220
|
+
},
|
|
20155
20221
|
(err) => fail3(res, err)
|
|
20156
20222
|
);
|
|
20157
20223
|
} else if (path === "/api/spawn/herdr") {
|
|
@@ -20176,6 +20242,11 @@ function createApiHandler(deps) {
|
|
|
20176
20242
|
if (r) sendJson2(res, 200, r);
|
|
20177
20243
|
else sendJson2(res, 404, { error: tr("Esta sess\xE3o n\xE3o foi aberta pelo herdr.") });
|
|
20178
20244
|
}).catch((err) => fail3(res, err));
|
|
20245
|
+
} else if (path === "/api/spawn/models") {
|
|
20246
|
+
const provider = ["claude", "gentle-shell", "codex"].find((p) => p === url.searchParams.get("provider"));
|
|
20247
|
+
if (!isRead) methodNotAllowed4(res, "GET");
|
|
20248
|
+
else if (!provider) sendJson2(res, 400, { error: tr("provedor desconhecido") });
|
|
20249
|
+
else sendJson2(res, 200, deps.spawnModels?.(provider) ?? { free: false, state: "unavailable", models: [] });
|
|
20179
20250
|
} else if (path === "/api/spawn/folders") {
|
|
20180
20251
|
if (!isRead) methodNotAllowed4(res, "GET");
|
|
20181
20252
|
else (deps.spawnFolders ?? (async () => []))().then((folders) => sendJson2(res, 200, { folders }), (err) => fail3(res, err));
|
|
@@ -35267,7 +35338,7 @@ async function startUpdate(o) {
|
|
|
35267
35338
|
import { spawn as spawnProcess } from "node:child_process";
|
|
35268
35339
|
|
|
35269
35340
|
// server/spawn/spawn.ts
|
|
35270
|
-
import { execFile as
|
|
35341
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
35271
35342
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
35272
35343
|
import { statSync as statSync23 } from "node:fs";
|
|
35273
35344
|
import { isAbsolute as isAbsolute7 } from "node:path";
|
|
@@ -35283,6 +35354,87 @@ function isHerdrPaneId(s2) {
|
|
|
35283
35354
|
return typeof s2 === "string" && PANE_ID.test(s2);
|
|
35284
35355
|
}
|
|
35285
35356
|
|
|
35357
|
+
// server/spawn/models.ts
|
|
35358
|
+
import { execFile as execFile4 } from "node:child_process";
|
|
35359
|
+
var MODEL_MAX = 100;
|
|
35360
|
+
var MODEL_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._/:-]*$/;
|
|
35361
|
+
var CLAUDE_MODELS = ["opus", "sonnet", "haiku", "fable"];
|
|
35362
|
+
var LIST_TTL_MS = 10 * 6e4;
|
|
35363
|
+
var LIST_TIMEOUT_MS = 15e3;
|
|
35364
|
+
var LIST_FAIL_TTL_MS = 3e4;
|
|
35365
|
+
function parseListModels(text3) {
|
|
35366
|
+
const out = [];
|
|
35367
|
+
for (const line2 of text3.split("\n").slice(1)) {
|
|
35368
|
+
const [provider, model, ...rest] = line2.trim().split(/\s+/);
|
|
35369
|
+
if (!provider || !model || !rest.length) continue;
|
|
35370
|
+
const value = `${provider}/${model}`;
|
|
35371
|
+
if (value.length <= MODEL_MAX && MODEL_PATTERN.test(value) && !out.includes(value)) out.push(value);
|
|
35372
|
+
}
|
|
35373
|
+
return out;
|
|
35374
|
+
}
|
|
35375
|
+
function modelProblem(provider, model, offered) {
|
|
35376
|
+
if (!model || model.length > MODEL_MAX || !MODEL_PATTERN.test(model)) {
|
|
35377
|
+
return tr("modelo inv\xE1lido (use letras, d\xEDgitos e . - _ / :, at\xE9 {0} caracteres)", [MODEL_MAX]);
|
|
35378
|
+
}
|
|
35379
|
+
if (provider === "claude" && !CLAUDE_MODELS.includes(model)) return tr("modelo desconhecido para o Claude Code");
|
|
35380
|
+
if (provider === "gentle-shell") {
|
|
35381
|
+
if (!offered) return tr("a lista de modelos do Gentle Shell ainda n\xE3o carregou: abra o di\xE1logo de novo");
|
|
35382
|
+
if (!offered.includes(model)) return tr("modelo desconhecido para o Gentle Shell");
|
|
35383
|
+
}
|
|
35384
|
+
return void 0;
|
|
35385
|
+
}
|
|
35386
|
+
function createGentleModelLister(opts) {
|
|
35387
|
+
const now = opts.now ?? Date.now;
|
|
35388
|
+
const ttl = opts.ttlMs ?? LIST_TTL_MS;
|
|
35389
|
+
const failTtl = opts.failTtlMs ?? LIST_FAIL_TTL_MS;
|
|
35390
|
+
const timeoutMs = opts.timeoutMs ?? LIST_TIMEOUT_MS;
|
|
35391
|
+
let cache2;
|
|
35392
|
+
let failedAt;
|
|
35393
|
+
let inflight = false;
|
|
35394
|
+
const refresh = () => {
|
|
35395
|
+
inflight = true;
|
|
35396
|
+
let timer;
|
|
35397
|
+
const deadline = new Promise((_ok, no) => {
|
|
35398
|
+
timer = setTimeout(() => no(new Error("timeout")), timeoutMs);
|
|
35399
|
+
});
|
|
35400
|
+
Promise.race([opts.run(), deadline]).then((text3) => {
|
|
35401
|
+
const models = parseListModels(text3);
|
|
35402
|
+
if (!models.length) throw new Error("empty");
|
|
35403
|
+
cache2 = { models, at: now() };
|
|
35404
|
+
failedAt = void 0;
|
|
35405
|
+
}).catch(() => {
|
|
35406
|
+
failedAt = now();
|
|
35407
|
+
}).finally(() => {
|
|
35408
|
+
clearTimeout(timer);
|
|
35409
|
+
inflight = false;
|
|
35410
|
+
});
|
|
35411
|
+
};
|
|
35412
|
+
const failedRecently = () => failedAt !== void 0 && now() - failedAt <= failTtl;
|
|
35413
|
+
return {
|
|
35414
|
+
lookup() {
|
|
35415
|
+
const stale = !cache2 || now() - cache2.at > ttl;
|
|
35416
|
+
if (stale && !inflight && !failedRecently()) refresh();
|
|
35417
|
+
if (cache2) return { state: "ready", models: [...cache2.models] };
|
|
35418
|
+
return inflight ? { state: "loading" } : { state: "unavailable" };
|
|
35419
|
+
},
|
|
35420
|
+
peek: () => cache2 ? [...cache2.models] : void 0
|
|
35421
|
+
};
|
|
35422
|
+
}
|
|
35423
|
+
function createListModelsRunner(bin, timeoutMs = LIST_TIMEOUT_MS) {
|
|
35424
|
+
return () => new Promise((ok, no) => {
|
|
35425
|
+
const path = bin();
|
|
35426
|
+
if (!path) return no(new Error("gentle-shell not found"));
|
|
35427
|
+
const child = execFile4(path, ["--", "--list-models"], { timeout: timeoutMs, windowsHide: true, encoding: "utf8", maxBuffer: 1 << 20 }, (err, out) => err ? no(err) : ok(out));
|
|
35428
|
+
child.stdin?.end();
|
|
35429
|
+
});
|
|
35430
|
+
}
|
|
35431
|
+
function modelOptions(provider, gentle) {
|
|
35432
|
+
if (provider === "claude") return { free: false, state: "ready", models: [...CLAUDE_MODELS] };
|
|
35433
|
+
if (provider === "codex") return { free: true, state: "ready", models: [] };
|
|
35434
|
+
const l = gentle.lookup();
|
|
35435
|
+
return { free: false, state: l.state, models: l.state === "ready" ? l.models : [] };
|
|
35436
|
+
}
|
|
35437
|
+
|
|
35286
35438
|
// server/spawn/spawn.ts
|
|
35287
35439
|
var PROMPT_MAX = 8e3;
|
|
35288
35440
|
var FOLDER_MAX = 1024;
|
|
@@ -35297,7 +35449,7 @@ var MAX_OPEN3 = 5;
|
|
|
35297
35449
|
var ERROR_MAX4 = 300;
|
|
35298
35450
|
var PROVIDERS = ["claude", "gentle-shell", "codex"];
|
|
35299
35451
|
var PROVIDER_NAMES = { claude: "Claude Code", "gentle-shell": "Gentle Shell", codex: "Codex" };
|
|
35300
|
-
function parseSpawn(raw) {
|
|
35452
|
+
function parseSpawn(raw, offered = () => void 0) {
|
|
35301
35453
|
const r = raw && typeof raw === "object" ? raw : {};
|
|
35302
35454
|
const folder = typeof r.folder === "string" ? r.folder.trim() : "";
|
|
35303
35455
|
const prompt = typeof r.prompt === "string" ? r.prompt.replace(/\s+$/, "") : "";
|
|
@@ -35312,12 +35464,18 @@ function parseSpawn(raw) {
|
|
|
35312
35464
|
if (destination.kind === "background" && provider !== "claude") {
|
|
35313
35465
|
return { error: tr("{0} s\xF3 abre no herdr (n\xE3o tem modo em segundo plano)", [PROVIDER_NAMES[provider]]) };
|
|
35314
35466
|
}
|
|
35315
|
-
|
|
35467
|
+
const model = r.model === void 0 || r.model === null || r.model === "" ? void 0 : r.model;
|
|
35468
|
+
if (model !== void 0) {
|
|
35469
|
+
const problem = typeof model === "string" ? modelProblem(provider, model, offered(provider)) : tr("modelo inv\xE1lido");
|
|
35470
|
+
if (problem) return { error: problem };
|
|
35471
|
+
}
|
|
35472
|
+
return { folder, prompt, provider, destination, ...typeof model === "string" ? { model } : {} };
|
|
35316
35473
|
}
|
|
35317
35474
|
function parseDestination(raw) {
|
|
35318
35475
|
if (raw === void 0) return { kind: "background" };
|
|
35319
35476
|
const d = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : void 0;
|
|
35320
35477
|
if (d?.kind === "background") return { kind: "background" };
|
|
35478
|
+
if (d?.kind === "window") return { kind: "window" };
|
|
35321
35479
|
if (d?.kind === "tab" && typeof d.workspaceId === "string" && isHerdrWorkspaceId(d.workspaceId)) return { kind: "tab", workspaceId: d.workspaceId };
|
|
35322
35480
|
if (d?.kind === "split" && typeof d.paneId === "string" && isHerdrPaneId(d.paneId) && (d.direction === "right" || d.direction === "down")) {
|
|
35323
35481
|
return { kind: "split", paneId: d.paneId, direction: d.direction };
|
|
@@ -35337,12 +35495,12 @@ function sessionName(prompt) {
|
|
|
35337
35495
|
return cut3 ? `Busybits: ${cut3}` : "Busybits";
|
|
35338
35496
|
}
|
|
35339
35497
|
function cliArgs(req) {
|
|
35340
|
-
const args = ["--bg", "-n", sessionName(req.prompt)];
|
|
35498
|
+
const args = ["--bg", "-n", sessionName(req.prompt), ...req.model ? ["--model", req.model] : []];
|
|
35341
35499
|
return req.prompt.trim() ? [...args, "--", req.prompt] : args;
|
|
35342
35500
|
}
|
|
35343
35501
|
function createCliRunner(bin, timeoutMs = CLI_TIMEOUT_MS) {
|
|
35344
35502
|
return (req) => new Promise((ok) => {
|
|
35345
|
-
const child =
|
|
35503
|
+
const child = execFile5(bin, cliArgs(req), { cwd: req.folder, timeout: timeoutMs, windowsHide: true, encoding: "utf8" }, (err, out, stderr) => {
|
|
35346
35504
|
const id = /backgrounded\s*·\s*([\w-]+)/.exec(out ?? "")?.[1];
|
|
35347
35505
|
if (!err && id) return ok({ ok: true, id });
|
|
35348
35506
|
const line2 = [stderr, out, err?.message].map((t) => (t ?? "").split("\n").map((l) => l.trim()).find(Boolean)).find(Boolean);
|
|
@@ -35375,7 +35533,7 @@ function folderProblem(folder, stat3 = statSync23) {
|
|
|
35375
35533
|
function createOpener(platform = process.platform, timeoutMs = OPEN_TIMEOUT_MS) {
|
|
35376
35534
|
const [bin, pre2] = platform === "darwin" ? ["open", []] : platform === "win32" ? ["cmd", ["/c", "start", '""']] : ["xdg-open", []];
|
|
35377
35535
|
return (url) => new Promise((ok) => {
|
|
35378
|
-
|
|
35536
|
+
execFile5(bin, [...pre2, url], { timeout: timeoutMs, windowsHide: true, encoding: "utf8" }, (err, _out, stderr) => {
|
|
35379
35537
|
if (!err) return ok({ ok: true });
|
|
35380
35538
|
const line2 = (stderr || err.message || "").split("\n").find((l) => l.trim()) ?? tr("falhou");
|
|
35381
35539
|
ok({ ok: false, error: `${bin}: ${line2.trim()}`.slice(0, ERROR_MAX4) });
|
|
@@ -35400,12 +35558,16 @@ var SpawnService = class {
|
|
|
35400
35558
|
}
|
|
35401
35559
|
submit(raw) {
|
|
35402
35560
|
this.prune();
|
|
35403
|
-
const req = parseSpawn(raw);
|
|
35561
|
+
const req = parseSpawn(raw, (p) => p === "gentle-shell" ? this.opts.gentleModels?.() : void 0);
|
|
35404
35562
|
if ("error" in req) return { error: "invalid", reason: req.error };
|
|
35405
35563
|
if (!this.opts.opener && (req.destination.kind !== "background" || req.provider !== "claude")) {
|
|
35406
35564
|
return { error: "invalid", reason: tr("no Docker o agente novo s\xF3 abre em segundo plano, com o Claude Code") };
|
|
35407
35565
|
}
|
|
35408
|
-
if (
|
|
35566
|
+
if (!this.opts.opener && req.model) return { error: "invalid", reason: tr("no Docker o agente novo n\xE3o aceita escolher o modelo") };
|
|
35567
|
+
if (req.destination.kind === "window") {
|
|
35568
|
+
const w = this.opts.window?.status();
|
|
35569
|
+
if (!w?.available) return { error: "unavailable", reason: w?.reason ?? tr("n\xE3o h\xE1 terminal dispon\xEDvel para abrir uma janela") };
|
|
35570
|
+
} else if (req.destination.kind !== "background" && !this.opts.herdr) return { error: "unavailable", reason: tr("o herdr n\xE3o est\xE1 dispon\xEDvel") };
|
|
35409
35571
|
if (!this.available()) {
|
|
35410
35572
|
return { error: "unavailable", reason: tr("o auxiliar do computador n\xE3o est\xE1 rodando: deixe npm run codex:bridge no ar (o Habblaud est\xE1 no Docker)") };
|
|
35411
35573
|
}
|
|
@@ -35475,13 +35637,22 @@ var SpawnService = class {
|
|
|
35475
35637
|
}
|
|
35476
35638
|
const prompt = promptWithAttachments(e.req.prompt, paths);
|
|
35477
35639
|
const dest = e.req.destination;
|
|
35478
|
-
if (dest.kind === "background") return this.resolve(e, await launch({ folder: e.req.folder, prompt }, opener, this.opts.cli));
|
|
35640
|
+
if (dest.kind === "background") return this.resolve(e, await launch({ folder: e.req.folder, prompt, ...e.req.model ? { model: e.req.model } : {} }, opener, this.opts.cli));
|
|
35641
|
+
if (dest.kind === "window") return this.resolveWindow(e, prompt);
|
|
35479
35642
|
return this.resolveHerdr(e, dest, prompt);
|
|
35480
35643
|
}
|
|
35644
|
+
/** Janela nova do terminal do sistema: o pedido (com os caminhos dos anexos) vai como argumento do agente. */
|
|
35645
|
+
async resolveWindow(e, prompt) {
|
|
35646
|
+
const w = this.opts.window;
|
|
35647
|
+
if (!w) return this.resolve(e, { ok: false, error: tr("n\xE3o h\xE1 terminal dispon\xEDvel para abrir uma janela") });
|
|
35648
|
+
const { provider, folder, model } = e.req;
|
|
35649
|
+
const r = await w.open({ provider, folder, prompt, ...model ? { model } : {} }).catch((err) => ({ ok: false, error: String(err?.message ?? err) }));
|
|
35650
|
+
this.resolve(e, r.ok ? { ok: true, how: "window" } : { ok: false, error: r.error.slice(0, ERROR_MAX4) });
|
|
35651
|
+
}
|
|
35481
35652
|
async resolveHerdr(e, destination, prompt) {
|
|
35482
35653
|
const herdr2 = this.opts.herdr;
|
|
35483
35654
|
if (!herdr2) return this.resolve(e, { ok: false, error: tr("o herdr n\xE3o est\xE1 dispon\xEDvel") });
|
|
35484
|
-
const { provider, folder } = e.req;
|
|
35655
|
+
const { provider, folder, model } = e.req;
|
|
35485
35656
|
const recorded = /* @__PURE__ */ new Set();
|
|
35486
35657
|
const onPane = (paneId) => {
|
|
35487
35658
|
if (recorded.has(paneId)) return;
|
|
@@ -35495,7 +35666,7 @@ var SpawnService = class {
|
|
|
35495
35666
|
e.info.error = tr("o painel {0} do herdr foi criado, mas o agente n\xE3o come\xE7ou: {1}", [paneId, e.info.error ?? ""]).slice(0, ERROR_MAX4);
|
|
35496
35667
|
}
|
|
35497
35668
|
};
|
|
35498
|
-
const r = await herdr2({ provider, folder, prompt, destination }, onPane).catch((err) => ({
|
|
35669
|
+
const r = await herdr2({ provider, folder, prompt, destination, ...model ? { model } : {} }, onPane).catch((err) => ({
|
|
35499
35670
|
ok: false,
|
|
35500
35671
|
error: String(err?.message ?? err).slice(0, ERROR_MAX4)
|
|
35501
35672
|
}));
|
|
@@ -35536,7 +35707,7 @@ var SpawnService = class {
|
|
|
35536
35707
|
};
|
|
35537
35708
|
|
|
35538
35709
|
// server/herdr/cli.ts
|
|
35539
|
-
import { execFile as
|
|
35710
|
+
import { execFile as execFile6 } from "node:child_process";
|
|
35540
35711
|
import { join as join30 } from "node:path";
|
|
35541
35712
|
var HERDR_TIMEOUT_MS = 5e3;
|
|
35542
35713
|
var TIMEOUT_SLACK_MS = 5e3;
|
|
@@ -35591,7 +35762,7 @@ function errorOf(json) {
|
|
|
35591
35762
|
function createHerdrExec(bin, env, timeoutMs = HERDR_TIMEOUT_MS) {
|
|
35592
35763
|
return (args, callTimeout) => new Promise((ok) => {
|
|
35593
35764
|
try {
|
|
35594
|
-
const child =
|
|
35765
|
+
const child = execFile6(
|
|
35595
35766
|
bin,
|
|
35596
35767
|
[...args],
|
|
35597
35768
|
{ env, timeout: callTimeout ?? timeoutMs, windowsHide: true, encoding: "utf8", maxBuffer: 4 * 1024 * 1024 },
|
|
@@ -35754,6 +35925,11 @@ var HerdrClient = class {
|
|
|
35754
35925
|
}
|
|
35755
35926
|
};
|
|
35756
35927
|
|
|
35928
|
+
// server/spawn/terminal.ts
|
|
35929
|
+
import { spawn as nodeSpawn } from "node:child_process";
|
|
35930
|
+
import { readFileSync as readFileSync25 } from "node:fs";
|
|
35931
|
+
import { basename as basename11 } from "node:path";
|
|
35932
|
+
|
|
35757
35933
|
// server/herdr/links.ts
|
|
35758
35934
|
import { resolve as resolvePath } from "node:path";
|
|
35759
35935
|
var LINK_WINDOW_MS = 12e4;
|
|
@@ -35814,8 +35990,16 @@ var BACKOFF_MAX_MS = 2e3;
|
|
|
35814
35990
|
var INBOX_WAIT_MS = 25e3;
|
|
35815
35991
|
var EARLY_MS2 = 5e3;
|
|
35816
35992
|
var GENTLE_SHELL_COMMAND = "gentle-shell";
|
|
35817
|
-
function providerArgs(provider, name) {
|
|
35818
|
-
|
|
35993
|
+
function providerArgs(provider, name, model) {
|
|
35994
|
+
if (provider === "claude") return model ? ["-n", name, "--model", model] : ["-n", name];
|
|
35995
|
+
return model ? ["-m", model] : [];
|
|
35996
|
+
}
|
|
35997
|
+
function gentleShellArgv(model, piArgs = []) {
|
|
35998
|
+
const args = [...piArgs, ...model ? ["--model", model] : []];
|
|
35999
|
+
return args.length ? [GENTLE_SHELL_COMMAND, "--", ...args] : [GENTLE_SHELL_COMMAND];
|
|
36000
|
+
}
|
|
36001
|
+
function gentleShellCommand(model, piArgs = []) {
|
|
36002
|
+
return gentleShellArgv(model, piArgs).join(" ");
|
|
35819
36003
|
}
|
|
35820
36004
|
function agentName(provider, taken, tag) {
|
|
35821
36005
|
const prefix = provider === "gentle-shell" ? "gentle" : provider;
|
|
@@ -35852,6 +36036,7 @@ function matchGentle(agents2, known, folder, at) {
|
|
|
35852
36036
|
var message = (err) => err instanceof Error ? err.message : String(err);
|
|
35853
36037
|
var sleep = (ms) => new Promise((ok) => setTimeout(ok, ms));
|
|
35854
36038
|
async function launchInHerdr(client, req, opts = {}) {
|
|
36039
|
+
if (req.model !== void 0 && (req.model.length > MODEL_MAX || !MODEL_PATTERN.test(req.model))) return { ok: false, error: tr("modelo inv\xE1lido") };
|
|
35855
36040
|
const now = opts.now ?? Date.now;
|
|
35856
36041
|
const maxMs = opts.maxMs ?? HERDR_LAUNCH_MAX_MS;
|
|
35857
36042
|
const pollMs = opts.pollMs ?? POLL_MS2;
|
|
@@ -35955,10 +36140,10 @@ async function launchInHerdr(client, req, opts = {}) {
|
|
|
35955
36140
|
try {
|
|
35956
36141
|
if (state.over) return partial(late2);
|
|
35957
36142
|
if (req.provider === "gentle-shell") {
|
|
35958
|
-
await client.run(paneId,
|
|
36143
|
+
await client.run(paneId, gentleShellCommand(req.model));
|
|
35959
36144
|
} else {
|
|
35960
36145
|
const name = agentName(req.provider, names2, launchTag(now()));
|
|
35961
|
-
await client.startAgent(name, req.provider, paneId, providerArgs(req.provider, name), Math.min(START_MAX_MS, left()));
|
|
36146
|
+
await client.startAgent(name, req.provider, paneId, providerArgs(req.provider, name, req.model), Math.min(START_MAX_MS, left()));
|
|
35962
36147
|
}
|
|
35963
36148
|
if (req.prompt.trim() || req.provider === "gentle-shell") {
|
|
35964
36149
|
await retrying(() => client.waitIdle(paneId, Math.min(START_MAX_MS, left())), noAgentYet);
|
|
@@ -35992,6 +36177,163 @@ async function launchInHerdr(client, req, opts = {}) {
|
|
|
35992
36177
|
}
|
|
35993
36178
|
}
|
|
35994
36179
|
|
|
36180
|
+
// server/spawn/terminal.ts
|
|
36181
|
+
var LINUX_TERMINALS = ["x-terminal-emulator", "gnome-terminal", "konsole", "kitty", "alacritty", "wezterm", "xfce4-terminal", "xterm"];
|
|
36182
|
+
function detectWsl(env, platform = process.platform, readProc = () => readFileSync25("/proc/version", "utf8")) {
|
|
36183
|
+
if (platform !== "linux") return false;
|
|
36184
|
+
if (env.WSL_DISTRO_NAME || env.WSL_INTEROP) return true;
|
|
36185
|
+
try {
|
|
36186
|
+
return /microsoft/i.test(readProc());
|
|
36187
|
+
} catch {
|
|
36188
|
+
return false;
|
|
36189
|
+
}
|
|
36190
|
+
}
|
|
36191
|
+
function detectTerminal(e) {
|
|
36192
|
+
if (e.inDocker) return { available: false, reason: tr("indispon\xEDvel no Docker") };
|
|
36193
|
+
if (e.platform === "darwin") {
|
|
36194
|
+
const bin = e.which("osascript");
|
|
36195
|
+
return bin ? { available: true, kind: "terminal-app", bin } : { available: false, reason: tr("n\xE3o achei o osascript para abrir o Terminal") };
|
|
36196
|
+
}
|
|
36197
|
+
if (e.platform === "win32") {
|
|
36198
|
+
const wt = e.which("wt.exe");
|
|
36199
|
+
return wt ? { available: true, kind: "wt", bin: wt } : { available: true, kind: "cmd-start", bin: e.which("cmd.exe") ?? "cmd.exe" };
|
|
36200
|
+
}
|
|
36201
|
+
if (e.wsl) {
|
|
36202
|
+
const wt = e.which("wt.exe");
|
|
36203
|
+
if (wt) return { available: true, kind: "wt-wsl", bin: wt };
|
|
36204
|
+
}
|
|
36205
|
+
if (!e.env.DISPLAY && !e.env.WAYLAND_DISPLAY) return { available: false, reason: tr("sem ambiente gr\xE1fico (DISPLAY ou WAYLAND_DISPLAY) para abrir um terminal") };
|
|
36206
|
+
const custom = e.env.TERMINAL?.trim();
|
|
36207
|
+
if (custom) {
|
|
36208
|
+
const bin = e.which(custom);
|
|
36209
|
+
if (bin) {
|
|
36210
|
+
const name = basename11(custom);
|
|
36211
|
+
return { available: true, kind: LINUX_TERMINALS.includes(name) ? name : "x-terminal-emulator", bin };
|
|
36212
|
+
}
|
|
36213
|
+
}
|
|
36214
|
+
for (const kind of LINUX_TERMINALS) {
|
|
36215
|
+
const bin = e.which(kind);
|
|
36216
|
+
if (bin) return { available: true, kind, bin };
|
|
36217
|
+
}
|
|
36218
|
+
return { available: false, reason: tr("n\xE3o achei um terminal (defina $TERMINAL ou instale gnome-terminal, konsole, kitty, alacritty, wezterm, xfce4-terminal ou xterm)") };
|
|
36219
|
+
}
|
|
36220
|
+
var CONTROL4 = /[\x00-\x1f\x7f]/;
|
|
36221
|
+
function appleScriptString(text3) {
|
|
36222
|
+
if (CONTROL4.test(text3)) return void 0;
|
|
36223
|
+
return `"${text3.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
36224
|
+
}
|
|
36225
|
+
function shellQuote(text3, eol) {
|
|
36226
|
+
if (/^[A-Za-z0-9_@%+=:,./-]+$/.test(text3)) return text3;
|
|
36227
|
+
if (!CONTROL4.test(text3)) return `'${text3.replace(/'/g, "'\\''")}'`;
|
|
36228
|
+
if (!eol || /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/.test(text3)) return void 0;
|
|
36229
|
+
const esc2 = text3.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
|
|
36230
|
+
return `$'${esc2}'`;
|
|
36231
|
+
}
|
|
36232
|
+
function quoteWindowsArg(arg) {
|
|
36233
|
+
if (arg !== "" && !/[\s"]/.test(arg)) return arg;
|
|
36234
|
+
let out = '"';
|
|
36235
|
+
let slashes = 0;
|
|
36236
|
+
for (const ch of arg) {
|
|
36237
|
+
if (ch === "\\") slashes++;
|
|
36238
|
+
else {
|
|
36239
|
+
out += ch === '"' ? "\\".repeat(slashes * 2 + 1) + '"' : "\\".repeat(slashes) + ch;
|
|
36240
|
+
slashes = 0;
|
|
36241
|
+
}
|
|
36242
|
+
}
|
|
36243
|
+
return `${out}${"\\".repeat(slashes * 2)}"`;
|
|
36244
|
+
}
|
|
36245
|
+
function cmdArg(arg) {
|
|
36246
|
+
if (/["%\r\n\0]/.test(arg)) return void 0;
|
|
36247
|
+
return arg === "" || /[\s&|<>^()]/.test(arg) ? quoteWindowsArg(arg) : arg;
|
|
36248
|
+
}
|
|
36249
|
+
var wtArg = (arg) => arg.replace(/;/g, "\\;");
|
|
36250
|
+
function terminalCommand(pick2, folder, argv, _platform = process.platform) {
|
|
36251
|
+
const { kind, bin } = pick2;
|
|
36252
|
+
switch (kind) {
|
|
36253
|
+
case "gnome-terminal":
|
|
36254
|
+
return { bin, args: [`--working-directory=${folder}`, "--", ...argv], cwd: folder };
|
|
36255
|
+
case "xfce4-terminal":
|
|
36256
|
+
return { bin, args: [`--working-directory=${folder}`, "-x", ...argv], cwd: folder };
|
|
36257
|
+
case "konsole":
|
|
36258
|
+
return { bin, args: ["--workdir", folder, "-e", ...argv], cwd: folder };
|
|
36259
|
+
case "kitty":
|
|
36260
|
+
return { bin, args: ["--directory", folder, ...argv], cwd: folder };
|
|
36261
|
+
case "alacritty":
|
|
36262
|
+
return { bin, args: ["--working-directory", folder, "-e", ...argv], cwd: folder };
|
|
36263
|
+
case "wezterm":
|
|
36264
|
+
return { bin, args: ["start", "--cwd", folder, "--", ...argv], cwd: folder };
|
|
36265
|
+
case "xterm":
|
|
36266
|
+
case "x-terminal-emulator":
|
|
36267
|
+
return { bin, args: ["-e", ...argv], cwd: folder };
|
|
36268
|
+
case "wt-wsl":
|
|
36269
|
+
return { bin, args: ["wsl.exe", "--cd", folder, "--exec", "bash", "-lc", 'exec "$@"', "bash", ...argv].map(wtArg) };
|
|
36270
|
+
case "wt":
|
|
36271
|
+
return { bin, args: ["-d", folder, ...argv].map(wtArg) };
|
|
36272
|
+
case "cmd-start": {
|
|
36273
|
+
const parts = [folder, ...argv].map(cmdArg);
|
|
36274
|
+
if (parts.some((p) => p === void 0)) return { error: tr("o pedido ou a pasta tem caracteres (aspas, % ou quebra de linha) que o cmd.exe n\xE3o aceita com seguran\xE7a") };
|
|
36275
|
+
const [dir, ...rest] = parts;
|
|
36276
|
+
return { bin, args: ["/d", "/c", `start "" /D ${dir} ${rest.join(" ")}`], verbatim: true };
|
|
36277
|
+
}
|
|
36278
|
+
case "terminal-app": {
|
|
36279
|
+
const dir = shellQuote(folder, false);
|
|
36280
|
+
const words2 = argv.map((a) => shellQuote(a, true));
|
|
36281
|
+
if (dir === void 0 || words2.some((w) => w === void 0)) return { error: tr("o pedido ou a pasta tem caracteres de controle que o Terminal n\xE3o aceita com seguran\xE7a") };
|
|
36282
|
+
const script2 = appleScriptString(`cd ${dir} && ${words2.join(" ")}`);
|
|
36283
|
+
if (script2 === void 0) return { error: tr("o pedido ou a pasta tem caracteres de controle que o Terminal n\xE3o aceita com seguran\xE7a") };
|
|
36284
|
+
return { bin, args: ["-e", 'tell application "Terminal"', "-e", "activate", "-e", `do script ${script2}`, "-e", "end tell"] };
|
|
36285
|
+
}
|
|
36286
|
+
}
|
|
36287
|
+
}
|
|
36288
|
+
function windowArgv(req, bins = {}) {
|
|
36289
|
+
const hasPrompt = req.prompt.trim() !== "";
|
|
36290
|
+
if (req.provider === "gentle-shell") {
|
|
36291
|
+
const text3 = /^[-@]/.test(req.prompt) ? ` ${req.prompt}` : req.prompt;
|
|
36292
|
+
return gentleShellArgv(req.model, hasPrompt ? [text3] : []);
|
|
36293
|
+
}
|
|
36294
|
+
const tail = hasPrompt ? ["--", req.prompt] : [];
|
|
36295
|
+
if (req.provider === "claude") return [bins.claude ?? "claude", ...providerArgs("claude", sessionName(req.prompt), req.model), ...tail];
|
|
36296
|
+
return ["codex", ...providerArgs("codex", "codex", req.model), ...tail];
|
|
36297
|
+
}
|
|
36298
|
+
function createTerminalLauncher(o) {
|
|
36299
|
+
const spawn2 = o.spawn ?? nodeSpawn;
|
|
36300
|
+
return {
|
|
36301
|
+
status() {
|
|
36302
|
+
const p = detectTerminal(o);
|
|
36303
|
+
return p.available ? { available: true } : { available: false, reason: p.reason };
|
|
36304
|
+
},
|
|
36305
|
+
open(req) {
|
|
36306
|
+
const pick2 = detectTerminal(o);
|
|
36307
|
+
if (!pick2.available) return Promise.resolve({ ok: false, error: pick2.reason });
|
|
36308
|
+
const cmd = terminalCommand(pick2, req.folder, windowArgv(req, o.bins), o.platform);
|
|
36309
|
+
if ("error" in cmd) return Promise.resolve({ ok: false, error: cmd.error });
|
|
36310
|
+
return new Promise((ok) => {
|
|
36311
|
+
try {
|
|
36312
|
+
const child = spawn2(cmd.bin, cmd.args, {
|
|
36313
|
+
...cmd.cwd ? { cwd: cmd.cwd } : {},
|
|
36314
|
+
detached: true,
|
|
36315
|
+
stdio: "ignore",
|
|
36316
|
+
windowsHide: true,
|
|
36317
|
+
...cmd.verbatim ? { windowsVerbatimArguments: true } : {}
|
|
36318
|
+
});
|
|
36319
|
+
child.once("error", (err) => ok({ ok: false, error: `${basename11(cmd.bin)}: ${err.message}`.slice(0, 300) }));
|
|
36320
|
+
child.once("spawn", () => {
|
|
36321
|
+
child.unref();
|
|
36322
|
+
ok({ ok: true });
|
|
36323
|
+
});
|
|
36324
|
+
} catch (err) {
|
|
36325
|
+
ok({ ok: false, error: `${basename11(cmd.bin)}: ${err.message}`.slice(0, 300) });
|
|
36326
|
+
}
|
|
36327
|
+
});
|
|
36328
|
+
}
|
|
36329
|
+
};
|
|
36330
|
+
}
|
|
36331
|
+
function systemTerminalLauncher(inDocker, bins) {
|
|
36332
|
+
const env = process.env;
|
|
36333
|
+
const platform = process.platform;
|
|
36334
|
+
return createTerminalLauncher({ platform, env, which: (name) => findExecutable(name, env, platform), wsl: detectWsl(env, platform), inDocker, bins });
|
|
36335
|
+
}
|
|
36336
|
+
|
|
35995
36337
|
// server/spawn/providers.ts
|
|
35996
36338
|
function detectProviders(env, find = {}) {
|
|
35997
36339
|
const claude2 = find.claude ?? (() => runnableClaudeBin(env));
|
|
@@ -36053,7 +36395,7 @@ function startAttachmentsPruner(opts) {
|
|
|
36053
36395
|
}
|
|
36054
36396
|
|
|
36055
36397
|
// server/settings/attachments.ts
|
|
36056
|
-
import { mkdirSync as mkdirSync17, readFileSync as
|
|
36398
|
+
import { mkdirSync as mkdirSync17, readFileSync as readFileSync26, renameSync as renameSync15, writeFileSync as writeFileSync15 } from "node:fs";
|
|
36057
36399
|
import { dirname as dirname16 } from "node:path";
|
|
36058
36400
|
var RETENTION_CHOICES = [1, 3, 7, 30];
|
|
36059
36401
|
var DEFAULT_RETENTION_DAYS = 7;
|
|
@@ -36082,7 +36424,7 @@ var AttachmentSettingsStore = class {
|
|
|
36082
36424
|
load() {
|
|
36083
36425
|
if (!this.file) return null;
|
|
36084
36426
|
try {
|
|
36085
|
-
return parseRetention(JSON.parse(
|
|
36427
|
+
return parseRetention(JSON.parse(readFileSync26(this.file, "utf8")));
|
|
36086
36428
|
} catch (err) {
|
|
36087
36429
|
if (err.code !== "ENOENT") log.warn(tr("attachments.json ileg\xEDvel ({0}); usando o padr\xE3o de {1} dias.", [errMsg(err), DEFAULT_RETENTION_DAYS]));
|
|
36088
36430
|
return null;
|
|
@@ -36153,8 +36495,8 @@ function recentFolders(sessions, rooms, limit = FOLDERS_LIMIT) {
|
|
|
36153
36495
|
}
|
|
36154
36496
|
|
|
36155
36497
|
// server/dictation/whisper.ts
|
|
36156
|
-
import { execFile as
|
|
36157
|
-
import { existsSync as existsSync12, mkdtempSync as mkdtempSync2, readFileSync as
|
|
36498
|
+
import { execFile as execFile7 } from "node:child_process";
|
|
36499
|
+
import { existsSync as existsSync12, mkdtempSync as mkdtempSync2, readFileSync as readFileSync27, rmSync as rmSync8, writeFileSync as writeFileSync16 } from "node:fs";
|
|
36158
36500
|
import { homedir as homedir7, tmpdir } from "node:os";
|
|
36159
36501
|
import { delimiter as delimiter2, join as join32 } from "node:path";
|
|
36160
36502
|
var TRANSCRIBE_TIMEOUT_MS = 12e4;
|
|
@@ -36182,7 +36524,7 @@ function findWhisper(env = process.env, exists = existsSync12) {
|
|
|
36182
36524
|
}
|
|
36183
36525
|
function run2(bin, args, timeoutMs) {
|
|
36184
36526
|
return new Promise((ok) => {
|
|
36185
|
-
|
|
36527
|
+
execFile7(bin, args, { timeout: timeoutMs, encoding: "utf8", maxBuffer: 8 * 1024 * 1024 }, (err, _out, stderr) => {
|
|
36186
36528
|
if (!err) return ok({ ok: true });
|
|
36187
36529
|
const line2 = (stderr || err.message || "").split("\n").filter((l) => l.trim()).pop() ?? tr("falhou");
|
|
36188
36530
|
ok({ ok: false, error: line2.trim().slice(0, 300) });
|
|
@@ -36207,7 +36549,7 @@ function createWhisperTranscriber(setup, timeoutMs = TRANSCRIBE_TIMEOUT_MS) {
|
|
|
36207
36549
|
const out = join32(dir, `out-${lang}`);
|
|
36208
36550
|
const r = await run2(setup.bin, ["-m", setup.model, "-l", lang, "-f", wav, "-nt", "-np", "-oj", "-of", out], timeoutMs);
|
|
36209
36551
|
if (!r.ok) throw new Error(tr("o Whisper falhou ({0})", [r.error]));
|
|
36210
|
-
return parseWhisperJson(
|
|
36552
|
+
return parseWhisperJson(readFileSync27(`${out}.json`, "utf8"));
|
|
36211
36553
|
};
|
|
36212
36554
|
const first = await pass("auto");
|
|
36213
36555
|
if (!first.lang || setup.langs.includes(first.lang) || !first.text) return first;
|
|
@@ -36221,7 +36563,7 @@ function createWhisperTranscriber(setup, timeoutMs = TRANSCRIBE_TIMEOUT_MS) {
|
|
|
36221
36563
|
|
|
36222
36564
|
// server/deliveries/fetcher.ts
|
|
36223
36565
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
36224
|
-
import { readFileSync as
|
|
36566
|
+
import { readFileSync as readFileSync28 } from "node:fs";
|
|
36225
36567
|
var HOST_PRESENCE_MS3 = 1e4;
|
|
36226
36568
|
var WAIT_MS = 2e4;
|
|
36227
36569
|
var CACHE_MAX_BYTES = 80 * 1024 * 1024;
|
|
@@ -36304,7 +36646,7 @@ var FileFetcher = class {
|
|
|
36304
36646
|
const c = (this.opts.check ?? checkFile)(path);
|
|
36305
36647
|
if ("error" in c) return { error: c.error, status: c.error === tr("arquivo n\xE3o encontrado") ? 404 : 403 };
|
|
36306
36648
|
try {
|
|
36307
|
-
const data = (this.opts.read ??
|
|
36649
|
+
const data = (this.opts.read ?? readFileSync28)(c.path);
|
|
36308
36650
|
this.remember(path, data);
|
|
36309
36651
|
return { data };
|
|
36310
36652
|
} catch {
|
|
@@ -37326,7 +37668,7 @@ function socialRoutes(social) {
|
|
|
37326
37668
|
}
|
|
37327
37669
|
|
|
37328
37670
|
// server/world/settings.ts
|
|
37329
|
-
import { chmodSync as chmodSync7, mkdirSync as mkdirSync18, readFileSync as
|
|
37671
|
+
import { chmodSync as chmodSync7, mkdirSync as mkdirSync18, readFileSync as readFileSync29, renameSync as renameSync16, rmSync as rmSync9, statSync as statSync24, writeFileSync as writeFileSync17 } from "node:fs";
|
|
37330
37672
|
import { dirname as dirname17 } from "node:path";
|
|
37331
37673
|
var DEVICE_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
37332
37674
|
var TOKEN_RE = /^[A-Za-z0-9_-]{16,256}$/;
|
|
@@ -37373,7 +37715,7 @@ var WorldSettingsStore = class {
|
|
|
37373
37715
|
const st = statSync24(this.file);
|
|
37374
37716
|
if (st.size > MAX_FILE) throw new Error("too large");
|
|
37375
37717
|
if ((st.mode & 63) !== 0) chmodSync7(this.file, 384);
|
|
37376
|
-
const raw = JSON.parse(
|
|
37718
|
+
const raw = JSON.parse(readFileSync29(this.file, "utf8"));
|
|
37377
37719
|
const obj4 = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
37378
37720
|
if (isWorldThemeChoice(obj4.theme)) this.theme = obj4.theme;
|
|
37379
37721
|
this.session = parseWorldSession(raw);
|
|
@@ -38102,7 +38444,7 @@ function createWorldRoutes(service, viewer, social) {
|
|
|
38102
38444
|
}
|
|
38103
38445
|
|
|
38104
38446
|
// server/world/uplink.ts
|
|
38105
|
-
import { chmodSync as chmodSync8, mkdirSync as mkdirSync19, readFileSync as
|
|
38447
|
+
import { chmodSync as chmodSync8, mkdirSync as mkdirSync19, readFileSync as readFileSync30, renameSync as renameSync17, rmSync as rmSync10, writeFileSync as writeFileSync18 } from "node:fs";
|
|
38106
38448
|
import { dirname as dirname18 } from "node:path";
|
|
38107
38449
|
|
|
38108
38450
|
// shared/world/appearance-flat.ts
|
|
@@ -39164,7 +39506,7 @@ var BuildingUplink = class {
|
|
|
39164
39506
|
this.deviceId = s2?.deviceId;
|
|
39165
39507
|
if (!file) return;
|
|
39166
39508
|
try {
|
|
39167
|
-
const raw = JSON.parse(
|
|
39509
|
+
const raw = JSON.parse(readFileSync30(file, "utf8"));
|
|
39168
39510
|
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);
|
|
39169
39511
|
if (!ok || raw.deviceId !== s2?.deviceId) return this.removeLast();
|
|
39170
39512
|
this.last = raw;
|
|
@@ -40598,13 +40940,17 @@ var gentleInbox = () => messages && {
|
|
|
40598
40940
|
return { ok: false, retry: false, reason: "reason" in r ? r.reason : tr("o agente n\xE3o foi achado") };
|
|
40599
40941
|
}
|
|
40600
40942
|
};
|
|
40943
|
+
var gentleModels = createGentleModelLister({ run: createListModelsRunner(() => config.inDocker ? void 0 : findExecutable("gentle-shell", process.env)) });
|
|
40944
|
+
var windowLauncher = spawnOn && !config.inDocker ? systemTerminalLauncher(false, { claude: spawnBin }) : void 0;
|
|
40601
40945
|
var spawn = spawnOn ? new SpawnService(
|
|
40602
40946
|
config.inDocker ? { attachments } : {
|
|
40603
40947
|
opener: createOpener(),
|
|
40604
40948
|
cli: spawnBin ? createCliRunner(spawnBin) : void 0,
|
|
40605
40949
|
attachments,
|
|
40950
|
+
gentleModels: () => gentleModels.peek(),
|
|
40606
40951
|
herdr: herdrClient ? (r, onPane) => launchInHerdr(herdrClient, r, { onPane, inbox: gentleInbox() }) : void 0,
|
|
40607
|
-
onHerdrLaunch: herdrLinks ? (r) => herdrLinks.record(r) : void 0
|
|
40952
|
+
onHerdrLaunch: herdrLinks ? (r) => herdrLinks.record(r) : void 0,
|
|
40953
|
+
window: windowLauncher
|
|
40608
40954
|
}
|
|
40609
40955
|
) : void 0;
|
|
40610
40956
|
var whisper = config.messages && !config.inDocker ? findWhisper() : void 0;
|
|
@@ -40740,11 +41086,13 @@ var api = createApiHandler({
|
|
|
40740
41086
|
pty: config.central ? createPtyRoutes(ptys, () => config.messages ? late.remotePtys : void 0) : ptys ? createPtyRoutes(ptys) : void 0,
|
|
40741
41087
|
spawn,
|
|
40742
41088
|
herdr,
|
|
41089
|
+
spawnWindow: windowLauncher ? () => windowLauncher.status() : void 0,
|
|
40743
41090
|
providers,
|
|
40744
41091
|
attachments,
|
|
40745
41092
|
dictation,
|
|
40746
41093
|
deliveries,
|
|
40747
41094
|
files: deliveryFiles,
|
|
41095
|
+
spawnModels: (provider) => modelOptions(provider, gentleModels),
|
|
40748
41096
|
spawnFolders: async () => {
|
|
40749
41097
|
const snap = hub.current();
|
|
40750
41098
|
const last = /* @__PURE__ */ new Map();
|
|
@@ -40938,7 +41286,7 @@ if (config.central) {
|
|
|
40938
41286
|
listener = startCentralListener({
|
|
40939
41287
|
host: bind.host,
|
|
40940
41288
|
port: central.port,
|
|
40941
|
-
tls: { key:
|
|
41289
|
+
tls: { key: readFileSync31(paths.serverKey), cert: readFileSync31(paths.serverCert), ca: readFileSync31(paths.caCert) },
|
|
40942
41290
|
machines,
|
|
40943
41291
|
routes: centralHub
|
|
40944
41292
|
});
|