ltcai 10.0.0 → 10.3.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.
Files changed (214) hide show
  1. package/README.md +43 -32
  2. package/docs/CHANGELOG.md +204 -0
  3. package/docs/COMMUNITY_AND_PLUGINS.md +1 -1
  4. package/docs/DEVELOPMENT.md +1 -1
  5. package/docs/HYBRID_CLOUD_KG_STREAMING.md +101 -0
  6. package/docs/MYPY_BACKLOG.md +98 -0
  7. package/docs/ONBOARDING.md +1 -1
  8. package/docs/OPERATIONS.md +1 -1
  9. package/docs/TRUST_MODEL.md +1 -1
  10. package/docs/WHY_LATTICE.md +1 -1
  11. package/docs/kg-schema.md +1 -1
  12. package/lattice_brain/__init__.py +1 -1
  13. package/lattice_brain/archive.py +5 -4
  14. package/lattice_brain/conversations.py +14 -3
  15. package/lattice_brain/embeddings.py +12 -2
  16. package/lattice_brain/graph/_kg_common.py +5 -5
  17. package/lattice_brain/graph/_kg_fsutil.py +5 -4
  18. package/lattice_brain/graph/discovery.py +4 -3
  19. package/lattice_brain/graph/discovery_index.py +0 -1
  20. package/lattice_brain/graph/documents.py +3 -2
  21. package/lattice_brain/graph/fusion.py +4 -0
  22. package/lattice_brain/graph/ingest.py +12 -2
  23. package/lattice_brain/graph/projection.py +3 -2
  24. package/lattice_brain/graph/provenance.py +5 -3
  25. package/lattice_brain/graph/rerank.py +4 -1
  26. package/lattice_brain/graph/retrieval.py +0 -1
  27. package/lattice_brain/graph/retrieval_docgen.py +0 -1
  28. package/lattice_brain/graph/retrieval_reads.py +0 -1
  29. package/lattice_brain/graph/retrieval_vector.py +0 -1
  30. package/lattice_brain/graph/schema.py +4 -3
  31. package/lattice_brain/graph/store.py +18 -4
  32. package/lattice_brain/graph/write_master.py +46 -1
  33. package/lattice_brain/ingestion.py +4 -1
  34. package/lattice_brain/portability.py +5 -2
  35. package/lattice_brain/quality.py +12 -5
  36. package/lattice_brain/quiet.py +43 -0
  37. package/lattice_brain/runtime/agent_runtime.py +19 -10
  38. package/lattice_brain/runtime/hooks.py +3 -2
  39. package/lattice_brain/runtime/multi_agent.py +2 -3
  40. package/lattice_brain/sensitivity.py +94 -0
  41. package/lattice_brain/storage/base.py +30 -2
  42. package/lattice_brain/storage/migration.py +3 -2
  43. package/lattice_brain/storage/postgres.py +2 -2
  44. package/lattice_brain/storage/sqlite.py +6 -4
  45. package/lattice_brain/workflow.py +4 -2
  46. package/latticeai/__init__.py +1 -1
  47. package/latticeai/api/admin.py +1 -1
  48. package/latticeai/api/agents.py +4 -2
  49. package/latticeai/api/auth.py +5 -1
  50. package/latticeai/api/automation_intelligence.py +2 -1
  51. package/latticeai/api/browser.py +3 -2
  52. package/latticeai/api/chat.py +28 -17
  53. package/latticeai/api/chat_agent_http.py +22 -8
  54. package/latticeai/api/chat_contracts.py +4 -0
  55. package/latticeai/api/chat_documents.py +6 -2
  56. package/latticeai/api/chat_hybrid.py +82 -0
  57. package/latticeai/api/computer_use.py +8 -3
  58. package/latticeai/api/knowledge_graph.py +1 -1
  59. package/latticeai/api/mcp.py +4 -4
  60. package/latticeai/api/models.py +5 -2
  61. package/latticeai/api/network_boundary.py +220 -0
  62. package/latticeai/api/permissions.py +0 -1
  63. package/latticeai/api/realtime.py +1 -1
  64. package/latticeai/api/security_dashboard.py +1 -1
  65. package/latticeai/api/setup.py +16 -3
  66. package/latticeai/api/static_routes.py +2 -1
  67. package/latticeai/api/tools.py +12 -8
  68. package/latticeai/api/voice_capture.py +3 -1
  69. package/latticeai/api/workflow_designer.py +1 -1
  70. package/latticeai/api/workspace.py +1 -2
  71. package/latticeai/app_factory.py +174 -145
  72. package/latticeai/cli/entrypoint.py +6 -4
  73. package/latticeai/core/agent.py +55 -495
  74. package/latticeai/core/agent_eval.py +2 -2
  75. package/latticeai/core/agent_helpers.py +493 -0
  76. package/latticeai/core/agent_prompts.py +0 -1
  77. package/latticeai/core/agent_registry.py +3 -1
  78. package/latticeai/core/agent_state.py +41 -0
  79. package/latticeai/core/audit.py +1 -1
  80. package/latticeai/core/builtin_hooks.py +2 -1
  81. package/latticeai/core/config.py +0 -1
  82. package/latticeai/core/embedding_providers.py +12 -1
  83. package/latticeai/core/file_generation.py +3 -0
  84. package/latticeai/core/invitations.py +4 -1
  85. package/latticeai/core/io_utils.py +3 -1
  86. package/latticeai/core/legacy_compatibility.py +1 -2
  87. package/latticeai/core/local_embeddings.py +12 -1
  88. package/latticeai/core/marketplace.py +1 -2
  89. package/latticeai/core/mcp_registry.py +0 -1
  90. package/latticeai/core/model_compat.py +1 -1
  91. package/latticeai/core/model_resolution.py +1 -1
  92. package/latticeai/core/network_boundary.py +168 -0
  93. package/latticeai/core/oidc.py +3 -0
  94. package/latticeai/core/permission_mode.py +6 -6
  95. package/latticeai/core/plugins.py +3 -2
  96. package/latticeai/core/policy.py +0 -1
  97. package/latticeai/core/quiet.py +84 -0
  98. package/latticeai/core/realtime.py +3 -2
  99. package/latticeai/core/run_store.py +4 -2
  100. package/latticeai/core/security.py +4 -0
  101. package/latticeai/core/users.py +5 -3
  102. package/latticeai/core/workspace_graph_trace.py +3 -0
  103. package/latticeai/core/workspace_os.py +65 -273
  104. package/latticeai/core/workspace_os_constants.py +126 -0
  105. package/latticeai/core/workspace_os_state.py +180 -0
  106. package/latticeai/core/workspace_os_utils.py +3 -1
  107. package/latticeai/core/workspace_permissions.py +1 -0
  108. package/latticeai/core/workspace_snapshots.py +3 -1
  109. package/latticeai/core/workspace_timeline.py +3 -1
  110. package/latticeai/integrations/telegram_bot.py +25 -16
  111. package/latticeai/models/router.py +6 -3
  112. package/latticeai/runtime/access_runtime.py +3 -1
  113. package/latticeai/runtime/audit_runtime.py +3 -2
  114. package/latticeai/runtime/chat_wiring.py +4 -1
  115. package/latticeai/runtime/history_runtime.py +1 -1
  116. package/latticeai/runtime/history_writer.py +138 -0
  117. package/latticeai/runtime/lifespan_runtime.py +3 -1
  118. package/latticeai/runtime/network_boundary_wiring.py +124 -0
  119. package/latticeai/runtime/persistence_runtime.py +3 -1
  120. package/latticeai/runtime/router_registration.py +11 -1
  121. package/latticeai/services/architecture_readiness.py +1 -2
  122. package/latticeai/services/change_proposals.py +2 -1
  123. package/latticeai/services/cloud_egress_audit.py +85 -0
  124. package/latticeai/services/cloud_extraction.py +129 -0
  125. package/latticeai/services/cloud_streaming.py +266 -0
  126. package/latticeai/services/cloud_token_guard.py +84 -0
  127. package/latticeai/services/command_center.py +2 -1
  128. package/latticeai/services/folder_watch.py +3 -0
  129. package/latticeai/services/funnel_metrics.py +3 -1
  130. package/latticeai/services/hybrid_chat.py +265 -0
  131. package/latticeai/services/hybrid_context.py +228 -0
  132. package/latticeai/services/hybrid_policy.py +178 -0
  133. package/latticeai/services/memory_service.py +1 -1
  134. package/latticeai/services/model_catalog.py +10 -1
  135. package/latticeai/services/model_engines.py +35 -14
  136. package/latticeai/services/model_loading.py +3 -2
  137. package/latticeai/services/model_runtime.py +68 -17
  138. package/latticeai/services/multimodal_streaming.py +123 -0
  139. package/latticeai/services/network_boundary_service.py +154 -0
  140. package/latticeai/services/openai_compatible_adapter.py +100 -0
  141. package/latticeai/services/p_reinforce.py +4 -0
  142. package/latticeai/services/platform_runtime.py +9 -4
  143. package/latticeai/services/process_audit.py +0 -1
  144. package/latticeai/services/product_readiness.py +1 -1
  145. package/latticeai/services/run_executor.py +3 -2
  146. package/latticeai/services/search_service.py +1 -4
  147. package/latticeai/services/setup_detection.py +2 -1
  148. package/latticeai/services/tool_dispatch.py +7 -2
  149. package/latticeai/services/upload_service.py +2 -1
  150. package/latticeai/setup/auto_setup.py +10 -7
  151. package/latticeai/setup/wizard.py +15 -11
  152. package/latticeai/tools/__init__.py +3 -3
  153. package/latticeai/tools/commands.py +7 -7
  154. package/latticeai/tools/computer.py +3 -2
  155. package/latticeai/tools/documents.py +10 -9
  156. package/latticeai/tools/filesystem.py +7 -4
  157. package/latticeai/tools/knowledge.py +2 -0
  158. package/latticeai/tools/local_files.py +1 -1
  159. package/latticeai/tools/network.py +2 -1
  160. package/package.json +7 -3
  161. package/scripts/bench_agent_smoke.py +0 -1
  162. package/scripts/bench_models.py +0 -1
  163. package/scripts/brain_quality_eval.py +7 -2
  164. package/scripts/bump_version.py +2 -1
  165. package/scripts/check_current_release_docs.mjs +1 -1
  166. package/scripts/migrate_brain_storage.py +5 -1
  167. package/scripts/profile_kg.py +2 -7
  168. package/scripts/verify_hf_model_registry.py +2 -2
  169. package/src-tauri/Cargo.lock +1 -1
  170. package/src-tauri/Cargo.toml +1 -1
  171. package/src-tauri/tauri.conf.json +1 -1
  172. package/static/app/asset-manifest.json +37 -37
  173. package/static/app/assets/{Act-BtCREeN1.js → Act-DrKIGZeJ.js} +1 -1
  174. package/static/app/assets/{AdminConsole-TPeeN18T.js → AdminConsole-CEV1VefA.js} +1 -1
  175. package/static/app/assets/{Brain-BKs6JAp0.js → Brain-BZSXnwWU.js} +1 -1
  176. package/static/app/assets/{BrainHome-BPGOvSd6.js → BrainHome-CEBd86k6.js} +1 -1
  177. package/static/app/assets/{BrainSignals-CtzQZ15J.js → BrainSignals-O4s6R7av.js} +1 -1
  178. package/static/app/assets/{Capture-1_NaHWqB.js → Capture-AGbOxsg-.js} +1 -1
  179. package/static/app/assets/{CommandPalette-pqvQOXe4.js → CommandPalette-CeqBjCn2.js} +1 -1
  180. package/static/app/assets/Library-CXnbNiQW.js +1 -0
  181. package/static/app/assets/{LivingBrain-DlQ20Q75.js → LivingBrain-D9Iei2ZJ.js} +1 -1
  182. package/static/app/assets/{ProductFlow-BZvGDRi_.js → ProductFlow-JlXiDfMM.js} +1 -1
  183. package/static/app/assets/{ReviewCard-BWgI0D2s.js → ReviewCard-QQly2bTV.js} +1 -1
  184. package/static/app/assets/System-Bp9ZY4ER.js +1 -0
  185. package/static/app/assets/{activity-Dlfk8YC7.js → activity-CxRPOQ2F.js} +1 -1
  186. package/static/app/assets/{bot-CDvUB76P.js → bot-1bcsWB2s.js} +1 -1
  187. package/static/app/assets/{brain-xczrohrt.js → brain-CxaeKCRM.js} +1 -1
  188. package/static/app/assets/{button-SOdH3Oyf.js → button-ZYFqGan7.js} +1 -1
  189. package/static/app/assets/{circle-pause-CG1ythH4.js → circle-pause-B5NOIqvk.js} +1 -1
  190. package/static/app/assets/{circle-play-HXwvjS6W.js → circle-play-BiJVFXf7.js} +1 -1
  191. package/static/app/assets/{cpu-B0d-rGyk.js → cpu-Vvq0OKTr.js} +1 -1
  192. package/static/app/assets/{download-BGIkTQL6.js → download-SEcXzkx1.js} +1 -1
  193. package/static/app/assets/{folder-open-Dst_Z0_K.js → folder-open-Dw1ff_Qa.js} +1 -1
  194. package/static/app/assets/{hard-drive-D53MsWkV.js → hard-drive-B00fR7_r.js} +1 -1
  195. package/static/app/assets/index-CEkL4_M-.css +2 -0
  196. package/static/app/assets/{index-C_IrlQMV.js → index-Dm9VXl1o.js} +3 -3
  197. package/static/app/assets/{input-C5m0riF6.js → input-DtdWYQEa.js} +1 -1
  198. package/static/app/assets/{network-C5a-E5iS.js → network-CpjBu0kI.js} +1 -1
  199. package/static/app/assets/{primitives-vNXYf58F.js → primitives-CwsudBwc.js} +1 -1
  200. package/static/app/assets/search-CwEJWBEA.js +1 -0
  201. package/static/app/assets/{shield-alert-Cc-WVXqN.js → shield-alert-CpjBc-gQ.js} +1 -1
  202. package/static/app/assets/{textarea-BkZ0EqVO.js → textarea-DUPyjHQs.js} +1 -1
  203. package/static/app/assets/{useFocusTrap-CTtKbAOU.js → useFocusTrap-BWcMtCWH.js} +1 -1
  204. package/static/app/assets/{useQuery-Dx1fi4Wu.js → useQuery-Dg5fPqTS.js} +1 -1
  205. package/static/app/assets/{users-BFpQXtEF.js → users-BgcdTQGM.js} +1 -1
  206. package/static/app/assets/{utils-BA_lmW3J.js → utils-a3YXFtEO.js} +2 -2
  207. package/static/app/assets/workspace-BMUEiXUm.js +1 -0
  208. package/static/app/index.html +4 -4
  209. package/static/sw.js +1 -1
  210. package/static/app/assets/Library-DhvoPvC7.js +0 -1
  211. package/static/app/assets/System-CSMdYLMy.js +0 -1
  212. package/static/app/assets/index-FxDusbr0.css +0 -2
  213. package/static/app/assets/search-DhbSgW6m.js +0 -1
  214. package/static/app/assets/workspace-DBPB0jkX.js +0 -1
