{"id":"flipbook-labs/agent-gateway","name":"agent-gateway","scope":"flipbook-labs","platform":"roblox","description":"Action registry and agent gateway for Roblox Studio plugins","version":"0.3.0","latest":"0.3.0","versions":["0.2.0","0.2.1","0.3.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{"roblox/jest":{"version":"^3.21.0","alias":"Jest"},"roblox/jest-globals":{"version":"^3.21.0","alias":"JestGlobals"}},"integrity":"31374a8f0e26fd376162487b08f78ec118097a3dc810db87be290b5823aefb2b","likes":0,"downloads":0,"install":"forest install flipbook-labs/agent-gateway","url":"https://forest.dev/p/roblox/flipbook-labs/agent-gateway","files":"https://api.forest.dev/ai/package/roblox/flipbook-labs/agent-gateway/files","readme":"# AgentGateway\n\nAgentGateway lets a Roblox Studio plugin offer its actions to agents. You define each action in Luau, and AgentGateway serves them through one `BindableFunction` built on a small, MCP-inspired protocol, so an agent can list what the plugin can do and call it.\n\n## Install\n\nWith Wally:\n\n```toml\n[dependencies]\nAgentGateway = \"flipbook-labs/agent-gateway@0.3.0\"\n```\n\nWith Lute, add this to `pkg.luau` and run `lute pkg install --vendor`:\n\n```luau\n[\"agent-gateway\"] = {\n\trev = \"v0.3.0\",\n\tsourceKind = \"github\",\n\tsource = \"https://github.com/flipbook-labs/agent-gateway\",\n},\n```\n\n## Use\n\nDefine an action, register it, and start the gateway from your plugin's script:\n\n```luau\nlocal AgentGateway = require(\"@pkg/AgentGateway\")\n\ntype Context = { plugin: Plugin }\n\nlocal config: AgentGateway.Config = {\n\tname = \"MyPluginGateway\",\n\tdescription = \"Actions for driving MyPlugin.\",\n\tinstructions = \"Call insertPart to add a Part to the Workspace.\",\n}\n\nlocal context: Context = { plugin = plugin }\n\nlocal actions: { AgentGateway.Action<Context> } = {\n\t{\n\t\tname = \"insertPart\",\n\t\ttitle = \"Insert Part\",\n\t\tdescription = \"Insert a new anchored Part into the Workspace.\",\n\t\trun = function(_context, _params)\n\t\t\tlocal part = Instance.new(\"Part\")\n\t\t\tpart.Anchored = true\n\t\t\tpart.Parent = workspace\n\t\t\treturn { name = part.Name }\n\t\tend,\n\t},\n}\n\nlocal registry = AgentGateway.createActionRegistry(config, context, actions)\nlocal cleanup = AgentGateway.createGateway(registry, config)\n\nplugin.Unloading:Connect(cleanup)\n```\n\nEvery gateway has the `AgentGateway` tag, wherever its plugin parented it, and is named after its config. Several plugins can have one, so an agent picks the gateway it wants by name and calls it:\n\n```luau\nlocal CollectionService = game:GetService(\"CollectionService\")\n\nlocal gateway\nfor _, tagged in CollectionService:GetTagged(\"AgentGateway\") do\n\tif tagged.Name == \"MyPluginGateway\" then\n\t\tgateway = tagged\n\tend\nend\n\ngateway:Invoke({ method = \"list\" })\ngateway:Invoke({ method = \"call\", action = \"insertPart\" })\n```\n\nFor a complete plugin, see [`examples/agent-plugin`](examples/agent-plugin).\n\n## Actions\n\nAn action takes a `name`, a `title`, a `description`, an optional `inputSchema`, and a `run` function. `run` receives the context you passed to `createActionRegistry` and the `params` the caller sent, which is an empty table when the caller sent none. Its return value becomes the `result`, and it must be JSON-encodable.\n\n`inputSchema` describes the `params` an action takes, using JSON Schema's `type`, `properties`, and `required` fields, plus `enum` on a property. Agents read it from the manifest, and AgentGateway checks `params` against it before `run`. Anything the schema can't express, such as a path that must resolve, is up to `run`:\n\n```luau\ninputSchema = {\n\ttype = \"object\",\n\tproperties = {\n\t\tname = { type = \"string\", description = \"Name for the new Part\" },\n\t},\n\trequired = { \"name\" },\n},\n```\n\nNames must be non-empty and unique, or `createActionRegistry` raises an error. An error thrown from `run` comes back to the caller as `{ ok = false, error = ... }` and does not stop the gateway. The registry copies the actions array when it is created, so later changes to that table have no effect.\n\n## Protocol\n\nThe gateway accepts two methods:\n\n- `list` returns `{ ok = true, result = manifest }`. The manifest holds `protocolVersion`, the config's `name`, `description`, and `instructions`, and each action's `name`, `title`, `description`, and `inputSchema`. It leaves out `run`.\n- `call` takes an `action` name and optional `params`. It returns `{ ok = true, result = ... }` on success, or `{ ok = false, error = ... }` for an unknown action, a non-string action name, an unknown method, `params` that don't match the schema, a result that isn't JSON-encodable, or an error thrown from `run`. The error says how to fix the call.\n\nEvery gateway's `BindableFunction` has the `AgentGateway` tag and carries `ProtocolVersion`, `Usage`, and, when the config has one, `Description` attributes. AgentGateway sets the protocol version and exports it with the tag as `PROTOCOL_VERSION` and `TAG`. Use the config's `instructions` to tell agents what to call first and what to wait for.\n\nSet `parent` in the config to place the gateway somewhere other than `CoreGui`. Creating a gateway with a name that already exists under the same parent replaces the old one. The function returned by `createGateway` destroys the gateway.\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## License\n\nMIT.\n","readmeTruncated":false}