class Workspace extends AbstractObject implements IdAble, Node

A Dagger workspace detected from the current working directory or constructed from a Directory.

Properties

$lastQuery from  AbstractObject

Methods

__construct(AbstractClient $client, QueryBuilderChain $queryBuilderChain)

No description

null|array|string|int|float|bool
queryLeaf(QueryBuilder $leafQueryBuilder, string $leafKey)

No description

string
address()

Canonical Dagger address of the workspace location, or an opaque identity for synthetic workspaces.

agents(array|null $include = null)

Return all agent middlewares from modules loaded in the workspace.

changes(Workspace|null $from = null)

Return this workspace's changes, with paths relative to its working directory.

checks(array|null $include = null, array|null $skip = null, bool|null $noGenerate = null, bool|null $onlyGenerate = null)

Return all checks from modules loaded in the workspace.

string
configFile()

Selected native workspace config file relative to the workspace cwd, if any.

string
configRead(string|null $key = '')

Read a configuration value from dagger.toml.

string
cwd()

Current location within the workspace root.

directory(string $path, array|null $exclude = [], array|null $include = [], bool|null $gitignore = false)

Returns a Directory from the workspace.

array
envList()

List named environments defined in the workspace configuration.

void
export()

Write this workspace's pending changes to its local Git workspace.

file(string $path)

Returns a File from the workspace.

array
findRoots(array $markers, string|null $start = '.', array|null $exclude = [])

Find project roots marked by any of the given filenames, starting from a path relative to the workspace cwd.

string
findUp(string $name, string|null $from = '.')

Search for a file or directory by walking up from the start path within the workspace.

generators(array|null $include = null)

Return all generators from modules loaded in the workspace.

git()

Git state for this workspace. Errors if the workspace is not in a git repository.

array
glob(string $pattern)

Returns a list of files and directories that match the given pattern.

Id
id()

A unique identifier for this Workspace.

migrate()

Plan the explicit migration needed for the current workspace.

module(string $name)

Return a module defined in the workspace configuration.

moduleSource(string $path)

Load a module source from a path within the workspace.

array
modules()

List modules defined in the workspace configuration.

reloaded()

Return this workspace with its cached host reads invalidated, so subsequent file and directory reads re-read the live host instead of a snapshot cached earlier in the session.

sdk(string $name)

An installed SDK, by name.

array
sdks()

Installed SDKs.

array
search(string $pattern, array|null $paths = [], array|null $globs = [], bool|null $literal = false, bool|null $multiline = false, bool|null $dotall = false, bool|null $insensitive = false, bool|null $skipIgnored = false, bool|null $skipHidden = false, bool|null $filesOnly = false, int|null $limit = null)

Searches for content matching the given regular expression or literal string.

services(array|null $include = null)

Return all services from modules loaded in the workspace.

withChanges(Changeset $changes)

Return this workspace with a changeset applied, without mutating the source.

withConfigEnv(string $name, bool|null $here = false)

Return this workspace with a named config environment created.

withConfigValue(string $key, string $value, array|null $values = null, bool|null $here = false)

Return this workspace with a configuration value written.

withDirectory(string $path, Directory $source)

Return this workspace with a directory merged into the given path, without mutating the source.

withInitClient(string $path, string $sdk, string $module, Json|null $args = null, bool|null $here = false, bool|null $noGenerate = false)

Return this workspace with a generated API client initialized.

withInitModule(string $name, string $sdk, string|null $path = '', string|null $source = '', array|null $include = [], Json|null $args = null, bool|null $here = false, bool|null $noGenerate = false)

Return this workspace with a new module initialized.

withModule(string $ref, string|null $name = '', bool|null $here = false)

Return this workspace with a module installed in its config.

withMountedDirectory(string $path, Directory $source)

Return this workspace with a directory mounted read-only at the given path, without mutating the source.

withMountedFile(string $path, File $source)

Return this workspace with a file mounted read-only at the given path, without mutating the source.

withNewDirectory(string $path, Directory $source)

