@open-agent-kit/bridge
v1.5.0
Published
Bridge module for SAALT
Readme
SAALT Bridge
The Bridge is the TypeScript SDK that plugins use to communicate with a SAALT server. It wraps the SAALT Admin API into a typed, ergonomic client so plugin code never has to deal with raw HTTP.
Installation
npm install @open-agent-kit/bridgeWhat it does
When a plugin runs, it receives a signed JWT and the server URL. Passing those two values to createBridge returns a ready-to-use client:
import { createBridge } from "@open-agent-kit/bridge";
const bridge = createBridge({ token, serverUrl });The bridge exposes the following namespaces:
| Namespace | What it gives you |
| ------------------------ | --------------------------------------------------------------------------------------------------------------- |
| bridge.llm | Generate text, structured objects, images, or full conversation responses via the configured LLM |
| bridge.files | Upload, retrieve, and parse files (PDFs, images, Office documents) — including OCR and model-powered extraction |
| bridge.knowledge | List knowledge documents and trigger sync operations |
| bridge.conversation | Look up a single conversation (findFirst) or list an agent's conversations (findMany) |
| bridge.data.config | Read and write plugin-level configuration |
| bridge.data.pluginData | Persistent key/value storage scoped to the plugin |
| bridge.user | Retrieve the current user, their permissions on this app, the groups behind them and the app's users |
All calls are authenticated automatically using the token provided at construction time.
Users, permissions and groups
bridge.user.permissions(): Promise<string[]>
bridge.user.groups(): Promise<UserGroup[]>
bridge.user.appGroups(): Promise<UserGroup[]>Check once, then branch on the result:
const permissions = await bridge.user.permissions();
if (permissions.includes("view_settings")) {
// show the settings
}- Keys come exactly as declared in
/meta, without theapp.<id>.prefix. - Users with
app.usewho are App Admin of the app (system role Admin on the app) or Super Admin get every declared key. A plugin admin through the org permissionglobal.edit_pluginswithoutapp.usegets[]. Keys the app no longer declares are left out. - Requires Core 1.9.0 or later (CORE-1642); an older Core throws HTTP 404.
- Standalone apps only; for an agent-scoped app all three calls return
[]. - The calls need a logged-in user. Cron, knowledge and anonymous
/api/*calls throw HTTP 400. groups()returns only the user's groups that have a role on this app.appGroups()returns every group that has a role on this app and is meant for a share picker. The plugin decides who sees the list; do not show it to users who should not see these group names.
An app declares its permissions in /meta as permissions: [{ key, name: { en, de? }, description?: { en, de? } }]. A key matches ^[a-z0-9_]{1,50}$, and use and admin are reserved. name.en is required and non-empty; a name is at most 100 characters and a description at most 500. An invalid entry is dropped on its own and the rest stays; with duplicate keys the first entry wins. Only the first 200 entries are looked at and at most 50 are kept. Use the exported AppPermission type to type it.
Users of the app
bridge.user.appUsers(query?: { search?: string; limit?: number } | { ids: string[] }): Promise<AppUser[]>
// AppUser = { id, name, email }const matches = await bridge.user.appUsers({ search: "anna", limit: 10 }); // share picker
const owners = await bridge.user.appUsers({ ids: storedUserIds }); // resolve stored ids to namesThe types AppUser and AppUsersQuery are exported (type-only).
- Requires Core 1.9.0 or later with CORE-1704. Detect an old Core by
error.status === 404. - An admin has to enable "User directory" ("Benutzerverzeichnis") on the app's Advanced page; it is off by default. Until then the call throws HTTP 403 (
userDirectoryDisabled); detect it byerror.status === 403together with the message containinguserDirectoryDisabled(another bridge 403 is possible). - Needs a user in the token: cron, webhooks and the machine API throw HTTP 400.
- Lists only users who hold
app.useon this app (through an app role, Super Admin, or a group with either); deactivated users are left out. The calling user needsapp.usetoo, otherwise the result is[]. Standalone apps only. - Give either
searchorids, not both.searchmatches name or e-mail, case-insensitively, and needs 2–100 characters after trimming (a blank one counts as absent);limitis 1–50, default 20.idstakes at most 50 ids and returns only those that qualify; an empty array returns[]without a request. Without either you get the firstlimitusers. Results are ordered by name. Anything else throws HTTP 400. - An
idsentry for a user who lost access or is deactivated is silently absent: treat it as an unknown user. - To probe availability use
{ search: "<2+ chars>", limit: 1 }, notids: [](that answers[]without a request). - Plugin guidance: debounce and rate-limit the picker, never pass a client-supplied
limitor an empty query through, verify recipients withappUsers({ ids })before storing them, store ids rather than names or e-mails, and show e-mail addresses only to users who may share, not to everyone who can open the app.
Text-to-speech
bridge.llm.generateSpeech turns a script into audio with a Gemini TTS model. Use gemini-3.8-flash-tts or gemini-3.8-flash-lite-tts; the 2.5 and 3.1 preview models shut down on 2026-11-17.
// Single voice
const { base64, mimeType } = await bridge.llm.generateSpeech({
model: "gemini-3.8-flash-tts",
text: "Welcome to the show.",
voiceName: "Kore",
});
// Two-speaker conversation, one part per turn (needed for Gemini 3.8 multi-speaker)
const dialogue = await bridge.llm.generateSpeech({
model: "gemini-3.8-flash-tts",
text: "Alex: Hi Sam.\nSam: Hello Alex.", // not sent when `turns` is set
speakers: [
{ speaker: "Alex", voiceName: "Kore", style: "Warm and upbeat" },
{ speaker: "Sam", voiceName: "Puck", style: "Calm, a little dry" },
],
turns: [
{ speaker: "Alex", text: "Hi Sam." },
{ speaker: "Sam", text: "Hello Alex." },
],
});textis the script for a single voice, or a direction preamble plus transcript forspeakerswithoutturns.voiceNamepicks the single-speaker voice;speakerstakes precedence when set.turns({ speaker, text }[]) makes Core send one part per turn withspeechMetadata.speaker. When it is set,textis not sent: Gemini 3.8 rejects system instructions for TTS, so a direction preamble would be spoken as an extra part. Put the direction inspeakers[].styleinstead.speakers[].styleis an optional per-speaker delivery direction, sent with that speaker's turns. It is ignored withoutturns.- Validation (400): at most 2 speakers;
turnsneed exactly 2 speakers with unique names, every turn'sspeakermust be one of them, at most 150 turns and 20,000 characters of turn text in total;styleat most 1000 characters.
The answer is { base64, mimeType: "audio/wav" }. A WAV the provider returns is passed through unchanged, including its C2PA provenance chunk; raw PCM is wrapped into a WAV.
Failed calls throw an Error whose message is HTTP <status>: <statusText>: 400 for validation errors and for a provider rejection, 429 when the provider's rate limit is reached, 502 when the provider is unavailable. Core's response body carries the provider's detail on a 400.
Speech-to-text
The transcription routes need the SAALT Core release that ships them (as does files.deleteFile). Core holds the endpoints and keys of its registry models; getAvailableTranscriptionModels() lists the configured ones with public details only (key, displayName, locationLabel?, pricing.perMinute) and defaultModel, the first of them. The list can be empty: handle that case.
const { models } = await bridge.llm.getAvailableTranscriptionModels();
if (models.length === 0) throw new Error("No transcription model configured");
// Store the recording in the plugin's own file namespace, then reference it by
// the same path you gave putFile.
await bridge.files.putFile(base64, "recordings/meeting.mp3");
const { jobId } = await bridge.llm.startTranscription({
model: models[0].key,
audioPath: "recordings/meeting.mp3",
mimeType: "audio/mpeg",
language: "de",
responseFormat: "verbose_json",
timestampGranularities: ["word"],
});
// Poll getTranscription(jobId) until `state` is final, read `result`, then deleteTranscription(jobId).Options: language, prompt, temperature, and the provider fields responseFormat (json | verbose_json | diarized_json), timestampGranularities, chunkingStrategy (auto) and diarize, sent only when set; which of them a model takes is the caller's knowledge. The answer is the provider's, in the shape of OpenAI's transcription response: text, language?, duration? (seconds), segments? (as the provider returned them) and words? ({ word, start, end, speaker? }). Segmenting and speaker naming are up to the plugin.
Failed calls throw an Error whose message is HTTP <status>: <statusText> followed by Core's message, with a status property and, when Core sent a Retry-After, retryAfterSeconds.
Jobs
| Call | What it does |
| --------------------------------------------- | ------------------------------------------------------------------------------------------ |
| startTranscription(params) -> { jobId } | Validates the request and queues the job. |
| getTranscription(jobId) -> TranscriptionJob | state: queued, running, succeeded, failed or cancelled, plus result/error. |
| cancelTranscription(jobId) | Stops the upstream request. Idempotent. |
| deleteTranscription(jobId) | Removes the job and its transcript from Core. |
- Jobs take
audioPathonly and only Core's registry models; a catalogue model or agemini-*id is refused (400/404). A job'sresulthas the same shape astranscribe's. - Limits (fixed in Core): 20 open and 2 running jobs per plugin, a result of at most 10 MB, results kept 6 hours after the job ended. A job is visible only to the plugin and agent that started it, not scoped to a user.
Synchronous transcribe
transcribe takes audioPath or audioBase64 and holds one HTTP request open for the whole recording, so it suits short clips. The self-hosted and Gemini registry models run only as jobs; Core refuses them here. At most 2 calls per plugin run at once in one Core process; more answer 429.
Breaking changes since 1.4.0-alpha.0
transcribeand a job'sresultreturn the provider's passthrough answer (text,language?,duration?,segments?,words?) instead ofTranscribeResult(segmentswith speakers,durationSeconds).TranscriptionModelInfocarries onlykey,displayName,locationLabel?andpricing; the limit and capability fields are gone.transcribeAndWaitis removed; pollgetTranscriptionyourself.- The transcription env knobs are constants in Core now.
