代码提交
This commit is contained in:
1 parent
500dab29ab
commit
70da7c5649
59 files changed
+12108
-148
No files matched your search
@@ -151,6 +151,7 @@ FastAPI application providing REST endpoints for frontend integration:
|
||||
| `GET /api/threads/{id}/uploads/list` | List uploaded files |
|
||||
| `DELETE /api/threads/{id}` | Delete DeerFlow-managed local thread data after LangGraph thread deletion; unexpected failures are logged server-side and return a generic 500 detail |
|
||||
| `GET /api/threads/{id}/artifacts/{path}` | Serve generated artifacts |
|
||||
| `GET/POST /api/deep-research/*` | Durable Deep Research sessions and jobs. `quick`/`basic` run the compact report flow; `detailed` plans subtopics and writes independent sections; `deep` recursively investigates bounded follow-up branches. All modes reuse DeerFlow's configured material provider, LLM factory, hidden-thread artifacts, and SSE event log. Optional report illustrations use a separately configured OpenAI-compatible image endpoint and are served only through the owning session's authenticated artifact route. |
|
||||
| `POST /api/ai-writing/sample/extract` | Extract text from Word/PDF/Markdown/TXT samples for AI-writing imitation mode |
|
||||
| `POST /cop/saveSuperiorTask` | TaskCOP compatibility API (DeerFlow Bearer/session authentication required): create a situation-overview task with a sequential four-digit id (`0001`, `0002`, ...) and return the legacy `{state, msg, data}` envelope |
|
||||
| `POST /api/taskcop/import/tasks` | TaskCOP compatibility API (authenticated): import tasks from a JSON array or `tasks`/`records` envelope; every row's supplied `id`/`taskId` is authoritative and a duplicate id completely replaces the stored task |
|
||||
@@ -159,7 +160,102 @@ FastAPI application providing REST endpoints for frontend integration:
|
||||
| `GET/POST/PUT /api/task-reports/by-task/{task_id}` | Shared task-scoped situation-report detail. Query, first save, and full update all use the legacy-compatible `{state, msg, data:[{id, taskId, createTime, updateTime, sessionId, contentJson, categoryType}]}` shape; `contentJson` is preserved as a JSON string. Saving a non-empty report automatically moves the matching TaskCOP task to status `25` (the legacy list's “已完成” state). |
|
||||
| `POST /api/task-reports/import/by-task/{task_id}` | TaskCOP detail import (authenticated): accept a `sq-report-mock.json`-compatible `data`/`records` array and atomically replace the selected task's full report. The path task id overrides task ids inside the file. |
|
||||
|
||||
The separately deployed TaskCOP Vue app uses `POST /api/v1/auth/login/username` directly (its `username`, `userId`, or `yUserId` URL parameter identifies the user), so this compatibility flow does not depend on the retired Consumer login service. It calls the Gateway address configured as `b1ConsumerUrl` directly; it does not use a Vite `/api` reverse proxy. An empty TaskCOP store remains empty; task data is introduced through normal creation or the JSON import API. The Gateway CORS middleware always merges the local TaskCOP Vite origins `http://localhost:8080` and `http://127.0.0.1:8080`, including when `GATEWAY_CORS_ORIGINS` is set for another frontend. `scripts/env.sh` also includes them in its startup default. For a deployment, set `GATEWAY_CORS_ORIGINS` to the exact additional frontend origins that are allowed to call the Gateway.
|
||||
The separately deployed TaskCOP Vue app uses `POST /api/v1/auth/login/username` directly (its `username`, `userId`, or `yUserId` URL parameter identifies the user), so this compatibility flow does not depend on the retired Consumer login service. It calls the Gateway address configured as `b1ConsumerUrl` directly; it does not use a Vite `/api` reverse proxy. An empty TaskCOP store remains empty; task data is introduced through normal creation or the JSON import API. The Gateway CORS middleware always merges local Vite origins `http://localhost|127.0.0.1:{5173,5174,3000,8080}`, including when `GATEWAY_CORS_ORIGINS` is set for another frontend. This keeps a Vite server that falls back from 5173 to 5174 (or the reverse) working after a backend restart. For a deployment, set `GATEWAY_CORS_ORIGINS` to the exact additional frontend origins that are allowed to call the Gateway.
|
||||
|
||||
### Deep Research modes
|
||||
|
||||
Deep Research is a separate Gateway feature rather than part of AI Writing. Its
|
||||
`detailed` runner adapts GPT Researcher's detailed-report control flow (plan
|
||||
subtopics, collect materials concurrently, write sections concurrently, then
|
||||
assemble the report). Its `deep` runner adapts the recursive DeepResearchSkill
|
||||
flow (branch, extract learnings, investigate follow-ups) with a deterministic
|
||||
query budget derived from `deep_breadth` and `deep_depth`. The runners live in
|
||||
`packages/harness/deerflow/agents/deep_research/runners/` and only use injected
|
||||
DeerFlow adapters. `multi_agent` is a LangGraph 1.x editor/researcher/writer/
|
||||
reviewer graph: it persists a plan-review pause, releases the worker lease, and
|
||||
resumes from the approved or revised plan through the existing durable-job API.
|
||||
Report prose uses the configured LangChain model's `astream()` path. Each
|
||||
native model delta is fanned out as an in-process `report_delta` SSE frame so
|
||||
the right-side `report.md` sandbox can write smoothly, while bounded,
|
||||
persisted `report_chunk` events remain reconnect checkpoints. The durable log
|
||||
is still authoritative: a browser reconnect, slow consumer, or another worker
|
||||
falls back to `?after=<seq>` replay rather than starting a second model call.
|
||||
The short non-streaming control-plane calls used to plan queries, sections, and
|
||||
reviews are independently capped at 45 seconds (maximum 120 seconds). If query
|
||||
or section planning times out, the runner emits a visible recoverable warning
|
||||
and searches the original research topic instead of leaving the job at the
|
||||
planning step indefinitely. Report-prose streaming is intentionally not capped
|
||||
by this control-plane limit.
|
||||
Planning also persists `queries_planned` before each basic, detailed, or
|
||||
multi-agent parallel search fan-out; the completed session stores its terminal
|
||||
`lastJobId` in the usage snapshot so
|
||||
the conversation workbench can replay the full planning/search/source/curation
|
||||
trace after a page refresh. These are observable execution facts only, never
|
||||
hidden model reasoning.
|
||||
Detailed reports use stable introduction/section/conclusion targets; a
|
||||
multi-agent review revision emits `report_reset` before the replacement draft.
|
||||
Every session may also provide a bounded `custom_outline`. Markdown headings or
|
||||
numbered entries become the deterministic section plan for `detailed` and
|
||||
`multi_agent`; `basic` and `deep` receive the same outline as a guarded
|
||||
report-writing constraint. The outline is frozen in the session snapshot and
|
||||
never treated as a system instruction.
|
||||
|
||||
All owner-scoped Deep Research routes resolve the platform's asynchronous
|
||||
`get_current_user` identity before querying or writing persistence, so session
|
||||
and job records are always bound to a concrete user ID.
|
||||
|
||||
Report artifacts are server-named and written through the canonical sandbox
|
||||
virtual path (`/mnt/user-data/outputs/<name>`), which the path layer maps to
|
||||
the host filesystem. This keeps native Windows deployments compatible without
|
||||
relaxing the sandbox traversal guard.
|
||||
|
||||
Deep Research reuses the DeerFlow Q&A retrieval stack instead of a separate
|
||||
scraper. It first runs enabled research skills (`deep-search`, `web-research`,
|
||||
and enabled knowledge-base skills) through the same `SubagentExecutor` runtime
|
||||
used by Q&A, then uses a configured `web_search` provider when present. If this
|
||||
offline deployment still has the shipped placeholder/disabled `web_search`
|
||||
configuration, it falls back to DeerFlow's existing keyless DuckDuckGo provider
|
||||
and, when that provider returns only irrelevant engine noise, a second real-web
|
||||
search source. It persists only real returned sources. A missing intranet
|
||||
endpoint therefore cannot by itself produce an empty Deep Research report. The capabilities API
|
||||
reports `skill` only when its required Q&A tool is available, and reports
|
||||
`web_search` when configured search or the online fallback can run.
|
||||
Cancelling a queued research job finalizes its job row and immediately marks
|
||||
the owning session `cancelled` with no active job, so it cannot retain a
|
||||
per-user concurrency slot.
|
||||
Saved `draft` sessions do not consume a concurrency slot; the two-job limit
|
||||
only applies to sessions with a `running` or `awaiting_input` durable job.
|
||||
|
||||
#### Optional report illustrations
|
||||
|
||||
DeerFlow's stock configuration includes image recognition but no image-generation
|
||||
provider. Deep Research therefore keeps illustrations disabled until an operator
|
||||
fills `config.yaml -> deep_research.image_generation` with an
|
||||
OpenAI-compatible image endpoint, API key, and model. When configured, the
|
||||
capabilities endpoint enables the page's “生成报告配图” switch. A selected job
|
||||
requests at most four base64 image results, writes them as protected
|
||||
`research-image-*.png|jpg|webp` artifacts, injects `deep-research://` links into
|
||||
the Markdown report, and emits image SSE events. A failed/unconfigured image
|
||||
provider only emits a recoverable warning; the text report still completes.
|
||||
|
||||
Completed reports also expose `GET /api/deep-research/sessions/{id}/messages`
|
||||
and `POST /api/deep-research/sessions/{id}/chat`. Follow-up answers are grounded
|
||||
only in that session's report, selected sources, and recent follow-up history;
|
||||
the assistant returns persisted source ids for every accepted citation. Passing
|
||||
`allow_new_research=true` is rejected rather than silently triggering another
|
||||
search job. Owners can change the follow-up evidence set with
|
||||
`PATCH /api/deep-research/sessions/{id}/sources/{source_id}` after a research
|
||||
job stops. That selection is applied immediately to later follow-up prompts;
|
||||
it never rewrites the completed report, and edits are rejected while the job is
|
||||
running so they cannot race the automatic curation projection.
|
||||
|
||||
The Deep Research page is a conversation workspace: the original research
|
||||
question, observable retrieval steps, completion summary, and report-grounded
|
||||
follow-ups appear in chronological order. The report itself is written in the
|
||||
adjacent sandbox as `/mnt/user-data/outputs/report.md`, with Word, Markdown,
|
||||
and HTML export actions. Word export uses the frontend's existing `docx`
|
||||
dependency and includes the collected reference list, without changing backend
|
||||
Python dependencies.
|
||||
|
||||
Position-roundtable history supports two modes. A non-empty `external_task_id` from the frontend route's `taskId` creates a row with `task_scoped = true`, so all sessions, nodes and persisted conversation snapshots for that task are shared across users; `user_id` is then creator audit metadata only. When the field is absent or empty, the original per-user personal-session behavior remains unchanged. Alembic revision `20260808_01` adds `task_scoped` with the safe default `false` for historical rows plus the task/update-time index.
|
||||
|
||||
@@ -338,11 +434,11 @@ Provider note:
|
||||
|
||||
### Browser CORS
|
||||
|
||||
The Gateway permits the local TaskCOP/Vite development origins
|
||||
`http://localhost:8080` and `http://127.0.0.1:8080` with credentials. For a
|
||||
separate deployed frontend, set `GATEWAY_CORS_ORIGINS` to its exact origin
|
||||
(including scheme and port), for example `http://47.88.25.99:7010`. Explicit
|
||||
origins are used in addition to the local TaskCOP development origins.
|
||||
The Gateway permits the local Vite development origins on ports 5173, 5174,
|
||||
3000, and 8080 for both `localhost` and `127.0.0.1` with credentials, even
|
||||
when `GATEWAY_CORS_ORIGINS` is set. For a separate deployed frontend, set
|
||||
`GATEWAY_CORS_ORIGINS` to its exact origin (including scheme and port), for
|
||||
example `http://47.88.25.99:7010`.
|
||||
|
||||
### Extensions Configuration (`extensions_config.json`)
|
||||
|
||||
|
||||
Reference in new issue
Block a user