@graview/hub
@graview/hub is one of the 16 npm packages of Graview, a TypeScript framework that derives an app’s interface, permissions and agent tools from one declaration. The local hub: one process on this machine that knows the Graview apps a person registered, opens each at its address and lets an agent act in each under that app's own rules. Experimental.
pnpm add @graview/hubEntry points: @graview/hub, @graview/hub/cli, @graview/hub/runtime, @graview/hub/runtime/in-app
What it is
The local hub: one process on this machine that knows the Graview apps a person registered with it, opens each at its address, and lets an agent act in each under that app's own rules. Experimental.
graview hub start # on 127.0.0.1:4977; prints the address to open and the line for an agent
graview hub add . # register this checkout, at the address its declaration says
graview hub list # each app, whether it can be read now, and its checkouts
graview hub scan ~/projects # the Graview apps in a folder, found by their manifests; --add registers them
graview hub open @neumo/pricing # print (and open) where an app opens
graview hub stopThe command line is the graview package; graview hub dispatches to this one's ./cli. Nothing here is a product's dependency.
What it keeps
Graview's folder is ~/.graview, or the folder GRAVIEW_HOME names (every test and harness names one, so a person's own is never touched):
| File | What |
|---|---|
hub.json | The registry: each app by its address (@<space>/<app>), with its checkouts and the one that is current |
hub.lock | Who runs the hub and where it answers, in a store hold's shape; a lock left by a process that died is taken over |
hub/hub.log | What the hub did |
door-key | This machine's user's key, which the dev servers' doors ask for |
hub-key | The hub's own key, made from door-key and written when the hub starts; the hub asks for this one, and nothing else does |
Registering
Explicit, always: graview hub add, or Register with local hub in the profile menu of an app's own page (graview preview, or a dev server with devHub() from @graview/ship/dev). graview serve --hub registers as it starts. A second checkout of an address already registered is added beside the first when the two share git history, and the first stays current until graview hub use chooses another; a folder that declares the same address with no shared history is refused, unless --same-app says it is a copy.
Finding the apps on this machine
graview hub scan [<folder>…], and "Find Graview apps on this machine" on the hub's page, walk the folders named (the home folder unless named), six folders deep unless told, never following a link or leaving the disk it started on, and stop at a time limit, at a count of folders, or when canceled. They walk past hidden folders (.git, .claude) and the folders in SCAN_SKIPS, wherever they are below a folder named: dependencies (node_modules, bower_components, CocoaPods' Pods folder, venv), build output (dist, build, out, target, Xcode's DerivedData folder, __pycache__, coverage), documentation and tests with their fixtures (docs, fixtures, __fixtures__, test, tests, e2e), scratch files (tmp), and the system's and other programs' own (the Library and AppData folders). A folder called docs, fixtures, tests or tmp is still looked at as an app itself (an app may be called fixtures); only what is below it is walked past. apps and examples are looked through. A skipped folder is looked through when it is named itself: graview hub scan ~/work/app/tests. A folder is an app when its package.json names a graview entry, or depends on Graview beside a declaration where the scaffold puts one (src/domain/app.ts), or when its app.json is a Graview document; each app of a monorepo is listed. The scan reads those small files and the address and name a declaration's text says, and never runs an app's code: adding one, which a person presses for (or --add), does, as graview hub add does. What it found is listed with the address each would land at, those not registered first.
An app in several checkouts of one repository is listed once. Linked worktrees, and clones sharing the repository's history, hold the same app at the same place in them, the registry's rule for one app (shared history) is the scan's, and the repository's own checkout is listed first with the others beside it ("also in 2 other checkouts", collapsed on the page); adding it registers that one, and another is added by naming its folder. The scan reads this from git's own files, a .git folder or the gitdir: a linked worktree's .git file names, and asks git for a repository's root commits once, not once a folder. A checkout named like a walk's or a batch's copy (walk3, -batch-, tmp…), or sitting in a temporary folder, is marked "looks like a scratch copy", and listed all the same.
Managing them from the page
"Apps on this machine", at the end of the Graverse's index, lists the apps registered and each checkout of them: remove an app or one checkout, or make another checkout current. Its "Add a folder" looks at a folder first (by its manifests, as a scan does) and says the address it lands at before anything is written: for an app that declares no address, a space to choose; for a second checkout of an app already here, that it is added beside it, or, with no shared history, a box to say it is a copy.
What it serves
| Path | What |
|---|---|
/ | The Graverse (@graview/graverse, which graview carries built): every app registered here as one page, found across and opened. Its files are under /graverse/. Started without it, the apps registered here, each linked |
/@<space>/<app>/ | The app's own page: through the serve or preview that holds its store, or served by the hub when nobody does. It never opens a store another process holds. |
/@<space>/<app>/mcp | The app's own tools, as graview mcp gives them, over Streamable HTTP, acting under the app's rules and what its seat may see |
/mcp | The hub's own tools: describe_universe, find_everywhere and route across every app registered here, each app asked as the seat the hub holds there, and open_app, which says where one opens and where its tools are |
/universe/describe, /universe/find, /universe/route | The same three answers as JSON, for a page |
/universe/cloud | One app's records as the seat sees them, for the Graverse to draw as the camera comes near (appCloud): asked live, capped, never kept |
/hub/apps, /hub/health | Registering (a whole path), removing and listing; health |
/hub/look, /hub/use | A folder looked at before it is added, by its manifests alone; another checkout made current |
/hub/scan | A scan for the apps on this machine, a line of JSON at a time (NDJSON) as it walks; it stops when its asker hangs up |
It listens on 127.0.0.1 only and answers only this machine's user: a program sends the hub's key as Authorization: Bearer, and a page is given a cookie, good until the hub stops, for opening the address graview hub start printed. Every route above is admitted the same way. A browser that opens the bare address without the key is shown a short page saying to run graview hub open, and nothing about the hub or its apps; a program that asks for JSON is answered in JSON. An app's own server sends the key only once the listener at the lock's address has proved it holds it.
An app served on localhost is told to the hub at 127.0.0.1 when it listens there (graview serve and graview preview do by default): a browser counts the two names as different sites, and a link from the hub's page would otherwise arrive without the app's cookie.
claude mcp add --transport http graview http://127.0.0.1:4977/mcp --header "Authorization: Bearer $(cat ~/.graview/hub-key)"The universe: @graview/hub/runtime
Reaches no node: builtin, so it runs in a Worker as it runs on a laptop.
import { describeUniverse, findEverywhere, route, universeTools, type UniverseHost } from "@graview/hub/runtime";
const found = await findEverywhere(host, { person }, "florist status=open price>10");A host supplies only what is its own: which apps a seat reaches, the seat it holds in each, the shapes it keeps, how a question reaches an app's store, the limits it sets, and, if it has one, a tie-break for route. The framework owns the rest: the query, pruning, the order apps are asked in, deadlines, merging, the cursor, route's matching, and every sentence an answer says.
describeUniverse: every app's shape at once, trimmed to the seat, and what the seat sees of each now, a bounded number of apps at a time.findEverywhere(andfindEverywhereStream): words,kind:, field conditions (status=open,price>10,due<=2026-12-01),app:andspace:; every field that matched; slow and refused apps named, never dropped; a cursor that never widens reach.route: which app, which record, which act a sentence is about. It changes nothing.universeTools: the three as tools, for an MCP endpoint.appCloud: one app's records as the seat sees them, live and capped, for a page that draws them.
The in-app end: @graview/hub/runtime/in-app
answerInApp(store, app, principal, question) answers one question as one seat, through the seat's own view of the store, inside the question's own budget. It imports none of the fan-out, so an app's server carries only it. graview serve and graview preview answer it at POST /graview/universe.
The main entry
For a host or a test that runs the hub in its own process: startHub, registerFolder, listApps, readRegistry and the rest. ./cli is hub(argv) and HUB_USAGE. LocalUniverseHost is the universe over this machine's registry.
License: Elastic License 2.0.
What it exports (38)
Read off the package's own barrel, so this is what is there today.
addCheckoutaddressOfPathCOLLECTION_FOLDERScurrentOfemptyRegistryfolderAddressfolderAskedfolderNameOfformatAddressgitFactshasStoreholderOfHUB_PERSONHUB_PORThubFileshubHomehubPathOfhubPersonlistAppsLocalUniverseHostlookAtFolderparseAddressreadCheckoutreadRegistryregisterFolderremoveFromsayAppSCAN_SKIPSscanForAppsseatInAppslugOfstartHubstateOfstoreOfunregisteruseCheckoutuseFolderwriteRegistry