Return this workspace with the given path replaced by a directory, without mutating the source.

withNewFile(string $path, string $contents, int|null $permissions = 420)

Return this workspace with a new or replaced file, without mutating the source.

withSDK(string $ref, string|null $name = '', bool|null $here = false, string|null $asSdkName = '')

Return this workspace with an SDK installed in its config.

withUpdatedLock()

Return this workspace with refreshed lockfile state.

withWorkdir(string $path)

Return this workspace with its working directory pointed at the given workspace-relative path.

withoutConfigEnv(string $name, bool|null $here = false)

Return this workspace with a named config environment removed.

withoutConfigValue(string $key, bool|null $here = false)

Return this workspace with a configuration value removed.

withoutDirectory(string $path)

Return this workspace with a directory removed, without mutating the source.

withoutFile(string $path)

Return this workspace with a file removed, without mutating the source.

withoutModule(string $name, bool|null $here = false)

Return this workspace with a module removed from its config.

withoutSDK(string $name, bool|null $here = false)

Return this workspace with an SDK removed from its config.

Details

in AbstractObject at line 13
__construct(AbstractClient $client, QueryBuilderChain $queryBuilderChain)

No description

Parameters

AbstractClient $client
QueryBuilderChain $queryBuilderChain

in AbstractObject at line 19
protected null|array|string|int|float|bool queryLeaf(QueryBuilder $leafQueryBuilder, string $leafKey)

No description

Parameters

QueryBuilder $leafQueryBuilder
string $leafKey

Return Value

null|array|string|int|float|bool

at line 19
string address()

Canonical Dagger address of the workspace location, or an opaque identity for synthetic workspaces.

Return Value

string

at line 28
AgentGroup agents(array|null $include = null)

Return all agent middlewares from modules loaded in the workspace.

Parameters

array|null $include

Return Value

AgentGroup

at line 42
Changeset changes(Workspace|null $from = null)

Return this workspace's changes, with paths relative to its working directory.

Pass from to compare against an earlier workspace state. Omitting it preserves the cumulative behavior used by clients from before this argument was added.

Parameters

Workspace|null $from

Return Value

Changeset

at line 54
CheckGroup checks(array|null $include = null, array|null $skip = null, bool|null $noGenerate = null, bool|null $onlyGenerate = null)

Return all checks from modules loaded in the workspace.

Parameters

array|null $include
array|null $skip
bool|null $noGenerate
bool|null $onlyGenerate

Return Value

CheckGroup

at line 79
string configFile()

Selected native workspace config file relative to the workspace cwd, if any.

Return Value

string

at line 94
string configRead(string|null $key = '')

Read a configuration value from dagger.toml.

If key is empty, returns the full config.

If key points to a scalar, returns the value.

If key points to a table, returns flattened dotted-key output.

Parameters

string|null $key

Return Value

string

at line 110
string cwd()

Current location within the workspace root.

The workspace root is returned as "/".

Relative paths in workspace APIs resolve from here.

Return Value

string

at line 121
Directory directory(string $path, array|null $exclude = [], array|null $include = [], bool|null $gitignore = false)

Returns a Directory from the workspace.

Relative paths resolve from the workspace cwd. Absolute paths resolve from the workspace root.

Parameters

string $path
array|null $exclude
array|null $include
bool|null $gitignore

Return Value

Directory

at line 144
array envList()

List named environments defined in the workspace configuration.

Return Value

array

at line 153
void export()

Write this workspace's pending changes to its local Git workspace.

Return Value

void

at line 164
File file(string $path)

Returns a File from the workspace.

Relative paths resolve from the workspace cwd. Absolute paths resolve from the workspace root.

Parameters

string $path

Return Value

File

at line 178
array findRoots(array $markers, string|null $start = '.', array|null $exclude = [])

Find project roots marked by any of the given filenames, starting from a path relative to the workspace cwd.

Returns cwd-relative directory paths for every marked directory at or below start, plus the nearest marked ancestor when start itself is not marked.

Each returned path is usable as-is with other workspace APIs, e.g. directory(path).

