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?
_defaultPlatform?
_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
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?
Returns
changeset()
changeset():
Changeset
Creates an empty changeset
Returns
cloud()
cloud():
Cloud
Dagger Cloud configuration and state
Returns
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?
Returns
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
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
currentModule()
currentModule():
CurrentModule
The module currently being served in the session, if any.
Returns
currentTypeDefs()
currentTypeDefs(
opts?):Promise<TypeDef[]>
The TypeDef representations of the objects currently being served in the session.
Parameters
opts?
Returns
Promise<TypeDef[]>
currentWorkspace()
currentWorkspace():
Workspace
Experimental
Detect and return the current workspace.
Returns
defaultPlatform()
defaultPlatform():
Promise<Platform>
The default platform of the engine.
Returns
Promise<Platform>
directory()
directory():
Directory
Creates an empty directory.
Returns
engine()
engine():
Engine
The Dagger engine container configuration and state
Returns
env()
env(
opts?):Env
Experimental
Initializes a new environment
Parameters
opts?
Returns
envFile()
envFile(
opts?):EnvFile
Initialize an environment file
Parameters
opts?
Returns
error()
error(
message):Error
Create a new error.
Parameters
message
string
A brief description of the error.
Returns
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?
Returns
function_()
function_(
name,returnType):Function_
Creates a function.
Parameters
name
string
Name of the function, in its original format from the implementation language.
returnType
Return type of the function.
Returns
generatedCode()
generatedCode(
code):GeneratedCode
Create a code generation result, given a directory containing the generated code.
Parameters
code
Returns
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?
Returns
host()
host():
Host
Queries the host environment.
Returns
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?
Returns
id()
id():
Promise<ID>
A unique identifier for this Query.
Returns
Promise<ID>
json()
json():
JSONValue
Initialize a JSON value
Returns
llm()
llm(
opts?):LLM
Experimental
Initialize a Large Language Model (LLM)
Parameters
opts?
Returns
module_()
module_():
Module_
Create a new module.
Returns
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?
Returns
node()
node(
id):Node
Load any object by its ID.
Parameters
id
Returns
secret()
secret(
uri,opts?):Secret
Creates a new secret.
Parameters
uri
string
The URI of the secret store
opts?
Returns
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
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
typeDef()
typeDef():
TypeDef
Create a new TypeDef.
Returns
version()
version():
Promise<string>
Get the current Dagger Engine version.
Returns
Promise<string>