ltcai 8.9.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +28 -39
  2. package/auto_setup.py +11 -62
  3. package/docs/CHANGELOG.md +76 -237
  4. package/docs/COMMUNITY_AND_PLUGINS.md +2 -2
  5. package/docs/DEVELOPMENT.md +8 -8
  6. package/docs/LEGACY_COMPATIBILITY.md +1 -1
  7. package/docs/ONBOARDING.md +2 -2
  8. package/docs/ROADMAP_RECOMMENDATIONS.md +61 -36
  9. package/docs/TRUST_MODEL.md +1 -1
  10. package/docs/WHY_LATTICE.md +2 -2
  11. package/docs/kg-schema.md +1 -1
  12. package/lattice_brain/__init__.py +1 -1
  13. package/lattice_brain/archive.py +4 -9
  14. package/lattice_brain/embeddings.py +38 -2
  15. package/lattice_brain/graph/_kg_common.py +27 -462
  16. package/lattice_brain/graph/_kg_constants.py +243 -0
  17. package/lattice_brain/graph/_kg_fsutil.py +297 -0
  18. package/lattice_brain/graph/discovery.py +0 -948
  19. package/lattice_brain/graph/discovery_index.py +972 -0
  20. package/lattice_brain/graph/retrieval.py +0 -570
  21. package/lattice_brain/graph/retrieval_docgen.py +210 -0
  22. package/lattice_brain/graph/retrieval_vector.py +460 -0
  23. package/lattice_brain/graph/store.py +6 -0
  24. package/lattice_brain/ingestion.py +68 -0
  25. package/lattice_brain/portability.py +1 -9
  26. package/lattice_brain/quality.py +98 -4
  27. package/lattice_brain/runtime/agent_runtime.py +166 -0
  28. package/lattice_brain/runtime/multi_agent.py +1 -1
  29. package/lattice_brain/utils.py +28 -0
  30. package/latticeai/__init__.py +1 -1
  31. package/latticeai/api/chat.py +340 -407
  32. package/latticeai/api/chat_helpers.py +227 -0
  33. package/latticeai/api/computer_use.py +149 -31
  34. package/latticeai/api/marketplace.py +11 -0
  35. package/latticeai/api/permissions.py +3 -3
  36. package/latticeai/api/tools.py +1 -0
  37. package/latticeai/app_factory.py +82 -360
  38. package/latticeai/core/io_utils.py +37 -0
  39. package/latticeai/core/legacy_compatibility.py +1 -1
  40. package/latticeai/core/local_embeddings.py +2 -4
  41. package/latticeai/core/marketplace.py +33 -2
  42. package/latticeai/core/mcp_catalog.py +450 -0
  43. package/latticeai/core/mcp_registry.py +2 -441
  44. package/latticeai/core/users.py +4 -9
  45. package/latticeai/core/workspace_os.py +1 -1
  46. package/latticeai/core/workspace_os_utils.py +3 -17
  47. package/latticeai/integrations/telegram_bot.py +7 -2
  48. package/latticeai/models/model_providers.py +111 -0
  49. package/latticeai/models/router.py +58 -136
  50. package/latticeai/runtime/audit_runtime.py +27 -16
  51. package/latticeai/runtime/automation_runtime.py +9 -0
  52. package/latticeai/runtime/history_runtime.py +163 -0
  53. package/latticeai/runtime/namespace_runtime.py +173 -0
  54. package/latticeai/runtime/network_config_runtime.py +56 -0
  55. package/latticeai/runtime/sso_config_runtime.py +128 -0
  56. package/latticeai/runtime/user_key_runtime.py +106 -0
  57. package/latticeai/services/architecture_readiness.py +2 -2
  58. package/latticeai/services/memory_service.py +213 -0
  59. package/latticeai/services/platform_runtime.py +9 -1
  60. package/latticeai/services/product_readiness.py +11 -11
  61. package/latticeai/services/review_queue.py +64 -11
  62. package/latticeai/services/run_executor.py +21 -0
  63. package/latticeai/services/setup_detection.py +80 -0
  64. package/latticeai/services/tool_dispatch.py +1 -1
  65. package/package.json +1 -1
  66. package/setup_wizard.py +11 -55
  67. package/src-tauri/Cargo.lock +1 -1
  68. package/src-tauri/Cargo.toml +1 -1
  69. package/src-tauri/tauri.conf.json +1 -1
  70. package/static/app/asset-manifest.json +11 -11
  71. package/static/app/assets/{Act-fZokUnC0.js → Act-21lIXx2E.js} +1 -1
  72. package/static/app/assets/Brain-BqUd5UJJ.js +321 -0
  73. package/static/app/assets/{Capture-D5KV3Cu7.js → Capture-BA7Z2Q1u.js} +1 -1
  74. package/static/app/assets/{Library-C9kyFkSt.js → Library-bFMtyni3.js} +1 -1
  75. package/static/app/assets/System-K6krGCqn.js +1 -0
  76. package/static/app/assets/index-C4R3ws30.js +17 -0
  77. package/static/app/assets/index-ChSeOB02.css +2 -0
  78. package/static/app/assets/primitives-sQU3it5I.js +1 -0
  79. package/static/app/assets/{textarea-CD8UNKIy.js → textarea-DK3Fd_lR.js} +1 -1
  80. package/static/app/index.html +2 -2
  81. package/static/css/tokens.css +4 -2
  82. package/static/sw.js +1 -1
  83. package/tools/local_files.py +6 -0
  84. package/latticeai/runtime/sso_runtime.py +0 -52
  85. package/static/app/assets/Brain-DtyuWubr.js +0 -321
  86. package/static/app/assets/System-VbChmX7r.js +0 -1
  87. package/static/app/assets/index-DCh5AoXt.css +0 -2
  88. package/static/app/assets/index-DPdcPoF0.js +0 -17
  89. package/static/app/assets/primitives-DFeanEV6.js +0 -1
