(runtime, options)
| 217 | SystemClipboardCommandOptions, |
| 218 | SystemClipboardCommandResult |
| 219 | > = async (runtime, options): Promise<SystemClipboardCommandResult> => { |
| 220 | if (options.action === 'read') { |
| 221 | if (!runtime.backend.getClipboard) { |
| 222 | throw new AppError( |
| 223 | 'UNSUPPORTED_OPERATION', |
| 224 | 'system.clipboard read is not supported by this backend', |
| 225 | ); |
| 226 | } |
| 227 | const result = await runtime.backend.getClipboard(toBackendContext(runtime, options)); |
| 228 | return { |
| 229 | kind: 'clipboardText', |
| 230 | action: 'read', |
| 231 | text: typeof result === 'string' ? result : result.text, |
| 232 | }; |
| 233 | } |
| 234 | |
| 235 | if (options.action !== 'write') { |
| 236 | throw new AppError('INVALID_ARGS', 'system.clipboard action must be read or write'); |
| 237 | } |
| 238 | if (!runtime.backend.setClipboard) { |
| 239 | throw new AppError( |
| 240 | 'UNSUPPORTED_OPERATION', |
| 241 | 'system.clipboard write is not supported by this backend', |
| 242 | ); |
| 243 | } |
| 244 | if (typeof options.text !== 'string') { |
| 245 | throw new AppError('INVALID_ARGS', 'system.clipboard write requires text'); |
| 246 | } |
| 247 | const backendResult = await runtime.backend.setClipboard( |
| 248 | toBackendContext(runtime, options), |
| 249 | options.text, |
| 250 | ); |
| 251 | const formattedBackendResult = toBackendResult(backendResult); |
| 252 | return { |
| 253 | kind: 'clipboardUpdated', |
| 254 | action: 'write', |
| 255 | textLength: Array.from(options.text).length, |
| 256 | ...(formattedBackendResult ? { backendResult: formattedBackendResult } : {}), |
| 257 | ...successText('Clipboard updated'), |
| 258 | }; |
| 259 | }; |
| 260 | |
| 261 | export const settingsCommand: RuntimeCommand< |
| 262 | SystemSettingsCommandOptions | undefined, |
nothing calls this directly
no test coverage detected