velune-cli 0.9.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.
Files changed (279) hide show
  1. velune/__init__.py +5 -0
  2. velune/__main__.py +6 -0
  3. velune/cli/__init__.py +5 -0
  4. velune/cli/app.py +208 -0
  5. velune/cli/autocomplete.py +80 -0
  6. velune/cli/banner.py +60 -0
  7. velune/cli/commands/__init__.py +32 -0
  8. velune/cli/commands/ask.py +175 -0
  9. velune/cli/commands/base.py +16 -0
  10. velune/cli/commands/chat.py +228 -0
  11. velune/cli/commands/config.py +224 -0
  12. velune/cli/commands/daemon.py +88 -0
  13. velune/cli/commands/doctor.py +721 -0
  14. velune/cli/commands/init.py +170 -0
  15. velune/cli/commands/mcp.py +82 -0
  16. velune/cli/commands/memory.py +293 -0
  17. velune/cli/commands/models.py +683 -0
  18. velune/cli/commands/preflight.py +95 -0
  19. velune/cli/commands/run.py +270 -0
  20. velune/cli/commands/setup.py +184 -0
  21. velune/cli/commands/workspace.py +249 -0
  22. velune/cli/context.py +36 -0
  23. velune/cli/councilmodel_ui.py +199 -0
  24. velune/cli/display/council_view.py +254 -0
  25. velune/cli/display/memory_view.py +126 -0
  26. velune/cli/display/panels.py +35 -0
  27. velune/cli/display/progress.py +25 -0
  28. velune/cli/display/themes.py +25 -0
  29. velune/cli/main.py +15 -0
  30. velune/cli/model_selector.py +51 -0
  31. velune/cli/modes.py +86 -0
  32. velune/cli/pull_ui.py +123 -0
  33. velune/cli/registry.py +80 -0
  34. velune/cli/rendering/__init__.py +5 -0
  35. velune/cli/rendering/error_panel.py +79 -0
  36. velune/cli/rendering/markdown.py +63 -0
  37. velune/cli/repl.py +1855 -0
  38. velune/cli/session_manager.py +71 -0
  39. velune/cli/slash_commands.py +37 -0
  40. velune/cli/theme.py +8 -0
  41. velune/cognition/__init__.py +23 -0
  42. velune/cognition/agents/__init__.py +7 -0
  43. velune/cognition/agents/coder.py +209 -0
  44. velune/cognition/agents/planner.py +156 -0
  45. velune/cognition/agents/reviewer.py +195 -0
  46. velune/cognition/arbitrator.py +220 -0
  47. velune/cognition/architecture.py +415 -0
  48. velune/cognition/budget.py +65 -0
  49. velune/cognition/council/__init__.py +47 -0
  50. velune/cognition/council/base.py +217 -0
  51. velune/cognition/council/challenger.py +74 -0
  52. velune/cognition/council/coder.py +79 -0
  53. velune/cognition/council/critic_agent.py +43 -0
  54. velune/cognition/council/critic_configs.py +111 -0
  55. velune/cognition/council/critics.py +41 -0
  56. velune/cognition/council/debate.py +46 -0
  57. velune/cognition/council/factory.py +140 -0
  58. velune/cognition/council/messages.py +56 -0
  59. velune/cognition/council/planner.py +124 -0
  60. velune/cognition/council/reviewer.py +74 -0
  61. velune/cognition/council/synthesizer.py +67 -0
  62. velune/cognition/council/tiers.py +188 -0
  63. velune/cognition/council_orchestrator.py +282 -0
  64. velune/cognition/firewall.py +354 -0
  65. velune/cognition/module.py +46 -0
  66. velune/cognition/orchestrator.py +1205 -0
  67. velune/cognition/personality.py +238 -0
  68. velune/cognition/state.py +104 -0
  69. velune/cognition/style_resolver.py +64 -0
  70. velune/cognition/verification.py +205 -0
  71. velune/context/__init__.py +28 -0
  72. velune/context/assembler.py +240 -0
  73. velune/context/budget.py +97 -0
  74. velune/context/extractive.py +95 -0
  75. velune/context/prompt_adaptation.py +480 -0
  76. velune/context/sections.py +99 -0
  77. velune/context/token_counter.py +134 -0
  78. velune/context/utilization.py +33 -0
  79. velune/context/window.py +63 -0
  80. velune/core/__init__.py +89 -0
  81. velune/core/background.py +5 -0
  82. velune/core/config/__init__.py +37 -0
  83. velune/core/errors/__init__.py +90 -0
  84. velune/core/errors/catalog.py +188 -0
  85. velune/core/errors/execution.py +31 -0
  86. velune/core/errors/memory.py +25 -0
  87. velune/core/errors/orchestration.py +31 -0
  88. velune/core/errors/provider.py +37 -0
  89. velune/core/event_loop.py +35 -0
  90. velune/core/logging.py +83 -0
  91. velune/core/paths.py +165 -0
  92. velune/core/runtime.py +113 -0
  93. velune/core/startup_profiler.py +56 -0
  94. velune/core/task_registry.py +117 -0
  95. velune/core/trace.py +83 -0
  96. velune/core/types/__init__.py +48 -0
  97. velune/core/types/agent.py +53 -0
  98. velune/core/types/context.py +42 -0
  99. velune/core/types/inference.py +38 -0
  100. velune/core/types/memory.py +42 -0
  101. velune/core/types/model.py +70 -0
  102. velune/core/types/provider.py +62 -0
  103. velune/core/types/repository.py +38 -0
  104. velune/core/types/task.py +61 -0
  105. velune/core/types/workspace.py +28 -0
  106. velune/daemon/client.py +13 -0
  107. velune/daemon/server.py +127 -0
  108. velune/daemon/transport.py +179 -0
  109. velune/events.py +204 -0
  110. velune/execution/__init__.py +22 -0
  111. velune/execution/benchmarker.py +315 -0
  112. velune/execution/cancellation.py +53 -0
  113. velune/execution/checkpointer.py +130 -0
  114. velune/execution/command_spec.py +165 -0
  115. velune/execution/diff_preview.py +197 -0
  116. velune/execution/executor.py +181 -0
  117. velune/execution/module.py +18 -0
  118. velune/execution/multi_diff.py +67 -0
  119. velune/execution/path_guard.py +74 -0
  120. velune/execution/planner.py +91 -0
  121. velune/execution/rollback.py +89 -0
  122. velune/execution/sandbox.py +268 -0
  123. velune/execution/validator.py +115 -0
  124. velune/hardware/__init__.py +1 -0
  125. velune/hardware/detector.py +192 -0
  126. velune/kernel/__init__.py +55 -0
  127. velune/kernel/bootstrap.py +125 -0
  128. velune/kernel/config.py +426 -0
  129. velune/kernel/entrypoint.py +78 -0
  130. velune/kernel/health.py +54 -0
  131. velune/kernel/lifecycle.py +143 -0
  132. velune/kernel/module.py +17 -0
  133. velune/kernel/modules.py +23 -0
  134. velune/kernel/registry.py +96 -0
  135. velune/kernel/schemas.py +28 -0
  136. velune/main.py +9 -0
  137. velune/mcp/__init__.py +9 -0
  138. velune/mcp/client.py +115 -0
  139. velune/mcp/config.py +19 -0
  140. velune/mcp/server.py +624 -0
  141. velune/memory/__init__.py +32 -0
  142. velune/memory/compaction.py +506 -0
  143. velune/memory/embedding_pipeline.py +241 -0
  144. velune/memory/lifecycle.py +680 -0
  145. velune/memory/module.py +218 -0
  146. velune/memory/prioritizer.py +67 -0
  147. velune/memory/storage/episodic_schema.sql +53 -0
  148. velune/memory/storage/lancedb_store.py +282 -0
  149. velune/memory/storage/sqlite_manager.py +369 -0
  150. velune/memory/storage/sqlite_pool.py +149 -0
  151. velune/memory/tiers/episodic.py +588 -0
  152. velune/memory/tiers/graph.py +378 -0
  153. velune/memory/tiers/lineage.py +416 -0
  154. velune/memory/tiers/semantic.py +475 -0
  155. velune/memory/tiers/working.py +168 -0
  156. velune/memory/vitality.py +132 -0
  157. velune/models/__init__.py +15 -0
  158. velune/models/family.py +76 -0
  159. velune/models/module.py +20 -0
  160. velune/models/probes.py +192 -0
  161. velune/models/profile_cache.py +84 -0
  162. velune/models/profiler.py +108 -0
  163. velune/models/registry.py +251 -0
  164. velune/models/scorer.py +233 -0
  165. velune/models/specializations.py +205 -0
  166. velune/orchestration/__init__.py +19 -0
  167. velune/orchestration/engine.py +239 -0
  168. velune/orchestration/module.py +15 -0
  169. velune/orchestration/role_assignments.py +82 -0
  170. velune/orchestration/schemas.py +98 -0
  171. velune/plugins/__init__.py +20 -0
  172. velune/plugins/hooks.py +50 -0
  173. velune/plugins/loader.py +161 -0
  174. velune/plugins/registry.py +56 -0
  175. velune/plugins/schemas.py +21 -0
  176. velune/providers/__init__.py +23 -0
  177. velune/providers/adapters/anthropic.py +257 -0
  178. velune/providers/adapters/fireworks.py +115 -0
  179. velune/providers/adapters/google.py +234 -0
  180. velune/providers/adapters/groq.py +151 -0
  181. velune/providers/adapters/huggingface.py +210 -0
  182. velune/providers/adapters/llamacpp.py +208 -0
  183. velune/providers/adapters/lmstudio.py +175 -0
  184. velune/providers/adapters/ollama.py +233 -0
  185. velune/providers/adapters/openai.py +213 -0
  186. velune/providers/adapters/openrouter.py +81 -0
  187. velune/providers/adapters/together.py +134 -0
  188. velune/providers/adapters/xai.py +60 -0
  189. velune/providers/base.py +86 -0
  190. velune/providers/benchmarker.py +138 -0
  191. velune/providers/discovery/__init__.py +33 -0
  192. velune/providers/discovery/anthropic.py +79 -0
  193. velune/providers/discovery/benchmarks.py +44 -0
  194. velune/providers/discovery/classifier.py +69 -0
  195. velune/providers/discovery/fireworks.py +95 -0
  196. velune/providers/discovery/gguf.py +88 -0
  197. velune/providers/discovery/google.py +95 -0
  198. velune/providers/discovery/gpu.py +117 -0
  199. velune/providers/discovery/groq.py +21 -0
  200. velune/providers/discovery/huggingface.py +67 -0
  201. velune/providers/discovery/lmstudio.py +80 -0
  202. velune/providers/discovery/ollama.py +162 -0
  203. velune/providers/discovery/openai.py +96 -0
  204. velune/providers/discovery/openrouter.py +113 -0
  205. velune/providers/discovery/scanner.py +115 -0
  206. velune/providers/discovery/together.py +114 -0
  207. velune/providers/discovery/xai.py +57 -0
  208. velune/providers/health.py +67 -0
  209. velune/providers/health_monitor.py +169 -0
  210. velune/providers/keystore.py +142 -0
  211. velune/providers/local_paths.py +49 -0
  212. velune/providers/local_resolver.py +229 -0
  213. velune/providers/module.py +51 -0
  214. velune/providers/ollama_manager.py +193 -0
  215. velune/providers/registry.py +220 -0
  216. velune/providers/router.py +255 -0
  217. velune/providers/task_classifier.py +288 -0
  218. velune/py.typed +0 -0
  219. velune/repository/__init__.py +33 -0
  220. velune/repository/analyzer.py +127 -0
  221. velune/repository/ast_parser.py +822 -0
  222. velune/repository/blast_radius.py +298 -0
  223. velune/repository/boundary_classifier.py +295 -0
  224. velune/repository/cognition.py +316 -0
  225. velune/repository/grapher.py +179 -0
  226. velune/repository/import_graph.py +263 -0
  227. velune/repository/incremental_indexer.py +275 -0
  228. velune/repository/index_state.py +96 -0
  229. velune/repository/indexer.py +243 -0
  230. velune/repository/module.py +17 -0
  231. velune/repository/parser.py +474 -0
  232. velune/repository/project_type.py +300 -0
  233. velune/repository/rename_journal.py +287 -0
  234. velune/repository/scanner.py +193 -0
  235. velune/repository/schemas.py +102 -0
  236. velune/repository/symbol_registry.py +365 -0
  237. velune/repository/tracker.py +252 -0
  238. velune/retrieval/__init__.py +27 -0
  239. velune/retrieval/cache.py +110 -0
  240. velune/retrieval/fast_path.py +391 -0
  241. velune/retrieval/graph.py +124 -0
  242. velune/retrieval/hybrid.py +271 -0
  243. velune/retrieval/keyword.py +131 -0
  244. velune/retrieval/module.py +26 -0
  245. velune/retrieval/pipeline.py +303 -0
  246. velune/retrieval/reranker.py +102 -0
  247. velune/retrieval/schemas.py +59 -0
  248. velune/retrieval/slow_path.py +364 -0
  249. velune/retrieval/vector.py +203 -0
  250. velune/telemetry/__init__.py +59 -0
  251. velune/telemetry/cognition.py +267 -0
  252. velune/telemetry/cost_estimator.py +92 -0
  253. velune/telemetry/debug.py +304 -0
  254. velune/telemetry/doctor.py +244 -0
  255. velune/telemetry/logging.py +286 -0
  256. velune/telemetry/spans.py +277 -0
  257. velune/telemetry/token_tracker.py +140 -0
  258. velune/telemetry/usage_tracker.py +340 -0
  259. velune/tools/__init__.py +41 -0
  260. velune/tools/base/registry.py +87 -0
  261. velune/tools/base/tool.py +63 -0
  262. velune/tools/code/navigate.py +116 -0
  263. velune/tools/code/search.py +123 -0
  264. velune/tools/filesystem/read.py +75 -0
  265. velune/tools/filesystem/search.py +136 -0
  266. velune/tools/filesystem/write.py +163 -0
  267. velune/tools/git/history.py +177 -0
  268. velune/tools/git/operations.py +122 -0
  269. velune/tools/git/state.py +121 -0
  270. velune/tools/module.py +81 -0
  271. velune/tools/terminal/execute.py +72 -0
  272. velune/tools/terminal/history.py +47 -0
  273. velune/tools/web/fetch.py +55 -0
  274. velune/tools/web/validator.py +122 -0
  275. velune_cli-0.9.0.dist-info/METADATA +518 -0
  276. velune_cli-0.9.0.dist-info/RECORD +279 -0
  277. velune_cli-0.9.0.dist-info/WHEEL +4 -0
  278. velune_cli-0.9.0.dist-info/entry_points.txt +2 -0
  279. velune_cli-0.9.0.dist-info/licenses/LICENSE +201 -0