@@ -41,471 +41,36 @@ from .runtime import get_llm_router, set_llm_router
41
41
  # Override with LATTICEAI_KG_READ_V2=0 to fall back to the legacy tables.
42
42
  _READ_FROM_V2_DEFAULT = os.getenv("LATTICEAI_KG_READ_V2", "1") != "0"
43
43
 
44
- # Bump when the v2 projection layout changes (columns, normalization rules).
45
- # On init, a stale projection is dropped and rebuilt from the authoritative
46
- # legacy tables safe because nodes_v2/edges_v2 only ever hold a derived view.
47
- # v4: summary nullable + verbatim (byte-faithful) projection of legacy values.
48
- _PROJECTION_VERSION = 4
49
- _KG_DB_FORMAT_VERSION = 4
50
- _KG_DB_FORMAT_KEY = "db_format_version"
51
- _V2_WRITE_MASTER_KEY = "v2_write_mastered_at"
52
-
53
- GRAPH_SCHEMA_VERSION = 1
54
-
55
- LOCAL_TEXT_EXTENSIONS = {".txt", ".md"}
56
- LOCAL_CODE_EXTENSIONS = {
57
- ".py",
58
- ".js",
59
- ".ts",
60
- ".tsx",
61
- ".jsx",
62
- ".html",
63
- ".css",
64
- ".json",
65
- ".yaml",
66
- ".yml",
67
- ".xml",
68
- ".sql",
69
- ".sh",
70
- ".zsh",
71
- ".toml",
72
- ".ini",
73
- }
74
- LOCAL_DOCUMENT_EXTENSIONS = {".pdf", ".docx"}
75
- LOCAL_SPREADSHEET_EXTENSIONS = {".xlsx", ".csv"}
76
- LOCAL_SLIDE_EXTENSIONS = {".pptx"}
77
- LOCAL_IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".webp"}
78
- LOCAL_SUPPORTED_EXTENSIONS = (
79
- LOCAL_TEXT_EXTENSIONS
80
- | LOCAL_CODE_EXTENSIONS
81
- | LOCAL_DOCUMENT_EXTENSIONS
82
- | LOCAL_SPREADSHEET_EXTENSIONS
83
- | LOCAL_SLIDE_EXTENSIONS
84
- | LOCAL_IMAGE_EXTENSIONS
85
- )
86
-
87
- LOCAL_SIZE_LIMITS = {
88
- "text": 4_000_000,
89
- "code": 4_000_000,
90
- "pdf": 50_000_000,
91
- "document": 50_000_000,
92
- "spreadsheet": 50_000_000,
93
- "slide_deck": 50_000_000,
94
- "image": 100_000_000,
95
- }
96
-
97
- COMMON_EXCLUDED_DIRS = {
98
- ".git",
99
- "node_modules",
100
- ".venv",
101
- "venv",
102
- "env",
103
- "__pycache__",
104
- ".pytest_cache",
105
- ".mypy_cache",
106
- ".ruff_cache",
107
- ".next",
108
- ".nuxt",
109
- ".turbo",
110
- "dist",
111
- "build",
112
- "target",
113
- "out",
114
- "coverage",
115
- ".cache",
116
- ".config",
117
- ".ssh",
118
- ".gnupg",
119
- ".docker",
120
- ".kube",
121
- ".aws",
122
- ".azure",
123
- ".npm",
124
- ".pnpm-store",
125
- ".yarn",
126
- ".bun",
127
- ".cargo",
128
- ".rustup",
129
- ".pyenv",
130
- ".conda",
131
- ".local",
132
- ".claude",
133
- ".codex",
134
- ".cursor",
135
- ".copilot",
136
- ".antigravity",
137
- ".antigravity-ide",
138
- }
139
-
140
- COMMON_EXCLUDED_FILE_NAMES = {
141
- ".env",
142
- ".env.local",
143
- ".env.production",
144
- ".env.development",
145
- "id_rsa",
146
- "id_ed25519",
147
- "authorized_keys",
148
- "known_hosts",
149
- "credentials.json",
150
- "service-account.json",
151
- "token.json",
152
- "secrets.json",
153
- "cookies",
154
- "login data",
155
- "history",
156
- "web data",
157
- ".ds_store",
158
- "thumbs.db",
159
- }
160
- COMMON_EXCLUDED_FILE_SUFFIXES = {
161
- ".pem",
162
- ".key",
163
- ".p12",
164
- ".pfx",
165
- ".kdbx",
166
- ".wallet",
167
- ".sqlite",
168
- ".db",
169
- ".exe",
170
- ".dll",
171
- ".sys",
172
- ".msi",
173
- ".dmg",
174
- ".pkg",
175
- ".app",
176
- ".zip",
177
- ".tar",
178
- ".gz",
179
- ".7z",
180
- ".rar",
181
- ".mp4",
182
- ".mov",
183
- ".mp3",
184
- ".wav",
185
- ".tmp",
186
- ".bak",
187
- ".lock",
188
- }
189
- SENSITIVE_PATH_KEYWORDS = {
190
- "secret",
191
- "secrets",
192
- "token",
193
- "password",
194
- "passwd",
195
- "credential",
196
- "credentials",
197
- "private",
198
- "key",
199
- "wallet",
200
- "recovery",
201
- "seed",
202
- "mnemonic",
203
- "cookie",
204
- "session",
205
- "auth",
206
- "oauth",
207
- "certificate",
208
- "cert",
209
- "api_key",
210
- "apikey",
211
- }
212
-
213
- MACOS_EXCLUDED_PREFIXES = (
214
- "/System",
215
- "/Library",
216
- "/Applications",
217
- "/private",
218
- "/tmp",
219
- "/var",
220
- )
221
- WINDOWS_EXCLUDED_NAMES = {
222
- "windows",
223
- "program files",
224
- "program files (x86)",
225
- "programdata",
226
- "appdata",
227
- "$recycle.bin",
228
- "system volume information",
229
- "recovery",
230
- "perflogs",
231
- "intel",
232
- "amd",
233
- "nvidia",
234
- }
235
- LINUX_EXCLUDED_PREFIXES = (
236
- "/bin",
237
- "/boot",
238
- "/dev",
239
- "/etc",
240
- "/lib",
241
- "/lib64",
242
- "/proc",
243
- "/root",
244
- "/run",
245
- "/sbin",
246
- "/sys",
247
- "/tmp",
248
- "/usr",
249
- "/var",
250
- "/snap",
251
- "/lost+found",
44
+ # Static constants (projection/format versions, local-ingestion classification
45
+ # tables, OS exclusion lists) live in ._kg_constants; re-exported here so every
46
+ # existing ``from ._kg_common import <CONST>`` site is unaffected.
47
+ from ._kg_constants import ( # noqa: E402
48
+ _KG_DB_FORMAT_KEY,
49
+ _KG_DB_FORMAT_VERSION,
50
+ _PROJECTION_VERSION,
51
+ _V2_WRITE_MASTER_KEY,
52
+ COMMON_EXCLUDED_DIRS,
53
+ COMMON_EXCLUDED_FILE_NAMES,
54
+ COMMON_EXCLUDED_FILE_SUFFIXES,
55
+ GRAPH_SCHEMA_VERSION,
56
+ LINUX_EXCLUDED_PREFIXES,
57
+ LOCAL_CODE_EXTENSIONS,
58
+ LOCAL_DOCUMENT_EXTENSIONS,
59
+ LOCAL_IMAGE_EXTENSIONS,
60
+ LOCAL_SIZE_LIMITS,
61
+ LOCAL_SLIDE_EXTENSIONS,
62
+ LOCAL_SPREADSHEET_EXTENSIONS,
63
+ LOCAL_SUPPORTED_EXTENSIONS,
64
+ LOCAL_TEXT_EXTENSIONS,
65
+ MACOS_EXCLUDED_PREFIXES,
66
+ SENSITIVE_PATH_KEYWORDS,
67
+ WINDOWS_EXCLUDED_NAMES,
252
68
  )
253
69
 
254
70
 
255
- def _now() -> str:
256
- return datetime.now().isoformat()
257
-
258
-
259
- def _parse_iso(raw: Optional[str]) -> Optional[datetime]:
260
- if not raw:
261
- return None
262
- try:
263
- return datetime.fromisoformat(str(raw))
264
- except (TypeError, ValueError):
265
- return None
266
-
267
-
268
- def _recency_score(
269
- updated_at: Optional[str],
270
- *,
271
- now: Optional[datetime] = None,
272
- half_life_days: float = 14.0,
273
- ) -> float:
274
- stamp = _parse_iso(updated_at)
275
- if not stamp:
276
- return 0.0
277
- now = now or datetime.now()
278
- age_days = max(0.0, (now - stamp).total_seconds() / 86400.0)
279
- decay = math.log(2) / max(0.1, half_life_days)
280
- return math.exp(-decay * age_days)
281
-
282
-
283
- def _slug(text: str, max_len: int = 96) -> str:
284
- value = re.sub(r"\s+", " ", str(text or "")).strip().lower()
285
- value = re.sub(r"[^0-9a-zA-Z가-힣._:@/-]+", "-", value).strip("-")
286
- return (value or "untitled")[:max_len]
287
-
288
-
289
- def _sha256_bytes(data: bytes) -> str:
290
- return hashlib.sha256(data).hexdigest()
291
-
292
-
293
- def _sha256_text(text: str) -> str:
294
- return hashlib.sha256(text.encode("utf-8", errors="replace")).hexdigest()
295
-
296
-
297
- def _safe_iso_from_stat_mtime(mtime: float) -> str:
298
- try:
299
- return datetime.fromtimestamp(float(mtime)).isoformat()
300
- except (TypeError, ValueError, OSError):
301
- return ""
302
-
303
-
304
- def _path_fingerprint(path: Path) -> str:
305
- return _sha256_text(str(path.expanduser().resolve()))[:24]
306
-
307
-
308
- def _is_relative_to(path: Path, base: Path) -> bool:
309
- try:
310
- path.relative_to(base)
311
- return True
312
- except ValueError:
313
- return False
314
-
315
-
316
- def _path_parts_lower(path: Path) -> List[str]:
317
- return [
318
- part.lower()
319
- for part in path.parts
320
- if part and part not in {os.sep, path.anchor}
321
- ]
322
-
323
-
324
- def _current_os_type() -> str:
325
- system = platform.system().lower()
326
- if system.startswith("darwin"):
327
- return "macos"
328
- if system.startswith("windows"):
329
- return "windows"
330
- if system.startswith("linux"):
331
- return "linux"
332
- return system or "unknown"
333
-
334
-
335
- def _drive_id_for_path(path: Path) -> str:
336
- resolved = path.expanduser().resolve()
337
- if resolved.drive:
338
- return resolved.drive.upper()
339
- parts = resolved.parts
340
- if len(parts) >= 3 and parts[1] == "Volumes":
341
- return f"/Volumes/{parts[2]}"
342
- if len(parts) >= 3 and parts[1] == "media":
343
- return f"/media/{parts[2]}"
344
- if len(parts) >= 3 and parts[1] == "mnt":
345
- return f"/mnt/{parts[2]}"
346
- return resolved.anchor or "/"
347
-
348
-
349
- def _file_category(ext: str) -> str:
350
- ext = (ext or "").lower()
351
- if ext in LOCAL_CODE_EXTENSIONS:
352
- return "code"
353
- if ext in LOCAL_TEXT_EXTENSIONS:
354
- return "text"
355
- if ext == ".pdf":
356
- return "pdf"
357
- if ext in LOCAL_DOCUMENT_EXTENSIONS:
358
- return "document"
359
- if ext in LOCAL_SPREADSHEET_EXTENSIONS:
360
- return "spreadsheet"
361
- if ext in LOCAL_SLIDE_EXTENSIONS:
362
- return "slide_deck"
363
- if ext in LOCAL_IMAGE_EXTENSIONS:
364
- return "image"
365
- return "unsupported"
366
-
367
-
368
- def _node_type_for_category(category: str) -> str:
369
- return {
370
- "code": "CodeFile",
371
- "spreadsheet": "Spreadsheet",
372
- "slide_deck": "SlideDeck",
373
- "image": "Image",
374
- "unsupported": "File",
375
- }.get(category, "Document")
376
-
377
-
378
- def _parser_type_for_category(category: str, ext: str) -> str:
379
- if category in {"text", "code"}:
380
- return "plain_text"
381
- if category == "spreadsheet" and ext == ".csv":
382
- return "csv_text"
383
- if category == "image":
384
- return "image_ocr"
385
- return ext.lstrip(".") or category
386
-
387
-
388
- def _size_limit_for_category(category: str) -> int:
389
- return LOCAL_SIZE_LIMITS.get(category, LOCAL_SIZE_LIMITS["document"])
390
-
391
-
392
- def _is_hidden_path(path: Path, root: Optional[Path] = None) -> bool:
393
- parts: Iterable[str]
394
- if root is not None:
395
- try:
396
- parts = path.relative_to(root).parts
397
- except ValueError:
398
- parts = path.parts
399
- else:
400
- parts = path.parts
401
- return any(part.startswith(".") and part not in {".", ".."} for part in parts)
402
-
403
-
404
- def _excluded_directory_reason(
405
- path: Path, *, root: Optional[Path] = None, os_type: Optional[str] = None
406
- ) -> Optional[str]:
407
- os_type = os_type or _current_os_type()
408
- name = path.name.lower()
409
- if name in COMMON_EXCLUDED_DIRS:
410
- return "excluded_folder"
411
- if _is_hidden_path(path, root):
412
- return "hidden_folder"
413
- parts = _path_parts_lower(path)
414
- if os_type == "windows" and any(part in WINDOWS_EXCLUDED_NAMES for part in parts):
415
- return "system_folder"
416
- normalized = path.as_posix()
417
- root_normalized = root.as_posix() if root else ""
418
-
419
- def _prefix_blocks(prefixes: Tuple[str, ...]) -> bool:
420
- for prefix in prefixes:
421
- path_under_prefix = normalized == prefix or normalized.startswith(
422
- f"{prefix}/"
423
- )
424
- root_under_prefix = bool(root_normalized) and (
425
- root_normalized == prefix or root_normalized.startswith(f"{prefix}/")
426
- )
427
- if path_under_prefix and not root_under_prefix:
428
- return True
429
- return False
430
-
431
- if os_type == "macos":
432
- home_library = Path.home() / "Library"
433
- try:
434
- root_is_library = bool(root) and _is_relative_to(
435
- root.expanduser().resolve(), home_library.expanduser().resolve()
436
- )
437
- if (
438
- _is_relative_to(
439
- path.expanduser().resolve(), home_library.expanduser().resolve()
440
- )
441
- and not root_is_library
442
- ):
443
- return "user_library"
444
- except OSError:
445
- pass
446
- if _prefix_blocks(MACOS_EXCLUDED_PREFIXES):
447
- return "system_folder"
448
- if os_type == "linux":
449
- if _prefix_blocks(LINUX_EXCLUDED_PREFIXES):
450
- return "system_folder"
451
- return None
452
-
453
-
454
- def _sensitive_file_reason(path: Path, *, root: Optional[Path] = None) -> Optional[str]:
455
- name = path.name.lower()
456
- suffix = path.suffix.lower()
457
- if name in COMMON_EXCLUDED_FILE_NAMES or suffix in COMMON_EXCLUDED_FILE_SUFFIXES:
458
- return "sensitive_or_excluded_file"
459
- try:
460
- rel_text = (
461
- path.relative_to(root).as_posix().lower()
462
- if root
463
- else path.as_posix().lower()
464
- )
465
- except ValueError:
466
- rel_text = path.as_posix().lower()
467
- tokens = re.split(r"[^0-9a-zA-Z_가-힣]+", rel_text)
468
- if any(token in SENSITIVE_PATH_KEYWORDS for token in tokens):
469
- return "sensitive_name"
470
- return None
471
-
472
-
473
- def _root_warning(path: Path, os_type: str) -> Optional[str]:
474
- resolved = path.expanduser().resolve()
475
- home = Path.home().expanduser().resolve()
476
- if os_type == "macos" and resolved == home:
477
- return "홈 전체에는 설정/숨김 폴더가 포함될 수 있습니다. 문서, 데스크탑, 다운로드, 프로젝트 폴더부터 추가하는 것을 권장합니다."
478
- if os_type == "linux" and resolved.as_posix() == "/":
479
- return "루트 디렉터리에는 시스템 파일이 포함되어 있습니다. 일반 사용자 폴더나 마운트된 데이터 폴더를 권장합니다."
480
- if os_type == "windows" and str(resolved).rstrip("\\/").upper() in {"C:", "C:\\"}:
481
- return "C드라이브에는 Windows 시스템 파일과 앱 설정 파일이 포함되어 있습니다. 하위 폴더를 선택하는 것을 권장합니다."
482
- return None
483
-
484
-
485
- def _sample_file(
486
- path: Path, root: Path, status: str, reason: str = ""
487
- ) -> Dict[str, Any]:
488
- try:
489
- rel = path.relative_to(root).as_posix()
490
- except ValueError:
491
- rel = path.name
492
- try:
493
- stat = path.stat()
494
- size = stat.st_size if path.is_file() else None
495
- modified_at = _safe_iso_from_stat_mtime(stat.st_mtime)
496
- except OSError:
497
- size = None
498
- modified_at = ""
499
- return {
500
- "path": str(path),
501
- "relative_path": rel,
502
- "name": path.name,
503
- "extension": path.suffix.lower(),
504
- "status": status,
505
- "reason": reason,
506
- "size_bytes": size,
507
- "modified_at": modified_at,
508
- }
71
+ # Pure fs/path/hash/classification helpers → ._kg_fsutil (re-exported so the
72
+ # computed __all__ below still forwards them to the graph mixins).
73
+ from ._kg_fsutil import * # noqa: E402,F401,F403
509
74
 
510
75
 
511
76
  def _clean_text(text: str) -> str: