ltcai 11.5.2 → 11.7.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.
- package/README.md +93 -148
- package/bin/ltcai.js +234 -24
- package/docs/CHANGELOG.md +119 -0
- package/docs/COMMUNITY_AND_PLUGINS.md +1 -1
- package/docs/DEVELOPMENT.md +8 -6
- package/docs/ENTERPRISE.md +2 -1
- package/docs/MULTI_AGENT_RUNTIME.md +12 -5
- package/docs/ONBOARDING.md +1 -1
- package/docs/OPERATIONS.md +6 -3
- package/docs/REALTIME_COLLABORATION.md +1 -1
- package/docs/TRUST_MODEL.md +1 -1
- package/docs/WHY_LATTICE.md +1 -1
- package/docs/WORKFLOW_DESIGNER.md +3 -2
- package/docs/kg-schema.md +1 -1
- package/docs/v11.6.0_ONE_DOOR_PLAN.md +170 -0
- package/lattice_brain/__init__.py +42 -79
- package/lattice_brain/graph/__init__.py +9 -24
- package/lattice_brain/graph/_kg_common/__init__.py +13 -24
- package/lattice_brain/ingestion/__init__.py +19 -58
- package/lattice_brain/ingestion/pipeline.py +20 -398
- package/lattice_brain/multimodal/__init__.py +7 -18
- package/lattice_brain/multimodal/images.py +6 -264
- package/lattice_brain/multimodal/video.py +8 -247
- package/lattice_brain/runtime/__init__.py +8 -79
- package/lattice_brain/runtime/hooks.py +22 -584
- package/latticeai/__init__.py +1 -1
- package/latticeai/api/agent_worker_seam.py +7 -80
- package/latticeai/api/health.py +6 -20
- package/latticeai/api/local_files.py +16 -613
- package/latticeai/api/models.py +12 -87
- package/latticeai/api/search.py +17 -255
- package/latticeai/api/tools.py +69 -750
- package/latticeai/api/voice_capture.py +8 -70
- package/latticeai/api/worker_compute.py +842 -0
- package/latticeai/api/worker_seams.py +216 -0
- package/latticeai/app_factory.py +23 -232
- package/latticeai/cli/entrypoint.py +36 -249
- package/latticeai/core/agent_permission.py +16 -91
- package/latticeai/core/messages.py +89 -531
- package/latticeai/runtime/access_runtime.py +0 -14
- package/latticeai/runtime/bootstrap.py +10 -21
- package/latticeai/runtime/brain_runtime.py +35 -43
- package/latticeai/runtime/build_phases/__init__.py +21 -37
- package/latticeai/runtime/build_phases/features.py +99 -389
- package/latticeai/runtime/build_phases/foundation.py +82 -392
- package/latticeai/runtime/build_phases/web.py +91 -408
- package/latticeai/runtime/build_phases/worker_profile.py +244 -0
- package/latticeai/runtime/lifespan_runtime.py +7 -16
- package/latticeai/runtime/platform_services_runtime.py +1 -15
- package/latticeai/runtime/runtime_context.py +13 -130
- package/latticeai/runtime/security_runtime.py +10 -103
- package/latticeai/services/architecture_readiness.py +82 -43
- package/latticeai/services/model_runtime/__init__.py +2 -11
- package/latticeai/services/model_runtime/service.py +4 -28
- package/latticeai/services/p_reinforce.py +10 -261
- package/latticeai/services/product_readiness.py +31 -38
- package/latticeai/services/search_service.py +37 -795
- package/latticeai/services/tool_dispatch.py +30 -386
- package/latticeai/services/voice_capture.py +13 -107
- package/latticeai/tools/__init__.py +22 -49
- package/latticeai/tools/commands.py +0 -163
- package/latticeai/tools/computer.py +0 -39
- package/latticeai/tools/documents.py +1 -134
- package/latticeai/tools/filesystem.py +1 -247
- package/latticeai/tools/knowledge.py +1 -52
- package/latticeai/tools/local_files.py +0 -20
- package/latticeai/worker_app.py +75 -0
- package/package.json +2 -3
- package/requirements.txt +0 -5
- package/scripts/agent_eval.py +16 -28
- package/scripts/brain_quality_eval.py +20 -183
- package/scripts/bump_version.py +5 -5
- package/scripts/check_current_release_docs.mjs +7 -4
- package/scripts/check_openapi_drift.mjs +10 -0
- package/scripts/check_server_i18n.mjs +2 -18
- package/scripts/compose_openapi.py +377 -0
- package/scripts/export_openapi.py +32 -4
- package/scripts/gen_messages_catalog_fixture.py +302 -0
- package/scripts/gen_openapi_fragments.py +365 -0
- package/scripts/gen_redact_fixture.py +196 -0
- package/scripts/gen_worker_allowlist_fixture.py +115 -0
- package/scripts/generate_agent_parity_fixtures.py +33 -14
- package/scripts/openapi_route_families.json +2161 -0
- package/scripts/release_screen_claims.json +54 -0
- package/scripts/run_integration_tests.mjs +134 -29
- package/scripts/run_sidecar_e2e.mjs +104 -11
- package/scripts/wheel_smoke.py +32 -22
- package/src-tauri/Cargo.lock +375 -9
- package/src-tauri/Cargo.toml +1 -1
- package/src-tauri/src/backend.rs +151 -45
- package/src-tauri/src/main.rs +18 -18
- package/src-tauri/src/topology.rs +58 -88
- package/src-tauri/tauri.conf.json +1 -2
- package/static/app/asset-manifest.json +41 -41
- package/static/app/assets/{Act-DcQizkl1.js → Act-BPcVAbOL.js} +1 -1
- package/static/app/assets/AdminConsole-Bw1ATQL0.js +1 -0
- package/static/app/assets/{Brain-3VCSHFcn.js → Brain-CT92Kos0.js} +2 -2
- package/static/app/assets/{BrainHome-Qm8eaztx.js → BrainHome-CFBkt1K_.js} +1 -1
- package/static/app/assets/{BrainSignals-DS9BtKOW.js → BrainSignals-ReLWF2H8.js} +1 -1
- package/static/app/assets/Capture-BsTokYkk.js +1 -0
- package/static/app/assets/{Chronicle-BGvuAchH.js → Chronicle-B6f0T9id.js} +1 -1
- package/static/app/assets/{CommandPalette-Bqhm0Urn.js → CommandPalette-CuvjTv1u.js} +1 -1
- package/static/app/assets/{Library-BV6NnF0a.js → Library-BGJbG9Hd.js} +1 -1
- package/static/app/assets/{LivingBrain-GzenJchP.js → LivingBrain-DGYK_Jsa.js} +1 -1
- package/static/app/assets/{ProductFlow-DEP6-vML.js → ProductFlow-DXBC6brE.js} +1 -1
- package/static/app/assets/{ReviewCard-CNZ7XjWG.js → ReviewCard-HXRle3qq.js} +2 -2
- package/static/app/assets/System-CMHSO9qM.js +1 -0
- package/static/app/assets/arrow-left-BfmkskWx.js +1 -0
- package/static/app/assets/{bot-B_K1Tdmw.js → bot-Cn8bWRuq.js} +1 -1
- package/static/app/assets/{brain-DWyaV1L1.js → brain-CQJberbE.js} +1 -1
- package/static/app/assets/{button-aTn4s84A.js → button-Ct9f2_oT.js} +1 -1
- package/static/app/assets/circle-check-DruOxB-4.js +1 -0
- package/static/app/assets/{circle-pause-xKgeGXkT.js → circle-pause-CmzC_apg.js} +1 -1
- package/static/app/assets/{circle-play-DkT6tYPX.js → circle-play-D8mW2aQ7.js} +1 -1
- package/static/app/assets/{cpu-85xYObUC.js → cpu-DZcdd0PZ.js} +1 -1
- package/static/app/assets/{download-B5Fm7YXo.js → download-bv1KEPGQ.js} +1 -1
- package/static/app/assets/{folder-open-kk2Xa52u.js → folder-open-d-Pip5gr.js} +1 -1
- package/static/app/assets/{hard-drive-DkA3zBW_.js → hard-drive-D20iavUb.js} +1 -1
- package/static/app/assets/index-D9x-kSNy.css +2 -0
- package/static/app/assets/{index-BMPdTmlY.js → index-Do83hDzJ.js} +3 -3
- package/static/app/assets/{input-B0nRf2jO.js → input-BLXVNmj1.js} +1 -1
- package/static/app/assets/{link-2-Dwb4gnTc.js → link-2-BPJOFlAy.js} +1 -1
- package/static/app/assets/{permissionCopy-CQDUBrOZ.js → permissionCopy-ChdJd493.js} +1 -1
- package/static/app/assets/primitives-Cv5tbZBY.js +1 -0
- package/static/app/assets/search-CT9aho2j.js +1 -0
- package/static/app/assets/{share-2-BsrxFglO.js → share-2-YNX_NtMU.js} +1 -1
- package/static/app/assets/{shield-alert-5BStfp2_.js → shield-alert-DuQ3zrVL.js} +1 -1
- package/static/app/assets/{textarea-Cg8IUA-k.js → textarea-DqwLnli4.js} +1 -1
- package/static/app/assets/{useFocusTrap-CYKvE46M.js → useFocusTrap-ZVI98jaW.js} +1 -1
- package/static/app/assets/{useMutation-CSn9t1op.js → useMutation-CVC4qv_D.js} +1 -1
- package/static/app/assets/{useQuery-CY2OI2uy.js → useQuery-C7BeG4HU.js} +1 -1
- package/static/app/assets/{utils-Ddol2RWD.js → utils-CiFtIdZq.js} +1 -1
- package/static/app/assets/{workspace-BqDwOz_p.js → workspace-DQz9vIId.js} +1 -1
- package/static/app/index.html +4 -4
- package/static/sw.js +1 -1
- package/lattice_brain/archive.py +0 -522
- package/lattice_brain/context.py +0 -325
- package/lattice_brain/conversations.py +0 -382
- package/lattice_brain/core.py +0 -82
- package/lattice_brain/graph/_kg_contract.py +0 -249
- package/lattice_brain/graph/curator.py +0 -676
- package/lattice_brain/graph/discovery.py +0 -595
- package/lattice_brain/graph/discovery_index/__init__.py +0 -35
- package/lattice_brain/graph/discovery_index/cleanup.py +0 -182
- package/lattice_brain/graph/discovery_index/extract.py +0 -137
- package/lattice_brain/graph/discovery_index/scan.py +0 -411
- package/lattice_brain/graph/discovery_index/upsert.py +0 -495
- package/lattice_brain/graph/documents.py +0 -380
- package/lattice_brain/graph/fusion.py +0 -395
- package/lattice_brain/graph/identity.py +0 -175
- package/lattice_brain/graph/image_vectors.py +0 -230
- package/lattice_brain/graph/ingest.py +0 -829
- package/lattice_brain/graph/network.py +0 -205
- package/lattice_brain/graph/proactive.py +0 -724
- package/lattice_brain/graph/projection/__init__.py +0 -42
- package/lattice_brain/graph/projection/curation.py +0 -500
- package/lattice_brain/graph/projection/v2_schema.py +0 -518
- package/lattice_brain/graph/provenance.py +0 -524
- package/lattice_brain/graph/rerank.py +0 -163
- package/lattice_brain/graph/retrieval/__init__.py +0 -54
- package/lattice_brain/graph/retrieval/context.py +0 -197
- package/lattice_brain/graph/retrieval/graph_view.py +0 -319
- package/lattice_brain/graph/retrieval/hybrid.py +0 -488
- package/lattice_brain/graph/retrieval/maintenance.py +0 -121
- package/lattice_brain/graph/retrieval/signals.py +0 -95
- package/lattice_brain/graph/retrieval_docgen.py +0 -253
- package/lattice_brain/graph/retrieval_policy.py +0 -180
- package/lattice_brain/graph/retrieval_reads.py +0 -769
- package/lattice_brain/graph/retrieval_vector/__init__.py +0 -42
- package/lattice_brain/graph/retrieval_vector/fingerprint.py +0 -97
- package/lattice_brain/graph/retrieval_vector/indexing.py +0 -347
- package/lattice_brain/graph/retrieval_vector/search.py +0 -560
- package/lattice_brain/graph/retrieval_vector/status.py +0 -374
- package/lattice_brain/graph/schema.py +0 -792
- package/lattice_brain/graph/store.py +0 -268
- package/lattice_brain/graph/vector_index/__init__.py +0 -85
- package/lattice_brain/graph/vector_index/base.py +0 -167
- package/lattice_brain/graph/vector_index/brute_force.py +0 -110
- package/lattice_brain/graph/vector_index/hnsw.py +0 -290
- package/lattice_brain/graph/vector_index/jobs.py +0 -287
- package/lattice_brain/graph/vector_index/quantized.py +0 -148
- package/lattice_brain/graph/vector_index/selector.py +0 -161
- package/lattice_brain/graph/write_master.py +0 -308
- package/lattice_brain/ingestion/_contract.py +0 -90
- package/lattice_brain/ingestion/folder_scan.py +0 -57
- package/lattice_brain/ingestion/folders.py +0 -258
- package/lattice_brain/ingestion/jobs_api.py +0 -107
- package/lattice_brain/ingestion/routing.py +0 -295
- package/lattice_brain/ingestion_jobs.py +0 -380
- package/lattice_brain/memory.py +0 -75
- package/lattice_brain/portability/__init__.py +0 -90
- package/lattice_brain/portability/_contract.py +0 -42
- package/lattice_brain/portability/backups.py +0 -338
- package/lattice_brain/portability/bundles.py +0 -136
- package/lattice_brain/portability/constants.py +0 -93
- package/lattice_brain/portability/fsops.py +0 -138
- package/lattice_brain/portability/service.py +0 -41
- package/lattice_brain/portability/sharing.py +0 -710
- package/lattice_brain/quality.py +0 -543
- package/lattice_brain/retrieval_benchmark_fixtures.py +0 -92
- package/lattice_brain/runtime/agent_runtime.py +0 -859
- package/lattice_brain/runtime/contracts.py +0 -460
- package/lattice_brain/runtime/multi_agent.py +0 -942
- package/lattice_brain/runtime/statuses.py +0 -10
- package/lattice_brain/sealed_box.py +0 -240
- package/lattice_brain/self_model.py +0 -675
- package/lattice_brain/sensitivity.py +0 -94
- package/lattice_brain/storage/__init__.py +0 -22
- package/lattice_brain/storage/base.py +0 -100
- package/lattice_brain/storage/docker.py +0 -105
- package/lattice_brain/storage/factory.py +0 -31
- package/lattice_brain/storage/migration.py +0 -191
- package/lattice_brain/storage/postgres.py +0 -123
- package/lattice_brain/storage/sqlite.py +0 -143
- package/lattice_brain/synthesis.py +0 -824
- package/lattice_brain/workflow.py +0 -497
- package/latticeai/api/admin.py +0 -471
- package/latticeai/api/agent_registry.py +0 -105
- package/latticeai/api/agents.py +0 -228
- package/latticeai/api/auth.py +0 -383
- package/latticeai/api/automation_intelligence.py +0 -401
- package/latticeai/api/brain_intelligence.py +0 -199
- package/latticeai/api/browser.py +0 -493
- package/latticeai/api/change_proposals.py +0 -89
- package/latticeai/api/chat.py +0 -572
- package/latticeai/api/chat_agent_http.py +0 -892
- package/latticeai/api/chat_contracts.py +0 -73
- package/latticeai/api/chat_documents.py +0 -276
- package/latticeai/api/chat_helpers.py +0 -460
- package/latticeai/api/chat_history.py +0 -101
- package/latticeai/api/chat_hybrid.py +0 -113
- package/latticeai/api/chat_intents.py +0 -646
- package/latticeai/api/chat_stream.py +0 -216
- package/latticeai/api/chronicle.py +0 -63
- package/latticeai/api/command_center.py +0 -51
- package/latticeai/api/computer_use.py +0 -474
- package/latticeai/api/evidence_actions.py +0 -48
- package/latticeai/api/features.py +0 -70
- package/latticeai/api/funnel_metrics.py +0 -31
- package/latticeai/api/garden.py +0 -34
- package/latticeai/api/hooks.py +0 -165
- package/latticeai/api/index_jobs.py +0 -145
- package/latticeai/api/invitations.py +0 -100
- package/latticeai/api/knowledge_graph.py +0 -536
- package/latticeai/api/marketplace.py +0 -105
- package/latticeai/api/mcp.py +0 -482
- package/latticeai/api/memory.py +0 -270
- package/latticeai/api/network.py +0 -81
- package/latticeai/api/network_boundary.py +0 -225
- package/latticeai/api/permission_mode.py +0 -61
- package/latticeai/api/permissions.py +0 -436
- package/latticeai/api/plugins.py +0 -126
- package/latticeai/api/portability.py +0 -391
- package/latticeai/api/project_sessions.py +0 -114
- package/latticeai/api/realtime.py +0 -118
- package/latticeai/api/review_queue.py +0 -364
- package/latticeai/api/security_dashboard.py +0 -604
- package/latticeai/api/setup.py +0 -319
- package/latticeai/api/static_routes.py +0 -354
- package/latticeai/api/ui_redirects.py +0 -26
- package/latticeai/api/workflow_designer.py +0 -394
- package/latticeai/api/workspace.py +0 -856
- package/latticeai/api/workspace_scope.py +0 -125
- package/latticeai/core/agent/__init__.py +0 -93
- package/latticeai/core/agent/_contract.py +0 -79
- package/latticeai/core/agent/context.py +0 -57
- package/latticeai/core/agent/deps.py +0 -125
- package/latticeai/core/agent/execution.py +0 -622
- package/latticeai/core/agent/planning.py +0 -145
- package/latticeai/core/agent/recovery.py +0 -157
- package/latticeai/core/agent/runtime.py +0 -210
- package/latticeai/core/agent/verification.py +0 -231
- package/latticeai/core/agent_eval.py +0 -739
- package/latticeai/core/agent_helpers.py +0 -493
- package/latticeai/core/agent_profiles.py +0 -110
- package/latticeai/core/agent_prompts.py +0 -171
- package/latticeai/core/agent_registry.py +0 -232
- package/latticeai/core/agent_state.py +0 -41
- package/latticeai/core/agent_trace.py +0 -104
- package/latticeai/core/artifact_ledger.py +0 -109
- package/latticeai/core/audit.py +0 -260
- package/latticeai/core/builtin_hooks.py +0 -105
- package/latticeai/core/context_builder.py +0 -394
- package/latticeai/core/document_generator.py +0 -103
- package/latticeai/core/enterprise.py +0 -154
- package/latticeai/core/enterprise_admin.py +0 -158
- package/latticeai/core/file_generation/__init__.py +0 -115
- package/latticeai/core/file_generation/bundles.py +0 -76
- package/latticeai/core/file_generation/extraction.py +0 -154
- package/latticeai/core/file_generation/inference.py +0 -235
- package/latticeai/core/file_generation/orchestration.py +0 -152
- package/latticeai/core/file_generation/prompting.py +0 -117
- package/latticeai/core/file_generation/repair.py +0 -114
- package/latticeai/core/file_generation/sanitize.py +0 -61
- package/latticeai/core/file_generation/validation.py +0 -201
- package/latticeai/core/invitations.py +0 -132
- package/latticeai/core/legacy_compatibility.py +0 -243
- package/latticeai/core/logging_safety.py +0 -46
- package/latticeai/core/marketplace.py +0 -293
- package/latticeai/core/mcp_catalog.py +0 -452
- package/latticeai/core/mcp_registry.py +0 -506
- package/latticeai/core/network_boundary.py +0 -168
- package/latticeai/core/oidc.py +0 -208
- package/latticeai/core/plugins.py +0 -432
- package/latticeai/core/product_hardening.py +0 -218
- package/latticeai/core/project_sessions.py +0 -337
- package/latticeai/core/realtime.py +0 -238
- package/latticeai/core/run_explain.py +0 -426
- package/latticeai/core/run_store.py +0 -252
- package/latticeai/core/timezones.py +0 -80
- package/latticeai/core/workspace_computer_memory.py +0 -84
- package/latticeai/core/workspace_graph_trace.py +0 -155
- package/latticeai/core/workspace_indexing.py +0 -102
- package/latticeai/core/workspace_memory.py +0 -77
- package/latticeai/core/workspace_onboarding.py +0 -104
- package/latticeai/core/workspace_os.py +0 -978
- package/latticeai/core/workspace_os_constants.py +0 -126
- package/latticeai/core/workspace_os_state.py +0 -180
- package/latticeai/core/workspace_os_utils.py +0 -103
- package/latticeai/core/workspace_permissions.py +0 -101
- package/latticeai/core/workspace_plugins.py +0 -97
- package/latticeai/core/workspace_relationships.py +0 -99
- package/latticeai/core/workspace_reorganization.py +0 -335
- package/latticeai/core/workspace_review_items.py +0 -112
- package/latticeai/core/workspace_runs.py +0 -726
- package/latticeai/core/workspace_skills.py +0 -109
- package/latticeai/core/workspace_snapshots.py +0 -198
- package/latticeai/core/workspace_timeline.py +0 -110
- package/latticeai/integrations/__init__.py +0 -0
- package/latticeai/integrations/telegram_bot/__init__.py +0 -123
- package/latticeai/integrations/telegram_bot/__main__.py +0 -17
- package/latticeai/integrations/telegram_bot/config.py +0 -86
- package/latticeai/integrations/telegram_bot/dispatch.py +0 -311
- package/latticeai/integrations/telegram_bot/flows.py +0 -478
- package/latticeai/integrations/telegram_bot/helpers.py +0 -322
- package/latticeai/integrations/telegram_bot/screens.py +0 -394
- package/latticeai/runtime/audit_runtime.py +0 -76
- package/latticeai/runtime/automation_runtime.py +0 -81
- package/latticeai/runtime/chat_wiring.py +0 -141
- package/latticeai/runtime/context_runtime.py +0 -66
- package/latticeai/runtime/feature_toggle_wiring.py +0 -157
- package/latticeai/runtime/history_runtime.py +0 -163
- package/latticeai/runtime/history_writer.py +0 -138
- package/latticeai/runtime/hooks_runtime.py +0 -77
- package/latticeai/runtime/model_wiring.py +0 -68
- package/latticeai/runtime/namespace_runtime.py +0 -163
- package/latticeai/runtime/network_boundary_wiring.py +0 -117
- package/latticeai/runtime/network_config_runtime.py +0 -56
- package/latticeai/runtime/permission_mode_wiring.py +0 -112
- package/latticeai/runtime/persistence_runtime.py +0 -159
- package/latticeai/runtime/platform_runtime_wiring.py +0 -89
- package/latticeai/runtime/review_wiring.py +0 -42
- package/latticeai/runtime/router_registration.py +0 -693
- package/latticeai/runtime/service_singletons.py +0 -55
- package/latticeai/runtime/sso_config_runtime.py +0 -128
- package/latticeai/runtime/user_key_runtime.py +0 -106
- package/latticeai/runtime/web_runtime.py +0 -92
- package/latticeai/server_app.py +0 -51
- package/latticeai/services/app_context.py +0 -130
- package/latticeai/services/automation_execution.py +0 -266
- package/latticeai/services/automation_intelligence.py +0 -614
- package/latticeai/services/brain_automation.py +0 -191
- package/latticeai/services/brain_intelligence/__init__.py +0 -58
- package/latticeai/services/brain_intelligence/_contract.py +0 -71
- package/latticeai/services/brain_intelligence/consistency.py +0 -193
- package/latticeai/services/brain_intelligence/constants.py +0 -47
- package/latticeai/services/brain_intelligence/digest.py +0 -258
- package/latticeai/services/brain_intelligence/health.py +0 -331
- package/latticeai/services/brain_intelligence/proposals.py +0 -259
- package/latticeai/services/brain_intelligence/sampling.py +0 -84
- package/latticeai/services/brain_intelligence/service.py +0 -48
- package/latticeai/services/change_proposals.py +0 -471
- package/latticeai/services/chat_service.py +0 -243
- package/latticeai/services/chronicle.py +0 -555
- package/latticeai/services/cloud_egress_audit.py +0 -85
- package/latticeai/services/cloud_extraction.py +0 -129
- package/latticeai/services/cloud_streaming.py +0 -268
- package/latticeai/services/cloud_token_guard.py +0 -84
- package/latticeai/services/command_center.py +0 -548
- package/latticeai/services/evidence_actions.py +0 -258
- package/latticeai/services/feature_toggles.py +0 -502
- package/latticeai/services/folder_watch.py +0 -520
- package/latticeai/services/funnel_metrics.py +0 -307
- package/latticeai/services/hybrid_chat.py +0 -316
- package/latticeai/services/hybrid_context.py +0 -228
- package/latticeai/services/hybrid_policy.py +0 -129
- package/latticeai/services/interop_bridges.py +0 -978
- package/latticeai/services/local_knowledge.py +0 -465
- package/latticeai/services/memory_service/__init__.py +0 -52
- package/latticeai/services/memory_service/_contract.py +0 -100
- package/latticeai/services/memory_service/brief.py +0 -431
- package/latticeai/services/memory_service/constants.py +0 -57
- package/latticeai/services/memory_service/maintenance.py +0 -138
- package/latticeai/services/memory_service/manager.py +0 -186
- package/latticeai/services/memory_service/proof.py +0 -136
- package/latticeai/services/memory_service/recall.py +0 -225
- package/latticeai/services/memory_service/service.py +0 -48
- package/latticeai/services/memory_service/stores.py +0 -110
- package/latticeai/services/mode_store.py +0 -132
- package/latticeai/services/model_recommendation.py +0 -224
- package/latticeai/services/model_runtime/cloud.py +0 -87
- package/latticeai/services/network_boundary_service.py +0 -117
- package/latticeai/services/obsidian_bridge.py +0 -609
- package/latticeai/services/openai_compatible_adapter.py +0 -101
- package/latticeai/services/permission_mode_service.py +0 -122
- package/latticeai/services/platform_runtime.py +0 -366
- package/latticeai/services/review_queue.py +0 -380
- package/latticeai/services/router_context.py +0 -59
- package/latticeai/services/run_executor.py +0 -387
- package/latticeai/services/self_model_service.py +0 -171
- package/latticeai/services/setup_detection.py +0 -147
- package/latticeai/services/triggers.py +0 -378
- package/latticeai/services/upload_service.py +0 -172
- package/latticeai/services/workspace_service.py +0 -165
- package/latticeai/setup/__init__.py +0 -25
- package/latticeai/setup/auto_setup.py +0 -846
- package/latticeai/setup/demo_corpus.py +0 -98
- package/latticeai/setup/wizard/__init__.py +0 -126
- package/latticeai/setup/wizard/catalog.py +0 -175
- package/latticeai/setup/wizard/detect.py +0 -302
- package/latticeai/setup/wizard/install.py +0 -348
- package/latticeai/setup/wizard/paths.py +0 -165
- package/latticeai/setup/wizard/plans.py +0 -74
- package/latticeai/setup/wizard/recommend.py +0 -320
- package/scripts/bench_agent_smoke.py +0 -409
- package/scripts/bench_models.py +0 -540
- package/scripts/bench_vector_index.py +0 -295
- package/scripts/funnel_soft_gate.py +0 -192
- package/scripts/generate_agent_loop_fixtures.py +0 -994
- package/scripts/generate_rust_parity_fixtures.py +0 -908
- package/scripts/migrate_brain_storage.py +0 -57
- package/scripts/parity_fixture_corpus_context.py +0 -162
- package/scripts/parity_fixture_corpus_docgen.py +0 -341
- package/scripts/profile_kg.py +0 -355
- package/server.py +0 -30
- package/static/app/assets/AdminConsole-cf4npybT.js +0 -1
- package/static/app/assets/Capture-DiQ219jW.js +0 -1
- package/static/app/assets/System-CieofHQa.js +0 -1
- package/static/app/assets/arrow-left-kfsrk0mv.js +0 -1
- package/static/app/assets/circle-check-qqLug9nU.js +0 -1
- package/static/app/assets/index-DxmOfNRi.css +0 -2
- package/static/app/assets/primitives-SNp0LRJz.js +0 -1
- package/static/app/assets/search-BcHqkjoy.js +0 -1
|
@@ -1,595 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
4
|
-
|
|
5
|
-
from ..quiet import quiet
|
|
6
|
-
|
|
7
|
-
# ruff: noqa: F403,F405
|
|
8
|
-
from ._kg_common import * # noqa: F403,F401
|
|
9
|
-
|
|
10
|
-
# The cross-mixin surface (`_connect`, `_upsert_node`, …) is declared in
|
|
11
|
-
# `_kg_contract.KnowledgeGraphCore`. It is a typing-only base: at runtime this
|
|
12
|
-
# is `object`, so the MRO of `KnowledgeGraphStore` is unchanged.
|
|
13
|
-
if TYPE_CHECKING:
|
|
14
|
-
from ._kg_contract import KnowledgeGraphCore as _Core
|
|
15
|
-
else:
|
|
16
|
-
_Core = object
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class KnowledgeGraphDiscoveryMixin(_Core):
|
|
21
|
-
def discover_local_roots(self) -> Dict[str, Any]:
|
|
22
|
-
"""Return safe, cross-platform starting points for structure browsing."""
|
|
23
|
-
os_type = _current_os_type()
|
|
24
|
-
home = Path.home().expanduser()
|
|
25
|
-
roots: List[Dict[str, Any]] = []
|
|
26
|
-
seen: set = set()
|
|
27
|
-
|
|
28
|
-
def add(
|
|
29
|
-
label: str,
|
|
30
|
-
path: Path,
|
|
31
|
-
kind: str,
|
|
32
|
-
*,
|
|
33
|
-
recommended: bool = True,
|
|
34
|
-
warning: Optional[str] = None,
|
|
35
|
-
) -> None:
|
|
36
|
-
try:
|
|
37
|
-
resolved = path.expanduser().resolve()
|
|
38
|
-
except OSError:
|
|
39
|
-
resolved = path.expanduser()
|
|
40
|
-
key = str(resolved)
|
|
41
|
-
if key in seen or not resolved.exists():
|
|
42
|
-
return
|
|
43
|
-
seen.add(key)
|
|
44
|
-
roots.append(
|
|
45
|
-
{
|
|
46
|
-
"id": f"{kind}:{_path_fingerprint(resolved)}",
|
|
47
|
-
"label": label,
|
|
48
|
-
"path": key,
|
|
49
|
-
"kind": kind,
|
|
50
|
-
"recommended": recommended,
|
|
51
|
-
"warning": warning or _root_warning(resolved, os_type),
|
|
52
|
-
}
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
add("홈", home, "home", warning=_root_warning(home, os_type))
|
|
56
|
-
for name, label in (
|
|
57
|
-
("Documents", "문서"),
|
|
58
|
-
("Desktop", "데스크탑"),
|
|
59
|
-
("Downloads", "다운로드"),
|
|
60
|
-
("Pictures", "사진"),
|
|
61
|
-
("Projects", "프로젝트"),
|
|
62
|
-
):
|
|
63
|
-
add(label, home / name, name.lower())
|
|
64
|
-
|
|
65
|
-
if os_type == "macos":
|
|
66
|
-
volumes = Path("/Volumes")
|
|
67
|
-
if volumes.exists():
|
|
68
|
-
try:
|
|
69
|
-
for volume in sorted(
|
|
70
|
-
volumes.iterdir(), key=lambda p: p.name.lower()
|
|
71
|
-
):
|
|
72
|
-
add(volume.name, volume, "volume", recommended=False)
|
|
73
|
-
except OSError:
|
|
74
|
-
quiet()
|
|
75
|
-
elif os_type == "windows":
|
|
76
|
-
for letter in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
|
|
77
|
-
drive = Path(f"{letter}:\\")
|
|
78
|
-
if drive.exists():
|
|
79
|
-
add(
|
|
80
|
-
f"{letter}: 드라이브",
|
|
81
|
-
drive,
|
|
82
|
-
"drive",
|
|
83
|
-
recommended=(letter != "C"),
|
|
84
|
-
)
|
|
85
|
-
for env_name, label in (
|
|
86
|
-
("OneDrive", "OneDrive"),
|
|
87
|
-
("OneDriveCommercial", "OneDrive"),
|
|
88
|
-
):
|
|
89
|
-
raw = os.environ.get(env_name)
|
|
90
|
-
if raw:
|
|
91
|
-
add(label, Path(raw), "cloud", recommended=False)
|
|
92
|
-
elif os_type == "linux":
|
|
93
|
-
for base in (Path("/mnt"), Path("/media")):
|
|
94
|
-
add(str(base), base, "mounts", recommended=False)
|
|
95
|
-
try:
|
|
96
|
-
if base.exists():
|
|
97
|
-
for mounted in sorted(
|
|
98
|
-
base.iterdir(), key=lambda p: p.name.lower()
|
|
99
|
-
):
|
|
100
|
-
add(mounted.name, mounted, "volume", recommended=False)
|
|
101
|
-
except OSError:
|
|
102
|
-
quiet()
|
|
103
|
-
|
|
104
|
-
return {
|
|
105
|
-
"os_type": os_type,
|
|
106
|
-
"computer": platform.node() or "local",
|
|
107
|
-
"roots": roots,
|
|
108
|
-
"privacy_notice": "처음에는 드라이브와 폴더 구조만 확인하며, 파일 내용은 사용자가 동의한 뒤에만 읽습니다.",
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
def preview_local_tree(self, path: Path, *, max_items: int = 200) -> Dict[str, Any]:
|
|
112
|
-
"""List one folder level using metadata only; file contents are not read."""
|
|
113
|
-
root = Path(path).expanduser().resolve()
|
|
114
|
-
if not root.exists():
|
|
115
|
-
raise ValueError(f"경로가 존재하지 않습니다: {path}")
|
|
116
|
-
if not root.is_dir():
|
|
117
|
-
raise ValueError(f"폴더가 아닙니다: {path}")
|
|
118
|
-
|
|
119
|
-
os_type = _current_os_type()
|
|
120
|
-
max_items = max(1, min(int(max_items or 200), 1000))
|
|
121
|
-
items: List[Dict[str, Any]] = []
|
|
122
|
-
inaccessible = 0
|
|
123
|
-
try:
|
|
124
|
-
children = sorted(
|
|
125
|
-
root.iterdir(), key=lambda p: (not p.is_dir(), p.name.lower())
|
|
126
|
-
)
|
|
127
|
-
except PermissionError as exc:
|
|
128
|
-
return {
|
|
129
|
-
"path": str(root),
|
|
130
|
-
"items": [],
|
|
131
|
-
"error": f"접근 권한 없음: {exc}",
|
|
132
|
-
"privacy_notice": "현재 단계에서는 파일 내용을 읽지 않고, 폴더와 파일의 이름/크기/수정일만 확인합니다.",
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
for child in children[:max_items]:
|
|
136
|
-
try:
|
|
137
|
-
is_dir = child.is_dir()
|
|
138
|
-
stat = child.stat()
|
|
139
|
-
reason = (
|
|
140
|
-
_excluded_directory_reason(child, root=root, os_type=os_type)
|
|
141
|
-
if is_dir
|
|
142
|
-
else _sensitive_file_reason(child, root=root)
|
|
143
|
-
)
|
|
144
|
-
items.append(
|
|
145
|
-
{
|
|
146
|
-
"name": child.name,
|
|
147
|
-
"path": str(child),
|
|
148
|
-
"type": "directory" if is_dir else "file",
|
|
149
|
-
"extension": "" if is_dir else child.suffix.lower(),
|
|
150
|
-
"size_bytes": None if is_dir else stat.st_size,
|
|
151
|
-
"modified_at": _safe_iso_from_stat_mtime(stat.st_mtime),
|
|
152
|
-
"hidden": _is_hidden_path(child, root),
|
|
153
|
-
"accessible": True,
|
|
154
|
-
"excluded_reason": reason,
|
|
155
|
-
}
|
|
156
|
-
)
|
|
157
|
-
except PermissionError:
|
|
158
|
-
inaccessible += 1
|
|
159
|
-
items.append(
|
|
160
|
-
{
|
|
161
|
-
"name": child.name,
|
|
162
|
-
"path": str(child),
|
|
163
|
-
"type": "unknown",
|
|
164
|
-
"accessible": False,
|
|
165
|
-
"excluded_reason": "permission_denied",
|
|
166
|
-
}
|
|
167
|
-
)
|
|
168
|
-
except OSError as exc:
|
|
169
|
-
inaccessible += 1
|
|
170
|
-
items.append(
|
|
171
|
-
{
|
|
172
|
-
"name": child.name,
|
|
173
|
-
"path": str(child),
|
|
174
|
-
"type": "unknown",
|
|
175
|
-
"accessible": False,
|
|
176
|
-
"excluded_reason": str(exc),
|
|
177
|
-
}
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
return {
|
|
181
|
-
"path": str(root),
|
|
182
|
-
"os_type": os_type,
|
|
183
|
-
"items": items,
|
|
184
|
-
"truncated": len(children) > max_items,
|
|
185
|
-
"inaccessible": inaccessible,
|
|
186
|
-
"warning": _root_warning(root, os_type),
|
|
187
|
-
"privacy_notice": "현재 단계에서는 파일 내용을 읽지 않고, 폴더와 파일의 이름/크기/수정일만 확인합니다.",
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
def _iter_local_scan_entries(
|
|
191
|
-
self, root: Path, *, max_files: int
|
|
192
|
-
) -> Iterable[Dict[str, Any]]:
|
|
193
|
-
os_type = _current_os_type()
|
|
194
|
-
stack = [root]
|
|
195
|
-
files_seen = 0
|
|
196
|
-
while stack:
|
|
197
|
-
current = stack.pop()
|
|
198
|
-
try:
|
|
199
|
-
children = sorted(
|
|
200
|
-
current.iterdir(), key=lambda p: (not p.is_dir(), p.name.lower())
|
|
201
|
-
)
|
|
202
|
-
except PermissionError as exc:
|
|
203
|
-
yield {
|
|
204
|
-
"kind": "inaccessible_dir",
|
|
205
|
-
"path": current,
|
|
206
|
-
"reason": f"permission_denied: {exc}",
|
|
207
|
-
}
|
|
208
|
-
continue
|
|
209
|
-
except OSError as exc:
|
|
210
|
-
yield {"kind": "inaccessible_dir", "path": current, "reason": str(exc)}
|
|
211
|
-
continue
|
|
212
|
-
|
|
213
|
-
for child in children:
|
|
214
|
-
if child.is_symlink():
|
|
215
|
-
yield {"kind": "excluded", "path": child, "reason": "symlink"}
|
|
216
|
-
continue
|
|
217
|
-
try:
|
|
218
|
-
if child.is_dir():
|
|
219
|
-
reason = _excluded_directory_reason(
|
|
220
|
-
child, root=root, os_type=os_type
|
|
221
|
-
)
|
|
222
|
-
if reason:
|
|
223
|
-
yield {
|
|
224
|
-
"kind": "excluded_dir",
|
|
225
|
-
"path": child,
|
|
226
|
-
"reason": reason,
|
|
227
|
-
}
|
|
228
|
-
else:
|
|
229
|
-
stack.append(child)
|
|
230
|
-
continue
|
|
231
|
-
if not child.is_file():
|
|
232
|
-
yield {
|
|
233
|
-
"kind": "excluded",
|
|
234
|
-
"path": child,
|
|
235
|
-
"reason": "not_regular_file",
|
|
236
|
-
}
|
|
237
|
-
continue
|
|
238
|
-
stat = child.stat()
|
|
239
|
-
except PermissionError as exc:
|
|
240
|
-
yield {
|
|
241
|
-
"kind": "inaccessible_file",
|
|
242
|
-
"path": child,
|
|
243
|
-
"reason": f"permission_denied: {exc}",
|
|
244
|
-
}
|
|
245
|
-
continue
|
|
246
|
-
except OSError as exc:
|
|
247
|
-
yield {
|
|
248
|
-
"kind": "inaccessible_file",
|
|
249
|
-
"path": child,
|
|
250
|
-
"reason": str(exc),
|
|
251
|
-
}
|
|
252
|
-
continue
|
|
253
|
-
|
|
254
|
-
files_seen += 1
|
|
255
|
-
if files_seen > max_files:
|
|
256
|
-
yield {
|
|
257
|
-
"kind": "limit_reached",
|
|
258
|
-
"path": child,
|
|
259
|
-
"reason": "max_files",
|
|
260
|
-
}
|
|
261
|
-
return
|
|
262
|
-
yield {"kind": "file", "path": child, "stat": stat}
|
|
263
|
-
|
|
264
|
-
def _local_file_decision(
|
|
265
|
-
self, path: Path, root: Path, stat: os.stat_result
|
|
266
|
-
) -> Dict[str, Any]:
|
|
267
|
-
ext = path.suffix.lower()
|
|
268
|
-
category = _file_category(ext)
|
|
269
|
-
parser_type = _parser_type_for_category(category, ext)
|
|
270
|
-
sensitive_reason = _sensitive_file_reason(path, root=root)
|
|
271
|
-
if sensitive_reason:
|
|
272
|
-
return {
|
|
273
|
-
"status": "sensitive_blocked",
|
|
274
|
-
"reason": sensitive_reason,
|
|
275
|
-
"category": category,
|
|
276
|
-
"parser_type": parser_type,
|
|
277
|
-
"indexable": False,
|
|
278
|
-
}
|
|
279
|
-
if category == "unsupported":
|
|
280
|
-
return {
|
|
281
|
-
"status": "unsupported",
|
|
282
|
-
"reason": "unsupported_extension",
|
|
283
|
-
"category": category,
|
|
284
|
-
"parser_type": parser_type,
|
|
285
|
-
"indexable": False,
|
|
286
|
-
}
|
|
287
|
-
limit = _size_limit_for_category(category)
|
|
288
|
-
if stat.st_size > limit:
|
|
289
|
-
return {
|
|
290
|
-
"status": "too_large",
|
|
291
|
-
"reason": f"size>{limit}",
|
|
292
|
-
"category": category,
|
|
293
|
-
"parser_type": parser_type,
|
|
294
|
-
"indexable": False,
|
|
295
|
-
}
|
|
296
|
-
return {
|
|
297
|
-
"status": "pending",
|
|
298
|
-
"reason": "",
|
|
299
|
-
"category": category,
|
|
300
|
-
"parser_type": parser_type,
|
|
301
|
-
"indexable": True,
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
def audit_local_folder(
|
|
305
|
-
self, path: Path, *, include_ocr: bool = False, max_files: int = 50_000
|
|
306
|
-
) -> Dict[str, Any]:
|
|
307
|
-
"""Safety-check a folder using metadata only; file bodies are not read."""
|
|
308
|
-
root = Path(path).expanduser().resolve()
|
|
309
|
-
if not root.exists():
|
|
310
|
-
raise ValueError(f"경로가 존재하지 않습니다: {path}")
|
|
311
|
-
if not root.is_dir():
|
|
312
|
-
raise ValueError(f"폴더가 아닙니다: {path}")
|
|
313
|
-
|
|
314
|
-
os_type = _current_os_type()
|
|
315
|
-
max_files = max(1, min(int(max_files or 50_000), 200_000))
|
|
316
|
-
status_counts: Counter = Counter()
|
|
317
|
-
category_counts: Counter = Counter()
|
|
318
|
-
extension_counts: Counter = Counter()
|
|
319
|
-
allowed_samples: List[Dict[str, Any]] = []
|
|
320
|
-
excluded_samples: List[Dict[str, Any]] = []
|
|
321
|
-
total_files = 0
|
|
322
|
-
readable_files = 0
|
|
323
|
-
inaccessible = 0
|
|
324
|
-
excluded_dirs = 0
|
|
325
|
-
limit_reached = False
|
|
326
|
-
|
|
327
|
-
for entry in self._iter_local_scan_entries(root, max_files=max_files):
|
|
328
|
-
kind = entry["kind"]
|
|
329
|
-
path_obj = entry["path"]
|
|
330
|
-
if kind == "limit_reached":
|
|
331
|
-
limit_reached = True
|
|
332
|
-
break
|
|
333
|
-
if kind == "excluded_dir":
|
|
334
|
-
excluded_dirs += 1
|
|
335
|
-
if len(excluded_samples) < 25:
|
|
336
|
-
excluded_samples.append(
|
|
337
|
-
_sample_file(
|
|
338
|
-
path_obj, root, "excluded", entry.get("reason", "")
|
|
339
|
-
)
|
|
340
|
-
)
|
|
341
|
-
continue
|
|
342
|
-
if kind in {"inaccessible_dir", "inaccessible_file"}:
|
|
343
|
-
inaccessible += 1
|
|
344
|
-
status_counts["failed"] += 1
|
|
345
|
-
if len(excluded_samples) < 25:
|
|
346
|
-
excluded_samples.append(
|
|
347
|
-
_sample_file(path_obj, root, "failed", entry.get("reason", ""))
|
|
348
|
-
)
|
|
349
|
-
continue
|
|
350
|
-
if kind == "excluded":
|
|
351
|
-
status_counts["excluded"] += 1
|
|
352
|
-
if len(excluded_samples) < 25:
|
|
353
|
-
excluded_samples.append(
|
|
354
|
-
_sample_file(
|
|
355
|
-
path_obj, root, "excluded", entry.get("reason", "")
|
|
356
|
-
)
|
|
357
|
-
)
|
|
358
|
-
continue
|
|
359
|
-
if kind != "file":
|
|
360
|
-
continue
|
|
361
|
-
|
|
362
|
-
total_files += 1
|
|
363
|
-
stat = entry["stat"]
|
|
364
|
-
decision = self._local_file_decision(path_obj, root, stat)
|
|
365
|
-
status = decision["status"]
|
|
366
|
-
category = decision["category"]
|
|
367
|
-
ext = path_obj.suffix.lower() or "(none)"
|
|
368
|
-
category_counts[category] += 1
|
|
369
|
-
extension_counts[ext] += 1
|
|
370
|
-
if decision["indexable"]:
|
|
371
|
-
readable_files += 1
|
|
372
|
-
status_counts["readable"] += 1
|
|
373
|
-
if len(allowed_samples) < 25:
|
|
374
|
-
allowed_samples.append(_sample_file(path_obj, root, "readable"))
|
|
375
|
-
else:
|
|
376
|
-
status_counts[status] += 1
|
|
377
|
-
if len(excluded_samples) < 25:
|
|
378
|
-
excluded_samples.append(
|
|
379
|
-
_sample_file(path_obj, root, status, decision["reason"])
|
|
380
|
-
)
|
|
381
|
-
|
|
382
|
-
doc_weight = (
|
|
383
|
-
category_counts["pdf"] * 1.4
|
|
384
|
-
+ category_counts["document"] * 0.9
|
|
385
|
-
+ category_counts["slide_deck"] * 1.0
|
|
386
|
-
)
|
|
387
|
-
sheet_weight = category_counts["spreadsheet"] * 0.6
|
|
388
|
-
ocr_weight = category_counts["image"] * (1.8 if include_ocr else 0.1)
|
|
389
|
-
estimated_seconds = round(
|
|
390
|
-
readable_files * 0.04 + doc_weight + sheet_weight + ocr_weight, 1
|
|
391
|
-
)
|
|
392
|
-
|
|
393
|
-
return {
|
|
394
|
-
"path": str(root),
|
|
395
|
-
"source_id": f"source:{_path_fingerprint(root)}",
|
|
396
|
-
"os_type": os_type,
|
|
397
|
-
"drive_id": _drive_id_for_path(root),
|
|
398
|
-
"warning": _root_warning(root, os_type),
|
|
399
|
-
"privacy_notice": "현재 단계에서는 파일 내용을 읽지 않고, 폴더와 파일의 이름/크기/수정일만 확인합니다.",
|
|
400
|
-
"include_ocr_requested": bool(include_ocr),
|
|
401
|
-
"summary": {
|
|
402
|
-
"total_files": total_files,
|
|
403
|
-
"readable_files": readable_files,
|
|
404
|
-
"excluded_files": int(
|
|
405
|
-
status_counts["excluded"]
|
|
406
|
-
+ status_counts["sensitive_blocked"]
|
|
407
|
-
+ status_counts["too_large"]
|
|
408
|
-
+ status_counts["unsupported"]
|
|
409
|
-
),
|
|
410
|
-
"sensitive_files": int(status_counts["sensitive_blocked"]),
|
|
411
|
-
"too_large_files": int(status_counts["too_large"]),
|
|
412
|
-
"unsupported_files": int(status_counts["unsupported"]),
|
|
413
|
-
"image_ocr_candidates": int(category_counts["image"]),
|
|
414
|
-
"inaccessible_items": inaccessible,
|
|
415
|
-
"excluded_dirs": excluded_dirs,
|
|
416
|
-
"estimated_seconds": estimated_seconds,
|
|
417
|
-
"storage_root": str(self.db_path.parent),
|
|
418
|
-
"limit_reached": limit_reached,
|
|
419
|
-
},
|
|
420
|
-
"by_status": dict(status_counts),
|
|
421
|
-
"by_category": dict(category_counts),
|
|
422
|
-
"by_extension": dict(extension_counts.most_common(40)),
|
|
423
|
-
"allowed_samples": allowed_samples,
|
|
424
|
-
"excluded_samples": excluded_samples,
|
|
425
|
-
"consent_required": {
|
|
426
|
-
"knowledge_source": True,
|
|
427
|
-
"image_ocr": bool(category_counts["image"]),
|
|
428
|
-
"watch": True,
|
|
429
|
-
"sensitive_files_default_excluded": True,
|
|
430
|
-
},
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
def local_sources(self) -> Dict[str, Any]:
|
|
434
|
-
with self._connect() as conn:
|
|
435
|
-
sources = [
|
|
436
|
-
{
|
|
437
|
-
"id": row["id"],
|
|
438
|
-
"root_path": row["root_path"],
|
|
439
|
-
"os_type": row["os_type"],
|
|
440
|
-
"drive_id": row["drive_id"],
|
|
441
|
-
"label": row["label"],
|
|
442
|
-
"status": row["status"],
|
|
443
|
-
"include_ocr": bool(row["include_ocr"]),
|
|
444
|
-
"watch_enabled": bool(row["watch_enabled"]),
|
|
445
|
-
"consent": _safe_loads(row["consent_json"]),
|
|
446
|
-
"created_at": row["created_at"],
|
|
447
|
-
"updated_at": row["updated_at"],
|
|
448
|
-
"last_scanned_at": row["last_scanned_at"],
|
|
449
|
-
}
|
|
450
|
-
for row in conn.execute(
|
|
451
|
-
"""
|
|
452
|
-
SELECT id, root_path, os_type, drive_id, label, status, include_ocr,
|
|
453
|
-
watch_enabled, consent_json, created_at, updated_at, last_scanned_at
|
|
454
|
-
FROM knowledge_sources
|
|
455
|
-
ORDER BY updated_at DESC, id ASC
|
|
456
|
-
"""
|
|
457
|
-
)
|
|
458
|
-
]
|
|
459
|
-
status_rows = conn.execute(
|
|
460
|
-
"SELECT source_id, status, COUNT(*) AS count FROM local_file_index GROUP BY source_id, status"
|
|
461
|
-
).fetchall()
|
|
462
|
-
counts: Dict[str, Dict[str, int]] = {}
|
|
463
|
-
for row in status_rows:
|
|
464
|
-
counts.setdefault(row["source_id"], {})[row["status"]] = row["count"]
|
|
465
|
-
for source in sources:
|
|
466
|
-
source["file_status"] = counts.get(source["id"], {})
|
|
467
|
-
return {"sources": sources}
|
|
468
|
-
|
|
469
|
-
def local_source_health(self, *, error_samples: int = 3) -> Dict[str, Any]:
|
|
470
|
-
"""Per-folder memory state (v9.9.7).
|
|
471
|
-
|
|
472
|
-
``local_sources`` answers "which folders are connected"; a user asking
|
|
473
|
-
"is this folder actually in my Brain?" needs three more facts per
|
|
474
|
-
folder, and this is the single read that provides them:
|
|
475
|
-
|
|
476
|
-
* **coverage** — indexed / known files, so a half-indexed folder is
|
|
477
|
-
visible instead of looking connected;
|
|
478
|
-
* **failed / skipped counts** — what did not make it in;
|
|
479
|
-
* **recent error samples** — *why*, with the stored message.
|
|
480
|
-
|
|
481
|
-
Vector freshness is deliberately **not** claimed per folder: the vector
|
|
482
|
-
index is global, so a per-folder number would be invented. Callers pair
|
|
483
|
-
this with ``vector_freshness()`` and label it as global.
|
|
484
|
-
"""
|
|
485
|
-
try:
|
|
486
|
-
samples = max(0, min(int(error_samples), 20))
|
|
487
|
-
except (TypeError, ValueError):
|
|
488
|
-
samples = 3
|
|
489
|
-
payload = self.local_sources()
|
|
490
|
-
sources = payload.get("sources") or []
|
|
491
|
-
by_id = {str(source.get("id")): source for source in sources}
|
|
492
|
-
errors: Dict[str, List[Dict[str, Any]]] = {}
|
|
493
|
-
if by_id:
|
|
494
|
-
with self._connect() as conn:
|
|
495
|
-
for source_id in by_id:
|
|
496
|
-
rows = conn.execute(
|
|
497
|
-
"""
|
|
498
|
-
SELECT relative_path, status, error_message, last_scanned_at
|
|
499
|
-
FROM local_file_index
|
|
500
|
-
WHERE source_id=? AND error_message IS NOT NULL AND error_message<>''
|
|
501
|
-
ORDER BY last_scanned_at DESC
|
|
502
|
-
LIMIT ?
|
|
503
|
-
""",
|
|
504
|
-
(source_id, samples or 1),
|
|
505
|
-
).fetchall()
|
|
506
|
-
if samples:
|
|
507
|
-
errors[source_id] = [
|
|
508
|
-
{
|
|
509
|
-
"path": row["relative_path"],
|
|
510
|
-
"status": row["status"],
|
|
511
|
-
"detail": str(row["error_message"] or "")[:300],
|
|
512
|
-
"at": row["last_scanned_at"],
|
|
513
|
-
}
|
|
514
|
-
for row in rows
|
|
515
|
-
]
|
|
516
|
-
|
|
517
|
-
folders: List[Dict[str, Any]] = []
|
|
518
|
-
for source in sources:
|
|
519
|
-
counts = source.get("file_status") or {}
|
|
520
|
-
total = sum(int(value or 0) for value in counts.values())
|
|
521
|
-
indexed = int(counts.get("indexed") or 0)
|
|
522
|
-
failed = int(counts.get("failed") or 0) + int(counts.get("error") or 0)
|
|
523
|
-
skipped = int(counts.get("skipped") or 0)
|
|
524
|
-
folders.append({
|
|
525
|
-
"id": source.get("id"),
|
|
526
|
-
"label": source.get("label") or source.get("root_path"),
|
|
527
|
-
"root_path": source.get("root_path"),
|
|
528
|
-
"status": source.get("status"),
|
|
529
|
-
"watch_enabled": bool(source.get("watch_enabled")),
|
|
530
|
-
"last_scanned_at": source.get("last_scanned_at"),
|
|
531
|
-
"files": {
|
|
532
|
-
"total": total,
|
|
533
|
-
"indexed": indexed,
|
|
534
|
-
"failed": failed,
|
|
535
|
-
"skipped": skipped,
|
|
536
|
-
"pending": max(0, total - indexed - failed - skipped),
|
|
537
|
-
},
|
|
538
|
-
# None (not 0) when nothing is known yet — an empty folder must
|
|
539
|
-
# not read as "0% indexed".
|
|
540
|
-
"coverage": round(indexed / total, 4) if total else None,
|
|
541
|
-
"recent_errors": errors.get(str(source.get("id")), []),
|
|
542
|
-
})
|
|
543
|
-
return {"folders": folders, "count": len(folders)}
|
|
544
|
-
|
|
545
|
-
def set_local_source_watch(self, source_id: str, enabled: bool) -> Dict[str, Any]:
|
|
546
|
-
source_id = str(source_id or "").strip()
|
|
547
|
-
if not source_id:
|
|
548
|
-
raise ValueError("source_id required")
|
|
549
|
-
with self._connect() as conn:
|
|
550
|
-
row = conn.execute(
|
|
551
|
-
"SELECT id FROM knowledge_sources WHERE id=?",
|
|
552
|
-
(source_id,),
|
|
553
|
-
).fetchone()
|
|
554
|
-
if not row:
|
|
555
|
-
raise ValueError(f"knowledge source not found: {source_id}")
|
|
556
|
-
conn.execute(
|
|
557
|
-
"UPDATE knowledge_sources SET watch_enabled=?, updated_at=? WHERE id=?",
|
|
558
|
-
(1 if enabled else 0, _now(), source_id),
|
|
559
|
-
)
|
|
560
|
-
return {"source_id": source_id, "watch_enabled": bool(enabled)}
|
|
561
|
-
|
|
562
|
-
def remove_local_source(self, source_id: str) -> Dict[str, Any]:
|
|
563
|
-
"""Remove one approved local source and its derived graph projection.
|
|
564
|
-
|
|
565
|
-
This is intentionally non-destructive for user files: only the LatticeAI
|
|
566
|
-
index rows, graph nodes, edges, and chunks derived from the source are
|
|
567
|
-
removed. The original folder and files are never touched.
|
|
568
|
-
"""
|
|
569
|
-
source_id = str(source_id or "").strip()
|
|
570
|
-
if not source_id:
|
|
571
|
-
raise ValueError("source_id required")
|
|
572
|
-
with self._connect() as conn:
|
|
573
|
-
source = conn.execute(
|
|
574
|
-
"SELECT id, root_path FROM knowledge_sources WHERE id=?",
|
|
575
|
-
(source_id,),
|
|
576
|
-
).fetchone()
|
|
577
|
-
if not source:
|
|
578
|
-
raise ValueError(f"knowledge source not found: {source_id}")
|
|
579
|
-
rows = conn.execute(
|
|
580
|
-
"SELECT graph_node_id FROM local_file_index WHERE source_id=? AND graph_node_id IS NOT NULL",
|
|
581
|
-
(source_id,),
|
|
582
|
-
).fetchall()
|
|
583
|
-
graph_node_ids = [
|
|
584
|
-
row["graph_node_id"] for row in rows if row["graph_node_id"]
|
|
585
|
-
]
|
|
586
|
-
for graph_node_id in graph_node_ids:
|
|
587
|
-
self._delete_local_file_graph(conn, graph_node_id)
|
|
588
|
-
conn.execute("DELETE FROM local_file_index WHERE source_id=?", (source_id,))
|
|
589
|
-
conn.execute("DELETE FROM knowledge_sources WHERE id=?", (source_id,))
|
|
590
|
-
self._cleanup_local_graph_orphans(conn, source_id)
|
|
591
|
-
return {
|
|
592
|
-
"source_id": source_id,
|
|
593
|
-
"root_path": source["root_path"],
|
|
594
|
-
"removed_graph_nodes": len(graph_node_ids),
|
|
595
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"""Local filesystem indexing: a chosen folder becomes graph knowledge.
|
|
2
|
-
|
|
3
|
-
v11.3.0 turned this module into a package. ``KnowledgeGraphLocalIndexMixin``
|
|
4
|
-
is now composed from four cohesive sub-mixins — text extraction, node/index
|
|
5
|
-
upserts, graph cleanup, and the folder-scan driver — each moved here
|
|
6
|
-
verbatim. Every name this module exported before still resolves from
|
|
7
|
-
``lattice_brain.graph.discovery_index``.
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
from __future__ import annotations
|
|
11
|
-
|
|
12
|
-
# ruff: noqa: F403,F405
|
|
13
|
-
from .._kg_common import * # noqa: F403,F401
|
|
14
|
-
from .cleanup import _LocalCleanupMixin
|
|
15
|
-
from .extract import _LocalExtractMixin
|
|
16
|
-
from .scan import _LocalScanMixin
|
|
17
|
-
from .upsert import _local_scoped_slug, _LocalUpsertMixin # noqa: F401
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# Base order is most-composed-first (the scan driver, then the three halves it
|
|
21
|
-
# calls): each half is named as the driver's typing-only base, and C3 needs a
|
|
22
|
-
# subclass ahead of the class it extends. The method sets are disjoint, so at
|
|
23
|
-
# runtime the order changes nothing.
|
|
24
|
-
class KnowledgeGraphLocalIndexMixin(
|
|
25
|
-
_LocalScanMixin,
|
|
26
|
-
_LocalExtractMixin,
|
|
27
|
-
_LocalUpsertMixin,
|
|
28
|
-
_LocalCleanupMixin,
|
|
29
|
-
):
|
|
30
|
-
"""Local file → graph indexing (text extraction, node/index upserts,
|
|
31
|
-
graph-node deletion, orphan cleanup, and the index_local_folder driver),
|
|
32
|
-
split out of discovery. Composed into KnowledgeGraphStore alongside
|
|
33
|
-
KnowledgeGraphDiscoveryMixin; both share the instance so these methods
|
|
34
|
-
still reach sibling discovery/write helpers through the class MRO.
|
|
35
|
-
"""
|