feat: knowledge-serve HTTP API + SDK + API-key auth (self-host) - #16
Merged
Conversation
…y auth Adds the fourth surface: a Bun.serve HTTP API (knowledge-serve) wrapping the core lib PURE REMOTE per Amendment A1 (reads/writes the shared cloud Postgres directly). Public probes GET /health,/ready,/version + /openapi.json; versioned /v1 notes CRUD (knowledge_items) and /v1/registry, gated by @hasna/contracts API-key middleware. The typed SDK (KnowledgeApiClient) is generated from the serve OpenAPI document.
Appends the cloud knowledge_items table to pg-migrations and folds the @hasna/contracts api_keys migrations into the cloud migration runner (prefers an owner-scoped DSN; restores kit sslmode=require semantics under pg >= 8.22).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stands up the fourth surface (knowledge-serve) and brings @hasna/knowledge to the self-host standard.
Surfaces
knowledge) and MCP (knowledge-mcp) — unchanged, still real.GET /health,/ready(DB ping),/version->{status,version,mode},/openapi.json./v1: notes CRUD overknowledge_items, plus/v1/registry.@hasna/contractsAPI-key middleware (verifyApiKey+ApiKeyStorerevocation), scope grammarknowledge:read|write.KnowledgeApiClientgenerated from the serve OpenAPI document (scripts/generate-sdk.mjs, run inbuild).Storage / DB
knowledge_itemsmigration appended to the cloud schema;api_keysledger folded into the cloud migration runner. Runner prefers an owner-scoped DSN (HASNA_KNOWLEDGE_DATABASE_URL_OWNER) and restores kitsslmode=requiresemantics under node-postgres >= 8.22.Packaging / Deploy
knowledge-servebin, ARM64/bunDockerfile,docker-compose.yml, andhasna.contract.jsonupdated toclass=servicewith HTTP-service + client metadata.Proof
oss-fleet-prodbehind the shared ALB atknowledge.hasna.xyz./health,/ready,/versionreturn 200; unauthenticated/v1-> 401.