DocsPlugins
UI SDK
Plugin UIs run in a sandboxed iframe and call host capabilities through the SDK built into the desktop app. The SDK updates with the desktop app; nothing to install.
Import
HTML
<link rel="stylesheet" href="pdt-plugin://__kit__/ui-kit.css">
<script type="module">
import { createBridge } from 'pdt-plugin://__kit__/plugin-sdk.js'
const bridge = createBridge()
const { theme, grantedPermissions } = await bridge.ready()
// ...set up the UI
bridge.reportAppReady()
</script>ui-kit.css is optional and provides buttons, inputs and light/dark themes that match the desktop app. It requires desktop 2.2.0 or later, so set "minHost": "2.2.0" in the manifest.
Common capabilities
JavaScript
// Clipboard (clipboard.read / clipboard.write)
const text = await bridge.clipboard.readText()
await bridge.clipboard.writeText('hello')
// Toast (notify)
await bridge.toast({ level: 'success', title: 'Done' })
// AI (ai.chat): without a model, routes by the user's current work mode
const { content } = await bridge.ai.chat({ prompt: 'Summarize in one sentence' })
// Local KV (storage.local); cloud KV is bridge.cloud.*, same usage
await bridge.storage.set('prefs', { dark: true })
const prefs = await bridge.storage.get('prefs')
// Run a command declared in your own manifest; returns the handler's result, throws on failure
const out = await bridge.commands.run('transform', { text: '{"a":1}', action: 'format' })| Namespace | Methods |
|---|---|
clipboard |
readText / writeText |
ai |
chat (single response) / stream + onEvent (streaming) / stop / capabilities |
image / video |
create / get / history |
storage / cloud |
get / set / remove / keys (local also has clear) |
user |
profile |
commands |
run(id, input, { timeoutMs }), only your own commands |
| Other | toast / hostInfo / invoke (low-level call) |
Notes
ready()returns the current theme and granted permissions; the SDK setsdata-themeon<html>automatically.- Call
reportAppReady()after the first render so the host knows the plugin started correctly. - The iframe only has
allow-scriptsand no same-origin access: no cookies and no access to the host page. - When the UI is not enough, put the logic in a command script and call it with
commands.run. Older desktop versions lack it; usebridge.invoke('command.invoke', { command, input }, { timeoutMs })instead. The example plugin shows the fallback. - The SDK only adds methods and never changes existing behavior, so old plugins keep working.
Problem with this page?Sent anonymously; your account is not recorded.