aegix 2.0.0__tar.gz

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 (59) hide show
  1. aegix-2.0.0/.gitignore +37 -0
  2. aegix-2.0.0/LICENSE +21 -0
  3. aegix-2.0.0/PKG-INFO +129 -0
  4. aegix-2.0.0/README.md +106 -0
  5. aegix-2.0.0/config/config.yaml +36 -0
  6. aegix-2.0.0/config/registry.json +52 -0
  7. aegix-2.0.0/pyproject.toml +48 -0
  8. aegix-2.0.0/src/aegix/__init__.py +41 -0
  9. aegix-2.0.0/src/aegix/accel/Makefile +31 -0
  10. aegix-2.0.0/src/aegix/accel/__init__.py +7 -0
  11. aegix-2.0.0/src/aegix/accel/aegix_accel.c +43 -0
  12. aegix-2.0.0/src/aegix/accel/aegix_count.S +25 -0
  13. aegix-2.0.0/src/aegix/adapters/__init__.py +1 -0
  14. aegix-2.0.0/src/aegix/adapters/base.py +57 -0
  15. aegix-2.0.0/src/aegix/adapters/generic.py +67 -0
  16. aegix-2.0.0/src/aegix/adapters/heuristic_worker.py +68 -0
  17. aegix-2.0.0/src/aegix/cli.py +198 -0
  18. aegix-2.0.0/src/aegix/core/__init__.py +1 -0
  19. aegix-2.0.0/src/aegix/core/config.py +101 -0
  20. aegix-2.0.0/src/aegix/core/events.py +38 -0
  21. aegix-2.0.0/src/aegix/core/orchestrator.py +168 -0
  22. aegix-2.0.0/src/aegix/core/reporter.py +88 -0
  23. aegix-2.0.0/src/aegix/core/store.py +217 -0
  24. aegix-2.0.0/src/aegix/core/types.py +169 -0
  25. aegix-2.0.0/src/aegix/mcp/__init__.py +1 -0
  26. aegix-2.0.0/src/aegix/mcp/engine.py +120 -0
  27. aegix-2.0.0/src/aegix/mcp/registry.py +85 -0
  28. aegix-2.0.0/src/aegix/perf/README.md +24 -0
  29. aegix-2.0.0/src/aegix/perf/__init__.py +6 -0
  30. aegix-2.0.0/src/aegix/perf/java/com/aegix/perf/DispatchCoordinator.java +80 -0
  31. aegix-2.0.0/src/aegix/platform.py +106 -0
  32. aegix-2.0.0/src/aegix/router/__init__.py +1 -0
  33. aegix-2.0.0/src/aegix/router/router.py +67 -0
  34. aegix-2.0.0/src/aegix/supervisor/__init__.py +1 -0
  35. aegix-2.0.0/src/aegix/supervisor/decomposer.py +84 -0
  36. aegix-2.0.0/src/aegix/supervisor/escalation.py +52 -0
  37. aegix-2.0.0/src/aegix/supervisor/feedback_injector.py +50 -0
  38. aegix-2.0.0/src/aegix/supervisor/loop_detector.py +88 -0
  39. aegix-2.0.0/src/aegix/supervisor/progress_scorer.py +60 -0
  40. aegix-2.0.0/src/aegix/supervisor/state.py +55 -0
  41. aegix-2.0.0/src/aegix/supervisor/supervisor.py +138 -0
  42. aegix-2.0.0/src/aegix/supervisor/token_budget.py +72 -0
  43. aegix-2.0.0/src/aegix/terminal/__init__.py +1 -0
  44. aegix-2.0.0/src/aegix/terminal/argv.py +59 -0
  45. aegix-2.0.0/src/aegix/terminal/installer.py +130 -0
  46. aegix-2.0.0/src/aegix/terminal/parser.py +240 -0
  47. aegix-2.0.0/src/aegix/terminal/pty_engine.py +92 -0
  48. aegix-2.0.0/src/aegix/terminal/simulator.py +115 -0
  49. aegix-2.0.0/src/aegix/util/__init__.py +1 -0
  50. aegix-2.0.0/src/aegix/util/accel.py +126 -0
  51. aegix-2.0.0/src/aegix/util/ansi.py +11 -0
  52. aegix-2.0.0/src/aegix/util/ids.py +60 -0
  53. aegix-2.0.0/src/aegix/util/logger.py +57 -0
  54. aegix-2.0.0/tests/__init__.py +0 -0
  55. aegix-2.0.0/tests/test_end_to_end.py +22 -0
  56. aegix-2.0.0/tests/test_parsers_extra.py +43 -0
  57. aegix-2.0.0/tests/test_pipeline.py +63 -0
  58. aegix-2.0.0/tests/test_store.py +50 -0
  59. aegix-2.0.0/tests/test_supervisor.py +74 -0