Parameters

array $markers
string|null $start
array|null $exclude

Return Value

array

at line 200
string findUp(string $name, string|null $from = '.')

Search for a file or directory by walking up from the start path within the workspace.

Returns the absolute workspace path if found, or null if not found.

Relative start paths resolve from the workspace cwd.

The search stops at the workspace root and will not traverse above it.

Parameters

string $name
string|null $from

Return Value

string

at line 213
GeneratorGroup generators(array|null $include = null)

Return all generators from modules loaded in the workspace.

Parameters

array|null $include

Return Value

GeneratorGroup

at line 225
WorkspaceGit git()

Git state for this workspace. Errors if the workspace is not in a git repository.

Return Value

WorkspaceGit

at line 236
array glob(string $pattern)

Returns a list of files and directories that match the given pattern.

Patterns match paths relative to the workspace root.

Parameters

string $pattern

Return Value

array

at line 246
Id id()

A unique identifier for this Workspace.

Return Value

Id

at line 257
WorkspaceMigration migrate()

Plan the explicit migration needed for the current workspace.

The returned plan has an empty changeset and no steps when no migration is needed.

Return Value

WorkspaceMigration

at line 268
WorkspaceModule module(string $name)

Return a module defined in the workspace configuration.

Reflects the selected env's effective view.

Parameters

string $name

Return Value

WorkspaceModule

at line 282
ModuleSource moduleSource(string $path)

Load a module source from a path within the workspace.

Relative paths (e.g., "foo") resolve from the workspace cwd; absolute paths (e.g., "/foo") resolve from the workspace root.

Fails if the path does not point to an initialized module.

Parameters

string $path

Return Value

ModuleSource

at line 294
array modules()

List modules defined in the workspace configuration.

Reflects the selected env's effective view.

Return Value

array

at line 303
Workspace reloaded()

Return this workspace with its cached host reads invalidated, so subsequent file and directory reads re-read the live host instead of a snapshot cached earlier in the session.

Return Value

Workspace

at line 312
WorkspaceSDK sdk(string $name)

An installed SDK, by name.

Parameters

string $name

Return Value

WorkspaceSDK

at line 322
array sdks()

Installed SDKs.

Return Value

array

Searches for content matching the given regular expression or literal string.

Uses Rust regex syntax; escape literal ., [, ], {, }, | with backslashes.

Runs ripgrep on the client host, falling back to grep if unavailable.

Parameters

string $pattern
array|null $paths
array|null $globs
bool|null $literal
bool|null $multiline
bool|null $dotall
bool|null $insensitive
bool|null $skipIgnored
bool|null $skipHidden
bool|null $filesOnly
int|null $limit

Return Value

array

at line 386
UpGroup services(array|null $include = null)

Return all services from modules loaded in the workspace.

Parameters

array|null $include

Return Value

UpGroup

at line 398
Workspace withChanges(Changeset $changes)

Return this workspace with a changeset applied, without mutating the source.

Parameters

Changeset $changes

Return Value

Workspace

at line 408
Workspace withConfigEnv(string $name, bool|null $here = false)

Return this workspace with a named config environment created.

Parameters

string $name
bool|null $here

Return Value

Workspace

at line 423
Workspace withConfigValue(string $key, string $value, array|null $values = null, bool|null $here = false)

Return this workspace with a configuration value written.

When the session selects an env, the key is scoped to that env's overlay and the env is created if missing.

Parameters

string $key
string $value
array|null $values
bool|null $here

Return Value

Workspace

at line 442
Workspace withDirectory(string $path, Directory $source)

Return this workspace with a directory merged into the given path, without mutating the source.

Anything already at the path stays, and files the source carries win, as with Directory.withDirectory. Use withNewDirectory to replace the path instead.

Parameters

string $path
Directory $source

Return Value

Workspace

at line 455
Workspace withInitClient(string $path, string $sdk, string $module, Json|null $args = null, bool|null $here = false, bool|null $noGenerate = false)

Return this workspace with a generated API client initialized.

