Commit graph

6405 commits

Author SHA1 Message Date
CREDO23
14bbea0854 refactor(agents): delete single-agent stack + new_chat shim package (bucket B3/B4)
With multi-agent the only live factory (B1), the single-agent stack is dead.
Remove app/agents/new_chat/ entirely: chat_deepagent.py, subagents/, and all
re-export shims (errors/context/llm_config/permissions/tools/middleware/...) that
existed only to serve frozen single-agent code. Live code already imports the
shared kernel (app.agents.shared.*) directly.

Tests: delete single-agent-only suites (test_resolve_prompt_model_name,
test_specialized_subagents) and the chat_deepagent source-shape contract assertion;
repoint test_scoped_model_fallback to the shared middleware path. Suite green
(2710 passed).
2026-06-04 13:40:44 +02:00
CREDO23
724bbd6deb refactor(agents): hardwire multi-agent as the only chat factory (bucket B1)
Make create_multi_agent_chat_deep_agent the unconditional agent factory in
all three streaming entry points (stream_new_chat monolith + new_chat/resume
flow orchestrators). Drop the MULTI_AGENT_CHAT_ENABLED branch and the now-unused
create_surfsense_deep_agent / _app_config imports. The single-agent
implementation (chat_deepagent.py, subagents/) is left in place; it is deleted
in a later phase. Suite green (2758 passed).
2026-06-04 13:35:38 +02:00
CREDO23
64d2ad6451 refactor(agents): promote anonymous_agent to its own anonymous_chat/ package (slice 8)
The anonymous / free-chat agent is a distinct live agent (not part of the
single-agent stack and not shared infrastructure), so it gets its own top-level
package app/agents/anonymous_chat/ (sibling to multi_agent_chat). Moved
new_chat/anonymous_agent.py -> anonymous_chat/agent.py with a package __init__
re-exporting create_anonymous_chat_agent + build_anonymous_system_prompt.

Repointed its only new_chat import (the context shim) to app.agents.shared.context
and updated the single importer (anonymous_chat_routes). The test_import_all
guard auto-discovers the new package via pkgutil.walk_packages, so it is covered.
2026-06-04 13:25:23 +02:00
CREDO23
a019f18d1c refactor(agents): move connector_searchable_types, agent_cache, system_prompt + prompts to app/agents/shared (slice 7b)
Three live shared leaves discovered while taking stock after slice 7 (all are
consumed by the multi-agent stack and/or live routes, not single-agent-only):

- connector_searchable_types -> shared + shim (multi-agent factory uses it)
- agent_cache -> shared + shim (multi-agent runtime/agent_cache uses it)
- system_prompt + prompts/ (42 .md fragments) -> shared together + shim.
  Repointed composer's _PROMPTS_PACKAGE to app.agents.shared.prompts so
  importlib.resources fragment loading keeps working; system_prompt's relative
  ".prompts.composer" import is preserved by moving both as a unit.

Each keeps a re-export shim for the frozen chat_deepagent. After this slice,
new_chat/ holds only the frozen single-agent stack (chat_deepagent, subagents/,
__init__) plus shims.
2026-06-04 13:21:45 +02:00
CREDO23
13a96851ef refactor(agents): move skills/, plugins/, plugin_loader to app/agents/shared (slice 7)
- skills/ (builtin SKILL.md assets) has zero Python importers; it is read by
  filesystem path only. Moved the dir and restored
  skills_backends._default_builtin_root() to the clean
  parent.parent / "skills" / "builtin" form (undoing the transient path from 5c).
- plugin_loader.py -> shared (frozen chat_deepagent uses it -> re-export shim).
- plugins/ package -> shared (year_substituter rewired to shared.plugin_loader;
  docstring entry-point example updated to the shared dotted path). No shim
  needed (only a test imported it). Plugin discovery is via importlib entry
  points (group "surfsense.plugins"), not dotted-path import, and nothing is
  registered in pyproject, so the move does not affect runtime discovery.
2026-06-04 13:16:22 +02:00
CREDO23
aab95b9130 refactor(agents): move tools package to app/agents/shared (slice 6)
Relocate the entire new_chat/tools/ package (62 files incl. registry, hitl, MCP
cluster, and all connector subpackages: gmail/slack/discord/teams/drive/etc.)
to the shared kernel. The package turned out to be a clean cohesive cluster:
its only references to non-tools new_chat modules were comments, and its
middleware deps were already flipped to shared in slice 5c.

