Documentation
¶
Index ¶
- Constants
- Variables
- func EngineSession(cmd *cobra.Command, args []string) error
- func FindStateKeys(s string) iter.Seq[string]
- func FindStateTokens(s string) []string
- func FlagAvailableForCommand(cmd *cobra.Command, flag *pflag.Flag) bool
- func GetStateKey(in string) string
- func GetSupportedFunction(md *moduleDef, fp functionProvider, name string) (*modFunction, error)
- func GetSupportedFunctions(fp functionProvider) ([]*modFunction, []string, error)
- func HandlerCtx(ctx context.Context) (ret *interp.HandlerContext)
- func HasState(s string) bool
- func IsExperimental(cmd *cobra.Command) bool
- func ListSessions() ([]sessionMetadata, error)
- func Listen(ctx context.Context, engineClient *client.Client, _ *dagger.Module, ...) error
- func Main()
- func NoArgs(args []string) error
- func NormalizeWorkdir(workdir string) (string, error)
- func Query(ctx context.Context, engineClient *client.Client, _ *dagger.Module, ...) (rerr error)
- func Resource(ctx context.Context) *resource.Resource
- func RootCommand() *cobra.Command
- func Run(cmd *cobra.Command, args []string) error
- func Sorted2[K cmp.Ordered, V any](x iter.Seq2[K, V]) iter.Seq2[K, V]
- func Tracer() trace.Tracer
- func WorkspaceActivity(cmd *cobra.Command, _ []string) error
- func WorkspaceRemote(cmd *cobra.Command, _ []string) error
- func WorkspaceRemotes(cmd *cobra.Command, _ []string) error
- type CheckGroupInfo
- type CheckInfo
- type CloudCLI
- func (cli *CloudCLI) BillingManage(cmd *cobra.Command, args []string) error
- func (cli *CloudCLI) BillingPlans(cmd *cobra.Command, args []string) error
- func (cli *CloudCLI) CloudLogs(cmd *cobra.Command, args []string) error
- func (cli *CloudCLI) IntegrationList(cmd *cobra.Command, args []string) error
- func (cli *CloudCLI) IntegrationSetup(cmd *cobra.Command, args []string) error
- func (cli *CloudCLI) Login(cmd *cobra.Command, args []string) error
- func (cli *CloudCLI) Logout(cmd *cobra.Command, args []string) error
- func (cli *CloudCLI) OrgInfo(cmd *cobra.Command, args []string) error
- func (cli *CloudCLI) OrgList(cmd *cobra.Command, args []string) error
- func (cli *CloudCLI) OrgUse(cmd *cobra.Command, args []string) error
- func (cli *CloudCLI) Rerun(cmd *cobra.Command, _ []string) error
- func (cli *CloudCLI) Signup(cmd *cobra.Command, args []string) error
- func (cli *CloudCLI) Usage(cmd *cobra.Command, args []string) error
- type CompletionContext
- type DaggerValue
- type FlagGroup
- type FuncCommand
- type FunctionCall
- type GeneratorGroupInfo
- type GeneratorInfo
- type HandlerError
- type LLMSession
- func (s *LLMSession) AgentStepped(agentHandle string)
- func (s *LLMSession) Attach(ctx context.Context, agentHandle, name, encodedID string) (*sessionAgent, error)
- func (s *LLMSession) AttachRestored(ctx context.Context, agentHandle, name, encodedID string) (*sessionAgent, error)
- func (s *LLMSession) ContextVizURL() (string, error)
- func (s *LLMSession) Focus(ctx context.Context, agentHandle, name, encodedID string) error
- func (s *LLMSession) InterruptTarget() bool
- func (s *LLMSession) SetTarget(a *sessionAgent)
- func (s *LLMSession) ShowContextViz()
- func (s *LLMSession) SubmitToTarget(msg string) bool
- func (s *LLMSession) Target() *sessionAgent
- func (s *LLMSession) TargetAgentID() string
- type PositionalArgs
- type RecommendFn
- type Result
- type ShellCommand
- type ShellDoc
- type ShellDocSection
- type ShellState
- func (st ShellState) Function() FunctionCall
- func (st *ShellState) GetDef(modDef *moduleDef) (*modFunction, error)
- func (st *ShellState) GetTypeDef(modDef *moduleDef) (*modTypeDef, error)
- func (st ShellState) IsEmpty() bool
- func (st ShellState) IsError() bool
- func (st ShellState) IsHandlerError() bool
- func (st ShellState) QueryBuilder(dag *dagger.Client) *querybuilder.Selection
- func (st ShellState) WithCall(fn *modFunction, argValues map[string]any) ShellState
- type ShellStateStore
- func (s *ShellStateStore) Delete(ctx context.Context, key string)
- func (s *ShellStateStore) Extract(ctx context.Context, key string) (*ShellState, error)
- func (s *ShellStateStore) Get(key string) (ShellState, bool)
- func (s *ShellStateStore) Load(key string) (*ShellState, error)
- func (s *ShellStateStore) Prune(ctx context.Context) int
- func (s *ShellStateStore) Store(st ShellState) string
- type StateArg
- type UnsupportedFlagError
- type UpGroupInfo
- type UpInfo
Constants ¶
const ( GPUSupportEnv = "_EXPERIMENTAL_DAGGER_GPU_SUPPORT" RunnerHostEnv = "_EXPERIMENTAL_DAGGER_RUNNER_HOST" RunnerImageLoaderEnv = "_EXPERIMENTAL_DAGGER_RUNNER_IMAGESTORE" TraceNameEnv = "DAGGER_TRACE_NAME" )
const ( Directory string = "Directory" Changeset string = "Changeset" Container string = "Container" File string = "File" Secret string = "Secret" Service string = "Service" PortForward string = "PortForward" CacheVolume string = "CacheVolume" Volume string = "Volume" LLM string = "LLM" ModuleSource string = "ModuleSource" Module string = "Module" Platform string = "Platform" BuildArg string = "BuildArg" Socket string = "Socket" GitRepository string = "GitRepository" GitRef string = "GitRef" Workspace string = "Workspace" )
const InstrumentationLibrary = "dagger.io/cli"
Variables ¶
var ( // RunnerHost holds the host to connect to. // // Note: this is filled at link-time. RunnerHost string // RunnerImageLoader holds the image store for the client. RunnerImageLoader string )
var (
Frontend idtui.Frontend
)
Functions ¶
func FindStateKeys ¶
FindStateKeys returns an iterator over all state keys in the input string.
func FindStateTokens ¶
FindStateTokens returns all state tokens in the input string, if any.
func FlagAvailableForCommand ¶
FlagAvailableForCommand reports whether a flag's required capabilities are available on cmd. It is exported for CLI reference generation.
func GetStateKey ¶
GetStateKey returns the state key from a token.
If input is not exactly a token, returns an empty string.
func GetSupportedFunction ¶
func GetSupportedFunctions ¶
func HandlerCtx ¶
func HandlerCtx(ctx context.Context) (ret *interp.HandlerContext)
HandlerCtx returns interp.HandlerContext value stored in ctx, or nil if it doesn't have one.
func IsExperimental ¶
IsExperimental reports whether cmd (or any ancestor) is marked experimental.
func ListSessions ¶
func ListSessions() ([]sessionMetadata, error)
ListSessions returns saved sessions sorted by creation time (newest first, via UUIDv7 ordering). The returned metadata's LLMID field carries the file UUID (for loading), not the full LLM ID.
func NormalizeWorkdir ¶
func RootCommand ¶
RootCommand returns the fully-assembled CLI command tree, ready for documentation generation. It installs global flags so the reference includes them, matching what Main does before Execute.
Types ¶
type CheckGroupInfo ¶
type CheckGroupInfo struct {
Checks []*CheckInfo
}
type CloudCLI ¶
type CloudCLI struct{}
func (*CloudCLI) BillingManage ¶
func (*CloudCLI) BillingPlans ¶
func (*CloudCLI) IntegrationList ¶
IntegrationList lists configured integrations. With no arg, all are listed; with one arg, results are filtered by provider type (e.g., "github").
func (*CloudCLI) IntegrationSetup ¶
type CompletionContext ¶
type CompletionContext struct {
Completer *shellAutoComplete
// ModType indicates the completions should be performed on an
// object/interface/etc.
ModType functionProvider
// ModFunc indicates the completions should be performed on the arguments
// for a function call.
ModFunction *modFunction
// contains filtered or unexported fields
}
CompletionContext provides completions for a specific point in a command chain. Each point is represented by one of `Mod` prefixed fields being set at a time.
type DaggerValue ¶
type DaggerValue interface {
pflag.Value
// Get returns the final value for the query builder.
Get(context.Context, *dagger.Client, *dagger.ModuleSource, *modFunctionArg) (any, error)
}
DaggerValue is a pflag.Value that requires a dagger.Client for producing the final value.
func GetCustomFlagValue ¶
func GetCustomFlagValue(name string) DaggerValue
GetCustomFlagValue returns a pflag.Value instance for a dagger.ObjectTypeDef name.
func GetCustomFlagValueSlice ¶
func GetCustomFlagValueSlice(name string, defVal []string) (DaggerValue, error)
GetCustomFlagValueSlice returns a pflag.Value instance for a dagger.ObjectTypeDef name.
type FuncCommand ¶
type FuncCommand struct {
// The name of the command (or verb), as shown in usage.
Name string
// Aliases is an array of aliases that can be used instead of the first word in Use.
Aliases []string
// Short is the short description shown in the 'help' output.
Short string
// Hidden hides the command from help output.
Hidden bool
// Deprecated marks the command as deprecated.
Deprecated string
// Long is the long message shown in the 'help <this-command>' output.
Long string
// Example is examples of how to use the command.
Example string
// Annotations are key/value pairs that can be used to identify or
// group commands or set special options.
Annotations map[string]string
// DisableModuleLoad skips adding a flag for loading a user Dagger Module.
DisableModuleLoad bool
// contains filtered or unexported fields
}
FuncCommand is a config object used to create a dynamic set of commands for querying a module's functions.
func (*FuncCommand) Command ¶
func (fc *FuncCommand) Command() *cobra.Command
type FunctionCall ¶
type FunctionCall struct {
Object string `json:"object"`
Name string `json:"name"`
Arguments map[string]any `json:"arguments"`
ReturnObject string `json:"returnObject"`
InlineFragment string `json:"inlineFragment,omitempty"`
}
FunctionCall represents a querybyilder.Selection
The query builder only cares about the name of the function and its arguments, but we also keep track of its object's name and return type to make it easy to get the right definition from the introspection data.
func (FunctionCall) GetDef ¶
func (f FunctionCall) GetDef(modDef *moduleDef) (*modFunction, error)
GetDef returns the introspection definition for this function call
func (FunctionCall) GetNextDef ¶
func (f FunctionCall) GetNextDef(modDef *moduleDef, name string) (*modFunction, error)
GetNextDef returns the introspection definition for the next function call, based on the current return type and name of the next function
type GeneratorGroupInfo ¶
type GeneratorGroupInfo struct {
Generators []*GeneratorInfo
}
type GeneratorInfo ¶
type HandlerError ¶
type HandlerError struct {
// Err is the original error
Err error
// ExitCode is the exit status code
ExitCode int
}
HandlerError attatches an exit code to an error returned by the handler.
Could be replaced with `errors.Join(err, interp.ExitStatus(exit))` but it always adds a "exit status X" message to the error, so this allows printing only the original but still have `errors.As()` work with `interp.ExitStatus`, which is necessary for the interpreter.
We want fatal errors but adding `interp.ExitStatus` makes it non-fatal so we always add it to get a consistent behavior and rely on `set -eo pipefail` to make it fatal.
The discrepancy is due to the interpreter library considering errors without `interp.ExitStatus" to be unexpected and thus fatal by default (opt-out, not opt-in), to avoid going unnoticed.
func NewHandlerError ¶
func NewHandlerError(err error) *HandlerError
func (*HandlerError) Error ¶
func (e *HandlerError) Error() string
func (*HandlerError) Unwrap ¶
func (e *HandlerError) Unwrap() []error
type LLMSession ¶
type LLMSession struct {
// contains filtered or unexported fields
}
LLMSession owns an interactive session's conversations (hack/designs/async-agents.md §5.1). It holds the session-wide plumbing -- the dagger client, the shell handler, the frontend, the plumbing span -- plus the conversations themselves and which one the prompt addresses.
Routing resolves in exactly one place: Target. Nothing else may infer a destination from what happens to be running, because with a roster the busy agent and the focused agent are routinely different agents.
func NewLLMSession ¶
func (*LLMSession) AgentStepped ¶
func (s *LLMSession) AgentStepped(agentHandle string)
AgentStepped notifies the session that the trace reported a step boundary (a conversation commit) for the runtime with the given runtime handle. When that runtime backs the TARGET conversation, the conversation-scoped surfaces -- status line, changes preview -- are refreshed from its latest snapshot, so they track the agent step by step instead of turn by turn.
Cheap by design: it is invoked from the frontend's telemetry ingestion, so everything that talks to the engine happens on the refresh goroutine (scheduleUIRefresh), never here.
func (*LLMSession) Attach ¶
func (s *LLMSession) Attach(ctx context.Context, agentHandle, name, encodedID string) (*sessionAgent, error)
Attach adopts an agent this session did not spawn as a conversation of its own, rooted on the runtime's last committed snapshot -- the honest chain, pinned by ID. The runtime is not owned: this session may prompt and interrupt it, but clearing the conversation must never stop somebody else's worker.
Re-attaching to the same agent returns the existing conversation rather than forking a second view of one runtime.
func (*LLMSession) AttachRestored ¶
func (s *LLMSession) AttachRestored(ctx context.Context, agentHandle, name, encodedID string) (*sessionAgent, error)
AttachRestored adopts an agent this session RE-HYDRATED from a trace (hack/designs/resume-from-trace.md §5.3). Same adoption, opposite ownership: a restored agent has no other driver -- the session that published it is gone -- so this session is the one whose business it is to stop it, and .clear stopping the runtime is right.
func (*LLMSession) ContextVizURL ¶
func (s *LLMSession) ContextVizURL() (string, error)
ContextVizURL starts the visualizer's local web server on first use and returns its URL. The server lives for the rest of the session, bound to localhost on a random port, and always renders the conversation the session currently focuses.
func (*LLMSession) Focus ¶
func (s *LLMSession) Focus(ctx context.Context, agentHandle, name, encodedID string) error
Focus points the prompt at the agent with the given runtime handle, attaching to it first when the session is not already driving it. encodedID is a handle the client rebuilt from the trace (design §9: telemetry is the directory); it is only consulted when attaching.
A failed attach leaves focus where it was: an agent the client cannot address is one it can watch, not one it can talk to.
func (*LLMSession) InterruptTarget ¶
func (s *LLMSession) InterruptTarget() bool
InterruptTarget preempts the target conversation, reporting whether there was anything to preempt. This is Ctrl-C with a roster: it acts on the focused agent's runtime, not on whichever turn holds the client.
func (*LLMSession) SetTarget ¶
func (s *LLMSession) SetTarget(a *sessionAgent)
SetTarget points the prompt at a conversation the session already holds. Focus moves only by keypress, so nothing calls this from an event path.
func (*LLMSession) ShowContextViz ¶
func (s *LLMSession) ShowContextViz()
ShowContextViz makes the visualizer reachable: it starts the server if needed, surfaces the URL in the sidebar (the browser may be unreachable, e.g. over SSH), and tries to open the user's browser.
func (*LLMSession) SubmitToTarget ¶
func (s *LLMSession) SubmitToTarget(msg string) bool
SubmitToTarget offers a message to the target conversation's in-flight turn, reporting whether there was one to absorb it. Nothing else routes messages: a message submitted while some OTHER agent is mid-turn must not be delivered to that agent just because it happens to be the busy one.
func (*LLMSession) Target ¶
func (s *LLMSession) Target() *sessionAgent
Target is the conversation the prompt addresses -- the single place message routing resolves. It is never nil: the session's own conversation exists from construction.
func (*LLMSession) TargetAgentID ¶
func (s *LLMSession) TargetAgentID() string
TargetAgentID is the runtime handle of the runtime the prompt currently addresses, or "" when the target has not spawned (or attached to) one yet. The roster marks its entry with it.
type PositionalArgs ¶
func ExactArgs ¶
func ExactArgs(n int) PositionalArgs
func MaximumArgs ¶
func MaximumArgs(n int) PositionalArgs
func MinimumArgs ¶
func MinimumArgs(n int) PositionalArgs
type RecommendFn ¶
RecommendFn returns the workspace-root-relative paths that recommend a module. An empty result means no recommendation. A nil function is never called.
func SimpleRecommend ¶
func SimpleRecommend(patterns ...string) RecommendFn
SimpleRecommend recommends a module when any file path pattern matches.
type Result ¶
type Result struct {
Value any
// contains filtered or unexported fields
}
Result is a resolved state
type ShellCommand ¶
type ShellCommand struct {
// Use is the one-line usage message
Use string
// Description is the short description shown in the '.help' output
Description string
// Expected arguments
Args PositionalArgs
// Expected state
State StateArg
// Run is the function that will be executed.
Run func(ctx context.Context, cmd *ShellCommand, args []string, st *ShellState) error
// Complete provides builtin completions
Complete func(ctx *CompletionContext, args []string) *CompletionContext
// HelpFunc is a custom function for customizing the help output
HelpFunc func(cmd *ShellCommand) string
// The group id under which this command is grouped in the '.help' output
GroupID string
// Hidden hides the command from `.help`
Hidden bool
// NoResolveStateArgs indicates that the command should not resolve state
// values in arguments, before passing them to Run.
NoResolveStateArgs bool
}
ShellCommand is a Dagger Shell builtin or stdlib command
func (*ShellCommand) Execute ¶
func (c *ShellCommand) Execute(ctx context.Context, h *shellCallHandler, args []string, st *ShellState) error
Execute is the main dispatcher function for shell builtin commands
func (*ShellCommand) Help ¶
func (c *ShellCommand) Help() string
func (*ShellCommand) Short ¶
func (c *ShellCommand) Short() string
Short is the summary for the command
type ShellDocSection ¶
type ShellState ¶
type ShellState struct {
// Key is the state store key
Key string `json:"key"`
// ModDigest is the module source digest for the current state
//
// If empty, it must fall back to the default context.
// It matches a key in the modDefs map in the handler.
ModDigest string `json:"digest"`
// Cmd is non-empty if next command comes from a builtin instead of an API object
Cmd string `json:"cmd"`
// Calls is the list of functions for building an API query
Calls []FunctionCall `json:"calls,omitempty"`
// Error is non-nil if the previous command failed
Error error `json:"error,omitempty"`
}
ShellState is an intermediate representation of a query
The query builder serializes to a GraphQL query but not back from it so we use this data structure to keep track of the command chain in order to make it easy to create a querybuilder.Selection from it, when needed.
We could alternatively encode this in the querybuilder itself, except that this state also includes key pieces of information from introspection that make it very easy to validate and get the next function's definition.
This state is passed around from the stdout of an exec handler to then next one's stdin. Each handler in the chain should add a corresponding FunctionCall to the state and write it to stdout for the next handler to read.
func (ShellState) Function ¶
func (st ShellState) Function() FunctionCall
Function returns the last function in the chain, if not empty
func (*ShellState) GetDef ¶
func (st *ShellState) GetDef(modDef *moduleDef) (*modFunction, error)
GetDef returns the introspection definition for the last function call
func (*ShellState) GetTypeDef ¶
func (st *ShellState) GetTypeDef(modDef *moduleDef) (*modTypeDef, error)
GetTypeDef returns the introspection definition for the return type of the last function call
func (ShellState) IsEmpty ¶
func (st ShellState) IsEmpty() bool
IsEmpty returns true if there's no function calls in the chain
func (ShellState) IsError ¶
func (st ShellState) IsError() bool
func (ShellState) IsHandlerError ¶
func (st ShellState) IsHandlerError() bool
func (ShellState) QueryBuilder ¶
func (st ShellState) QueryBuilder(dag *dagger.Client) *querybuilder.Selection
QueryBuilder returns a querybuilder.Selection from the shell state
func (ShellState) WithCall ¶
func (st ShellState) WithCall(fn *modFunction, argValues map[string]any) ShellState
WithCall returns a new state with the given function call added to the chain
type ShellStateStore ¶
type ShellStateStore struct {
// contains filtered or unexported fields
}
ShellStateStore manages state instances in memory concurrently.
func NewStateStore ¶
func NewStateStore(runner *interp.Runner) *ShellStateStore
func (*ShellStateStore) Delete ¶
func (s *ShellStateStore) Delete(ctx context.Context, key string)
Delete removes a state instance by key.
The state won't be deleted if in use by a variable.
func (*ShellStateStore) Extract ¶
func (s *ShellStateStore) Extract(ctx context.Context, key string) (*ShellState, error)
Extract is like [Load] but also deletes the state from memory.
This is expected to be used when the state is being resolved rather than just passed around.
func (*ShellStateStore) Get ¶
func (s *ShellStateStore) Get(key string) (ShellState, bool)
Get returns a state instance by key.
func (*ShellStateStore) Load ¶
func (s *ShellStateStore) Load(key string) (*ShellState, error)
Load is like [Get] but returns an error if the key is not found or if the state represents an error.
func (*ShellStateStore) Prune ¶
func (s *ShellStateStore) Prune(ctx context.Context) int
Prune removes all state instances that are not in use by a variable.
func (*ShellStateStore) Store ¶
func (s *ShellStateStore) Store(st ShellState) string
Store saves a state instance and returns its key.
This always generates a new key for immutability.
type UnsupportedFlagError ¶
func (*UnsupportedFlagError) Error ¶
func (e *UnsupportedFlagError) Error() string
type UpGroupInfo ¶
type UpGroupInfo struct {
Ups []*UpInfo
}
Source Files
¶
- agent.go
- analyze_cloud.go
- api.go
- billing_cloud.go
- call.go
- capabilities.go
- checks.go
- cloud.go
- cloud_check.go
- cloud_checks.go
- cloud_client.go
- cloud_helpers.go
- cloud_rerun.go
- cloud_rerun_query.go
- cloud_signup.go
- context_viz.go
- debug.go
- engine.go
- engine_help.go
- exec_unix.go
- flags.go
- function_name.go
- functions.go
- generators.go
- init.go
- installed.go
- integration_cloud.go
- list_output.go
- listen.go
- llm.go
- llm_changes.go
- llm_config.go
- lock.go
- main.go
- mcp.go
- migrate.go
- mod.go
- module.go
- module_init.go
- module_inspect.go
- module_recommend.go
- module_sdk.go
- module_sdk_dynamic.go
- module_selection.go
- modules.go
- org_cloud.go
- query.go
- recommend.go
- recommend_config.go
- references.go
- restore.go
- run.go
- sdk.go
- sdk_init_dynamic.go
- session.go
- session_agent.go
- settings.go
- setup.go
- shell.go
- shell_commands.go
- shell_completion.go
- shell_debug.go
- shell_exec.go
- shell_fs.go
- shell_help.go
- shell_state.go
- span_name.go
- ssh_askpass.go
- terminal.go
- trace.go
- trace_target.go
- up.go
- usage_cloud.go
- version.go
- workspace.go
- workspace_entrypoint.go
- workspace_exec.go
- workspace_export.go
- workspace_find.go
- workspace_git.go
- workspace_git_url.go
- workspace_grep.go