Skip to content

Bridge API Reference

The Bridge API is exposed as window.vibeDepot in every VibeDepot app window. It provides four namespaces: ai, storage, shell, and db.

Permission required: ai

Send messages to an AI model and receive a complete response.

Parameters:

interface CallAIParams {
provider?: 'anthropic' | 'openai' | 'gemini'; // Force a specific provider
model?: string; // Force a specific model
messages: AIMessage[]; // Conversation messages
maxTokens?: number; // Max tokens in response
temperature?: number; // Sampling temperature (0–2)
}
interface AIMessage {
role: 'user' | 'assistant' | 'system';
content: string;
}

Returns:

interface CallAIResponse {
content: string; // The AI's response text
model: string; // Model used (e.g. "claude-sonnet-4-20250514")
usage: {
inputTokens: number; // Tokens in the prompt
outputTokens: number; // Tokens in the response
};
}

Example:

const response = await window.vibeDepot.ai.callAI({
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is 2 + 2?' }
],
maxTokens: 100,
temperature: 0.7
});
console.log(response.content);

Errors: MISSING_API_KEY, AI_PROVIDER_ERROR, PERMISSION_DENIED, INVALID_PARAMS


Stream an AI response, receiving text chunks in real-time.

Parameters:

ParameterTypeDescription
paramsCallAIParamsSame parameters as callAI()
onChunk(chunk: string) => voidCallback fired for each text fragment

Returns: Promise<void> — Resolves when the stream is complete.

Example:

let fullText = '';
await window.vibeDepot.ai.streamAI(
{
messages: [{ role: 'user', content: 'Write a haiku.' }]
},
(chunk) => {
fullText += chunk;
document.getElementById('output').textContent = fullText;
}
);

Errors: MISSING_API_KEY, AI_PROVIDER_ERROR, PERMISSION_DENIED, INVALID_PARAMS


Get the name of the currently selected AI provider.

Returns: Promise<string> — e.g. 'anthropic', 'openai', 'gemini'

const provider = await window.vibeDepot.ai.getProvider();

Get the currently selected model name.

Returns: Promise<string> — e.g. 'claude-sonnet-4-20250514', 'gpt-4o'

const model = await window.vibeDepot.ai.getModel();

List all AI providers available to this app (that have API keys configured).

Returns: Promise<string[]> — e.g. ['anthropic', 'openai']

const providers = await window.vibeDepot.ai.listProviders();

Permission required: storage.kv (auto-granted)

Store a JSON-serializable value.

ParameterTypeDescription
keystringStorage key (1–256 characters)
valueunknownAny JSON-serializable value

Returns: Promise<void>

await window.vibeDepot.storage.set('prefs', { theme: 'dark' });

Retrieve a stored value.

ParameterTypeDescription
keystringStorage key

Returns: Promise<unknown> — The stored value, or null if not found.

const prefs = await window.vibeDepot.storage.get('prefs');

Delete a stored value.

ParameterTypeDescription
keystringStorage key

Returns: Promise<boolean>true if the key existed and was deleted, false otherwise.

const deleted = await window.vibeDepot.storage.delete('prefs');

List all stored keys.

Returns: Promise<string[]>

const allKeys = await window.vibeDepot.storage.keys();

Delete all stored data for this app.

Returns: Promise<void>

await window.vibeDepot.storage.clear();

Most methods require no permission. Exceptions noted below.

Get this app’s manifest.

Returns: Promise<AppManifest> — The full manifest object.

const info = await window.vibeDepot.shell.getAppInfo();
console.log(info.name, info.version);

Get the VibeDepot shell version.

Returns: Promise<string> — e.g. '0.1.0'

const version = await window.vibeDepot.shell.getVersion();

Open a URL in the user’s default browser.

ParameterTypeDescription
urlstringA valid URL

Returns: Promise<void>

await window.vibeDepot.shell.openExternal('https://example.com');

Show a desktop notification. Requires notifications permission.

ParameterTypeConstraints
titlestringMax 256 characters
bodystringMax 1024 characters

Returns: Promise<void>

await window.vibeDepot.shell.notify('Task Complete', 'Your document has been generated.');

Set the app window’s title bar text.

ParameterTypeDescription
titlestringWindow title

Returns: Promise<void>

await window.vibeDepot.shell.setTitle('My App - Document 1');

Get the current system theme.

Returns: Promise<'light' | 'dark'>

const theme = await window.vibeDepot.shell.theme();
if (theme === 'dark') {
document.body.classList.add('dark');
}

Permission required: storage.db

Execute a write statement (INSERT, UPDATE, DELETE, CREATE TABLE, etc.).

ParameterTypeDescription
sqlstringSQL statement (must be on the allowlist)
paramsunknown[]Optional bind parameters

Returns:

Promise<{
changes: number; // Number of rows affected
lastInsertRowid: number; // ID of the last inserted row
}>
const result = await window.vibeDepot.db.run(
'INSERT INTO notes (title) VALUES (?)',
['Meeting Notes']
);
console.log(result.lastInsertRowid); // e.g. 1

Errors: DB_ERROR, PERMISSION_DENIED


Execute a SELECT query.

ParameterTypeDescription
sqlstringSQL SELECT statement
paramsunknown[]Optional bind parameters

Returns: Promise<unknown[]> — Array of row objects.

const notes = await window.vibeDepot.db.query(
'SELECT * FROM notes WHERE title LIKE ?',
['%Meeting%']
);

Errors: DB_ERROR, PERMISSION_DENIED


Execute multiple statements atomically. If any statement fails, all changes are rolled back.

ParameterTypeDescription
statementsArray<{ sql: string; params?: unknown[] }>Statements to execute

Returns: Promise<void>

await window.vibeDepot.db.transaction([
{ sql: 'INSERT INTO tags (name) VALUES (?)', params: ['important'] },
{ sql: 'INSERT INTO tags (name) VALUES (?)', params: ['urgent'] }
]);

Errors: DB_ERROR, PERMISSION_DENIED