# atlibs-agents Launch [atirc](https://irc.fedfork.com) agents on socialweb.computer VMs, with [atlibs](https://knotless.dev/johnandersen777.bsky.social/atlibs) modules ([knotless://johnandersen777.bsky.social/atlibs](https://knotless.dev/johnandersen777.bsky.social/atlibs)). - `modules/agents`: the agents module. `composition.json` (written by `compose.ts`) composes it with the market requester and a bidder allowlist; `serve.json` (by `serve.ts`) puts the service behind a did:key ingress. - `modules/atirc`: post to and list an atirc channel. - `web/agents`, `web/atirc`: their pages. - `service/`: the agents service on the Rust host: `com.fedfork.agents.{launchAgent,getAgent,shutdownAgent}`, atproto service auth checked. - `records/`: the session records (`clientMetadata`) the modules run under; `records/wasm/`: what was published. - `lexicons/com/fedfork/agents`: the launch record and the service's methods. ## Check out the siblings The JS host and test harness come from an `atlibs` checkout beside this one. The compositions borrow modules from three more: `requester`, `policy-open` and `user-data` (the requester's userData hook default) from atlibs-socialweb-computer-requester, `ingress` from atlibs-fedproxy, and `iroh-user-data` (user-data's hook default) from atlibs-iroh. Rust gets `abi` by git (pinned in `Cargo.lock`), `atlibs-host` and `atlibs-iroh` at the revs `service/Cargo.toml` names. ```bash for r in atlibs@88b2ba8 atlibs-socialweb-computer-requester@aaa3724 atlibs-fedproxy@dfba4fb atlibs-iroh@c669c68; do git clone -q https://knotless.dev/johnandersen777.bsky.social/${r%@*} && git -C ${r%@*} checkout -q ${r#*@} done git clone https://knotless.dev/johnandersen777.bsky.social/atlibs-agents cd atlibs-agents ``` ## Build ```bash cargo wasm (cd ../atlibs-socialweb-computer-requester && cargo wasm) (cd ../atlibs-fedproxy && cargo wasm) (cd ../atlibs-iroh && cargo wasm) cargo service ``` ## Compose `compose.ts` and `serve.ts` write the compositions from `atlibs.modules.js`, the bindings of this repo's modules and the siblings' (regenerate after a sibling's module.json changes): ```bash r=../atlibs-socialweb-computer-requester/modules atlibs compose bindings $r/requester $r/policy-open $r/user-data ../atlibs-iroh/modules/iroh-user-data ../atlibs-fedproxy/modules/ingress node modules/agents/compose.ts | diff - modules/agents/composition.json node modules/agents/serve.ts | diff - modules/agents/serve.json ``` ## Test ```bash node --test modules/*/test.mjs web/*/*.test.mjs cargo service-test ``` The service tests run the real composition against a stub account. Each instance calls as the account only within its own module's session record: agents within `records/agents.json`, and the requester within `records/requester.json` from its own checkout. `policy-open` has no session record, so it can only make calls that need no scope. ## Run a page ```bash python3 -m http.server 8000 --bind 127.0.0.1 --directory web/atirc ``` Open http://127.0.0.1:8000/. `atlibs/` in each page links to `../atlibs/javascript/src`, and `modules/` links to this repo's build. ## Run the service It runs as an operator account (an app password, never read from the environment) and needs the cloud-init `user_data` its guests boot with: ```bash node ../atlibs-iroh/examples/iroh.mjs user-data ~/.atlibs-server/iroh_ed25519.pub > user_data.yaml ATLIBS_AGENTS_USER_DATA=user_data.yaml target/$(rustc --print host-tuple)/release/agents-service \ --app-password you.bsky.social --password-file - ``` Every flag and environment variable is described at the top of `service/src/main.rs`. ## Publish Install the `atlibs` CLI, then publish the session records and modules that changed: ```bash cargo install --locked --git https://knotless.dev/johnandersen777.bsky.social/atlibs --rev 88b2ba8 atlibs atlibs publish --dir modules --dry-run --as you.bsky.social atlibs publish --dir modules --as you.bsky.social ``` `--no-build` publishes your `cargo wasm` build. Without it, `atlibs publish` builds in a container from the paths atlibs' own layout uses (`rust/src`, `examples/rust`). For a `modules/` layout like this one, that needs a change in atlibs first.