velune/core/trace.py ADDED
@@ -0,0 +1,83 @@
1
+ """Structured tracing utilities for distributed execution and agent deliberation in Velune."""
2
+
3
+ import contextvars
4
+ import logging
5
+ from typing import Any
6
+
7
+ _run_id: contextvars.ContextVar[str | None] = contextvars.ContextVar("run_id", default=None)
8
+ _agent_id: contextvars.ContextVar[str | None] = contextvars.ContextVar("agent_id", default=None)
9
+ _step_id: contextvars.ContextVar[str | None] = contextvars.ContextVar("step_id", default=None)
10
+
11
+
12
+ class TraceContext:
13
+ """Context manager to manage the active run, agent, and step trace ids in context variables."""
14
+
15
+ def __init__(
16
+ self, run_id: str, agent_id: str | None = None, step_id: str | None = None
17
+ ) -> None:
18
+ self._tokens: list[contextvars.Token[str | None]] = []
19
+ self.run_id = run_id
20
+ self.agent_id = agent_id
21
+ self.step_id = step_id
22
+
23
+ def __enter__(self) -> "TraceContext":
24
+ self._tokens = [
25
+ _run_id.set(self.run_id),
26
+ _agent_id.set(self.agent_id),
27
+ _step_id.set(self.step_id),
28
+ ]
29
+ return self
30
+
31
+ def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
32
+ for tok in self._tokens:
33
+ tok.var.reset(tok)
34
+
35
+
36
+ def get_trace_prefix() -> str:
37
+ """Generate the structured trace prefix string from active context variables."""
38
+ import os
39
+
40
+ if os.environ.get("VELUNE_LOG_FORMAT", "").lower() == "json":
41
+ return ""
42
+ parts = []
43
+ if r := _run_id.get():
44
+ parts.append(f"run={r[:8]}")
45
+ if a := _agent_id.get():
46
+ parts.append(f"agent={a}")
47
+ if s := _step_id.get():
48
+ parts.append(f"step={s}")
49
+ return "[" + " ".join(parts) + "] " if parts else ""
50
+
51
+
52
+ class TracedLogger:
53
+ """Logger wrapper that prepends trace context to all messages."""
54
+
55
+ def __init__(self, name: str | logging.Logger) -> None:
56
+ if isinstance(name, str):
57
+ self._logger = logging.getLogger(name)
58
+ else:
59
+ self._logger = name
60
+
61
+ def info(self, msg: Any, *args: Any, **kwargs: Any) -> None:
62
+ self._logger.info(get_trace_prefix() + str(msg), *args, **kwargs)
63
+
64
+ def warning(self, msg: Any, *args: Any, **kwargs: Any) -> None:
65
+ self._logger.warning(get_trace_prefix() + str(msg), *args, **kwargs)
66
+
67
+ def error(self, msg: Any, *args: Any, **kwargs: Any) -> None:
68
+ self._logger.error(get_trace_prefix() + str(msg), *args, **kwargs)
69
+
70
+ def debug(self, msg: Any, *args: Any, **kwargs: Any) -> None:
71
+ self._logger.debug(get_trace_prefix() + str(msg), *args, **kwargs)
72
+
73
+ def exception(self, msg: Any, *args: Any, **kwargs: Any) -> None:
74
+ self._logger.exception(get_trace_prefix() + str(msg), *args, **kwargs)
75
+
76
+ def critical(self, msg: Any, *args: Any, **kwargs: Any) -> None:
77
+ self._logger.critical(get_trace_prefix() + str(msg), *args, **kwargs)
78
+
79
+ def log(self, level: int, msg: Any, *args: Any, **kwargs: Any) -> None:
80
+ self._logger.log(level, get_trace_prefix() + str(msg), *args, **kwargs)
81
+
82
+ def __getattr__(self, name: str) -> Any:
83
+ return getattr(self._logger, name)
@@ -0,0 +1,48 @@
1
+ """Core type definitions."""
2
+
3
+ from velune.core.types.agent import AgentMessage, AgentMessageType, AgentResult, AgentRole
4
+ from velune.core.types.context import ContextChunk, ContextPriority, ContextWindow
5
+ from velune.core.types.inference import InferenceRequest, InferenceResponse, StreamChunk
6
+ from velune.core.types.memory import MemoryQuery, MemoryRecord, MemoryType
7
+ from velune.core.types.model import (
8
+ CapabilityLevel,
9
+ ModelCapability,
10
+ ModelCapabilityProfile,
11
+ ModelDescriptor,
12
+ )
13
+ from velune.core.types.provider import ProviderCapabilities, ProviderConfig
14
+ from velune.core.types.repository import DependencyEdge, FileNode, SymbolNode
15
+ from velune.core.types.task import Task, TaskPlan, TaskResult, TaskStatus, TaskStep
16
+ from velune.core.types.workspace import WorkspaceEvent, WorkspaceState
17
+
18
+ __all__ = [
19
+ "AgentRole",
20
+ "AgentMessage",
21
+ "AgentMessageType",
22
+ "AgentResult",
23
+ "ContextPriority",
24
+ "ContextChunk",
25
+ "ContextWindow",
26
+ "InferenceRequest",
27
+ "StreamChunk",
28
+ "InferenceResponse",
29
+ "MemoryType",
30
+ "MemoryRecord",
31
+ "MemoryQuery",
32
+ "CapabilityLevel",
33
+ "ModelCapability",
34
+ "ModelCapabilityProfile",
35
+ "ModelDescriptor",
36
+ "ProviderConfig",
37
+ "ProviderCapabilities",
38
+ "FileNode",
39
+ "SymbolNode",
40
+ "DependencyEdge",
41
+ "TaskStatus",
42
+ "Task",
43
+ "TaskStep",
44
+ "TaskPlan",
45
+ "TaskResult",
46
+ "WorkspaceState",
47
+ "WorkspaceEvent",
48
+ ]
@@ -0,0 +1,53 @@
1
+ """Core agent type definitions."""
2
+
3
+ from enum import StrEnum
4
+ from typing import Any
5
+
6
+ from pydantic import BaseModel, Field
7
+
8
+
9
+ class AgentRole(StrEnum):
10
+ """Agent role definitions."""
11
+
12
+ PLANNER = "planner"
13
+ CODER = "coder"
14
+ REASONER = "reasoner"
15
+ REVIEWER = "reviewer"
16
+ DEBUGGER = "debugger"
17
+ SUMMARIZER = "summarizer"
18
+ RETRIEVER = "retriever"
19
+ SUPERVISOR = "supervisor"
20
+
21
+
22
+ class AgentMessageType(StrEnum):
23
+ """Typed message protocol for agent communication."""
24
+
25
+ TASK_REQUEST = "task_request"
26
+ TASK_RESPONSE = "task_response"
27
+ STATUS_UPDATE = "status_update"
28
+ ERROR_REPORT = "error_report"
29
+ QUERY = "query"
30
+ RESPONSE = "response"
31
+ CONTROL = "control"
32
+
33
+
34
+ class AgentMessage(BaseModel):
35
+ """Typed message for inter-agent communication."""
36
+
37
+ message_type: AgentMessageType
38
+ sender: str
39
+ recipient: str
40
+ content: Any
41
+ timestamp: float
42
+ correlation_id: str | None = None
43
+ metadata: dict[str, Any] = Field(default_factory=dict)
44
+
45
+
46
+ class AgentResult(BaseModel):
47
+ """Result from agent execution."""
48
+
49
+ success: bool
50
+ output: Any | None = None
51
+ error: str | None = None
52
+ metadata: dict[str, Any] = Field(default_factory=dict)
53
+ execution_time_ms: float | None = None
@@ -0,0 +1,42 @@
1
+ """Core context type definitions."""
2
+
3
+ from enum import StrEnum
4
+ from typing import Any
5
+
6
+ from pydantic import BaseModel, Field
7
+
8
+
9
+ class ContextPriority(StrEnum):
10
+ """Context chunk priority levels."""
11
+
12
+ CRITICAL = "critical"
13
+ HIGH = "high"
14
+ MEDIUM = "medium"
15
+ LOW = "low"
16
+
17
+
18
+ class ContextChunk(BaseModel):
19
+ """A chunk of context with metadata."""
20
+
21
+ content: str
22
+ source: str
23
+ priority: ContextPriority
24
+ tokens: int
25
+ relevance_score: float = Field(ge=0.0, le=1.0)
26
+ timestamp: float
27
+ metadata: dict[str, Any] = Field(default_factory=dict)
28
+
29
+
30
+ class ContextWindow(BaseModel):
31
+ """The assembled context window for inference."""
32
+
33
+ chunks: list[ContextChunk]
34
+ total_tokens: int
35
+ max_tokens: int
36
+ compression_ratio: float = Field(ge=0.0, le=1.0)
37
+ metadata: dict[str, Any] = Field(default_factory=dict)
38
+
39
+ @property
40
+ def utilization(self) -> float:
41
+ """Calculate context window utilization."""
42
+ return self.total_tokens / self.max_tokens if self.max_tokens > 0 else 0.0
@@ -0,0 +1,38 @@
1
+ """Core inference type definitions."""
2
+
3
+ from typing import Any
4
+
5
+ from pydantic import BaseModel, Field
6
+
7
+
8
+ class InferenceRequest(BaseModel):
9
+ """Request for model inference."""
10
+
11
+ model_id: str
12
+ messages: list[dict[str, str]]
13
+ temperature: float = Field(default=0.7, ge=0.0, le=2.0)
14
+ max_tokens: int | None = None
15
+ top_p: float = Field(default=1.0, ge=0.0, le=1.0)
16
+ stop_sequences: list[str] | None = None
17
+ metadata: dict[str, Any] = Field(default_factory=dict)
18
+
19
+
20
+ class StreamChunk(BaseModel):
21
+ """A chunk of streamed inference response."""
22
+
23
+ content: str
24
+ finish_reason: str | None = None
25
+ metadata: dict[str, Any] = Field(default_factory=dict)
26
+
27
+
28
+ class InferenceResponse(BaseModel):
29
+ """Response from model inference."""
30
+
31
+ content: str
32
+ model_id: str
33
+ finish_reason: str
34
+ tokens_used: int
35
+ latency_ms: float
36
+ prompt_tokens: int = 0
37
+ completion_tokens: int = 0
38
+ metadata: dict[str, Any] = Field(default_factory=dict)
@@ -0,0 +1,42 @@
1
+ """Core memory type definitions."""
2
+
3
+ from datetime import datetime
4
+ from enum import StrEnum
5
+ from typing import Any
6
+
7
+ from pydantic import BaseModel, Field
8
+
9
+
10
+ class MemoryType(StrEnum):
11
+ """Types of memory records."""
12
+
13
+ WORKING = "working"
14
+ EPISODIC = "episodic"
15
+ SEMANTIC = "semantic"
16
+ PROCEDURAL = "procedural"
17
+ GRAPH = "graph"
18
+
19
+
20
+ class MemoryRecord(BaseModel):
21
+ """A memory record."""
22
+
23
+ id: str
24
+ memory_type: MemoryType
25
+ content: str
26
+ embedding: list[float] | None = None
27
+ importance: float = Field(ge=0.0, le=1.0)
28
+ access_count: int = 0
29
+ last_accessed: datetime
30
+ created_at: datetime
31
+ expires_at: datetime | None = None
32
+ metadata: dict[str, Any] = Field(default_factory=dict)
33
+
34
+
35
+ class MemoryQuery(BaseModel):
36
+ """Query for memory retrieval."""
37
+
38
+ query_text: str
39
+ memory_types: list[MemoryType] = Field(default_factory=list)
40
+ limit: int = Field(default=10, ge=1, le=100)
41
+ min_importance: float = Field(default=0.0, ge=0.0, le=1.0)
42
+ metadata_filter: dict[str, Any] = Field(default_factory=dict)
@@ -0,0 +1,70 @@
1
+ """Core model type definitions."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from enum import IntEnum, StrEnum
6
+ from typing import Any, Literal
7
+
8
+ from pydantic import BaseModel, ConfigDict, Field
9
+
10
+
11
+ class ModelCapability(StrEnum):
12
+ """Capability categories used by the model router and classifiers."""
13
+
14
+ CODE_GENERATION = "code_generation"
15
+ CODE_ANALYSIS = "code_analysis"
16
+ REASONING = "reasoning"
17
+ PLANNING = "planning"
18
+ TOOL_USE = "tool_use"
19
+ DEBUGGING = "debugging"
20
+ REFACTORING = "refactoring"
21
+ SUMMARIZATION = "summarization"
22
+ RETRIEVAL = "retrieval"
23
+ MULTILINGUAL = "multilingual"
24
+ EMBEDDING = "embedding"
25
+ LONG_CONTEXT = "long_context"
26
+
27
+
28
+ class CapabilityLevel(IntEnum):
29
+ """Capability proficiency levels."""
30
+
31
+ NONE = 0
32
+ BASIC = 25
33
+ INTERMEDIATE = 50
34
+ ADVANCED = 75
35
+ EXPERT = 100
36
+
37
+
38
+ class ModelCapabilityProfile(BaseModel):
39
+ """Capability profile for a model."""
40
+
41
+ coding: CapabilityLevel = CapabilityLevel.NONE
42
+ reasoning: CapabilityLevel = CapabilityLevel.NONE
43
+ planning: CapabilityLevel = CapabilityLevel.NONE
44
+ summarization: CapabilityLevel = CapabilityLevel.NONE
45
+ embedding: CapabilityLevel = CapabilityLevel.NONE
46
+ instruction_following: CapabilityLevel = CapabilityLevel.NONE
47
+ multimodal: CapabilityLevel = CapabilityLevel.NONE
48
+ tool_use: CapabilityLevel = CapabilityLevel.NONE
49
+ long_context: CapabilityLevel = CapabilityLevel.NONE
50
+
51
+
52
+ class ModelDescriptor(BaseModel):
53
+ """Descriptor for a model."""
54
+
55
+ model_config = ConfigDict(extra="allow")
56
+
57
+ model_id: str
58
+ provider_id: str
59
+ display_name: str
60
+ context_length: int
61
+ capabilities: Any
62
+ is_local: bool = False
63
+ quantization: str | None = None # e.g. "Q4_K_M", "Q8_0"
64
+ vram_required_gb: float | None = None
65
+ parameter_count_b: float | None = None
66
+ speed_tier: Literal["fast", "medium", "slow"] = "medium"
67
+ cost_per_1k_tokens: float | None = None # None for local models
68
+ tags: list[str] = Field(default_factory=list)
69
+ metadata: dict[str, Any] = Field(default_factory=dict)
70
+ family: str | None = None # Model family for prompt adaptation (e.g., "qwen", "claude")
@@ -0,0 +1,62 @@
1
+ """Core provider type definitions."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass, field
6
+ from enum import StrEnum
7
+ from typing import Any
8
+
9
+ from pydantic import BaseModel, Field
10
+
11
+
12
+ class ProviderHealth(StrEnum):
13
+ """Provider health status."""
14
+
15
+ HEALTHY = "healthy"
16
+ DEGRADED = "degraded"
17
+ UNAVAILABLE = "unavailable"
18
+ UNKNOWN = "unknown"
19
+
20
+
21
+ class ProviderConfig(BaseModel):
22
+ """Configuration for a provider."""
23
+
24
+ name: str
25
+ base_url: str
26
+ api_key: str | None = None
27
+ api_key_env: str | None = None
28
+ timeout: int = Field(default=30, ge=1)
29
+ max_retries: int = Field(default=3, ge=0)
30
+ metadata: dict[str, Any] = Field(default_factory=dict)
31
+
32
+
33
+ class ProviderCapabilities(BaseModel):
34
+ """Capabilities offered by a provider."""
35
+
36
+ supports_streaming: bool = False
37
+ supports_function_calling: bool = False
38
+ supports_embeddings: bool = False
39
+ max_context_window: int | None = None
40
+ rate_limit_rpm: int | None = None
41
+ rate_limit_tpm: int | None = None
42
+
43
+
44
+ @dataclass
45
+ class CapabilityManifest:
46
+ """Real-time capability and health manifest for a provider."""
47
+
48
+ provider_id: str
49
+ health: ProviderHealth
50
+ available_models: list[Any]
51
+ rate_limit_remaining: int | None = None
52
+ rate_limit_reset_at: float | None = None
53
+ estimated_latency_ms: int = 0
54
+ supports_streaming: bool = False
55
+ supports_tools: bool = False
56
+ is_online: bool = True
57
+ refreshed_at: float = field(default_factory=lambda: __import__("time").time())
58
+
59
+ @property
60
+ def is_available(self) -> bool:
61
+ """True if provider is not unavailable."""
62
+ return self.health != ProviderHealth.UNAVAILABLE
@@ -0,0 +1,38 @@
1
+ """Core repository type definitions."""
2
+
3
+ from typing import Any
4
+
5
+ from pydantic import BaseModel, Field
6
+
7
+
8
+ class FileNode(BaseModel):
9
+ """A file node in the repository."""
10
+
11
+ path: str
12
+ language: str | None = None
13
+ size_bytes: int
14
+ last_modified: float
15
+ is_ignored: bool = False
16
+ metadata: dict[str, Any] = Field(default_factory=dict)
17
+
18
+
19
+ class SymbolNode(BaseModel):
20
+ """A symbol node (function, class, variable) in the repository."""
21
+
22
+ name: str
23
+ kind: str # function, class, variable, etc.
24
+ file_path: str
25
+ line_start: int
26
+ line_end: int
27
+ parent: str | None = None
28
+ children: list[str] = Field(default_factory=list)
29
+ metadata: dict[str, Any] = Field(default_factory=dict)
30
+
31
+
32
+ class DependencyEdge(BaseModel):
33
+ """A dependency edge between nodes."""
34
+
35
+ source: str
36
+ target: str
37
+ edge_type: str # import, call, inheritance, etc.
38
+ metadata: dict[str, Any] = Field(default_factory=dict)
@@ -0,0 +1,61 @@
1
+ """Core task type definitions."""
2
+
3
+ from enum import StrEnum
4
+ from typing import Any
5
+
6
+ from pydantic import BaseModel, Field
7
+
8
+
9
+ class TaskStatus(StrEnum):
10
+ """Task execution status."""
11
+
12
+ PENDING = "pending"
13
+ IN_PROGRESS = "in_progress"
14
+ COMPLETED = "completed"
15
+ FAILED = "failed"
16
+ CANCELLED = "cancelled"
17
+
18
+
19
+ class Task(BaseModel):
20
+ """A task to be executed."""
21
+
22
+ id: str
23
+ description: str
24
+ status: TaskStatus = TaskStatus.PENDING
25
+ priority: int = Field(default=5, ge=1, le=10)
26
+ dependencies: list[str] = Field(default_factory=list)
27
+ metadata: dict[str, Any] = Field(default_factory=dict)
28
+
29
+
30
+ class TaskStep(BaseModel):
31
+ """A step within a task plan."""
32
+
33
+ id: str
34
+ description: str
35
+ agent_role: str
36
+ status: TaskStatus = TaskStatus.PENDING
37
+ dependencies: list[str] = Field(default_factory=list)
38
+ estimated_duration_ms: int | None = None
39
+ metadata: dict[str, Any] = Field(default_factory=dict)
40
+
41
+
42
+ class TaskPlan(BaseModel):
43
+ """A plan for executing a task."""
44
+
45
+ task_id: str
46
+ steps: list[TaskStep]
47
+ estimated_duration_ms: int | None = None
48
+ metadata: dict[str, Any] = Field(default_factory=dict)
49
+
50
+
51
+ class TaskResult(BaseModel):
52
+ """Result from task execution."""
53
+
54
+ task_id: str
55
+ success: bool
56
+ output: Any | None = None
57
+ error: str | None = None
58
+ steps_completed: int
59
+ steps_total: int
60
+ execution_time_ms: float
61
+ metadata: dict[str, Any] = Field(default_factory=dict)
@@ -0,0 +1,28 @@
1
+ """Core workspace type definitions."""
2
+
3
+ from datetime import datetime
4
+ from enum import StrEnum
5
+ from typing import Any
6
+
7
+ from pydantic import BaseModel, Field
8
+
9
+
10
+ class WorkspaceState(StrEnum):
11
+ """Workspace state machine states."""
12
+
13
+ IDLE = "idle"
14
+ TASK_ACTIVE = "task_active"
15
+ DEBUGGING = "debugging"
16
+ REVIEWING = "reviewing"
17
+ INDEXING = "indexing"
18
+ ERROR = "error"
19
+
20
+
21
+ class WorkspaceEvent(BaseModel):
22
+ """An event in the workspace."""
23
+
24
+ event_type: str
25
+ timestamp: datetime
26
+ source: str
27
+ data: dict[str, Any] = Field(default_factory=dict)
28
+ metadata: dict[str, Any] = Field(default_factory=dict)
@@ -0,0 +1,13 @@
1
+ from velune.daemon.transport import IpcClient, get_ipc_address
2
+
3
+
4
+ class DaemonClient:
5
+ """Thin client for communicating with Velune daemon."""
6
+
7
+ @staticmethod
8
+ def is_running() -> bool:
9
+ return IpcClient.is_running(get_ipc_address())
10
+
11
+ @staticmethod
12
+ async def send_command(command: str, **kwargs) -> dict:
13
+ return await IpcClient.send_command(get_ipc_address(), command, **kwargs)