IPC API Reference
OpenWork uses Electron’s IPC (Inter-Process Communication) system to communicate between the main process and the renderer process. The IPC API is exposed through the preload script to the React renderer.
API Structure
The IPC API is exposed via window.accomplish in the renderer process. All API methods return promises and handle errors through the promise rejection mechanism.
Task Operations
task:start(config)
Start a new automation task with the provided configuration.
| Parameter | Type | Required | Description |
|---|---|---|---|
config.prompt |
string | Yes | The task description or command |
config.taskId |
string | No | Optional task ID (auto-generated if not provided) |
config.sessionId |
string | No | Session ID for resuming conversations |
config.workingDirectory |
string | No | Working directory for the task (defaults to current) |
config.allowedTools |
string[] | No | List of allowed tools (max 20) |
config.systemPromptAppend |
string | No | Additional system prompt instructions |
config.outputSchema |
object | No | JSON schema for structured output |
Returns: Promise<Task> - The created task object
Example:
const task = await accomplish.startTask({
prompt: "Create a React component for a todo list",
workingDirectory: "/Users/user/project",
allowedTools: ["file", "terminal", "browser"]
});
task:cancel(taskId)
Cancel a running or queued task.
| Parameter | Type | Required | Description |
|---|---|---|---|
taskId |
string | Yes | The ID of the task to cancel |
Returns: Promise<void>
task:interrupt(taskId)
Interrupt a running task gracefully (like Ctrl+C).
| Parameter | Type | Required | Description |
|---|---|---|---|
taskId |
string | Yes | The ID of the task to interrupt |
Returns: Promise<void>
task:get(taskId)
Get a task from history.
| Parameter | Type | Required | Description |
|---|---|---|---|
taskId |
string | Yes | The ID of the task to retrieve |
Returns: Promise<Task | null> - Task object or null if not found
task:list()
List all tasks from history.
Returns: Promise<Task[]> - Array of task objects
task:delete(taskId)
Delete a task from history.
| Parameter | Type | Required | Description |
|---|---|---|---|
taskId |
string | Yes | The ID of the task to delete |
Returns: Promise<void>
task:clear-history()
Clear all task history.
Returns: Promise<void>
Session Management
session:resume(sessionId, prompt, existingTaskId?)
Resume a previous conversation session.
| Parameter | Type | Required | Description |
|---|---|---|---|
sessionId |
string | Yes | The session ID to resume |
prompt |
string | Yes | The user’s follow-up message |
existingTaskId |
string | No | Optional existing task ID to continue |
Returns: Promise<Task> - The resumed task
Permission Handling
permission:respond(response)
Respond to a permission request from a task.
| Parameter | Type | Required | Description |
|---|---|---|---|
response.taskId |
string | Yes | The task ID requesting permission |
response.decision |
‘allow’ | ‘deny’ | Yes | The permission decision |
response.requestId |
string | No | Request ID (for file permissions) |
response.selectedOptions |
string[] | No | Selected options (if applicable) |
response.message |
string | No | Custom response message |
Returns: Promise<void>
API Key Management
api-key:exists()
Check if an API key exists for the default provider.
Returns: Promise<boolean>
api-key:set(key)
Set an API key for the default provider (Anthropic).
| Parameter | Type | Required | Description |
|---|---|---|---|
key |
string | Yes | The API key to store |
Returns: Promise<void>
api-key:get()
Get the API key for the default provider.
Returns: Promise<string | null> - API key or null if not set
api-key:validate(key)
Validate an API key by making a test request.
| Parameter | Type | Required | Description |
|---|---|---|---|
key |
string | Yes | The API key to validate |
Returns: Promise<{ valid: boolean; error?: string }> - Validation result
api-key:validate-provider(provider, key)
Validate an API key for any provider.
| Parameter | Type | Required | Description |
|---|---|---|---|
provider |
string | Yes | Provider name (‘anthropic’, ‘openai’, ‘google’, ‘groq’) |
key |
string | Yes | The API key to validate |
Returns: Promise<{ valid: boolean; error?: string }> - Validation result
api-key:clear()
Clear the API key for the default provider.
Returns: Promise<void>
api-keys:all()
Get API key status for all providers.
Returns: Promise<Record<string, { exists: boolean; prefix?: string }>> - Provider status with key prefixes
api-keys:has-any()
Check if any API key exists for any provider.
Returns: Promise<boolean>
Settings Management
settings:debug-mode()
Get debug mode setting.
Returns: Promise<boolean>
settings:set-debug-mode(enabled)
Set debug mode setting.
| Parameter | Type | Required | Description |
|---|---|---|---|
enabled |
boolean | Yes | Enable debug mode |
Returns: Promise<void>
settings:app-settings()
Get all app settings.
Returns: Promise<{ debugMode: boolean; onboardingComplete: boolean; selectedModel?: { provider: string; model: string } }> - App settings object
settings:api-keys()
Get API key information (metadata only, keys are stored securely).
Returns: Promise<Array<{ id: string; provider: string; label: string; keyPrefix: string; isActive: boolean; createdAt: string }>> - API key metadata
settings:add-api-key(provider, key, label?)
Add an API key for a specific provider.
| Parameter | Type | Required | Description |
|---|---|---|---|
provider |
string | Yes | Provider name |
key |
string | Yes | The API key |
label |
string | No | Optional label for the key |
Returns: Promise<{ id: string; provider: string; label: string; keyPrefix: string; isActive: boolean; createdAt: string }> - Key metadata
settings:remove-api-key(id)
Remove an API key.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
string | Yes | The key ID to remove |
Returns: Promise<void>
Model Management
model:get()
Get the currently selected model.
Returns: Promise<{ provider: string; model: string } | null> - Selected model or null
model:set(model)
Set the selected model.
| Parameter | Type | Required | Description |
|---|---|---|---|
model.provider |
string | Yes | Model provider |
model.model |
string | Yes | Model identifier |
Returns: Promise<void>
Onboarding
onboarding:complete()
Get onboarding completion status.
Returns: Promise<boolean>
onboarding:set-complete(complete)
Set onboarding completion status.
| Parameter | Type | Required | Description |
|---|---|---|---|
complete |
boolean | Yes | Whether onboarding is complete |
Returns: Promise<void>
System Operations
getVersion()
Get the application version.
Returns: Promise<string>
getPlatform()
Get the current platform.
Returns: Promise<string> - ‘darwin’, ‘win32’, or ‘linux’
openExternal(url)
Open a URL in the external browser.
| Parameter | Type | Required | Description |
|---|---|---|---|
url |
string | Yes | The URL to open (must be http/https) |
Returns: Promise<void>
OpenCode CLI Operations
opencode:check()
Check if OpenCode CLI is installed.
Returns: Promise<{ installed: boolean; version: string | null; installCommand: string }> - CLI status
opencode:version()
Get OpenCode CLI version.
Returns: Promise<string | null> - Version or null if not installed
Event Listeners
The API also provides event subscription methods for real-time updates:
onTaskUpdate(callback)
Subscribe to task updates.
| Parameter | Type | Required | Description |
|---|---|---|---|
callback |
(event: unknown) => void |
Yes | Callback function |
Returns: () => void - Unsubscribe function
onTaskUpdateBatch(callback)
Subscribe to batched task updates for better performance.
| Parameter | Type | Required | Description |
|---|---|---|---|
callback |
(event: { taskId: string; messages: unknown[] }) => void |
Yes | Callback function |
Returns: () => void - Unsubscribe function
onPermissionRequest(callback)
Subscribe to permission requests.
| Parameter | Type | Required | Description |
|---|---|---|---|
callback |
(request: unknown) => void |
Yes | Callback function |
Returns: () => void - Unsubscribe function
onTaskProgress(callback)
Subscribe to task progress updates.
| Parameter | Type | Required | Description |
|---|---|---|---|
callback |
(progress: unknown) => void |
Yes | Callback function |
Returns: () => void - Unsubscribe function
onDebugLog(callback)
Subscribe to debug logs (only when debug mode is enabled).
| Parameter | Type | Required | Description |
|---|---|---|---|
callback |
(log: unknown) => void |
Yes | Callback function |
Returns: () => void - Unsubscribe function
onTaskStatusChange(callback)
Subscribe to task status changes.
| Parameter | Type | Required | Description |
|---|---|---|---|
callback |
(data: { taskId: string; status: string }) => void |
Yes | Callback function |
Returns: () => void - Unsubscribe function
Utility Methods
logEvent(payload)
Log an event (currently no-op, kept for compatibility).
| Parameter | Type | Required | Description |
|---|---|---|---|
payload.level |
string | No | Log level |
payload.message |
string | Yes | Log message |
payload.context |
object | No | Context data |
Returns: Promise<{ ok: boolean }> - Log result
Error Handling
All IPC methods handle errors internally and normalize them before throwing to the renderer. Common error types include:
ValidationError- Invalid input parametersPermissionError- Permission denied (file access, etc.)NetworkError- Network connectivity issuesTaskError- Task execution errorsStorageError- Data storage/retrieval errors
All errors include a human-readable message appropriate for display in the UI.