deja-cli 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.
- deja/__init__.py +0 -0
- deja/config.py +127 -0
- deja/core/__init__.py +0 -0
- deja/core/extractor.py +135 -0
- deja/core/reflection.py +364 -0
- deja/core/scheduler.py +65 -0
- deja/core/store.py +1413 -0
- deja/ingest/__init__.py +0 -0
- deja/ingest/watchers/__init__.py +0 -0
- deja/ingest/watchers/base.py +143 -0
- deja/ingest/watchers/claude_code.py +62 -0
- deja/ingest/watchers/codex_cli.py +95 -0
- deja/ingest/watchers/gemini_cli.py +96 -0
- deja/interfaces/__init__.py +0 -0
- deja/interfaces/cli.py +1967 -0
- deja/interfaces/mcp_server.py +96 -0
- deja/interfaces/web.py +104 -0
- deja/interfaces/web_ui/index.html +614 -0
- deja/llm/__init__.py +0 -0
- deja/llm/base.py +34 -0
- deja/llm/embedding.py +45 -0
- deja/llm/factory.py +90 -0
- deja/llm/providers/__init__.py +0 -0
- deja/llm/providers/anthropic.py +21 -0
- deja/llm/providers/ollama.py +30 -0
- deja/main.py +4 -0
- deja_cli-0.1.0.dist-info/METADATA +100 -0
- deja_cli-0.1.0.dist-info/RECORD +31 -0
- deja_cli-0.1.0.dist-info/WHEEL +4 -0
- deja_cli-0.1.0.dist-info/entry_points.txt +3 -0
- deja_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
deja/core/scheduler.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import sys
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from apscheduler.schedulers.background import BackgroundScheduler
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from deja.core.reflection import ReflectionEngine
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def make_scheduler(
|
|
14
|
+
engine: "ReflectionEngine",
|
|
15
|
+
loop: asyncio.AbstractEventLoop,
|
|
16
|
+
) -> BackgroundScheduler:
|
|
17
|
+
"""Create and configure the background scheduler for the watch daemon.
|
|
18
|
+
|
|
19
|
+
Schedule:
|
|
20
|
+
- Every 5 minutes: check token thresholds, auto-trigger observer/reflector
|
|
21
|
+
- Nightly 2:00am UTC: run_decay
|
|
22
|
+
- Nightly 2:05am UTC: run_promote
|
|
23
|
+
- Nightly 2:10am UTC: run_archive
|
|
24
|
+
"""
|
|
25
|
+
scheduler = BackgroundScheduler(timezone="UTC")
|
|
26
|
+
|
|
27
|
+
def _run(coro_fn, label: str, *args):
|
|
28
|
+
"""Submit a coroutine to the async event loop from the scheduler thread."""
|
|
29
|
+
try:
|
|
30
|
+
future = asyncio.run_coroutine_threadsafe(coro_fn(*args), loop)
|
|
31
|
+
result = future.result(timeout=300)
|
|
32
|
+
if result:
|
|
33
|
+
print(f"[deja scheduler] {label}: {result}", file=sys.stderr)
|
|
34
|
+
except Exception as e:
|
|
35
|
+
print(f"[deja scheduler] {label} error: {e}", file=sys.stderr)
|
|
36
|
+
|
|
37
|
+
scheduler.add_job(
|
|
38
|
+
lambda: _run(engine.check_and_trigger, "token-trigger check"),
|
|
39
|
+
"interval",
|
|
40
|
+
minutes=5,
|
|
41
|
+
id="token_trigger",
|
|
42
|
+
)
|
|
43
|
+
scheduler.add_job(
|
|
44
|
+
lambda: _run(engine.run_decay, "decay"),
|
|
45
|
+
"cron",
|
|
46
|
+
hour=2,
|
|
47
|
+
minute=0,
|
|
48
|
+
id="nightly_decay",
|
|
49
|
+
)
|
|
50
|
+
scheduler.add_job(
|
|
51
|
+
lambda: _run(engine.run_promote, "promote"),
|
|
52
|
+
"cron",
|
|
53
|
+
hour=2,
|
|
54
|
+
minute=5,
|
|
55
|
+
id="nightly_promote",
|
|
56
|
+
)
|
|
57
|
+
scheduler.add_job(
|
|
58
|
+
lambda: _run(engine.run_archive, "archive"),
|
|
59
|
+
"cron",
|
|
60
|
+
hour=2,
|
|
61
|
+
minute=10,
|
|
62
|
+
id="nightly_archive",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
return scheduler
|