tauri-plugin-ambient-fs
Tauri plugin for bridging ambient-fsd to Tauri applications.
Features
- Watch project directories for file events
- Query file awareness (change frequency, attribution, analysis)
- Attribute changes to sources (user, AI agents, git, etc.)
- Query active agents
- Real-time event forwarding to frontend
Installation
Rust (in src-tauri/Cargo.toml)
[]
= { = "../../ambient-fs/integrations/tauri-plugin-ambient-fs" }
TypeScript (in package.json)
Usage
Initialize Plugin
// src-tauri/src/main.rs
Frontend API
import * as AmbientFs from '@ambient-fs/tauri-plugin';
// Watch a project
const projectId = await AmbientFs.watchProject('/home/user/project');
// Query events
const events = await AmbientFs.queryEvents({
project_id: projectId,
limit: 100
});
// Query awareness for a file
const awareness = await AmbientFs.queryAwareness(projectId, 'src/main.rs');
// Attribute a change
await AmbientFs.attribute(projectId, 'src/auth.rs', 'ai_agent', 'chat-42');
// Listen to events
const unlisten = AmbientFs.onFileEvent((event) => {
console.log('file changed:', event.file_path, event.event_type);
});
// Cleanup
unlisten();
Vue Composable Example
// composables/useAmbientFs.ts
import { ref } from 'vue';
import * as AmbientFs from '@ambient-fs/tauri-plugin';
export function useAmbientFs() {
const isConnected = ref(false);
const projectAwareness = ref(new Map<string, AmbientFs.FileAwareness>());
// Connection status
const unlistenConnected = AmbientFs.onConnectedChanged((connected) => {
isConnected.value = connected;
});
// Awareness updates
const unlistenAwareness = AmbientFs.onAwarenessChanged(({ file_path, awareness }) => {
projectAwareness.value.set(file_path, awareness);
});
// Cleanup on unmount
onUnmounted(() => {
unlistenConnected();
unlistenAwareness();
});
return {
isConnected,
projectAwareness,
watchProject: AmbientFs.watchProject,
queryAwareness: AmbientFs.queryAwareness,
attribute: AmbientFs.attribute,
};
}
Configuration
The plugin reads the socket path from the AMBIENT_FS_SOCKET environment variable, defaulting to /tmp/ambient-fs.sock.
Features
auto-launch(default): Automatically spawn the daemon if not running
Events
Events are emitted to the frontend:
ambient-fs://connected- Connection status changedambient-fs://event- File event occurredambient-fs://awareness-changed- File awareness updatedambient-fs://analysis-complete- File analysis completed
IPC Commands
watch_project- Start watching a directoryunwatch_project- Stop watching a projectquery_events- Query events with filterquery_awareness- Query awareness for a filequery_tree- Query file tree for a projectattribute- Attribute a change to a sourcequery_agents- Query active agentsget_status- Get daemon connection status
Development
# Build plugin
# Run tests
License
MIT