SDK
Drive LangSync workflows in-process from Node.js with the @mariokreitz/langsync-sdk package.
The LangSync SDK (@mariokreitz/langsync-sdk) exposes LangSync's command
runners as in-process functions. Editor integrations, custom scripts, build
plugins, and CI tooling can run the exact workflows the CLI uses without
spawning a child process.
Every runner takes an explicit cwd, returns a structured result object, and
never logs, prompts, or calls process.exit. This makes the SDK safe to embed
in long-running hosts such as a VS Code extension or a dev server.
Why a dedicated package
The SDK ships independently from the langsync CLI so you can depend on the
programmatic surface without pulling in command-line dependencies. It is the
same engine that powers the CLI and the official VS Code extension, exposed
through a stable, semver-versioned API.
The CLI re-exports the SDK for backward compatibility, but new integrations
should depend on @mariokreitz/langsync-sdk directly.
Installation
Import
Loading config
loadConfig resolves the LangSync config from an explicit working directory and
returns null when no config is found.
Validate
Sync
Find missing
Translate
Defining config in TypeScript
defineConfig gives you a fully typed langsync.config.ts and is re-exported by
both the SDK and the CLI:
Exported types
The following option, result, and engine types are exported alongside the runtime functions:
| Type | Used by |
|---|---|
LoadedConfig | loadConfig result ({ config, filepath }) |
LangSyncConfig | shape of loaded.config |
LangSyncConfigInput | defineConfig input |
RunValidateOptions | runValidate |
RunValidateResult | runValidate |
NamespacedValidationIssue | runValidate issues |
RunSyncOptions | runSync |
RunSyncResult | runSync |
RunFindMissingOptions | runFindMissing |
RunFindMissingResult | runFindMissing |
MissingEntry | runFindMissing entries |
RunTranslateOptions | runTranslate |
RunTranslateResult | runTranslate |
TranslationEntry | runTranslate entries |
AIProvider | runTranslate provider override |
ValidationIssue | underlying validation issue shape |
TreeDiff | per-file diff in RunSyncResult |