PHPackages                             stezkoy/flarum-ai-openreply - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. stezkoy/flarum-ai-openreply

ActiveFlarum-extension

stezkoy/flarum-ai-openreply
===========================

AI Open-Reply Extension for Flarum, powered by opencode.

0.0.1(today)00MITPHPPHP ^8.3

Since Aug 28Pushed todayCompare

[ Source](https://github.com/Stezkoy/flarum-ai-openreply)[ Packagist](https://packagist.org/packages/stezkoy/flarum-ai-openreply)[ RSS](/packages/stezkoy-flarum-ai-openreply/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (2)Used By (0)

AI Open-Reply Extension for Flarum
==================================

[](#ai-open-reply-extension-for-flarum)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667) [![Latest Stable Version](https://camo.githubusercontent.com/0ae17ca3f2c1e5ad5f02bcb27e8a7928b8845c2f5e2528a06fad81afad932aa4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7374657a6b6f792f666c6172756d2d61692d6f70656e7265706c792e737667)](https://packagist.org/packages/stezkoy/flarum-ai-openreply) [![Total Downloads](https://camo.githubusercontent.com/486489cb2ee886ebae20a03d222363432a0bbcbda5faf63b986c8f71ccb95ea4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7374657a6b6f792f666c6172756d2d61692d6f70656e7265706c792e737667)](https://packagist.org/packages/stezkoy/flarum-ai-openreply)

A [Flarum](http://flarum.org) extension.

Automatically replies to new discussions (or to every post made by the original poster) using an AI assistant. Replies are generated by [opencode](https://opencode.ai) — a headless [opencode serve](https://opencode.ai/docs/server/) instance — and posted by a designated assistant user.

Each discussion gets its own persistent opencode session, so the assistant keeps full context of the conversation. The assistant's reply is inserted into the thread as a text post.

A fork of `michaelbelgium/flarum-ai-autoreply`, reworked to work exclusively with the opencode 1.x server API.

Requirements
------------

[](#requirements)

- **Flarum &gt;= 2.0** and **PHP 8.3**
- A running [opencode server](https://opencode.ai/docs/server/) instance reachable from the Flarum host

Installation
------------

[](#installation)

Install with composer:

```
composer require stezkoy/flarum-ai-openreply
```

Then run migrations:

```
php flarum migrate
```

Installing opencode on Ubuntu
-----------------------------

[](#installing-opencode-on-ubuntu)

Install the `opencode` CLI on the machine that runs Flarum:

```
curl -fsSL https://opencode.ai/install | bash
```

The script installs opencode into `~/.opencode/bin` and prints next steps. Alternatively, install it globally via npm so the binary lands on your `PATH` (convenient for a systemd service later):

```
sudo apt-get install -y nodejs npm
sudo npm install -g opencode-ai
which opencode   # -> /usr/bin/opencode
```

Configure at least one AI provider for opencode (this is done once per machine, not per session):

```
opencode auth login
```

Setting up the opencode server
------------------------------

[](#setting-up-the-opencode-server)

> The AI provider(s) and API keys are configured inside opencode itself. This extension only talks HTTP to the opencode server.

### Safe default: localhost only (recommended)

[](#safe-default-localhost-only-recommended)

The server binds to `127.0.0.1` by default, so it is only reachable from the same machine. Start it with basic auth and a fixed port:

```
OPENCODE_SERVER_PASSWORD=your-strong-password opencode serve --hostname 127.0.0.1 --port 4096
```

The extension's default `http://localhost:4096` matches this command. Nothing is exposed to the network; you don't need to touch the firewall.

### Exposing it externally (not recommended)

[](#exposing-it-externally-not-recommended)

Only do this if the opencode server must live on a different machine than Flarum. Always set a password:

```
OPENCODE_SERVER_PASSWORD=your-strong-password opencode serve \
  --hostname 0.0.0.0 --port 4096 \
  --cors https://forum.example.com
```

Notes:

- With `--hostname 0.0.0.0` the server listens on all interfaces — restrict access with a firewall (`ufw allow from  to any port 4096`) and put it behind TLS (Nginx/Caddy reverse proxy) if possible.
- `--cors` is only needed for browser-based clients. This extension calls the API from PHP, so CORS is not required for it to work.

### `opencode serve` options

[](#opencode-serve-options)

FlagDescriptionDefault`--port`Port to listen on`4096``--hostname`Hostname to listen on`127.0.0.1``--mdns`Enable mDNS discovery (implies `0.0.0.0`)`false``--mdns-domain`mDNS domain name`opencode.local``--cors`Extra browser origins to allow (repeatable)`[]`Authentication is controlled with environment variables:

- `OPENCODE_SERVER_PASSWORD` — enables HTTP basic auth (required if the server is reachable by anyone else).
- `OPENCODE_SERVER_USERNAME` — basic auth username, defaults to `opencode` (the username the extension sends).

### Running as a systemd service

[](#running-as-a-systemd-service)

Create `/etc/systemd/system/opencode.service`:

```
[Unit]
Description=opencode headless server (AI Open-Reply)
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=opencode
WorkingDirectory=/var/lib/opencode
Environment=OPENCODE_SERVER_PASSWORD=your-strong-password
ExecStart=/usr/bin/opencode serve --hostname 127.0.0.1 --port 4096
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target
```

Adjust `ExecStart` if `opencode` lives elsewhere (`which opencode`), then:

```
sudo useradd -r -s /usr/sbin/nologin --home-dir /var/lib/opencode opencode
sudo mkdir -p /var/lib/opencode && sudo chown opencode:opencode /var/lib/opencode
sudo systemctl daemon-reload
sudo systemctl enable --now opencode
sudo systemctl status opencode
```

> The `User=opencode` account stores its own provider credentials and session data. Add `Environment=OPENCODE_SERVER_USERNAME=...` if you changed the basic auth username.

Server recommendations
----------------------

[](#server-recommendations)

opencode is a local LLM agent runtime: it loads the model, keeps the full conversation (and often the context window) in memory, and may spawn long-running background tasks. The headless server used by this extension is no exception, so plan its resources accordingly.

### Performance and stability

[](#performance-and-stability)

- **Run it next to Flarum on a dedicated machine (or container)**, not on the same process as PHP. Reply generation can be slow (tens of seconds to minutes), so isolate it from the web stack and give it its own CPU/memory budget and network.
- **Ensure the extension can reach the server.** The extension uses a 600-second request timeout (`OpencodeClient`), so slow generations are fine, but the connection timeout is 5 seconds — the server must respond quickly at the TCP level. Keep them on the same LAN / low-latency network to avoid spurious failures.
- **Watch memory.** Each discussion keeps its own persistent session; long conversations and large context windows accumulate in RAM. Set a safe limit on the number of active discussions or restart the service periodically (`Restart=always` above) to reclaim memory.
- **Use a fast network and a stable provider** for the upstream LLM. generation latency and provider rate limits dominate response time.
- **Apply an access token / basic auth** so the server is not left open (see authentication section above).

### Minimum / recommended hardware

[](#minimum--recommended-hardware)

These are rough guidelines for a CPU-only setup running a headless server that serves a small-to-medium forum. Rent a dedicated VM or container rather than sharing a tiny VPS with heavy applications.

Model size (approx.)RAMvCPUNotesSmall (cloud / hosted APIs)2–4 GB1–2Model runs on the provider, little local loadLocal 7–8B quantized model16 GB4Comfortable for multi-session useLarge 70B+ / many concurrent64 GB+8+Heavy; prefer hosted APIs insteadIf you are using hosted APIs (recommended for most forums), opencode itself only needs modest resources — the table's first row. Save the bigger rows for running local models.

In the extension's admin settings page:

- **opencode server URL** — the address of your headless opencode server (default `http://localhost:4096`).
- **opencode server username** — the basic auth username (default `opencode`). Used only when a password is set.
- **opencode server password** — the `OPENCODE_SERVER_PASSWORD` value if basic auth is enabled.
- **Agent** — an optional [opencode agent](https://opencode.ai/docs/agents/) to use; leave empty for the default agent. The agent defines the assistant's *behavior* (persona), not the model.
- **Model** — the model to use, in `provider/model` format. Pick one of the preset free models (`opencode/...`), "default" to use the agent's model, or select "Set my own" to type any model. This is independent of the agent: the agent fixes *how* it behaves, the model fixes *which* AI answers.
- **User assistant** — the user ID of the account that posts the AI replies (required).
- **User assistant badge** — the text shown below the assistant's posts.
- **Enable on discussion start** — when enabled, the AI replies only when a discussion is started. When disabled, the discussion becomes a chat between the OP and the assistant.
- **Tags** — restrict the assistant to specific tags.
- **Actions** — three buttons: **Check connection** (server health + current model), **Count sessions** (total sessions on the server and how many belong to this extension), and **Close all sessions** (closes this extension's sessions; other server sessions are left untouched).
- **Resource limits** — `max_active_sessions`, `max_messages_per_session`, `session_ttl_days`. Set 0 to disable a limit.

The agent and model are sent with each request, so new discussions pick up the latest setting. The assistant's instructions (a "system prompt") are configured on the agent itself, e.g. in `opencode.json`:

```
{
  "agent": {
    "prompt": "You are a helpful assistant on a Flarum forum. Answer in the language of the user's post."
  }
}
```

Also grant the "Use AI assistant" permission to the desired user groups.

Features
--------

[](#features)

- Auto-reply to new discussions using AI
- Chat mode: a discussion becomes a 1-on-1 chat between the OP and the assistant
- Persistent per-discussion context (one opencode session per discussion)
- Replies are posted as regular text posts by a designated assistant user
- Restrict the assistant to selected tags
- Permission controls for who can trigger the auto-reply

Updating
--------

[](#updating)

```
composer update stezkoy/flarum-ai-openreply
php flarum migrate
php flarum cache:clear
```

Links
-----

[](#links)

- [Packagist](https://packagist.org/packages/stezkoy/flarum-ai-openreply)
- [GitHub](https://github.com/stezkoy/flarum-ai-openreply)
- [Discuss](https://discuss.flarum.org/d/38244)

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e9fd2251b9526c53b9d9c1a7e559790f11510f47e171f1a97373ab7990507c44?d=identicon)[Stezkoy](/maintainers/Stezkoy)

---

Top Contributors

[![MichaelBelgium](https://avatars.githubusercontent.com/u/8951045?v=4)](https://github.com/MichaelBelgium "MichaelBelgium (47 commits)")[![Stezkoy](https://avatars.githubusercontent.com/u/50829118?v=4)](https://github.com/Stezkoy "Stezkoy (37 commits)")[![datlechin](https://avatars.githubusercontent.com/u/56961917?v=4)](https://github.com/datlechin "datlechin (20 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![flarum-bot](https://avatars.githubusercontent.com/u/39334649?v=4)](https://github.com/flarum-bot "flarum-bot (4 commits)")

---

Tags

aiopencodeflarumchatbotassistantautoreplyopenreply

### Embed Badge

![Health badge](/badges/stezkoy-flarum-ai-openreply/health.svg)

```
[![Health](https://phpackages.com/badges/stezkoy-flarum-ai-openreply/health.svg)](https://phpackages.com/packages/stezkoy-flarum-ai-openreply)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k555.0M2.9k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k832.6k58](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.3M49](/packages/tencentcloud-tencentcloud-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[flarum-lang/russian

Russian language pack for Flarum.

13129.1k](/packages/flarum-lang-russian)[flarum-lang/french

French language pack to localize the Flarum forum software plus its official and third-party extensions.

1941.0k](/packages/flarum-lang-french)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