The SDK's generators run for the new client, so the returned workspace carries its generated bindings.

Parameters

string $path
string $sdk
string $module
Json|null $args
bool|null $here
bool|null $noGenerate

Return Value

Workspace

at line 484
Workspace withInitModule(string $name, string $sdk, string|null $path = '', string|null $source = '', array|null $include = [], Json|null $args = null, bool|null $here = false, bool|null $noGenerate = false)

Return this workspace with a new module initialized.

The SDK's generators run for the new module, so the returned workspace carries the generated code it needs to be loadable.

Parameters

string $name
string $sdk
string|null $path
string|null $source
array|null $include
Json|null $args
bool|null $here
bool|null $noGenerate

Return Value

Workspace

at line 523
Workspace withModule(string $ref, string|null $name = '', bool|null $here = false)

Return this workspace with a module installed in its config.

When the session selects an env, the module is recorded in that env's overlay and the env is created if missing.

Parameters

string $ref
string|null $name
bool|null $here

Return Value

Workspace

at line 541
Workspace withMountedDirectory(string $path, Directory $source)

Return this workspace with a directory mounted read-only at the given path, without mutating the source.

Mounted content is readable through the normal workspace file tools but shadows the source at the mount path and stays out of the pending changeset: it never appears in changes, is never exported, and cannot be modified.

Parameters

string $path
Directory $source

Return Value

Workspace

at line 554
Workspace withMountedFile(string $path, File $source)

Return this workspace with a file mounted read-only at the given path, without mutating the source.

Mounted content is readable through the normal workspace file tools but shadows the source at the mount path and stays out of the pending changeset: it never appears in changes, is never exported, and cannot be modified.

Parameters

string $path
File $source

Return Value

Workspace

at line 567
Workspace withNewDirectory(string $path, Directory $source)

Return this workspace with the given path replaced by a directory, without mutating the source.

The source becomes the entire contents of the path: anything already there that the source does not carry is removed. Use withDirectory to keep it instead.

Parameters

string $path
Directory $source

Return Value

Workspace

at line 578
Workspace withNewFile(string $path, string $contents, int|null $permissions = 420)

Return this workspace with a new or replaced file, without mutating the source.

Parameters

string $path
string $contents
int|null $permissions

Return Value

Workspace

at line 592
Workspace withSDK(string $ref, string|null $name = '', bool|null $here = false, string|null $asSdkName = '')

Return this workspace with an SDK installed in its config.

Parameters

string $ref
string|null $name
bool|null $here
string|null $asSdkName

Return Value

Workspace

at line 611
Workspace withUpdatedLock()

Return this workspace with refreshed lockfile state.

Return Value

Workspace

at line 620
Workspace withWorkdir(string $path)

Return this workspace with its working directory pointed at the given workspace-relative path.

Parameters

string $path

Return Value

Workspace

at line 630
Workspace withoutConfigEnv(string $name, bool|null $here = false)

Return this workspace with a named config environment removed.

Parameters

string $name
bool|null $here

Return Value

Workspace

at line 647
Workspace withoutConfigValue(string $key, bool|null $here = false)

Return this workspace with a configuration value removed.

Errors when the key is not currently set.

When the session selects an env, the key is scoped to that env's overlay.

Parameters

string $key
bool|null $here

Return Value

Workspace

at line 660
Workspace withoutDirectory(string $path)

Return this workspace with a directory removed, without mutating the source.

Parameters

string $path

Return Value

Workspace

at line 670
Workspace withoutFile(string $path)

Return this workspace with a file removed, without mutating the source.

Parameters

string $path

Return Value

Workspace

at line 682
Workspace withoutModule(string $name, bool|null $here = false)

Return this workspace with a module removed from its config.

When the session selects an env, only that env's overlay entry is removed.

Parameters

string $name
bool|null $here

Return Value

Workspace

at line 695
Workspace withoutSDK(string $name, bool|null $here = false)

Return this workspace with an SDK removed from its config.

Parameters

string $name
bool|null $here

Return Value

Workspace