Skip to content
safran

Type to search. Enter opens the first result.

    Connectors overview

    A connector is the piece of Safran that talks to one outside system. This page tells you which connectors exist, what each kind is for, how a profile entry selects one, and the behaviour every connector shares: how configuration is validated, where secrets come from, what happens on HTTP failures, and what has and has not been tested against the real services.

    The four kinds

    KindProfile keyWhat it doesContract
    Trackertrackers[]Reads tickets: fields, comments, attachments, links, history, search.Tracker
    Code hostcode.hosts[]Lists repositories, supplies clone credentials, lists merged pull requests and the files they changed.CodeHost
    Doc sourcedocs[]Fetches wiki pages that tickets link to, and only pages it recognises as its own.DocSource
    EmbedderembeddingsTurns text into vectors for the code index. Exactly one per profile.Embedder

    Every connector is read-only. No built-in connector creates, edits, transitions or deletes anything in the system it talks to, and the contracts in @safran/kit have no method that could.

    A profile with one of each

    version: 1
    company: acme
    languages:
      tickets: tr
      code: en
    
    trackers:
      - id: jira
        type: jira
        url: https://acme.atlassian.net
        email_env: JIRA_EMAIL
        token_env: JIRA_TOKEN
        projects: [PAY, MOB, WEB]
    
    code:
      hosts:
        - id: azure
          type: azure-repos
          organization: acme
          project: Platform
          token_env: AZURE_DEVOPS_PAT
    
    docs:
      - id: wiki
        type: confluence
        url: https://acme.atlassian.net
        email_env: JIRA_EMAIL
        token_env: CONFLUENCE_TOKEN
        spaces: [PAY]
    
    embeddings:
      type: ollama
      model: bge-m3

    type selects the plugin; id is the name you give the entry and the name Safran uses everywhere else (jira:PAY-1423, the host column of safran repos, the source of a fetched page). Everything else in the entry belongs to the plugin and is validated by it. The surrounding file is described in the profile reference.

    Checking this file needs neither a network nor the tokens:

    $ safran profile check --profile /work/acme/safran.yaml
    ✔ /work/acme/safran.yaml is valid
    
      company      acme
      languages    tickets tr, code en
      trackers     jira
      code hosts   azure (azure-repos)
      doc sources  wiki (confluence)
      groups       none
      teams        none
      glossary     0 terms
      conventions  0
      embeddings   ollama (bge-m3)
      data         /work/acme/data
    
    Environment variables
      name              status   used by
      AZURE_DEVOPS_PAT  not set  code.hosts.azure.token_env
      CONFLUENCE_TOKEN  not set  docs.wiki.token_env
      JIRA_EMAIL        not set  trackers.jira.email_env, docs.wiki.email_env
      JIRA_TOKEN        not set  trackers.jira.token_env
    ! AZURE_DEVOPS_PAT, CONFLUENCE_TOKEN, JIRA_EMAIL, JIRA_TOKEN are not set; the connectors that use them will fail when called.
      → Export them in your shell, or put them in a .env file next to the profile.
    
    Connectors were built, not called. `safran profile check --online --profile /work/acme/safran.yaml` makes one call to each.

    Built-in connectors

    typeKindTalks toCapabilities
    jiraTrackerJira Cloud (REST v3), Jira Data Center / Server (REST v2)comments, attachments, links, history, search, native-query
    azure-boardsTrackerAzure Boards work items (Azure DevOps Services and Server)comments, attachments, links, history, search, native-query
    linearTrackerLinear, through its GraphQL APIcomments, links, history, search
    github-issuesTrackerGitHub Issues (github.com and GitHub Enterprise Server)comments, links, history, search, native-query
    azure-reposCode hostAzure Repos (Azure DevOps Services and Server)pull-requests, remote-head
    githubCode hostGitHub and GitHub Enterprise Serverpull-requests, remote-head
    gitlabCode hostGitLab (gitlab.com and self-managed), REST v4pull-requests, remote-head
    localCode hostDirectories on this machine, read in placenone
    confluenceDoc sourceConfluence Cloud (REST v2), Data Center / Server (REST v1)fetches pages by URL
    ollamaEmbedderA local Ollama server (/api/embed)embeds text
    openai-compatibleEmbedderAny server with an OpenAI-style /embeddings endpointembeds text

    safran plugins prints the same list from the registry, and marks the types your profile uses:

    $ safran plugins --profile /work/acme/safran.yaml
    Trackers  trackers[].type
      azure-boards   Azure Boards work items (Azure DevOps Services and Server), read-only
      github-issues  GitHub Issues (github.com and GitHub Enterprise Server), read-only
      jira           Jira Cloud (REST v3) and Jira Data Center / Server (REST v2), read-only [in use]
      linear         Linear issues through the GraphQL API, read-only
    
    Code hosts  code.hosts[].type
      azure-repos  Azure Repos (Azure DevOps Services and Server) [in use]
      github       GitHub and GitHub Enterprise Server
      gitlab       GitLab (gitlab.com and self-managed)
      local        Directories on this machine (read in place, no clone)
    
    Doc sources  docs[].type
      confluence  Confluence Cloud and Data Center pages that tickets link to, read-only [in use]
    
    Embedders  embeddings.type
      ollama             Local embeddings via Ollama (default model: bge-m3, multilingual) [in use]
      openai-compatible  Embeddings from any OpenAI-compatible /embeddings endpoint

    A type that is not in this list comes from a third-party plugin; see writing plugins.

    Capabilities

    A connector declares what it can do in a capabilities set, and each capability is paired with a method. Callers check the set; a call that needs a missing capability fails with UNSUPPORTED and names the tracker and what it does support.

    export const TRACKER_CAPABILITIES = ["comments", "attachments", "links", "history", "search", "native-query"] as const;
    
    export const CODE_HOST_CAPABILITIES = ["pull-requests", "remote-head"] as const;

    defined in packages/kit/src/types.ts

    Trackers

    commentsattachmentslinkshistorysearchnative-query
    jirayesyesyesyesyesJQL
    azure-boardsyesyesyesyesyesWIQL
    linearyesnoyesyesyesno
    github-issuesyesnoyesyesyessearch syntax
    • attachments means files that can be listed and downloaded. Linear's "attachments" are links to other systems and are returned by links; GitHub issue uploads are part of the Markdown body.
    • native-query means TicketSearchQuery.native is passed to the tracker as written. A search across all trackers that carries native only runs on the trackers that support it; the others are named in the result's warnings.

    Code hosts

    pull-requestsremote-head
    azure-reposyesyes
    githubyesyes
    gitlabyesyes
    localnono
    • pull-requests is what safran links refresh needs: merged pull requests, the tickets linked to them and the files they changed. A profile whose only code host is local has no work history.
    • remote-head is the getRemoteHead(repo, branch) method: the commit a branch points at on the remote.

    Rules every connector follows

    The entry is validated strictly

    Each plugin validates its whole entry with a strict schema. An unknown key is an error that names its path, so a typo cannot silently become a default:

    $ safran profile check --profile /work/acme/safran.yaml
    ✘ The profile has 1 configuration problem:
      - trackers.0: Unrecognized key: "colour"
    → Fix these entries in the profile. `safran plugins` lists the available types and their fields.

    The same applies to values. url fields accept a plain http or https URL only: one with credentials in it, a query string or a fragment is refused, because a base URL with a secret would put that secret into the profile and a query string does not survive being joined with a path. The full list of messages is in validation errors.

    Secrets are named, not written

    A field that ends in _env holds the name of an environment variable. The value must look like a variable name (JIRA_TOKEN: upper-case letters, digits, underscores), which is why a token pasted into the profile fails validation instead of being accepted. The variable is read when the connector first needs it; when it is unset or empty the call fails with AUTH_MISSING and names the variable. See secrets.

    Nothing is called at construction

    Building a connector does no network I/O and does not read its token. That is why safran profile check works on a machine with no network and no secrets, and why an instance that only reads tickets never contacts the code host or the embedder.

    safran profile check --online adds one cheap call per tracker (listProjects) and per code host (listRepos). Doc sources and the embedder are not called by it; safran doctor checks the embedder.

    HTTP failures map to error codes

    All built-in connectors use one HTTP client. A failed response becomes a SafranError with a stable code:

    ResponseCodeNotes
    401AUTH_FAILEDThe token was rejected.
    403AUTH_FAILEDThe token is valid but lacks permission. The GitHub connectors recognise a rate-limit 403 and report RATE_LIMITED instead.
    404NOT_FOUNDTrackers and hosts answer 404 for "does not exist" and for "you may not see it"; the hint says so.
    429RATE_LIMITEDAfter the retries below.
    anything else, or no responseUPSTREAMIncludes timeouts, unreachable servers, non-JSON bodies and refused redirects.
    • Retries. 408, 425, 429, 500, 502, 503, 504 and network failures are retried up to DEFAULT_HTTP_MAX_RETRIES (3) times after the first attempt. The wait is the server's Retry-After when it sends one, otherwise 500 ms doubling per attempt, and never more than DEFAULT_HTTP_MAX_RETRY_DELAY_MS (20 s). Each attempt times out after DEFAULT_HTTP_TIMEOUT_MS (30 s) unless the connector sets its own.
    • Redirects. A redirect is followed only while it stays on the origin that was asked, for at most DEFAULT_HTTP_MAX_REDIRECTS (5) hops. A redirect to another origin fails with UPSTREAM, so a token never reaches a host that is not in your profile. The Azure DevOps and Confluence connectors are stricter and follow none on their own.
    • Requests stay on the configured origin. A "next page" link or download URL supplied by the server is refused (INVALID_INPUT) when it points at another origin.
    • Errors carry no secrets. error.details holds the status, the URL without its query string, the first HTTP_ERROR_BODY_CHARS (300) characters of the body and four allow-listed response headers (retry-after, x-ratelimit-remaining, x-ratelimit-reset, content-type). Request headers never appear.

    Two codes are raised by connectors themselves, not mapped from a status: FORBIDDEN when a local allow-list refuses something the remote would have served (a Confluence space, an Azure Boards project), and UNSUPPORTED for a missing capability. How to branch on codes is in errors.

    handle-errors.ts
    import { createSafran, isSafranError } from "@safran/core";
    
    await using safran = await createSafran({ profile: "safran.yaml" });
    
    try {
      const ticket = await safran.tickets.get("PAY-1423");
      console.log(ticket.title);
    } catch (error) {
      if (isSafranError(error, "AUTH_MISSING")) console.error(error.hint);
      else if (isSafranError(error, "RATE_LIMITED")) console.error("try again later");
      else throw error;
    }

    Pagination and limits

    List methods take limit and cursor. For trackers the default page is DEFAULT_PAGE_SIZE (50) and the largest is MAX_PAGE_SIZE (100); for pull requests the default is DEFAULT_PULL_REQUEST_LIMIT (50) and the largest MAX_PULL_REQUEST_LIMIT (500). A limit above the maximum is lowered to it; one below 1 is INVALID_INPUT. A cursor is opaque: pass nextCursor back unchanged. Details are in pagination and logging.

    Verification status

    The Jira, Azure DevOps (Boards and Repos), Linear, GitLab and Confluence connectors are implemented from the vendors' API documentation and tested against recorded-shape fixtures: responses built to the documented shapes, replayed through a mock fetch. Of the built-in tracker, code host and doc source connectors, only GitHub has been exercised against the live service, and only with public repositories.

    Where the documentation did not settle a detail, the source marks the line UNVERIFIED. Each connector's page lists those items under "Known caveats", phrased as what you might see. If you run one of these connectors against a real instance and something differs, the caveats are the first place to look.

    Where to go next