Skip to content

Host API

The Lua sandbox exposes a single host table named waydir. Functions either do small synchronous work inside the sandbox or emit effects that the Flutter host applies after run(ctx) returns.

Functions

CallPermissionEffect
waydir.toast(msg)noneShows a short toast message.
waydir.notify({ title, message, level, persistent })noneCreates a notification. level can be info, success, warn, or error.
waydir.dialog({ title, fields, submit_action })noneShows a form and re-runs the action with ctx.form.
waydir.set_setting(key, value)nonePersists one setting value for this plugin.
waydir.refresh()noneRefreshes the current file list.
waydir.log(msg)noneWrites to the Waydir log.
waydir.exec(cmd, args)execRuns a short external command and waits for it.
waydir.run_task({ title, cmd, args, cwd, timeout })execRuns a long external command outside the Lua sandbox.
waydir.read_text(path)fsReads a UTF-8 text file, capped at 4 MiB.
waydir.write_text(path, text)fsWrites a text file.
waydir.mkdir(path)fsCreates a directory and parents.
waydir.exists(path)fsReturns whether a path exists.
waydir.list(path)fsLists a directory as { name, path, is_dir } rows.
waydir.copy(src, destDir)fsQueues a copy into destDir using Waydir operations.
waydir.move(src, destDir)fsQueues a move into destDir using Waydir operations.
waydir.delete(path)fsQueues a permanent delete with host-side confirmation.
waydir.trash(path)fsQueues a move to trash with host-side confirmation.

Notifications

lua
waydir.notify({
  title = "New from Template",
  message = "Created README.md",
  level = "success",
  persistent = false,
})

title is optional. message is required.

Quick commands

Use waydir.exec for short commands only.

lua
waydir.exec("code", { ctx.dir })

Non-zero exit codes are logged. Missing binaries or process launch errors fail the plugin invocation.

Long tasks

Use waydir.run_task for compression, conversion, extraction, uploads, or anything that may be slow.

lua
waydir.run_task({
  title = "Extract archive",
  cmd = "7z",
  args = { "x", "/tmp/archive.zip", "-o/tmp/archive", "-y" },
  cwd = ctx.dir,
  timeout = 3600,
})

Task timeout is in seconds. If omitted, Waydir uses 600 seconds. The maximum is 21600 seconds.

File operations

The direct file helpers (read_text, write_text, mkdir, exists, list) run in the native plugin runtime and require fs.

The queued operations (copy, move, delete, trash) are applied through Waydir's normal operation system, so they get progress, cancellation, and host confirmation for destructive actions.

Sandbox limits

LimitValue
Lua standard librariestable, string, math
Missing librariesos, io, require
Load timeout5 seconds
Invoke timeout5 seconds
read_text cap4 MiB

Each run starts with a fresh Lua VM. Do not rely on module-level variables persisting between clicks.

MIT licensed. Open source.