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.
- package/README.md +28 -39
- package/auto_setup.py +11 -62
- package/docs/CHANGELOG.md +76 -237
- package/docs/COMMUNITY_AND_PLUGINS.md +2 -2
- package/docs/DEVELOPMENT.md +8 -8
- package/docs/LEGACY_COMPATIBILITY.md +1 -1
- package/docs/ONBOARDING.md +2 -2
- package/docs/ROADMAP_RECOMMENDATIONS.md +61 -36
- package/docs/TRUST_MODEL.md +1 -1
- package/docs/WHY_LATTICE.md +2 -2
- package/docs/kg-schema.md +1 -1
- package/lattice_brain/__init__.py +1 -1
- package/lattice_brain/archive.py +4 -9
- package/lattice_brain/embeddings.py +38 -2
- package/lattice_brain/graph/_kg_common.py +27 -462
- package/lattice_brain/graph/_kg_constants.py +243 -0
- package/lattice_brain/graph/_kg_fsutil.py +297 -0
- package/lattice_brain/graph/discovery.py +0 -948
- package/lattice_brain/graph/discovery_index.py +972 -0
- package/lattice_brain/graph/retrieval.py +0 -570
- package/lattice_brain/graph/retrieval_docgen.py +210 -0
- package/lattice_brain/graph/retrieval_vector.py +460 -0
- package/lattice_brain/graph/store.py +6 -0
- package/lattice_brain/ingestion.py +68 -0
- package/lattice_brain/portability.py +1 -9
- package/lattice_brain/quality.py +98 -4
- package/lattice_brain/runtime/agent_runtime.py +166 -0
- package/lattice_brain/runtime/multi_agent.py +1 -1
- package/lattice_brain/utils.py +28 -0
- package/latticeai/__init__.py +1 -1
- package/latticeai/api/chat.py +340 -407
- package/latticeai/api/chat_helpers.py +227 -0
- package/latticeai/api/computer_use.py +149 -31
- package/latticeai/api/marketplace.py +11 -0
- package/latticeai/api/permissions.py +3 -3
- package/latticeai/api/tools.py +1 -0
- package/latticeai/app_factory.py +82 -360
- package/latticeai/core/io_utils.py +37 -0
- package/latticeai/core/legacy_compatibility.py +1 -1
- package/latticeai/core/local_embeddings.py +2 -4
- package/latticeai/core/marketplace.py +33 -2
- package/latticeai/core/mcp_catalog.py +450 -0
- package/latticeai/core/mcp_registry.py +2 -441
- package/latticeai/core/users.py +4 -9
- package/latticeai/core/workspace_os.py +1 -1
- package/latticeai/core/workspace_os_utils.py +3 -17
- package/latticeai/integrations/telegram_bot.py +7 -2
- package/latticeai/models/model_providers.py +111 -0
- package/latticeai/models/router.py +58 -136
- package/latticeai/runtime/audit_runtime.py +27 -16
- package/latticeai/runtime/automation_runtime.py +9 -0
- package/latticeai/runtime/history_runtime.py +163 -0
- package/latticeai/runtime/namespace_runtime.py +173 -0
- package/latticeai/runtime/network_config_runtime.py +56 -0
- package/latticeai/runtime/sso_config_runtime.py +128 -0
- package/latticeai/runtime/user_key_runtime.py +106 -0
- package/latticeai/services/architecture_readiness.py +2 -2
- package/latticeai/services/memory_service.py +213 -0
- package/latticeai/services/platform_runtime.py +9 -1
- package/latticeai/services/product_readiness.py +11 -11
- package/latticeai/services/review_queue.py +64 -11
- package/latticeai/services/run_executor.py +21 -0
- package/latticeai/services/setup_detection.py +80 -0
- package/latticeai/services/tool_dispatch.py +1 -1
- package/package.json +1 -1
- package/setup_wizard.py +11 -55
- package/src-tauri/Cargo.lock +1 -1
- package/src-tauri/Cargo.toml +1 -1
- package/src-tauri/tauri.conf.json +1 -1
- package/static/app/asset-manifest.json +11 -11
- package/static/app/assets/{Act-fZokUnC0.js → Act-21lIXx2E.js} +1 -1
- package/static/app/assets/Brain-BqUd5UJJ.js +321 -0
- package/static/app/assets/{Capture-D5KV3Cu7.js → Capture-BA7Z2Q1u.js} +1 -1
- package/static/app/assets/{Library-C9kyFkSt.js → Library-bFMtyni3.js} +1 -1
- package/static/app/assets/System-K6krGCqn.js +1 -0
- package/static/app/assets/index-C4R3ws30.js +17 -0
- package/static/app/assets/index-ChSeOB02.css +2 -0
- package/static/app/assets/primitives-sQU3it5I.js +1 -0
- package/static/app/assets/{textarea-CD8UNKIy.js → textarea-DK3Fd_lR.js} +1 -1
- package/static/app/index.html +2 -2
- package/static/css/tokens.css +4 -2
- package/static/sw.js +1 -1
- package/tools/local_files.py +6 -0
- package/latticeai/runtime/sso_runtime.py +0 -52
- package/static/app/assets/Brain-DtyuWubr.js +0 -321
- package/static/app/assets/System-VbChmX7r.js +0 -1
- package/static/app/assets/index-DCh5AoXt.css +0 -2
- package/static/app/assets/index-DPdcPoF0.js +0 -17
- package/static/app/assets/primitives-DFeanEV6.js +0 -1
|
@@ -271,6 +271,7 @@ class MemoryService:
|
|
|
271
271
|
memory_count = len(memory_ids) + len(snaps) + len(convs)
|
|
272
272
|
return {
|
|
273
273
|
"sources": sources,
|
|
274
|
+
"recent_memories": self._manager_recent_memories([*ws_mem, *project_mem], limit=8),
|
|
274
275
|
"tiers": list(TIERS),
|
|
275
276
|
"usage": {"total_items": total_items, "total_bytes": total_bytes, "sources": len(sources)},
|
|
276
277
|
"brain_readiness": self._brain_readiness(
|
|
@@ -284,6 +285,23 @@ class MemoryService:
|
|
|
284
285
|
"generated_at": _now(),
|
|
285
286
|
}
|
|
286
287
|
|
|
288
|
+
@staticmethod
|
|
289
|
+
def _manager_recent_memories(memories: List[Dict[str, Any]], *, limit: int = 8) -> List[Dict[str, Any]]:
|
|
290
|
+
rows: List[Dict[str, Any]] = []
|
|
291
|
+
for item in memories[: max(1, limit)]:
|
|
292
|
+
metadata = item.get("metadata") if isinstance(item.get("metadata"), dict) else {}
|
|
293
|
+
rows.append({
|
|
294
|
+
"id": item.get("id") or "",
|
|
295
|
+
"kind": item.get("kind") or "memory",
|
|
296
|
+
"content": str(item.get("content") or "")[:320],
|
|
297
|
+
"tags": item.get("tags") if isinstance(item.get("tags"), list) else [],
|
|
298
|
+
"metadata": metadata,
|
|
299
|
+
"workspace_id": item.get("workspace_id") or "personal",
|
|
300
|
+
"created_at": item.get("created_at"),
|
|
301
|
+
"updated_at": item.get("updated_at"),
|
|
302
|
+
})
|
|
303
|
+
return rows
|
|
304
|
+
|
|
287
305
|
def brain_quality_summary(self, *, user_email: Optional[str] = None, workspace_id: Optional[str] = None) -> Dict[str, Any]:
|
|
288
306
|
"""Return the backend-owned Brain readiness signal for API consumers."""
|
|
289
307
|
return self.manager(user_email=user_email, workspace_id=workspace_id)["brain_readiness"]
|
|
@@ -338,6 +356,22 @@ class MemoryService:
|
|
|
338
356
|
has_recall=bool(recall_items),
|
|
339
357
|
graph_concepts=graph_concepts,
|
|
340
358
|
)
|
|
359
|
+
suggested_questions = self._brain_brief_suggested_questions(
|
|
360
|
+
focus=focus,
|
|
361
|
+
has_durable_evidence=bool(proofs.get("has_durable_evidence")),
|
|
362
|
+
has_recall=bool(recall_items),
|
|
363
|
+
graph_concepts=graph_concepts,
|
|
364
|
+
conversations=conversations,
|
|
365
|
+
)
|
|
366
|
+
proactive_actions = self._brain_brief_proactive_actions(
|
|
367
|
+
focus=focus,
|
|
368
|
+
state=state,
|
|
369
|
+
has_durable_evidence=bool(proofs.get("has_durable_evidence")),
|
|
370
|
+
has_recall=bool(recall_items),
|
|
371
|
+
graph_concepts=graph_concepts,
|
|
372
|
+
vector_items=vector_items,
|
|
373
|
+
healthy_sources=healthy_sources,
|
|
374
|
+
)
|
|
341
375
|
return {
|
|
342
376
|
"status": state,
|
|
343
377
|
"score": int(readiness.get("score") or 0),
|
|
@@ -345,6 +379,8 @@ class MemoryService:
|
|
|
345
379
|
"body_key": f"brain.brief.body.{state if state in {'quiet', 'forming', 'alive'} else 'quiet'}",
|
|
346
380
|
"focus": focus,
|
|
347
381
|
"next_actions": actions,
|
|
382
|
+
"suggested_questions": suggested_questions,
|
|
383
|
+
"proactive_actions": proactive_actions,
|
|
348
384
|
"evidence": [
|
|
349
385
|
{
|
|
350
386
|
"id": "durable",
|
|
@@ -501,6 +537,183 @@ class MemoryService:
|
|
|
501
537
|
})
|
|
502
538
|
return sorted(actions, key=lambda item: int(item.get("priority") or 0), reverse=True)[:4]
|
|
503
539
|
|
|
540
|
+
@staticmethod
|
|
541
|
+
def _brain_brief_proactive_actions(
|
|
542
|
+
*,
|
|
543
|
+
focus: Dict[str, Any],
|
|
544
|
+
state: str,
|
|
545
|
+
has_durable_evidence: bool,
|
|
546
|
+
has_recall: bool,
|
|
547
|
+
graph_concepts: int,
|
|
548
|
+
vector_items: int,
|
|
549
|
+
healthy_sources: int,
|
|
550
|
+
) -> List[Dict[str, Any]]:
|
|
551
|
+
"""Return concrete, one-click actions Brain can proactively suggest."""
|
|
552
|
+
focus_title = str(focus.get("title") or "").strip() or "Brain"
|
|
553
|
+
focus_detail = str(focus.get("detail") or "").strip()
|
|
554
|
+
actions: List[Dict[str, Any]] = []
|
|
555
|
+
if not has_durable_evidence:
|
|
556
|
+
actions.append({
|
|
557
|
+
"id": "proactive_add_source",
|
|
558
|
+
"intent": "route",
|
|
559
|
+
"label_key": "brain.proactive.addSource.label",
|
|
560
|
+
"detail_key": "brain.proactive.addSource.detail",
|
|
561
|
+
"route": "/capture",
|
|
562
|
+
"prompt": "Add a useful source to my Brain and explain what it learned.",
|
|
563
|
+
"priority": 100,
|
|
564
|
+
})
|
|
565
|
+
actions.append({
|
|
566
|
+
"id": "proactive_seed_memory",
|
|
567
|
+
"intent": "ask",
|
|
568
|
+
"label_key": "brain.proactive.seed.label",
|
|
569
|
+
"detail_key": "brain.proactive.seed.detail",
|
|
570
|
+
"prompt": "Help me seed my Brain with the most useful personal context to remember.",
|
|
571
|
+
"priority": 90,
|
|
572
|
+
})
|
|
573
|
+
return actions
|
|
574
|
+
|
|
575
|
+
if has_recall:
|
|
576
|
+
actions.append({
|
|
577
|
+
"id": "proactive_evidence_review",
|
|
578
|
+
"intent": "ask",
|
|
579
|
+
"label_key": "brain.proactive.evidence.label",
|
|
580
|
+
"detail_key": "brain.proactive.evidence.detail",
|
|
581
|
+
"prompt": (
|
|
582
|
+
f"Review the evidence Brain has for {focus_title}. "
|
|
583
|
+
"Separate confirmed facts, weak signals, contradictions, and next checks."
|
|
584
|
+
),
|
|
585
|
+
"priority": 100,
|
|
586
|
+
"context": {"focus": focus_title, "detail": focus_detail},
|
|
587
|
+
})
|
|
588
|
+
actions.append({
|
|
589
|
+
"id": "proactive_delegate",
|
|
590
|
+
"intent": "delegate",
|
|
591
|
+
"label_key": "brain.proactive.delegate.label",
|
|
592
|
+
"detail_key": "brain.proactive.delegate.detail",
|
|
593
|
+
"prompt": (
|
|
594
|
+
f"Turn {focus_title} into an execution plan, verify the known context, "
|
|
595
|
+
"and return concrete next steps with risks."
|
|
596
|
+
),
|
|
597
|
+
"priority": 95,
|
|
598
|
+
"context": {"focus": focus_title, "detail": focus_detail},
|
|
599
|
+
})
|
|
600
|
+
actions.append({
|
|
601
|
+
"id": "proactive_review_draft",
|
|
602
|
+
"intent": "review",
|
|
603
|
+
"label_key": "brain.proactive.review.label",
|
|
604
|
+
"detail_key": "brain.proactive.review.detail",
|
|
605
|
+
"prompt": (
|
|
606
|
+
f"Create a reviewable task from Brain's current focus: {focus_title}. "
|
|
607
|
+
f"{focus_detail[:240]}"
|
|
608
|
+
).strip(),
|
|
609
|
+
"priority": 90,
|
|
610
|
+
"context": {"focus": focus_title, "detail": focus_detail},
|
|
611
|
+
})
|
|
612
|
+
|
|
613
|
+
if graph_concepts > 0:
|
|
614
|
+
actions.append({
|
|
615
|
+
"id": "proactive_map_connections",
|
|
616
|
+
"intent": "route",
|
|
617
|
+
"label_key": "brain.proactive.map.label",
|
|
618
|
+
"detail_key": "brain.proactive.map.detail",
|
|
619
|
+
"route": "/knowledge-graph",
|
|
620
|
+
"prompt": f"Map the strongest Knowledge Graph connections around {focus_title}.",
|
|
621
|
+
"priority": 82,
|
|
622
|
+
"context": {"focus": focus_title, "graph_concepts": graph_concepts},
|
|
623
|
+
})
|
|
624
|
+
|
|
625
|
+
if state == "alive" and vector_items > 0 and healthy_sources > 0:
|
|
626
|
+
actions.append({
|
|
627
|
+
"id": "proactive_weekly_brief",
|
|
628
|
+
"intent": "review",
|
|
629
|
+
"label_key": "brain.proactive.weekly.label",
|
|
630
|
+
"detail_key": "brain.proactive.weekly.detail",
|
|
631
|
+
"prompt": (
|
|
632
|
+
"Prepare a weekly Brain review: what changed, what decisions are pending, "
|
|
633
|
+
"what should be delegated, and what evidence is stale."
|
|
634
|
+
),
|
|
635
|
+
"priority": 78,
|
|
636
|
+
"context": {"vector_items": vector_items, "healthy_sources": healthy_sources},
|
|
637
|
+
})
|
|
638
|
+
|
|
639
|
+
return sorted(actions, key=lambda item: int(item.get("priority") or 0), reverse=True)[:4]
|
|
640
|
+
|
|
641
|
+
@staticmethod
|
|
642
|
+
def _brain_brief_suggested_questions(
|
|
643
|
+
*,
|
|
644
|
+
focus: Dict[str, Any],
|
|
645
|
+
has_durable_evidence: bool,
|
|
646
|
+
has_recall: bool,
|
|
647
|
+
graph_concepts: int,
|
|
648
|
+
conversations: int,
|
|
649
|
+
) -> List[Dict[str, Any]]:
|
|
650
|
+
"""Return reusable, localized UI prompt descriptors for the Brain home."""
|
|
651
|
+
focus_title = str(focus.get("title") or "").strip()
|
|
652
|
+
focus_kind = str(focus.get("kind") or "empty")
|
|
653
|
+
questions: List[Dict[str, Any]] = []
|
|
654
|
+
|
|
655
|
+
if not has_durable_evidence or focus_kind == "empty":
|
|
656
|
+
questions.extend([
|
|
657
|
+
{
|
|
658
|
+
"id": "start_brain",
|
|
659
|
+
"label_key": "brain.suggestion.start.label",
|
|
660
|
+
"detail_key": "brain.suggestion.start.detail",
|
|
661
|
+
"prompt_key": "brain.suggestion.start.prompt",
|
|
662
|
+
"params": {},
|
|
663
|
+
"priority": 10,
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
"id": "add_context",
|
|
667
|
+
"label_key": "brain.suggestion.context.label",
|
|
668
|
+
"detail_key": "brain.suggestion.context.detail",
|
|
669
|
+
"prompt_key": "brain.suggestion.context.prompt",
|
|
670
|
+
"params": {},
|
|
671
|
+
"priority": 9,
|
|
672
|
+
},
|
|
673
|
+
])
|
|
674
|
+
return questions
|
|
675
|
+
|
|
676
|
+
questions.append({
|
|
677
|
+
"id": "focus_next",
|
|
678
|
+
"label_key": "brain.suggestion.focus.label",
|
|
679
|
+
"detail_key": "brain.suggestion.focus.detail",
|
|
680
|
+
"prompt_key": "brain.suggestion.focus.prompt",
|
|
681
|
+
"params": {"focus": focus_title or "Brain"},
|
|
682
|
+
"priority": 10,
|
|
683
|
+
})
|
|
684
|
+
|
|
685
|
+
if has_recall:
|
|
686
|
+
questions.append({
|
|
687
|
+
"id": "evidence_check",
|
|
688
|
+
"label_key": "brain.suggestion.evidence.label",
|
|
689
|
+
"detail_key": "brain.suggestion.evidence.detail",
|
|
690
|
+
"prompt_key": "brain.suggestion.evidence.prompt",
|
|
691
|
+
"params": {"focus": focus_title or "this topic"},
|
|
692
|
+
"priority": 9,
|
|
693
|
+
})
|
|
694
|
+
|
|
695
|
+
if graph_concepts > 0:
|
|
696
|
+
questions.append({
|
|
697
|
+
"id": "graph_connections",
|
|
698
|
+
"label_key": "brain.suggestion.graph.label",
|
|
699
|
+
"detail_key": "brain.suggestion.graph.detail",
|
|
700
|
+
"prompt_key": "brain.suggestion.graph.prompt",
|
|
701
|
+
"params": {"focus": focus_title or "Knowledge Graph"},
|
|
702
|
+
"priority": 8,
|
|
703
|
+
})
|
|
704
|
+
|
|
705
|
+
if conversations > 0:
|
|
706
|
+
questions.append({
|
|
707
|
+
"id": "conversation_followup",
|
|
708
|
+
"label_key": "brain.suggestion.history.label",
|
|
709
|
+
"detail_key": "brain.suggestion.history.detail",
|
|
710
|
+
"prompt_key": "brain.suggestion.history.prompt",
|
|
711
|
+
"params": {"focus": focus_title or "recent conversations"},
|
|
712
|
+
"priority": 7,
|
|
713
|
+
})
|
|
714
|
+
|
|
715
|
+
return sorted(questions, key=lambda item: int(item.get("priority") or 0), reverse=True)[:4]
|
|
716
|
+
|
|
504
717
|
def brain_proof(
|
|
505
718
|
self,
|
|
506
719
|
*,
|
|
@@ -144,7 +144,15 @@ class PlatformRuntime:
|
|
|
144
144
|
def provider(goal: str):
|
|
145
145
|
try:
|
|
146
146
|
mems = self.store.search_memories(goal, user_email=user, workspace_id=scope).get("memories", [])
|
|
147
|
-
|
|
147
|
+
ctx = [str(m.get("content") or "")[:180] for m in mems[:6]]
|
|
148
|
+
# Enrich with agent-synthesis memories preferentially for self-improving Brain feel
|
|
149
|
+
try:
|
|
150
|
+
allm = self.store.list_memories(user_email=user, workspace_id=scope).get("memories", [])
|
|
151
|
+
synth = [str(m.get("content") or "")[:160] for m in allm if "agent-synthesis" in (m.get("tags") or [])][:3]
|
|
152
|
+
ctx = synth + ctx
|
|
153
|
+
except Exception:
|
|
154
|
+
pass
|
|
155
|
+
return ctx[:8]
|
|
148
156
|
except Exception:
|
|
149
157
|
return []
|
|
150
158
|
return provider
|
|
@@ -18,7 +18,7 @@ from typing import Any, Dict, List
|
|
|
18
18
|
|
|
19
19
|
from latticeai.services.architecture_readiness import architecture_readiness
|
|
20
20
|
|
|
21
|
-
PRODUCT_VERSION_TARGET = "
|
|
21
|
+
PRODUCT_VERSION_TARGET = "9.0.0"
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@dataclass(frozen=True)
|
|
@@ -76,10 +76,10 @@ PRODUCT_GATES: List[ProductGate] = [
|
|
|
76
76
|
evidence=[
|
|
77
77
|
"package.json::release:artifacts",
|
|
78
78
|
"package.json::release:validate",
|
|
79
|
-
"README.md::dist/ltcai-
|
|
80
|
-
"README.md::dist/ltcai-
|
|
81
|
-
"README.md::dist/ltcai-
|
|
82
|
-
"README.md::ltcai-
|
|
79
|
+
"README.md::dist/ltcai-9.0.0-py3-none-any.whl",
|
|
80
|
+
"README.md::dist/ltcai-9.0.0.tar.gz",
|
|
81
|
+
"README.md::dist/ltcai-9.0.0.vsix",
|
|
82
|
+
"README.md::ltcai-9.0.0.tgz",
|
|
83
83
|
"scripts/validate_release_artifacts.py",
|
|
84
84
|
"scripts/release_smoke.py",
|
|
85
85
|
"Dockerfile",
|
|
@@ -95,12 +95,12 @@ PRODUCT_GATES: List[ProductGate] = [
|
|
|
95
95
|
title="Release story is documented and honest",
|
|
96
96
|
evidence=[
|
|
97
97
|
"README.md",
|
|
98
|
-
"README.md::The current release is **
|
|
99
|
-
"SECURITY.md::
|
|
100
|
-
"vscode-extension/README.md::**
|
|
101
|
-
"docs/CHANGELOG.md::## [
|
|
98
|
+
"README.md::The current release is **9.0.0",
|
|
99
|
+
"SECURITY.md::9.0.x (latest)",
|
|
100
|
+
"vscode-extension/README.md::**9.0.0",
|
|
101
|
+
"docs/CHANGELOG.md::## [9.0.0]",
|
|
102
102
|
"FEATURE_STATUS.md",
|
|
103
|
-
"
|
|
103
|
+
"RELEASE_NOTES_v9.0.0.md",
|
|
104
104
|
"latticeai/core/agent.py::SingleAgentRuntime",
|
|
105
105
|
"latticeai/core/agent.py::AgentRuntime = SingleAgentRuntime",
|
|
106
106
|
"lattice_brain/runtime/contracts.py::runtime-boundary/v1",
|
|
@@ -115,7 +115,7 @@ PRODUCT_GATES: List[ProductGate] = [
|
|
|
115
115
|
id="ecosystem-path",
|
|
116
116
|
title="Community and plugin growth path is explicit",
|
|
117
117
|
evidence=[
|
|
118
|
-
"docs/COMMUNITY_AND_PLUGINS.md::
|
|
118
|
+
"docs/COMMUNITY_AND_PLUGINS.md::9.0.0",
|
|
119
119
|
"docs/PLUGIN_SDK.md",
|
|
120
120
|
"plugins/README.md",
|
|
121
121
|
"plugins/hello-world/plugin.json",
|
|
@@ -21,12 +21,14 @@ from __future__ import annotations
|
|
|
21
21
|
from datetime import datetime
|
|
22
22
|
from typing import Any, Callable, Dict, Optional
|
|
23
23
|
|
|
24
|
+
from latticeai.core.io_utils import parse_iso as _parse_iso
|
|
25
|
+
|
|
24
26
|
# status: terminal vs. open. Open items can still be acted on.
|
|
25
27
|
OPEN_STATUSES = {"pending", "snoozed"}
|
|
26
28
|
TERMINAL_STATUSES = {"approved", "dismissed"}
|
|
27
29
|
ALL_STATUSES = OPEN_STATUSES | TERMINAL_STATUSES
|
|
28
30
|
|
|
29
|
-
REVIEW_SOURCES = frozenset({"workflow_run", "trigger", "kg_change_digest"})
|
|
31
|
+
REVIEW_SOURCES = frozenset({"workflow_run", "trigger", "kg_change_digest", "chat_followup", "agent_followup"})
|
|
30
32
|
|
|
31
33
|
# Which source statuses each action is allowed from.
|
|
32
34
|
_ALLOWED_FROM: Dict[str, set] = {
|
|
@@ -59,15 +61,6 @@ class InvalidReviewTransition(Exception):
|
|
|
59
61
|
super().__init__(f"cannot {action!r} a review item in status {status!r}")
|
|
60
62
|
|
|
61
63
|
|
|
62
|
-
def _parse_iso(value: Optional[str]) -> Optional[datetime]:
|
|
63
|
-
if not value:
|
|
64
|
-
return None
|
|
65
|
-
try:
|
|
66
|
-
return datetime.fromisoformat(str(value))
|
|
67
|
-
except (TypeError, ValueError):
|
|
68
|
-
return None
|
|
69
|
-
|
|
70
|
-
|
|
71
64
|
class ReviewQueueService:
|
|
72
65
|
"""Policy layer over the store's workspace-scoped ``review_items``."""
|
|
73
66
|
|
|
@@ -122,7 +115,20 @@ class ReviewQueueService:
|
|
|
122
115
|
|
|
123
116
|
# ── transitions ──────────────────────────────────────────────────────
|
|
124
117
|
def approve(self, item_id: str, *, workspace_id: Optional[str] = None) -> Dict[str, Any]:
|
|
125
|
-
|
|
118
|
+
item = self._store.get_review_item(item_id, workspace_id=workspace_id)
|
|
119
|
+
self._guard("approve", item)
|
|
120
|
+
payload = dict(item.get("payload") or {})
|
|
121
|
+
provenance = dict(item.get("provenance") or {})
|
|
122
|
+
promoted = self._promote_agent_followup(item, workspace_id=workspace_id)
|
|
123
|
+
if promoted:
|
|
124
|
+
payload["promoted_workflow_id"] = promoted.get("id")
|
|
125
|
+
provenance["workflow_id"] = promoted.get("id")
|
|
126
|
+
provenance["promotion"] = "workflow_draft"
|
|
127
|
+
patch: Dict[str, Any] = {"status": "approved", "payload": payload, "provenance": provenance}
|
|
128
|
+
if item.get("snoozed_until") is not None:
|
|
129
|
+
patch["snoozed_until"] = None
|
|
130
|
+
updated = self._store.update_review_item(item_id, workspace_id=workspace_id, **patch)
|
|
131
|
+
return self._view(updated)
|
|
126
132
|
|
|
127
133
|
def dismiss(self, item_id: str, *, workspace_id: Optional[str] = None) -> Dict[str, Any]:
|
|
128
134
|
return self._transition(item_id, "dismiss", "dismissed", workspace_id=workspace_id)
|
|
@@ -210,6 +216,53 @@ class ReviewQueueService:
|
|
|
210
216
|
view["effective_status"] = self._effective_status(item)
|
|
211
217
|
return view
|
|
212
218
|
|
|
219
|
+
def _promote_agent_followup(self, item: Dict[str, Any], *, workspace_id: Optional[str]) -> Optional[Dict[str, Any]]:
|
|
220
|
+
if item.get("source") != "agent_followup" or not hasattr(self._store, "create_workflow"):
|
|
221
|
+
return None
|
|
222
|
+
payload = dict(item.get("payload") or {})
|
|
223
|
+
followup = str(payload.get("followup") or item.get("title") or "").strip()
|
|
224
|
+
if not followup:
|
|
225
|
+
return None
|
|
226
|
+
goal = str(payload.get("goal") or item.get("summary") or followup).strip()
|
|
227
|
+
nodes = [
|
|
228
|
+
{
|
|
229
|
+
"id": "trigger",
|
|
230
|
+
"type": "trigger",
|
|
231
|
+
"config": {"trigger": "manual", "review_queue": False},
|
|
232
|
+
"next": "agent",
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"id": "agent",
|
|
236
|
+
"type": "agent",
|
|
237
|
+
"config": {
|
|
238
|
+
"goal": followup,
|
|
239
|
+
"roles": ["planner", "executor", "reviewer"],
|
|
240
|
+
"source": "agent_followup",
|
|
241
|
+
},
|
|
242
|
+
"next": "output",
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"id": "output",
|
|
246
|
+
"type": "output",
|
|
247
|
+
"config": {"format": "review_followup"},
|
|
248
|
+
"next": None,
|
|
249
|
+
},
|
|
250
|
+
]
|
|
251
|
+
return self._store.create_workflow(
|
|
252
|
+
name=f"Follow-up: {str(item.get('title') or followup)[:96]}",
|
|
253
|
+
steps=[{"action": "agent", "goal": followup}],
|
|
254
|
+
nodes=nodes,
|
|
255
|
+
metadata={
|
|
256
|
+
"source": "review_center",
|
|
257
|
+
"review_item_id": item.get("id"),
|
|
258
|
+
"agent_followup": followup,
|
|
259
|
+
"goal": goal,
|
|
260
|
+
"draft": True,
|
|
261
|
+
},
|
|
262
|
+
user_email=item.get("user_email"),
|
|
263
|
+
workspace_id=workspace_id or item.get("workspace_id"),
|
|
264
|
+
)
|
|
265
|
+
|
|
213
266
|
|
|
214
267
|
def enqueue_from_automation(
|
|
215
268
|
sink: "ReviewQueueService",
|
|
@@ -129,6 +129,27 @@ class RunExecutor:
|
|
|
129
129
|
self._cancel_agent_record(run_id, handle.scope, "cancelled after the final result was persisted")
|
|
130
130
|
else:
|
|
131
131
|
self._results[run_id] = payload
|
|
132
|
+
except Exception as exc:
|
|
133
|
+
try:
|
|
134
|
+
run = self.store.get_agent_run(run_id, workspace_id=handle.scope)
|
|
135
|
+
timeline = list(run.get("timeline") or [])
|
|
136
|
+
timeline.append({"event": "execution_failed", "status": "failed", "detail": str(exc), "timestamp": _now()})
|
|
137
|
+
failed = self.store.update_agent_run(
|
|
138
|
+
run_id,
|
|
139
|
+
workspace_id=handle.scope,
|
|
140
|
+
status="failed",
|
|
141
|
+
current_role=None,
|
|
142
|
+
output_text=str(exc),
|
|
143
|
+
timeline=timeline,
|
|
144
|
+
graph=self.workspace_graph(),
|
|
145
|
+
)
|
|
146
|
+
self._results[run_id] = {"run": failed, "result": {"status": "failed", "error": str(exc)}}
|
|
147
|
+
except Exception:
|
|
148
|
+
self._results[run_id] = {"run": {"id": run_id, "status": "failed"}, "result": {"status": "failed", "error": str(exc)}}
|
|
149
|
+
try:
|
|
150
|
+
self.append_audit_event("agent_run_failed", user_email=user_email, run_id=run_id, error=str(exc))
|
|
151
|
+
except Exception:
|
|
152
|
+
pass
|
|
132
153
|
finally:
|
|
133
154
|
self._handles.pop(run_id, None)
|
|
134
155
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""Shared setup/environment detection helpers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import re
|
|
7
|
+
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
WhichFn = Callable[[str], Optional[str]]
|
|
11
|
+
RunFn = Callable[[List[str]], str]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def parse_windows_video_controllers(raw: str) -> List[Dict[str, Any]]:
|
|
15
|
+
controllers: List[Dict[str, Any]] = []
|
|
16
|
+
if not raw:
|
|
17
|
+
return controllers
|
|
18
|
+
try:
|
|
19
|
+
data = json.loads(raw)
|
|
20
|
+
if isinstance(data, dict):
|
|
21
|
+
data = [data]
|
|
22
|
+
if isinstance(data, list):
|
|
23
|
+
for item in data:
|
|
24
|
+
name = str(item.get("Name") or "").strip()
|
|
25
|
+
if not name:
|
|
26
|
+
continue
|
|
27
|
+
try:
|
|
28
|
+
ram_mb = int(item.get("AdapterRAM") or 0) // (1024 * 1024)
|
|
29
|
+
except Exception:
|
|
30
|
+
ram_mb = 0
|
|
31
|
+
controllers.append({"name": name, "vram_mb": ram_mb})
|
|
32
|
+
if controllers:
|
|
33
|
+
return controllers
|
|
34
|
+
except Exception:
|
|
35
|
+
pass
|
|
36
|
+
current: Dict[str, Any] = {}
|
|
37
|
+
for line in raw.splitlines():
|
|
38
|
+
if line.startswith("Name="):
|
|
39
|
+
if current:
|
|
40
|
+
controllers.append(current)
|
|
41
|
+
current = {"name": line.split("=", 1)[-1].strip(), "vram_mb": 0}
|
|
42
|
+
elif line.startswith("AdapterRAM=") and current:
|
|
43
|
+
try:
|
|
44
|
+
current["vram_mb"] = int(line.split("=", 1)[-1].strip()) // (1024 * 1024)
|
|
45
|
+
except ValueError:
|
|
46
|
+
current["vram_mb"] = 0
|
|
47
|
+
if current:
|
|
48
|
+
controllers.append(current)
|
|
49
|
+
return controllers
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def detect_cuda(which: WhichFn, run: RunFn) -> Tuple[bool, str, Optional[str], Optional[str]]:
|
|
53
|
+
nvidia_smi = which("nvidia-smi")
|
|
54
|
+
nvcc = which("nvcc")
|
|
55
|
+
version = ""
|
|
56
|
+
if nvidia_smi:
|
|
57
|
+
raw = run([nvidia_smi, "--query-gpu=driver_version", "--format=csv,noheader"])
|
|
58
|
+
version = raw.splitlines()[0].strip() if raw.splitlines() else ""
|
|
59
|
+
if nvcc:
|
|
60
|
+
raw = run([nvcc, "--version"])
|
|
61
|
+
match = re.search(r"release\s+([\d.]+)", raw)
|
|
62
|
+
if match:
|
|
63
|
+
version = match.group(1)
|
|
64
|
+
return bool(nvidia_smi or nvcc), version, nvidia_smi, nvcc
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def detect_wsl_from_text(prof_os: str, raw: str) -> Tuple[bool, str]:
|
|
68
|
+
if prof_os.lower() != "linux":
|
|
69
|
+
return False, ""
|
|
70
|
+
lowered = (raw or "").lower()
|
|
71
|
+
is_wsl = "microsoft" in lowered or "wsl" in lowered
|
|
72
|
+
version = "2" if "microsoft-standard" in lowered or "wsl2" in lowered else ("1" if is_wsl else "")
|
|
73
|
+
return is_wsl, version
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def detect_tools(which: WhichFn, binaries: Iterable[str]) -> Dict[str, Optional[str]]:
|
|
77
|
+
return {binary: which(binary) for binary in binaries}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
__all__ = ["detect_cuda", "detect_tools", "detect_wsl_from_text", "parse_windows_video_controllers"]
|
package/package.json
CHANGED
package/setup_wizard.py
CHANGED
|
@@ -28,6 +28,12 @@ from latticeai.services.process_audit import (
|
|
|
28
28
|
command_plan_for_commands,
|
|
29
29
|
require_command_confirmation,
|
|
30
30
|
)
|
|
31
|
+
from latticeai.services.setup_detection import (
|
|
32
|
+
detect_cuda,
|
|
33
|
+
detect_tools,
|
|
34
|
+
detect_wsl_from_text,
|
|
35
|
+
parse_windows_video_controllers as _parse_windows_video_controllers,
|
|
36
|
+
)
|
|
31
37
|
|
|
32
38
|
# ── Helpers ───────────────────────────────────────────────────────────────────
|
|
33
39
|
|
|
@@ -411,43 +417,6 @@ def _detect_disk_free_gb() -> float:
|
|
|
411
417
|
return 0.0
|
|
412
418
|
|
|
413
419
|
|
|
414
|
-
def _parse_windows_video_controllers(raw: str) -> List[Dict[str, Any]]:
|
|
415
|
-
controllers: List[Dict[str, Any]] = []
|
|
416
|
-
if not raw:
|
|
417
|
-
return controllers
|
|
418
|
-
try:
|
|
419
|
-
data = _json.loads(raw)
|
|
420
|
-
if isinstance(data, dict):
|
|
421
|
-
data = [data]
|
|
422
|
-
if isinstance(data, list):
|
|
423
|
-
for item in data:
|
|
424
|
-
name = str(item.get("Name") or "").strip()
|
|
425
|
-
try:
|
|
426
|
-
ram_mb = int(item.get("AdapterRAM") or 0) // (1024 * 1024)
|
|
427
|
-
except Exception:
|
|
428
|
-
ram_mb = 0
|
|
429
|
-
if name:
|
|
430
|
-
controllers.append({"name": name, "vram_mb": ram_mb})
|
|
431
|
-
if controllers:
|
|
432
|
-
return controllers
|
|
433
|
-
except Exception:
|
|
434
|
-
pass
|
|
435
|
-
current: Dict[str, Any] = {}
|
|
436
|
-
for line in raw.splitlines():
|
|
437
|
-
if line.startswith("Name="):
|
|
438
|
-
if current:
|
|
439
|
-
controllers.append(current)
|
|
440
|
-
current = {"name": line.split("=", 1)[-1].strip(), "vram_mb": 0}
|
|
441
|
-
elif line.startswith("AdapterRAM=") and current:
|
|
442
|
-
try:
|
|
443
|
-
current["vram_mb"] = int(line.split("=", 1)[-1].strip()) // (1024 * 1024)
|
|
444
|
-
except ValueError:
|
|
445
|
-
current["vram_mb"] = 0
|
|
446
|
-
if current:
|
|
447
|
-
controllers.append(current)
|
|
448
|
-
return controllers
|
|
449
|
-
|
|
450
|
-
|
|
451
420
|
def _detect_gpu() -> Dict[str, Any]:
|
|
452
421
|
devices: List[Dict[str, Any]] = []
|
|
453
422
|
nvidia_smi = _which_any("nvidia-smi")
|
|
@@ -514,37 +483,24 @@ def _detect_gpu() -> Dict[str, Any]:
|
|
|
514
483
|
|
|
515
484
|
|
|
516
485
|
def _detect_cuda() -> Dict[str, Any]:
|
|
517
|
-
nvidia_smi = _which_any(
|
|
518
|
-
|
|
519
|
-
version = ""
|
|
520
|
-
if nvidia_smi:
|
|
521
|
-
raw = _cmd([nvidia_smi, "--query-gpu=driver_version", "--format=csv,noheader"], timeout=5)
|
|
522
|
-
version = raw.splitlines()[0].strip() if raw.splitlines() else ""
|
|
523
|
-
if nvcc:
|
|
524
|
-
raw = _cmd([nvcc, "--version"], timeout=5)
|
|
525
|
-
m = re.search(r"release\s+([\d.]+)", raw)
|
|
526
|
-
if m:
|
|
527
|
-
version = m.group(1)
|
|
528
|
-
return {"available": bool(nvidia_smi or nvcc), "nvidia_smi": nvidia_smi, "nvcc": nvcc, "version": version}
|
|
486
|
+
available, version, nvidia_smi, nvcc = detect_cuda(_which_any, lambda args: _cmd(args, timeout=5))
|
|
487
|
+
return {"available": available, "nvidia_smi": nvidia_smi, "nvcc": nvcc, "version": version}
|
|
529
488
|
|
|
530
489
|
|
|
531
490
|
def _detect_wsl() -> Dict[str, Any]:
|
|
532
|
-
if platform.system() != "Linux":
|
|
533
|
-
return {"is_wsl": False, "version": ""}
|
|
534
491
|
raw = ""
|
|
535
492
|
try:
|
|
536
493
|
raw = Path("/proc/version").read_text(encoding="utf-8", errors="replace")
|
|
537
494
|
except Exception:
|
|
538
495
|
pass
|
|
539
|
-
is_wsl =
|
|
540
|
-
version = "2" if "microsoft-standard" in raw.lower() or "wsl2" in raw.lower() else ("1" if is_wsl else "")
|
|
496
|
+
is_wsl, version = detect_wsl_from_text(platform.system().lower(), raw)
|
|
541
497
|
return {"is_wsl": is_wsl, "version": version}
|
|
542
498
|
|
|
543
499
|
|
|
544
500
|
def _detect_tools() -> Dict[str, bool]:
|
|
545
501
|
repair_path_for()
|
|
546
|
-
|
|
547
|
-
|
|
502
|
+
detected = detect_tools(_which_any, ["brew", "ollama", "python3", "python", "node", "npm", "git", "tesseract", "lms", "nvidia-smi", "nvcc"])
|
|
503
|
+
return {tool: path is not None for tool, path in detected.items()}
|
|
548
504
|
|
|
549
505
|
def _detect_mlx() -> Dict[str, Any]:
|
|
550
506
|
return {
|
package/src-tauri/Cargo.lock
CHANGED