Commit Graph
1589 Commits
Author SHA1 Message Date
Cooldude2606 e9a11013a4 Merge pull request #1236 from bbassie/chore/web-bundle-zip-zlib
Keep yauzl, browserify-zlib and assert out of the web interface
2026-11-20 20:55:12 +00:00
Cooldude2606andClaude Opus 5.5 59fa8403de Keep yauzl and yazl types out of lib's published declarations (#1235)
* Keep yauzl and yazl types out of lib's published declarations

ZipArchive exposed yauzl.ZipFile and yauzl.Entry in its public members
and zipOutputStream took a yazl.ZipFile, so @types/yauzl and @types/yazl
had to be runtime dependencies of @clusterio/lib. They pull in
@types/node and undici-types, about 2.7 MB in every server install.

Entries are now typed with a local ZipEntry interface, the yauzl
ZipFile is private, and zipOutputStream takes any object with an
outputStream and an error event. ZipWriter.addEntry reads the
compressed bytes through the new ZipArchive.openRawStream. Both type
packages move to devDependencies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Explain why ZipEntry is a local type

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 20:54:56 +00:00
Bastiaan 1c18dc3661 Merge pull request #1234 from bbassie/chore/inline-daily-rotate
Replace winston-daily-rotate-file with an in-repo transport
2026-11-20 20:54:42 +00:00
Bastiaan 81c7d24867 Merge pull request #1233 from bbassie/chore/drop-chalk
Replace chalk with util.styleText
2026-11-20 20:54:30 +00:00
Cooldude2606 bd41801c8d Prepare 2.1.1 2026-11-20 16:36:01 +00:00
bbassieandClaude Opus 5.5 c4a9545d28 Explain why ZipEntry is a local type
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 16:11:36 +00:00
Cooldude2606 34deacb881 Merge pull request #1230 from bbassie/feature/ctl-output-json
Add --output json to clusterioctl
2026-11-20 15:22:38 +00:00
bbassieandClaude Opus 5.5 6dc48b6732 Replace node:assert in link with a local assert
The assert polyfill is 28 KB in the web interface bundle and link only
uses it for plain truthiness checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 10:19:04 +00:00
bbassieandClaude Opus 5.5 4d7c1020b0 Use fflate for zlib in the web interface
ModPack and map exchange strings need synchronous inflate and deflate.
In the browser these came from the browserify-zlib polyfill, which
brings pako, assert and util along. The browser build now imports
fflate through a #zlib_sync subpath import, Node.js keeps node:zlib.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 10:18:37 +00:00
bbassieandClaude Opus 5.5 909f6ab08b Move ModInfo.fromModFile to ModStore.readModInfo
Reading a mod zip needs zip_ops, which pulled yauzl into the web
interface bundle through the data classes. ModStore is node only, so
the zip reading now lives there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 10:17:40 +00:00
bbassieandClaude Opus 5.5 aaafce4ace Keep yauzl and yazl types out of lib's published declarations
ZipArchive exposed yauzl.ZipFile and yauzl.Entry in its public members
and zipOutputStream took a yazl.ZipFile, so @types/yauzl and @types/yazl
had to be runtime dependencies of @clusterio/lib. They pull in
@types/node and undici-types, about 2.7 MB in every server install.

Entries are now typed with a local ZipEntry interface, the yauzl
ZipFile is private, and zipOutputStream takes any object with an
outputStream and an error event. ZipWriter.addEntry reads the
compressed bytes through the new ZipArchive.openRawStream. Both type
packages move to devDependencies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 20:39:58 +00:00
bbassieandClaude Opus 5.5 f49c633e77 Cover ctl output paths and stop deleting fields before printing
user show, mod list, mod search and mod-pack list deleted fields off the received objects to trim the table, which made their toJSON throw in wire mode. They now pick the fields for the human table only and print the whole objects in json and wire mode.

Add integration cases for config edit on the controller, a host and an instance, user show with instance stats, log query and host pending in human mode, mod-pack show with mods and settings, and wire output of the trimmed lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 16:05:08 +00:00
bbassieandClaude Opus 5.5 23187859d6 Address second review of ctl --output
CommandOutput.error takes a human reporter like result, so command errors log their message in human mode and print JSON in json and wire mode. table takes a map applied to each row in human mode, which note list, host plugin list, user list and save list now use. Rename streaming to streamingLog, and print startup errors with errorToJson directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 15:56:48 +00:00
bbassieandClaude Opus 5.5 bf33f4f52e Refuse to start without required mods and download them
requiredMods entries are now Factorio dependency strings, and a mod
listed twice gives a version range. The plugin loader validates them.

