A Dagger SDK for authoring Dagger modules and generating typed clients in TypeScript.
This module implements the Dagger CLI 1.0 SDK contract: the engine calls its
initModule and initClient functions when you run dagger module init and
dagger api client init. It also exposes targetRuntime ("typescript"), so
modules it creates run on the built-in TypeScript runtime.
Backed by github.com/dagger/sdk-sdk/polyfill.
Install the TypeScript SDK into your workspace:
dagger sdk install github.com/dagger/typescript-sdkThis registers the SDK under the name typescript, making it available to
dagger module init typescript and dagger api client init typescript.
Commands that produce a Changeset print the diff and prompt for confirmation
before writing anything. Pass --auto-apply to skip the prompt.
Create a TypeScript SDK module under the default .dagger/modules/<name>/:
dagger module init typescript my-modulePick a different location with --path:
dagger module init typescript my-module --path some/dir/my-modulePick a runtime (node is the default; bun and deno are also supported):
dagger module init typescript my-module --runtime BUN
dagger module init typescript my-module --runtime DENOinitModule seeds src/index.ts plus runtime-specific config files:
node/bun→package.json,tsconfig.jsondeno→deno.json
If package.json, tsconfig.json, or deno.json already exist at the target
path, init merges Dagger-required keys into them rather than overwriting — your
scripts, path aliases, unstable flags, and other custom settings are preserved.
The engine owns the module's dagger.json; the SDK only contributes the
template and config files above. Run dagger generate afterwards to produce the
generated SDK.
module init accepts configuration flags written into the module's
package.json (or deno.json for Deno modules):
dagger module init typescript my-module \
--package-manager pnpm@8.15.4 \
--base-image node:23.2.0-alpineBoth flags are optional. By default no packageManager field is written and no
base image override is set.
--package-manager accepts the Node-standard name@version syntax (e.g.
npm@10.7.0, pnpm@8.15.4, yarn@1.22.22). It is only valid with the Node
runtime; Bun and Deno bundle their own.
Generate a TypeScript client bound to a module at a target path:
dagger api client init typescript ./lib/client .dagger/modules/apiThe positional arguments are the output <path> and the target <module> (a
workspace-relative path or a canonical module ref). Pass --dev to generate
against the local development client instead of a pinned release:
dagger api client init typescript ./lib/client .dagger/modules/api --devThe engine records the client (generator + directory) in workspace config and
the target dagger.json; the SDK materializes the generated client files.
Regenerate every registered module and client in the workspace:
dagger generateThe SDK also exposes auxiliary functions for working with existing modules,
callable directly with dagger call.
Read current configuration:
dagger -m github.com/dagger/typescript-sdk call \
mod --path my-module config package-manager
dagger -m github.com/dagger/typescript-sdk call \
mod --path my-module config base-imageChange configuration with config set — pass either flag, or both in a single
call. Each returns a Changeset so you confirm the diff before anything is
written:
dagger -m github.com/dagger/typescript-sdk call \
mod --path my-module config set --package-manager pnpm@8.15.4
dagger -m github.com/dagger/typescript-sdk call \
mod --path my-module config set --base-image node:23.2.0-alpine
dagger -m github.com/dagger/typescript-sdk call \
mod --path my-module config set --package-manager pnpm@8.15.4 --base-image node:23.2.0-alpineUnset stays as separate commands:
dagger -m github.com/dagger/typescript-sdk call \
mod --path my-module config unset-package-manager
dagger -m github.com/dagger/typescript-sdk call \
mod --path my-module config unset-base-imagepackage-manager is only supported on Node modules; Bun and Deno bundle their
own and the SDK rejects the flag on those runtimes. base-image writes to
deno.json for Deno modules and to package.json otherwise — matching where
the engine reads it from.
# Generate a single module's SDK files
dagger -m github.com/dagger/typescript-sdk call \
mod --path my-module generate
# Every TypeScript SDK module under the workspace
dagger -m github.com/dagger/typescript-sdk call modules path
# Generate every discovered module, skipping any with a skip marker
dagger -m github.com/dagger/typescript-sdk call generate-all
modulesandgenerate-alluse legacydagger.jsonscanning. For workspace-managed modules the engine owns the source of truth (modules.<sdk>.as-sdk.modules); preferdagger generate.
To exclude a directory tree from generate-all, drop an empty
.dagger-typescript-sdk-skip-generate file at or above the module root. Useful
for fixtures, vendored modules, or anything you don't want regenerated in bulk.
touch some/fixture/.dagger-typescript-sdk-skip-generateSee typescript-sdk.dang for the full type surface.