@persistica/flux-agent
v0.0.37
Published
Persistica Flux Agent
Readme
@persistica/flux-agent
Connect an Agent to a Flux network, join channels, and publish/subscribe over the Flux mesh.
bun add @persistica/flux-agent # or: npm i @persistica/flux-agentimport { FluxAgent } from '@persistica/flux-agent';
const agent = new FluxAgent('my-network-id');
// The argument is your claim — whatever your Authority accepts.
const connection = await agent.connect({ user: 'alice' });
const channel = await connection.joinChannel('connected-agents');
channel.onPublish((msg) => console.log('received', msg));
channel.publish({ text: 'hello mesh' });A network needs an Authority (
@persistica/flux-authority) running before any Agent can join. With none present,connect()stays in thewaiting-for-authoritystate and keeps retrying. Attachagent.onNetworkState(...)and wrapconnect()in atry/catchto observe this.
Full reference (options, connection states, error handling, troubleshooting): docs/sdk/flux-agent.md.