Flip 33 live importers (multi-agent, flows, routes, services, anonymous_agent,
tests). Re-export shims remain for the frozen single-agent stack: a package
__init__ mirroring the public surface (new_chat.__init__ imports it) plus
invalid_tool + registry submodule shims (chat_deepagent imports those).

Resolves slice 5c's two transient back-edges: shared/middleware/action_log
(TYPE_CHECKING ToolDefinition) and tool_call_repair (local INVALID_TOOL_NAME)
now point at app.agents.shared.tools.
2026-06-04 13:11:56 +02:00
CREDO23
a7fde2a48e refactor(agents): move filesystem_backends to app/agents/shared (slice 5d)
Completes slice 5. filesystem_backends was deferred from 3b because it depends
on middleware.{kb_postgres_backend,multi_root_local_folder_backend}; those moved
to shared in 5c, so it now relocates cleanly. Flip the 2 non-frozen importers
(multi-agent factory + test); a re-export shim remains for the frozen
chat_deepagent (build_backend_resolver).
2026-06-04 13:03:15 +02:00
CREDO23
227983a104 refactor(agents): move middleware package to app/agents/shared (slice 5c)
Relocate the entire new_chat/middleware/ package to the shared kernel as one
cohesive unit (it is live shared infrastructure: the multi-agent stack wraps
nearly every middleware via multi_agent_chat/middleware/main_agent/*, and
anonymous_agent consumes it too). Flip 69 live importers across both the
package-path and submodule-path forms.

Shims left for the frozen single-agent stack: a package __init__ re-export plus
submodule shims for permission, skills_backends, and scoped_model_fallback
(the three imported via submodule path by chat_deepagent/subagents).

Cycle break: importing shared.middleware previously reached back into
new_chat.tools at module load, which dragged in new_chat.__init__ ->
chat_deepagent -> the middleware shim -> half-initialized shared.middleware.
Made action_log's ToolDefinition import TYPE_CHECKING-only and
tool_call_repair's INVALID_TOOL_NAME import function-local. These tools-package
back-edges fully resolve in slice 6.

Asset note: skills_backends._default_builtin_root now walks to
app/agents/new_chat/skills/builtin (the skills/ tree migrates in slice 7).
2026-06-04 13:00:41 +02:00
CREDO23
6f488d9564 refactor(agents): move checkpointer + mention_resolver to app/agents/shared (slice 5b)
Two independent leaf modules (no intra-new_chat deps, no frozen importer),
consumed only by flows/routes/tests. Flipped 8 importers across both the
dotted-path and module-style (from app.agents.new_chat import mention_resolver)
forms. No shims needed.
2026-06-04 12:52:54 +02:00
CREDO23
dcdf8f776b refactor(agents): move utils + document_xml to app/agents/shared (slice 5a)
Two pure leaf modules with no intra-new_chat deps and no frozen importer.
Moving them now (before the middleware package) pre-empts two shared->new_chat
back-edges that the middleware move would otherwise create
(knowledge_search->utils, kb_postgres_backend->document_xml).
2026-06-04 12:50:38 +02:00
CREDO23
946f8a8c5d refactor(agents): move llm_config + prompt_caching to app/agents/shared (slice 4b)
Relocate the mutually-dependent LLM config layer and the LiteLLM prompt-caching
helper to the shared kernel as one unit, rewiring their internal cross-reference
to the shared paths. Flip 21 non-frozen importers. Re-export shims remain at
new_chat/{llm_config,prompt_caching}.py for the frozen single-agent stack
(chat_deepagent); they will be removed when that stack is retired.
2026-06-04 12:41:52 +02:00
CREDO23
8fca2753aa refactor(agents): move permissions to app/agents/shared (slice 4a)
Relocate the permission evaluator (wildcard matcher + rule evaluation) to the
shared kernel and flip 43 non-frozen importers. A re-export shim remains at
new_chat/permissions.py for the frozen single-agent stack (chat_deepagent and
subagents/{config,providers/linear,providers/slack}); it will be removed when
that stack is retired.
2026-06-04 12:38:30 +02:00
CREDO23
3efe51e6ec refactor(agents): move filesystem_state, path_resolver, sandbox to app/agents/shared (slice 3b)
Relocate three leaf filesystem-cluster modules to the shared kernel and flip
all 38 importers. No re-export shims needed (no frozen single-agent importer).
This also resolves the pre-existing shared->new_chat back-edge from
shared/receipt_command.py onto filesystem_state.

filesystem_backends is intentionally deferred to slice 5: it depends on
new_chat middleware (kb_postgres_backend, multi_root_local_folder_backend)
that have not yet moved, so relocating it now would create a shared->new_chat edge.
2026-06-04 12:34:28 +02:00
CREDO23
1b536b8aee refactor(agents): move filesystem_selection to app/agents/shared (slice 3a)
Promote the filesystem mode contracts (FilesystemMode, FilesystemSelection,
ClientPlatform, LocalFilesystemMount) out of `new_chat` into the cross-agent
`app/agents/shared` kernel.

Pure leaf consumed across the whole multi-agent filesystem middleware/tool tree,
the chat flows/monolith, routes and tests. git mv (content unchanged) + flipped
all ~48 importers. A re-export shim remains at new_chat/filesystem_selection.py
only for the not-yet-retired single-agent (chat_deepagent).

Also updated the stream parity test's annotation normalizer to strip the new
app.agents.shared.filesystem_selection. prefix (the dataclasses' __module__
changed with the move), keeping monolith<->flows signature parity intact.

Behavior-preserving: only import paths change. 1326 tests green.
2026-06-04 12:28:20 +02:00
CREDO23
a975754e7d refactor(agents): move feature flags to app/agents/shared/feature_flags (slice 2b)
Promote the agent feature-flag resolver (AgentFeatureFlags / get_flags) out of
`new_chat` into the cross-agent `app/agents/shared` kernel.

feature_flags is a pure leaf consumed across the multi-agent middleware stack,
the chat routes, and tests. Moved it via git mv (content unchanged) and flipped
all 37 importers to app.agents.shared.feature_flags. A thin re-export shim
remains at new_chat/feature_flags.py only for the not-yet-retired single-agent
(chat_deepagent); it goes away with the single-agent deletion.

Behavior-preserving: only import paths change. 1243 tests green.
2026-06-04 12:23:12 +02:00
CREDO23
28b13ed25b refactor(agents): move context schema + state reducers to app/agents/shared (slice 2)
Continue promoting the shared agent toolkit out of `new_chat` into the
cross-agent `app/agents/shared` kernel.

- state_reducers.py: clean move (no single-agent importer); all 7 importers
  flipped to app.agents.shared.state_reducers.
- context.py: moved to app.agents.shared.context; flipped the multi-agent,
  app, automations, chat-flows and monolith importers. A thin re-export shim
  remains at new_chat/context.py because the not-yet-retired single-agent
  (chat_deepagent) and the new_chat package __init__ still import it; the shim
  goes away with the single-agent deletion.
- Updated the stream parity test's annotation normalizer to strip the new
  app.agents.shared.context. prefix (SurfSenseContextSchema.__module__ changed
  with the move), keeping monolith<->flows signature parity intact.

Behavior-preserving: definitions unchanged; only import paths move. 1219 tests green.
2026-06-04 12:19:22 +02:00
CREDO23
0354f73f29 refactor(agents): move error taxonomy to app/agents/shared/errors (slice 1)
First slice of promoting the shared agent toolkit out of the misnamed
`new_chat` package into the cross-agent `app/agents/shared` kernel.

`errors.py` is a leaf module (no intra-package deps) consumed by the
multi-agent chat, the chat streaming flows/monolith, and tests — i.e. it is
shared infrastructure, not single-agent code. Moved it verbatim to
`app.agents.shared.errors` and flipped all 12 importers. No re-export shim
remains since zero importers needed it.

Behavior-preserving: identical class/enum definitions; only the import path
changes. 1208 agent + chat-task tests green.
2026-06-04 12:13:55 +02:00
CREDO23
a4010a357f refactor: extract shared connector->searchable-type mapping out of chat_deepagent
The multi-agent factory reached into the single-agent factory module
(chat_deepagent) for `_map_connectors_to_searchable_types`. Move this
agent-agnostic helper (and its two lookup tables) into a dedicated
`connector_searchable_types` module and point both factories at it.

Behavior-preserving: the function body is unchanged; only its home and
visibility (now public `map_connectors_to_searchable_types`) change. This
removes the cross-dependency on the dying single-agent module so it can be
retired later without breaking the multi-agent path.
2026-06-04 12:05:17 +02:00
CREDO23
0b006badb0 chore: remove dead agent code (vision autocomplete, linear tools, provider hints) 2026-06-04 11:44:23 +02:00
CREDO23
fb70e23dd2 test: add agent refactor guardrail suite 2026-06-04 11:44:23 +02:00
CREDO23
cb44063081 fix: repair pre-existing agent_task, gateway, and skills tests 2026-06-04 10:25:06 +02:00
CREDO23
44abf56d6c fix: restore connector mentions, free-tier fallback, orphan-row guard in new chat flow 2026-06-04 10:25:06 +02:00
CREDO23
1165b3ad5c test: add notifications unit tests and conventions doc 2026-06-03 21:53:06 +02:00
CREDO23
3f770203ca test: add notifications integration behavior guard 2026-06-03 21:53:06 +02:00
CREDO23
339ec31cad refactor: use transform helpers in notifications API 2026-06-03 21:53:03 +02:00
CREDO23
1ea7d3109a feat: add pure notifications API transform helpers 2026-06-03 21:53:03 +02:00
CREDO23
7a6fcfb29b refactor: use shared truncate in mention and reply handlers 2026-06-03 21:53:03 +02:00
CREDO23
778ab9b254 refactor: route indexing handlers through message helpers 2026-06-03 21:53:03 +02:00
CREDO23
7618c3aafb refactor: use pure metadata core in base handler 2026-06-03 21:52:58 +02:00
CREDO23
d53707ebbf feat: add pure notification metadata transitions 2026-06-03 21:52:58 +02:00
CREDO23
c23bdc4a5e feat: add pure notification message helpers 2026-06-03 21:52:58 +02:00
CREDO23
f3ed1b85d0 test: switch pytest to importlib import mode 2026-06-03 21:52:54 +02:00
CREDO23
75b37bb8d4 refactor: remove legacy notification service 2026-06-03 18:04:47 +02:00
CREDO23
9dab07f775 refactor: point notification callers at notifications module 2026-06-03 18:04:47 +02:00
CREDO23
5d2a36f579 refactor: serve notifications API from notifications module 2026-06-03 18:04:47 +02:00
CREDO23
e5236d33a9 refactor: move Notification model into notifications module 2026-06-03 18:04:47 +02:00
CREDO23
9575b9d4db refactor: add notifications module 2026-06-03 18:04:47 +02:00
Rohan Verma
309bd9a2dd
Merge pull request #1463 from CREDO23/feat/blob-storage
[Feat] Add Document Blob Storage, Segregate Connectors, and Jira Cleanup
2026-06-02 12:15:48 -07:00
CREDO23
10a2f1ec2f chore(backend): ignore local object store 2026-06-02 16:56:01 +02:00
CREDO23
0259c53f50 fix(db): restore automation_runs to zero_publication 2026-06-02 16:56:01 +02:00
CREDO23
b6710ae9af refactor(jira): remove dead legacy indexing and write tools (mcp-only now) 2026-06-02 16:38:00 +02:00
CREDO23
ef60af90cf feat(web): segregate connectors into knowledge base and tools/live sources 2026-06-02 16:37:54 +02:00
CREDO23
af192a8405 feat(web): add download original action to editor header 2026-06-02 16:10:50 +02:00
CREDO23
637affecb8 feat(web): add document files contract and api method 2026-06-02 16:10:50 +02:00
CREDO23
a4f3af7ed8 chore(dev): document storage env vars and add azurite service 2026-06-02 16:10:50 +02:00
CREDO23
537b6e3b33 feat(db): add document_files migration 2026-06-02 16:10:50 +02:00
CREDO23
f9e2c22d45 feat(documents): purge stored blobs on document deletion 2026-06-02 16:10:50 +02:00
CREDO23
a4b31929d0 feat(documents): persist original upload bytes on file upload 2026-06-02 16:10:50 +02:00
CREDO23
7dad9ec3a9 feat(api): mount file-storage router 2026-06-02 16:10:50 +02:00
CREDO23
5e5f51b3a0 feat(db): register DocumentFile and document.files relationship 2026-06-02 16:10:44 +02:00