arkitekt-fastapi 1.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 (35) hide show
  1. arkitekt_fastapi-1.0.0/.gitignore +7 -0
  2. arkitekt_fastapi-1.0.0/PKG-INFO +40 -0
  3. arkitekt_fastapi-1.0.0/README.md +23 -0
  4. arkitekt_fastapi-1.0.0/arkitekt_fastapi/__init__.py +54 -0
  5. arkitekt_fastapi-1.0.0/arkitekt_fastapi/agent.py +1051 -0
  6. arkitekt_fastapi-1.0.0/arkitekt_fastapi/auth.py +104 -0
  7. arkitekt_fastapi-1.0.0/arkitekt_fastapi/detail_routes/__init__.py +6 -0
  8. arkitekt_fastapi-1.0.0/arkitekt_fastapi/detail_routes/states.py +445 -0
  9. arkitekt_fastapi-1.0.0/arkitekt_fastapi/detail_routes/tasks.py +36 -0
  10. arkitekt_fastapi-1.0.0/arkitekt_fastapi/models.py +147 -0
  11. arkitekt_fastapi-1.0.0/arkitekt_fastapi/openapi_utils.py +130 -0
  12. arkitekt_fastapi-1.0.0/arkitekt_fastapi/retriever/__init__.py +0 -0
  13. arkitekt_fastapi-1.0.0/arkitekt_fastapi/retriever/memory_retriever.py +369 -0
  14. arkitekt_fastapi-1.0.0/arkitekt_fastapi/retriever/protocol.py +89 -0
  15. arkitekt_fastapi-1.0.0/arkitekt_fastapi/retriever/replay.py +99 -0
  16. arkitekt_fastapi-1.0.0/arkitekt_fastapi/route_groups/__init__.py +20 -0
  17. arkitekt_fastapi-1.0.0/arkitekt_fastapi/route_groups/common.py +18 -0
  18. arkitekt_fastapi-1.0.0/arkitekt_fastapi/route_groups/core.py +127 -0
  19. arkitekt_fastapi-1.0.0/arkitekt_fastapi/route_groups/implementations.py +145 -0
  20. arkitekt_fastapi-1.0.0/arkitekt_fastapi/route_groups/journal.py +207 -0
  21. arkitekt_fastapi-1.0.0/arkitekt_fastapi/route_groups/locks.py +36 -0
  22. arkitekt_fastapi-1.0.0/arkitekt_fastapi/route_groups/schemas.py +40 -0
  23. arkitekt_fastapi-1.0.0/arkitekt_fastapi/route_groups/states.py +34 -0
  24. arkitekt_fastapi-1.0.0/arkitekt_fastapi/route_groups/tasks.py +34 -0
  25. arkitekt_fastapi-1.0.0/arkitekt_fastapi/routes.py +365 -0
  26. arkitekt_fastapi-1.0.0/arkitekt_fastapi/sink/__init__.py +0 -0
  27. arkitekt_fastapi-1.0.0/arkitekt_fastapi/sink/backend.py +54 -0
  28. arkitekt_fastapi-1.0.0/arkitekt_fastapi/sink/memory_sink.py +49 -0
  29. arkitekt_fastapi-1.0.0/arkitekt_fastapi/sink/protocol.py +35 -0
  30. arkitekt_fastapi-1.0.0/arkitekt_fastapi/sql_lite/__init__.py +0 -0
  31. arkitekt_fastapi-1.0.0/arkitekt_fastapi/sql_lite/retriever.py +507 -0
  32. arkitekt_fastapi-1.0.0/arkitekt_fastapi/sql_lite/schema.py +119 -0
  33. arkitekt_fastapi-1.0.0/arkitekt_fastapi/sql_lite/sink.py +175 -0
  34. arkitekt_fastapi-1.0.0/arkitekt_fastapi/testing.py +988 -0
  35. arkitekt_fastapi-1.0.0/pyproject.toml +107 -0
