Skip to main content

Class: Client

The root of the DAG.

Extends

  • BaseClient

Constructors

Constructor

new Client(ctx?, _id?, _defaultPlatform?, _version?): Client

Constructor is used for internal usage only, do not create object from it.

Parameters

ctx?

Context

_id?

ID

_defaultPlatform?

Platform

_version?

string

Returns

Client

Overrides

BaseClient.constructor

Methods

address()

address(value): Address

initialize an address to load directories, containers, secrets or other object types.

Parameters

value

string

Returns

Address


cacheVolume()

cacheVolume(key, opts?): CacheVolume

Constructs a cache volume for a given cache key.

Parameters

key

string

A string identifier to target this cache volume (e.g., "modules-cache").

opts?

ClientCacheVolumeOpts

Returns

CacheVolume


changeset()

changeset(): Changeset

Creates an empty changeset

Returns

Changeset


cloud()

cloud(): Cloud

Dagger Cloud configuration and state

Returns

Cloud


container()

container(opts?): Container

Creates a scratch container, with no image or metadata.

To pull an image, follow up with the "from" function.

Parameters

opts?

ClientContainerOpts

Returns

Container


currentEnv()

currentEnv(): Env

Experimental

Returns the current environment

When called from a function invoked via an LLM tool call, this will be the LLM's current environment, including any modifications made through calling tools. Env values returned by functions become the new environment for subsequent calls, and Changeset values returned by functions are applied to the environment's workspace.

When called from a module function outside of an LLM, this returns an Env with the current module installed, and with the current module's source directory as its workspace.

Returns

Env


currentFunctionCall()

currentFunctionCall(): FunctionCall

The FunctionCall context that the SDK caller is currently executing in.

If the caller is not currently executing in a function, this will return an error.

Returns

FunctionCall


currentModule()

currentModule(): CurrentModule

The module currently being served in the session, if any.

Returns

CurrentModule


currentTypeDefs()

currentTypeDefs(opts?): Promise<TypeDef[]>

The TypeDef representations of the objects currently being served in the session.

Parameters

opts?

ClientCurrentTypeDefsOpts

Returns

Promise<TypeDef[]>


currentWorkspace()

currentWorkspace(): Workspace

Experimental

Detect and return the current workspace.

Returns

Workspace


defaultPlatform()

defaultPlatform(): Promise<Platform>

The default platform of the engine.

Returns

Promise<Platform>


directory()

directory(): Directory

Creates an empty directory.

Returns

Directory


engine()

engine(): Engine

The Dagger engine container configuration and state

Returns

Engine


env()

env(opts?): Env

Experimental

Initializes a new environment

Parameters

opts?

ClientEnvOpts

Returns

Env


envFile()

envFile(opts?): EnvFile

Initialize an environment file

Parameters

opts?

ClientEnvFileOpts

Returns

EnvFile


error()

error(message): Error

Create a new error.

Parameters

message

string

A brief description of the error.

Returns

Error


file()

file(name, contents, opts?): File

Creates a file with the specified contents.

Parameters

name

string

Name of the new file. Example: "foo.txt"

contents

string

Contents of the new file. Example: "Hello world!"

opts?

ClientFileOpts

Returns

File


function_()

function_(name, returnType): Function_

Creates a function.

Parameters

name

string

Name of the function, in its original format from the implementation language.

returnType

TypeDef

Return type of the function.

Returns

Function_


generatedCode()

generatedCode(code): GeneratedCode

Create a code generation result, given a directory containing the generated code.

Parameters

code

Directory

Returns

GeneratedCode


getGQLClient()

getGQLClient(): GraphQLClient

Get the Raw GraphQL client.

Returns

GraphQLClient


git()

git(url, opts?): GitRepository

Queries a Git repository.

Parameters

url

string

URL of the git repository.

Can be formatted as https://{host}/{owner}/{repo}, git@{host}:{owner}/{repo}.

Suffix ".git" is optional.

opts?

ClientGitOpts

Returns

GitRepository


host()

host(): Host

Queries the host environment.

Returns

Host


http()

http(url, opts?): File

Returns a file containing an http remote url content.

Parameters

url

string

HTTP url to get the content from (e.g., "https://docs.dagger.io").

opts?

ClientHttpOpts

Returns

File


id()

id(): Promise<ID>

A unique identifier for this Query.

Returns

Promise<ID>


json()

json(): JSONValue

Initialize a JSON value

Returns

JSONValue


llm()

llm(opts?): LLM

Experimental

Initialize a Large Language Model (LLM)

Parameters

opts?

ClientLlmOpts

Returns

LLM


module_()

module_(): Module_

Create a new module.

Returns

Module_


moduleSource()

moduleSource(refString, opts?): ModuleSource

Create a new module source instance from a source ref string

Parameters

refString

string

The string ref representation of the module source

opts?

ClientModuleSourceOpts

Returns

ModuleSource


node()

node(id): Node

Load any object by its ID.

Parameters

id

ID

Returns

Node


secret()

secret(uri, opts?): Secret

Creates a new secret.

Parameters

uri

string

The URI of the secret store

opts?

ClientSecretOpts

Returns

Secret


setSecret()

setSecret(name, plaintext): Secret

Sets a secret given a user defined name to its plaintext and returns the secret.

The plaintext value is limited to a size of 128000 bytes.

Parameters

name

string

The user defined name for this secret

plaintext

string

The plaintext of the secret

Returns

Secret


sourceMap()

sourceMap(filename, line, column): SourceMap

Creates source map metadata.

Parameters

filename

string

The filename from the module source.

line

number

The line number within the filename.

column

number

The column number within the line.

Returns

SourceMap


typeDef()

typeDef(): TypeDef

Create a new TypeDef.

Returns

TypeDef


version()

version(): Promise<string>

Get the current Dagger Engine version.

Returns

Promise<string>