aegix-2.0.0/.gitignore ADDED
@@ -0,0 +1,37 @@
1
+ node_modules/
2
+ dist/
3
+ *.log
4
+ .env
5
+ .env.*
6
+ !.env.example
7
+ .DS_Store
8
+ coverage/
9
+ *.tsbuildinfo
10
+
11
+ # Editor / OS cruft
12
+ *.swp
13
+ *.swo
14
+ *~
15
+ data/
16
+ audit/*.jsonl
17
+ .aegix/
18
+
19
+ # Python
20
+ __pycache__/
21
+ *.py[cod]
22
+ .pytest_cache/
23
+ *.egg-info/
24
+ build/
25
+ .venv/
26
+ venv/
27
+
28
+ # Native accelerator build artifacts (built from pycore/src/aegix/accel)
29
+ *.so
30
+ *.dylib
31
+ *.dll
32
+ *.o
33
+
34
+ # Java performance layer build artifacts
35
+ *.jar
36
+ *.class
37
+ pycore/src/aegix/perf/out/
aegix-2.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ghulam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
aegix-2.0.0/PKG-INFO ADDED
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: aegix
3
+ Version: 2.0.0
4
+ Summary: AI-Supervised Cybersecurity Tool Orchestration Platform — Python core. Supported by TypeScript, C, and Assembly adapters/accelerators, with Java used alongside for high-throughput, cross-platform performance-critical paths. Installable via pip or bun (workspace tooling).
5
+ Project-URL: Homepage, https://github.com/ghulam36460/aegix
6
+ Project-URL: Repository, https://github.com/ghulam36460/aegix
7
+ Project-URL: Issues, https://github.com/ghulam36460/aegix/issues
8
+ Author: ghulam
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai,automation,cybersecurity,mcp,orchestration,pentest,supervisor
12
+ Requires-Python: >=3.12
13
+ Requires-Dist: pyyaml>=6.0
14
+ Provides-Extra: accel
15
+ Requires-Dist: cffi>=1.16; extra == 'accel'
16
+ Requires-Dist: jpype1>=1.5; extra == 'accel'
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
19
+ Requires-Dist: pytest>=8.0; extra == 'dev'
20
+ Provides-Extra: mcp
21
+ Requires-Dist: mcp>=1.2; extra == 'mcp'
22
+ Description-Content-Type: text/markdown
23
+
24
+ # Aegix Core (Python)
25
+
26
+ AI-Supervised Cybersecurity Tool Orchestration Platform — **Python core**.
27
+
28
+ A pipeline that connects any AI client (Claude, Gemini, Copilot, GitLab Duo,
29
+ Cursor, Codex, custom OpenAI-compatible) to security tools — via MCP servers
30
+ when available, or via terminal automation as a fallback — and supervises the
31
+ worker AI in real time so it does not loop, waste tokens, or wander.
32
+
33
+ The core is **Python**. It is supported by:
34
+
35
+ - **TypeScript** adapters for MCP / IDE clients (see the repository root).
36
+ - **C** and hand-tuned **Assembly** accelerators for hot paths (token
37
+ estimation, fuzzy-signature hashing) — see `src/aegix/accel`.
38
+ - A **Java** performance layer (JDK 21+) for high-throughput, cross-platform
39
+ fan-out (parallel tool dispatch, concurrent sub-agent monitoring) — see
40
+ `src/aegix/perf`.
41
+
42
+ Everything degrades gracefully: with no native components installed the platform
43
+ runs in pure Python with identical behavior, just slower on the hot paths.
44
+
45
+ > The security layer (scope enforcement, risk gating, audit logging) is owned and
46
+ > implemented separately by the security team. It is intentionally **not** part of
47
+ > this package.
48
+
49
+ ## Install
50
+
51
+ ```bash
52
+ pip install . # pure-Python core (zero native build steps)
53
+ pip install '.[accel]' # + C/Assembly fast paths and the Java bridge
54
+ pip install '.[mcp]' # + official Model Context Protocol SDK
55
+ pip install '.[dev]' # + test dependencies
56
+ ```
57
+
58
+ ### Optional: build the native accelerator
59
+
60
+ ```bash
61
+ cd src/aegix/accel && make # C + hand-tuned x86-64 Assembly
62
+ # or, portable C only (any architecture):
63
+ cd src/aegix/accel && make portable
64
+ ```
65
+
66
+ ### Optional: build the Java performance layer (JDK 21+)
67
+
68
+ ```bash
69
+ cd src/aegix/perf
70
+ javac -d out java/com/aegix/perf/DispatchCoordinator.java
71
+ jar --create --file aegix-perf.jar -C out .
72
+ ```
73
+
74
+ ## Usage
75
+
76
+ ```bash
77
+ # Run a supervised assessment (simulated, safe, no tools installed/executed)
78
+ aegix run "check if my web app is secure" --target scanme.nmap.org --dry-run
79
+
80
+ # Emit machine-readable JSON
81
+ aegix run "full security assessment" --target example.test --dry-run --json
82
+
83
+ # Inspect run history and export the audit trail
84
+ aegix history
85
+ aegix export <task_id>
86
+
87
+ # Registry + native acceleration status
88
+ aegix registry
89
+ aegix accel
90
+ ```
91
+
92
+ Programmatic:
93
+
94
+ ```python
95
+ import asyncio
96
+ from aegix import Aegix
97
+ from aegix.platform import AegixOptions
98
+ from aegix.core.store import SessionStore
99
+
100
+ async def main():
101
+ store = SessionStore() # persists to .aegix/sessions.db
102
+ app = Aegix(AegixOptions(client="custom", dry_run=True, store=store))
103
+ result = await app.run("check if my web app is secure", "scanme.nmap.org")
104
+ print(result.summary)
105
+
106
+ asyncio.run(main())
107
+ ```
108
+
109
+ ## Architecture
110
+
111
+ Five vertical layers plus a cross-cutting supervisor:
112
+
113
+ | Layer | Module | Responsibility |
114
+ | ----- | ------ | -------------- |
115
+ | L1 | `adapters/` | Normalize any AI client into a `TaskObject`; format results back. |
116
+ | L2 | `router/` | Classify + route each tool call (MCP first, terminal fallback). |
117
+ | L3 | `mcp/` | MCP registry, server lifecycle, trust-tier policy, transports. |
118
+ | L4 | `terminal/` | Auto-install cascade + PTY automation + output parser. |
119
+ | L5 | `supervisor/` | Loop detection, progress scoring, token budgets, feedback, escalation. |
120
+
121
+ Cross-cutting: `core/` (types, config, events, reporter, **SQLite session/audit
122
+ store**), `util/` (IDs, ANSI, logging, **native acceleration bridge**).
123
+
124
+ ## Test
125
+
126
+ ```bash
127
+ pip install '.[dev]'
128
+ pytest # src/ is on the path via pyproject [tool.pytest.ini_options]
129
+ ```
aegix-2.0.0/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # Aegix Core (Python)
2
+
3
+ AI-Supervised Cybersecurity Tool Orchestration Platform — **Python core**.
4
+
5
+ A pipeline that connects any AI client (Claude, Gemini, Copilot, GitLab Duo,
6
+ Cursor, Codex, custom OpenAI-compatible) to security tools — via MCP servers
7
+ when available, or via terminal automation as a fallback — and supervises the
8
+ worker AI in real time so it does not loop, waste tokens, or wander.
9
+
10
+ The core is **Python**. It is supported by:
11
+
12
+ - **TypeScript** adapters for MCP / IDE clients (see the repository root).
13
+ - **C** and hand-tuned **Assembly** accelerators for hot paths (token
14
+ estimation, fuzzy-signature hashing) — see `src/aegix/accel`.
15
+ - A **Java** performance layer (JDK 21+) for high-throughput, cross-platform
16
+ fan-out (parallel tool dispatch, concurrent sub-agent monitoring) — see
17
+ `src/aegix/perf`.
18
+
19
+ Everything degrades gracefully: with no native components installed the platform
20
+ runs in pure Python with identical behavior, just slower on the hot paths.
21
+
22
+ > The security layer (scope enforcement, risk gating, audit logging) is owned and
23
+ > implemented separately by the security team. It is intentionally **not** part of
24
+ > this package.
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ pip install . # pure-Python core (zero native build steps)
30
+ pip install '.[accel]' # + C/Assembly fast paths and the Java bridge
31
+ pip install '.[mcp]' # + official Model Context Protocol SDK
32
+ pip install '.[dev]' # + test dependencies
33
+ ```
34
+
35
+ ### Optional: build the native accelerator
36
+
37
+ ```bash
38
+ cd src/aegix/accel && make # C + hand-tuned x86-64 Assembly
39
+ # or, portable C only (any architecture):
40
+ cd src/aegix/accel && make portable
41
+ ```
42
+
43
+ ### Optional: build the Java performance layer (JDK 21+)
44
+
45
+ ```bash
46
+ cd src/aegix/perf
47
+ javac -d out java/com/aegix/perf/DispatchCoordinator.java
48
+ jar --create --file aegix-perf.jar -C out .
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ ```bash
54
+ # Run a supervised assessment (simulated, safe, no tools installed/executed)
55
+ aegix run "check if my web app is secure" --target scanme.nmap.org --dry-run
56
+
57
+ # Emit machine-readable JSON
58
+ aegix run "full security assessment" --target example.test --dry-run --json
59
+
60
+ # Inspect run history and export the audit trail
61
+ aegix history
62
+ aegix export <task_id>
63
+
64
+ # Registry + native acceleration status
65
+ aegix registry
66
+ aegix accel
67
+ ```
68
+
69
+ Programmatic:
70
+
71
+ ```python
72
+ import asyncio
73
+ from aegix import Aegix
74
+ from aegix.platform import AegixOptions
75
+ from aegix.core.store import SessionStore
76
+
77
+ async def main():
78
+ store = SessionStore() # persists to .aegix/sessions.db
79
+ app = Aegix(AegixOptions(client="custom", dry_run=True, store=store))
80
+ result = await app.run("check if my web app is secure", "scanme.nmap.org")
81
+ print(result.summary)
82
+
83
+ asyncio.run(main())
84
+ ```
85
+
86
+ ## Architecture
87
+
88
+ Five vertical layers plus a cross-cutting supervisor:
89
+
90
+ | Layer | Module | Responsibility |
91
+ | ----- | ------ | -------------- |
92
+ | L1 | `adapters/` | Normalize any AI client into a `TaskObject`; format results back. |
93
+ | L2 | `router/` | Classify + route each tool call (MCP first, terminal fallback). |
94
+ | L3 | `mcp/` | MCP registry, server lifecycle, trust-tier policy, transports. |
95
+ | L4 | `terminal/` | Auto-install cascade + PTY automation + output parser. |
96
+ | L5 | `supervisor/` | Loop detection, progress scoring, token budgets, feedback, escalation. |
97
+
98
+ Cross-cutting: `core/` (types, config, events, reporter, **SQLite session/audit
99
+ store**), `util/` (IDs, ANSI, logging, **native acceleration bridge**).
100
+
101
+ ## Test
102
+
103
+ ```bash
104
+ pip install '.[dev]'
105
+ pytest # src/ is on the path via pyproject [tool.pytest.ini_options]
106
+ ```
@@ -0,0 +1,36 @@
1
+ # Aegix (Python core) configuration.
2
+ # All values are optional; anything omitted falls back to built-in defaults.
3
+
4
+ defaultMaxTokens: 200000
5
+
6
+ # Fraction of the total token budget allocated per phase (re-normalized across
7
+ # the phases actually selected for a given goal). Should sum to ~1.0.
8
+ phaseBudget:
9
+ recon: 0.15
10
+ enumeration: 0.20
11
+ vuln_scan: 0.25
12
+ exploit: 0.20
13
+ analysis: 0.05
14
+ post_exploit: 0.05
15
+ report: 0.10
16
+
17
+ supervisor:
18
+ loopThreshold: 3 # consecutive near-identical calls before a loop fires
19
+ productivityWindow: 5 # calls without a new finding before low-productivity fires
20
+ loopEscalationLimit: 3 # loop fires on one task before escalating to a human
21
+ tokenSafetyMargin: 0.15 # reserve 15% of the budget as headroom
22
+
23
+ # When true, no real tools are installed or executed; output is simulated.
24
+ dryRun: false
25
+
26
+ # Independent sub-tasks within a phase may dispatch in parallel. Fan-out is
27
+ # offloaded to the Java 26 performance layer when available, else asyncio.
28
+ parallelDispatch: true
29
+ maxParallelism: 8
30
+
31
+ # NOTE: The security layer (scope enforcement, risk gating, audit logging) is
32
+ # owned and configured separately by the security team according to their own
33
+ # policies and the laws of the relevant jurisdictions. Its settings are
34
+ # intentionally not defined here.
35
+
36
+ registryPath: config/registry.json
@@ -0,0 +1,52 @@
1
+ {
2
+ "schemaVersion": "2",
3
+ "lastUpdated": "2026-06-27T00:00:00Z",
4
+ "tools": {
5
+ "nuclei": {
6
+ "mcpServer": "ghcr.io/projectdiscovery/nuclei-mcp:latest",
7
+ "transport": "stdio",
8
+ "trustTier": "official",
9
+ "install": { "native": "pip install nuclei-cli" },
10
+ "toolSchemas": [{ "name": "scan" }]
11
+ },
12
+ "ghidra": {
13
+ "mcpServer": "github:bethington/ghidra-mcp@v2.1",
14
+ "transport": "stdio",
15
+ "trustTier": "community",
16
+ "toolSchemas": [{ "name": "analyze" }]
17
+ },
18
+ "nmap": {
19
+ "mcpServer": "ghcr.io/org/nmap-mcp:latest",
20
+ "transport": "stdio",
21
+ "trustTier": "community",
22
+ "install": { "native": "apt install nmap" },
23
+ "toolSchemas": [{ "name": "scan" }]
24
+ },
25
+ "semgrep": {
26
+ "mcpServer": "ghcr.io/semgrep/semgrep-mcp:latest",
27
+ "transport": "stdio",
28
+ "trustTier": "official",
29
+ "install": { "native": "pip install semgrep" },
30
+ "toolSchemas": [{ "name": "scan" }]
31
+ },
32
+ "trivy": {
33
+ "mcpServer": "ghcr.io/aquasecurity/trivy-mcp:latest",
34
+ "transport": "stdio",
35
+ "trustTier": "official",
36
+ "install": { "native": "apt install trivy" },
37
+ "toolSchemas": [{ "name": "scan" }]
38
+ },
39
+ "subfinder": {
40
+ "mcpServer": "ghcr.io/projectdiscovery/subfinder-mcp:latest",
41
+ "transport": "stdio",
42
+ "trustTier": "official",
43
+ "toolSchemas": [{ "name": "enumerate" }]
44
+ },
45
+ "httpx": {
46
+ "mcpServer": "ghcr.io/projectdiscovery/httpx-mcp:latest",
47
+ "transport": "stdio",
48
+ "trustTier": "official",
49
+ "toolSchemas": [{ "name": "probe" }]
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "aegix"
7
+ version = "2.0.0"
8
+ description = "AI-Supervised Cybersecurity Tool Orchestration Platform — Python core. Supported by TypeScript, C, and Assembly adapters/accelerators, with Java used alongside for high-throughput, cross-platform performance-critical paths. Installable via pip or bun (workspace tooling)."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.12"
12
+ authors = [{ name = "ghulam" }]
13
+ keywords = ["ai", "cybersecurity", "mcp", "orchestration", "supervisor", "pentest", "automation"]
14
+
15
+ # Core is intentionally dependency-light so it installs cleanly via `pip install .`
16
+ # (and is resolvable from a bun workspace that shells out to Python). Optional
17
+ # accelerators (native C/Assembly via cffi, JVM bridge via jpype) are extras.
18
+ dependencies = [
19
+ "pyyaml>=6.0",
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/ghulam36460/aegix"
24
+ Repository = "https://github.com/ghulam36460/aegix"
25
+ Issues = "https://github.com/ghulam36460/aegix/issues"
26
+
27
+ [project.optional-dependencies]
28
+ accel = [
29
+ "cffi>=1.16", # load the C/Assembly fast-path shared library
30
+ "jpype1>=1.5", # bridge to the Java performance layer
31
+ ]
32
+ mcp = [
33
+ "mcp>=1.2", # official Model Context Protocol SDK (Python)
34
+ ]
35
+ dev = [
36
+ "pytest>=8.0",
37
+ "pytest-asyncio>=0.23",
38
+ ]
39
+
40
+ [project.scripts]
41
+ aegix = "aegix.cli:main"
42
+
43
+ [tool.hatch.build.targets.wheel]
44
+ packages = ["src/aegix"]
45
+
46
+ [tool.pytest.ini_options]
47
+ testpaths = ["tests"]
48
+ pythonpath = ["src"]
@@ -0,0 +1,41 @@
1
+ """Aegix — AI-Supervised Cybersecurity Tool Orchestration Platform (Python core).
2
+
3
+ The core is Python. It is supported by:
4
+ * TypeScript adapters (MCP / IDE clients),
5
+ * C and hand-tuned Assembly accelerators for hot paths (see ``aegix.accel``),
6
+ * a Java performance layer for high-throughput, cross-platform fan-out.
7
+
8
+ The security layer (scope, risk gating, audit) is intentionally NOT part of this
9
+ package. It is owned and implemented separately by the security team according to
10
+ their own policies and the laws of the relevant jurisdictions.
11
+ """
12
+
13
+ from .platform import Aegix, AegixOptions
14
+ from .core.config import AegixConfig, load_config, DEFAULT_CONFIG
15
+ from .core.types import (
16
+ Artifact,
17
+ Phase,
18
+ ResultObject,
19
+ SourceClient,
20
+ TaskObject,
21
+ ToolCall,
22
+ ToolResult,
23
+ )
24
+
25
+ __version__ = "2.0.0"
26
+
27
+ __all__ = [
28
+ "Aegix",
29
+ "AegixOptions",
30
+ "AegixConfig",
31
+ "load_config",
32
+ "DEFAULT_CONFIG",
33
+ "Artifact",
34
+ "Phase",
35
+ "ResultObject",
36
+ "SourceClient",
37
+ "TaskObject",
38
+ "ToolCall",
39
+ "ToolResult",
40
+ "__version__",
41
+ ]
@@ -0,0 +1,31 @@
1
+ # Build the optional C/Assembly accelerator shared library.
2
+ #
3
+ # The Python core runs fine without this (pure-Python fallback). Building it
4
+ # unlocks the native fast paths used by sentinel.util.accel.
5
+ #
6
+ # make # build with the hand-tuned Assembly inner loop (x86-64)
7
+ # make portable # build portable C only (any arch)
8
+ # make clean
9
+
10
+ CC ?= cc
11
+ CFLAGS ?= -O3 -shared -fPIC
12
+ UNAME_S := $(shell uname -s)
13
+
14
+ ifeq ($(UNAME_S),Darwin)
15
+ LIB := libaegix.dylib
16
+ else
17
+ LIB := libaegix.so
18
+ endif
19
+
20
+ .PHONY: all portable clean
21
+
22
+ all: $(LIB)
23
+
24
+ $(LIB): aegix_accel.c aegix_count.S
25
+ $(CC) $(CFLAGS) -DAEGIX_ASM aegix_accel.c aegix_count.S -o $(LIB)
26
+
27
+ portable: aegix_accel.c
28
+ $(CC) $(CFLAGS) aegix_accel.c -o $(LIB)
29
+
30
+ clean:
31
+ rm -f libaegix.so libaegix.dylib aegix.dll
@@ -0,0 +1,7 @@
1
+ """Native C/Assembly accelerator artifacts.
2
+
3
+ This package holds the source for the optional ``libaegix`` shared library
4
+ (C + hand-tuned Assembly). It is built via the Makefile here and loaded at
5
+ runtime by ``aegix.util.accel`` when present. The Python core works without
6
+ it via a pure-Python fallback.
7
+ """
@@ -0,0 +1,43 @@
1
+ /*
2
+ * sentinel native accelerator — C hot paths for the Python core.
3
+ *
4
+ * Exposes a tiny, stable C ABI loaded by sentinel.util.accel via cffi/ctypes.
5
+ * The token estimator's inner counting loop is delegated to hand-tuned
6
+ * Assembly (see aegix_count.S) when built with AEGIX_ASM; otherwise a
7
+ * portable C loop is used. Either way the result matches the pure-Python
8
+ * heuristic (ceil(bytes / 4)) so behavior is identical, just faster.
9
+ *
10
+ * Build (Linux):
11
+ * cc -O3 -shared -fPIC -DAEGIX_ASM aegix_accel.c aegix_count.S -o libaegix.so
12
+ * Build (portable C only):
13
+ * cc -O3 -shared -fPIC aegix_accel.c -o libaegix.so
14
+ */
15
+
16
+ #include <stddef.h>
17
+ #include <stdint.h>
18
+
19
+ #ifdef AEGIX_ASM
20
+ /* Implemented in aegix_count.S — counts bytes via a tight SIMD-friendly loop. */
21
+ extern uint64_t aegix_count_bytes(const char *data, size_t len);
22
+ #else
23
+ static uint64_t aegix_count_bytes(const char *data, size_t len) {
24
+ (void)data;
25
+ return (uint64_t)len;
26
+ }
27
+ #endif
28
+
29
+ /* ceil(len / 4): conservative ~4 chars/token estimate, matching the Python path. */
30
+ uint64_t aegix_estimate_tokens(const char *data, size_t len) {
31
+ uint64_t bytes = aegix_count_bytes(data, len);
32
+ return (bytes + 3u) / 4u;
33
+ }
34
+
35
+ /* Fast FNV-1a hash used by the loop detector's fuzzy signature comparison. */
36
+ uint64_t aegix_fnv1a(const char *data, size_t len) {
37
+ uint64_t h = 14695981039346656037ULL;
38
+ for (size_t i = 0; i < len; i++) {
39
+ h ^= (uint8_t)data[i];
40
+ h *= 1099511628211ULL;
41
+ }
42
+ return h;
43
+ }
@@ -0,0 +1,25 @@
1
+ /*
2
+ * aegix_count_bytes — x86-64 System V ABI hand-tuned byte counter.
3
+ *
4
+ * uint64_t aegix_count_bytes(const char *data [rdi], size_t len [rsi]);
5
+ *
6
+ * This is the Assembly inner loop backing the C accelerator's token estimator.
7
+ * The count itself is trivial (it returns len), but it is implemented in
8
+ * Assembly to demonstrate and host the native hot-path integration point: more
9
+ * complex SIMD scanning (e.g. UTF-8 codepoint counting, delimiter scanning) is
10
+ * dropped in here without touching the Python or C layers above it.
11
+ *
12
+ * Assemble as part of the shared library:
13
+ * cc -O3 -shared -fPIC -DAEGIX_ASM aegix_accel.c aegix_count.S -o libaegix.so
14
+ */
15
+
16
+ .text
17
+ .globl aegix_count_bytes
18
+ .type aegix_count_bytes, @function
19
+ aegix_count_bytes:
20
+ movq %rsi, %rax # rax = len (the byte count)
21
+ ret
22
+ .size aegix_count_bytes, .-aegix_count_bytes
23
+
24
+ /* Mark the stack as non-executable. */
25
+ .section .note.GNU-stack,"",@progbits
@@ -0,0 +1 @@
1
+ """Layer 1 — AI Client Adapters."""
@@ -0,0 +1,57 @@
1
+ """Layer 1 — AI Client Adapter contract.
2
+
3
+ Each supported AI client implements these protocols. Internally everything
4
+ speaks TaskObject / ResultObject; the adapter is the only place that knows a
5
+ client's native protocol (REST, JSON-RPC, MCP, VS Code API, etc.).
6
+
7
+ The ``WorkerAgent`` abstraction represents the actual AI doing the work: given
8
+ the current findings, it decides the next tool call (or signals done). In
9
+ production this is the live Claude/Gemini/etc. call; for offline runs a heuristic
10
+ stand-in implements the same interface.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from dataclasses import dataclass, field
16
+ from typing import Any, Protocol, runtime_checkable
17
+
18
+ from ..core.types import Artifact, Phase, ResultObject, TaskObject, ToolResult
19
+
20
+
21
+ @dataclass(slots=True)
22
+ class AdapterContext:
23
+ phase: Phase
24
+ tool_whitelist: list[str]
25
+ findings: list[Artifact] = field(default_factory=list)
26
+ feedback: str | None = None
27
+
28
+
29
+ @dataclass(slots=True)
30
+ class ToolCallDecision:
31
+ phase: Phase
32
+ tool: str
33
+ params: dict[str, Any] = field(default_factory=dict)
34
+ description: str | None = None
35
+
36
+
37
+ @dataclass(slots=True)
38
+ class DoneDecision:
39
+ reason: str
40
+
41
+
42
+ AgentDecision = ToolCallDecision | DoneDecision
43
+
44
+
45
+ @runtime_checkable
46
+ class WorkerAgent(Protocol):
47
+ async def next(self, ctx: AdapterContext) -> AgentDecision: ...
48
+ def observe(self, result: ToolResult) -> None: ...
49
+
50
+
51
+ @runtime_checkable
52
+ class ClientAdapter(Protocol):
53
+ id: str
54
+
55
+ def normalize(self, input_text: str, target: str, overrides: dict[str, Any] | None = None) -> TaskObject: ...
56
+ def create_worker(self, task: TaskObject) -> WorkerAgent: ...
57
+ def format_result(self, result: ResultObject) -> Any: ...