### Quick Start: Initialize and Run Task with @accomplish_ai/agent-core
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/README.md
Demonstrates the initialization of storage and a task manager, followed by starting a task with various event handlers. This example showcases the core workflow of using the agent-core library.
```typescript
import { createStorage, createTaskManager } from '@accomplish_ai/agent-core';
// Initialize storage (SQLite + encrypted secure storage)
const storage = createStorage({
databasePath: '/path/to/accomplish.db',
userDataPath: '/path/to/user-data',
});
storage.initialize();
// Set up a task manager
const taskManager = createTaskManager({
defaultWorkingDirectory: process.cwd(),
isCliAvailable: async () => true,
adapterOptions: {
platform: process.platform,
isPackaged: false,
tempPath: '/tmp',
getCliCommand: () => ({ command: 'opencode', args: [] }),
buildEnvironment: async () => ({ ...process.env }),
buildCliArgs: async (config, taskId) => [config.prompt],
},
});
// Start a task
await taskManager.startTask(
'task-1',
{ prompt: 'Hello' },
{
onMessage: (msg) => console.log(msg),
onProgress: (p) => console.log(p.stage),
onPermissionRequest: (req) => console.log(req),
onComplete: (result) => console.log('Done:', result),
onError: (err) => console.error(err),
},
);
```
--------------------------------
### SKILL.md Frontmatter Example
Source: https://github.com/accomplish-ai/accomplish/blob/main/apps/desktop/bundled-skills/skill-creator/SKILL.md
Illustrates the required YAML frontmatter for a SKILL.md file, including name, description, and an optional command for triggering the skill.
```yaml
name: Skill Name
description: A brief description of what the skill does.
command: /optional-command
```
--------------------------------
### Installation
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/dev-browser-mcp/README.md
Instructions on how to install the necessary dependencies for the dev-browser-mcp server.
```APIDOC
## Installation
### Description
Installs the project dependencies using npm.
### Method
`npm` command
### Endpoint
N/A
### Parameters
None
### Request Example
```bash
npm install
```
### Response
N/A
```
--------------------------------
### Ask User Question - Example: Simple Yes/No Confirmation
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/ask-user-question/SKILL.md
A straightforward example of using AskUserQuestion for a simple yes/no confirmation before sending an email. It presents minimal options for a quick decision.
```javascript
AskUserQuestion({
"questions": [{
"question": "Should I proceed with sending this email?",
"header": "Send email",
"options": [
{ "label": "Send", "description": "Send the email now" },
{ "label": "Cancel", "description": "Don't send" }
]
}]
})
```
--------------------------------
### Ask User Question - Example: Organization Preferences
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/ask-user-question/SKILL.md
An example of using the AskUserQuestion tool to inquire about user preferences for organizing files. It includes a question, a header, and multiple descriptive options.
```javascript
AskUserQuestion({
"questions": [{
"question": "How would you like to organize your Downloads folder?",
"header": "Organize",
"options": [
{ "label": "By file type", "description": "Group into Documents, Images, Videos, etc." },
{ "label": "By date", "description": "Group by month/year" },
{ "label": "By project", "description": "You'll help me name project folders" }
]
}]
})
```
--------------------------------
### Example Verification Flow
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/dev-browser/SKILL.md
Demonstrates a verification workflow after performing an action. It shows clicking a submit button and then verifying the appearance of a success message using 'browser_is_visible'.
```javascript
# Click a submit button
browser_click(ref="e5")
# VERIFY: Check if success message appeared
browser_is_visible(selector=".success-message")
# Output: true
```
--------------------------------
### Spawn Node.js/npx with Bundled Binaries
Source: https://github.com/accomplish-ai/accomplish/blob/main/docs/architecture.md
Illustrates how to spawn Node.js or npx processes within the main process of the desktop application. It's crucial to add the bundled Node.js bin directory to the PATH environment variable to ensure these processes can be found and executed correctly, especially on systems without a system-wide Node.js installation.
```typescript
import { spawn } from 'child_process';
import { getNpxPath, getBundledNodePaths } from '@accomplish_ai/agent-core/utils';
const npxPath = getNpxPath();
const bundledPaths = getBundledNodePaths();
let spawnEnv: NodeJS.ProcessEnv = { ...process.env };
if (bundledPaths) {
const delimiter = process.platform === 'win32' ? ';' : ':';
spawnEnv.PATH = `${bundledPaths.binDir}${delimiter}${process.env.PATH || ''}`;
}
spawn(npxPath, ['-y', 'some-package@latest'], {
stdio: ['pipe', 'pipe', 'pipe'],
env: spawnEnv,
});
```
--------------------------------
### Install Dependencies with npm
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/dev-browser-mcp/README.md
Installs the necessary project dependencies using npm. This is a prerequisite for running the server.
```bash
npm install
```
--------------------------------
### Ask User Question - Example: Destructive Action Confirmation
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/ask-user-question/SKILL.md
Demonstrates using AskUserQuestion to confirm a potentially destructive action, such as deleting files. It provides clear options for the user to proceed, review, or cancel.
```javascript
AskUserQuestion({
"questions": [{
"question": "Delete these 15 duplicate files?",
"header": "Confirm",
"options": [
{ "label": "Delete all", "description": "Remove all 15 duplicates" },
{ "label": "Review first", "description": "Show me the list before deleting" },
{ "label": "Cancel", "description": "Don't delete anything" }
]
}]
})
```
--------------------------------
### Skill Directory Structure
Source: https://github.com/accomplish-ai/accomplish/blob/main/apps/desktop/bundled-skills/skill-creator/SKILL.md
Defines the standard directory structure for an AI skill, including the mandatory SKILL.md file and optional bundled resources like scripts, references, and assets.
```tree
skill-name/
├── SKILL.md (required)
│ ├── YAML frontmatter metadata (required)
│ │ ├── name: (required)
│ │ ├── description: (required)
│ │ └── command: (optional, e.g., /my-skill)
│ └── Markdown instructions (required)
└── Bundled Resources (optional)
├── scripts/ - Executable code (Python/Bash/etc.)
├── references/ - Documentation loaded as needed
└── assets/ - Files used in output (templates, icons, fonts, etc.)
```
--------------------------------
### Configure Browser Connection Modes for Accomplish AI Agent
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/README.md
Demonstrates how to configure the Accomplish AI agent's browser connection using the `generateConfig` function. It shows examples for the default 'builtin' mode, connecting to a 'remote' Chrome DevTools Protocol endpoint with optional authentication, and disabling browser tools entirely with 'none'.
```typescript
import { generateConfig, type BrowserConfig } from '@accomplish_ai/agent-core';
// Default — uses the dev-browser HTTP server
generateConfig({ browser: { mode: 'builtin' } });
// Remote CDP — connect to any Chrome DevTools Protocol endpoint
generateConfig({
browser: {
mode: 'remote',
cdpEndpoint: 'http://localhost:9222',
cdpHeaders: { 'X-CDP-Secret': 'token' }, // optional auth
},
});
// No browser — omits browser tools entirely
generateConfig({ browser: { mode: 'none' } });
```
--------------------------------
### Manage Custom Prompt Skills with TypeScript
Source: https://context7.com/accomplish-ai/accomplish/llms.txt
Manages custom prompt skills (SKILL.md files) that define reusable automation workflows. Skills can be bundled with the app or user-installed, and contain frontmatter metadata plus markdown instructions. This manager allows initialization, listing, retrieval, enabling/disabling, installation, and deletion of skills.
```typescript
import {
createSkillsManager,
type SkillsManagerOptions,
type Skill,
} from '@accomplish_ai/agent-core';
const options: SkillsManagerOptions = {
bundledSkillsPath: '/app/resources/bundled-skills',
userSkillsPath: '/Users/me/.accomplish/skills',
};
const skillsManager = createSkillsManager(options);
await skillsManager.initialize();
// List all skills
const allSkills: Skill[] = skillsManager.getAllSkills();
console.log('Available skills:', allSkills.map(s => s.name));
// Get enabled skills only
const enabledSkills = skillsManager.getEnabledSkills();
// Find a specific skill
const codeReviewSkill = skillsManager.getSkillById('code-review');
if (codeReviewSkill) {
console.log('Skill:', codeReviewSkill.name);
console.log('Description:', codeReviewSkill.description);
console.log('Trigger:', codeReviewSkill.trigger);
// Get the raw markdown content
const content = skillsManager.getSkillContent('code-review');
console.log('Content:', content?.substring(0, 200));
}
// Enable/disable a skill
skillsManager.setSkillEnabled('code-review', true);
skillsManager.setSkillEnabled('deprecated-skill', false);
// Install a new skill from file
const newSkill = await skillsManager.addSkill('/path/to/my-custom-skill/SKILL.md');
if (newSkill) {
console.log('Installed:', newSkill.name);
}
// Remove a user-installed skill
const deleted = skillsManager.deleteSkill('my-custom-skill');
console.log('Deleted:', deleted);
// Reload all skills from disk
const refreshedSkills = await skillsManager.resync();
```
--------------------------------
### Importing Fixtures and Page Objects in TypeScript
Source: https://github.com/accomplish-ai/accomplish/blob/main/apps/desktop/e2e/README.md
Demonstrates how to import necessary testing utilities and page object models for writing tests. This setup is crucial for maintaining a structured and maintainable test suite.
```typescript
import { test, expect } from '../fixtures';
import { HomePage } from '../pages';
```
--------------------------------
### Create and Manage AI Tasks with TypeScript
Source: https://context7.com/accomplish-ai/accomplish/llms.txt
This snippet demonstrates how to create and manage AI tasks using the `createTaskManager` function from the `@accomplish_ai/agent-core` package. It covers configuring the task manager, defining callbacks for task events (progress, permissions, completion, errors), starting a task, checking its status, canceling it, and cleaning up the manager. Key configurations include adapter options for the CLI, default working directory, and maximum concurrent tasks.
```typescript
import {
createTaskManager,
type TaskManagerOptions,
type TaskCallbacks,
type TaskConfig,
} from '@accomplish_ai/agent-core';
// Configure the task manager
const options: TaskManagerOptions = {
adapterOptions: {
platform: process.platform,
isPackaged: false,
tempPath: '/tmp/accomplish',
getCliCommand: () => ({ command: 'opencode', args: [] }),
buildEnvironment: async (taskId) => ({
TASK_ID: taskId,
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY,
}),
buildCliArgs: async (config, taskId) => [
'--prompt', config.prompt,
'--task-id', taskId,
'--model', config.modelId || 'anthropic/claude-opus-4-5',
],
},
defaultWorkingDirectory: process.cwd(),
maxConcurrentTasks: 10,
isCliAvailable: async () => true,
onBeforeTaskStart: async (callbacks, isFirstTask) => {
if (isFirstTask) {
callbacks.onProgress({ stage: 'initializing', message: 'First task setup...' });
}
},
};
const taskManager = createTaskManager(options);
// Define task callbacks
const callbacks: TaskCallbacks = {
onBatchedMessages: (messages) => {
messages.forEach(msg => console.log(`[${msg.type}] ${msg.content}`));
},
onProgress: (event) => {
console.log(`Progress: ${event.stage} - ${event.message}`);
},
onPermissionRequest: (request) => {
console.log('Permission requested:', request.message);
// Handle file permission or user question
},
onComplete: (result) => {
console.log('Task completed:', result.status);
},
onError: (error) => {
console.error('Task error:', error.message);
},
onTodoUpdate: (todos) => {
console.log('Todos updated:', todos.length, 'items');
},
onStepFinish: (data) => {
console.log(`Step finished: ${data.reason}, tokens: ${data.tokens?.input}/${data.tokens?.output}`);
},
};
// Start a task
const taskConfig: TaskConfig = {
prompt: 'Organize all PDF files in ~/Documents by date',
workingDirectory: '/Users/me/Documents',
modelId: 'anthropic/claude-opus-4-5',
};
const task = await taskManager.startTask('task-001', taskConfig, callbacks);
console.log('Task started:', task.id, task.status);
// Check task status
console.log('Is running:', taskManager.isTaskRunning('task-001'));
console.log('Active tasks:', taskManager.getActiveTaskIds());
// Cancel a task
await taskManager.cancelTask('task-001');
// Cleanup
taskManager.dispose();
```
--------------------------------
### Configure MCP Server Environment for Bundled Node.js
Source: https://github.com/accomplish-ai/accomplish/blob/main/docs/architecture.md
Shows how to pass the bundled Node.js binary directory path to MCP server configurations via the NODE_BIN_PATH environment variable. This ensures that spawned servers can correctly locate and use the bundled Node.js executables.
```typescript
environment: {
NODE_BIN_PATH: bundledPaths?.binDir || '',
}
```
--------------------------------
### Manage Tasks via IPC in Accomplish AI Desktop App
Source: https://context7.com/accomplish-ai/accomplish/llms.txt
This snippet demonstrates how to interact with task management functionalities from the renderer process using Electron's IPC. It covers starting, resuming, canceling, interrupting, retrieving, listing, deleting tasks, clearing history, getting todos, responding to permissions, and listening for task-related events. These operations are invoked via `window.accomplish.invoke` and event listeners are set up with `window.accomplish.on`.
```typescript
// In renderer process (React components)
// These calls go through Electron's IPC to the main process
// Start a new task
const task = await window.accomplish.invoke('task:start', {
prompt: 'Organize my Downloads folder by file type',
workingDirectory: '/Users/me/Downloads',
modelId: 'anthropic/claude-opus-4-5',
});
console.log('Task ID:', task.id);
// Resume an existing session with a new prompt
const resumedTask = await window.accomplish.invoke(
'session:resume',
'session-abc123', // existing session ID
'Now create a summary of what you organized',
'task-001' // optional: existing task ID
);
// Cancel a running task
await window.accomplish.invoke('task:cancel', 'task-001');
// Interrupt a task (softer than cancel)
await window.accomplish.invoke('task:interrupt', 'task-001');
// Get task details
const taskDetails = await window.accomplish.invoke('task:get', 'task-001');
// List all tasks
const allTasks = await window.accomplish.invoke('task:list');
// Delete a task
await window.accomplish.invoke('task:delete', 'task-001');
// Clear all task history
await window.accomplish.invoke('task:clear-history');
// Get todos for a task
const todos = await window.accomplish.invoke('task:get-todos', 'task-001');
// Respond to a permission request
await window.accomplish.invoke('permission:respond', {
taskId: 'task-001',
requestId: 'perm-001',
decision: 'allow', // or 'deny'
message: 'Approved file access',
selectedOptions: ['Read files', 'Write files'],
});
// Listen for task events
window.accomplish.on('task:progress', (event) => {
console.log('Progress:', event.stage, event.message);
});
window.accomplish.on('task:messages', (event) => {
console.log('Messages:', event.messages.length);
});
window.accomplish.on('task:complete', (event) => {
console.log('Task completed:', event.taskId, event.status);
});
window.accomplish.on('task:summary', (event) => {
console.log('Summary generated:', event.summary);
});
```
--------------------------------
### Execute Multi-Step Login Flow with browser_script
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/dev-browser/SKILL.md
Demonstrates a complete login workflow using `browser_script` in a single call. This includes navigating to the login page, filling in email and password fields, submitting the form, and waiting for navigation. A snapshot of the final page state is automatically returned.
```json
browser_script(actions=[
{"action": "goto", "url": "example.com/login"},
{"action": "waitForLoad"},
{"action": "findAndFill", "selector": "input[type='email']", "text": "user@example.com"},
{"action": "findAndFill", "selector": "input[type='password']", "text": "secret123"},
{"action": "findAndClick", "selector": "button[type='submit']"},
{"action": "waitForNavigation"}
])
```
--------------------------------
### End-to-End Test Example: Submit Task (TypeScript)
Source: https://github.com/accomplish-ai/accomplish/blob/main/apps/desktop/e2e/README.md
An example of an end-to-end test using Playwright. This test submits a task via the HomePage, navigates to the ExecutionPage, and captures a screenshot for AI evaluation. It utilizes custom fixtures and page objects defined within the project.
```typescript
import { test, expect } from '../fixtures';
import { HomePage, ExecutionPage } from '../pages';
import { captureForAI } from '../utils';
test('should submit a task and navigate to execution', async ({ window }) => {
const homePage = new HomePage(window);
const executionPage = new ExecutionPage(window);
// Enter task
await homePage.enterTask('Create a new file called hello.txt');
await homePage.submitTask();
// Wait for navigation to execution page
await executionPage.statusBadge.waitFor({ state: 'visible' });
// Capture screenshot for AI evaluation
await captureForAI(window, 'task-submission', 'execution-started', [
'Task execution page loaded',
'Status badge visible',
]);
// Assert
await expect(executionPage.statusBadge).toBeVisible();
});
```
--------------------------------
### Get Browser Page Snapshot
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/dev-browser/SKILL.md
Retrieves the accessibility tree of the current page as YAML, including element references. The 'interactive_only' flag can filter for clickable/typeable elements.
```javascript
browser_snapshot(page_name?, interactive_only?)
```
--------------------------------
### Configure Provider Settings via IPC in Accomplish AI Desktop App
Source: https://context7.com/accomplish-ai/accomplish/llms.txt
This snippet illustrates how to manage AI provider configurations and credentials using IPC handlers in the Accomplish AI desktop application. It covers fetching, setting, and connecting providers, updating selected models, removing connections, enabling/disabling debug mode, managing API keys, validating keys, checking for key existence, and fetching available models from a provider. These operations are performed using `window.accomplish.invoke`.
```typescript
// Get all provider settings
const settings = await window.accomplish.invoke('provider-settings:get');
console.log('Active provider:', settings.activeProviderId);
console.log('Connected providers:', Object.keys(settings.providers));
// Set active provider
await window.accomplish.invoke('provider-settings:set-active', 'anthropic');
// Get connected provider details
const anthropic = await window.accomplish.invoke('provider-settings:get-connected', 'anthropic');
console.log('Model:', anthropic?.selectedModelId);
// Connect a new provider
await window.accomplish.invoke('provider-settings:set-connected', 'openai', {
id: 'openai',
status: 'connected',
selectedModelId: 'openai/gpt-4',
connectedAt: new Date().toISOString(),
});
// Update selected model for a provider
await window.accomplish.invoke('provider-settings:update-model', 'anthropic', 'anthropic/claude-sonnet-4-5');
// Remove a provider connection
await window.accomplish.invoke('provider-settings:remove-connected', 'openai');
// Enable/disable debug mode for providers
await window.accomplish.invoke('provider-settings:set-debug', true);
const debugEnabled = await window.accomplish.invoke('provider-settings:get-debug');
// API Key operations
await window.accomplish.invoke('settings:add-api-key', 'anthropic', 'sk-ant-xxx...', 'My Anthropic Key');
const apiKeys = await window.accomplish.invoke('settings:api-keys');
await window.accomplish.invoke('settings:remove-api-key', 'local-anthropic');
// Validate API keys
const validation = await window.accomplish.invoke('api-key:validate-provider', 'anthropic', 'sk-ant-xxx...');
console.log('Valid:', validation.valid);
// Check if any API key exists
const hasKeys = await window.accomplish.invoke('api-keys:has-any');
// Fetch models from a provider
const models = await window.accomplish.invoke('provider:fetch-models', 'anthropic');
console.log('Available models:', models.models);
```
--------------------------------
### Test LiteLLM Connection and Fetch Models (TypeScript)
Source: https://context7.com/accomplish-ai/accomplish/llms.txt
Tests connection to a LiteLLM proxy server and fetches available model configurations. Supports authentication with an API key for secured proxies. Requires the '@accomplish_ai/agent-core' package.
```typescript
import { testLiteLLMConnection, fetchLiteLLMModels } from '@accomplish_ai/agent-core';
// Test LiteLLM proxy connection
const result = await testLiteLLMConnection('http://localhost:4000');
if (result.success) {
console.log('LiteLLM connected!');
} else {
console.error('Connection failed:', result.error);
}
// Test with API key (for authenticated proxies)
const authResult = await testLiteLLMConnection(
'https://litellm.mycompany.com',
'my-api-key'
);
// Fetch available models from LiteLLM
const modelsResult = await fetchLiteLLMModels({
config: { baseUrl: 'http://localhost:4000', enabled: true },
apiKey: 'optional-key',
});
if (modelsResult.success) {
console.log('Available models:', modelsResult.models);
// models: [{ id: 'gpt-4', name: 'GPT-4', provider: 'openai', contextLength: 8192 }]
}
```
--------------------------------
### Initialize Theme from Local Storage or System Preference (JavaScript)
Source: https://github.com/accomplish-ai/accomplish/blob/main/apps/desktop/index.html
This JavaScript code snippet initializes the application's theme. It checks localStorage for a 'theme' setting ('dark', 'light', or 'system'). If 'dark' is set, or if the theme is 'system' and the user's system prefers dark mode, it adds the 'dark' class to the document's root element.
```javascript
(function () { var t = localStorage.getItem('theme') || 'system'; var d = t === 'dark' || (t === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches); if (d) document.documentElement.classList.add('dark'); })();
```
--------------------------------
### Get Browser Element Text
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/dev-browser/SKILL.md
Retrieves the text content of a specified element on the page, identified by a reference or CSS selector. Useful for verifying text content after actions.
```javascript
browser_get_text(ref?, selector?, page_name?)
```
--------------------------------
### Importing Image Assets in Web UI (TypeScript)
Source: https://github.com/accomplish-ai/accomplish/blob/main/CLAUDE.md
Demonstrates the correct method for importing image assets in the web UI using ES module imports. Incorrect usage of absolute paths can lead to issues in packaged applications. Static assets should be placed in the `apps/web/public/assets/` directory.
```typescript
import logoImage from '/assets/logo.png';
```
--------------------------------
### Test LM Studio Connection and Fetch Models (TypeScript)
Source: https://context7.com/accomplish-ai/accomplish/llms.txt
Tests connection to LM Studio's local server and retrieves a list of loaded models. Includes a function to validate LM Studio configuration objects. Requires the '@accomplish_ai/agent-core' package.
```typescript
import {
testLMStudioConnection,
fetchLMStudioModels,
validateLMStudioConfig,
} from '@accomplish_ai/agent-core';
// Test LM Studio connection
const result = await testLMStudioConnection({
url: 'http://localhost:1234',
});
if (result.success) {
console.log('LM Studio connected!');
console.log('Server version:', result.version);
} else {
console.error('Connection failed:', result.error);
}
// Fetch loaded models
const modelsResult = await fetchLMStudioModels({
baseUrl: 'http://localhost:1234',
});
if (modelsResult.success) {
console.log('Loaded models:', modelsResult.models);
// models: [{ id: 'llama-3.2-3b', name: 'Llama 3.2 3B', toolSupport: 'supported' }]
}
// Validate LM Studio configuration object
const config = {
baseUrl: 'http://localhost:1234',
enabled: true,
models: [{ id: 'model-1', name: 'Model 1', toolSupport: 'supported' as const }],
};
validateLMStudioConfig(config); // Throws if invalid
```
--------------------------------
### Resolve Bundled Node.js Binary Paths in Electron Apps (TypeScript)
Source: https://context7.com/accomplish-ai/accomplish/llms.txt
This utility helps resolve paths to Node.js, npm, and npx executables when they are bundled within a packaged Electron application. It requires the application's resources path and a flag indicating if the app is packaged. The functions return strings representing the absolute paths to these binaries or an extended PATH string.
```typescript
import {
getBundledNodePaths,
isBundledNodeAvailable,
getNodePath,
getNpmPath,
getNpxPath,
getExtendedNodePath,
findCommandInPath,
} from '@accomplish_ai/agent-core';
// Get paths to bundled Node.js binaries
const paths = getBundledNodePaths({
resourcesPath: '/app/resources',
isPackaged: true,
});
console.log('Node:', paths.node);
console.log('npm:', paths.npm);
console.log('npx:', paths.npx);
// Check if bundled Node.js is available
const available = await isBundledNodeAvailable('/app/resources');
console.log('Bundled Node available:', available);
// Get specific binary paths
const nodePath = getNodePath('/app/resources', true);
const npmPath = getNpmPath('/app/resources', true);
const npxPath = getNpxPath('/app/resources', true);
// Get extended PATH with bundled binaries
const extendedPath = getExtendedNodePath({
resourcesPath: '/app/resources',
isPackaged: true,
});
console.log('Extended PATH:', extendedPath);
// Find a command in PATH
const gitPath = await findCommandInPath('git');
console.log('Git path:', gitPath);
```
--------------------------------
### Run MCP Server in Built-in Mode (Default)
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/dev-browser-mcp/README.md
Starts the MCP server using the built-in connection mode, which connects to the dev-browser HTTP server. This is the default mode and is used by the Accomplish desktop app. It utilizes `http://localhost:9224` by default.
```bash
# Uses http://localhost:9224 by default
npx tsx src/index.ts
# Custom port
DEV_BROWSER_PORT=5555 npx tsx src/index.ts
```
--------------------------------
### Capture Network Request Details with TypeScript
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/dev-browser/references/scraping.md
Intercepts outgoing network requests to capture URL, headers, and method for API endpoints. This helps in understanding the structure and requirements of requests before replaying them. It saves the details to a JSON file for later use.
```typescript
import { connect, waitForPageLoad } from '@/client.js';
import * as fs from 'node:fs';
const client = await connect();
const page = await client.page('site');
let capturedRequest = null;
page.on('request', (request) => {
const url = request.url();
// Look for API endpoints (adjust pattern for your target site)
if (url.includes('/api/') || url.includes('/graphql/')) {
capturedRequest = {
url: url,
headers: request.headers(),
method: request.method(),
};
fs.writeFileSync('tmp/request-details.json', JSON.stringify(capturedRequest, null, 2));
console.log('Captured request:', url.substring(0, 80) + '...');
}
});
await page.goto('https://example.com/profile');
await waitForPageLoad(page);
await page.waitForTimeout(3000);
await client.disconnect();
```
--------------------------------
### Storage API
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/README.md
SQLite-backed storage for tasks, app settings, and provider configuration. Includes AES-256-GCM encrypted secure storage for API keys.
```APIDOC
## createStorage(options)
### Description
SQLite-backed storage for tasks, app settings, and provider configuration. Includes AES-256-GCM encrypted secure storage for API keys. Combines `TaskStorageAPI`, `AppSettingsAPI`, `ProviderSettingsAPI`, `SecureStorageAPI`, and `DatabaseLifecycleAPI` into a single interface.
### Method
Factory Function
### Parameters
#### Options
- **databasePath** (string) - Required - Path to the SQLite database file.
- **userDataPath** (string) - Required - Path to the user data directory for secure storage.
### Request Example
```typescript
import { createStorage } from '@accomplish_ai/agent-core';
const storage = createStorage({
databasePath: '/path/to/accomplish.db',
userDataPath: '/path/to/user-data',
});
storage.initialize();
```
### Response
#### Success Response (StorageAPI)
Returns an interface for interacting with the storage system.
#### Response Example
```typescript
// StorageAPI interface
interface StorageAPI {
initialize: () => Promise;
// ... methods for TaskStorageAPI, AppSettingsAPI, ProviderSettingsAPI, SecureStorageAPI, DatabaseLifecycleAPI
}
```
```
--------------------------------
### Run MCP Server in Remote CDP Mode
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/dev-browser-mcp/README.md
Starts the MCP server in remote Chrome DevTools Protocol (CDP) mode, connecting directly to a CDP endpoint without a dev-browser HTTP server. Pages are managed locally in an in-memory registry. Requires the `CDP_ENDPOINT` environment variable.
```bash
# Local headless Chromium
CDP_ENDPOINT=http://localhost:9222 npx tsx src/index.ts
# Remote browser with auth
CDP_ENDPOINT=ws://remote-browser:9222 CDP_SECRET=my-token npx tsx src/index.ts
```
--------------------------------
### Create Storage API with @accomplish_ai/agent-core
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/README.md
Imports and initializes the StorageAPI using the `createStorage` factory function. This API provides SQLite-backed storage for various application data, including AES-256-GCM encrypted secure storage for sensitive information.
```typescript
import { createStorage } from '@accomplish_ai/agent-core';
```
--------------------------------
### Capture API Response for Schema Analysis with TypeScript
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/dev-browser/references/scraping.md
Listens for network responses and captures the JSON payload of specific API calls. This allows for inspection of the data structure, identification of data arrays, pagination cursors, and necessary fields for extraction. The response is saved to a JSON file.
```typescript
page.on('response', async (response) => {
const url = response.url();
if (url.includes('UserTweets') || url.includes('/api/data')) {
const json = await response.json();
fs.writeFileSync('tmp/api-response.json', JSON.stringify(json, null, 2));
console.log('Captured response');
}
});
```
--------------------------------
### Navigate Browser Page
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/dev-browser/SKILL.md
Navigates the browser to a specified URL. An optional page name can be provided for managing multiple browser instances.
```javascript
browser_navigate(url, page_name?)
```
--------------------------------
### Replay API Requests with Pagination using TypeScript
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/dev-browser/references/scraping.md
Replays intercepted API requests directly within the browser context to leverage existing authentication. It handles cursor-based pagination, extracts data, and deduplicates results using a Map. The final extracted data is saved to a JSON file.
```typescript
import { connect } from '@/client.js';
import * as fs from 'node:fs';
const client = await connect();
const page = await client.page('site');
const results = new Map(); // Use Map for deduplication
const headers = JSON.parse(fs.readFileSync('tmp/request-details.json', 'utf8')).headers;
const baseUrl = 'https://example.com/api/data';
let cursor = null;
let hasMore = true;
while (hasMore) {
// Build URL with pagination cursor
const params = { count: 20 };
if (cursor) params.cursor = cursor;
const url = `${baseUrl}?params=${encodeURIComponent(JSON.stringify(params))}`;
// Execute fetch in browser context (has auth cookies/headers)
const response = await page.evaluate(
async ({ url, headers }) => {
const res = await fetch(url, { headers });
return res.json();
},
{ url, headers },
);
// Extract data and cursor (adjust paths for your API)
const entries = response?.data?.entries || [];
for (const entry of entries) {
if (entry.type === 'cursor-bottom') {
cursor = entry.value;
} else if (entry.id && !results.has(entry.id)) {
results.set(entry.id, {
id: entry.id,
text: entry.content,
timestamp: entry.created_at,
});
}
}
console.log(`Fetched page, total: ${results.size}`);
// Check stop conditions
if (!cursor || entries.length === 0) hasMore = false;
// Rate limiting - be respectful
await new Promise((r) => setTimeout(r, 500));
}
// Export results
const data = Array.from(results.values());
fs.writeFileSync('tmp/results.json', JSON.stringify(data, null, 2));
console.log(`Saved ${data.length} items`);
await client.disconnect();
```
--------------------------------
### Execute Browser Sequence with Refs
Source: https://github.com/accomplish-ai/accomplish/blob/main/packages/agent-core/mcp-tools/dev-browser/SKILL.md
Executes a sequence of browser actions using pre-obtained element references from a snapshot. Supports actions like click, type, snapshot, screenshot, and wait.
```javascript
browser_sequence(actions, page_name?)
```
--------------------------------
### Theme Management Script (JavaScript)
Source: https://github.com/accomplish-ai/accomplish/blob/main/apps/web/index.html
This JavaScript code snippet dynamically sets the UI theme. It checks local storage for a 'theme' preference ('dark', 'light', or 'system') and applies the 'dark' class to the document element if the theme is set to dark or if the system preference is dark. It includes error handling for local storage access.
```javascript
(function () { var t = 'system'; try { t = localStorage.getItem('theme') || 'system'; } catch (e) {} var d = t === 'dark' || (t === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches); if (d) document.documentElement.classList.add('dark'); })();
```
--------------------------------
### Run E2E Tests with Playwright (Bash)
Source: https://github.com/accomplish-ai/accomplish/blob/main/apps/desktop/e2e/README.md
Commands for running end-to-end tests using Playwright within a Dockerized environment or natively. Includes options for building the Docker image, cleaning resources, viewing reports, and running tests with debugging or specific configurations.
```bash
# Run all E2E tests (in Docker)
pnpm test:e2e
# Pre-build Docker image (useful for caching)
pnpm test:e2e:build
# Clean up Docker resources
pnpm test:e2e:clean
# View HTML report
pnpm test:e2e:report
# Run natively (Electron windows will pop up)
pnpm test:e2e:native
# Run with Playwright UI
pnpm test:e2e:native:ui
# Run in debug mode
pnpm test:e2e:native:debug
# Run fast tests only
pnpm test:e2e:native:fast
# Run integration tests only
pnpm test:e2e:native:integration
```