Expand description
§turul-ai-catalog-lambda
An AWS Lambda handler that serves an AI Catalog at the well-known URI
/.well-known/ai-catalog.json. The catalog is assembled from a
turul-ai-catalog-storage store, validated, and
served as canonical application/ai-catalog+json bytes.
Part of turul-agent-card.
GETandHEADon the well-known path answer 200 with the catalog media type; other methods answer 405 withAllow: GET, HEAD; any other path answers 404.- Cold start fails if the catalog cannot be assembled or has an error diagnostic. A later refresh that fails keeps serving the last good snapshot.
- The deployed function binary reads
TURUL_AI_CATALOG_ID(required withdynamodb, otherwise defaultdefault),TURUL_AI_CATALOG_TABLE(withdynamodb) andTURUL_AI_CATALOG_MAX_AGE_SECS(default 60).
§Feature flags
| Feature | Enables |
|---|---|
dynamodb | The turul-ai-catalog-lambda binary reads the catalog from a DynamoDB table, and table_name is available. |
local | The turul-ai-catalog-serve binary: the same handler on a plain HTTP port for local development. |
Without dynamodb the function binary serves an empty in-memory store.
§Example
use lambda_http::{Body, http::Request};
use turul_ai_catalog_lambda::{ServedCatalog, handle};
use turul_ai_catalog_storage::{CatalogId, InMemoryCatalogStore};
let store = InMemoryCatalogStore::new();
let catalog = CatalogId::new("default")?;
let served = ServedCatalog::assemble(&store, &catalog, std::time::SystemTime::now()).await?;
let request = Request::builder()
.uri("/.well-known/ai-catalog.json")
.body(Body::Empty)?;
assert_eq!(handle(&served, &request).status(), 200);§License
Apache-2.0.
Structs§
- Served
Catalog - Canonical bytes of an assembled catalog that passed
validatewith no error diagnostic, with what that assembly left out. - Snapshot
Cache - The last good
ServedCatalog, when it was last assembled or attempted, and the clock that decides when it is due. The clock lives here, never inhandle.
Enums§
- Cold
Start Error - Why the function cannot start or refresh its snapshot.
Constants§
- ALLOW
- Value of the
Allowheader on a 405 response (RFC 9110 section 15.5.6). - ID_VAR
- Environment variable naming the catalog in the store.
- MAX_
AGE_ VAR - Environment variable holding the snapshot refresh interval in seconds.
- TABLE_
VAR - Environment variable naming the DynamoDB table.
Functions§
- catalog_
id - Parses the catalog id from the value of
ID_VAR;rawisNonewhen the variable is unset. - handle
- Answers a request for the well-known path, routing by path, then method. Pure: no I/O, clock or state.
- max_age
- Parses the snapshot refresh interval from the value of
MAX_AGE_VAR: whole seconds, 60 when unset. - table_
name - Parses the DynamoDB table name from the value of
TABLE_VAR.