johnandersen777.bsky.social/atlibs-agents
agents and atirc modules for atlibs: launch agents from a composition, chat on atirc; pages and the agents service
0
0
// node modules/agents/serve.ts > modules/agents/serve.json
import { composition } from "../../../atlibs/javascript/src/compose/build.js";
import { ingress } from "../../atlibs.modules.js";
const ROUTES = {
launchAgent: ["Check the caller's service auth, create the launch record, launch the agent in the background; answers {rkey, uri, status}", "a caller on the internet asks to launch an agent"],
getAgent: ["Check the caller's service auth; the launch record and one read of the guest", "a caller on the internet reads an agent's status"],
shutdownAgent: ["Check the caller's service auth; revoke, release, clean up by rkey", "a caller on the internet shuts an agent down"],
};
const c = composition({
name: "atirc agents service",
description: "The public face of the agents service: the ingress module holds the did:key registration with xrpc.fedproxy.com and forwards the three agents XRPC methods to the host's handlers, which check atproto service auth and run composition.json (agents + requester).",
limits: { depth: 2, calls: 10000000 },
});
const front = c.instance("ingress", ingress, {
input: { routes: Object.keys(ROUTES).map((m) => `com.fedfork.agents.${m}`), deadlineMs: 28000 },
budget: { wallMs: 2000000000, events: 100000000, calls: 10000000 },
});
for (const [method, [description, reason]] of Object.entries(ROUTES)) c.route(front, `com.fedfork.agents.${method}`, c.handler(method, description), reason);
process.stdout.write(await c.json());