feat: add Obsidian CLI API service
Build and Push Docker Container / build-and-push (push) Successful in 4m26s
Build and Push Docker Container / build-and-push (push) Successful in 4m26s
- Add Docker image for the official Obsidian desktop app and CLI. - Start Obsidian headlessly with Xvfb and DBus setup. - Expose a safe structured HTTP command API without shell execution. - Add JWT-based vault, path, and command authorization. - Support single-vault and multi-vault container mounts. - Add TypeScript SDK helpers for Obsidian CLI commands. - Add n8n community node package with Obsidian operations. - Add docs, compose config, tests, and production image workflow.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
# @obsidian-api/sdk
|
||||
TypeScript SDK for this HTTP wrapper around the **official Obsidian CLI**.
|
||||
|
||||
The SDK is built for Node 18+, n8n Code nodes, Prism, and other TypeScript agent harnesses.
|
||||
|
||||
## Install locally
|
||||
```bash
|
||||
npm install /path/to/obsidian-api/sdk/typescript
|
||||
```
|
||||
|
||||
## Usage
|
||||
```ts
|
||||
import { ObsidianCliClient } from '@obsidian-api/sdk';
|
||||
|
||||
const obsidian = new ObsidianCliClient({
|
||||
baseUrl: 'http://localhost:8080',
|
||||
token: 'change-me',
|
||||
});
|
||||
|
||||
await obsidian.create({
|
||||
path: 'Inbox/Hello.md',
|
||||
content: '# Hello from n8n/Prism',
|
||||
overwrite: true,
|
||||
});
|
||||
|
||||
const note = await obsidian.read({ path: 'Inbox/Hello.md' });
|
||||
console.log(note.stdout);
|
||||
|
||||
const results = await obsidian.search('Hello', { format: 'json' });
|
||||
console.log(JSON.parse(results.stdout));
|
||||
```
|
||||
|
||||
## Multiple vaults
|
||||
Use the official CLI `vault=<name>` prefix directly:
|
||||
```ts
|
||||
await obsidian.runInVault('work', 'create', 'path=Inbox/Task.md', 'content=Hello');
|
||||
```
|
||||
|
||||
Or create a scoped client:
|
||||
```ts
|
||||
const workVault = obsidian.inVault('work');
|
||||
await workVault.create({ path: 'Inbox/Task.md', content: 'Hello', overwrite: true });
|
||||
await workVault.read({ path: 'Inbox/Task.md' });
|
||||
```
|
||||
|
||||
You can also set a default vault in the constructor:
|
||||
```ts
|
||||
const obsidian = new ObsidianCliClient({
|
||||
baseUrl: 'http://localhost:8080',
|
||||
token: 'change-me',
|
||||
vault: 'work',
|
||||
});
|
||||
```
|
||||
|
||||
## Raw command escape hatch
|
||||
Still safe: sends an args array, not a shell command string.
|
||||
```ts
|
||||
await obsidian.runRaw('create', 'name=Scratch', 'content=Test', 'overwrite');
|
||||
```
|
||||
Reference in New Issue
Block a user