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,302 +0,0 @@
|
|
|
1
|
-
"""Hardware, OS, toolchain and API-key detection for the setup wizard.
|
|
2
|
-
|
|
3
|
-
Everything the recommender needs to know about *this* machine: chip, CPU
|
|
4
|
-
features, RAM, free disk, GPU/CUDA/WSL, which CLIs are on PATH, whether MLX
|
|
5
|
-
imports, and which provider keys are in the environment. Every probe is
|
|
6
|
-
best-effort — a failed probe answers "unknown", never raises.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
from __future__ import annotations
|
|
10
|
-
|
|
11
|
-
import os
|
|
12
|
-
import platform
|
|
13
|
-
import re
|
|
14
|
-
import shutil
|
|
15
|
-
import subprocess
|
|
16
|
-
from pathlib import Path
|
|
17
|
-
from typing import Any, Dict, List
|
|
18
|
-
|
|
19
|
-
from latticeai.core.quiet import quiet
|
|
20
|
-
from latticeai.services.setup_detection import (
|
|
21
|
-
detect_cuda,
|
|
22
|
-
detect_tools,
|
|
23
|
-
detect_wsl_from_text,
|
|
24
|
-
parse_windows_cpu_info,
|
|
25
|
-
windows_processor_features,
|
|
26
|
-
)
|
|
27
|
-
from latticeai.services.setup_detection import (
|
|
28
|
-
parse_windows_video_controllers as _parse_windows_video_controllers,
|
|
29
|
-
)
|
|
30
|
-
from latticeai.setup.wizard.paths import (
|
|
31
|
-
_component_detail,
|
|
32
|
-
_module_available,
|
|
33
|
-
_which_any,
|
|
34
|
-
repair_path_for,
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def _cmd(args: List[str], timeout: int = 10) -> str:
|
|
39
|
-
try:
|
|
40
|
-
r = subprocess.run(args, capture_output=True, text=True, timeout=timeout, check=False)
|
|
41
|
-
return (r.stdout or r.stderr or "").strip()
|
|
42
|
-
except Exception:
|
|
43
|
-
return ""
|
|
44
|
-
|
|
45
|
-
# ── Environment Detection ─────────────────────────────────────────────────────
|
|
46
|
-
|
|
47
|
-
def _detect_chip() -> Dict[str, Any]:
|
|
48
|
-
arch = platform.machine()
|
|
49
|
-
is_apple = arch == "arm64" and platform.system() == "Darwin"
|
|
50
|
-
name = "Unknown CPU"
|
|
51
|
-
gen: Any = None
|
|
52
|
-
|
|
53
|
-
if is_apple:
|
|
54
|
-
profiler = _cmd(["system_profiler", "SPHardwareDataType"], timeout=8)
|
|
55
|
-
m = re.search(r"Chip:\s+(Apple M\S+)", profiler)
|
|
56
|
-
name = m.group(1) if m else "Apple Silicon"
|
|
57
|
-
gm = re.search(r"M(\d+)", name)
|
|
58
|
-
gen = int(gm.group(1)) if gm else 1
|
|
59
|
-
else:
|
|
60
|
-
brand = ""
|
|
61
|
-
if platform.system() == "Darwin":
|
|
62
|
-
brand = _cmd(["sysctl", "-n", "machdep.cpu.brand_string"])
|
|
63
|
-
elif platform.system() == "Windows":
|
|
64
|
-
raw = _cmd(["wmic", "cpu", "get", "Name", "/value"], timeout=5)
|
|
65
|
-
if "Name=" in raw:
|
|
66
|
-
brand = raw.split("Name=", 1)[-1].splitlines()[0].strip()
|
|
67
|
-
elif platform.system() == "Linux":
|
|
68
|
-
try:
|
|
69
|
-
for line in Path("/proc/cpuinfo").read_text(encoding="utf-8", errors="replace").splitlines():
|
|
70
|
-
if line.lower().startswith("model name"):
|
|
71
|
-
brand = line.split(":", 1)[-1].strip()
|
|
72
|
-
break
|
|
73
|
-
except Exception:
|
|
74
|
-
quiet()
|
|
75
|
-
name = brand or platform.processor() or "Unknown CPU"
|
|
76
|
-
|
|
77
|
-
return {"name": name, "arch": arch, "is_apple_silicon": is_apple, "gen": gen}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def _detect_cpu() -> Dict[str, Any]:
|
|
81
|
-
flags: List[str] = []
|
|
82
|
-
physical_cores = os.cpu_count() or 0
|
|
83
|
-
logical_cores = os.cpu_count() or 0
|
|
84
|
-
model = _detect_chip()["name"]
|
|
85
|
-
if platform.system() == "Darwin":
|
|
86
|
-
flags = [item.lower() for item in _cmd(["sysctl", "-n", "machdep.cpu.features"], timeout=5).split()]
|
|
87
|
-
try:
|
|
88
|
-
physical_cores = int(_cmd(["sysctl", "-n", "hw.physicalcpu"], timeout=5) or physical_cores)
|
|
89
|
-
logical_cores = int(_cmd(["sysctl", "-n", "hw.logicalcpu"], timeout=5) or logical_cores)
|
|
90
|
-
except ValueError:
|
|
91
|
-
quiet()
|
|
92
|
-
elif platform.system() == "Linux":
|
|
93
|
-
try:
|
|
94
|
-
text = Path("/proc/cpuinfo").read_text(encoding="utf-8", errors="replace")
|
|
95
|
-
for line in text.splitlines():
|
|
96
|
-
if line.lower().startswith(("flags", "features")):
|
|
97
|
-
flags = line.split(":", 1)[-1].strip().lower().split()
|
|
98
|
-
break
|
|
99
|
-
except Exception:
|
|
100
|
-
quiet()
|
|
101
|
-
elif platform.system() == "Windows":
|
|
102
|
-
raw = _cmd(["wmic", "cpu", "get", "Name,NumberOfCores,NumberOfLogicalProcessors", "/format:list"], timeout=5)
|
|
103
|
-
model, physical_cores, logical_cores = parse_windows_cpu_info(
|
|
104
|
-
raw, model=model, physical_cores=physical_cores, logical_cores=logical_cores,
|
|
105
|
-
)
|
|
106
|
-
flags.extend(windows_processor_features())
|
|
107
|
-
interesting = {"avx", "avx2", "avx512f", "fma", "neon", "sse4_2"}
|
|
108
|
-
if platform.system() == "Windows":
|
|
109
|
-
interesting.update({"sse", "sse2", "sse3", "rdrand"})
|
|
110
|
-
return {
|
|
111
|
-
"model": model,
|
|
112
|
-
"physical_cores": physical_cores,
|
|
113
|
-
"logical_cores": logical_cores,
|
|
114
|
-
"instructions": sorted({flag for flag in flags if flag in interesting}),
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
def _detect_ram_gb() -> float:
|
|
118
|
-
if platform.system() == "Windows":
|
|
119
|
-
raw = _cmd(["wmic", "ComputerSystem", "get", "TotalPhysicalMemory", "/format:list"], timeout=5)
|
|
120
|
-
for line in raw.splitlines():
|
|
121
|
-
if line.startswith("TotalPhysicalMemory="):
|
|
122
|
-
try:
|
|
123
|
-
return round(int(line.split("=", 1)[-1].strip()) / 1_073_741_824, 1)
|
|
124
|
-
except ValueError:
|
|
125
|
-
break
|
|
126
|
-
raw = _cmd(["sysctl", "-n", "hw.memsize"])
|
|
127
|
-
if raw:
|
|
128
|
-
try:
|
|
129
|
-
return round(int(raw) / 1_073_741_824, 1)
|
|
130
|
-
except ValueError:
|
|
131
|
-
quiet()
|
|
132
|
-
if platform.system() == "Darwin":
|
|
133
|
-
profiler = _cmd(["system_profiler", "SPHardwareDataType"], timeout=8)
|
|
134
|
-
m = re.search(r"Memory:\s+([\d.]+)\s*(TB|GB|MB)", profiler, re.IGNORECASE)
|
|
135
|
-
if m:
|
|
136
|
-
value = float(m.group(1))
|
|
137
|
-
unit = m.group(2).lower()
|
|
138
|
-
if unit == "tb":
|
|
139
|
-
return round(value * 1024, 1)
|
|
140
|
-
if unit == "gb":
|
|
141
|
-
return round(value, 1)
|
|
142
|
-
return round(value / 1024, 1)
|
|
143
|
-
hostinfo = _cmd(["hostinfo"], timeout=5)
|
|
144
|
-
m = re.search(r"Primary memory available:\s+([\d.]+)\s+gigabytes", hostinfo, re.IGNORECASE)
|
|
145
|
-
if m:
|
|
146
|
-
return round(float(m.group(1)), 1)
|
|
147
|
-
try:
|
|
148
|
-
with open("/proc/meminfo") as f:
|
|
149
|
-
for line in f:
|
|
150
|
-
if line.startswith("MemTotal:"):
|
|
151
|
-
return round(int(line.split()[1]) / 1_048_576, 1)
|
|
152
|
-
except Exception:
|
|
153
|
-
quiet()
|
|
154
|
-
return 0.0
|
|
155
|
-
|
|
156
|
-
def _detect_disk_free_gb() -> float:
|
|
157
|
-
try:
|
|
158
|
-
path = "C:\\" if platform.system() == "Windows" else "/"
|
|
159
|
-
return round(shutil.disk_usage(path).free / 1_073_741_824, 1)
|
|
160
|
-
except Exception:
|
|
161
|
-
return 0.0
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
def _detect_gpu() -> Dict[str, Any]:
|
|
165
|
-
devices: List[Dict[str, Any]] = []
|
|
166
|
-
nvidia_smi = _which_any("nvidia-smi")
|
|
167
|
-
if nvidia_smi:
|
|
168
|
-
info = _cmd([nvidia_smi, "--query-gpu=name,memory.total", "--format=csv,noheader,nounits"], timeout=8)
|
|
169
|
-
for line in [item.strip() for item in info.splitlines() if item.strip()]:
|
|
170
|
-
try:
|
|
171
|
-
name, mem = [part.strip() for part in line.split(",", 1)]
|
|
172
|
-
devices.append({"vendor": "nvidia", "name": name, "vram_mb": int(float(mem)), "backend": "cuda"})
|
|
173
|
-
except Exception:
|
|
174
|
-
quiet()
|
|
175
|
-
continue
|
|
176
|
-
|
|
177
|
-
if platform.system() == "Windows":
|
|
178
|
-
shell = _which_any("powershell") or _which_any("pwsh")
|
|
179
|
-
raw = ""
|
|
180
|
-
if shell:
|
|
181
|
-
raw = _cmd([
|
|
182
|
-
shell, "-NoProfile", "-Command",
|
|
183
|
-
"Get-CimInstance Win32_VideoController | Select-Object Name,AdapterRAM | ConvertTo-Json -Compress",
|
|
184
|
-
], timeout=8)
|
|
185
|
-
if not raw:
|
|
186
|
-
raw = _cmd(["wmic", "path", "win32_VideoController", "get", "Name,AdapterRAM", "/format:list"], timeout=8)
|
|
187
|
-
for item in _parse_windows_video_controllers(raw):
|
|
188
|
-
if any(existing.get("name") == item["name"] for existing in devices):
|
|
189
|
-
continue
|
|
190
|
-
low = item["name"].lower()
|
|
191
|
-
vendor, backend = "unknown", "cpu"
|
|
192
|
-
if "nvidia" in low or "geforce" in low or "rtx" in low:
|
|
193
|
-
vendor, backend = "nvidia", "cuda"
|
|
194
|
-
elif "amd" in low or "radeon" in low:
|
|
195
|
-
vendor, backend = "amd", "directml/vulkan"
|
|
196
|
-
elif "intel" in low or "arc" in low or "iris" in low:
|
|
197
|
-
vendor, backend = "intel", "directml/vulkan"
|
|
198
|
-
devices.append({"vendor": vendor, "name": item["name"], "vram_mb": item["vram_mb"], "backend": backend})
|
|
199
|
-
elif platform.system() == "Darwin":
|
|
200
|
-
sp = _cmd(["system_profiler", "SPDisplaysDataType"], timeout=8)
|
|
201
|
-
for line in sp.splitlines():
|
|
202
|
-
if "Chipset Model" in line:
|
|
203
|
-
devices.append({"vendor": "apple", "name": line.split(":", 1)[-1].strip(), "vram_mb": 0, "backend": "metal/mlx"})
|
|
204
|
-
break
|
|
205
|
-
elif platform.system() == "Linux" and not devices:
|
|
206
|
-
info = _cmd(["lspci"], timeout=5)
|
|
207
|
-
for line in info.splitlines():
|
|
208
|
-
low = line.lower()
|
|
209
|
-
if not any(token in low for token in ("vga", "3d controller", "display")):
|
|
210
|
-
continue
|
|
211
|
-
if "nvidia" in low:
|
|
212
|
-
devices.append({"vendor": "nvidia", "name": line.strip(), "vram_mb": 0, "backend": "cuda"})
|
|
213
|
-
elif "amd" in low or "advanced micro devices" in low or "radeon" in low:
|
|
214
|
-
devices.append({"vendor": "amd", "name": line.strip(), "vram_mb": 0, "backend": "rocm/vulkan"})
|
|
215
|
-
elif "intel" in low:
|
|
216
|
-
devices.append({"vendor": "intel", "name": line.strip(), "vram_mb": 0, "backend": "vulkan"})
|
|
217
|
-
|
|
218
|
-
primary = max(devices, key=lambda item: int(item.get("vram_mb") or 0), default={})
|
|
219
|
-
vram_mb = int(primary.get("vram_mb") or 0)
|
|
220
|
-
return {
|
|
221
|
-
"devices": devices,
|
|
222
|
-
"vendor": primary.get("vendor", "none"),
|
|
223
|
-
"name": primary.get("name", ""),
|
|
224
|
-
"vram_mb": vram_mb,
|
|
225
|
-
"vram_gb": round(vram_mb / 1024, 1),
|
|
226
|
-
"backend": primary.get("backend", "cpu"),
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
def _detect_cuda() -> Dict[str, Any]:
|
|
231
|
-
available, version, nvidia_smi, nvcc = detect_cuda(_which_any, lambda args: _cmd(args, timeout=5))
|
|
232
|
-
return {"available": available, "nvidia_smi": nvidia_smi, "nvcc": nvcc, "version": version}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
def _detect_wsl() -> Dict[str, Any]:
|
|
236
|
-
raw = ""
|
|
237
|
-
try:
|
|
238
|
-
raw = Path("/proc/version").read_text(encoding="utf-8", errors="replace")
|
|
239
|
-
except Exception:
|
|
240
|
-
quiet()
|
|
241
|
-
is_wsl, version = detect_wsl_from_text(platform.system().lower(), raw)
|
|
242
|
-
return {"is_wsl": is_wsl, "version": version}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
def _detect_tools() -> Dict[str, bool]:
|
|
246
|
-
repair_path_for()
|
|
247
|
-
detected = detect_tools(_which_any, ["brew", "ollama", "python3", "python", "node", "npm", "git", "tesseract", "lms", "nvidia-smi", "nvcc"])
|
|
248
|
-
return {tool: path is not None for tool, path in detected.items()}
|
|
249
|
-
|
|
250
|
-
def _detect_mlx() -> Dict[str, Any]:
|
|
251
|
-
return {
|
|
252
|
-
"available": _module_available("mlx"),
|
|
253
|
-
"mlx_vlm": _module_available("mlx_vlm"),
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
def _detect_api_keys() -> Dict[str, bool]:
|
|
257
|
-
return {
|
|
258
|
-
"openai": bool(os.getenv("OPENAI_API_KEY")),
|
|
259
|
-
"openrouter": bool(os.getenv("OPENROUTER_API_KEY")),
|
|
260
|
-
"groq": bool(os.getenv("GROQ_API_KEY")),
|
|
261
|
-
"together": bool(os.getenv("TOGETHER_API_KEY")),
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
def scan_environment() -> Dict[str, Any]:
|
|
265
|
-
chip = _detect_chip()
|
|
266
|
-
cpu = _detect_cpu()
|
|
267
|
-
gpu = _detect_gpu()
|
|
268
|
-
cuda = _detect_cuda()
|
|
269
|
-
wsl = _detect_wsl()
|
|
270
|
-
tools = _detect_tools()
|
|
271
|
-
python_binary = "python3" if tools.get("python3") else "python"
|
|
272
|
-
return {
|
|
273
|
-
"os": platform.system(),
|
|
274
|
-
"os_version": platform.mac_ver()[0] if platform.system() == "Darwin" else platform.version(),
|
|
275
|
-
"chip": chip,
|
|
276
|
-
"cpu": cpu,
|
|
277
|
-
"gpu": gpu,
|
|
278
|
-
"cuda": cuda,
|
|
279
|
-
"wsl": wsl,
|
|
280
|
-
"ram_gb": _detect_ram_gb(),
|
|
281
|
-
"disk_free_gb": _detect_disk_free_gb(),
|
|
282
|
-
"tools": tools,
|
|
283
|
-
"components": {
|
|
284
|
-
"homebrew": _component_detail("homebrew", "brew"),
|
|
285
|
-
"python": {**_component_detail("python", python_binary), "version": platform.python_version()},
|
|
286
|
-
"node": _component_detail("node", "node"),
|
|
287
|
-
"npm": _component_detail("node", "npm"),
|
|
288
|
-
"git": _component_detail("git", "git"),
|
|
289
|
-
"ollama": _component_detail("ollama", "ollama"),
|
|
290
|
-
"lmstudio": _component_detail("lmstudio", "lms"),
|
|
291
|
-
"cuda": {**_component_detail("cuda", "nvcc"), **cuda},
|
|
292
|
-
"tesseract": _component_detail("tesseract", "tesseract"),
|
|
293
|
-
"mlx": _component_detail("mlx", module="mlx"),
|
|
294
|
-
"mlx_vlm": _component_detail("mlx", module="mlx_vlm"),
|
|
295
|
-
},
|
|
296
|
-
"path": {
|
|
297
|
-
"active": os.environ.get("PATH", ""),
|
|
298
|
-
"extra": os.environ.get("LATTICEAI_EXTRA_PATH", ""),
|
|
299
|
-
},
|
|
300
|
-
"mlx": _detect_mlx(),
|
|
301
|
-
"api_keys": _detect_api_keys(),
|
|
302
|
-
}
|
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
"""Verification, repair, and the SSE install stream.
|
|
2
|
-
|
|
3
|
-
The acting half of the wizard: prove a binary or module is really there, try a
|
|
4
|
-
bounded automatic repair when it is not, and stream one SSE event per step
|
|
5
|
-
while pip/brew/model-load/auth actions run. Every subprocess goes through the
|
|
6
|
-
process-audit command plan, and every plan is confirmed against the token the
|
|
7
|
-
caller returned.
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
from __future__ import annotations
|
|
11
|
-
|
|
12
|
-
import asyncio
|
|
13
|
-
import os
|
|
14
|
-
import platform
|
|
15
|
-
import shutil
|
|
16
|
-
import subprocess
|
|
17
|
-
import sys
|
|
18
|
-
import time
|
|
19
|
-
from typing import Any, AsyncIterator, Dict, List, Tuple
|
|
20
|
-
|
|
21
|
-
from latticeai.core.quiet import quiet
|
|
22
|
-
from latticeai.services.process_audit import (
|
|
23
|
-
CommandConfirmationError,
|
|
24
|
-
append_process_audit_event,
|
|
25
|
-
command_plan,
|
|
26
|
-
require_command_confirmation,
|
|
27
|
-
)
|
|
28
|
-
from latticeai.setup.wizard.paths import (
|
|
29
|
-
_module_available,
|
|
30
|
-
_package_module,
|
|
31
|
-
_which_any,
|
|
32
|
-
repair_path_for,
|
|
33
|
-
)
|
|
34
|
-
from latticeai.setup.wizard.plans import _sse, _verify_action_confirmation
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def _verify_binary(binary: str, version_args: List[str] | None = None, timeout: int = 20) -> Tuple[bool, str]:
|
|
38
|
-
repair_path_for(binary)
|
|
39
|
-
found = _which_any(binary)
|
|
40
|
-
if not found:
|
|
41
|
-
return False, f"{binary} 실행 파일을 PATH에서 찾지 못했습니다."
|
|
42
|
-
args = [found, *(version_args or ["--version"])]
|
|
43
|
-
try:
|
|
44
|
-
completed = subprocess.run(args, capture_output=True, text=True, timeout=timeout, check=False)
|
|
45
|
-
except Exception as e:
|
|
46
|
-
return False, str(e)
|
|
47
|
-
output = (completed.stdout or completed.stderr or "").strip().splitlines()
|
|
48
|
-
if completed.returncode == 0:
|
|
49
|
-
return True, output[0] if output else found
|
|
50
|
-
return False, (completed.stderr or completed.stdout or f"returncode={completed.returncode}")[-400:]
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
async def _wait_for_binary(binary: str, seconds: int = 300) -> Tuple[bool, str]:
|
|
54
|
-
deadline = time.time() + seconds
|
|
55
|
-
while time.time() < deadline:
|
|
56
|
-
ok, msg = _verify_binary(binary)
|
|
57
|
-
if ok:
|
|
58
|
-
return True, msg
|
|
59
|
-
await asyncio.sleep(2)
|
|
60
|
-
return False, f"{binary} 설치 완료를 제한 시간 안에 감지하지 못했습니다."
|
|
61
|
-
|
|
62
|
-
# ── Installation Stream ───────────────────────────────────────────────────────
|
|
63
|
-
|
|
64
|
-
def _verify_action(action: Dict[str, Any]) -> Tuple[bool, str]:
|
|
65
|
-
atype = action.get("type")
|
|
66
|
-
if atype == "pip":
|
|
67
|
-
modules = action.get("verify_modules") or [_package_module(pkg) for pkg in action.get("packages", [])]
|
|
68
|
-
missing = [module for module in modules if not _module_available(module)]
|
|
69
|
-
if missing:
|
|
70
|
-
return False, "Python 모듈 감지 실패: " + ", ".join(missing)
|
|
71
|
-
return True, "Python 모듈 import 테스트 통과"
|
|
72
|
-
binary = action.get("binary")
|
|
73
|
-
if binary:
|
|
74
|
-
return _verify_binary(binary)
|
|
75
|
-
return True, "검증 항목 없음"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
async def _repair_action(
|
|
79
|
-
action: Dict[str, Any],
|
|
80
|
-
*,
|
|
81
|
-
confirmation_token: str | None = None,
|
|
82
|
-
actor: str | None = None,
|
|
83
|
-
) -> Tuple[bool, str]:
|
|
84
|
-
binary = action.get("binary")
|
|
85
|
-
if binary:
|
|
86
|
-
repair_path_for(binary)
|
|
87
|
-
ok, msg = _verify_binary(binary)
|
|
88
|
-
if ok:
|
|
89
|
-
return True, f"PATH 자동 보정 완료: {msg}"
|
|
90
|
-
if action.get("type") == "pip":
|
|
91
|
-
packages = action.get("packages", [])
|
|
92
|
-
if packages:
|
|
93
|
-
if not _verify_action_confirmation(action, confirmation_token, name="repair_action"):
|
|
94
|
-
return False, "설치 명령 확인 토큰이 일치하지 않습니다."
|
|
95
|
-
for pkg in packages:
|
|
96
|
-
success, err = await _pip_install(pkg, confirmed=True, actor=actor)
|
|
97
|
-
if not success:
|
|
98
|
-
return False, err
|
|
99
|
-
return _verify_action(action)
|
|
100
|
-
return False, "자동 복구 방법을 찾지 못했습니다."
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
async def install_stream(
|
|
104
|
-
items: List[Dict],
|
|
105
|
-
router: Any,
|
|
106
|
-
*,
|
|
107
|
-
confirmation_token: str | None = None,
|
|
108
|
-
user_email: str | None = None,
|
|
109
|
-
) -> AsyncIterator[str]:
|
|
110
|
-
for item in items:
|
|
111
|
-
item_id = item.get("id", "unknown")
|
|
112
|
-
name = item.get("name", item_id)
|
|
113
|
-
action = item.get("action") or {}
|
|
114
|
-
atype = action.get("type")
|
|
115
|
-
|
|
116
|
-
if not atype:
|
|
117
|
-
yield _sse({"id": item_id, "status": "skipped", "msg": f"{name} — 이미 준비됨"})
|
|
118
|
-
await asyncio.sleep(0.04)
|
|
119
|
-
continue
|
|
120
|
-
|
|
121
|
-
yield _sse({"id": item_id, "status": "starting", "msg": f"{name} 준비 중..."})
|
|
122
|
-
|
|
123
|
-
if atype == "pip":
|
|
124
|
-
packages = action.get("packages", [])
|
|
125
|
-
token = confirmation_token or action.get("confirmation_token") or (action.get("command_plan") or {}).get("confirmation_token")
|
|
126
|
-
if not _verify_action_confirmation(action, token, name=str(item_id)):
|
|
127
|
-
yield _sse({"id": item_id, "status": "error", "msg": "설치 명령 확인 토큰이 일치하지 않습니다."})
|
|
128
|
-
continue
|
|
129
|
-
ok = True
|
|
130
|
-
for pkg in packages:
|
|
131
|
-
yield _sse({"id": item_id, "status": "running", "msg": f"pip install {pkg} ..."})
|
|
132
|
-
success, err = await _pip_install(pkg, confirmed=True, actor=user_email)
|
|
133
|
-
if success:
|
|
134
|
-
yield _sse({"id": item_id, "status": "progress", "msg": f"{pkg} 설치 완료"})
|
|
135
|
-
else:
|
|
136
|
-
yield _sse({"id": item_id, "status": "error", "msg": f"{pkg} 실패: {err[:400]}"})
|
|
137
|
-
ok = False
|
|
138
|
-
break
|
|
139
|
-
if ok:
|
|
140
|
-
yield _sse({"id": item_id, "status": "running", "msg": f"{name} 동작 테스트 중..."})
|
|
141
|
-
verified, detail = _verify_action(action)
|
|
142
|
-
if verified:
|
|
143
|
-
yield _sse({"id": item_id, "status": "done", "msg": f"{name} 설치 · 검증 완료 ✅\n{detail}"})
|
|
144
|
-
else:
|
|
145
|
-
yield _sse({"id": item_id, "status": "running", "msg": f"검증 실패 — 자동 복구 중...\n{detail}"})
|
|
146
|
-
repaired, repair_msg = await _repair_action(action, confirmation_token=token, actor=user_email)
|
|
147
|
-
yield _sse({"id": item_id, "status": "done" if repaired else "error", "msg": repair_msg[:500]})
|
|
148
|
-
|
|
149
|
-
elif atype == "brew":
|
|
150
|
-
pkg = action.get("package", "")
|
|
151
|
-
token = confirmation_token or action.get("confirmation_token") or (action.get("command_plan") or {}).get("confirmation_token")
|
|
152
|
-
if not _verify_action_confirmation(action, token, name=str(item_id)):
|
|
153
|
-
yield _sse({"id": item_id, "status": "error", "msg": "설치 명령 확인 토큰이 일치하지 않습니다."})
|
|
154
|
-
continue
|
|
155
|
-
yield _sse({"id": item_id, "status": "running", "msg": f"brew install {pkg} ..."})
|
|
156
|
-
success, err = await _brew_install(pkg, confirmed=True, actor=user_email)
|
|
157
|
-
if success:
|
|
158
|
-
yield _sse({"id": item_id, "status": "running", "msg": "설치 완료 감지 · PATH 보정 중..."})
|
|
159
|
-
binary = action.get("binary")
|
|
160
|
-
if binary:
|
|
161
|
-
repair_path_for(binary)
|
|
162
|
-
verified, detail = _verify_action(action)
|
|
163
|
-
if verified:
|
|
164
|
-
yield _sse({"id": item_id, "status": "done", "msg": f"{name} 설치 · 연결 · 검증 완료 ✅\n{detail}"})
|
|
165
|
-
else:
|
|
166
|
-
yield _sse({"id": item_id, "status": "running", "msg": f"검증 실패 — 자동 복구 중...\n{detail}"})
|
|
167
|
-
repaired, repair_msg = await _repair_action(action, confirmation_token=token, actor=user_email)
|
|
168
|
-
yield _sse({"id": item_id, "status": "done" if repaired else "error", "msg": repair_msg[:500]})
|
|
169
|
-
else:
|
|
170
|
-
url = action.get("official_url") or action.get("url")
|
|
171
|
-
if url:
|
|
172
|
-
yield _sse({"id": item_id, "status": "auth", "msg": f"자동 설치 실패 — 공식 다운로드 페이지를 엽니다.\n{err[:240]}", "auth_url": url})
|
|
173
|
-
open_url(url)
|
|
174
|
-
yield _sse({"id": item_id, "status": "error", "msg": f"실패: {err[:400]}"})
|
|
175
|
-
|
|
176
|
-
elif atype == "load_model":
|
|
177
|
-
model_id = action.get("model_id", "")
|
|
178
|
-
yield _sse({"id": item_id, "status": "running",
|
|
179
|
-
"msg": f"모델 다운로드 · 로딩 중...\n{model_id}\n(용량에 따라 수 분 소요)"})
|
|
180
|
-
try:
|
|
181
|
-
await router.load_model(model_id)
|
|
182
|
-
yield _sse({"id": item_id, "status": "done", "msg": f"{name} 로드 완료 ✅"})
|
|
183
|
-
except Exception as e:
|
|
184
|
-
yield _sse({"id": item_id, "status": "error", "msg": f"로드 실패: {str(e)[:400]}"})
|
|
185
|
-
|
|
186
|
-
elif atype == "auth":
|
|
187
|
-
url = action.get("url", "")
|
|
188
|
-
yield _sse({"id": item_id, "status": "auth",
|
|
189
|
-
"msg": "브라우저에서 인증 페이지를 엽니다...", "auth_url": url})
|
|
190
|
-
open_url(url)
|
|
191
|
-
yield _sse({"id": item_id, "status": "waiting",
|
|
192
|
-
"msg": "브라우저에서 인증 완료 후 계속하세요"})
|
|
193
|
-
|
|
194
|
-
elif atype == "url":
|
|
195
|
-
url = action.get("url", "")
|
|
196
|
-
yield _sse({"id": item_id, "status": "auth",
|
|
197
|
-
"msg": "설치 페이지를 브라우저에서 엽니다...", "auth_url": url})
|
|
198
|
-
open_url(url)
|
|
199
|
-
binary = action.get("binary")
|
|
200
|
-
if binary:
|
|
201
|
-
yield _sse({"id": item_id, "status": "waiting",
|
|
202
|
-
"msg": f"{binary} 설치 완료를 자동 감지하는 중입니다..."})
|
|
203
|
-
ok, detail = await _wait_for_binary(binary)
|
|
204
|
-
if ok:
|
|
205
|
-
repair_path_for(binary)
|
|
206
|
-
yield _sse({"id": item_id, "status": "done",
|
|
207
|
-
"msg": f"{name} 설치 · PATH 연결 · 검증 완료 ✅\n{detail}"})
|
|
208
|
-
else:
|
|
209
|
-
yield _sse({"id": item_id, "status": "error",
|
|
210
|
-
"msg": f"{detail}\n공식 페이지에서 설치 후 다시 시도하세요."})
|
|
211
|
-
else:
|
|
212
|
-
yield _sse({"id": item_id, "status": "waiting",
|
|
213
|
-
"msg": "브라우저에서 설치 또는 인증을 완료한 뒤 다시 시도하세요"})
|
|
214
|
-
|
|
215
|
-
else:
|
|
216
|
-
yield _sse({"id": item_id, "status": "error", "msg": f"알 수 없는 액션: {atype}"})
|
|
217
|
-
|
|
218
|
-
yield _sse({"status": "complete", "msg": "모든 항목 처리 완료!"})
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
async def _pip_install(
|
|
222
|
-
package: str,
|
|
223
|
-
*,
|
|
224
|
-
confirmation_token: str | None = None,
|
|
225
|
-
confirmed: bool = False,
|
|
226
|
-
actor: str | None = None,
|
|
227
|
-
) -> Tuple[bool, str]:
|
|
228
|
-
command = [sys.executable, "-m", "pip", "install", "--upgrade", package]
|
|
229
|
-
plan = command_plan(
|
|
230
|
-
command,
|
|
231
|
-
name=f"pip:{package}",
|
|
232
|
-
purpose="setup_wizard_install",
|
|
233
|
-
metadata={"package": package},
|
|
234
|
-
)
|
|
235
|
-
try:
|
|
236
|
-
if not confirmed:
|
|
237
|
-
require_command_confirmation(command, confirmation_token, purpose="setup_wizard_install")
|
|
238
|
-
append_process_audit_event("setup_wizard_install", plan=plan, status="started", user_email=actor)
|
|
239
|
-
proc = await asyncio.create_subprocess_exec(
|
|
240
|
-
*command,
|
|
241
|
-
stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
|
|
242
|
-
)
|
|
243
|
-
_, stderr = await asyncio.wait_for(proc.communicate(), timeout=600)
|
|
244
|
-
stderr_text = stderr.decode(errors="replace")
|
|
245
|
-
append_process_audit_event(
|
|
246
|
-
"setup_wizard_install",
|
|
247
|
-
plan=plan,
|
|
248
|
-
status="finished",
|
|
249
|
-
user_email=actor,
|
|
250
|
-
returncode=proc.returncode,
|
|
251
|
-
stderr=stderr_text,
|
|
252
|
-
)
|
|
253
|
-
if proc.returncode == 0:
|
|
254
|
-
return True, ""
|
|
255
|
-
return False, stderr_text
|
|
256
|
-
except CommandConfirmationError as e:
|
|
257
|
-
append_process_audit_event("setup_wizard_install", plan=plan, status="denied", user_email=actor, error=str(e))
|
|
258
|
-
return False, str(e)
|
|
259
|
-
except asyncio.TimeoutError:
|
|
260
|
-
append_process_audit_event("setup_wizard_install", plan=plan, status="timeout", user_email=actor)
|
|
261
|
-
return False, "설치 시간 초과 (10분)"
|
|
262
|
-
except Exception as e:
|
|
263
|
-
append_process_audit_event("setup_wizard_install", plan=plan, status="error", user_email=actor, error=str(e))
|
|
264
|
-
return False, str(e)
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
async def _brew_install(
|
|
268
|
-
package: str,
|
|
269
|
-
*,
|
|
270
|
-
confirmation_token: str | None = None,
|
|
271
|
-
confirmed: bool = False,
|
|
272
|
-
actor: str | None = None,
|
|
273
|
-
) -> Tuple[bool, str]:
|
|
274
|
-
brew = shutil.which("brew")
|
|
275
|
-
if not brew:
|
|
276
|
-
return False, "Homebrew 미설치 — https://brew.sh 에서 설치하세요"
|
|
277
|
-
command = [brew, "install", package]
|
|
278
|
-
plan = command_plan(
|
|
279
|
-
command,
|
|
280
|
-
name=f"brew:{package}",
|
|
281
|
-
purpose="setup_wizard_install",
|
|
282
|
-
metadata={"package": package},
|
|
283
|
-
)
|
|
284
|
-
try:
|
|
285
|
-
if not confirmed:
|
|
286
|
-
require_command_confirmation(command, confirmation_token, purpose="setup_wizard_install")
|
|
287
|
-
append_process_audit_event("setup_wizard_install", plan=plan, status="started", user_email=actor)
|
|
288
|
-
proc = await asyncio.create_subprocess_exec(
|
|
289
|
-
*command,
|
|
290
|
-
stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
|
|
291
|
-
)
|
|
292
|
-
_, stderr = await asyncio.wait_for(proc.communicate(), timeout=300)
|
|
293
|
-
stderr_text = stderr.decode(errors="replace")
|
|
294
|
-
append_process_audit_event(
|
|
295
|
-
"setup_wizard_install",
|
|
296
|
-
plan=plan,
|
|
297
|
-
status="finished",
|
|
298
|
-
user_email=actor,
|
|
299
|
-
returncode=proc.returncode,
|
|
300
|
-
stderr=stderr_text,
|
|
301
|
-
)
|
|
302
|
-
if proc.returncode == 0:
|
|
303
|
-
return True, ""
|
|
304
|
-
return False, stderr_text
|
|
305
|
-
except CommandConfirmationError as e:
|
|
306
|
-
append_process_audit_event("setup_wizard_install", plan=plan, status="denied", user_email=actor, error=str(e))
|
|
307
|
-
return False, str(e)
|
|
308
|
-
except asyncio.TimeoutError:
|
|
309
|
-
append_process_audit_event("setup_wizard_install", plan=plan, status="timeout", user_email=actor)
|
|
310
|
-
return False, "설치 시간 초과 (5분)"
|
|
311
|
-
except Exception as e:
|
|
312
|
-
append_process_audit_event("setup_wizard_install", plan=plan, status="error", user_email=actor, error=str(e))
|
|
313
|
-
return False, str(e)
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
def open_url(url: str) -> None:
|
|
317
|
-
command: List[str]
|
|
318
|
-
try:
|
|
319
|
-
system = platform.system()
|
|
320
|
-
if system == "Darwin":
|
|
321
|
-
command = ["open", url]
|
|
322
|
-
plan = command_plan(command, name="open_url", purpose="setup_wizard_open_url")
|
|
323
|
-
append_process_audit_event("setup_wizard_open_url", plan=plan, status="started")
|
|
324
|
-
subprocess.Popen(command)
|
|
325
|
-
append_process_audit_event("setup_wizard_open_url", plan=plan, status="spawned")
|
|
326
|
-
elif system == "Windows":
|
|
327
|
-
command = ["os.startfile", url]
|
|
328
|
-
plan = command_plan(command, name="open_url", purpose="setup_wizard_open_url")
|
|
329
|
-
append_process_audit_event("setup_wizard_open_url", plan=plan, status="started")
|
|
330
|
-
os.startfile(url) # type: ignore[attr-defined] # noqa: S606 — fixed program, arguments validated by the caller
|
|
331
|
-
append_process_audit_event("setup_wizard_open_url", plan=plan, status="spawned")
|
|
332
|
-
else:
|
|
333
|
-
command = ["xdg-open", url]
|
|
334
|
-
plan = command_plan(command, name="open_url", purpose="setup_wizard_open_url")
|
|
335
|
-
append_process_audit_event("setup_wizard_open_url", plan=plan, status="started")
|
|
336
|
-
subprocess.Popen(command)
|
|
337
|
-
append_process_audit_event("setup_wizard_open_url", plan=plan, status="spawned")
|
|
338
|
-
except Exception as exc:
|
|
339
|
-
try:
|
|
340
|
-
append_process_audit_event(
|
|
341
|
-
"setup_wizard_open_url",
|
|
342
|
-
plan=command_plan(["open_url", url], name="open_url", purpose="setup_wizard_open_url"),
|
|
343
|
-
status="error",
|
|
344
|
-
error=str(exc),
|
|
345
|
-
)
|
|
346
|
-
except Exception:
|
|
347
|
-
quiet()
|
|
348
|
-
pass
|