@agentshouse/app-bridge
The types of the agents.house App bridge, an accessor and an in-page test host.
House builds the bridge object in every App it serves and hands it to the page
before the App's own scripts run; houseBridge() returns that object, so an App
carries no bridge code of its own. It carries these families: navigation,
ceremonies, installation, notifications, Telegram, status, App
release code, external calls, App messages, App and Site screenshot reads and the
Chat. docs/families.md describes each and the test host.
The bridge carries no credential handling and no Runtime family. House builds
the MD Runtime client into the page beside the bridge and serves it the Chat, so
the App imports, constructs and bundles neither: bridge.runtime resolves to the client.
House's guide to building an App is its Guide's apps/ pages, which guide/open opens.
Use
import { houseBridge } from '@agentshouse/app-bridge';
const bridge = houseBridge();
const md = await bridge.runtime;
bridge.onAddress((address) => render(address));
bridge.onStatus((status) => showSync(status.sync));
bridge.setTab({ title: 'Atlas (3)' });
open('/rooms/atlas');
function open(address) {
bridge.push(address);
}
async function manageSecurity(securityPath) {
try {
await bridge.ceremony(securityPath);
} catch (refusal) {
if (refusal.name === 'HouseCeremonyRefused') report(refusal.path);
}
}
bridge.runtime resolves to the MdRuntimeClient of @agentshouse/mdruntime/client,
whose README describes its members. Its call(method, params) is a remote procedure call
to a House act by its name, such as call('rooms/members/list', { room_ref }): HouseMethods
names each with House's own input, HouseParams<Name>, and answer, HouseResult<Name>.
Test without a House
import { houseBridge } from '@agentshouse/app-bridge';
import { createHouseBridgeTestHost } from '@agentshouse/app-bridge/test-host';
const host = createHouseBridgeTestHost({ address: '/rooms/atlas' });
const bridge = houseBridge();
bridge.push('/rooms/atlas/members');
host.open('/rooms/atlas');