@leg3ndy/otto-bridge 1.0.8 → 1.0.9
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/README.md +8 -8
- package/dist/cli_terminal.js +173 -30
- package/dist/types.js +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.mjs +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Para o estado atual da arquitetura, capacidades entregues, limitacoes e roadmap
|
|
|
15
15
|
|
|
16
16
|
Para o corte de arquitetura do `0.9.0`, veja [`leg3ndy-ai-backend/docs/otto-bridge/releases/OTTO_BRIDGE_0_9_0_RELEASE.md`](../leg3ndy-ai-backend/docs/otto-bridge/releases/OTTO_BRIDGE_0_9_0_RELEASE.md).
|
|
17
17
|
|
|
18
|
-
Para a release atual `1.0.
|
|
18
|
+
Para a release atual `1.0.9`, com composer multiline no console TTY e quebra de linha dentro da moldura, veja [`leg3ndy-ai-backend/docs/otto-bridge/releases/OTTO_BRIDGE_1_0_9_PATCH.md`](../leg3ndy-ai-backend/docs/otto-bridge/releases/OTTO_BRIDGE_1_0_9_PATCH.md).
|
|
19
19
|
|
|
20
20
|
## Distribuicao
|
|
21
21
|
|
|
@@ -38,14 +38,14 @@ Enquanto o pacote nao estiver publicado, voce pode gerar um tarball local:
|
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
40
|
npm pack
|
|
41
|
-
npm install -g ./leg3ndy-otto-bridge-1.0.
|
|
41
|
+
npm install -g ./leg3ndy-otto-bridge-1.0.9.tgz
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
Na linha `1.0.
|
|
44
|
+
Na linha `1.0.9`, `playwright` segue como dependencia obrigatoria no `otto-bridge`. O primeiro `npm install -g @leg3ndy/otto-bridge` pode demorar mais porque instala o browser persistente usado pelo WhatsApp Web e pelos fluxos web em background do bridge.
|
|
45
45
|
|
|
46
|
-
No macOS, a linha `1.0.
|
|
46
|
+
No macOS, a linha `1.0.9` usa o provider `macos-helper`, um helper `WKWebView` sem Dock para o WhatsApp Web. O helper sobe com user-agent de Chrome moderno para evitar o bloqueio do WhatsApp ao detectar Safari/WebKit. O runtime antigo com Chromium/Playwright fica disponivel apenas como override explicito via `OTTO_BRIDGE_WHATSAPP_RUNTIME_PROVIDER=embedded-playwright`.
|
|
47
47
|
|
|
48
|
-
No nivel arquitetural, o `0.9.0` marcou a mudanca de papel do bridge: ele publica tools e resultados estruturados para o Otto, em vez de injetar resposta pronta como caminho principal do chat. O `1.0.0` oficializou isso como runtime agentico; o `1.0.
|
|
48
|
+
No nivel arquitetural, o `0.9.0` marcou a mudanca de papel do bridge: ele publica tools e resultados estruturados para o Otto, em vez de injetar resposta pronta como caminho principal do chat. O `1.0.0` oficializou isso como runtime agentico; o `1.0.9` preserva esse fluxo, mantem o input-box TTY estavel, adiciona composer multiline e melhora as views de status/extensoes e o refresh ao sair do `Terminal`.
|
|
49
49
|
|
|
50
50
|
## Publicacao
|
|
51
51
|
|
|
@@ -157,7 +157,7 @@ Esse comando abre um shell local interativo para instalar extensoes, rodar coman
|
|
|
157
157
|
|
|
158
158
|
### WhatsApp Web em background
|
|
159
159
|
|
|
160
|
-
Fluxo recomendado na linha `1.0.
|
|
160
|
+
Fluxo recomendado na linha `1.0.9`:
|
|
161
161
|
|
|
162
162
|
```bash
|
|
163
163
|
otto-bridge extensions --install whatsappweb
|
|
@@ -167,13 +167,13 @@ otto-bridge extensions --status whatsappweb
|
|
|
167
167
|
|
|
168
168
|
O setup agora abre o login do WhatsApp Web no helper/background browser do proprio bridge. Depois do QR code, o Otto usa a sessao local em background, sem depender de aba visivel no Safari.
|
|
169
169
|
|
|
170
|
-
Contrato da linha `1.0.
|
|
170
|
+
Contrato da linha `1.0.9`:
|
|
171
171
|
|
|
172
172
|
- `otto-bridge extensions --setup whatsappweb`: autentica a sessao uma vez
|
|
173
173
|
- `otto-bridge`: mantem o browser persistente do WhatsApp vivo em background enquanto o runtime do hub estiver ativo, sem depender de uma aba aberta no Safari
|
|
174
174
|
- ao fechar o `otto-bridge`: o browser em background e desligado, mas a sessao local fica lembrada para o proximo boot
|
|
175
175
|
|
|
176
|
-
## Handoff rapido da linha 1.0.
|
|
176
|
+
## Handoff rapido da linha 1.0.9
|
|
177
177
|
|
|
178
178
|
Ja fechado no codigo:
|
|
179
179
|
|
package/dist/cli_terminal.js
CHANGED
|
@@ -688,6 +688,128 @@ function renderConsolePromptContentLine(text, width, tone) {
|
|
|
688
688
|
: style(clipped, ANSI.slateItalic, enabled);
|
|
689
689
|
return `${border} ${body} ${border}`;
|
|
690
690
|
}
|
|
691
|
+
function sliceByWidth(text, width) {
|
|
692
|
+
if (width <= 0) {
|
|
693
|
+
return [""];
|
|
694
|
+
}
|
|
695
|
+
if (!text.length) {
|
|
696
|
+
return [""];
|
|
697
|
+
}
|
|
698
|
+
const parts = [];
|
|
699
|
+
let offset = 0;
|
|
700
|
+
while (offset < text.length) {
|
|
701
|
+
parts.push(text.slice(offset, offset + width));
|
|
702
|
+
offset += width;
|
|
703
|
+
}
|
|
704
|
+
return parts.length ? parts : [""];
|
|
705
|
+
}
|
|
706
|
+
export function buildConsoleComposerLayout(value, innerWidth) {
|
|
707
|
+
const promptWidth = 2;
|
|
708
|
+
const lineContentWidth = Math.max(1, innerWidth - promptWidth);
|
|
709
|
+
if (!value) {
|
|
710
|
+
return {
|
|
711
|
+
lines: [CONSOLE_PLACEHOLDER],
|
|
712
|
+
cursorLineIndex: 0,
|
|
713
|
+
cursorColumn: 0,
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
const logicalLines = value.split("\n");
|
|
717
|
+
const lastLogicalLine = logicalLines[logicalLines.length - 1] ?? "";
|
|
718
|
+
const lines = [];
|
|
719
|
+
for (const logicalLine of logicalLines) {
|
|
720
|
+
const wrapped = sliceByWidth(logicalLine, lineContentWidth);
|
|
721
|
+
lines.push(...wrapped);
|
|
722
|
+
}
|
|
723
|
+
const trailingNewline = value.endsWith("\n");
|
|
724
|
+
const needsSoftWrapCursorRow = !trailingNewline
|
|
725
|
+
&& lastLogicalLine.length > 0
|
|
726
|
+
&& lastLogicalLine.length % lineContentWidth === 0;
|
|
727
|
+
if (trailingNewline || needsSoftWrapCursorRow) {
|
|
728
|
+
lines.push("");
|
|
729
|
+
}
|
|
730
|
+
const cursorLineIndex = trailingNewline
|
|
731
|
+
? lines.length - 1
|
|
732
|
+
: needsSoftWrapCursorRow
|
|
733
|
+
? lines.length - 1
|
|
734
|
+
: Math.max(0, lines.length - 1);
|
|
735
|
+
const cursorColumn = trailingNewline
|
|
736
|
+
? 0
|
|
737
|
+
: needsSoftWrapCursorRow
|
|
738
|
+
? 0
|
|
739
|
+
: lastLogicalLine.length % lineContentWidth;
|
|
740
|
+
return {
|
|
741
|
+
lines,
|
|
742
|
+
cursorLineIndex,
|
|
743
|
+
cursorColumn,
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
function renderConsoleComposerLines(value, innerWidth, enabled) {
|
|
747
|
+
const layout = buildConsoleComposerLayout(value, innerWidth);
|
|
748
|
+
const lineContentWidth = Math.max(1, innerWidth - 2);
|
|
749
|
+
const promptStyled = style(">", `${ANSI.bold}${ANSI.white}`, enabled);
|
|
750
|
+
if (!value) {
|
|
751
|
+
const placeholder = truncate(CONSOLE_PLACEHOLDER, lineContentWidth);
|
|
752
|
+
return {
|
|
753
|
+
renderedLines: [
|
|
754
|
+
`${promptStyled} ${style(placeholder, ANSI.slate, enabled)}${" ".repeat(Math.max(0, lineContentWidth - placeholder.length))}`,
|
|
755
|
+
],
|
|
756
|
+
cursorLineIndex: 0,
|
|
757
|
+
cursorColumn: 0,
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
return {
|
|
761
|
+
renderedLines: layout.lines.map((line, index) => {
|
|
762
|
+
const prefix = index === 0 ? `${promptStyled} ` : " ";
|
|
763
|
+
return `${prefix}${line}${" ".repeat(Math.max(0, lineContentWidth - line.length))}`;
|
|
764
|
+
}),
|
|
765
|
+
cursorLineIndex: layout.cursorLineIndex,
|
|
766
|
+
cursorColumn: layout.cursorColumn,
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
function tryConsumeControlSequence(buffer) {
|
|
770
|
+
const knownNewlineSequences = [
|
|
771
|
+
"\u001b[13;2u",
|
|
772
|
+
"\u001b[27;2;13~",
|
|
773
|
+
"\u001b[1;2M",
|
|
774
|
+
"\u001b\r",
|
|
775
|
+
"\u001b\n",
|
|
776
|
+
];
|
|
777
|
+
for (const sequence of knownNewlineSequences) {
|
|
778
|
+
if (buffer.startsWith(sequence)) {
|
|
779
|
+
return {
|
|
780
|
+
consumed: sequence.length,
|
|
781
|
+
action: "newline",
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
if (buffer === "\u001b" || /^\u001b\[[0-9;?]*$/.test(buffer)) {
|
|
786
|
+
return {
|
|
787
|
+
consumed: 0,
|
|
788
|
+
action: "incomplete",
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
const csiMatch = buffer.match(/^\u001b\[[0-9;?]*[ -/]*[@-~]/);
|
|
792
|
+
if (csiMatch) {
|
|
793
|
+
return {
|
|
794
|
+
consumed: csiMatch[0].length,
|
|
795
|
+
action: "ignore",
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
const ss3Match = buffer.match(/^\u001bO./);
|
|
799
|
+
if (ss3Match) {
|
|
800
|
+
return {
|
|
801
|
+
consumed: ss3Match[0].length,
|
|
802
|
+
action: "ignore",
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
if (buffer.startsWith("\u001b")) {
|
|
806
|
+
return {
|
|
807
|
+
consumed: 1,
|
|
808
|
+
action: "ignore",
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
return null;
|
|
812
|
+
}
|
|
691
813
|
async function askConsoleInput(rl) {
|
|
692
814
|
if (!supportsAnsi() || typeof input.setRawMode !== "function" || !input.isTTY) {
|
|
693
815
|
return normalizeText(await question(rl, "> "));
|
|
@@ -699,70 +821,90 @@ async function askConsoleInput(rl) {
|
|
|
699
821
|
const enabled = supportsAnsi();
|
|
700
822
|
const availableWidth = Number(output.columns || 96);
|
|
701
823
|
const innerWidth = Math.max(42, Math.min(availableWidth - 8, 116));
|
|
702
|
-
const sectionTopOffsetFromInputLine = 1;
|
|
703
824
|
let renderedOnce = false;
|
|
704
825
|
let value = "";
|
|
826
|
+
let pendingControlBuffer = "";
|
|
827
|
+
let previousCursorRowsFromTop = 0;
|
|
705
828
|
const cleanup = () => {
|
|
706
829
|
input.removeListener("data", onData);
|
|
707
830
|
input.setRawMode(false);
|
|
708
831
|
input.pause();
|
|
709
832
|
rl.resume();
|
|
710
833
|
};
|
|
711
|
-
const renderInputContent = () => {
|
|
712
|
-
const promptPlain = "> ";
|
|
713
|
-
const promptStyled = style(">", `${ANSI.bold}${ANSI.white}`, enabled);
|
|
714
|
-
const maxValueLength = Math.max(0, innerWidth - promptPlain.length);
|
|
715
|
-
if (!value) {
|
|
716
|
-
const placeholder = truncate(CONSOLE_PLACEHOLDER, maxValueLength);
|
|
717
|
-
const padded = `${style(placeholder, ANSI.slate, enabled)}${" ".repeat(Math.max(0, maxValueLength - placeholder.length))}`;
|
|
718
|
-
return `${promptStyled} ${padded}`;
|
|
719
|
-
}
|
|
720
|
-
const visibleValue = value.length > maxValueLength
|
|
721
|
-
? value.slice(value.length - maxValueLength)
|
|
722
|
-
: value;
|
|
723
|
-
return `${promptStyled} ${visibleValue}${" ".repeat(Math.max(0, maxValueLength - visibleValue.length))}`;
|
|
724
|
-
};
|
|
725
834
|
const render = () => {
|
|
835
|
+
const composer = renderConsoleComposerLines(value, innerWidth, enabled);
|
|
726
836
|
if (renderedOnce) {
|
|
727
837
|
cursorTo(output, 0);
|
|
728
|
-
moveCursor(output, 0, -
|
|
838
|
+
moveCursor(output, 0, -previousCursorRowsFromTop);
|
|
729
839
|
}
|
|
730
840
|
else {
|
|
731
841
|
renderedOnce = true;
|
|
732
842
|
}
|
|
733
843
|
const top = renderPromptFrameLine(innerWidth + 2, "┌", "┐");
|
|
734
844
|
const border = style("│", ANSI.brandBlue, enabled);
|
|
735
|
-
const middle = `${border} ${renderInputContent()} ${border}`;
|
|
736
845
|
const bottom = renderPromptFrameLine(innerWidth + 2, "└", "┘");
|
|
846
|
+
const content = composer.renderedLines.map((line) => `${border} ${line} ${border}`).join("\n");
|
|
737
847
|
output.write("\u001b[J");
|
|
738
|
-
output.write(`${top}\n${
|
|
848
|
+
output.write(`${top}\n${content}\n${bottom}\n`);
|
|
739
849
|
cursorTo(output, 0);
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
cursorTo(output, 4 +
|
|
850
|
+
previousCursorRowsFromTop = 1 + composer.cursorLineIndex;
|
|
851
|
+
moveCursor(output, 0, -previousCursorRowsFromTop);
|
|
852
|
+
cursorTo(output, 4 + composer.cursorColumn);
|
|
853
|
+
};
|
|
854
|
+
const insertNewline = () => {
|
|
855
|
+
value = `${value}\n`;
|
|
856
|
+
render();
|
|
857
|
+
};
|
|
858
|
+
const submitPrompt = () => {
|
|
859
|
+
cleanup();
|
|
860
|
+
output.write("\n");
|
|
861
|
+
resolve(normalizeText(value));
|
|
743
862
|
};
|
|
744
863
|
const onData = (chunk) => {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
if (
|
|
864
|
+
pendingControlBuffer += Buffer.isBuffer(chunk) ? chunk.toString("utf8") : String(chunk);
|
|
865
|
+
while (pendingControlBuffer.length > 0) {
|
|
866
|
+
if (pendingControlBuffer.startsWith("\u0003")) {
|
|
748
867
|
cleanup();
|
|
749
868
|
reject(createCliExitError());
|
|
750
869
|
return;
|
|
751
870
|
}
|
|
752
|
-
if (
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
871
|
+
if (pendingControlBuffer.startsWith("\r")) {
|
|
872
|
+
if (pendingControlBuffer.startsWith("\r\n")) {
|
|
873
|
+
pendingControlBuffer = pendingControlBuffer.slice(2);
|
|
874
|
+
}
|
|
875
|
+
else {
|
|
876
|
+
pendingControlBuffer = pendingControlBuffer.slice(1);
|
|
877
|
+
}
|
|
878
|
+
submitPrompt();
|
|
756
879
|
return;
|
|
757
880
|
}
|
|
758
|
-
if (
|
|
881
|
+
if (pendingControlBuffer.startsWith("\n")) {
|
|
882
|
+
pendingControlBuffer = pendingControlBuffer.slice(1);
|
|
883
|
+
insertNewline();
|
|
884
|
+
continue;
|
|
885
|
+
}
|
|
886
|
+
if (pendingControlBuffer.startsWith("\u007f") || pendingControlBuffer.startsWith("\b")) {
|
|
887
|
+
pendingControlBuffer = pendingControlBuffer.slice(1);
|
|
759
888
|
value = value.slice(0, -1);
|
|
760
889
|
render();
|
|
761
890
|
continue;
|
|
762
891
|
}
|
|
763
|
-
|
|
892
|
+
const controlSequence = tryConsumeControlSequence(pendingControlBuffer);
|
|
893
|
+
if (controlSequence) {
|
|
894
|
+
if (controlSequence.action === "incomplete") {
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
pendingControlBuffer = pendingControlBuffer.slice(controlSequence.consumed);
|
|
898
|
+
if (controlSequence.action === "newline") {
|
|
899
|
+
insertNewline();
|
|
900
|
+
}
|
|
764
901
|
continue;
|
|
765
902
|
}
|
|
903
|
+
const [char] = Array.from(pendingControlBuffer);
|
|
904
|
+
if (!char) {
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
pendingControlBuffer = pendingControlBuffer.slice(char.length);
|
|
766
908
|
value += char;
|
|
767
909
|
render();
|
|
768
910
|
}
|
|
@@ -1076,6 +1218,7 @@ async function runOttoConsole(rl, config, runtimeSession, options) {
|
|
|
1076
1218
|
printSection("Console");
|
|
1077
1219
|
printSoft("Comandos: /help, /model [fast|thinking], /status, /clear, /exit");
|
|
1078
1220
|
printSoft("Bridge: otto-bridge terminal, otto-bridge extensions --install <name>, otto-bridge update");
|
|
1221
|
+
printSoft("Composer: Enter envia; Shift+Enter quebra linha quando suportado; Ctrl+J tambem insere newline.");
|
|
1079
1222
|
};
|
|
1080
1223
|
const handlePrompt = async (promptText) => {
|
|
1081
1224
|
const normalizedPrompt = normalizeText(promptText);
|
package/dist/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const BRIDGE_CONFIG_VERSION = 1;
|
|
2
|
-
export const BRIDGE_VERSION = "1.0.
|
|
2
|
+
export const BRIDGE_VERSION = "1.0.9";
|
|
3
3
|
export const BRIDGE_PACKAGE_NAME = "@leg3ndy/otto-bridge";
|
|
4
4
|
export const DEFAULT_API_BASE_URL = "http://localhost:8000";
|
|
5
5
|
export const DEFAULT_POLL_INTERVAL_MS = 3000;
|
package/package.json
CHANGED
package/scripts/postinstall.mjs
CHANGED
|
@@ -24,7 +24,7 @@ if (!existsSync(mainPath)) {
|
|
|
24
24
|
process.exit(0);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
console.log("\n[otto-bridge] Welcome to OTTOAI 1.0.
|
|
27
|
+
console.log("\n[otto-bridge] Welcome to OTTOAI 1.0.9");
|
|
28
28
|
console.log("[otto-bridge] Vamos iniciar o setup interativo do bridge.\n");
|
|
29
29
|
|
|
30
30
|
const result = spawnSync(process.execPath, [mainPath, "setup", "--postinstall"], {
|