egzoscore 0.2.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.
- egzos/__init__.py +11 -0
- egzos/_ids.py +29 -0
- egzos/_signals.py +39 -0
- egzos/_term.py +33 -0
- egzos/_types.py +1023 -0
- egzos/api/__init__.py +150 -0
- egzos/api/app.py +1574 -0
- egzos/api/blobs.py +92 -0
- egzos/api/throttle.py +190 -0
- egzos/auth.py +176 -0
- egzos/authz/__init__.py +5 -0
- egzos/authz/presence.py +778 -0
- egzos/authz/values.py +32 -0
- egzos/backends/__init__.py +8 -0
- egzos/backends/base.py +91 -0
- egzos/backends/postgres.py +490 -0
- egzos/backends/sqlite.py +524 -0
- egzos/binding.py +309 -0
- egzos/cli/__init__.py +1092 -0
- egzos/cli/__main__.py +11 -0
- egzos/confirm.py +455 -0
- egzos/container.py +222 -0
- egzos/identity.py +1104 -0
- egzos/ledger.py +167 -0
- egzos/mcp/__init__.py +3 -0
- egzos/mcp/http.py +90 -0
- egzos/mcp/server.py +287 -0
- egzos/model.py +242 -0
- egzos/py.typed +0 -0
- egzos/resolver.py +115 -0
- egzos/store/__init__.py +10 -0
- egzos/store/autotitle.py +31 -0
- egzos/store/blobs.py +120 -0
- egzos/store/find.py +120 -0
- egzos/store/items.py +233 -0
- egzos/store/nodes.py +193 -0
- egzos/store/objects.py +143 -0
- egzos/store/uploads.py +369 -0
- egzos/trust.py +675 -0
- egzos/web/__init__.py +88 -0
- egzos/web/app.py +965 -0
- egzos/web/static/htmx.LICENSE +13 -0
- egzos/web/static/htmx.min.js +1 -0
- egzos/web/static/lifeboat.css +140 -0
- egzos/web/static/lifeboat.js +12 -0
- egzos/web/strings.py +133 -0
- egzos/web/templates/_manifest_row.html +3 -0
- egzos/web/templates/_shell.html +29 -0
- egzos/web/templates/_window.html +7 -0
- egzos/web/templates/base.html +24 -0
- egzos/web/templates/error.html +10 -0
- egzos/web/templates/home.html +39 -0
- egzos/web/templates/item.html +91 -0
- egzos/web/templates/notfound.html +6 -0
- egzos/web/templates/pending.html +107 -0
- egzos/web/tokens.css +294 -0
- egzoscore-0.2.0.dist-info/METADATA +135 -0
- egzoscore-0.2.0.dist-info/RECORD +62 -0
- egzoscore-0.2.0.dist-info/WHEEL +4 -0
- egzoscore-0.2.0.dist-info/entry_points.txt +2 -0
- egzoscore-0.2.0.dist-info/licenses/LICENSE +65 -0
- egzoscore-0.2.0.dist-info/licenses/NOTICE +6 -0
egzos/__init__.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Copyright 2026 Ali Sasanian
|
|
2
|
+
# SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0
|
|
3
|
+
"""
|
|
4
|
+
egzos — MCP-first, CLI-first personal context layer.
|
|
5
|
+
|
|
6
|
+
The container: store (nodes, items, blobs), trust engine, hash-chained ledger, resolver, the
|
|
7
|
+
CLI surface, the MCP stdio door and the step-up tap. The MVP runs on the Phase 0.1
|
|
8
|
+
walking skeleton's modules; the frozen-contract build replaces them module by module.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__version__ = "0.2.0"
|
egzos/_ids.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Copyright 2026 Ali Sasanian
|
|
2
|
+
# SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0
|
|
3
|
+
"""ULIDs — the identity of every node and item. Identity ≠ location (log §2)."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import time
|
|
9
|
+
|
|
10
|
+
_ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ" # Crockford base32
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _b32(value: int, length: int) -> str:
|
|
14
|
+
out = []
|
|
15
|
+
for _ in range(length):
|
|
16
|
+
out.append(_ALPHABET[value & 0x1F])
|
|
17
|
+
value >>= 5
|
|
18
|
+
return "".join(reversed(out))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def ulid(ts_ms: int | None = None) -> str:
|
|
22
|
+
"""26-char ULID: 48-bit millisecond timestamp + 80 bits of randomness."""
|
|
23
|
+
ts = int(time.time() * 1000) if ts_ms is None else ts_ms
|
|
24
|
+
rand = int.from_bytes(os.urandom(10), "big")
|
|
25
|
+
return _b32(ts, 10) + _b32(rand, 16)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def is_ulid(value: str) -> bool:
|
|
29
|
+
return len(value) == 26 and all(c in _ALPHABET for c in value)
|
egzos/_signals.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Copyright 2026 Ali Sasanian
|
|
2
|
+
# SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0
|
|
3
|
+
"""How a served door takes SIGTERM (GHSA-wf2m-wg6h-v6wf).
|
|
4
|
+
|
|
5
|
+
Docker, systemd and Kubernetes stop a process with SIGTERM; a terminal stops it with SIGINT
|
|
6
|
+
(Ctrl-C). uvicorn drains on either, then raises the signal again under the handler it found. Under
|
|
7
|
+
SIGTERM's default handler that ends the process before `uvicorn.run` returns, so the command never
|
|
8
|
+
closes its container (storage.md §3.7). Both doors that run uvicorn, `egzoscore serve --http` and
|
|
9
|
+
`egzoscore web`, run it inside `sigterm_as_sigint`, so `uvicorn.run` returns on either stop and the
|
|
10
|
+
close runs.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import contextlib
|
|
16
|
+
import signal
|
|
17
|
+
import threading
|
|
18
|
+
from collections.abc import Iterator
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@contextlib.contextmanager
|
|
22
|
+
def sigterm_as_sigint() -> Iterator[None]:
|
|
23
|
+
"""While the block runs, SIGTERM ends it as SIGINT does: KeyboardInterrupt, which `uvicorn.run`
|
|
24
|
+
ends on. Only SIGTERM's default handler is replaced, and only on the main thread, the one that
|
|
25
|
+
takes a signal: an ignored SIGTERM, or a handler set by whatever embeds the door, is left as it
|
|
26
|
+
is. The default is put back however the block ends. A uvicorn that does not raise the signal
|
|
27
|
+
again takes it itself while it serves, so this handler sees only a SIGTERM that lands during
|
|
28
|
+
startup or teardown."""
|
|
29
|
+
if threading.current_thread() is not threading.main_thread():
|
|
30
|
+
yield
|
|
31
|
+
return
|
|
32
|
+
if signal.getsignal(signal.SIGTERM) is not signal.SIG_DFL:
|
|
33
|
+
yield
|
|
34
|
+
return
|
|
35
|
+
try:
|
|
36
|
+
signal.signal(signal.SIGTERM, signal.default_int_handler)
|
|
37
|
+
yield
|
|
38
|
+
finally:
|
|
39
|
+
signal.signal(signal.SIGTERM, signal.SIG_DFL)
|
egzos/_term.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Copyright 2026 Ali Sasanian
|
|
2
|
+
# SPDX-License-Identifier: LicenseRef-PolyForm-Strict-1.0.0
|
|
3
|
+
"""Text for a terminal: stored content is data, and a terminal treats some characters as commands.
|
|
4
|
+
|
|
5
|
+
Anything an agent wrote (a title, a body, a scope it probed) can reach the owner's terminal through
|
|
6
|
+
`ls`, `find`, `fetch` or an error line. Control characters there are not text: an escape sequence
|
|
7
|
+
can rewrite what is on screen or reach the clipboard, and bidi controls can reorder a line. So
|
|
8
|
+
every character that is not printable text is shown as its escape, visible and inert. Newline and
|
|
9
|
+
tab stay: bodies have lines.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import re
|
|
15
|
+
|
|
16
|
+
# C0 controls except tab and newline, DEL, C1 controls, and the bidi / directional formatting marks.
|
|
17
|
+
# Written as escapes, never as the characters themselves.
|
|
18
|
+
_UNSAFE = re.compile("[\x00-\x08\x0b-\x1f\x7f-\x9f\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _escape(match: re.Match[str]) -> str:
|
|
22
|
+
code = ord(match.group(0))
|
|
23
|
+
return f"\\x{code:02x}" if code < 0x100 else f"\\u{code:04x}"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _json_escape(match: re.Match[str]) -> str:
|
|
27
|
+
return f"\\u{ord(match.group(0)):04x}"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def safe(text: str, *, json: bool = False) -> str:
|
|
31
|
+
"""`text` with every non-printing control shown as its escape. With `json` the escape is the
|
|
32
|
+
JSON form, so serialised JSON stays valid (json.dumps escapes C0; this adds C1 and bidi)."""
|
|
33
|
+
return _UNSAFE.sub(_json_escape if json else _escape, text)
|