dsh-plugin-weapp-gateway 0.8.53 → 0.8.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/PROTOCOL.md +26 -12
- package/README.en.md +410 -0
- package/README.md +16 -0
- package/README.zh-CN.md +425 -0
- package/cordis.patch.yml +2 -0
- package/docs/agent-team-app-integration.md +76 -55
- package/docs/android-connectors-alignment.md +73 -0
- package/docs/dsh-0.2.2-rc.1-mobile-integration.md +269 -0
- package/docs/dsh-0.2.2-rc.3-compatibility-audit.md +145 -0
- package/docs/file-cards-mobile-integration.md +111 -0
- package/docs/file-changes-app-integration.md +277 -0
- package/docs/generated-images-mobile-integration.md +125 -0
- package/docs/iphone-connector-actions.md +69 -0
- package/docs/iphone-map-markers.md +41 -0
- package/docs/iphone-maps-connectors.md +56 -0
- package/docs/iphone-music-cards.md +28 -0
- package/docs/map-app-adapters.md +57 -0
- package/docs/phone-connectors-implementation.md +105 -0
- package/docs/phone-connectors.md +91 -0
- package/docs/readme/README.de.md +404 -0
- package/docs/readme/README.es.md +404 -0
- package/docs/readme/README.fr.md +404 -0
- package/docs/readme/README.ja.md +404 -0
- package/docs/readme/README.ko.md +404 -0
- package/docs/readme/README.pt-BR.md +404 -0
- package/lib/client.js +82 -27
- package/lib/cloudflare-tunnel.mjs +6 -2
- package/lib/cloudflared-binary.mjs +10 -24
- package/lib/device-tool-validation.mjs +173 -0
- package/lib/device-tools.mjs +119 -0
- package/lib/devices.js +29 -7
- package/lib/dsh-host-adapter.mjs +169 -36
- package/lib/dsh-runtime-version.mjs +22 -0
- package/lib/index.mjs +253 -102
- package/lib/logging.mjs +16 -0
- package/lib/message-text.mjs +51 -0
- package/lib/phone-request-sources.mjs +91 -0
- package/lib/phone-tools.mjs +248 -0
- package/lib/plugin-management.mjs +24 -0
- package/lib/schedule-management.mjs +130 -0
- package/lib/session-target.mjs +16 -0
- package/lib/tool-images.mjs +32 -0
- package/lib/web-restart.mjs +11 -8
- package/lib/workspace-changes.mjs +162 -0
- package/package.json +8 -3
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
[English](../../README.md) · [简体中文](../../README.zh-CN.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [Español](README.es.md) · [Français](README.fr.md) · [Deutsch](README.de.md) · **Português (Brasil)**
|
|
2
|
+
|
|
3
|
+
> Alguns documentos detalhados de protocolo e integração estão disponíveis somente em chinês.
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="../assets/whale-girl-ios-app-promo-16x9.png" alt="Whaleness e Mobile Gateway" width="100%">
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
# dsh-plugin-mobile-gateway
|
|
10
|
+
|
|
11
|
+
> **v0.12.1 · publicação pendente** — Compatível com DSH 0.2.2-rc.3 e Node.js 24.9+. Corrige projeções de equipe e a continuação/interrupção de subagentes; adiciona controle do modo Team por sessão. [Changelog](../../CHANGELOG.md) · [RC.3 / App](../dsh-0.2.2-rc.3-compatibility-audit.md)
|
|
12
|
+
|
|
13
|
+
Gateway móvel de terceiros para DeepSeek Harness com autenticação de dispositivos. Sessões e eventos ao vivo; fila com sincronização, edição, exclusão e Steer; arquivamento/renomeação bidirecionais; parar/continuar geração; tarefas e Goal atual; menus de comandos e habilidades do servidor; intervenção humana; imagens e arquivos. A instalação adiciona Dispositivos móveis ao WebUI para ativar o gateway, gerar QR e gerenciar dispositivos confiáveis.
|
|
14
|
+
|
|
15
|
+
> Código atual para **DSH 0.2.2-rc.1**, com Connection Peer e Session format 4. Cursores antigos exigem uma nova base de histórico.
|
|
16
|
+
>
|
|
17
|
+
> Fluxo em quadros `assistant-stream` separados. Atualize assinaturas, cache e paginação conforme o [guia rc.2](../dsh-rc2-mobile-integration.md). Mudanças ainda não publicadas.
|
|
18
|
+
>
|
|
19
|
+
> v0.11.1 (código atual, não publicado): envio de arquivos em blocos, SHA-256, confirmação de progresso, cancelamento e limpeza ao desconectar. Usa armazenamento oficial de anexos DSH e credenciais por sessão para mensagens e referências ao vivo/históricas. Integre `file-upload-v1`; [guia de envio](../file-upload-app-integration.md).
|
|
20
|
+
>
|
|
21
|
+
> v0.11.0: equipes, subagentes, membros, tarefas compartilhadas, diretórios aninhados, estado ao vivo, histórico próprio, troca de visualização, conversa, imagens e parada. Descubra capacidades; [guia de equipes](../agent-team-app-integration.md).
|
|
22
|
+
>
|
|
23
|
+
> v0.10.4: listas mantêm apenas títulos e pontos de corte para evitar timeouts em túneis com muitas sessões. Metadados e histórico completo preservados; clientes existentes não precisam mudar.
|
|
24
|
+
>
|
|
25
|
+
> v0.10.3: Connection Peer em chamadas Remote/assinaturas DSH 0.2.1-rc.2, corrige `Cannot read properties of undefined (reading 'signal')` e libera Peer ao parar. Protocolo móvel inalterado.
|
|
26
|
+
>
|
|
27
|
+
> v0.10.2: eventos de cartões e referências seguras, reutilizando download em blocos para cartões/links de arquivos. [Guia de cartões](../file-cards-mobile-integration.md).
|
|
28
|
+
>
|
|
29
|
+
> v0.10.1: voz oficial, preparo/estado do modelo, transcrição, cancelamento e limpeza. Usa speech Remote oficial sem incluir modelos ASR.
|
|
30
|
+
>
|
|
31
|
+
> v0.10.0: janela central responsiva ao tema do host, menus uniformes, destaque de conexão, diálogo QR animado separado, avisos de reinício dispensáveis por instância, dispositivos online por padrão e offline expansíveis, nomes e numeração de duplicados. Modo Tunnel aplicado automaticamente; parâmetros nomeados salvos explicitamente.
|
|
32
|
+
>
|
|
33
|
+
> v0.9.0: plugins DSH 0.2.0-rc.2, Tunnels Quick/nomeados com `cloudflared` verificado no cache privado, orientação LAN/pública, reinício do gateway e parada DSH Web sem nova aba.
|
|
34
|
+
>
|
|
35
|
+
> v0.7.3: espaçamento da seta do seletor de modo.
|
|
36
|
+
>
|
|
37
|
+
> v0.7.2: conexões conversa/controle separadas, sessões vazias, parar/continuar, fila editável com exclusão/Steer e arquivamento/renomeação bidirecionais.
|
|
38
|
+
|
|
39
|
+
## Protocolo e compatibilidade DSH
|
|
40
|
+
|
|
41
|
+
Clientes usam `dsh-mobile-v1`, não o Remote interno DSH. Um Host Adapter separado conecta ao Remote Gateway DSH 0.2.1-rc.2. Session, Workspace, Settings, Commands, Goals, Schedule, Permission Presets, Plugin Manager e parâmetros estritos ficam no adaptador. Quadros e interface: [integração RC2](../dsh-0.2.0-rc.2-plugin-management-mobile-integration.md).
|
|
42
|
+
|
|
43
|
+
Cada chamada Remote exige `peer`. `ctx.connection.createPeer()` cria um Peer de usuário local liberado com o plugin. O adaptador o injeta em solicitações, leituras iniciais e assinaturas; o móvel não define identidade. Perguntas/aprovações continuam nos listeners Host. Ausência causa `Cannot read properties of undefined (reading 'signal')`. Após atualizar DSH, reinstale este código e reinicie `dsh web`; sem alteração no protocolo do telefone.
|
|
44
|
+
|
|
45
|
+
Verifique no DSH oficial instalado: Gateway/Connection reais, serviços de teste, sem ler/escrever sessões do usuário:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
DSH_INSTALL_ROOT=/absolute/path/to/@deepseek-ai/dsh node test/host-official.test.mjs
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Autenticação e `dsh-mobile-v1` / `hello.protocol = 3` não mudam. Tokens ao vivo não consomem `seq` persistente. Assine `assistantStream: true` para `session-snapshot` atômico e deltas separados; `event` só contém eventos persistentes. Sem nova assinatura, apenas mensagens persistentes.
|
|
52
|
+
|
|
53
|
+
Histórico inclui `historyFormatVersion` e `cursor`. Ao trocar formato, limpe cache e reinstale a base. Paginação `beforeSeq` e fork `atSeq` exigem `historyFormatVersion: 4`.
|
|
54
|
+
Integração/aceitação: [guia rc.2](../dsh-rc2-mobile-integration.md). Migração anterior: [plano Remote Gateway](../remote-gateway-refactor-plan.md).
|
|
55
|
+
|
|
56
|
+
- WebSocket: `/ws/mobile`
|
|
57
|
+
- LAN: `ws://<局域网 IP>:3081/ws/mobile`
|
|
58
|
+
- Linux público: `wss://<公网 IP>/ws/mobile`
|
|
59
|
+
- Protocolo: [PROTOCOL.md](../../PROTOCOL.md)
|
|
60
|
+
|
|
61
|
+
Código atual permite consultar/alterar predefinição do Agent em sessão vazia até a primeira conversa. Descubra `session-agent-preset`; [guia do cliente](../session-agent-preset-app-integration.md). Interface exige integração; não publicado.
|
|
62
|
+
|
|
63
|
+
`turn-outline-v1` transmite estrutura completa dos turnos WebUI e atualizações para marcadores, prévias pergunta/resposta e saltos paginados sem todo o texto. Reconectar controle ou novo dispositivo restaura a base; sem estrutura Host, use turnos carregados. [Guia de navegação](../turn-outline-app-integration.md). Interface separada; não publicado.
|
|
64
|
+
|
|
65
|
+
`file-upload-v1`: clientes pareados enviam PDF, Office, arquivos compactados, áudio e outros em blocos pelo controle. Após SHA-256, armazenamento oficial e envio com credenciais da sessão. Progresso, cancelamento, limpeza e referências ao vivo/históricas; mesmas regras WebUI, sem caminhos de host escolhidos pelo cliente. Quadros, estados, limites e testes: [guia de envio](../file-upload-app-integration.md). Interface separada; não publicado.
|
|
66
|
+
|
|
67
|
+
`agent-team-v1` e `subagent-conversations-v1`: membros/tarefas, diretórios aninhados, projeção/estado ao vivo, histórico/assinaturas próprios, conversa e parada. Destinos, JSON, regras, troca/reconexão, erros e aceitação: [guia de equipes](../agent-team-app-integration.md). Capacidades do gateway; interface separada, não publicado.
|
|
68
|
+
|
|
69
|
+
## Vários gateways: primeira fase (código atual)
|
|
70
|
+
|
|
71
|
+
`gatewayId` estável, `gatewayName` configurável, endpoints candidatos e modos Desativado / Temporário / Permanente persistidos. Uma app pode parear várias máquinas; implemente gestão conforme o [guia](../multi-gateway-app-integration.md). Nenhuma nova versão npm publicada para esse código.
|
|
72
|
+
|
|
73
|
+
Permanente aceita dispositivos autorizados após reinícios. Requer DSH ativo, máquina acordada e rede acessível; sem descoberta automática ou retransmissão.
|
|
74
|
+
|
|
75
|
+
Exemplo de `config` do plugin:
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
gatewayMode: persistent
|
|
79
|
+
gatewayName: 家里电脑
|
|
80
|
+
requireAuth: true
|
|
81
|
+
endpoints:
|
|
82
|
+
- wss://gateway.example.com/ws/mobile
|
|
83
|
+
- ws://192.168.1.10:3081/ws/mobile
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Prioridade: **seleção salva na interface > `gatewayMode` > antigo `gatewayEnabled`**. Sem seleção, `gatewayEnabled: true` significa Permanente; false, Desativado.
|
|
87
|
+
|
|
88
|
+
- Desativado: desconecta imediatamente e permanece assim após reinício.
|
|
89
|
+
- Temporário: sem conexão bem-sucedida em 5 minutos, desativa e salva; após conectar permanece ativo nessa execução. Reinício reinicia espera. `gatewayWaitTimeoutMs`: 30 segundos a 30 minutos.
|
|
90
|
+
- Permanente: sem temporizador de ausência. QR continua expirando em 5 minutos por padrão; timeouts de arquivos não mudam.
|
|
91
|
+
|
|
92
|
+
Estado em `<deviceFile>.gateway.json`, normalmente `~/.dsh/mobile-gateway-devices.json.gateway.json`, ou `gatewayStateFile`. UUID v4 e preferências, permissões `0600`, troca atômica com arquivo temporário vizinho. Corrupção impede início sem regenerar identidade silenciosamente. Cada instância tem registro/estado próprios.
|
|
93
|
+
|
|
94
|
+
Preserve ambos ao atualizar/migrar. Para clone independente, não copie identidade/estado nem registro; gere identidade e pareie de novo. Não apague identidade em execução. Para configuração inicial: pare, faça backup, mude só `mode` para `null`, preserve `version`/`gatewayId` e reinicie.
|
|
95
|
+
|
|
96
|
+
`gatewayName`: até 80 caracteres, hostname por padrão. `endpoints`: até 16 extras, 2048 caracteres cada. Mescla preferidos, públicos e LAN; total acima de 16 gera erro. Todos devem alcançar o mesmo gateway pelo telefone; não use `0.0.0.0` / `::`. WSS em rede pública.
|
|
97
|
+
|
|
98
|
+
Testes/passos manuais: [aceitação](../multi-gateway-phase1-acceptance.md). Escopo: [lista multigateway](../multi-gateway-todo.md).
|
|
99
|
+
|
|
100
|
+
## Cliente associado Android e iOS
|
|
101
|
+
|
|
102
|
+
[Whaleness](https://github.com/Clarklevis1995/dsh-mobile) é um cliente nativo de terceiros desenvolvido independentemente para este gateway. Android 7.0+ e iOS / iPadOS 16.1+, lógica Kotlin Multiplatform, interfaces Jetpack Compose e SwiftUI/UIKit. Espaços/sessões, conversa ao vivo, equipes/tarefas, envio/prévia de arquivos, seleção de texto, tabelas Markdown, histórico/cache, voz, aprovações e menus do servidor. iPhone Duo e telas amplas adaptam orientação/espaço; efeitos variam por sistema/aparelho. Downloads, configuração e capturas atuais no repositório do cliente.
|
|
103
|
+
|
|
104
|
+
> Capturas recentes de iOS: o conjunto 1.7.10 foi capturado em 22–23 de outubro de 2026; o conjunto iPhone Duo, em 26 de outubro de 2026. A interface está em chinês. [Fontes do produto](https://github.com/Clarklevis1995/dsh-mobile/blob/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/SOURCES.md) · [Fontes Duo](https://github.com/Clarklevis1995/dsh-mobile/blob/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/SOURCES.md).
|
|
105
|
+
|
|
106
|
+
### iPhone Duo: paisagem, retrato e navegação
|
|
107
|
+
|
|
108
|
+
<table>
|
|
109
|
+
<tr>
|
|
110
|
+
<td width="50.00%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-home.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-home.webp" alt="Início desdobrado em paisagem" width="100%"></a></td>
|
|
111
|
+
<td width="50.00%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-home-alt.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-home-alt.webp" alt="Fundo do início em paisagem" width="100%"></a></td>
|
|
112
|
+
</tr>
|
|
113
|
+
<tr>
|
|
114
|
+
<td align="center"><strong>Início desdobrado em paisagem</strong></td>
|
|
115
|
+
<td align="center"><strong>Fundo do início em paisagem</strong></td>
|
|
116
|
+
</tr>
|
|
117
|
+
<tr>
|
|
118
|
+
<td width="50.00%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-settings.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-settings.webp" alt="Configurações em paisagem" width="100%"></a></td>
|
|
119
|
+
<td width="50.00%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-conversation.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-conversation.webp" alt="Conversa em paisagem" width="100%"></a></td>
|
|
120
|
+
</tr>
|
|
121
|
+
<tr>
|
|
122
|
+
<td align="center"><strong>Configurações em paisagem</strong></td>
|
|
123
|
+
<td align="center"><strong>Conversa em paisagem</strong></td>
|
|
124
|
+
</tr>
|
|
125
|
+
<tr>
|
|
126
|
+
<td width="50.00%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-navigation.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-navigation.webp" alt="Barra lateral de navegação aberta" width="100%"></a></td>
|
|
127
|
+
<td width="50.00%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/portrait-home.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/portrait-home.webp" alt="Início desdobrado em retrato" width="100%"></a></td>
|
|
128
|
+
</tr>
|
|
129
|
+
<tr>
|
|
130
|
+
<td align="center"><strong>Barra lateral de navegação aberta</strong></td>
|
|
131
|
+
<td align="center"><strong>Início desdobrado em retrato</strong></td>
|
|
132
|
+
</tr>
|
|
133
|
+
</table>
|
|
134
|
+
|
|
135
|
+
### Equipes, anexos e armazenamento local
|
|
136
|
+
|
|
137
|
+
<table>
|
|
138
|
+
<tr>
|
|
139
|
+
<td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/team-members.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/team-members.webp" alt="Membros da equipe de Agents" width="100%"></a></td>
|
|
140
|
+
<td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/team-tasks.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/team-tasks.webp" alt="Tarefas compartilhadas da equipe" width="100%"></a></td>
|
|
141
|
+
<td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/attachment-picker.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/attachment-picker.webp" alt="Seletor de arquivos e imagens" width="100%"></a></td>
|
|
142
|
+
</tr>
|
|
143
|
+
<tr>
|
|
144
|
+
<td align="center"><strong>Membros da equipe de Agents</strong></td>
|
|
145
|
+
<td align="center"><strong>Tarefas compartilhadas da equipe</strong></td>
|
|
146
|
+
<td align="center"><strong>Seletor de arquivos e imagens</strong></td>
|
|
147
|
+
</tr>
|
|
148
|
+
<tr>
|
|
149
|
+
<td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/text-selection.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/text-selection.webp" alt="Tela dedicada de seleção de texto" width="100%"></a></td>
|
|
150
|
+
<td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/conversation-files.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/conversation-files.webp" alt="Arquivos em uma conversa" width="100%"></a></td>
|
|
151
|
+
<td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/release-notes.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/release-notes.webp" alt="Notas de versão incluídas" width="100%"></a></td>
|
|
152
|
+
</tr>
|
|
153
|
+
<tr>
|
|
154
|
+
<td align="center"><strong>Tela dedicada de seleção de texto</strong></td>
|
|
155
|
+
<td align="center"><strong>Arquivos em uma conversa</strong></td>
|
|
156
|
+
<td align="center"><strong>Notas de versão incluídas</strong></td>
|
|
157
|
+
</tr>
|
|
158
|
+
<tr>
|
|
159
|
+
<td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/storage.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/storage.webp" alt="Armazenamento local e categorias de cache" width="100%"></a></td>
|
|
160
|
+
<td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/voice-input.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/voice-input.webp" alt="Entrada de voz ao segurar" width="100%"></a></td>
|
|
161
|
+
<td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/file-upload.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/file-upload.webp" alt="Arquivo anexado no editor" width="100%"></a></td>
|
|
162
|
+
</tr>
|
|
163
|
+
<tr>
|
|
164
|
+
<td align="center"><strong>Armazenamento local e categorias de cache</strong></td>
|
|
165
|
+
<td align="center"><strong>Entrada de voz ao segurar</strong></td>
|
|
166
|
+
<td align="center"><strong>Arquivo anexado no editor</strong></td>
|
|
167
|
+
</tr>
|
|
168
|
+
</table>
|
|
169
|
+
|
|
170
|
+
## Instalar o plugin
|
|
171
|
+
|
|
172
|
+
Requer `dsh` CLI, `pnpm` e `dsh web` funcionando. Verifique `pnpm --version` com o usuário atual. O usuário deve conseguir executar `pnpm`.
|
|
173
|
+
|
|
174
|
+
Para LAN, instale:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
dsh plugin --profile web add dsh-plugin-mobile-gateway@latest
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Para IP público Linux, use inicialização unificada. Instala/atualiza plugin e pede sudo uma vez para Helper:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
npx --yes dsh-plugin-mobile-gateway@latest init
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
`init` instala a versão exata do pacote npm executado no perfil DSH e ignora a espera pnpm somente para essa versão, alinhando plugin/Helper.
|
|
187
|
+
|
|
188
|
+
Pare e reinicie WebUI após instalação:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
dsh web
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Verifique Dispositivos móveis ao fim da barra lateral.
|
|
195
|
+
|
|
196
|
+
## Pareamento LAN
|
|
197
|
+
|
|
198
|
+
Computador DSH e móvel na mesma LAN com acesso mútuo.
|
|
199
|
+
|
|
200
|
+
1. Abra Dispositivos móveis no WebUI.
|
|
201
|
+
2. Escolha Permanente ou Temporário para pareamento breve.
|
|
202
|
+
3. Mantenha autenticação ativa.
|
|
203
|
+
4. Escolha LAN direta e confirme `ws://<电脑局域网 IP>:3081/ws/mobile`. Tunnel pode continuar ativo. Ajuda explica rotas/cenários sem trocar seleção.
|
|
204
|
+
5. Nomeie o dispositivo e gere QR.
|
|
205
|
+
6. Abra autenticação no cliente móvel e escaneie.
|
|
206
|
+
7. Conclui ao aparecer Online no WebUI.
|
|
207
|
+
|
|
208
|
+
Se o firewall bloquear, permita TCP `3081` só em rede privada. Não exponha 3081 publicamente.
|
|
209
|
+
|
|
210
|
+
## Pareamento por IP público Linux
|
|
211
|
+
|
|
212
|
+
> [!NOTE]
|
|
213
|
+
> IP público aqui significa servidor Linux. Desde `v0.6.4`, Ubuntu/Debian com IPv4 pública fixa e Node.js, `pnpm`, `dsh` CLI já instalados. CentOS não suportado.
|
|
214
|
+
|
|
215
|
+
### 1. Preparar portas
|
|
216
|
+
|
|
217
|
+
Copie IPv4 pública do provedor e libere entrada TCP `80`/`443`. Não exponha WebUI nem TCP `3081`.
|
|
218
|
+
|
|
219
|
+
### 2. Inicializar
|
|
220
|
+
|
|
221
|
+
Confirme `pnpm` com usuário comum DSH:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
pnpm --version
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Execute com esse usuário, sem `root` nem `sudo npx`:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
npm_config_registry=https://registry.npmjs.org \
|
|
231
|
+
npx --yes dsh-plugin-mobile-gateway@latest init
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Instala/atualiza plugin e pede sudo uma vez para Nginx, Certbot, Helper e temporizadores de renovação. `init` alinha versões exatas.
|
|
235
|
+
|
|
236
|
+
Inicie/reinicie WebUI:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
dsh web
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### 3. Abrir WebUI remoto
|
|
243
|
+
|
|
244
|
+
Prefira encaminhamento de portas VS Code/Cursor ou execute no computador local:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
ssh -N -L <本地端口>:127.0.0.1:<DSH 实际端口> <服务器用户名>@<服务器公网 IP>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Abra no navegador local:
|
|
251
|
+
|
|
252
|
+
```text
|
|
253
|
+
http://127.0.0.1:<本地端口>
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### 4. Configurar entrada pública
|
|
257
|
+
|
|
258
|
+
Em Dispositivos móveis → Acesso público, informe IPv4 do provedor e configure/atualize. Helper detecta porta `dsh web` e configura Nginx, TLS e `wss://<公网 IP>/ws/mobile`.
|
|
259
|
+
|
|
260
|
+
<p align="center">
|
|
261
|
+
<img src="../assets/public-access-ui.jpg" alt="Configuração pública no painel de dispositivos" width="960">
|
|
262
|
+
</p>
|
|
263
|
+
|
|
264
|
+
### 5. Parear
|
|
265
|
+
|
|
266
|
+
1. Permita conexões móveis e mantenha autenticação.
|
|
267
|
+
2. Informe nome e gere QR.
|
|
268
|
+
3. Escaneie pela autenticação do telefone.
|
|
269
|
+
4. Verifique Online no WebUI.
|
|
270
|
+
|
|
271
|
+
QR de uso único, expira em 5 minutos; gere novamente se preciso.
|
|
272
|
+
|
|
273
|
+
## Acesso remoto Windows / macOS doméstico
|
|
274
|
+
|
|
275
|
+
Geralmente sem IP fixo; não se recomenda abrir portas do roteador. Quick Tunnel sem conta/domínio ou Tunnel nomeado fixo. Primeiro uso baixa/verifica `cloudflared` oficial no cache do usuário; sem serviço manual.
|
|
276
|
+
|
|
277
|
+
Inicie `dsh web`; mantenha computador acordado, online e DSH ativo. Suspensão/saída interrompem acesso.
|
|
278
|
+
|
|
279
|
+
### Cloudflare Quick Tunnel (temporário)
|
|
280
|
+
|
|
281
|
+
Padrão Automático · Priorizar LAN. Em Conexão e pareamento, mude para Priorizar público ou Cloudflare público; dica rosa indica configuração pendente. Escolha Quick Tunnel · Sem domínio e ative. Baixa `cloudflared` se necessário e usa `wss://<名称>.trycloudflare.com/ws/mobile`. Para LAN, volte a priorizar LAN ou LAN direta, sem desligar Tunnel. Gere/escaneie QR. Desligar interrompe o túnel; reiniciar DSH restaura Quick com **outro endereço aleatório**.
|
|
282
|
+
|
|
283
|
+
Sem conta, Token ou domínio; URL pode mudar ao reiniciar/reconectar. A app só aceita endereços confirmados: regenere e escaneie após mudar. **Computador online não garante URL antiga.** Quick visa testes/desenvolvimento, concorrência limitada, sem garantia de disponibilidade. [Documentação](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/trycloudflare/).
|
|
284
|
+
|
|
285
|
+
Atualizar salva modo/parâmetros; sem mudanças não reconecta. Reiniciar Tunnel interrompe conexões e recria túnel sem reiniciar DSH Web. Quick pode mudar URL e apagar QR; escaneie novamente. Não atualiza `cloudflared` automaticamente.
|
|
286
|
+
|
|
287
|
+
### Cloudflare Tunnel nomeado (fixo)
|
|
288
|
+
|
|
289
|
+
1. [Crie Tunnel gerenciado remotamente](https://developers.cloudflare.com/tunnel/get-started/), adicione `gateway.example.com`, **Service URL** `http://127.0.0.1:3082`. Sem serviço Cloudflare ou porta entrante no roteador.
|
|
290
|
+
2. Copie Token de Add a replica, escolha Tunnel nomeado · Domínio fixo, informe host/Token e ative. Modo Permanente, listener dedicado e `cloudflared`. Após registrar, verifica DNS/TLS/rota pública pela máquina; use `wss://gateway.example.com/ws/mobile` se aprovado.
|
|
291
|
+
3. `dsh web` restaura Tunnels ativos. Fechar Cloudflare Tunnel para processo/listener. Desligar manualmente gateway pausa; religar retoma. Também encerra o `cloudflared` gerenciado.
|
|
292
|
+
|
|
293
|
+
Só WebSocket `/ws/mobile`; outros caminhos, WebUI e `/mgw` retornam 404. Credenciais sempre exigidas mesmo com Debug local sem autenticação. Token em `<deviceFile>.cloudflare.json`, padrão `~/.dsh/mobile-gateway-devices.json.cloudflare.json`, permissões `0600`, nunca enviado ao navegador. Cache privado `cloudflared-bin`, sem binários de sistema/outras apps; verificado sempre, baixa versão fixa só se ausente/corrompido, com SHA-256 oficial. Externo só via `cloudflaredPath`. Mudar `cloudflarePort` exige atualizar Service URL. O `cloudflared` em cache é verificado ao iniciar.
|
|
294
|
+
|
|
295
|
+
#### Verificação pública e estado
|
|
296
|
+
|
|
297
|
+
`state: online` indica só registro do túnel, não domínio/TLS/rota. Inclui `endpointHealth` (estado, dica, hora, erro) e `publicReady`. Verifica após conectar e permite repetir DNS/TLS/WebSocket via `POST /mgw/cloudflare/check` com autenticação de gestão, sem reinício.
|
|
298
|
+
|
|
299
|
+
DNS do sistema, HTTPS WebSocket com certificado estrito, sem tokens/redirecionamentos. Só 401 com eco do marcador aleatório confirma rota protegida; 401 genérico proxy/Access não basta. Marcador apenas em recusas sem credenciais válidas, sem conceder acesso. Retrato local, não garante rede móvel, autenticação ou sincronização.
|
|
300
|
+
|
|
301
|
+
Falha DNS local não prova ausência pública: NXDOMAIN em cache, DNS, VPN ou proxy podem afetar. Confira host/CNAME com proxy e tente depois; não desative TLS. Token executa Tunnel remoto sem criar DNS/rotas. CLI/API com autorização adicional podem fazê-lo fora desta verificação.
|
|
302
|
+
|
|
303
|
+
### Tailscale (uso contínuo)
|
|
304
|
+
|
|
305
|
+
1. Instale [Tailscale](https://tailscale.com/download) no computador/móvel, no mesmo Tailnet.
|
|
306
|
+
2. Execute no PowerShell ou terminal macOS:
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
tailscale serve --bg 3081
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
3. Veja `tailscale serve status` para `https://<设备名>.<tailnet>.ts.net`.
|
|
313
|
+
4. Use `wss://<设备名>.<tailnet>.ts.net/ws/mobile` no WebUI e gere QR.
|
|
314
|
+
|
|
315
|
+
Serve permite só dispositivos autorizados no Tailnet e fornece HTTPS. Pare com `tailscale serve reset`. [Documentação](https://tailscale.com/docs/reference/tailscale-cli/serve).
|
|
316
|
+
|
|
317
|
+
## Opções de conexão
|
|
318
|
+
|
|
319
|
+
| Cenário | Entrada | Endereço WebSocket móvel | Configuração | Portas e autenticação |
|
|
320
|
+
|---|---|---|---|---|
|
|
321
|
+
| Mesma LAN | Listener do plugin | `ws://<电脑局域网 IP>:3081/ws/mobile` | Sem Helper/Nginx; acesso mútuo | TCP privado `3081`; autenticação |
|
|
322
|
+
| Simulador iOS local | WebUI local | `ws://127.0.0.1:<DSH WebUI 端口>/ws/mobile` | Sem Helper/Nginx ou `3081` separado | Sem portas externas; desativar só Debug |
|
|
323
|
+
| Linux público | Helper + Nginx + TLS | `wss://<服务器公网 IPv4>/ws/mobile` | `init`, IPv4 no WebUI | TCP `80/443`; não expor DSH/`3081`; autenticação |
|
|
324
|
+
| Windows / macOS doméstico | Tunnel nomeado | `wss://<公开域名>/ws/mobile` | Rota a `127.0.0.1:3082`; host/Token | Sem portas do roteador; autenticação |
|
|
325
|
+
| Windows / macOS doméstico | Quick Tunnel | `wss://<随机名称>.trycloudflare.com/ws/mobile` | Ativar; escanear após URL mudar | Sem conta/domínio/portas; autenticação |
|
|
326
|
+
| Windows / macOS doméstico | Tailscale Serve | `wss://<Tailscale 域名>/ws/mobile` | Encaminhar `127.0.0.1:3081`; URL no WebUI | Sem portas do roteador; autenticação |
|
|
327
|
+
|
|
328
|
+
## Gerenciar acesso público Linux
|
|
329
|
+
|
|
330
|
+
Consultar estado:
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
sudo env "PATH=$PATH" npx --yes dsh-plugin-mobile-gateway@latest status
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
Remover acesso público:
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
sudo env "PATH=$PATH" npx --yes dsh-plugin-mobile-gateway@latest remove
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## Atualizar
|
|
343
|
+
|
|
344
|
+
Repita inicialização para atualizar plugin e Helper:
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
npx --yes dsh-plugin-mobile-gateway@latest init
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Pare e reinicie `dsh web`.
|
|
351
|
+
|
|
352
|
+
## Desinstalar
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
dsh plugin --profile web remove dsh-plugin-mobile-gateway
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Para remover também Helper, mantendo Nginx:
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
sudo env "PATH=$PATH" npx --yes dsh-plugin-mobile-gateway@latest remove-helper
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
## Solução de problemas
|
|
365
|
+
|
|
366
|
+
| Sintoma | Ação |
|
|
367
|
+
|---|---|
|
|
368
|
+
| Sem Dispositivos móveis | Instalar no perfil `web`, reiniciar `dsh web` |
|
|
369
|
+
| Cliente recebe `503` | Habilitar conexões no WebUI |
|
|
370
|
+
| Cliente recebe `401` | Regenerar QR e parear |
|
|
371
|
+
| Timeout Linux público | Conferir segurança, firewall e TCP `80/443` |
|
|
372
|
+
| Sem endereço Linux | Informar IPv4 pública e atualizar |
|
|
373
|
+
| Falha download Cloudflare | Verificar GitHub Releases ou instalar cloudflared e definir `cloudflaredPath` absoluto |
|
|
374
|
+
| Quick falha após reinício | Regenerar/escanear; Tunnel nomeado para URL fixa |
|
|
375
|
+
| Quick com configuração prévia | Não compartilha diretório com `~/.cloudflared/config.yaml`; ver erros e [guia oficial](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/trycloudflare/) |
|
|
376
|
+
| Tunnel online mas app falha | Conferir Service URL `http://127.0.0.1:<端口>`, DNS e credenciais |
|
|
377
|
+
| Logs do servidor | `mobile-gateway.log` em temporários: Windows `%TEMP%`, macOS `$TMPDIR`, Linux geralmente `/tmp` |
|
|
378
|
+
|
|
379
|
+
## Desenvolvimento do código
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
dsh plugin --profile web add file:/absolute/path/to/dsh-plugin-mobile-gateway
|
|
383
|
+
npm test
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
Ferramentas oferece Reiniciar gateway e Parar DSH Web. Reinício só ao iniciar por `dsh web`, preserva argumentos e adiciona `--no-open`; a aba espera e recarrega. Novo processo em segundo plano, fora da tarefa do terminal original. Pare por menu ou `SIGTERM` ao DSH da porta Web. Conexões interrompidas brevemente e URL Quick pode mudar. Reinstale/reinicie após mudanças. Reinicie `dsh web` ao terminar.
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
## Integração de voz oficial
|
|
390
|
+
|
|
391
|
+
Plugin experimental oficial DSH 0.2.0-rc.2: listar reconhecedores, preparar/acompanhar modelos, preferências e transcrição. Cancelar/desconectar aborta; não envia automaticamente ao Agent.
|
|
392
|
+
|
|
393
|
+
1. Ative Entrada de voz (`@deepseek-ai/dsh-experimental-voice-input-bundle`) e baixe/prepare modelo.
|
|
394
|
+
2. Consulte `speech-catalog` pelo controle pareado; confira disponibilidade e `ready`/`standby`.
|
|
395
|
+
3. Converta gravação completa em WAV PCM16 mono 16 kHz e envie Base64 por `speech-transcribe`.
|
|
396
|
+
4. Insira `speech-transcript` no editor; envie `message` após confirmação.
|
|
397
|
+
|
|
398
|
+
Modelos no computador DSH, sem pesos no telefone. Só gravações completas; cliente deve integrar botões, permissões e conversão. [Protocolo](../../PROTOCOL.md#官方语音输入speech-input-v1).
|
|
399
|
+
|
|
400
|
+
Verifique WAV no plugin oficial instalado, Provider de teste e sem baixar modelos:
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
DSH_INSTALL_ROOT=/absolute/path/to/@deepseek-ai/dsh node test/speech-official.test.mjs
|
|
404
|
+
```
|
package/lib/client.js
CHANGED
|
@@ -132,6 +132,8 @@ window.__ModuleLoader__.load({
|
|
|
132
132
|
.mobile-gateway-panel .mgw-content::-webkit-scrollbar { display: none; }
|
|
133
133
|
.mobile-gateway-panel .mgw-content p { margin: 6px 0 10px; }
|
|
134
134
|
.mobile-gateway-panel strong { font-weight: 550; }
|
|
135
|
+
.mobile-gateway-panel .mgw-device-permissions > summary::-webkit-details-marker { display: none; }
|
|
136
|
+
.mobile-gateway-panel .mgw-device-permissions[open] > summary .mgw-permissions-chevron { transform: rotate(90deg); }
|
|
135
137
|
.mobile-gateway-panel .mgw-section-title { margin: 0 0 10px; font-size: 17px; line-height: 1.4; font-weight: 650; color: inherit; }
|
|
136
138
|
.mobile-gateway-panel .mgw-setting-row { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
|
|
137
139
|
.mobile-gateway-panel .mgw-setting-row select { width: auto !important; max-width: 100%; min-width: 150px; margin-bottom: 0 !important; flex-shrink: 1; }
|
|
@@ -601,7 +603,21 @@ window.__ModuleLoader__.load({
|
|
|
601
603
|
const sidebarOn = React.useSyncExternalStore(subscribeSidebar, getSidebarEntry, () => true)
|
|
602
604
|
const [activeSection, setActiveSection] = React.useState('general')
|
|
603
605
|
const [devices, setDevices] = React.useState(null)
|
|
604
|
-
const [
|
|
606
|
+
const [deviceLoadError, setDeviceLoadError] = React.useState(null)
|
|
607
|
+
const [statusLoadError, setStatusLoadError] = React.useState(null)
|
|
608
|
+
const refreshRequests = React.useRef(new Map())
|
|
609
|
+
const manualRefreshRef = React.useRef(false)
|
|
610
|
+
const [permissionSaving, setPermissionSaving] = React.useState(null)
|
|
611
|
+
const permissionLock = React.useRef(false)
|
|
612
|
+
const deviceRevision = React.useRef(0)
|
|
613
|
+
const [selectedDeviceIds, setSelectedDeviceIds] = React.useState(() => new Set())
|
|
614
|
+
React.useEffect(() => {
|
|
615
|
+
const existing = new Set((devices || []).map(device => device.id))
|
|
616
|
+
setSelectedDeviceIds(current => {
|
|
617
|
+
const next = new Set([...current].filter(id => existing.has(id)))
|
|
618
|
+
return next.size === current.size ? current : next
|
|
619
|
+
})
|
|
620
|
+
}, [devices])
|
|
605
621
|
const [status, setStatus] = React.useState(null)
|
|
606
622
|
const [dismissedNotice, setDismissedNotice] = React.useState(() => dismissedRestartInstance)
|
|
607
623
|
// 两个配对模块各自维护方案:鲸尾公网小程序(主用)与兼容 App(折叠备用)。
|
|
@@ -680,6 +696,14 @@ window.__ModuleLoader__.load({
|
|
|
680
696
|
const appRouteChosenRef = React.useRef(false)
|
|
681
697
|
const cloudflareModeLoadedRef = React.useRef(false)
|
|
682
698
|
|
|
699
|
+
// 同类读取去重:轮询与手动刷新并发时复用同一个 in-flight 请求(上游 0.12.x)。
|
|
700
|
+
const refreshRead = async (kind, options) => {
|
|
701
|
+
const inflight = refreshRequests.current.get(kind)
|
|
702
|
+
if (inflight && !(options && options.force)) return inflight
|
|
703
|
+
const task = request(kind === 'devices' ? '/mgw/devices' : '/mgw/status', options)
|
|
704
|
+
refreshRequests.current.set(kind, task)
|
|
705
|
+
try { return await task } finally { refreshRequests.current.delete(kind) }
|
|
706
|
+
}
|
|
683
707
|
const refresh = React.useCallback(async () => {
|
|
684
708
|
try {
|
|
685
709
|
const [deviceData, statusData] = await Promise.all([
|
|
@@ -725,8 +749,10 @@ window.__ModuleLoader__.load({
|
|
|
725
749
|
}
|
|
726
750
|
}, [])
|
|
727
751
|
|
|
752
|
+
|
|
728
753
|
const manualRefresh = async () => {
|
|
729
|
-
if (
|
|
754
|
+
if (manualRefreshRef.current) return
|
|
755
|
+
manualRefreshRef.current = true
|
|
730
756
|
setRefreshing(true)
|
|
731
757
|
setRefreshNotice(null)
|
|
732
758
|
const succeeded = await refresh()
|
|
@@ -1133,33 +1159,59 @@ window.__ModuleLoader__.load({
|
|
|
1133
1159
|
}
|
|
1134
1160
|
}
|
|
1135
1161
|
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1162
|
+
// 批量吊销:逐个调用单设备吊销接口(/mgw/devices/<id>/revoke)。
|
|
1163
|
+
const removeDevices = async (list) => {
|
|
1164
|
+
const targets = Array.isArray(list) ? list : [list]
|
|
1165
|
+
const removed = []
|
|
1166
|
+
for (const device of targets) {
|
|
1167
|
+
if (revokingIdsRef.current.has(device.id)) continue
|
|
1168
|
+
setDeviceNotice(null)
|
|
1169
|
+
setDeviceNoticeError(false)
|
|
1170
|
+
setError(null)
|
|
1171
|
+
deviceRevision.current += 1
|
|
1172
|
+
revokingIdsRef.current.add(device.id)
|
|
1173
|
+
setRevokingIds((current) => new Set(current).add(device.id))
|
|
1174
|
+
try {
|
|
1175
|
+
await request(`/mgw/devices/${encodeURIComponent(device.id)}/revoke`, { method: 'POST' })
|
|
1176
|
+
removed.push(device.id)
|
|
1177
|
+
setDevices((current) => Array.isArray(current) ? current.filter((item) => item.id !== device.id) : current)
|
|
1178
|
+
setDeviceNotice(`已吊销 ${device.displayName || device.name}`)
|
|
1179
|
+
window.setTimeout(() => setDeviceNotice(null), 2200)
|
|
1180
|
+
} catch (cause) {
|
|
1181
|
+
setDeviceNoticeError(true)
|
|
1182
|
+
setDeviceNotice(`吊销失败:${cause.message}`)
|
|
1183
|
+
setError(cause.message)
|
|
1184
|
+
} finally {
|
|
1185
|
+
deviceRevision.current += 1
|
|
1186
|
+
revokingIdsRef.current.delete(device.id)
|
|
1187
|
+
setRevokingIds((current) => { const next = new Set(current); next.delete(device.id); return next })
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
await refreshRead('devices')
|
|
1191
|
+
return removed
|
|
1192
|
+
const revoke = (device) => removeDevices([device])
|
|
1193
|
+
}
|
|
1194
|
+
const selectDevice = (id, selected) => setSelectedDeviceIds(current => {
|
|
1195
|
+
const next = new Set(current)
|
|
1196
|
+
selected ? next.add(id) : next.delete(id)
|
|
1197
|
+
return next
|
|
1198
|
+
})
|
|
1199
|
+
|
|
1200
|
+
const savePermission = async (device, module, value) => {
|
|
1201
|
+
if (permissionLock.current || revokingIdsRef.current.size) return
|
|
1202
|
+
permissionLock.current = true
|
|
1203
|
+
deviceRevision.current += 1
|
|
1204
|
+
setPermissionSaving(`${device.id}:${module}`)
|
|
1140
1205
|
setError(null)
|
|
1141
|
-
revokingIdsRef.current.add(device.id)
|
|
1142
|
-
setRevokingIds((current) => new Set(current).add(device.id))
|
|
1143
1206
|
try {
|
|
1144
|
-
await request(`/mgw/devices/${encodeURIComponent(device.id)}/
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
window.setTimeout(() => setDeviceNotice(null), 2200)
|
|
1148
|
-
} catch (cause) {
|
|
1149
|
-
setDeviceNoticeError(true)
|
|
1150
|
-
setDeviceNotice(`吊销失败:${cause.message}`)
|
|
1151
|
-
setError(cause.message)
|
|
1152
|
-
} finally {
|
|
1153
|
-
revokingIdsRef.current.delete(device.id)
|
|
1154
|
-
setRevokingIds((current) => {
|
|
1155
|
-
const next = new Set(current)
|
|
1156
|
-
next.delete(device.id)
|
|
1157
|
-
return next
|
|
1207
|
+
const result = await request(`/mgw/devices/${encodeURIComponent(device.id)}/permissions`, {
|
|
1208
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
1209
|
+
body: JSON.stringify({ permissions: { [module]: value } }),
|
|
1158
1210
|
})
|
|
1159
|
-
|
|
1160
|
-
}
|
|
1211
|
+
setDevices(current => current?.map(row => row.id === device.id ? { ...row, permissions: result.permissions } : row))
|
|
1212
|
+
} catch (cause) { setError(cause.message) }
|
|
1213
|
+
finally { deviceRevision.current += 1; permissionLock.current = false; setPermissionSaving(null) }
|
|
1161
1214
|
}
|
|
1162
|
-
|
|
1163
1215
|
const restartNoticeInstance = status?.gatewayInstanceId || (status?.webPid ? String(status.webPid) : null)
|
|
1164
1216
|
const dismissRestartNotice = () => {
|
|
1165
1217
|
dismissedRestartInstance = restartNoticeInstance
|
|
@@ -1169,7 +1221,10 @@ window.__ModuleLoader__.load({
|
|
|
1169
1221
|
|
|
1170
1222
|
const onlineDevices = (devices || []).filter((device) => device.online)
|
|
1171
1223
|
const offlineDevices = (devices || []).filter((device) => !device.online)
|
|
1172
|
-
const
|
|
1224
|
+
const orderedDevices = [...onlineDevices, ...offlineDevices]
|
|
1225
|
+
const selectedCount = orderedDevices.filter(device => selectedDeviceIds.has(device.id)).length
|
|
1226
|
+
const deletingDevices = revokingIds.size > 0
|
|
1227
|
+
const deviceActionsDisabled = deletingDevices || permissionSaving !== null
|
|
1173
1228
|
|
|
1174
1229
|
// The same v2 QR is native-app compatible; mini-program-only public
|
|
1175
1230
|
// routing is carried in an optional field that older apps ignore.
|
|
@@ -1271,7 +1326,7 @@ window.__ModuleLoader__.load({
|
|
|
1271
1326
|
React.createElement('div', { style: { color: colors.muted, marginTop: 4 } },
|
|
1272
1327
|
'端口仍被占用时,请关闭其他 Harness 实例。')) : null,
|
|
1273
1328
|
toolNotice ? React.createElement('div', { style: { ...styles.muted, marginBottom: 10 } }, toolNotice) : null,
|
|
1274
|
-
error ? React.createElement('div', { style: styles.error }, error) : null,
|
|
1329
|
+
(error || deviceLoadError || statusLoadError) ? React.createElement('div', { style: styles.error, role: 'alert' }, error || deviceLoadError || statusLoadError) : null,
|
|
1275
1330
|
React.createElement('div', { hidden: activeSection !== 'general' },
|
|
1276
1331
|
React.createElement('section', { style: styles.card },
|
|
1277
1332
|
React.createElement('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 14, alignItems: 'center' } },
|
|
@@ -58,10 +58,14 @@ function writeState(file, value) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
export function isCloudflareTunnelSupported(platform = process.platform) {
|
|
62
|
+
return ['darwin', 'win32', 'linux'].includes(platform)
|
|
63
|
+
}
|
|
64
|
+
|
|
61
65
|
// A separate loopback listener exposes only the mobile WebSocket. In particular,
|
|
62
66
|
// Cloudflare can never reach the DSH WebUI or the /mgw management API through it.
|
|
63
67
|
export function createCloudflareTunnel({ file, port = 3082, wsPath, executable = 'cloudflared',
|
|
64
|
-
supported =
|
|
68
|
+
supported = isCloudflareTunnelSupported(), isGatewayEnabled, onUpgrade, log = () => {}, spawnProcess = spawn,
|
|
65
69
|
prepareExecutable = ensureCloudflared, probeEndpoint = checkPublicEndpoint,
|
|
66
70
|
protocol = 'http2' } = {}) {
|
|
67
71
|
let settings = supported ? readState(file) : { version: 1, enabled: false, mode: 'quick', hostname: '', token: '' }
|
|
@@ -274,7 +278,7 @@ export function createCloudflareTunnel({ file, port = 3082, wsPath, executable =
|
|
|
274
278
|
}
|
|
275
279
|
|
|
276
280
|
const configure = async ({ enabled, mode, hostname, token }) => {
|
|
277
|
-
if (!supported) throw new TypeError('Cloudflare Tunnel is available on
|
|
281
|
+
if (!supported) throw new TypeError('Cloudflare Tunnel is available on macOS, Windows and Linux only')
|
|
278
282
|
if (typeof enabled !== 'boolean') throw new TypeError('enabled must be a boolean')
|
|
279
283
|
const next = {
|
|
280
284
|
version: 1,
|