dsh-local-ai 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/LICENSE +201 -0
- package/README.es.md +211 -0
- package/README.hi.md +211 -0
- package/README.md +211 -0
- package/README.pt.md +211 -0
- package/README.zh.md +211 -0
- package/THIRD_PARTY_NOTICES.md +20 -0
- package/cordis.patch.yml +44 -0
- package/lib/index.js +1334 -0
- package/lib/types/adapter.d.ts +39 -0
- package/lib/types/adapter.d.ts.map +1 -0
- package/lib/types/adapter.js +190 -0
- package/lib/types/adapter.js.map +1 -0
- package/lib/types/config.d.ts +109 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +161 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/health.d.ts +64 -0
- package/lib/types/health.d.ts.map +1 -0
- package/lib/types/health.js +92 -0
- package/lib/types/health.js.map +1 -0
- package/lib/types/index.d.ts +43 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +232 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/ollama.d.ts +91 -0
- package/lib/types/ollama.d.ts.map +1 -0
- package/lib/types/ollama.js +184 -0
- package/lib/types/ollama.js.map +1 -0
- package/lib/types/route.d.ts +52 -0
- package/lib/types/route.d.ts.map +1 -0
- package/lib/types/route.js +119 -0
- package/lib/types/route.js.map +1 -0
- package/lib/types/sanitize.d.ts +58 -0
- package/lib/types/sanitize.d.ts.map +1 -0
- package/lib/types/sanitize.js +110 -0
- package/lib/types/sanitize.js.map +1 -0
- package/lib/types/serialize.d.ts +65 -0
- package/lib/types/serialize.d.ts.map +1 -0
- package/lib/types/serialize.js +149 -0
- package/lib/types/serialize.js.map +1 -0
- package/lib/types/translate.d.ts +57 -0
- package/lib/types/translate.d.ts.map +1 -0
- package/lib/types/translate.js +169 -0
- package/lib/types/translate.js.map +1 -0
- package/lib/types/version.d.ts +6 -0
- package/lib/types/version.d.ts.map +1 -0
- package/lib/types/version.js +6 -0
- package/lib/types/version.js.map +1 -0
- package/package.json +141 -0
- package/src/adapter.ts +158 -0
- package/src/config.ts +243 -0
- package/src/health.ts +133 -0
- package/src/index.ts +279 -0
- package/src/ollama.ts +274 -0
- package/src/route.ts +127 -0
- package/src/sanitize.ts +114 -0
- package/src/serialize.ts +178 -0
- package/src/translate.ts +205 -0
- package/src/version.ts +5 -0
package/README.pt.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# 🤖 dsh-local-ai
|
|
4
|
+
|
|
5
|
+
**Integração de modelos locais (Ollama) para o DeepSeek Harness.**
|
|
6
|
+
|
|
7
|
+
*Descubra, baixe, remova e inspecione modelos locais, roteie solicitações para eles por tipo de tarefa ou palavra-chave com fallback automático para a nuvem e obtenha um resumo de status de relance com `/ollama`.*
|
|
8
|
+
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](https://github.com/topics/dsh-plugin)
|
|
11
|
+
[](#)
|
|
12
|
+
[](https://github.com/PerryLink/dsh-local-ai/actions)
|
|
13
|
+
[](https://github.com/PerryLink/dsh-local-ai/releases)
|
|
14
|
+
[](https://www.npmjs.com/package/dsh-local-ai)
|
|
15
|
+
[](https://www.npmjs.com/package/dsh-local-ai)
|
|
16
|
+
|
|
17
|
+
[English](README.md) · [简体中文](README.zh.md) · [Español](README.es.md) · [Português](README.pt.md) · [हिन्दी](README.hi.md)
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Compatibility
|
|
24
|
+
|
|
25
|
+
| Superfície | Status |
|
|
26
|
+
|---|---|
|
|
27
|
+
| Harness | DeepSeek Harness `0.1.0-rc.6` |
|
|
28
|
+
| Node | `^22.19.0 \|\| >=24.0.0` |
|
|
29
|
+
| Backend | [Ollama](https://ollama.com) (API HTTP local + sonda CLI) |
|
|
30
|
+
| Modelo | Rota somente texto (`inputModalities: ['text']`); chamadas e resultados de ferramentas são suportados |
|
|
31
|
+
|
|
32
|
+
## What you get
|
|
33
|
+
|
|
34
|
+
O `dsh-local-ai` torna o Ollama um provedor local de primeira classe no DeepSeek Harness:
|
|
35
|
+
|
|
36
|
+
- **Descoberta e gestão** — `ollama_list` (modelos instalados, em execução, uso de disco), `ollama_show` (tamanho de parâmetros, quantização, comprimento de contexto), `ollama_pull` e `ollama_remove`.
|
|
37
|
+
- **Verificação de saúde** — vitalidade do processo (via CLI `ollama`) e resposta da API (via `/api/version`), como dois sinais independentes.
|
|
38
|
+
- **Adaptador oficial** — a rota do provedor `ollama` é registrada por `ctx.llm.registerAdapter` (`LlmAdapter`), com mapeamento de modelos configurável e tradução de temperature / max-tokens / stop.
|
|
39
|
+
- **Roteamento local** — regras `model_route` roteiam solicitações para um modelo local por tipo de tarefa (`purpose`), palavra-chave (sem diferenciar maiúsculas) ou `always`, com fallback automático para a nuvem quando a rota local falha antes de produzir conteúdo.
|
|
40
|
+
- **Comando `/ollama`** — resumo de status de relance: modelos, uso de disco, saúde e sugestões.
|
|
41
|
+
- **Zero dependências, HTTP primeiro** — tudo fala com a API HTTP do Ollama (a CLI só é usada para a sonda de processo); nenhum arquivo de modelo é empacotado.
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
request (loop)
|
|
45
|
+
│ cascata llm/stream
|
|
46
|
+
├─ regra corresponde? ──▶ rotear para ollama ──▶ Ollama /api/chat (fluxo NDJSON)
|
|
47
|
+
│ └─ falha primeiro ─▶ fallback para nuvem (next())
|
|
48
|
+
└─ sem correspondência ──▶ provedor na nuvem
|
|
49
|
+
tools ──▶ /api/tags · /api/ps · /api/show · /api/pull · /api/delete
|
|
50
|
+
health ──▶ /api/version (API) + ollama list (processo)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Quick start
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
# 1. instale o bundle no seu perfil
|
|
57
|
+
dsh plugin --profile web add "github:PerryLink/dsh-local-ai#main"
|
|
58
|
+
|
|
59
|
+
# ou do npm (versões publicadas)
|
|
60
|
+
dsh plugin --profile web add dsh-local-ai
|
|
61
|
+
|
|
62
|
+
# 2. configure o roteamento no seu patch de perfil (cordis.yml) e reinicie
|
|
63
|
+
dsh --profile web
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Configuração mínima de roteamento (a regra vem comentada em `cordis.patch.yml`):
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
- insert:
|
|
70
|
+
- id: dsh-local-ai
|
|
71
|
+
name: dsh-local-ai
|
|
72
|
+
config:
|
|
73
|
+
route:
|
|
74
|
+
- model: llama3.2
|
|
75
|
+
keywords: ["confidential", "offline"]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Depois verifique se a linha monta:
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
dsh --profile web --dump-config | grep -A2 'id: dsh-local-ai'
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Install & uninstall
|
|
85
|
+
|
|
86
|
+
- **canal git** (último `main`): `dsh plugin --profile web add "github:PerryLink/dsh-local-ai#main"` — o script `prepare` compila apenas com dependências de produção.
|
|
87
|
+
- **canal npm** (versões publicadas): `dsh plugin --profile web add dsh-local-ai`.
|
|
88
|
+
- **canal tarball**: `pnpm pack` neste repo e depois `dsh plugin --profile web add ./dsh-local-ai-<version>.tgz`.
|
|
89
|
+
- **desinstalar**: `dsh plugin --profile web remove dsh-local-ai` (ou remova a linha do patch do perfil).
|
|
90
|
+
|
|
91
|
+
> Se o pnpm relatar `ERR_PNPM_IGNORED_BUILDS` para este pacote, adicione `allowBuilds: { esbuild: true }` ao seu `pnpm-workspace.yaml` — a CLI `dsh` imprime o trecho exato.
|
|
92
|
+
|
|
93
|
+
## Configuration
|
|
94
|
+
|
|
95
|
+
Todos os ajustes são campos `Config` de Schemastery (modificáveis pelo cordis.yml). Uma sobrescrita por id substitui a linha inteira — repita cada chave de que precisa. O `cordis.patch.yml` documenta cada chave em linha.
|
|
96
|
+
|
|
97
|
+
| Key | Default | Meaning |
|
|
98
|
+
|---|---|---|
|
|
99
|
+
| `baseURL` | `http://127.0.0.1:11434` | URL base da API HTTP do Ollama; caminhos `/api/*` são anexados |
|
|
100
|
+
| `requestTimeoutMs` | `30000` | Tempo limite HTTP por solicitação (milissegundos) |
|
|
101
|
+
| `graceMs` | `15000` | Graça de término do subprocesso para a sonda CLI de saúde |
|
|
102
|
+
| `defaultContextWindow` | `8192` | Capacidade de contexto quando um modelo não tem valor exato |
|
|
103
|
+
| `maxTokens` | `4096` | Limite de saída por solicitação quando um modelo não tem valor exato |
|
|
104
|
+
| `temperature` | *(none)* | Temperatura de amostragem padrão (0..2); omitir mantém o padrão do provedor |
|
|
105
|
+
| `models` | `[]` | Mapeamentos nome visível → modelo Ollama |
|
|
106
|
+
| `models[].name` | *(required)* | Nome de modelo visível no harness (`GenerateOptions.model`) |
|
|
107
|
+
| `models[].model` | `= name` | Id do modelo Ollama |
|
|
108
|
+
| `models[].contextWindow` | *(none)* | Capacidade de contexto por modelo |
|
|
109
|
+
| `models[].maxTokens` | *(none)* | Limite de saída por modelo |
|
|
110
|
+
| `models[].temperature` | *(none)* | Temperatura de amostragem por modelo |
|
|
111
|
+
| `route` | `[]` | Regras de roteamento para modelos locais (primeira correspondência vence) |
|
|
112
|
+
| `route[].model` | *(required)* | Nome do modelo local de destino |
|
|
113
|
+
| `route[].purpose` | *(none)* | Correspondência de tipo de tarefa: `compaction` / `session-title` |
|
|
114
|
+
| `route[].keywords` | `[]` | Palavras-chave da solicitação (sem diferenciar maiúsculas) |
|
|
115
|
+
| `route[].always` | `false` | Roteia toda solicitação elegível para este modelo |
|
|
116
|
+
|
|
117
|
+
## Tools & surfaces
|
|
118
|
+
|
|
119
|
+
| Superfície | Tipo | O que faz |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `ollama_list` | ferramenta | Lista modelos instalados, em execução e uso de disco |
|
|
122
|
+
| `ollama_show` | ferramenta | Mostra tamanho de parâmetros, quantização, comprimento de contexto, família, formato |
|
|
123
|
+
| `ollama_pull` | ferramenta | Baixa um modelo |
|
|
124
|
+
| `ollama_remove` | ferramenta | Remove um modelo |
|
|
125
|
+
| `ollama_health` | ferramenta | Vitalidade do processo + resposta da API |
|
|
126
|
+
| `/ollama` | comando | Resumo de status de relance (modelos + saúde + sugestões) |
|
|
127
|
+
|
|
128
|
+
**Consome** os serviços host públicos `ctx.llm` (`registerAdapter`), `ctx.tools`, `ctx.subprocess` (sonda CLI) e `ctx.commands`. Não curto-circuita `llm/stream` por padrão — o ouvinte de roteamento repassa (`next()`) salvo quando uma regra corresponde.
|
|
129
|
+
|
|
130
|
+
## Permissions & data
|
|
131
|
+
|
|
132
|
+
- **Permissões**: `network:outbound` para o endpoint Ollama que você configurar; sem código nativo, sem acesso ao sistema de arquivos, sem armazenamento.
|
|
133
|
+
- **Dados**: toda lista/detalhe de modelo, fato de saúde e mensagem de erro exibidos ao modelo ou ao usuário são sanitizados (userinfo e parâmetros de consulta secretos do endpoint removidos, caracteres de controle removidos, comprimentos limitados) antes da exibição. Resultados de ferramentas e comandos são registrados pelos mecanismos próprios do harness.
|
|
134
|
+
- **Credenciais**: o plugin não armazena nem lê credenciais. Ele apenas emite solicitações HTTP ao endpoint que você configurar, além da sonda de processo local `ollama list`.
|
|
135
|
+
|
|
136
|
+
## Security boundaries
|
|
137
|
+
|
|
138
|
+
- **Sem re-roteamento por padrão** — a lista `route` fica vazia salvo se você optar; uma solicitação chega a um modelo local apenas por uma regra explícita ou seleção explícita do provedor `ollama`.
|
|
139
|
+
- **Sanitização antes de exibir** — endereços de endpoint e caminhos locais são sanitizados antes de chegar à saída de ferramentas, ao comando `/ollama` ou a mensagens de erro.
|
|
140
|
+
- **Zero modelos empacotados** — downloads e armazenamento são responsabilidade do Ollama; nada é enviado no pacote.
|
|
141
|
+
- **Falha alta, falha contida** — configuração inválida faz o montagem falhar; uma rota local que falha antes de produzir conteúdo faz fallback para a nuvem (`next()`), de modo que um Ollama caído nunca trava uma conversa.
|
|
142
|
+
- **Visível ao modelo ⟺ registrado** — o roteamento só muda qual provedor atende uma solicitação (a mensagem do assistente é registrada com sua proveniência `ollama`); nenhuma entrada visível nova é inventada.
|
|
143
|
+
|
|
144
|
+
## Known limitations
|
|
145
|
+
|
|
146
|
+
- **Somente rc.6** — desenvolvido e testado contra `@deepseek-ai/dsh@0.1.0-rc.6`; espera-se que baselines mais novos funcionem, mas são verificados pelo workflow mensal de compat.
|
|
147
|
+
- **Rota somente texto** — conteúdo de imagem é rejeitado (`UNSUPPORTED_CONTENT`); modelos locais multimodais ainda não estão conectados.
|
|
148
|
+
- **Fallback no meio do fluxo** — uma vez que uma rota local começou a produzir conteúdo, uma falha posterior é reencaminhada (não retirada); apenas uma falha antes do primeiro token faz fallback para a nuvem.
|
|
149
|
+
|
|
150
|
+
## Development
|
|
151
|
+
|
|
152
|
+
```sh
|
|
153
|
+
pnpm install # node ^22.19 || >=24
|
|
154
|
+
pnpm run typecheck # tsc: src + testes contra os tipos publicados 0.1.0-rc.6
|
|
155
|
+
pnpm run typecheck:ci # tsc estrito contra os tipos publicados rc.6 (skipLibCheck off)
|
|
156
|
+
pnpm test # vitest: costuras reais Context/LlmRuntime/ToolRuntime/CommandRuntime/subprocess
|
|
157
|
+
pnpm run test:coverage # porta de cobertura (90/80/90/90)
|
|
158
|
+
pnpm run build # bundle tsdown + declarações tsc (lib/)
|
|
159
|
+
pnpm run verify:self-contained # especificações de dependências resolvem do registry
|
|
160
|
+
pnpm run verify:artifacts # face ESM construída + bundle patch presentes
|
|
161
|
+
node scripts/check-readme-sync.mjs # porta de sincronização de README em cinco idiomas
|
|
162
|
+
pnpm pack # o tarball publicado
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Topics
|
|
166
|
+
|
|
167
|
+
`dsh`, `dsh-plugin`, `deepseek-harness`, `deepseek`, `cordis`, `ollama`, `local-llm`, `local-models`, `offline`, `privacy`, `model-routing`
|
|
168
|
+
|
|
169
|
+
## Contributors
|
|
170
|
+
|
|
171
|
+
- [@PerryLink](https://github.com/PerryLink) — criador e mantenedor: adaptador, roteamento, ferramentas, verificação de saúde, sanitização e documentação em cinco idiomas.
|
|
172
|
+
|
|
173
|
+
## PerryLink DSH Plugin Family
|
|
174
|
+
|
|
175
|
+
Este projeto é um dos [29 complementos do DeepSeek Harness](https://github.com/PerryLink) mantidos por [PerryLink](https://github.com/PerryLink). Se este ajuda você, os outros provavelmente também ajudarão:
|
|
176
|
+
|
|
177
|
+
| Plugin | One-liner |
|
|
178
|
+
|---|---|
|
|
179
|
+
| [dsh-auto-review](https://github.com/PerryLink/dsh-auto-review) | Auto-revisão com segundo modelo na cadeia de aprovação, falha fechada por padrão |
|
|
180
|
+
| [dsh-background-agents](https://github.com/PerryLink/dsh-background-agents) | Agentes filhos em segundo plano e duráveis com barra lateral Web, mensagens e interrupção |
|
|
181
|
+
| [dsh-budget](https://github.com/PerryLink/dsh-budget) | Governança de custos para DeepSeek Harness: orçamentos, carbono e latência em um painel. |
|
|
182
|
+
| [dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-checkpoint-rewind) | Equivalente ao /rewind do Claude Code: instantâneos, bifurcações e restauração de uma vez |
|
|
183
|
+
| [dsh-claude-move](https://github.com/PerryLink/dsh-claude-move) | Migra sessões, memória, skills e CLAUDE.md do Claude Code para o DSH |
|
|
184
|
+
| [dsh-click](https://github.com/PerryLink/dsh-click) | Controle de desktop nativo multiplataforma para DeepSeek Harness — Windows primeiro. |
|
|
185
|
+
| [dsh-composer-history](https://github.com/PerryLink/dsh-composer-history) | Histórico de entrada estilo terminal para o compositor web: setas, busca Ctrl+R |
|
|
186
|
+
| [dsh-defend](https://github.com/PerryLink/dsh-defend) | Defesa contra injeção de prompt, jailbreak e vazamento de segredos para DeepSeek Harness. |
|
|
187
|
+
| [dsh-doublecheck](https://github.com/PerryLink/dsh-doublecheck) | Guarda de disciplina de engenharia: sabatina de requisitos, portões de teste, revisão adversária |
|
|
188
|
+
| [dsh-draw](https://github.com/PerryLink/dsh-draw) | Roteamento unificado de geração de imagens estáticas para DeepSeek Harness. |
|
|
189
|
+
| [dsh-fast](https://github.com/PerryLink/dsh-fast) | Diagnóstico de desempenho somente leitura para DeepSeek Harness. |
|
|
190
|
+
| [dsh-github](https://github.com/PerryLink/dsh-github) | Integração de PR/issues do GitHub para DSH, toda escrita com aprovação |
|
|
191
|
+
| [dsh-library](https://github.com/PerryLink/dsh-library) | Base de conhecimento documental local para DeepSeek Harness. |
|
|
192
|
+
| **[dsh-local-ai](https://github.com/PerryLink/dsh-local-ai)** | Integração de modelos locais (Ollama) para DeepSeek Harness. |
|
|
193
|
+
| [dsh-lsp-actions](https://github.com/PerryLink/dsh-lsp-actions) | Diagnóstico, formatação, completação, ações e renomeação LSP via servidores de linguagem |
|
|
194
|
+
| [dsh-mask](https://github.com/PerryLink/dsh-mask) | Middleware de mascaramento de PII para DeepSeek Harness — anonimiza antes do modelo e restaura na camada de exibição. |
|
|
195
|
+
| [dsh-mcp-panel](https://github.com/PerryLink/dsh-mcp-panel) | Painel MCP somente leitura: comando /mcp + aba de configurações com status, ferramentas e erros |
|
|
196
|
+
| [dsh-memento](https://github.com/PerryLink/dsh-memento) | Memória entre sessões com porta de aprovação: seam ctx.memory + SQLite + ferramenta memory |
|
|
197
|
+
| [dsh-observe](https://github.com/PerryLink/dsh-observe) | Exportador de observabilidade OpenTelemetry e Langfuse para DeepSeek Harness. |
|
|
198
|
+
| [dsh-output-styles](https://github.com/PerryLink/dsh-output-styles) | Troca de estilos em tempo de execução equivalente ao outputStyles do Claude Code |
|
|
199
|
+
| [dsh-permission-rules](https://github.com/PerryLink/dsh-permission-rules) | Regras declarativas allow/deny/ask estilo Claude Code com auditoria |
|
|
200
|
+
| [dsh-plugin-guide](https://github.com/PerryLink/dsh-plugin-guide) | Base de conhecimento de desenvolvimento de plugins como skill de agente sob demanda |
|
|
201
|
+
| [dsh-score](https://github.com/PerryLink/dsh-score) | Pontuação de qualidade multidimensional para plugins do DeepSeek Harness. |
|
|
202
|
+
| [dsh-session-pin](https://github.com/PerryLink/dsh-session-pin) | Fixa sessões na barra lateral Web com ordenação durável |
|
|
203
|
+
| [dsh-session-sync](https://github.com/PerryLink/dsh-session-sync) | Sincronização de sessões entre dispositivos para DeepSeek Harness — um espelho git dedicado do seu armazenamento de sessões. |
|
|
204
|
+
| [dsh-skill-pack-security](https://github.com/PerryLink/dsh-skill-pack-security) | Pacote de skills de auditoria de segurança: varredura de segredos, revisão de dependências e cadeia de suprimentos |
|
|
205
|
+
| [dsh-talk](https://github.com/PerryLink/dsh-talk) | Loop de sessão com voz para DeepSeek Harness: fale e ouça a resposta. |
|
|
206
|
+
| [dsh-test-drive](https://github.com/PerryLink/dsh-test-drive) | Testes isolados de instalação e inicialização para plugins do DeepSeek Harness. |
|
|
207
|
+
| [dsh-translate](https://github.com/PerryLink/dsh-translate) | Tradução de parâmetros entre fornecedores e reparo determinístico de JSON para DeepSeek Harness. |
|
|
208
|
+
|
|
209
|
+
## License
|
|
210
|
+
|
|
211
|
+
[Apache License 2.0](LICENSE) © 2026 dsh-local-ai contributors
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# 🤖 dsh-local-ai
|
|
4
|
+
|
|
5
|
+
**DeepSeek Harness 的本地模型(Ollama)接入。**
|
|
6
|
+
|
|
7
|
+
*发现、拉取、删除、查看本地模型,按任务类型或关键词把请求分流到本地模型并在失败时自动回退云端,通过 `/ollama` 一键查看状态总览。*
|
|
8
|
+
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](https://github.com/topics/dsh-plugin)
|
|
11
|
+
[](#)
|
|
12
|
+
[](https://github.com/PerryLink/dsh-local-ai/actions)
|
|
13
|
+
[](https://github.com/PerryLink/dsh-local-ai/releases)
|
|
14
|
+
[](https://www.npmjs.com/package/dsh-local-ai)
|
|
15
|
+
[](https://www.npmjs.com/package/dsh-local-ai)
|
|
16
|
+
|
|
17
|
+
[English](README.md) · [简体中文](README.zh.md) · [Español](README.es.md) · [Português](README.pt.md) · [हिन्दी](README.hi.md)
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Compatibility
|
|
24
|
+
|
|
25
|
+
| 项目 | 状态 |
|
|
26
|
+
|---|---|
|
|
27
|
+
| Harness | DeepSeek Harness `0.1.0-rc.6` |
|
|
28
|
+
| Node | `^22.19.0 \|\| >=24.0.0` |
|
|
29
|
+
| 后端 | [Ollama](https://ollama.com)(本地 HTTP API + CLI 探测) |
|
|
30
|
+
| 模型 | 纯文本路由(`inputModalities: ['text']`);支持工具调用与工具结果 |
|
|
31
|
+
|
|
32
|
+
## What you get
|
|
33
|
+
|
|
34
|
+
`dsh-local-ai` 让 Ollama 成为 DeepSeek Harness 的一等本地模型提供方:
|
|
35
|
+
|
|
36
|
+
- **发现与管理** — `ollama_list`(已安装模型 / 运行中 / 磁盘占用)、`ollama_show`(参数尺寸、量化、上下文长度)、`ollama_pull`、`ollama_remove`。
|
|
37
|
+
- **健康检查** — 进程存活(经 `ollama` CLI)与 API 响应(经 `/api/version`),作为两个独立信号报告。
|
|
38
|
+
- **官方适配器** — 通过 `ctx.llm.registerAdapter`(`LlmAdapter`)注册 `ollama` 提供方路由,支持配置模型映射与 temperature / max-tokens / stop 参数翻译。
|
|
39
|
+
- **本地路由** — `model_route` 规则按任务类型(`purpose`)、不区分大小写的关键词或 `always` 分流到本地模型,本地路由在产出内容前失败时自动回退云端。
|
|
40
|
+
- **`/ollama` 命令** — 一键状态总览:模型、磁盘占用、健康、建议。
|
|
41
|
+
- **零依赖、HTTP 优先** — 一切走 Ollama HTTP API(CLI 仅用于进程探测);不捆绑模型文件。
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
request (loop)
|
|
45
|
+
│ llm/stream 瀑布
|
|
46
|
+
├─ 命中规则? ──▶ 路由到 ollama ──▶ Ollama /api/chat(NDJSON 流)
|
|
47
|
+
│ └─ 先失败 ─▶ 回退云端(next())
|
|
48
|
+
└─ 未命中 ──▶ 云端提供方
|
|
49
|
+
tools ──▶ /api/tags · /api/ps · /api/show · /api/pull · /api/delete
|
|
50
|
+
health ──▶ /api/version(API)+ ollama list(进程)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Quick start
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
# 1. 把 bundle 安装进你的 profile
|
|
57
|
+
dsh plugin --profile web add "github:PerryLink/dsh-local-ai#main"
|
|
58
|
+
|
|
59
|
+
# 或从 npm(正式发布版)
|
|
60
|
+
dsh plugin --profile web add dsh-local-ai
|
|
61
|
+
|
|
62
|
+
# 2. 在 profile patch(cordis.yml)里配置路由并重启
|
|
63
|
+
dsh --profile web
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
最小路由配置(该规则在 `cordis.patch.yml` 里以注释形式给出):
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
- insert:
|
|
70
|
+
- id: dsh-local-ai
|
|
71
|
+
name: dsh-local-ai
|
|
72
|
+
config:
|
|
73
|
+
route:
|
|
74
|
+
- model: llama3.2
|
|
75
|
+
keywords: ["confidential", "offline"]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
验证 row 是否挂载:
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
dsh --profile web --dump-config | grep -A2 'id: dsh-local-ai'
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Install & uninstall
|
|
85
|
+
|
|
86
|
+
- **git 通道**(最新 `main`):`dsh plugin --profile web add "github:PerryLink/dsh-local-ai#main"` —— `prepare` 脚本只使用生产依赖构建。
|
|
87
|
+
- **npm 通道**(正式发布版):`dsh plugin --profile web add dsh-local-ai`。
|
|
88
|
+
- **tarball 通道**:在本仓库 `pnpm pack`,然后 `dsh plugin --profile web add ./dsh-local-ai-<version>.tgz`。
|
|
89
|
+
- **卸载**:`dsh plugin --profile web remove dsh-local-ai`(或从 profile patch 移除该 row)。
|
|
90
|
+
|
|
91
|
+
> 如果 pnpm 对本包报告 `ERR_PNPM_IGNORED_BUILDS`,请在 `pnpm-workspace.yaml` 里加 `allowBuilds: { esbuild: true }` —— `dsh` CLI 会打印精确片段。
|
|
92
|
+
|
|
93
|
+
## Configuration
|
|
94
|
+
|
|
95
|
+
所有可调参数都是 Schemastery `Config` 字段(可在 cordis.yml 中修改)。按 id 覆盖会替换整个 row —— 重述你需要的每个键。`cordis.patch.yml` 对每个键都有行内注释。
|
|
96
|
+
|
|
97
|
+
| Key | Default | Meaning |
|
|
98
|
+
|---|---|---|
|
|
99
|
+
| `baseURL` | `http://127.0.0.1:11434` | Ollama HTTP API 基础 URL;会追加 `/api/*` 路径 |
|
|
100
|
+
| `requestTimeoutMs` | `30000` | 单次请求 HTTP 超时(毫秒) |
|
|
101
|
+
| `graceMs` | `15000` | 健康检查 CLI 探测的子进程终止宽限 |
|
|
102
|
+
| `defaultContextWindow` | `8192` | 模型无精确值时的上下文容量 |
|
|
103
|
+
| `maxTokens` | `4096` | 模型无精确值时的单请求输出上限 |
|
|
104
|
+
| `temperature` | *(none)* | 默认采样温度(0..2);省略则用提供方默认值 |
|
|
105
|
+
| `models` | `[]` | Harness 可见名 → Ollama 模型映射 |
|
|
106
|
+
| `models[].name` | *(required)* | Harness 可见模型名(`GenerateOptions.model`) |
|
|
107
|
+
| `models[].model` | `= name` | Ollama 模型 id |
|
|
108
|
+
| `models[].contextWindow` | *(none)* | 该模型的上下文容量 |
|
|
109
|
+
| `models[].maxTokens` | *(none)* | 该模型的输出上限 |
|
|
110
|
+
| `models[].temperature` | *(none)* | 该模型的采样温度 |
|
|
111
|
+
| `route` | `[]` | 本地模型路由规则(首个命中生效) |
|
|
112
|
+
| `route[].model` | *(required)* | 目标本地模型名 |
|
|
113
|
+
| `route[].purpose` | *(none)* | 任务类型匹配:`compaction` / `session-title` |
|
|
114
|
+
| `route[].keywords` | `[]` | 不区分大小写的请求关键词 |
|
|
115
|
+
| `route[].always` | `false` | 把所有符合条件的请求路由到此模型 |
|
|
116
|
+
|
|
117
|
+
## Tools & surfaces
|
|
118
|
+
|
|
119
|
+
| 界面 | 类型 | 作用 |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `ollama_list` | 工具 | 列出已安装模型、运行中模型与磁盘占用 |
|
|
122
|
+
| `ollama_show` | 工具 | 显示参数尺寸、量化、上下文长度、family、format |
|
|
123
|
+
| `ollama_pull` | 工具 | 拉取(下载)模型 |
|
|
124
|
+
| `ollama_remove` | 工具 | 删除模型 |
|
|
125
|
+
| `ollama_health` | 工具 | 进程存活 + API 响应 |
|
|
126
|
+
| `/ollama` | 命令 | 一键状态总览(模型 + 健康 + 建议) |
|
|
127
|
+
|
|
128
|
+
**消费** 公开 host 服务 `ctx.llm`(`registerAdapter`)、`ctx.tools`、`ctx.subprocess`(CLI 探测)、`ctx.commands`。默认不短路 `llm/stream` —— 路由监听器在无规则命中时透传(`next()`)。
|
|
129
|
+
|
|
130
|
+
## Permissions & data
|
|
131
|
+
|
|
132
|
+
- **权限**:对您配置的 Ollama 端点的 `network:outbound`;无原生代码、无文件系统访问、无存储。
|
|
133
|
+
- **数据**:展示给模型或用户的每个模型列表/详情、健康事实与错误消息在展示前都经过脱敏(去除端点 userinfo 与密钥查询参数、剥离控制字符、限制长度)。工具与命令结果由 harness 自身的 tool/command 机制记录。
|
|
134
|
+
- **凭据**:插件不存储也不读取任何凭据。它只向您配置的端点发起 HTTP 请求,外加本地 `ollama list` 进程探测。
|
|
135
|
+
|
|
136
|
+
## Security boundaries
|
|
137
|
+
|
|
138
|
+
- **默认不重路由** —— `route` 列表默认为空;请求只有通过显式规则或显式选择 `ollama` 提供方才会到达本地模型。
|
|
139
|
+
- **展示前脱敏** —— 端点地址与本地路径在进入工具输出、`/ollama` 命令或错误消息前都会被脱敏。
|
|
140
|
+
- **零捆绑模型** —— 下载与存储是 Ollama 自己的事;包内不含任何模型。
|
|
141
|
+
- **失败响亮、失败可控** —— 非法配置导致挂载失败;本地路由在产出内容前失败会回退云端(`next()`),因此 Ollama 宕机不会卡死对话。
|
|
142
|
+
- **模型可见 ⟺ 已记录** —— 路由只改变由哪个提供方服务请求(assistant 消息会以 `ollama` 来源记录);不凭空新增模型可见输入。
|
|
143
|
+
|
|
144
|
+
## Known limitations
|
|
145
|
+
|
|
146
|
+
- **仅 rc.6** —— 针对 `@deepseek-ai/dsh@0.1.0-rc.6` 开发与测试;更新版本的 harness 基线预期可用,但由每月 compat workflow 验证。
|
|
147
|
+
- **纯文本路由** —— 图片内容会被拒绝(`UNSUPPORTED_CONTENT`);多模态本地模型尚未接入。
|
|
148
|
+
- **中途失败不回退** —— 本地路由一旦开始产出内容,之后的失败会透传(无法撤回);只有首个 token 前的失败才回退云端。
|
|
149
|
+
|
|
150
|
+
## Development
|
|
151
|
+
|
|
152
|
+
```sh
|
|
153
|
+
pnpm install # node ^22.19 || >=24
|
|
154
|
+
pnpm run typecheck # tsc:src + 测试,对发布版 0.1.0-rc.6 类型
|
|
155
|
+
pnpm run typecheck:ci # 严格 tsc,对发布版 rc.6 类型(关闭 skipLibCheck)
|
|
156
|
+
pnpm test # vitest:真实 Context/LlmRuntime/ToolRuntime/CommandRuntime/subprocess 机制
|
|
157
|
+
pnpm run test:coverage # 覆盖率门禁(90/80/90/90)
|
|
158
|
+
pnpm run build # tsdown 打包 + tsc 声明(lib/)
|
|
159
|
+
pnpm run verify:self-contained # 依赖声明均来自 registry
|
|
160
|
+
pnpm run verify:artifacts # 构建产物 ESM 面 + bundle patch 存在
|
|
161
|
+
node scripts/check-readme-sync.mjs # 五语 README 同步门禁
|
|
162
|
+
pnpm pack # 发布用 tarball
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Topics
|
|
166
|
+
|
|
167
|
+
`dsh`, `dsh-plugin`, `deepseek-harness`, `deepseek`, `cordis`, `ollama`, `local-llm`, `local-models`, `offline`, `privacy`, `model-routing`
|
|
168
|
+
|
|
169
|
+
## Contributors
|
|
170
|
+
|
|
171
|
+
- [@PerryLink](https://github.com/PerryLink) — 创建者与维护者:适配器、路由、工具、健康检查、脱敏与五语文档。
|
|
172
|
+
|
|
173
|
+
## PerryLink DSH Plugin Family
|
|
174
|
+
|
|
175
|
+
本项目是由 [PerryLink](https://github.com/PerryLink) 维护的 [29 个 DeepSeek Harness 插件](https://github.com/PerryLink)之一。如果这个对你有用,其他插件很可能也会:
|
|
176
|
+
|
|
177
|
+
| Plugin | One-liner |
|
|
178
|
+
|---|---|
|
|
179
|
+
| [dsh-auto-review](https://github.com/PerryLink/dsh-auto-review) | 审批链上的第二模型自动审查,默认失败关闭 |
|
|
180
|
+
| [dsh-background-agents](https://github.com/PerryLink/dsh-background-agents) | 持久化后台子代理,带 Web UI 侧边栏、消息与打断 |
|
|
181
|
+
| [dsh-budget](https://github.com/PerryLink/dsh-budget) | DeepSeek Harness 的成本治理:预算、碳排与延迟一屏呈现。 |
|
|
182
|
+
| [dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-checkpoint-rewind) | Claude Code /rewind 等价物:快照、会话分叉、一次性恢复 |
|
|
183
|
+
| [dsh-claude-move](https://github.com/PerryLink/dsh-claude-move) | 将 Claude Code 会话、记忆、技能与 CLAUDE.md 迁入 DSH |
|
|
184
|
+
| [dsh-click](https://github.com/PerryLink/dsh-click) | 跨平台原生桌面控制(DeepSeek Harness),Windows 优先。 |
|
|
185
|
+
| [dsh-composer-history](https://github.com/PerryLink/dsh-composer-history) | Web 输入框的终端式输入历史:方向键、Ctrl+R 搜索 |
|
|
186
|
+
| [dsh-defend](https://github.com/PerryLink/dsh-defend) | DeepSeek Harness 的提示注入、越狱与密钥泄露防护。 |
|
|
187
|
+
| [dsh-doublecheck](https://github.com/PerryLink/dsh-doublecheck) | 工程纪律门禁:需求质询、测试门禁、对抗式审查 |
|
|
188
|
+
| [dsh-draw](https://github.com/PerryLink/dsh-draw) | DeepSeek Harness 的统一静态图像生成路由。 |
|
|
189
|
+
| [dsh-fast](https://github.com/PerryLink/dsh-fast) | DeepSeek Harness 的只读性能诊断。 |
|
|
190
|
+
| [dsh-github](https://github.com/PerryLink/dsh-github) | DSH 的 GitHub PR/issue 集成,每次写入都经审批门 |
|
|
191
|
+
| [dsh-library](https://github.com/PerryLink/dsh-library) | DeepSeek Harness 的本地文档知识库。 |
|
|
192
|
+
| **[dsh-local-ai](https://github.com/PerryLink/dsh-local-ai)** | DeepSeek Harness 的本地模型(Ollama)接入。 |
|
|
193
|
+
| [dsh-lsp-actions](https://github.com/PerryLink/dsh-lsp-actions) | 经语言服务器的 LSP 诊断、格式化、补全、代码操作与重命名 |
|
|
194
|
+
| [dsh-mask](https://github.com/PerryLink/dsh-mask) | DeepSeek Harness 的 PII 脱敏中间件——数据到模型前匿名化,展示层还原。 |
|
|
195
|
+
| [dsh-mcp-panel](https://github.com/PerryLink/dsh-mcp-panel) | 只读 MCP 运行时面板:/mcp 命令 + 带状态、工具与错误的设置页 |
|
|
196
|
+
| [dsh-memento](https://github.com/PerryLink/dsh-memento) | 带审批门的跨会话记忆:ctx.memory 接缝 + SQLite + memory 工具 |
|
|
197
|
+
| [dsh-observe](https://github.com/PerryLink/dsh-observe) | DeepSeek Harness 的 OpenTelemetry 与 Langfuse 可观测导出器。 |
|
|
198
|
+
| [dsh-output-styles](https://github.com/PerryLink/dsh-output-styles) | Claude Code outputStyles 等价的运行时样式切换 |
|
|
199
|
+
| [dsh-permission-rules](https://github.com/PerryLink/dsh-permission-rules) | Claude Code 风格声明式 allow/deny/ask 权限规则,带审计 |
|
|
200
|
+
| [dsh-plugin-guide](https://github.com/PerryLink/dsh-plugin-guide) | 按需 agent 技能形式的插件开发知识库 |
|
|
201
|
+
| [dsh-score](https://github.com/PerryLink/dsh-score) | DeepSeek Harness 插件的多指标质量评分。 |
|
|
202
|
+
| [dsh-session-pin](https://github.com/PerryLink/dsh-session-pin) | 在 Web 侧边栏置顶会话,顺序持久化 |
|
|
203
|
+
| [dsh-session-sync](https://github.com/PerryLink/dsh-session-sync) | DeepSeek Harness 的跨设备会话同步——会话存储的专用 git 镜像。 |
|
|
204
|
+
| [dsh-skill-pack-security](https://github.com/PerryLink/dsh-skill-pack-security) | 安全审计技能包:密钥扫描、依赖与供应链审查 |
|
|
205
|
+
| [dsh-talk](https://github.com/PerryLink/dsh-talk) | DeepSeek Harness 的语音优先会话闭环:对它说,听它答。 |
|
|
206
|
+
| [dsh-test-drive](https://github.com/PerryLink/dsh-test-drive) | DeepSeek Harness 插件的隔离式安装冒烟实测。 |
|
|
207
|
+
| [dsh-translate](https://github.com/PerryLink/dsh-translate) | DeepSeek Harness 的厂商参数翻译与确定性 JSON 修复。 |
|
|
208
|
+
|
|
209
|
+
## License
|
|
210
|
+
|
|
211
|
+
[Apache License 2.0](LICENSE) © 2026 dsh-local-ai contributors
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
`dsh-local-ai` bundles no third-party source code. All TypeScript/JavaScript
|
|
4
|
+
sources in this repository are original works by the dsh-local-ai
|
|
5
|
+
contributors, licensed under Apache-2.0 (see `LICENSE`).
|
|
6
|
+
|
|
7
|
+
The package depends on the following software. None of it is bundled into the
|
|
8
|
+
published tarball; these are install-time dependencies:
|
|
9
|
+
|
|
10
|
+
| Package | Version range | License | Purpose |
|
|
11
|
+
|---|---|---|---|
|
|
12
|
+
| [tsdown](https://github.com/rolldown/tsdown) | `^0.22.14` | MIT | Build-time bundling of `lib/` (a regular dependency so the git-install channel's `prepare` script can build) |
|
|
13
|
+
| [typescript](https://github.com/microsoft/TypeScript) | `^5.9.0` | Apache-2.0 | Build-time declaration emission (`lib/types/`) |
|
|
14
|
+
| [@deepseek-ai/cordis](https://www.npmjs.com/package/@deepseek-ai/cordis) | `^4.0.1` (peer) | See package | The plugin runtime |
|
|
15
|
+
| [@deepseek-ai/schemastery](https://www.npmjs.com/package/@deepseek-ai/schemastery) | `^3.18.0` (peer) | See package | Configuration schema |
|
|
16
|
+
| `@deepseek-ai/dsh-*` peers | `0.1.0-rc.6` (peer) | See packages | Official harness seams (`dsh-llm`, `dsh-tools`, `dsh-subprocess`, `dsh-commands`, `dsh-timeout`) |
|
|
17
|
+
|
|
18
|
+
At runtime the plugin only talks to the Ollama endpoint you configure (over
|
|
19
|
+
its HTTP API and, for the process-liveness probe, its CLI); it performs no
|
|
20
|
+
other network requests.
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# dsh-local-ai bundle patch: mount the local-model (Ollama) integration.
|
|
2
|
+
#
|
|
3
|
+
# Every key below is a Config field (Schemastery schema); invalid values fail
|
|
4
|
+
# the profile load loudly. See README.md "Configuration" for the full table.
|
|
5
|
+
# Off by default: the `route` list is empty, so no request is re-routed to a
|
|
6
|
+
# local model until you configure at least one rule (or select the `ollama`
|
|
7
|
+
# provider explicitly).
|
|
8
|
+
- insert:
|
|
9
|
+
- id: dsh-local-ai
|
|
10
|
+
name: dsh-local-ai
|
|
11
|
+
config:
|
|
12
|
+
# Ollama HTTP API base URL; /api/* paths are appended by the plugin.
|
|
13
|
+
baseURL: http://127.0.0.1:11434
|
|
14
|
+
# Per-request HTTP timeout in milliseconds.
|
|
15
|
+
requestTimeoutMs: 30000
|
|
16
|
+
# Subprocess terminate grace (ms) for the health-check CLI probe.
|
|
17
|
+
graceMs: 15000
|
|
18
|
+
# Combined context capacity used when a model has no exact value.
|
|
19
|
+
defaultContextWindow: 8192
|
|
20
|
+
# Per-request output cap used when a model has no exact value.
|
|
21
|
+
maxTokens: 4096
|
|
22
|
+
# Default sampling temperature; omit to keep the provider default.
|
|
23
|
+
# temperature: 0.7
|
|
24
|
+
# Harness-visible -> Ollama model mappings. Each entry maps a name you
|
|
25
|
+
# select in the harness to an Ollama model id (defaults to the name).
|
|
26
|
+
models: []
|
|
27
|
+
# models:
|
|
28
|
+
# - name: local
|
|
29
|
+
# model: llama3.2
|
|
30
|
+
# contextWindow: 4096
|
|
31
|
+
# maxTokens: 2048
|
|
32
|
+
# temperature: 0.7
|
|
33
|
+
# Routing rules (first match wins): route requests to a local model by
|
|
34
|
+
# task type (purpose), keyword (case-insensitive), or always. A rule
|
|
35
|
+
# needs at least one of purpose/keywords/always; an empty list means
|
|
36
|
+
# no automatic re-routing.
|
|
37
|
+
route: []
|
|
38
|
+
# route:
|
|
39
|
+
# - model: local
|
|
40
|
+
# keywords: ["confidential", "offline", "internal"]
|
|
41
|
+
# - model: local
|
|
42
|
+
# purpose: compaction
|
|
43
|
+
# - model: local
|
|
44
|
+
# always: true # offline-first: route everything local
|