@@ -0,0 +1,7 @@
1
+ .venv/
2
+ dist/
3
+ __pycache__/
4
+ *.py[cod]
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ .coverage
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.5
2
+ Name: arkitekt-fastapi
3
+ Version: 1.0.0
4
+ Summary: server mode for an Arkitekt app: serve a declared app over HTTP with FastAPI
5
+ Author-email: jhnnsrs <jhnnsrs@gmail.com>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: aiosqlite>=0.19
9
+ Requires-Dist: arkitekt-runtime>=1.0.2
10
+ Requires-Dist: arkitekt-spec>=1.1.1
11
+ Requires-Dist: fastapi>=0.100
12
+ Requires-Dist: httpx>=0.27
13
+ Requires-Dist: jsonpatch>=1.33
14
+ Requires-Dist: koil>=3.3.3
15
+ Requires-Dist: pydantic>=2.11
16
+ Description-Content-Type: text/markdown
17
+
18
+ # arkitekt-fastapi
19
+
20
+ Server mode for an Arkitekt app: serve an app declared with [arkitekt-spec](../arkitekt-spec)
21
+ as an HTTP service.
22
+
23
+ ```python
24
+ from fastapi import FastAPI
25
+ from arkitekt_fastapi import configure_fastapi
26
+
27
+ app = FastAPI()
28
+ configure_fastapi(app=app, app_registry=registry, db_file="journal.db")
29
+ ```
30
+
31
+ Every declared action becomes a route with an OpenAPI schema generated from its ports; states,
32
+ locks, tasks and the journal are served alongside. It runs actions on
33
+ [arkitekt-runtime](../arkitekt-runtime)'s execution core, the same one
34
+ [rekuest](../rekuest)'s distributed agent uses, but with an in-process transport: no
35
+ websockets, no rath, no rekuest server.
36
+
37
+ A served app registers with no one and so cannot call other actions: `Task.call` raises
38
+ `NoCallerError` at once.
39
+
40
+ `AsyncAgentTestClient` drives a served app in tests without a network.
@@ -0,0 +1,23 @@
1
+ # arkitekt-fastapi
2
+
3
+ Server mode for an Arkitekt app: serve an app declared with [arkitekt-spec](../arkitekt-spec)
4
+ as an HTTP service.
5
+
6
+ ```python
7
+ from fastapi import FastAPI
8
+ from arkitekt_fastapi import configure_fastapi
9
+
10
+ app = FastAPI()
11
+ configure_fastapi(app=app, app_registry=registry, db_file="journal.db")
12
+ ```
13
+
14
+ Every declared action becomes a route with an OpenAPI schema generated from its ports; states,
15
+ locks, tasks and the journal are served alongside. It runs actions on
16
+ [arkitekt-runtime](../arkitekt-runtime)'s execution core, the same one
17
+ [rekuest](../rekuest)'s distributed agent uses, but with an in-process transport: no
18
+ websockets, no rath, no rekuest server.
19
+
20
+ A served app registers with no one and so cannot call other actions: `Task.call` raises
21
+ `NoCallerError` at once.
22
+
23
+ `AsyncAgentTestClient` drives a served app in tests without a network.
@@ -0,0 +1,54 @@
1
+ """Server mode: a declared Arkitekt app served over HTTP by FastAPI.
2
+
3
+ The agent runs on arkitekt-runtime's execution core with an in-process transport; it
4
+ registers with no server and cannot call other actions (``Task.call`` raises
5
+ ``NoCallerError``).
6
+ """
7
+
8
+ from .auth import (
9
+ AuthenticationError,
10
+ ExpandUserFromRequest,
11
+ UserSource,
12
+ )
13
+ from .routes import (
14
+ add_agent_routes,
15
+ add_implementation_routes,
16
+ add_lock_routes,
17
+ add_schema_routes,
18
+ add_state_detail_routes,
19
+ add_state_routes,
20
+ configure_fastapi,
21
+ create_lifespan,
22
+ )
23
+ from .testing import (
24
+ AsyncAgentTestClient,
25
+ AgentTestClient,
26
+ AssignmentResult,
27
+ BufferedEvent,
28
+ create_test_app_and_agent,
29
+ )
30
+ from .agent import FastAPIConnectionManager, FastApiAgent, FastApiTransport
31
+
32
+
33
+ __all__ = [
34
+ "AuthenticationError",
35
+ "ExpandUserFromRequest",
36
+ "UserSource",
37
+ "FastApiAgent",
38
+ "FastApiTransport",
39
+ "FastAPIConnectionManager",
40
+ "configure_fastapi",
41
+ "create_lifespan",
42
+ "add_agent_routes",
43
+ "add_implementation_routes",
44
+ "add_lock_routes",
45
+ "add_schema_routes",
46
+ "add_state_detail_routes",
47
+ "add_state_routes",
48
+ # Testing utilities
49
+ "AgentTestClient",
50
+ "AsyncAgentTestClient",
51
+ "AssignmentResult",
52
+ "BufferedEvent",
53
+ "create_test_app_and_agent",
54
+ ]