Repository navigation
feat: bind knowledge MCP services to workflow nodes and chat sessions - #1434
alberthaolihai wants to merge 60 commits into
Conversation
… tests - checkReferences: surface underlying probe errors and distinguish 'no read-only tools' instead of the misleading identity-related message - UI: align knowledge picker (chat + SOP node) and dialog footer buttons with existing design system; fix message-references class collision - tests: add validate/redaction/token/check-reference edge cases and fix pre-existing struct-comparability compile error in query_performance_test - deploy: isolate compose project name for parallel fork instance
… and citation tracking
…with multi-connection & console UI
…s, and route management APIs per connection
…talog cache, and origin separation (step 3)
- dual-timeout clients (60s json / 10m stream) sharing one transport - outbound URL validation and cross-origin redirect refusal - UpstreamError with three-envelope parsing and Structured flag (1MiB cap) - io.Pipe streaming multipart upload safe on early upstream errors - streaming preview/download with active MIME downgrade and log path truncation - capability/document/chunk domain models for the management surface
…(step 3) - resolve exactly the named connection and reject non-canonical scoped ids - gate document operations before the parent knowledge-base lookup - invalidate cached capabilities only for changed connections - inherit the top-level provider for connection checks
Add 11 DOM-driven cases for web/app/knowledge.js: connection capability badges and re-probe, 503 capability_unavailable degradation gating, explicit connectionId KB create/update/delete, three-mode document import, document list paging/reparse/delete confirm, document detail drawer (inert/focus restore, chunk paging, safe text preview, legacy chunk fallback, manual edit PUT), admin:* audit badges, search, distill review, and not-ready/LightCloud/read-only fallbacks. load-app: default capabilities route returns an empty safe payload so existing knowledge stubs stay backward compatible.
P1-1: preview stub now carries <b>/<img onerror> markup and asserts tags stay as text, never become elements. P1-2: project scope starts empty, asserts unchecked, checks via DOM click, then asserts PUT writes {projectId:[source]}. P1-3: assert legacy capability probe happens once despite re-renders, assert scoped connID::rawID prefix wins over the active connection filter, and add a single-connection addressing case covering bare source/doc ids.
… (step 4) - check accepts connectionId and returns capability snapshot; new GET /connections/:id/capabilities - source detail (GET /sources/:id) and PATCH with field presence, so a partial update no longer clears the description; PUT keeps full replace - document detail/chunks and verbatim preview/download streaming with sanitized MIME, nosniff and no-store; gzip skips these paths so the exact Content-Length survives - upload streams multipart.File through UploadDocumentReader, rejects bodies past the 50MiB file + 1MiB envelope limit with 413 - every management write emits a structured audit line and an admin:* activity entry, with parent target fallback on failure - sources?connectionId= filters by explicit connection and rejects unknown/default under multi-connection settings - TestKnowledgeManagement covers capability gates, 503 mapping, streaming headers, project scope 403, audit entries and read-only isolation when probes fail Verified: gofmt, go vet ./internal/httpapi ./internal/knowledge, go test -race ./internal/httpapi -run TestKnowledgeManagement, full ./internal/httpapi ./internal/knowledge, go build ./...
…p 5) - probe preview and download independently, deriving the aggregate preview_download so one denied action no longer disables the other - reject query/fragment credentials in the WeKnora base URL and redact connection URLs using the inherited provider in Public() - accept legacy connectionId=default, allow PATCH in CORS preflight and require platform admin for forced capability refresh - invalidate stale probes on demotion after a concurrent invalidate and make the singleflight probe panic-safe
- track which capability keys the backend actually returned so legacy payloads stay optimistic while explicit unknown verdicts are enforced - gate preview and download separately and recompute the aggregate badge state after a live 503 demotion - add webtest coverage for endpoint asymmetry and legacy 404 + 503
…bedding model config
…icate superscripts
# Conflicts: # chatbot/src/knowledge-citations.js # internal/domain/knowledge_ref.go # internal/httpapi/knowledge_reference.go # internal/httpapi/knowledge_reference_edges_test.go # internal/knowledge/rules.go
…n with auto refresh
…ax reference-check
- three-segment OAuth card (none/auto/preset) in connector drawer with preset gallery, public-app notice and read-only redirect URI - vendor gallery cards with unauthorized grayscale / authorized states and one-click authorization - OAuth session lifecycle (begin/end/timeout reaping) closed by BroadcastChannel completion signal, with auto probe after grant - sync i18n entries and add acceptance tests
…verified vendor presets
…only callTool responses
… approval, and 2025-06-18 support
…, SiYuan, and Feishu
…dings P0: - compose.yaml: restore project name loopforge (volume/network compatibility) - openapi.yaml: cover GET /api/knowledge/connectors contract - gin_helpers/auth_tokens: drop global DisallowUnknownFields and stale weknora console-sso redeem auth/CORS exemption - connector_feishu: fix getTAT mutex self-deadlock; release tatMu before network I/O (redactWithTAT) - connector_mcp: prefix mcpClients/mcpToolsCache/mcpSemaphores keys with OwnerUserID; never cache probe connectors; refresh lastToken on retry; split consecutive-uppercase acronyms and extend write verbs - connector_common/connector_weknora/mcpclient: unified SSRF DialContext guard, no ProxyFromEnvironment, exclude link-local/CGNAT/metadata IPs, same-origin redirects, 16MB response cap, scanner.Err, separate initMu - oauth/service_oauth/knowledge_oauth/server: browser-binding cookie (loopforge_kb_oauth_nonce) + VerifyOAuthStateNonce against Login-CSRF; POST-only /authorize; ignore unverified X-Forwarded-Host; SHA-256 domain-separated state secret; verifyStateAt uses injected clock P1: - assistant/assistant_session/assistant_workbench: isolate personal KB refs by owner in project sessions - service: require fresh credentials when endpoint changes (check/update) - knowledge handler: server-generated kbconn_* IDs only - connector_feishu: validate obj_token belongs to allowed space node tree - connector_obsidian: block hidden path segments, require .md suffix - engine/node_execute: persist cited_count on success and all waiting_approval paths - docs: rewrite 4 knowledge guides for the 6-connector architecture P2/P3: - connector_common: rune-based case-insensitive snippet matching (no panic) - connector_weknora: mode-based allowlist check, bounded error drain - executor/connector_mcp: context.WithoutCancel + timeout for singleflight - engine/assets: XML-escape fallback SOP knowledge catalog - agent_tool_mcp: fail-closed write-tool approval gate - knowledge_proxy: require RunID/NodeID and run-node liveness - migrations/036: idempotent MySQL cited_count via information_schema - repo: composite usage index alignment, row lock on connector upsert, config JSON fallback + AllowedTools normalization, dedup/sorted usage deltas, throttled prune out of hot tx, LIKE escaping - web: iframe postMessage navigation to knowledge view, escaped error rendering, usage-events request sequencing, i18n sync, css cleanup - chatbot: citation scroll after expand via useEffect, ArtifactPanel fallback prefers selected.runId Tests updated for the new security rules (OAuth cookie/POST-only, proxy run identity, endpoint-change credential reset). go vet ./... clean; knowledge/mcpclient/repo/domain/engine/httpapi/web/docs/api/mcpserver, chatbot Vitest 384/384 and webtest 197/197 all green.
…-ups Covers cross-run ArtifactPanel knowledge read isolation, per-nonce OAuth browser cookies, Obsidian hidden-entry filtering, strict connector endpoint credential reuse checks, MCP semaphore ref-counted cleanup, and guarded mcpclient transport with hermetic regression tests.
…ector # Conflicts: # chatbot/src/ActivityTrace.jsx # chatbot/src/App.jsx # chatbot/src/RichContent.jsx # chatbot/src/useChat.js # internal/domain/run.go # internal/engine/artifacts.go # internal/engine/node_execute.go # internal/httpapi/agent_tool_catalog.go # internal/httpapi/assistant.go # internal/httpapi/assistant_fork.go # internal/httpapi/assistant_native_approval.go # internal/httpapi/assistant_session.go # internal/httpapi/assistant_workbench.go # internal/httpapi/gin_helpers.go # internal/httpapi/runs.go # internal/httpapi/server.go # internal/knowledge/service.go # internal/knowledge/service_test.go # internal/mcpclient/client.go # internal/repo/automigrate.go # internal/repo/models.go # internal/repo/run_knowledge.go # internal/runtime/protocol.go # web/app.js # web/app/flows.js # web/app/runners.js # web/app/runs.js # web/embed.go # web/index.html # webtest/lib/load-app.mjs # webtest/tests/views.test.mjs
|
Code Review: ISSUES FOUND ❌ Reviewed changes: Binds knowledge MCP services to workflow nodes and chat sessions. P2 — Cross-user personal KB exposure: P2 — Broken connector causes permanent 400: P2 — SSRF via MCP connectors: P2 — Silent backwards-compat break: P2 — Migration number collision: P3s:
The P2 issues (cross-user data exposure, SSRF, migration collision) need to be resolved before this PR is ready to merge. loopforge-pr-review:e8ee72d544cd0741a2ad7b66e362bcd6456ce533 |
What changed
Describe the user problem and the resulting behavior.
Scope
Compatibility
List affected hosts and any migration or backward-compatibility impact.
Validation
List commands that were actually run and mark anything blocked or not run.
Safety