amfs-http-server 0.3.5__tar.gz → 0.3.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amfs-http-server
3
- Version: 0.3.5
3
+ Version: 0.3.6
4
4
  Summary: AMFS HTTP/REST API server with SSE support
5
5
  License-Expression: Apache-2.0
6
6
  Requires-Python: >=3.11
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "amfs-http-server"
3
- version = "0.3.5"
3
+ version = "0.3.6"
4
4
  description = "AMFS HTTP/REST API server with SSE support"
5
5
  requires-python = ">=3.11"
6
6
  license = "Apache-2.0"
@@ -66,6 +66,27 @@ from amfs_http.sse import SSEManager
66
66
 
67
67
  logger = logging.getLogger(__name__)
68
68
 
69
+
70
+ def _server_version() -> str:
71
+ """Return the deployed amfs-http-server package version.
72
+
73
+ Sourced from installed package metadata so it changes on every release —
74
+ unlike the per-entry ``amfs_version`` schema tag. This is the value to use
75
+ when telling deploys/revisions apart.
76
+ """
77
+ try:
78
+ from importlib.metadata import version
79
+
80
+ return version("amfs-http-server")
81
+ except Exception:
82
+ return "unknown"
83
+
84
+
85
+ # Set by the deploy pipeline (e.g. the git SHA) so a running revision is
86
+ # identifiable even between version bumps. Empty when not provided.
87
+ _BUILD_SHA = os.environ.get("AMFS_BUILD_SHA", "")
88
+ _SCHEMA_VERSION = MemoryEntry.model_fields["amfs_version"].default
89
+
69
90
  # ── Async adapter (hot-path, non-blocking) ──────────────────────────
70
91
  _async_adapter = None # AsyncPostgresAdapter | None, set in lifespan
71
92
 
@@ -94,7 +115,7 @@ async def _lifespan(application: FastAPI): # noqa: ARG001
94
115
  app = FastAPI(
95
116
  title="AMFS HTTP API",
96
117
  description="Agent Memory File System — REST API with SSE support",
97
- version="0.1.0",
118
+ version=_server_version(),
98
119
  lifespan=_lifespan,
99
120
  )
100
121
 
@@ -316,14 +337,25 @@ def _ensure_agent_owner(
316
337
  # ──────────────────────────────────────────────────────────────────────
317
338
 
318
339
 
340
+ def _health_payload() -> dict[str, str]:
341
+ payload = {
342
+ "status": "ok",
343
+ "version": _server_version(), # deploy/package version — changes per release
344
+ "schema_version": _SCHEMA_VERSION, # per-entry MemoryEntry schema tag
345
+ }
346
+ if _BUILD_SHA:
347
+ payload["build"] = _BUILD_SHA
348
+ return payload
349
+
350
+
319
351
  @app.get("/health")
320
352
  async def health() -> dict[str, str]:
321
- return {"status": "ok"}
353
+ return _health_payload()
322
354
 
323
355
 
324
356
  @app.get("/api/v1/health")
325
357
  async def health_v1() -> dict[str, str]:
326
- return {"status": "ok"}
358
+ return _health_payload()
327
359
 
328
360
 
329
361
  @app.get("/api/v1/auth/whoami")