closecode 0.1.0__py3-none-any.whl
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.
- closecode/__init__.py +4 -0
- closecode/__main__.py +6 -0
- closecode/agent/__init__.py +79 -0
- closecode/app.py +691 -0
- closecode/auth.py +22 -0
- closecode/config.py +97 -0
- closecode/llmesh/__init__.py +91 -0
- closecode/llmesh/client.py +221 -0
- closecode/llmesh/streaming.py +47 -0
- closecode/py.typed +0 -0
- closecode/sessions.py +176 -0
- closecode/ui/__init__.py +1 -0
- closecode/ui/screens/__init__.py +1 -0
- closecode/ui/screens/main.py +125 -0
- closecode/ui/screens/onboarding.py +101 -0
- closecode/ui/theme.tcss +374 -0
- closecode/ui/widgets/__init__.py +1 -0
- closecode/ui/widgets/chat.py +105 -0
- closecode/ui/widgets/composer.py +52 -0
- closecode/ui/widgets/header.py +53 -0
- closecode/ui/widgets/infopanel.py +101 -0
- closecode/ui/widgets/statusbar.py +60 -0
- closecode-0.1.0.dist-info/METADATA +404 -0
- closecode-0.1.0.dist-info/RECORD +28 -0
- closecode-0.1.0.dist-info/WHEEL +5 -0
- closecode-0.1.0.dist-info/entry_points.txt +2 -0
- closecode-0.1.0.dist-info/licenses/LICENSE +21 -0
- closecode-0.1.0.dist-info/top_level.txt +1 -0
closecode/__init__.py
ADDED
closecode/__main__.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""Agent state — core state model for Close Code.
|
|
2
|
+
|
|
3
|
+
Simplified: just tracks connection, model, messages, and streaming status.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from enum import Enum
|
|
9
|
+
from typing import List, Dict, Any
|
|
10
|
+
from dataclasses import dataclass, field
|
|
11
|
+
from datetime import datetime
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AgentStatus(Enum):
|
|
15
|
+
"""What Close Code is currently doing."""
|
|
16
|
+
IDLE = "idle"
|
|
17
|
+
STREAMING = "streaming"
|
|
18
|
+
FAILED = "failed"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass
|
|
22
|
+
class ChatMessage:
|
|
23
|
+
"""A single chat message."""
|
|
24
|
+
role: str # user | assistant | system
|
|
25
|
+
content: str
|
|
26
|
+
timestamp: datetime = field(default_factory=datetime.now)
|
|
27
|
+
model: str = ""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class AgentState:
|
|
32
|
+
"""Complete state — single source of truth.
|
|
33
|
+
|
|
34
|
+
The Textual UI observes this and renders accordingly.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
# Status
|
|
38
|
+
status: AgentStatus = AgentStatus.IDLE
|
|
39
|
+
status_message: str = ""
|
|
40
|
+
|
|
41
|
+
# Model
|
|
42
|
+
model: str = ""
|
|
43
|
+
provider: str = ""
|
|
44
|
+
|
|
45
|
+
# Connection
|
|
46
|
+
connected: bool = False
|
|
47
|
+
|
|
48
|
+
# Conversation
|
|
49
|
+
messages: List[ChatMessage] = field(default_factory=list)
|
|
50
|
+
|
|
51
|
+
# Context estimate
|
|
52
|
+
context_used: int = 0
|
|
53
|
+
context_total: int = 128_000
|
|
54
|
+
|
|
55
|
+
def add_message(self, role: str, content: str, **kwargs) -> ChatMessage:
|
|
56
|
+
"""Add a message to the conversation."""
|
|
57
|
+
msg = ChatMessage(role=role, content=content, **kwargs)
|
|
58
|
+
self.messages.append(msg)
|
|
59
|
+
return msg
|
|
60
|
+
|
|
61
|
+
def get_messages_for_api(self, system_prompt: str = "") -> List[Dict[str, str]]:
|
|
62
|
+
"""Build the message list for the LLMesh API."""
|
|
63
|
+
api_msgs = []
|
|
64
|
+
if system_prompt:
|
|
65
|
+
api_msgs.append({"role": "system", "content": system_prompt})
|
|
66
|
+
for msg in self.messages:
|
|
67
|
+
if msg.role in ("user", "assistant", "system"):
|
|
68
|
+
api_msgs.append({"role": msg.role, "content": msg.content})
|
|
69
|
+
return api_msgs
|
|
70
|
+
|
|
71
|
+
def clear_conversation(self):
|
|
72
|
+
"""Clear messages but keep model state."""
|
|
73
|
+
self.messages.clear()
|
|
74
|
+
self.context_used = 0
|
|
75
|
+
self.status = AgentStatus.IDLE
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def message_count(self) -> int:
|
|
79
|
+
return len(self.messages)
|