The host refuses to start an instance whose mod pack is missing a
required mod of a loaded plugin, has it disabled or has it outside the
version range.

On start the controller resolves the required mods of its plugins and
their dependencies for the default mod pack's Factorio version and
downloads the ones missing from the mod store. The resolver and portal
download move from the ControlConnection handlers into Controller
methods so both paths share them.

Subspace Storage requires subspace_storage >= 1.99.0, and the
integration tests build a stub of that mod for the test mod pack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 15:19:05 +00:00
bbassieandClaude Opus 5.5 a845b7ac52 Add requiredMods to plugin declarations
Plugins can list the Factorio mods they need under requiredMods. When an
instance starts, the host warns in the instance log about each loaded
plugin whose required mods are missing or disabled in the mod pack.
Subspace Storage declares the subspace_storage mod.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 15:07:06 +00:00
bbassieandClaude Opus 5.5 8550df69eb Address review of ctl --output
Add a wire output format that prints the toJSON format sent over the link. Commands without a result print {"success": true}, or "Command ran successfully" in human mode. The missing URL check throws a StartupError, unexpected command errors are rethrown to the startup handler, and startup errors log as fatal. user list, note list and host plugin list print the objects they received instead of their table rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 16:48:40 +00:00
Cooldude2606 b8e96989af Merge pull request #1228 from bbassie/feature/arm-headless
Support the ARM64 Linux headless build of Factorio
2026-11-18 13:33:28 +00:00
Cooldude2606 e814309750 Merge pull request #1227 from bbassie/fix/machine-details-on-start
Collect system info on start and when a host connects
2026-11-18 13:22:55 +00:00
bbassieandClaude Opus 5.5 10beffe167 Add --output json to clusterioctl
Commands print their results through a CommandOutput on the ctl link.
In json mode lists print as arrays of objects, other results as an
object, commands without a result print {} and failures print
{ error: ClassName, message } with exit code 1. log follow and
debug dump-ws print JSON lines.

Human output now goes through the shared asTable printer in every
command, results that were logged to stderr (role create, save and mod
upload/download) print to stdout, and config edit failures are logged
instead of printed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 13:07:18 +00:00
bbassieandClaude Opus 5.5 62f17a20af Take platform and arch in the lib headless helpers
hasFactorioHeadless(version, platform, arch) replaces the host's
hasArm64Headless, and factorioHeadlessUrl takes the platform too and
throws when Factorio has no headless build for it, which for now is
every platform except Linux. headlessUrl is marked deprecated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 11:15:40 +00:00
bbassieandClaude Opus 5.5 8374e4e3cd Start the autosave and system metrics intervals together
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 11:15:18 +00:00
bbassieandClaude Opus 5.5 5aaea1f213 Support the ARM64 Linux headless build of Factorio
Factorio publishes a linux-arm64 headless build from 2.1.18. On ARM64
Linux the host now downloads that build, refuses versions older than
2.1.18 that are not already installed, and finds the binary in bin/arm64
or bin/x64, whichever is present.

The host builds the download URL from the version instead of using
headlessUrl from the controller, so the version list on the wire stays
the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 11:14:54 +00:00
Cooldude2606 35f9609865 Merge pull request #1225 from bbassie/chore/drop-maintenance-node
Test only the oldest and latest supported Node.js in CI
2026-11-18 11:11:16 +00:00
bbassieandClaude Opus 5.5 211180a801 Type check Node.js code against ES2024
Node.js 22 supports all of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 16:13:55 +00:00
bbassieandClaude Opus 5.5 bb6ce06e5a Test only the oldest and latest supported Node.js in CI
The middle version adds two jobs without catching anything the top and
bottom of the range would miss. The host whitelist watcher now uses
Set.difference, which every supported Node.js has.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 16:05:57 +00:00
bbassieandClaude Opus 5.5 6363f15cb9 Replace SILENT_TEST and VERBOSE_TEST with TEST_OUTPUT
The reporter now handles all three modes: verbose prints everything,
normal prints output from failing tests and hooks, silent prints only
the results. The integration spawn helper and setup_logging no longer
filter output themselves.

