Host.clipboardWrite
luastra/hostHost.clipboardWrite(value: string): RequestId
Requests that the host place a bounded string on the system clipboard and returns a RequestId for completion. Clipboard access remains an explicit capability rather than a hidden side effect.
Before you use it
Add luastra/host to this module's dependencies in luastra.json, then import it with require("luastra/host"). Declare clipboard.write in luastra.json. Save the returned RequestId with its purpose and implement app.resolve.
How it fits
The function starts an asynchronous host request and returns immediately. app.resolve receives its success payload or stable failure code; availability and permission can vary by host.
When to use it
Use Host.clipboardWrite after a clear user action such as Copy code or Copy link. Confirm success accessibly when useful and avoid copying secrets or personal data without an explicit user expectation.
Parameters
| Parameter | Type / values | Description |
|---|---|---|
| value | string | Bounded text copied after an explicit user action. |
Returns
RequestId — an opaque request identifier used to correlate the asynchronous completion in app.resolve.
What happens next
A RequestId now, followed later by one matching app.resolve completion.
Failures and fixes
Undeclared capability, unavailable host support, denied permission, invalid input, deadline, network, or internal failure reaches the bounded failure path. Public completion codes are CANCELLED, DEADLINE, FORBIDDEN, INTERNAL, NETWORK, UNAUTHORIZED, and VALIDATION.
Availability
Public-source alpha capability API in 0.5.0-alpha; verify each claimed host independently.
Focused example
local Host = require("luastra/host")
local requestId = Host.clipboardWrite("luastra check")