Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DeepChat 文档索引

本文档反映 `2026-03-23` 完成的 legacy `AgentPresenter` retirement 之后的代码结构。
本文档反映 `2026-04-11` 完成 legacy `AgentPresenter` retirement 与 legacy provider runtime retirement 之后的代码结构。

当前聊天主链路已经收敛为:

Expand Down Expand Up @@ -36,6 +36,13 @@ Renderer
| [docs/specs/legacy-agentpresenter-retirement/spec.md](./specs/legacy-agentpresenter-retirement/spec.md) | 本次 retirement 的目标、范围、兼容边界 |
| [docs/specs/legacy-agentpresenter-retirement/plan.md](./specs/legacy-agentpresenter-retirement/plan.md) | 迁移/归档/验证计划 |
| [docs/specs/legacy-agentpresenter-retirement/tasks.md](./specs/legacy-agentpresenter-retirement/tasks.md) | 已执行清单 |
| [docs/specs/legacy-llm-provider-runtime-retirement/spec.md](./specs/legacy-llm-provider-runtime-retirement/spec.md) | legacy provider runtime retirement 规格 |
| [docs/specs/legacy-llm-provider-runtime-retirement/plan.md](./specs/legacy-llm-provider-runtime-retirement/plan.md) | provider runtime 收口与依赖清理计划 |
| [docs/specs/legacy-llm-provider-runtime-retirement/tasks.md](./specs/legacy-llm-provider-runtime-retirement/tasks.md) | provider runtime 退役执行清单 |
| [docs/specs/provider-layer-simplification/spec.md](./specs/provider-layer-simplification/spec.md) | provider layer 第二轮内部收口规格 |
| [docs/specs/provider-layer-simplification/plan.md](./specs/provider-layer-simplification/plan.md) | registry + generic provider 合并计划 |
| [docs/specs/provider-layer-simplification/tasks.md](./specs/provider-layer-simplification/tasks.md) | provider layer 第二轮执行清单 |
| [docs/specs/ai-sdk-runtime/spec.md](./specs/ai-sdk-runtime/spec.md) | AI SDK runtime 规格,现已更新为 retired 状态 |
| [docs/specs/architecture-simplification/spec.md](./specs/architecture-simplification/spec.md) | 整体减负治理规格 |
| [docs/specs/architecture-simplification/plan.md](./specs/architecture-simplification/plan.md) | 分层/基线/guard 计划 |
| [docs/specs/architecture-simplification/tasks.md](./specs/architecture-simplification/tasks.md) | 首期实施清单 |
Expand All @@ -62,10 +69,14 @@ docs/
├── specs/
│ ├── agent-cleanup/
│ ├── architecture-simplification/
│ ├── ai-sdk-runtime/
│ ├── provider-layer-simplification/
│ ├── legacy-llm-provider-runtime-retirement/
│ └── legacy-agentpresenter-retirement/
└── archives/
├── legacy-agentpresenter-architecture.md
├── legacy-agentpresenter-flows.md
├── legacy-llm-provider-runtime.md
├── thread-presenter-migration-plan.md
└── workspace-agent-refactoring-summary.md
```
Expand All @@ -78,6 +89,7 @@ docs/
| --- | --- |
| [archives/legacy-agentpresenter-architecture.md](./archives/legacy-agentpresenter-architecture.md) | 旧 `AgentPresenter` 架构快照 |
| [archives/legacy-agentpresenter-flows.md](./archives/legacy-agentpresenter-flows.md) | 旧 `startStreamCompletion` / permission / loop 流程 |
| [archives/legacy-llm-provider-runtime.md](./archives/legacy-llm-provider-runtime.md) | 旧 provider runtime 的历史归档与提交锚点 |
| [archives/thread-presenter-migration-plan.md](./archives/thread-presenter-migration-plan.md) | 历史迁移设计 |
| [archives/workspace-agent-refactoring-summary.md](./archives/workspace-agent-refactoring-summary.md) | 历史工作区改造总结 |

Expand Down
4 changes: 0 additions & 4 deletions docs/architecture/baselines/dependency-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Generated on 2026-04-03.
- `eventbus.ts`: 57
- `presenter/index.ts`: 44
- `presenter/llmProviderPresenter/runtimePorts.ts`: 34
- `presenter/llmProviderPresenter/providers/openAICompatibleProvider.ts`: 24
- `presenter/llmProviderPresenter/baseProvider.ts`: 19
- `presenter/remoteControlPresenter/types.ts`: 18
- `presenter/sqlitePresenter/tables/baseTable.ts`: 16
Expand All @@ -51,9 +50,7 @@ Generated on 2026-04-03.
- `presenter/index.ts -> presenter/windowPresenter/index.ts -> presenter/windowPresenter/FloatingChatWindow.ts -> presenter/index.ts`
- `presenter/index.ts -> presenter/shortcutPresenter.ts -> presenter/index.ts`
- `presenter/index.ts -> presenter/llmProviderPresenter/index.ts -> presenter/llmProviderPresenter/baseProvider.ts -> presenter/devicePresenter/index.ts -> presenter/index.ts`
- `presenter/index.ts -> presenter/llmProviderPresenter/index.ts -> presenter/llmProviderPresenter/managers/providerInstanceManager.ts -> presenter/llmProviderPresenter/providers/deepseekProvider.ts -> presenter/llmProviderPresenter/providers/openAICompatibleProvider.ts -> presenter/index.ts`
- `presenter/index.ts -> presenter/llmProviderPresenter/index.ts -> presenter/llmProviderPresenter/managers/providerInstanceManager.ts -> presenter/llmProviderPresenter/providers/githubCopilotProvider.ts -> presenter/githubCopilotDeviceFlow.ts -> presenter/index.ts`
- `presenter/index.ts -> presenter/llmProviderPresenter/index.ts -> presenter/llmProviderPresenter/managers/providerInstanceManager.ts -> presenter/llmProviderPresenter/providers/openAIResponsesProvider.ts -> presenter/index.ts`
- `presenter/filePresenter/mime.ts -> presenter/filePresenter/CsvFileAdapter.ts -> presenter/filePresenter/BaseFileAdapter.ts -> presenter/filePresenter/mime.ts`
- `presenter/index.ts -> presenter/sessionPresenter/index.ts -> presenter/index.ts`
- `presenter/index.ts -> presenter/sessionPresenter/index.ts -> presenter/sessionPresenter/managers/conversationManager.ts -> presenter/index.ts`
Expand Down Expand Up @@ -115,4 +112,3 @@ Generated on 2026-04-03.
- `components/json-viewer/JsonValue.ts -> components/json-viewer/JsonObject.ts -> components/json-viewer/JsonValue.ts`
- `components/json-viewer/JsonArray.ts -> components/json-viewer/JsonValue.ts -> components/json-viewer/JsonArray.ts`
- `composables/usePageCapture.example.ts -> composables/usePageCapture.example.ts`

4 changes: 1 addition & 3 deletions docs/architecture/baselines/zero-inbound-candidates.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ These files have no in-repo importers inside their scope and need manual classif

## main

- Candidate count: 16
- Candidate count: 15

- `env.d.ts`
- `lib/system.ts`
- `lib/terminalHelper.ts`
- `presenter/browser/BrowserContextBuilder.ts`
- `presenter/configPresenter/aes.ts`
- `presenter/llmProviderPresenter/oauthHelper.ts`
- `presenter/llmProviderPresenter/providers/openAIProvider.ts`
- `presenter/mcpPresenter/agentMcpFilter.ts`
- `presenter/searchPrompts/searchPrompts.ts`
- `presenter/sessionPresenter/events.ts`
Expand Down Expand Up @@ -73,4 +72,3 @@ These files have no in-repo importers inside their scope and need manual classif
- `stores/systemPromptStore.ts`
- `utils/maxOutputTokens.ts`
- `views/SettingsTabView.vue`

38 changes: 38 additions & 0 deletions docs/archives/legacy-llm-provider-runtime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Legacy LLM Provider Runtime Archive

## Summary

DeepChat previously maintained two low-level provider runtimes under `llmProviderPresenter`:

- the original provider-specific SDK implementations
- the newer shared AI SDK runtime

That rollback window is now closed. The active codebase only keeps the AI SDK runtime.

## Timeline

- AI SDK migration landed in commit `4c8345a7`
- Legacy runtime retirement and dependency cleanup landed after the migration stabilized

## Where To Find The Old Provider Implementation

Use commit `3add4093b46f15072d5ec3a65c8097e23b4907c4` to inspect the historical provider implementation and legacy runtime code.

That commit is the canonical source for:

- legacy provider request code
- legacy stream parsing branches
- provider-specific MCP conversion APIs
- legacy rollback-path wiring

## Current State

- no `DEEPCHAT_LLM_RUNTIME`
- no `llmRuntimeMode`
- no legacy provider SDK fallback branches in active providers
- no provider-specific MCP conversion APIs exposed from presenters

For current implementation details, read:

- [docs/specs/ai-sdk-runtime/spec.md](../specs/ai-sdk-runtime/spec.md)
- [docs/specs/legacy-llm-provider-runtime-retirement/spec.md](../specs/legacy-llm-provider-runtime-retirement/spec.md)
10 changes: 10 additions & 0 deletions docs/specs/ai-sdk-runtime/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# AI SDK Runtime Plan

Status: completed, rollback retired. See [../legacy-llm-provider-runtime-retirement/plan.md](../legacy-llm-provider-runtime-retirement/plan.md).

1. Introduce shared AI SDK runtime modules without changing upper-layer interfaces.
2. Migrate OpenAI-compatible and OpenAI responses providers first.
3. Migrate Anthropic / Gemini / Vertex / Bedrock / Ollama to the shared runtime.
4. Keep routing providers (`new-api`, `zenmux`) as thin delegates over migrated providers.
5. Freeze `LLMCoreStreamEvent` behavior with adapter-focused tests.
6. Retire the rollback path and delete legacy state machines.
93 changes: 93 additions & 0 deletions docs/specs/ai-sdk-runtime/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# AI SDK Runtime Spec

## Status

Completed in commit `4c8345a7`.

As of `2026-04-11`, the rollback path is retired. See [../legacy-llm-provider-runtime-retirement/spec.md](../legacy-llm-provider-runtime-retirement/spec.md).

## Goal

Unify DeepChat's low-level LLM request pipeline on Vercel AI SDK while keeping the upper-layer contracts unchanged:

- `BaseLLMProvider`
- `LLMProviderPresenter`
- `LLMCoreStreamEvent`
- existing provider IDs, model configs, and conversation history

The AI SDK runtime is the only remaining implementation.

## Non-Negotiable Compatibility

- No functional regression in text streaming, reasoning streaming, tool call streaming, image output, prompt cache, proxy handling, request tracing, routing, and embeddings.
- `LLMCoreStreamEvent` event names, field names, and stop reasons remain unchanged.
- Existing `function_call_record` history must stay reusable across providers.
- Existing provider list / model list / provider check / key status responsibilities remain in provider classes.

## Runtime Mode

- Single runtime: `ai-sdk`
- `DEEPCHAT_LLM_RUNTIME` has been removed
- config setting `llmRuntimeMode` has been removed

## Scope

Shared runtime under `src/main/presenter/llmProviderPresenter/aiSdk/` provides:

- provider factory
- model / message mapper
- MCP tool mapper
- streaming adapter
- image runtime
- embedding runtime
- provider-options mapper
- reasoning middleware
- legacy function-call compatibility middleware

## Provider Rollout

Phase 1:

- `OpenAICompatibleProvider`
- `OpenAIResponsesProvider`
- all `extends OpenAICompatibleProvider` providers

Phase 2:

- `AnthropicProvider`
- `GeminiProvider`
- `VertexProvider`
- `AwsBedrockProvider`
- `OllamaProvider`

Phase 3:

- `NewApiProvider`
- `ZenmuxProvider`

Out of scope for first unification pass:

- `AcpProvider`
- `VoiceAIProvider`

## Validation Matrix

- pure text
- reasoning native
- reasoning via `<think>`
- native tool streaming
- legacy `<function_call>` fallback
- multi-tool history replay
- image input
- image output
- usage mapping
- prompt cache mapping
- proxy / trace / abort
- embeddings
- retired rollback path verification

## Legacy Removal Exit Criteria

- AI SDK runtime passes the provider regression matrix
- duplicated legacy stream parsers / tool parsers have no remaining callers
- retirement is documented in [../legacy-llm-provider-runtime-retirement/spec.md](../legacy-llm-provider-runtime-retirement/spec.md)
17 changes: 17 additions & 0 deletions docs/specs/ai-sdk-runtime/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# AI SDK Runtime Tasks

- [x] Freeze migration scope in SDD docs.
- [x] Add shared AI SDK runtime modules. (implemented in 4c8345a7)
- [x] Integrate OpenAI-compatible runtime path. (implemented in 4c8345a7)
- [x] Integrate OpenAI responses runtime path. (implemented in 4c8345a7)
- [x] Integrate Anthropic runtime path. (implemented in 4c8345a7)
- [x] Integrate Gemini runtime path. (implemented in 4c8345a7)
- [x] Integrate Vertex runtime path. (implemented in 4c8345a7)
- [x] Integrate Bedrock runtime path. (implemented in 4c8345a7)
- [x] Integrate Ollama runtime path. (implemented in 4c8345a7)
- [x] Add regression tests for runtime adapter behavior. (implemented in 4c8345a7)
- [x] Retire `DEEPCHAT_LLM_RUNTIME` and `llmRuntimeMode`.
- [x] Remove legacy provider SDK fallback branches.
- [x] Remove provider-specific MCP conversion interfaces from presenter ports.
- [x] Record retirement history in [../legacy-llm-provider-runtime-retirement/tasks.md](../legacy-llm-provider-runtime-retirement/tasks.md).
- [x] Run format, i18n, lint, and targeted tests.
20 changes: 20 additions & 0 deletions docs/specs/legacy-llm-provider-runtime-retirement/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Legacy Provider Runtime Retirement Plan

## Outcome

Legacy provider runtime retirement is complete and no rollback path remains in the codebase.

## Executed Plan

1. Remove runtime selection and make AI SDK the only request runtime.
2. Collapse provider implementations onto shared AI SDK helpers.
3. Remove legacy MCP tool conversion surface from presenter interfaces.
4. Delete obsolete provider SDK dependencies and refresh lockfiles.
5. Archive the migration history and point readers to the final legacy-code commit.

## Exit Conditions

- No remaining source imports of `openai`, `@anthropic-ai/sdk`, `@google/genai`, `together-ai`, or `@aws-sdk/client-bedrock-runtime`
- No `DEEPCHAT_LLM_RUNTIME` or `llmRuntimeMode` references remain
- Main-process provider tests validate AI SDK-only behavior
- Documentation explicitly marks the rollback path as retired
45 changes: 45 additions & 0 deletions docs/specs/legacy-llm-provider-runtime-retirement/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Legacy Provider Runtime Retirement Spec

## Status

Completed on `2026-04-11`.

The hidden rollback window is closed. `llmProviderPresenter` now runs on AI SDK only.

## Goal

Retire the legacy provider runtime and remove obsolete provider SDK dependencies without changing upper-layer contracts:

- `BaseLLMProvider`
- `LLMProviderPresenter`
- `LLMCoreStreamEvent`
- existing provider IDs, model configs, conversation history, and `function_call_record` compatibility

## Scope

- Remove `DEEPCHAT_LLM_RUNTIME`
- Remove config key `llmRuntimeMode`
- Delete `src/main/presenter/llmProviderPresenter/aiSdk/runtimeMode.ts`
- Remove legacy-only provider branches, stream parsers, and MCP conversion ports
- Keep provider-managed responsibilities that still matter:
- `ollama` local model management
- `@aws-sdk/client-bedrock` model discovery

## Runtime State After Retirement

- Single runtime: `ai-sdk`
- No hidden fallback
- No provider-specific MCP conversion APIs exposed from presenters
- Vendor-specific request body customization is handled via AI SDK provider options mapping

## Historical Anchors

- AI SDK migration landed in commit `4c8345a7`
- Legacy provider implementation can be inspected at commit `3add4093b46f15072d5ec3a65c8097e23b4907c4`

## Compatibility Commitments

- `LLMCoreStreamEvent` names and fields remain unchanged
- Provider IDs and provider settings remain unchanged
- Existing message history and `function_call_record` remain reusable
- Routing providers (`new-api`, `zenmux`) stay as thin delegates over migrated providers
17 changes: 17 additions & 0 deletions docs/specs/legacy-llm-provider-runtime-retirement/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Legacy Provider Runtime Retirement Tasks

- [x] Delete `src/main/presenter/llmProviderPresenter/aiSdk/runtimeMode.ts`
- [x] Remove `DEEPCHAT_LLM_RUNTIME` and `llmRuntimeMode`
- [x] Convert provider request paths to AI SDK-only implementations
- [x] Remove provider-specific MCP tool conversion interfaces from presenter ports
- [x] Replace legacy SDK type imports with local neutral types where still needed
- [x] Remove obsolete provider SDK dependencies from `package.json`
- [x] Rewrite provider tests around AI SDK runtime helpers and delegate routing
- [x] Archive legacy runtime history and document the last legacy-code commit
- [x] Run `pnpm install`
- [x] Run `pnpm run format`
- [x] Run `pnpm run i18n`
- [x] Run `pnpm run lint`
- [x] Run `pnpm run typecheck`
- [x] Run targeted provider tests for the migrated AI SDK-only paths
- [ ] Run `pnpm run test:main`
15 changes: 15 additions & 0 deletions docs/specs/provider-layer-simplification/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Provider Layer Simplification Plan

1. Add a provider definition registry that captures runtime kind, model source, health check, and
hook strategy per provider.
2. Introduce a generic `AiSdkProvider` that owns AI SDK-backed text, stream, summary, image,
embeddings, and provider check flows.
3. Switch `ProviderInstanceManager` from vendor constructor maps to:
- special providers for `acp`, `github-copilot`, `voiceai`, `ollama`
- generic `AiSdkProvider` for all other AI SDK-backed providers
4. Move ModelScope MCP sync HTTP logic into shared helpers so `ModelscopeProvider` is no longer
required.
5. Adapt provider tests to assert behavior through the generic provider instead of vendor classes.
6. Delete obsolete vendor provider classes after import scans confirm they have no remaining
callers.
7. Run format, i18n, lint, typecheck, and targeted provider tests.
Loading
Loading