npm install output in plugin install now goes through the logger
instead of inherited stdio, so it follows the log level and is
captured in tests like the rest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 12:31:45 +00:00
Daniel 5cf14eb15b Fix plugin list and header layout on mobile (#1223) 2026-11-17 12:14:36 +00:00
bbassieandClaude Opus 5.5 dbe56638f9 Collect system info on start and when a host connects
The controller polled system info only on the system metrics interval, so
restart required and machine details stayed empty for up to one interval
after the controller started or a host connected. Collect once right away
and then on every interval. Resumed sessions are skipped since the host
process kept running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 12:12:11 +00:00
BastiaanandClaude Opus 5.5 c2c7edf1b7 Default to the newest Base Game pack on new clusters (#1216)
A new cluster gets the default mod packs but controller.default_mod_pack_id
stays null, so the first Create save or Start fails with "Default mod pack
not set on controller". When seeding the packs, also point the default at
the newest Base Game pack, unless an admin already set one. Clusters that
already have mod packs are left alone. The config is written with the
mod packs on the next autosave or shutdown.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 11:03:22 +00:00
BastiaanandClaude Opus 5.5 09d79d775f Fix small web interface nits from the RC smoke test (#1215)
Fix the "Permamently" typo in the delete instance confirm.

The Search Mod Portal dialog now opens on the default mod pack's
Factorio version, or the newest known version when there is no default
pack. It used to always start on 2.0. A version the user picks still
sticks while the page is open.

The mod portal cache key used request.hide_deprecated directly, and the
web interface never sends it, so the controller logged "2.0-undefined".
A missing value now counts as false, the same default
fetchAllModsFromPortal already uses, so "2.1" and "2.1-false" share a
cache entry.

Closes #1209

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:57:32 +00:00
BastiaanandClaude Opus 5.5 c6bc81b0df Confirm controller and host restarts in the web UI (#1214)
Restart on the Controller and host pages sent the request on click. A
host restart stops every running instance on it, and they stay down
unless instance.auto_start is set, so one misclick takes servers
offline. Both now open a confirm dialog first, and the host one names
the running instances it will stop.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:51:34 +00:00
BastiaanandClaude Opus 5.5 8acb54985c Print Set values in ctl tables as lists (#1213)
user list, user show and role list passed UserDetails and Role objects
straight to as-table, whose default String() turns the roleIds,
instances and permissions Sets into "[object Set]". Move the as-table
setup into command_ops.ts with a cell printer that joins Sets with
", ", and use it for the user and role commands.

The integration tests for role list and user list now capture the
output and check it.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:44:39 +00:00
BastiaanandClaude Opus 5.5 ec2bc6504b Exit run scripts with the code that stopped the restart loop (#1212)
run-controller.sh and run-host.sh ran `exit $?` after the `[[ ]]` test,
so they exited with the test's status (0) even when the process exited
with 8 to ask not to be restarted. Save the status before testing it.

The .cmd scripts now pass 8 to `exit /b` explicitly instead of relying on
a bare `exit /b` to carry the errorlevel through.

Closes #1208.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:44:17 +00:00
Bastiaan 154ebe294a Merge pull request #1211 from bbassie/fix/pairing-restart-pending
Don't flag a restart when a new host pairs
2026-11-17 10:32:44 +00:00
Cooldude2606 61f2b01172 Prepare 2.1.0 2026-11-14 22:53:42 +00:00
Daniel 79ef9aaeb0 Merge branch 'master' into fix/stream-reject-closes-connection 2026-11-13 23:17:41 +01:00
Danielv123 b31983e30b Close requests moving too little instead of idle ones
Replace controller.transfer_idle_timeout with
controller.transfer_min_progress, the amount a request has to move
every 30 seconds, so a request trickled in is closed too. The check
now runs for every route.

Both ends of a proxy stream are judged on what the receiver has taken,
so a sender held back by a slow receiver is not closed.

Keep the limit on receiving headers, which turning off the request
timeout also turned off.
2026-11-13 22:59:12 +01:00
Bastiaan e37bf31cd3 Merge pull request #1200 from bbassie/feature/log-retention
Delete log files older than a configurable number of days
2026-11-13 19:30:24 +00:00
Cooldude2606 9ec817c1c6 Share one connect and close listener between subscribers (#1171)
* Share one connect and close listener between subscribers

Every EventSubscriber added its own connect and close listener to the
connector, and Link caps the connector at 20 listeners per event. The
web Control and App use 13 close listeners, so the 8th plugin
subscriber made the browser log MaxListenersExceededWarning on every
page load. Subscribers on a connector now share one listener for each
event, which leaves the cap in place for everything else.

* Keep the connector subscribers as a static on EventSubscriber
2026-11-11 17:49:48 +00:00
BastiaanandClaude Opus 5.5 e2185e9269 Detect Steam's Factorio install on macOS in the installer (#1195)
Steam on macOS puts Factorio in ~/Library/Application Support/Steam/steamapps/common/Factorio, with the app bundle inside it. Point at factorio.app/Contents like the existing /Applications entry, since that's where data/ lives and the host finds MacOS/factorio next to it.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 17:43:35 +00:00
BastiaanandClaude Opus 5.5 381d1d8573 Show online player count on the instance list (#1196)
Counts users per instance from the shared users subscription, the same
data the instance page's online players list reads, so the table adds
no per-row requests. The column is sortable and hidden without
core.user.subscribe.

Fixes #1193

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 17:42:16 +00:00
BastiaanandClaude Opus 5.5 ae707f7768 Always show the instance player list, collapsed when empty (#1197)
The list used to disappear when nobody was online. It is now a Collapse
that opens while players are online and closes when the last one leaves.
Once the user toggles it, their choice sticks for the page.

Fixes #1191

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 17:40:37 +00:00
BastiaanandClaude Opus 5.5 484cffc136 Add controller metrics for WebSocket session events (#1199)
Counts ready, resume, drop and session timeout per connection type
(host or control), plus resume attempts rejected for an unknown or
expired session. Lets a dashboard show hosts or users reconnecting.

Fixes #1192

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 17:37:13 +00:00
Danielv123 f86ebb6e66 Keep the connector subscribers as a static on EventSubscriber 2026-11-11 11:22:08 +01:00
bbassieandClaude Opus 5.5 3868efcead Focus the mod search inputs when they open
The "Add mods" card on the mod pack view mounts when shown, so autoFocus
is enough there. The Search Mod Portal modal stays mounted after the
first open, so it focuses the name input from afterOpenChange instead.

Fixes #1194

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 09:38:11 +00:00
Danielv123 49ddc9ebd1 Stop reading all rejected uploads and close stalled transfers
Guard the export, save, mod and stream routes with one middleware that
closes the connection of an upload answered before its body was read,
and of a transfer that has made no progress for the new
controller.transfer_idle_timeout.

The save and mod uploads share one handler that responds on the first
error instead of reading the rest of the upload, and uploads cut short
now fail the transfer instead of leaving it hanging.

Node's 5 minute limit on receiving a request is turned off so large
uploads over slow connections are not cut off.
2026-11-10 21:59:03 +01:00
Danielv123 60a4b103ab Merge remote-tracking branch 'origin/master' into fix/stream-reject-closes-connection 2026-11-10 21:32:23 +01:00
Cooldude2606andClaude Opus 5.5 7cf9cf8d3e Unpatch saves started with save patching disabled (#1184)
* Unpatch saves started with save patching disabled

Turning factorio.enable_save_patching off did nothing to a save that
was patched before. Its control.lua still loaded every module, so the
clusterio_api interface, player_sync's join handling and the other
module event handlers kept running with no plugin on the host side.

When patching is disabled the instance now restores the original
control.lua that patching kept as scenario.lua and removes the module
files, locale files included, as listed in clusterio.json. The patch
info stays with an empty module list so the patch number keeps
counting. Otherwise patching the save again would reuse the number
stored in the game and on_server_startup would not be raised. Data
the modules put in storage is left alone.

PatchInfo.fromSave dropped the version read from the save, so the
check against newer patch versions never fired. It now keeps it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Remove scenario.lua when unpatching a save

Unpatching moves scenario.lua back to control.lua instead of copying it, so the save only keeps clusterio.json for the patch number. Patching such a save again copies control.lua back to scenario.lua.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 20:58:13 +00:00
BastiaanandClaude Opus 5.5 6d9a32d28b Show localised names of mod settings in the web UI (#1181)
The mod pack page only looked up mod-setting-name.<name>, so settings
with a localised_name showed the internal name, and rich text tags in
the locale showed up as raw text.

Resolve localised_name and localised_description from the exported
settings prototypes against the exported locale, falling back to the
mod-setting-name/mod-setting-description keys and then the internal
name. The resolver handles parameters, the "" and "?" keys and
__ITEM__/__ENTITY__/__TILE__/__FLUID__ references. Rich text
formatting tags are removed and prototype icons are replaced with
their name.

Fixes #768

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 18:02:37 +00:00
bbassieandClaude Opus 5.5 513d964a8b Remove scenario.lua when unpatching a save
Unpatching moves scenario.lua back to control.lua instead of copying it, so the save only keeps clusterio.json for the patch number. Patching such a save again copies control.lua back to scenario.lua.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 17:21:19 +00:00