aim-mailbox 0.3.5__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.
- aim_mailbox/__init__.py +37 -0
- aim_mailbox/__main__.py +13 -0
- aim_mailbox/_fast_check.py +95 -0
- aim_mailbox/cli.py +897 -0
- aim_mailbox/dispatcher.py +457 -0
- aim_mailbox/drivers.py +2449 -0
- aim_mailbox/dsh_plugin.py +891 -0
- aim_mailbox/hooks.py +469 -0
- aim_mailbox/mcp_stdio.py +382 -0
- aim_mailbox/store.py +1403 -0
- aim_mailbox-0.3.5.dist-info/METADATA +365 -0
- aim_mailbox-0.3.5.dist-info/RECORD +16 -0
- aim_mailbox-0.3.5.dist-info/WHEEL +5 -0
- aim_mailbox-0.3.5.dist-info/entry_points.txt +3 -0
- aim_mailbox-0.3.5.dist-info/licenses/LICENSE +21 -0
- aim_mailbox-0.3.5.dist-info/top_level.txt +1 -0
aim_mailbox/__init__.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""aim-mailbox — A-Mail (amail / aim-mail): Zero-daemon, zero-LLM local Maildir post office and wake dispatcher."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__version__ = "0.3.5"
|
|
6
|
+
|
|
7
|
+
from .dispatcher import pulse_mailbox, watch_mailbox
|
|
8
|
+
from .drivers import (
|
|
9
|
+
DRIVER_NAMES,
|
|
10
|
+
check_driver_host_affinity,
|
|
11
|
+
inspect_fleet_health,
|
|
12
|
+
install_agy_sidecar,
|
|
13
|
+
resolve_latest_codex_session,
|
|
14
|
+
resolve_latest_dsh_session,
|
|
15
|
+
uninstall_agy_sidecar,
|
|
16
|
+
)
|
|
17
|
+
from .dsh_plugin import install_dsh_plugin, uninstall_dsh_plugin
|
|
18
|
+
from .store import MailboxError, MailboxStore, is_agent_dnd, validate_agent_id
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"__version__",
|
|
22
|
+
"DRIVER_NAMES",
|
|
23
|
+
"MailboxError",
|
|
24
|
+
"MailboxStore",
|
|
25
|
+
"check_driver_host_affinity",
|
|
26
|
+
"inspect_fleet_health",
|
|
27
|
+
"install_agy_sidecar",
|
|
28
|
+
"install_dsh_plugin",
|
|
29
|
+
"is_agent_dnd",
|
|
30
|
+
"pulse_mailbox",
|
|
31
|
+
"resolve_latest_codex_session",
|
|
32
|
+
"resolve_latest_dsh_session",
|
|
33
|
+
"uninstall_agy_sidecar",
|
|
34
|
+
"uninstall_dsh_plugin",
|
|
35
|
+
"validate_agent_id",
|
|
36
|
+
"watch_mailbox",
|
|
37
|
+
]
|
aim_mailbox/__main__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
_PKG_SRC_ROOT = str(Path(__file__).resolve().parent.parent)
|
|
7
|
+
if _PKG_SRC_ROOT not in sys.path:
|
|
8
|
+
sys.path.insert(0, _PKG_SRC_ROOT)
|
|
9
|
+
|
|
10
|
+
from aim_mailbox.cli import main # noqa: E402
|
|
11
|
+
|
|
12
|
+
if __name__ == "__main__":
|
|
13
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
_FAST_AGENT_CHARS = frozenset("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.-")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def try_fast_empty_check(argv: list[str]) -> int | None:
|
|
10
|
+
"""Zero-import fast path for `check` when unread/ is empty (<15ms CLI latency)."""
|
|
11
|
+
if not argv or "check" not in argv:
|
|
12
|
+
return None
|
|
13
|
+
mb_dir: str | None = None
|
|
14
|
+
agent: str | None = None
|
|
15
|
+
inject = False
|
|
16
|
+
quiet = False
|
|
17
|
+
fmt = "text"
|
|
18
|
+
saw_check = False
|
|
19
|
+
i = 0
|
|
20
|
+
while i < len(argv):
|
|
21
|
+
tok = argv[i]
|
|
22
|
+
if tok in ("-h", "--help", "--version", "--json"):
|
|
23
|
+
return None
|
|
24
|
+
if tok == "--mailbox-dir":
|
|
25
|
+
if i + 1 >= len(argv):
|
|
26
|
+
return None
|
|
27
|
+
mb_dir = argv[i + 1]
|
|
28
|
+
i += 2
|
|
29
|
+
continue
|
|
30
|
+
if tok.startswith("--mailbox-dir="):
|
|
31
|
+
mb_dir = tok.split("=", 1)[1]
|
|
32
|
+
i += 1
|
|
33
|
+
continue
|
|
34
|
+
if not saw_check:
|
|
35
|
+
if tok == "check":
|
|
36
|
+
saw_check = True
|
|
37
|
+
i += 1
|
|
38
|
+
continue
|
|
39
|
+
return None
|
|
40
|
+
if tok == "--inject":
|
|
41
|
+
inject = True
|
|
42
|
+
elif tok == "--quiet":
|
|
43
|
+
quiet = True
|
|
44
|
+
elif tok == "--format":
|
|
45
|
+
if i + 1 >= len(argv):
|
|
46
|
+
return None
|
|
47
|
+
fmt = argv[i + 1]
|
|
48
|
+
if fmt not in ("text", "agy-inject", "agy-stop"):
|
|
49
|
+
return None
|
|
50
|
+
i += 1
|
|
51
|
+
elif tok.startswith("--format="):
|
|
52
|
+
fmt = tok.split("=", 1)[1]
|
|
53
|
+
if fmt not in ("text", "agy-inject", "agy-stop"):
|
|
54
|
+
return None
|
|
55
|
+
elif tok.startswith("-"):
|
|
56
|
+
return None
|
|
57
|
+
elif agent is None:
|
|
58
|
+
agent = tok
|
|
59
|
+
else:
|
|
60
|
+
return None
|
|
61
|
+
i += 1
|
|
62
|
+
|
|
63
|
+
if not saw_check or not agent:
|
|
64
|
+
return None
|
|
65
|
+
cleaned_agent = agent.strip()
|
|
66
|
+
if cleaned_agent.startswith("@"):
|
|
67
|
+
cleaned_agent = cleaned_agent[1:]
|
|
68
|
+
if (
|
|
69
|
+
not cleaned_agent
|
|
70
|
+
or len(cleaned_agent) > 64
|
|
71
|
+
or not cleaned_agent[0].isalnum()
|
|
72
|
+
or cleaned_agent.endswith(".")
|
|
73
|
+
or ".." in cleaned_agent
|
|
74
|
+
or not all(ch in _FAST_AGENT_CHARS for ch in cleaned_agent)
|
|
75
|
+
):
|
|
76
|
+
return None
|
|
77
|
+
cleaned_agent = cleaned_agent.lower()
|
|
78
|
+
|
|
79
|
+
raw_mb = mb_dir or os.environ.get("AIM_MAILBOX_DIR", "").strip() or os.path.join(os.path.expanduser("~"), ".aim", "mailbox")
|
|
80
|
+
unread_dir = os.path.join(os.path.abspath(os.path.expanduser(raw_mb)), "boxes", cleaned_agent, "unread")
|
|
81
|
+
try:
|
|
82
|
+
with os.scandir(unread_dir) as it:
|
|
83
|
+
for entry in it:
|
|
84
|
+
if entry.name.endswith(".json") and entry.is_file():
|
|
85
|
+
return None
|
|
86
|
+
except FileNotFoundError:
|
|
87
|
+
pass
|
|
88
|
+
except OSError:
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
if fmt in ("agy-inject", "agy-stop"):
|
|
92
|
+
sys.stdout.write("{}\n")
|
|
93
|
+
elif not quiet and not inject:
|
|
94
|
+
sys.stdout.write(f"0 unread messages for '{cleaned_agent}'.\n")
|
|
95
|
+
return 0
|