edytlab logoedytlabGitHub

API Reference

All Tauri commands, TypeScript bridge types, and SSE events.

This page covers the public API consumed by the edytlab frontend. For the full Rust implementation, see commands.rs and tauri-bridge.ts. The complete reference is in docs/api-reference.md.

Commands

All commands are invoked via tauri-bridge.ts. They return Promise<T> and throw a string on Rust Err(_).

Project

FunctionReturnsDescription
openProject(path)ProjectInfoOpen or create a project directory. Returns the current head node ID (null if empty).

API Keys

FunctionReturnsDescription
setApiKey(key)voidStore the API key for the active provider in the OS keychain.
setApiKeyFor(provider, key)voidStore the API key for a specific provider.
hasApiKey()booleanCheck whether the active provider has a key configured.
hasApiKeyFor(provider)booleanCheck whether a specific provider has a key.
clearApiKey()voidRemove the API key for the active provider from the keychain.
testApiKey(key)voidValidate a key with a 1-token probe request. Throws on failure.

Provider and Model

FunctionReturnsDescription
listProviders()ProviderId[]Returns ["anthropic", "openrouter", "openai"].
getActiveProvider()ProviderIdReturns the currently active provider ID.
setActiveProvider(provider)voidSwitch the active provider. Rebuilds the agent.
listModelsFor(provider, apiKey?)ModelInfo[]Fetch available models. Results cached 10 minutes.
getActiveModel(provider)stringReturns the model ID selected for the provider.
setActiveModel(provider, model)voidSet the active model for a provider.

Session Graph

FunctionReturnsDescription
getSessionHead()NodeIdReturns the current head node ID.
getNode(id)SessionNodeFetch a full node (including SessionState) by ID.
getGraph()GraphSummaryFetch all nodes (without full state) and the current head.
setHeadTo(nodeId)NodeIdMove the head pointer to any existing node (non-destructive revert).
renameNode(nodeId, label)voidSet a human-readable label on a node.

Rendering and A/B

FunctionReturnsDescription
renderPreview(node)string (path)Render session to a temp WAV for playback. Returns file path.
renderRange(node, startSec, endSec, outPath)voidRender a time range to a specific output file.
prepareCompare(a, b){ a_path, b_path }Pre-render two nodes for A/B comparison.
acceptB(b)NodeIdAccept node B as the new session head.

Agent

FunctionReturnsDescription
sendMessage(text)voidSend a user message. Agent runs async; emits events during processing.
approvePlan()voidIn mashup mode: approve the agent's proposed plan to proceed.

Selection and Markers

FunctionReturnsDescription
setSelectionContext(range?)voidSet or clear the selection range. Injected as agent context on next turn.
addMarker(timeSec, name)string (annotation_id)Add a named point marker.
removeMarker(id)NodeIdRemove a marker by annotation ID.
listMarkers()Marker[]List all markers and regions for the current session.

Tracks

FunctionReturnsDescription
listTracks()TrackSummary[]List all tracks in the current session head.

Memory

FunctionReturnsDescription
readMemory("global" | "project")stringRead the memory markdown for the given scope. Returns empty string if none.
writeMemory("global" | "project", contents)voidOverwrite the memory file atomically.

Events

Subscribe with the unlisten pattern. Each handler returns an UnlistenFn — call it in useEffect cleanup.

const unlisten = await bridge.onTextDelta((chunk) => {
  appendText(chunk);
});
// cleanup:
return () => { unlisten(); };
EventPayloadDescription
onTextDelta(cb)string (text chunk)Each streamed text chunk from the LLM. Append to the current assistant message.
onToolCall(cb){ name, id }Tool execution started. Use to show a tool badge in the chat UI.
onToolCallEnd(cb){ id, ok: boolean }Tool execution completed. ok = false if the tool returned an error.
onNodeCreated(cb)nodeId: stringNew DAG node appended. Refresh the graph view and track list.
onAgentDone(cb)noneAgent turn fully complete — no more text or tool calls.
onPlan(cb)steps: object[]Mashup mode: agent proposed a multi-step plan before execution.
onMarkerChanged(cb)noneMarker or region annotation added or removed. Refresh the marker list.

Key types

type NodeId = string;
type ProviderId = "anthropic" | "openrouter" | "openai";

interface ProjectInfo  { path: string; head: NodeId | null }
interface SessionNode  { id: NodeId; parent: NodeId | null; label: string | null; state: SessionState }
interface GraphSummary { nodes: GraphNode[]; head: NodeId | null }
interface GraphNode    { id: NodeId; parent: NodeId | null; label: string | null; tool: string | null }
interface TrackSummary { id: string; name: string; muted: boolean; gain_db: number; audio_path: string | null }
interface ModelInfo    { id: string; display_name: string; context_length: number | null }
interface Marker       { id: string; name: string; kind: "marker" | "region"; time_sec?: number; start_sec?: number; end_sec?: number }