Dagger
Search

workspace

No long description provided.

Installation

dagger install github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27

Entrypoint

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
checkers[Interface ! ] -Configurable backends for check()
onSave[Interface ! ] -Notification hooks to call every time save() is called
startDirectory -Initial state to start the workspace from By default the workspace starts empty
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
func (m *myModule) example() *Workspace  {
	return dag.
			Workspace()
}
@function
def example() -> dag.Workspace:
	return (
		dag.workspace()
	)
@func()
example(): Workspace {
	return dag
		.workspace()
}

Types

Workspace 🔗

A workspace for editing files and checking the result

dir() 🔗

An immutable snapshot of the workspace contents

Return Type
Directory !
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
 dir
func (m *myModule) example() *Directory  {
	return dag.
			Workspace().
			Dir()
}
@function
def example() -> dagger.Directory:
	return (
		dag.workspace()
		.dir()
	)
@func()
example(): Directory {
	return dag
		.workspace()
		.dir()
}

check() 🔗

Check that the current contents is valid Always check before completing your task

Return Type
Void !
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
 check
func (m *myModule) example(ctx context.Context)   {
	return dag.
			Workspace().
			Check(ctx)
}
@function
async def example() -> None:
	return await (
		dag.workspace()
		.check()
	)
@func()
async example(): Promise<void> {
	return dag
		.workspace()
		.check()
}

diff() 🔗

Return all changes to the workspace since the start of the session, in unified diff format, with the following convention: - before/ is the start state - after/ is the current state

Return Type
String !
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
 diff
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			Workspace().
			Diff(ctx)
}
@function
async def example() -> str:
	return await (
		dag.workspace()
		.diff()
	)
@func()
async example(): Promise<string> {
	return dag
		.workspace()
		.diff()
}

save() 🔗

Save a snapshot of the workspace

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
descriptionString !-A detailed description of the changes to save
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
 save --description string
func (m *myModule) example(description string) *Workspace  {
	return dag.
			Workspace().
			Save(description)
}
@function
def example(description: str) -> dag.Workspace:
	return (
		dag.workspace()
		.save(description)
	)
@func()
example(description: string): Workspace {
	return dag
		.workspace()
		.save(description)
}

history() 🔗

Return a history of all Snapshots so far, from first to last

Return Type
[String ! ] !
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
 history
func (m *myModule) example(ctx context.Context) []string  {
	return dag.
			Workspace().
			History(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.workspace()
		.history()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.workspace()
		.history()
}

reset() 🔗

Reset the workspace to its starting state. Warning: this will wipe all changes made during the current session

Return Type
Workspace !
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
 reset
func (m *myModule) example() *Workspace  {
	return dag.
			Workspace().
			Reset()
}
@function
def example() -> dag.Workspace:
	return (
		dag.workspace()
		.reset()
	)
@func()
example(): Workspace {
	return dag
		.workspace()
		.reset()
}

write() 🔗

Write to a file in the workspace

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
pathString !-The path of the file to write
contentsString !-The contents to write
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
 write --path string --contents string
func (m *myModule) example(path string, contents string) *Workspace  {
	return dag.
			Workspace().
			Write(path, contents)
}
@function
def example(path: str, contents: str) -> dag.Workspace:
	return (
		dag.workspace()
		.write(path, contents)
	)
@func()
example(path: string, contents: string): Workspace {
	return dag
		.workspace()
		.write(path, contents)
}

copyDir() 🔗

Copy an entire directory into the workspace

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
pathString !-The target path
dirDirectory !-The directory to copy at the target path. Existing content is overwritten at the file granularity.
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
 copy-dir --path string --dir DIR_PATH
func (m *myModule) example(path string, dir *Directory) *Workspace  {
	return dag.
			Workspace().
			CopyDir(path, dir)
}
@function
def example(path: str, dir: dagger.Directory) -> dag.Workspace:
	return (
		dag.workspace()
		.copy_dir(path, dir)
	)
@func()
example(path: string, dir: Directory): Workspace {
	return dag
		.workspace()
		.copyDir(path, dir)
}

read() 🔗

Read the contents of a file in thw workspace

Return Type
String !
Arguments
NameTypeDefault ValueDescription
pathString !-No description provided
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
 read --path string
func (m *myModule) example(ctx context.Context, path string) string  {
	return dag.
			Workspace().
			Read(ctx, path)
}
@function
async def example(path: str) -> str:
	return await (
		dag.workspace()
		.read(path)
	)
@func()
async example(path: string): Promise<string> {
	return dag
		.workspace()
		.read(path)
}

rm() 🔗

Remove a file from the workspace

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
pathString !-No description provided
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
 rm --path string
func (m *myModule) example(path string) *Workspace  {
	return dag.
			Workspace().
			Rm(path)
}
@function
def example(path: str) -> dag.Workspace:
	return (
		dag.workspace()
		.rm(path)
	)
@func()
example(path: string): Workspace {
	return dag
		.workspace()
		.rm(path)
}

rmDir() 🔗

Remove a directory from the workspace

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
pathString !-No description provided
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
 rm-dir --path string
func (m *myModule) example(path string) *Workspace  {
	return dag.
			Workspace().
			RmDir(path)
}
@function
def example(path: str) -> dag.Workspace:
	return (
		dag.workspace()
		.rm_dir(path)
	)
@func()
example(path: string): Workspace {
	return dag
		.workspace()
		.rmDir(path)
}

listDir() 🔗

List the contents of a directory in the workspace

Return Type
[String ! ] !
Arguments
NameTypeDefault ValueDescription
pathString "/"Path of the target directory
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
 list-dir
func (m *myModule) example(ctx context.Context) []string  {
	return dag.
			Workspace().
			ListDir(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.workspace()
		.list_dir()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.workspace()
		.listDir()
}

walk() 🔗

Walk all files in the workspace (optionally filtered by a glob pattern), and return their path.

Return Type
[String ! ] !
Arguments
NameTypeDefault ValueDescription
patternString "**"A glob pattern to filter files. Only matching files will be included. The glob format is the same as Dockerfile/buildkit
Example
dagger -m github.com/dagger/agents/workspace@462fd9c6efccb1c6cc80ac5f7e0a0cfef611ef27 call \
 walk
func (m *myModule) example(ctx context.Context) []string  {
	return dag.
			Workspace().
			Walk(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.workspace()
		.walk()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.workspace()
		.walk()
}