@@ -18,7 +18,9 @@ import threading
18
18
  from dataclasses import dataclass
19
19
  from typing import TYPE_CHECKING, Any, Dict, List, Optional
20
20
 
21
+ from latticeai.core.quiet import quiet
21
22
  from latticeai.runtime.access_runtime import build_access_runtime
23
+ from latticeai.runtime.audit_runtime import build_audit_runtime
22
24
  from latticeai.runtime.bootstrap import build_session_runtime
23
25
  from latticeai.runtime.brain_runtime import build_brain_runtime
24
26
  from latticeai.runtime.chat_wiring import (
@@ -28,38 +30,38 @@ from latticeai.runtime.chat_wiring import (
28
30
  )
29
31
  from latticeai.runtime.config_runtime import build_config_runtime
30
32
  from latticeai.runtime.context_runtime import build_context_runtime
33
+ from latticeai.runtime.history_runtime import build_history_query_runtime
34
+ from latticeai.runtime.history_writer import HistoryWriterDeps, write_chat_turn
31
35
  from latticeai.runtime.hooks_runtime import (
32
36
  bind_builtin_hook_runners,
33
37
  bind_trigger_hook_runner,
34
38
  build_hooks_runtime,
35
39
  )
36
- from latticeai.runtime.history_runtime import build_history_query_runtime
37
40
  from latticeai.runtime.lifespan_runtime import build_lifespan_runtime
38
- from latticeai.runtime.network_config_runtime import build_vpc_runtime
39
41
  from latticeai.runtime.model_wiring import (
40
42
  configure_model_runtime_from_context,
41
43
  register_model_runtime_routers,
42
44
  )
43
45
  from latticeai.runtime.namespace_runtime import RuntimeBundle, build_runtime_namespace
46
+ from latticeai.runtime.network_config_runtime import build_vpc_runtime
47
+ from latticeai.runtime.persistence_runtime import build_persistence_runtime
48
+ from latticeai.runtime.platform_runtime_wiring import build_platform_automation_runtime
44
49
  from latticeai.runtime.platform_services_runtime import (
45
50
  build_brain_network,
46
51
  )
47
- from latticeai.runtime.platform_runtime_wiring import build_platform_automation_runtime
48
- from latticeai.runtime.persistence_runtime import build_persistence_runtime
49
52
  from latticeai.runtime.review_wiring import build_review_run_now_runner
50
- from latticeai.runtime.sso_config_runtime import build_sso_config_runtime
51
- from latticeai.runtime.audit_runtime import build_audit_runtime
52
53
  from latticeai.runtime.router_registration import (
53
54
  build_auth_admin_security_router_bundle,
54
55
  build_router_bundle,
55
56
  build_static_routes_bundle,
56
- register_health_and_model_routers,
57
57
  register_foundation_routers,
58
+ register_health_and_model_routers,
58
59
  register_interaction_routers,
59
60
  register_platform_feature_routers,
60
61
  register_review_and_brain_tail_routers,
61
62
  )
62
63
  from latticeai.runtime.security_runtime import build_security_runtime
64
+ from latticeai.runtime.sso_config_runtime import build_sso_config_runtime
63
65
  from latticeai.runtime.user_key_runtime import build_user_key_runtime
64
66
  from latticeai.runtime.web_runtime import build_web_runtime
65
67
 
@@ -92,47 +94,120 @@ def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
92
94
  from fastapi import HTTPException, Request
93
95
  from pydantic import BaseModel
94
96
 
95
- from latticeai.models.router import LLMRouter, normalize_branding
96
97
  from lattice_brain.graph.runtime import set_llm_router
97
98
  from lattice_brain.graph.schema import set_embed_dim
98
- from latticeai.core.security import (
99
- hash_password,
100
- verify_password,
101
- host_is_loopback as _host_is_loopback_impl,
102
- client_ip as _client_ip_impl,
103
- bytes_match_extension as _bytes_match_extension_impl,
104
- redact_secret_text as _redact_secret_text,
105
- check_ip_rate_limit as _check_ip_rate_limit,
106
- enforce_rate_limit as _enforce_rate_limit,
99
+ from lattice_brain.ingestion import IngestionItem
100
+ from lattice_brain.storage import storage_from_env
101
+ from latticeai.api.admin import create_admin_router
102
+ from latticeai.api.agent_registry import create_agent_registry_router
103
+ from latticeai.api.agents import create_agents_router
104
+ from latticeai.api.auth import create_auth_router
105
+ from latticeai.api.automation_intelligence import (
106
+ create_automation_intelligence_router,
107
+ )
108
+ from latticeai.api.brain_intelligence import create_brain_intelligence_router
109
+ from latticeai.api.browser import create_browser_router
110
+ from latticeai.api.change_proposals import create_change_proposals_router
111
+ from latticeai.api.chat import build_recent_chat_context, create_chat_router
112
+ from latticeai.api.command_center import create_command_center_router
113
+ from latticeai.api.garden import create_garden_router
114
+ from latticeai.api.health import create_health_router
115
+ from latticeai.api.hooks import create_hooks_router
116
+ from latticeai.api.invitations import create_invitations_router
117
+ from latticeai.api.marketplace import create_marketplace_router
118
+ from latticeai.api.memory import create_memory_router
119
+ from latticeai.api.models import create_models_router
120
+ from latticeai.api.network import create_network_router
121
+
122
+ # ── v2 Agentic Workspace Platform layers ─────────────────────────────────────
123
+ from latticeai.api.plugins import create_plugins_router
124
+ from latticeai.api.portability import create_portability_router
125
+ from latticeai.api.realtime import create_realtime_router
126
+ from latticeai.api.search import create_search_router
127
+ from latticeai.api.security_dashboard import (
128
+ create_security_router as _create_security_router,
129
+ )
130
+ from latticeai.api.setup import create_setup_router
131
+ from latticeai.api.static_routes import create_static_routes_router
132
+ from latticeai.api.tools import create_tools_router
133
+ from latticeai.api.workflow_designer import create_workflow_designer_router
134
+ from latticeai.api.workspace import (
135
+ _workspace_scope_from_request,
136
+ create_workspace_router,
107
137
  )
108
138
  from latticeai.core.audit import (
109
- get_audit_log as _get_audit_log, # noqa: F401 - explicit legacy server_app export
110
- classify_sensitive_message as _classify_sensitive_message,
111
- build_sensitivity_report as _build_sensitivity_report,
112
139
  build_admin_audit_report as _build_admin_audit_report,
113
140
  )
114
- from latticeai.api.auth import create_auth_router
115
- from latticeai.api.admin import create_admin_router
116
- from latticeai.api.security_dashboard import create_security_router as _create_security_router
117
- from latticeai.core.model_compat import list_cached_profiles as _list_compat_profiles
118
- from latticeai.core.workspace_os import (
119
- WORKSPACE_OS_VERSION,
120
- remove_skill_directory,
141
+ from latticeai.core.audit import (
142
+ build_sensitivity_report as _build_sensitivity_report,
143
+ )
144
+ from latticeai.core.audit import (
145
+ classify_sensitive_message as _classify_sensitive_message,
146
+ )
147
+ from latticeai.core.audit import (
148
+ get_audit_log as _get_audit_log, # noqa: F401 - explicit legacy server_app export
149
+ )
150
+ from latticeai.core.embedding_providers import (
151
+ resolve_embedder,
152
+ resolve_embedding_profile,
121
153
  )
122
154
  from latticeai.core.enterprise import (
123
155
  capability_registry,
124
156
  )
157
+ from latticeai.core.mcp_registry import (
158
+ SKILLS_DIR,
159
+ _fetch_skills_marketplace,
160
+ create_mcp_install_state,
161
+ install_skill,
162
+ )
163
+ from latticeai.core.model_compat import (
164
+ list_cached_profiles as _list_compat_profiles,
165
+ )
125
166
  from latticeai.core.policy import policy_matrix
167
+ from latticeai.core.product_hardening import build_product_hardening_status
168
+ from latticeai.core.security import (
169
+ bytes_match_extension as _bytes_match_extension_impl,
170
+ )
171
+ from latticeai.core.security import (
172
+ check_ip_rate_limit as _check_ip_rate_limit,
173
+ )
174
+ from latticeai.core.security import (
175
+ client_ip as _client_ip_impl,
176
+ )
177
+ from latticeai.core.security import (
178
+ enforce_rate_limit as _enforce_rate_limit,
179
+ )
180
+ from latticeai.core.security import (
181
+ hash_password,
182
+ verify_password,
183
+ )
184
+ from latticeai.core.security import (
185
+ host_is_loopback as _host_is_loopback_impl,
186
+ )
187
+ from latticeai.core.security import (
188
+ redact_secret_text as _redact_secret_text,
189
+ )
190
+ from latticeai.core.tool_registry import (
191
+ TOOL_CATALOG_BRIEF as _TOOL_CATALOG_BRIEF, # noqa: F401
192
+ )
126
193
  from latticeai.core.users import (
127
194
  ensure_user_identity,
128
195
  load_users_file,
129
196
  migrate_knowledge_graph_identity,
130
197
  save_users_file,
198
+ )
199
+ from latticeai.core.users import (
131
200
  user_id_for_email as _user_id_for_email,
132
201
  )
133
- from latticeai.services.chat_service import ChatService
202
+ from latticeai.core.workspace_os import (
203
+ WORKSPACE_OS_VERSION,
204
+ remove_skill_directory,
205
+ )
206
+ from latticeai.models.router import LLMRouter, normalize_branding
134
207
  from latticeai.services.app_context import AppContext
135
- from latticeai.core.embedding_providers import resolve_embedder, resolve_embedding_profile
208
+ from latticeai.services.change_proposals import ChangeProposalService
209
+ from latticeai.services.chat_service import ChatService
210
+ from latticeai.services.command_center import CommandCenterService
136
211
  from latticeai.services.model_runtime import (
137
212
  CLOUD_VERIFY_TTL_SECONDS,
138
213
  ENGINE_MODEL_CATALOG,
@@ -140,75 +215,50 @@ def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
140
215
  MODEL_ENGINE_ALIASES,
141
216
  build_model_runtime,
142
217
  download_hf_model,
218
+ ensure_ollama_server,
143
219
  filter_lower_family_versions,
144
220
  local_binary,
145
221
  normalize_local_model_request,
146
222
  sse_event,
147
- ensure_ollama_server,
148
223
  )
149
- from latticeai.api.workspace import create_workspace_router, _workspace_scope_from_request
150
- from latticeai.api.health import create_health_router
151
- # ── v2 Agentic Workspace Platform layers ─────────────────────────────────────
152
- from latticeai.api.plugins import create_plugins_router
153
- from latticeai.api.workflow_designer import create_workflow_designer_router
154
- from latticeai.api.agents import create_agents_router
155
- from latticeai.api.realtime import create_realtime_router
156
- from latticeai.api.invitations import create_invitations_router
157
- from latticeai.api.marketplace import create_marketplace_router
158
- from latticeai.api.models import create_models_router
159
- from latticeai.api.chat import build_recent_chat_context, create_chat_router
160
- from latticeai.api.search import create_search_router
161
- from latticeai.api.tools import create_tools_router
162
- from latticeai.api.static_routes import create_static_routes_router
163
- from latticeai.api.garden import create_garden_router
164
- from latticeai.api.setup import create_setup_router
165
- from latticeai.api.hooks import create_hooks_router
166
- from latticeai.core.product_hardening import build_product_hardening_status
167
- from latticeai.api.agent_registry import create_agent_registry_router
168
- from latticeai.api.automation_intelligence import create_automation_intelligence_router
169
- from latticeai.api.brain_intelligence import create_brain_intelligence_router
170
- from latticeai.api.command_center import create_command_center_router
171
- from latticeai.services.command_center import CommandCenterService
172
- from latticeai.api.change_proposals import create_change_proposals_router
173
- from latticeai.services.change_proposals import ChangeProposalService
174
- from latticeai.tools import resolve_workspace_path
175
- from latticeai.api.memory import create_memory_router
176
- from latticeai.api.browser import create_browser_router
177
- from latticeai.api.portability import create_portability_router
178
- from lattice_brain.ingestion import IngestionItem
179
- from lattice_brain.storage import storage_from_env
180
- from latticeai.api.network import create_network_router
224
+ from latticeai.services.p_reinforce import PReinforceGardener
225
+
181
226
  # The aliased names below form the explicit, allowlisted compatibility
182
227
  # surface consumed by historical ``server_app`` callers.
183
228
  from latticeai.services.tool_dispatch import ( # noqa: F401
184
229
  LOCAL_WRITE_BLOCKED_PREFIXES as _LOCAL_WRITE_BLOCKED_PREFIXES,
230
+ )
231
+ from latticeai.services.tool_dispatch import (
185
232
  TOOL_GOVERNANCE,
233
+ build_agent_runtime,
234
+ configure_tool_dispatch,
235
+ get_tool_permission,
236
+ )
237
+ from latticeai.services.tool_dispatch import (
186
238
  TOOL_GOVERNANCE_DEFAULT as _TOOL_GOVERNANCE_DEFAULT,
239
+ )
240
+ from latticeai.services.tool_dispatch import (
187
241
  agent_risk as _agent_risk,
242
+ )
243
+ from latticeai.services.tool_dispatch import (
188
244
  check_tool_role as _check_tool_role,
189
- configure_tool_dispatch,
190
- get_tool_permission,
191
- list_tool_permissions,
192
- build_agent_runtime,
193
- tool_response as _tool_response,
194
245
  )
195
- from latticeai.core.tool_registry import TOOL_CATALOG_BRIEF as _TOOL_CATALOG_BRIEF # noqa: F401
196
- from latticeai.core.mcp_registry import (
197
- _fetch_skills_marketplace,
198
- install_skill,
199
- SKILLS_DIR,
200
- create_mcp_install_state,
246
+ from latticeai.services.tool_dispatch import (
247
+ tool_response as _tool_response,
201
248
  )
202
- from latticeai.services.p_reinforce import PReinforceGardener
203
249
  from latticeai.setup.wizard import get_recommendations, scan_environment
204
- from latticeai.tools import ensure_agent_root, execute_tool, knowledge_save
250
+ from latticeai.tools import (
251
+ ensure_agent_root,
252
+ execute_tool,
253
+ knowledge_save,
254
+ resolve_workspace_path,
255
+ )
205
256
 
206
257
  try:
207
258
  import keyring
208
259
  except Exception:
209
260
  keyring = None
210
261
 
211
- from datetime import datetime
212
262
 
213
263
  # ── App-level config — parsed once, in one place (latticeai.core.config) ──────
214
264
  # The module-level names below are kept as a compatibility surface for the rest
@@ -302,7 +352,7 @@ def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
302
352
  try:
303
353
  DATA_DIR.chmod(0o700)
304
354
  except OSError:
305
- pass
355
+ quiet()
306
356
  STATIC_DIR = CONFIG.static_dir
307
357
 
308
358
  USERS_FILE = DATA_DIR / "users.json"
@@ -359,6 +409,46 @@ def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
359
409
  # free). Legacy chat_history.json is imported once, idempotently, and the
360
410
  # file is left untouched on disk as the import source.
361
411
  CONVERSATIONS = _brain_runtime["CONVERSATIONS"]
412
+
413
+ def save_to_history(
414
+ role: str,
415
+ message: str,
416
+ user_email: Optional[str] = None,
417
+ user_nickname: Optional[str] = None,
418
+ source: Optional[str] = None,
419
+ conversation_id: Optional[str] = None,
420
+ workspace_id: Optional[str] = None,
421
+ ) -> None:
422
+ """Persist one chat turn. Logic lives in runtime/history_writer.py.
423
+
424
+ This stays a closure on purpose: `append_audit_event`,
425
+ `classify_sensitive_message` and `redact_secret_text` are bound further
426
+ down this composition root, and a closure resolves them at call time.
427
+ Hoisting the construction instead would reorder the whole function.
428
+ """
429
+ write_chat_turn(
430
+ role,
431
+ message,
432
+ user_email=user_email,
433
+ user_nickname=user_nickname,
434
+ source=source,
435
+ conversation_id=conversation_id,
436
+ workspace_id=workspace_id,
437
+ deps=HistoryWriterDeps(
438
+ conversations=CONVERSATIONS,
439
+ append_audit_event=append_audit_event,
440
+ classify_sensitive_message=classify_sensitive_message,
441
+ redact_secret_text=redact_secret_text,
442
+ normalize_branding=normalize_branding,
443
+ ingestion_pipeline=INGESTION_PIPELINE,
444
+ ingestion_item_factory=IngestionItem,
445
+ enable_graph=ENABLE_GRAPH,
446
+ knowledge_graph=KNOWLEDGE_GRAPH,
447
+ ),
448
+ )
449
+
450
+
451
+
362
452
  # Hooks registry is constructed here (ahead of the watcher) so folder-watch
363
453
  # reindexes can fire the pre_index/post_index lifecycle hooks. The registry
364
454
  # + watcher pair is assembled behind the hooks_runtime seam.
@@ -484,72 +574,7 @@ def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
484
574
 
485
575
  # audit build moved after redact_secret_text is defined (see below)
486
576
 
487
- def save_to_history(
488
- role: str,
489
- message: str,
490
- user_email: Optional[str] = None,
491
- user_nickname: Optional[str] = None,
492
- source: Optional[str] = None,
493
- conversation_id: Optional[str] = None,
494
- workspace_id: Optional[str] = None,
495
- ):
496
- try:
497
- message = redact_secret_text(message)
498
- if role == "assistant":
499
- message = normalize_branding(message)
500
- item = {"role": role, "content": message, "timestamp": datetime.now().isoformat()}
501
- if user_email:
502
- item["user_email"] = user_email
503
- if user_nickname:
504
- item["user_nickname"] = user_nickname
505
- if source:
506
- item["source"] = source
507
- if conversation_id:
508
- item["conversation_id"] = conversation_id
509
- if workspace_id:
510
- item["workspace_id"] = workspace_id
511
- sensitive = classify_sensitive_message(item, -1)
512
- append_audit_event(
513
- "chat_message",
514
- role=role,
515
- user_email=user_email,
516
- user_nickname=user_nickname,
517
- source=source,
518
- conversation_id=conversation_id,
519
- workspace_id=workspace_id,
520
- content_preview=sensitive.get("preview"),
521
- content_chars=len(message or ""),
522
- sensitivity=sensitive.get("sensitivity"),
523
- sensitive_labels=sensitive.get("labels") or [],
524
- )
525
- # v4: conversations are durable episodic memory — unbounded SQLite
526
- # store (the 50-message chat_history.json cap is dead).
527
- CONVERSATIONS.append(item)
528
- try:
529
- if ENABLE_GRAPH and KNOWLEDGE_GRAPH:
530
- # v4: chat messages enter the brain through the unified
531
- # ingestion pipeline (provenance + hook lifecycle), not by
532
- # bypassing it with a direct store call.
533
- INGESTION_PIPELINE.ingest(
534
- IngestionItem(
535
- source_type="chat_message",
536
- text=message,
537
- owner=user_email,
538
- workspace_id=workspace_id,
539
- conversation_id=conversation_id,
540
- metadata={
541
- "role": role,
542
- "user_nickname": user_nickname,
543
- "source": source,
544
- "raw": item,
545
- },
546
- ),
547
- user_email=user_email,
548
- )
549
- except Exception as graph_error:
550
- logging.warning("knowledge graph message ingest failed: %s", graph_error)
551
- except Exception as e:
552
- logging.warning("save_to_history failed: %s", e)
577
+
553
578
 
554
579
  def redact_secret_text(text: str) -> str:
555
580
  return _redact_secret_text(text)
@@ -642,6 +667,7 @@ def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
642
667
  def build_sensitivity_report(history: List[Dict]) -> Dict:
643
668
  return _build_sensitivity_report(history)
644
669
 
670
+
645
671
  # ── Admin audit report — delegated to latticeai.core.audit ───────────────────
646
672
  def build_admin_audit_report(users: Dict, audit_events: Optional[List[Dict]] = None) -> Dict:
647
673
  graph_stats = None
@@ -649,7 +675,7 @@ def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
649
675
  if ENABLE_GRAPH and KNOWLEDGE_GRAPH:
650
676
  graph_stats = KNOWLEDGE_GRAPH.stats()
651
677
  except Exception:
652
- pass
678
+ quiet()
653
679
  return _build_admin_audit_report(
654
680
  AUDIT_FILE, users,
655
681
  get_user_role=get_user_role,
@@ -1135,7 +1161,10 @@ def _build(config: "Optional[Config]" = None) -> Dict[str, Any]:
1135
1161
  # ── Chat / Completion ──────────────────────────────────────────────────────────
1136
1162
 
1137
1163
  def _embedding_info() -> dict:
1138
- from latticeai.core.embedding_providers import PROVIDER_TYPES, embedding_provider_profiles
1164
+ from latticeai.core.embedding_providers import (
1165
+ PROVIDER_TYPES,
1166
+ embedding_provider_profiles,
1167
+ )
1139
1168
  info = EMBEDDER.as_dict()
1140
1169
  info["available_providers"] = list(PROVIDER_TYPES)
1141
1170
  info["profile"] = CONFIG.embedding_profile or ""
@@ -21,6 +21,8 @@ from latticeai.cli.runtime import (
21
21
  _has_module,
22
22
  _load_env_file,
23
23
  )
24
+ from latticeai.core.quiet import quiet
25
+
24
26
 
25
27
  def _local_ips() -> list[str]:
26
28
  ips: list[str] = []
@@ -32,7 +34,7 @@ def _local_ips() -> list[str]:
32
34
  if addr not in ips:
33
35
  ips.append(addr)
34
36
  except Exception:
35
- pass
37
+ quiet()
36
38
  if not ips:
37
39
  try:
38
40
  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@@ -40,7 +42,7 @@ def _local_ips() -> list[str]:
40
42
  ips.append(s.getsockname()[0])
41
43
  s.close()
42
44
  except Exception:
43
- pass
45
+ quiet()
44
46
  return ips
45
47
 
46
48
 
@@ -145,7 +147,7 @@ def _send_telegram(token: str, chat_id: str, text: str) -> None:
145
147
  )
146
148
  urllib.request.urlopen(req, timeout=10)
147
149
  except Exception:
148
- pass
150
+ quiet()
149
151
 
150
152
 
151
153
  def _start_tunnel(port: int) -> str | None:
@@ -178,7 +180,7 @@ def _start_tunnel(port: int) -> str | None:
178
180
  url = m.group(0)
179
181
  break
180
182
  except Exception:
181
- pass
183
+ quiet()
182
184
 
183
185
  if not url:
184
186
  return None