engine

package
v1.0.0-beta.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 20 Imported by: 3

Documentation

Index

Constants

View Source
const (
	EngineImageRepo = "registry.dagger.io/engine"
	Package         = "github.com/dagger/dagger"

	DefaultEngineSockAddr = distconsts.DefaultEngineSockAddr

	DaggerNameEnv = "_EXPERIMENTAL_DAGGER_ENGINE_NAME"

	DaggerVersionEnv        = "_EXPERIMENTAL_DAGGER_VERSION"
	DaggerTagEnv            = "_EXPERIMENTAL_DAGGER_TAG"
	DaggerMinimumVersionEnv = "_EXPERIMENTAL_DAGGER_MIN_VERSION"

	CloudRunnerHostPrefix  = "dagger-cloud://"
	DefaultCloudRunnerHost = CloudRunnerHostPrefix + "default-engine-config.dagger.cloud"
)
View Source
const (
	StdinPrefix  = "\x00,"
	StdoutPrefix = "\x01,"
	StderrPrefix = "\x02,"
	ResizePrefix = "resize,"
	ExitPrefix   = "exit,"
)
View Source
const (
	HTTPProxyEnvName  = "HTTP_PROXY"
	HTTPSProxyEnvName = "HTTPS_PROXY"
	FTPProxyEnvName   = "FTP_PROXY"
	NoProxyEnvName    = "NO_PROXY"
	AllProxyEnvName   = "ALL_PROXY"

	SessionAttachablesEndpoint = "/sessionAttachables"

	// NestedClientIDEnv carries the exec-created identity used by the injected
	// /.init helper's attachables connection. Logical clients created by the
	// nested process use their independently generated request client IDs.
	NestedClientIDEnv = "_DAGGER_NESTED_CLIENT_ID"
	InitEndpoint      = "/init"
	QueryEndpoint     = "/query"
	ShutdownEndpoint  = "/shutdown"

	// Buildkit-interpreted session keys, can't change
	SessionIDMetaKey         = "X-Docker-Expose-Session-Uuid"
	SessionNameMetaKey       = "X-Docker-Expose-Session-Name"
	SessionSharedKeyMetaKey  = "X-Docker-Expose-Session-Sharedkey"
	SessionMethodNameMetaKey = "X-Docker-Expose-Session-Grpc-Method"
)
View Source
const (
	OTelTraceParentEnv      = "TRACEPARENT"
	OTelTracesExporterEnv   = "OTEL_TRACES_EXPORTER"
	OTelExporterProtocolEnv = "OTEL_EXPORTER_OTLP_PROTOCOL"
	OTelExporterEndpointEnv = "OTEL_EXPORTER_OTLP_ENDPOINT"
	OTelTracesProtocolEnv   = "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL"
	OTelTracesEndpointEnv   = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"
	OTelTracesLiveEnv       = "OTEL_EXPORTER_OTLP_TRACES_LIVE"
	OTelLogsProtocolEnv     = "OTEL_EXPORTER_OTLP_LOGS_PROTOCOL"
	OTelLogsEndpointEnv     = "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT"
	OTelMetricsProtocolEnv  = "OTEL_EXPORTER_OTLP_METRICS_PROTOCOL"
	OTelMetricsEndpointEnv  = "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT"
)
View Source
const (
	EngineVersionMetaKey = "X-Dagger-Engine"

	ClientMetadataMetaKey = "X-Dagger-Client-Metadata"
	// ChildClientMetadataMetaKey carries the client metadata of a Dagger client
	// that another client serves to its own child processes, as `dagger api
	// with-session` does. Each client between the child and the engine appends
	// the metadata of the client it serves, so the last value is the direct
	// child of the client the request's own metadata names.
	ChildClientMetadataMetaKey = "X-Dagger-Child-Client-Metadata"

	// GitIgnoreOverridesHeader acknowledges client-side rule overrides.
	GitIgnoreOverridesHeader = "dagger-gitignore-overrides"

	// socket session attachable keys
	SocketURLEncodedKey = "X-Dagger-Socket-URLEncoded"

	// SuppressTelemetryHeader opts a single /query request out of telemetry
	// when set to "true": no per-request wrapper span, and no dagql call
	// spans/logs for the request's whole selection. Intended for read-only
	// "observer" queries (e.g. the CLI's context visualizer polling the LLM
	// conversation) whose telemetry is pure noise and, worse, unbounded: an
	// observer re-reading ever-growing state emits volume quadratic in that
	// state's size, bloating the engine-side telemetry stores.
	SuppressTelemetryHeader = "X-Dagger-Suppress-Telemetry"
)
View Source
const (
	// CloudTelemetryPublisherEngine is the ClientMetadata.CloudTelemetryPublisher
	// value that asks the engine to publish the session's telemetry to Cloud.
	CloudTelemetryPublisherEngine = "engine"

	// CloudTelemetryPublisherHeader, set to CloudTelemetryPublisherEngine on a
	// telemetry stream's response, confirms that the engine publishes the
	// session's telemetry to Cloud, so the client must not forward it there.
	// An engine decides once per session, before any stream opens, and answers
	// every stream of the session alike, reconnects included.
	CloudTelemetryPublisherHeader = "X-Dagger-Cloud-Telemetry-Publisher"
)
View Source
const IdentifierCasingVersion = PrereleaseViewsVersion

IdentifierCasingVersion is the first engine version with the identifier casing rules: new module naming rules and the renamed core API (e.g. GitCommit.shortSHA). Gate on it with a view filter, View(AfterVersion(engine.IdentifierCasingVersion)) and View(BeforeVersion(engine.IdentifierCasingVersion)), in a resolver with core.Supports(ctx, engine.IdentifierCasingVersion), and for a declared version outside a call with APIVersionAtLeast.

It must not be older than PrereleaseViewsVersion: earlier prereleases share one view, which a gate cannot split. Prerelease views exist for this cut, so the two ship together; if PrereleaseViewsVersion ships before the casing changes do, give this its own, later, value.

View Source
const PrereleaseViewsVersion = "v1.0.0-beta.22"

PrereleaseViewsVersion is the first release whose API view keeps its prerelease (see APIViewVersion). It is frozen once released: moving it would change the view, and so the schema and cache keys, of every caller declaring a version between the old and new value. Until then, if the release it names ships without prerelease views (as v1.0.0-beta.21 did), bump it and basePrereleaseView together (see internal-docs/version-gating.md).

Variables

View Source
var (
	// Version is the engine/CLI semver, derived from internal/version.Version
	// (which embeds the VERSION file at build time) with a "v" prefix. It is no
	// longer injected via -ldflags: the binary self-reports from embedded VERSION.
	//
	// DAGGER_VERSION overrides at init for tests.
	Version string

	// Tag is the default engine image tag. It defaults to Version.
	//
	// DAGGER_TAG overrides at init for tests.
	Tag string

	// MinimumEngineVersion is used by the client to determine the minimum
	// allowed engine version that can be used by that client.
	MinimumEngineVersion = "v0.19.0"

	// MinimumClientVersion is used by the engine to determine the minimum
	// allowed client version that can connect to that engine.
	MinimumClientVersion = "v0.19.0"

	// MinimumModuleVersion is used by the engine to determine the minimum
	// allowed module engine version that can connect to this engine.
	//
	// Set to v0.9.9, because this was when the engineVersion field was
	// introduced - if it's present and not a dev version, it must be higher
	// than v0.9.9.
	MinimumModuleVersion = "v0.9.9"

	// MinimumDefaultFunctionCachingModuleVersion is the minimum module version at which
	// we will enable default function caching behavior.
	MinimumDefaultFunctionCachingModuleVersion = "v0.19.4"

	// CollectionItemChecksVersion is the first module version where collection
	// checks no longer replace matching item checks during execution.
	CollectionItemChecksVersion = "v1.0.0-beta.22"

	// MinimumDangV2ModuleVersion is the minimum module engine version that gets
	// Dang v2 semantics (`.{ }` is dot-block application, `.{{ }}` is
	// selection); older modules keep Dang v1 semantics (`.{ }` is selection).
	MinimumDangV2ModuleVersion = "v0.21.5"
)
View Source
var ErrSnapshotShareEvaluation = errors.New("snapshot share preparation cannot evaluate, execute, start a service or request content")

ErrSnapshotShareEvaluation is returned by every boundary a snapshot-share preparation is forbidden to cross. It is an invariant diagnostic, not a supported outcome: the decoder audit and the reference preflight are what keep a known context-dependent failure out of a shared decode attempt, and a guard that trips means one of those missed a case.

Functions

func APIVersionAtLeast

func APIVersionAtLeast(version, minVersion string) bool

APIVersionAtLeast reports whether a module that declares engineVersion version gets the API of minVersion or later: whether its API view (ModuleAPIViewVersion) is at or past minVersion, comparing prereleases. It is a view gate, AfterVersion(minVersion), for a module's declared version where no call carries the view.

func APIViewVersion

func APIViewVersion(version string) string

APIViewVersion returns the API view for a client or module that declares version.

From PrereleaseViewsVersion on, a view keeps the declared prerelease, so a view gate such as AfterVersion(PrereleaseViewsVersion) tells it and later prereleases apart from earlier ones, and orders them before v1.0.0. Build metadata is dropped, and so is a dev build's prerelease (any prerelease mentioning "dev", e.g. v1.0.0-dev-<commit>): dev builds of a version share its release's view, and are past every prerelease gate of that version.

Before PrereleaseViewsVersion, views are base-version granular, as they always were: every prerelease of a version shares that version's view. The exception is v1.0.0, whose release view is now distinct: its earlier prereleases share basePrereleaseView instead.

func BaseVersion added in v0.12.4

func BaseVersion(version string) string

func CheckMaxVersionCompatibility added in v0.12.4

func CheckMaxVersionCompatibility(version string, maxVersion string) bool

CheckMaxVersionCompatibility reports whether version's base version is not past maxVersion's. An engine refuses a module declaring a later base version (e.g. v2.0.1 on v2.0.0). A later prerelease of the engine's own base version, or the release itself, loads: ModuleAPIViewVersion caps its view at the engine's.

func CheckSnapshotSharePreparation

func CheckSnapshotSharePreparation(ctx context.Context, operation string) error

CheckSnapshotSharePreparation refuses the named operation under the marker. Guards never grant authority: an accidental ClientScope does not bypass them, and an unmarked context is unaffected.

func CheckVersionCompatibility added in v0.11.7

func CheckVersionCompatibility(version string, minVersion string) bool

func ContextWithClientMetadata added in v0.8.0

func ContextWithClientMetadata(ctx context.Context, clientMetadata *ClientMetadata) context.Context

func ContextWithClientScope

func ContextWithClientScope(ctx context.Context, scope ClientScope) (context.Context, error)

ContextWithClientScope installs the immutable scope and its metadata snapshot. Existing metadata values are replaced by the sealed snapshot.

func ContextWithTelemetrySuppression

func ContextWithTelemetrySuppression(ctx context.Context) context.Context

ContextWithTelemetrySuppression marks the context so that HTTP requests made with it carry SuppressTelemetryHeader, opting the request out of engine-side telemetry. See SuppressTelemetryHeader for when this is appropriate.

func FullVersion

func FullVersion() string

func IsSnapshotSharePreparation

func IsSnapshotSharePreparation(ctx context.Context) bool

IsSnapshotSharePreparation reports whether ctx carries the marker.

func ModuleAPIViewVersion

func ModuleAPIViewVersion(version string) string

ModuleAPIViewVersion returns the API view for a module that declares engineVersion version: its APIViewVersion, capped at the engine's own (APIViewVersion(Version)). A module declaring a later prerelease than the engine, or the release itself, loads and is served the engine's view, the newest API the engine has; e.g. a v1.0.0-beta.22 engine serves a module declaring v1.0.0 the v1.0.0-beta.22 view. A later base version is refused before it gets a view (CheckMaxVersionCompatibility).

Use it wherever a module's engineVersion becomes a view: its core schema, its client sessions, and gates on its declared version (APIVersionAtLeast). A module client that declares its own version is capped by it too.

func NestedClientParentID

func NestedClientParentID(ctx context.Context, sessionID string) (string, error)

NestedClientParentID returns the client that may create a nested client from this context: the one whose scope it holds. Client metadata may name a workspace-owning ancestor while the held scope names the client actually executing the operation, and only the held scope is authority to create a child; deriving the parent from metadata would let cache or workspace metadata choose the transport's parent.

func NormalizeVersion added in v0.12.4

func NormalizeVersion(version string) string

func RipgrepNoFilesSearched

func RipgrepNoFilesSearched(stderr string) bool

RipgrepNoFilesSearched reports whether ripgrep's stderr says it exited only because every candidate file was excluded by a filter (globs, ignore rules, hidden-file rules), rather than because something actually went wrong.

ripgrep exits 2 with "No files were searched, which means ripgrep probably applied a filter you didn't expect." even though "the filter matched nothing" is a perfectly ordinary outcome of a search - e.g. a --glob naming a file that doesn't exist in the tree being searched. Since search results from one tree get merged with results from others (workspace overlays, cache mounts), treating this as fatal loses matches that do exist in the other trees.

func TelemetrySuppressedFromContext

func TelemetrySuppressedFromContext(ctx context.Context) bool

TelemetrySuppressedFromContext reports whether the context was marked with ContextWithTelemetrySuppression.

func WithSnapshotSharePreparation

func WithSnapshotSharePreparation(ctx context.Context) context.Context

WithSnapshotSharePreparation marks a context as a sharing worker's preparation context. The marker is preserved through slot, ancestor and detached cleanup contexts; it never enters a decoded value, a schema builder or an unmarked foreground waiter's context.

Types

type ClientLeaseKind

type ClientLeaseKind string

ClientLeaseKind identifies why executable client state is retained. These lifecycle leases are intentionally unrelated to BuildKit or DagQL operation leases, which protect snapshots and other operation resources.

const (
	ClientLeaseTransport      ClientLeaseKind = "transport"
	ClientLeaseRequest        ClientLeaseKind = "request"
	ClientLeaseAgent          ClientLeaseKind = "agent"
	ClientLeaseAgentTombstone ClientLeaseKind = "agent-tombstone"
	ClientLeaseService        ClientLeaseKind = "service"
	ClientLeaseSharedWork     ClientLeaseKind = "shared-work"
	ClientLeaseChild          ClientLeaseKind = "child"
)

type ClientLifecycleLease

type ClientLifecycleLease struct {
	// contains filtered or unexported fields
}

ClientLifecycleLease is an idempotent handle retaining one client runtime for a specific owner and reason.

func DetachClientScope

func DetachClientScope(ctx context.Context, kind ClientLeaseKind, ownerID string) (context.Context, *ClientLifecycleLease, error)

DetachClientScope explicitly clones lifecycle ownership before removing the caller's cancellation. It replaces only execution authority, preserving the effective client metadata used for host/resource routing. Contexts without a scope are supported for standalone DagQL/core use and return no lease; engine request contexts always carry one.

func NewClientLifecycleLease

func NewClientLifecycleLease(
	kind ClientLeaseKind,
	ownerID string,
	release func(),
	clone func(ClientLeaseKind, string) (*ClientLifecycleLease, error),
) *ClientLifecycleLease

NewClientLifecycleLease constructs a lifecycle lease. The release and clone callbacks are supplied by the owning session, which serializes both against client closing and session teardown.

func NewClientLifecycleLeaseWithDelegation

func NewClientLifecycleLeaseWithDelegation(
	kind ClientLeaseKind,
	ownerID string,
	release func(),
	clone func(ClientLeaseKind, string) (*ClientLifecycleLease, error),
	delegate func(string, string, ClientLeaseKind, string) (*ClientLifecycleLease, error),
	authority *ClientScopeAuthority,
) *ClientLifecycleLease

NewClientLifecycleLeaseWithDelegation constructs a lifecycle lease bound to one session-owned client record. delegate must atomically validate the source identity and ownership before cloning it; unlike Clone, Delegate never accepts an unbound or synthetic lease.

func (*ClientLifecycleLease) Held

func (lease *ClientLifecycleLease) Held() bool

func (*ClientLifecycleLease) Kind

func (lease *ClientLifecycleLease) Kind() ClientLeaseKind

func (*ClientLifecycleLease) OwnerID

func (lease *ClientLifecycleLease) OwnerID() string

func (*ClientLifecycleLease) Release

func (lease *ClientLifecycleLease) Release()

Release relinquishes the lease exactly once and is safe to call concurrently.

func (*ClientLifecycleLease) SessionClosed

func (lease *ClientLifecycleLease) SessionClosed() bool

SessionClosed reports whether the session that issued the lease has been removed. Work running under the lease can no longer rely on that session's services, attachables or cache state. Leases issued without a session authority never report closed.

type ClientMetadata added in v0.8.0

type ClientMetadata struct {
	// ClientID is unique to each client, randomly generated each time a client initializes.
	// It's also used as the *buildkit* session ID (as opposed to the dagger session ID), which
	// is created for each client.
	ClientID string `json:"client_id"`

	// ClientSecretToken is a secret token that is unique to every client.
	// Every request w/ that client ID must also include the same token.
	ClientSecretToken string `json:"client_secret_token"`

	// SessionID is the id of the dagger session that a client and any of its nested
	// module clients connect to
	SessionID string `json:"session_id"`

	// ClientHostname is the hostname of the client that made the request. It's
	// used to help identify clients in the logs more clearly; nothing functional.
	ClientHostname string `json:"client_hostname"`

	// ClientStableID is an ID that's persisted in a client's XDG state directory.
	// It's currently used to identify clients that are executing on the same host in order to
	// tell buildkit which filesync cache ref to re-use when syncing dirs+files to the engine.
	ClientStableID string `json:"client_stable_id"`

	// ClientVersion is the version string of the client that make the request.
	ClientVersion         string `json:"client_version"`
	ClientVersionDeclared bool   `json:"-"`

	// (Optional) Pipeline labels for e.g. vcs info like branch, commit, etc.
	Labels map[string]string `json:"labels"`

	// PrimaryTraceID and PrimarySpanID (hex) identify the client-side span
	// that represents this client's session, e.g. the CLI's command span. The
	// engine attributes session-level telemetry to it, such as the span-name
	// record published by Query.setSessionTitle. Only meaningful for a
	// session's main client.
	PrimaryTraceID string `json:"primary_trace_id,omitempty"`
	PrimarySpanID  string `json:"primary_span_id,omitempty"`

	// Interactive mode
	Interactive bool `json:"interactive"`

	// InteractiveCommand changes the command that is run in interactive mode.
	InteractiveCommand []string `json:"interactive_command"`

	// Import configuration for Buildkit's remote cache
	UpstreamCacheImportConfig []*controlapi.CacheOptionsEntry `json:"upstream_cache_import_config"`

	// Export configuration for Buildkit's remote cache
	UpstreamCacheExportConfig []*controlapi.CacheOptionsEntry `json:"upstream_cache_export_config"`

	// Dagger Cloud Org
	CloudOrg string `json:"cloud_org"`

	// CloudEngine reports that this client is connected to a Dagger Cloud Engine.
	CloudEngine bool `json:"cloud_engine,omitempty"`

	// Disable analytics
	DoNotTrack bool `json:"do_not_track"`

	// SSH auth socket path
	SSHAuthSocketPath string `json:"ssh_auth_socket_path"`

	// Modules permitted to access LLM APIs or "all" to allow every loaded module.
	AllowedLLMModules []string `json:"allowed_llm_modules"`

	// Disable lazy loading on module runtime.
	EagerRuntime bool `json:"eager_runtime"`

	// If set, the auth for cloud requests; used for PARC and scale-out
	CloudAuth *auth.Cloud `json:"cloud_auth,omitempty"`

	// If set, the Dagger Cloud API URL the client is configured with, so the
	// engine publishes the session's telemetry to the same endpoint.
	CloudURL string `json:"cloud_url,omitempty"`

	// Path to the Dagger Cloud credentials file on the client's filesystem.
	// The engine writes a refreshed OAuth token back to it.
	CredentialsPath string `json:"config_path,omitempty"`

	// CloudTelemetryPublisher, set to CloudTelemetryPublisherEngine by a main
	// client, asks the engine to publish the session's telemetry to Dagger
	// Cloud itself, with CloudAuth, instead of the client forwarding it.
	CloudTelemetryPublisher string `json:"cloud_telemetry_publisher,omitempty"`

	// If true, this client enables scaling checks out to cloud engines
	EnableCloudScaleOut bool `json:"enable_cloud_scale_out,omitempty"`

	// if set, this client is another engine scaling out to the current one, and the current
	// one has this ID. Should be included in OTEL span sttrs so we can correlate spans to engine.
	// TODO: This is a bit convoluted; it would be nicer if an engine could figure out its own ID
	// rather than being told what it is by the client connecting to it.
	CloudScaleOutEngineID string `json:"cloud_scale_out_engine_id,omitempty"`

	// ExtraModules specifies additional modules to load at connect time.
	// When Main is true, the module's main-object methods are proxied onto
	// the Query root in addition to its namespaced constructor.
	ExtraModules []ExtraModule `json:"extra_modules,omitempty"`

	// LoadWorkspaceModules opts this client into loading workspace modules.
	// When false, only the core API is exposed by default.
	LoadWorkspaceModules bool `json:"load_workspace_modules,omitempty"`

	// SingleQuery declares that this client will send at most one GraphQL query
	// request before disconnecting. The engine may use the query document to
	// optimize session initialization.
	SingleQuery bool `json:"single_query,omitempty"`

	// SkipWorkspaceModules is a legacy compatibility input. New clients should
	// use LoadWorkspaceModules instead.
	SkipWorkspaceModules bool `json:"skip_workspace_modules,omitempty"`

	// SuppressCompatWorkspaceWarning disables the user-facing warning emitted
	// when a legacy dagger.json is projected into a compat workspace.
	SuppressCompatWorkspaceWarning bool `json:"suppress_compat_workspace_warning,omitempty"`

	// Workspace explicitly declares the workspace binding for this client.
	// When unset, the engine applies default workspace binding behavior.
	Workspace *string `json:"workspace,omitempty"`

	// WorkspaceEnv explicitly selects the workspace environment overlay for
	// this client. When unset, no environment overlay is applied.
	WorkspaceEnv *string `json:"workspace_env,omitempty"`

	// UserConfigPath is the caller-host path to the user-level Dagger config
	// file (~/.config/dagger/config.toml). The engine reads it through the
	// caller host session to apply user-level workspace overrides. When unset,
	// no user-level config is consulted.
	UserConfigPath string `json:"user_config_path,omitempty"`

	// LLMConfig is this client's LLM routing configuration, assembled by the
	// client from its config file, environment and .env. Credentials in it
	// are secret URIs resolved against this client's session. See
	// hack/designs/llm-config-transport.md.
	LLMConfig *LLMConfig `json:"llm_config,omitempty"`

	// WorkspaceModuleScope hints at the workspace module this client's first
	// schema introspection targets: the leading CLI command token, unresolved
	// (it may name a module, a workspace-main-proxied function, or a typo). The
	// engine may use it to defer loading unrelated workspace modules for the
	// first request whose only full-schema demand is currentTypeDefs. An
	// unrecognized token falls back to the workspace main module when one is
	// configured, else to loading everything; deferred modules load on demand
	// from later requests.
	WorkspaceModuleScope string `json:"workspace_module_scope,omitempty"`

	// UseRecipeIDsByDefault asks id() to return recipe-form IDs unless the
	// request explicitly passes a recipe argument. This is engine-internal
	// nested-client state and must not be forwarded through client headers.
	UseRecipeIDsByDefault bool `json:"-"`

	// SDKEntrypoint marks the nested client that evaluates a module
	// entrypoint. Its cache volumes default to a namespace every module
	// entrypoint shares, so SDK build caches stay warm for every module.
	// Engine-internal: never read from client headers, and not inherited by
	// the processes the entrypoint starts.
	SDKEntrypoint bool `json:"-"`

	// Profile enables engine wall-clock profiling (wcprof) for the duration
	// of this client's work. Experimental; the recorded events are retrieved
	// via the engine debug endpoints.
	Profile bool `json:"profile,omitempty"`
}

func ClientMetadataFromContext added in v0.8.0

func ClientMetadataFromContext(ctx context.Context) (*ClientMetadata, error)

func ClientMetadataFromHTTPHeaders added in v0.11.8

func ClientMetadataFromHTTPHeaders(h http.Header) (*ClientMetadata, error)

func (ClientMetadata) AppendToHTTPHeaders added in v0.11.8

func (m ClientMetadata) AppendToHTTPHeaders(h http.Header) http.Header

type ClientScope

type ClientScope struct {
	// contains filtered or unexported fields
}

ClientScope is an immutable client identity and metadata snapshot paired with one held lifecycle lease. Copies are safe: they refer to the same idempotent lease, while Clone acquires independent ownership.

func ClientScopeFromContext

func ClientScopeFromContext(ctx context.Context) (ClientScope, bool)

func NewClientScope

func NewClientScope(metadata *ClientMetadata, lease *ClientLifecycleLease) (ClientScope, error)

NewClientScope snapshots metadata so later bootstrap mutations cannot change work that has already detached from the request that launched it.

func (ClientScope) CanDelegateTo

func (scope ClientScope) CanDelegateTo(authority *ClientScopeAuthority) bool

CanDelegateTo reports whether this scope belongs to the exact live session authority, not merely a record with equal session and client ID strings.

func (ClientScope) ClientID

func (scope ClientScope) ClientID() string

func (ClientScope) Clone

func (scope ClientScope) Clone(kind ClientLeaseKind, ownerID string) (ClientScope, error)

Clone acquires an independent lease from an already-held scope. The owning session validates the source lease under its lifecycle serialization point, so cloning remains valid while the client is closing but loses the race to a source release or session teardown.

func (ClientScope) Delegate

func (scope ClientScope) Delegate(kind ClientLeaseKind, ownerID string) (ClientScope, error)

Delegate clones a scope through its owning session's strict capability boundary. It rejects synthetic, stale, released, or identity-mismatched scopes instead of treating their IDs as authority.

func (ClientScope) Lease

func (scope ClientScope) Lease() *ClientLifecycleLease

func (ClientScope) Metadata

func (scope ClientScope) Metadata() (*ClientMetadata, error)

Metadata returns an independent copy of the scope's sealed metadata.

func (ClientScope) SessionID

func (scope ClientScope) SessionID() string

type ClientScopeAuthority

type ClientScopeAuthority struct {
	// contains filtered or unexported fields
}

ClientScopeAuthority is an opaque session identity used for strict capability delegation. It also records the session's removal, so work running under one of its scopes can tell that the session has gone away.

func NewClientScopeAuthority

func NewClientScopeAuthority() *ClientScopeAuthority

NewClientScopeAuthority creates an unforgeable-by-identity session token used to reject scopes retained from an older session record with reused string IDs.

func (*ClientScopeAuthority) Close

func (authority *ClientScopeAuthority) Close()

Close records that the owning session has been removed. The session calls it before tearing anything down, so any failure teardown causes is observed after Closed reports true.

func (*ClientScopeAuthority) Closed

func (authority *ClientScopeAuthority) Closed() bool

Closed reports whether the owning session has been removed.

type ExtraModule added in v0.20.4

type ExtraModule struct {
	Ref  string `json:"ref"`
	Name string `json:"name,omitempty"`
	Main bool   `json:"main,omitempty"`
	// Entrypoint is the deprecated source-level alias for Main.
	Entrypoint bool `json:"-"`
}

ExtraModule specifies a module to load at connect time in addition to (or instead of) workspace modules.

func (ExtraModule) IsMain

func (m ExtraModule) IsMain() bool

func (ExtraModule) MarshalJSON

func (m ExtraModule) MarshalJSON() ([]byte, error)

func (*ExtraModule) UnmarshalJSON

func (m *ExtraModule) UnmarshalJSON(data []byte) error

type LLMConfig

type LLMConfig struct {
	// DefaultProvider and DefaultModel are the configured default route, as
	// chosen by `dagger llm setup` / `dagger llm set-default`. Either may be
	// empty, in which case the engine infers a default from the configured
	// providers.
	DefaultProvider string `json:"default_provider,omitempty"`
	DefaultModel    string `json:"default_model,omitempty"`

	// Providers is keyed by the engine's provider name: anthropic, openai,
	// openai-codex, google, local.
	Providers map[string]*LLMProviderConfig `json:"providers,omitempty"`
}

LLMConfig is a client's LLM routing configuration, assembled client-side (config file, environment, .env) and sent to the engine in ClientMetadata. See hack/designs/llm-config-transport.md.

Routing fields are plain values. Credential fields carry secret URIs that the engine resolves against the sending client's session, on demand, for the provider it actually routes — never values.

func (*LLMConfig) Clone

func (c *LLMConfig) Clone() *LLMConfig

Clone returns a deep copy.

func (*LLMConfig) IsEmpty

func (c *LLMConfig) IsEmpty() bool

IsEmpty reports whether the config carries nothing at all.

func (*LLMConfig) Provider

func (c *LLMConfig) Provider(name string) *LLMProviderConfig

Provider returns the named provider's config, allocating it if absent.

type LLMProviderConfig

type LLMProviderConfig struct {
	// APIKey is a secret URI for the provider's API key.
	APIKey string `json:"api_key,omitempty"`
	// AuthToken is a secret URI for a subscription OAuth bearer token
	// (Anthropic Claude Code, OpenAI Codex). For Anthropic it is an
	// alternative to APIKey; a config that supplies one must not carry the
	// other, see Merge.
	AuthToken string `json:"auth_token,omitempty"`
	// AuthTokenExpiresAt is a secret URI resolving to AuthToken's true expiry
	// as RFC 3339 UTC, when known. The engine reads it right after the token
	// within one resolution, so a resolver that rotates the token on read
	// must update the expiry in the same step.
	AuthTokenExpiresAt string `json:"auth_token_expires_at,omitempty"`

	BaseURL         string `json:"base_url,omitempty"`
	Model           string `json:"model,omitempty"`
	SmallModel      string `json:"small_model,omitempty"`
	ReasoningEffort string `json:"reasoning_effort,omitempty"`

	// APICompat selects the wire protocol of a local endpoint: "openai" or
	// "anthropic".
	APICompat string `json:"api_compat,omitempty"`

	// AzureVersion routes an OpenAI provider through Azure OpenAI with the
	// given API version.
	AzureVersion string `json:"azure_version,omitempty"`
	// DisableStreaming turns off streaming responses for an OpenAI provider.
	// A pointer, so an explicit false survives the trip and can override a
	// true layered in from another client; nil means unset.
	DisableStreaming *bool `json:"disable_streaming,omitempty"`

	// ClaudeCodeVersion is the Claude Code release to present when
	// authenticating Anthropic with a subscription OAuth token, as a bare
	// X.Y.Z.
	ClaudeCodeVersion string `json:"claude_code_version,omitempty"`
}

LLMProviderConfig configures one provider.

func (*LLMProviderConfig) HasCredential

func (p *LLMProviderConfig) HasCredential() bool

HasCredential reports whether the provider has any credential configured.

func (*LLMProviderConfig) IsEmpty

func (p *LLMProviderConfig) IsEmpty() bool

IsEmpty reports whether no field is set.

func (*LLMProviderConfig) Merge

func (p *LLMProviderConfig) Merge(src *LLMProviderConfig)

Merge overlays src onto p: only fields src sets overwrite p's, so a config can be layered (the session's main client as the base with the calling client's own values on top).

The API key and the OAuth token are alternative credentials for the same provider. When src supplies one but not the other, the supplied credential wins outright: the other is cleared so a value layered in earlier (the host's OAuth login when a nested client sets an explicit API key) can't shadow it at request time.

func (*LLMProviderConfig) StreamingDisabled

func (p *LLMProviderConfig) StreamingDisabled() bool

StreamingDisabled reports whether DisableStreaming is set to true.

type LocalExportOpts added in v0.8.0

type LocalExportOpts struct {
	Path               string      `json:"path"`
	IsFileStream       bool        `json:"is_file_stream"`
	FileOriginalName   string      `json:"file_original_name"`
	AllowParentDirPath bool        `json:"allow_parent_dir_path"`
	FileMode           os.FileMode `json:"file_mode"`
	// whether to just merge in contents of a directory to the target on the host
	// or to replace the target entirely such that it matches the source directory,
	// which includes deleting any files that are not in the source directory
	Merge       bool
	RemovePaths []string `json:"remove_paths"`
	// ReplaceAtomically, for a file stream, writes a temporary file beside
	// the destination and renames it into place, so a concurrent reader or
	// writer of the file never sees a partial or interleaved one.
	ReplaceAtomically bool `json:"replace_atomically,omitempty"`
}

func LocalExportOptsFromContext added in v0.8.0

func LocalExportOptsFromContext(ctx context.Context) (*LocalExportOpts, error)

func (LocalExportOpts) AppendToOutgoingContext added in v0.8.0

func (o LocalExportOpts) AppendToOutgoingContext(ctx context.Context) context.Context

func (*LocalExportOpts) FromGRPCMD added in v0.11.2

func (o *LocalExportOpts) FromGRPCMD(md metadata.MD) error

func (LocalExportOpts) ToGRPCMD added in v0.8.0

func (o LocalExportOpts) ToGRPCMD() metadata.MD

type LocalImportOpts added in v0.8.0

type LocalImportOpts struct {
	Path               string            `json:"path"`
	UseGitIgnore       bool              `json:"use_gitignore"`
	GitIgnoreOverrides map[string]string `json:"gitignore_overrides,omitempty"`
	IncludePatterns    []string          `json:"include_patterns"`
	ExcludePatterns    []string          `json:"exclude_patterns"`
	FollowPaths        []string          `json:"follow_paths"`
	ReadSingleFileOnly bool              `json:"read_single_file_only"`
	MaxFileSize        int64             `json:"max_file_size"`
	StatPathOnly       bool              `json:"stat_path_only"`
	StatReturnAbsPath  bool              `json:"stat_return_abs_path"`
	StatResolvePath    bool              `json:"stat_resolve_path"`
	GetAbsPathOnly     bool              `json:"get_abs_path_only"`
	GlobPattern        string            `json:"glob_pattern"`
	SearchOpts         *LocalSearchOpts  `json:"search_opts,omitempty"`
}

func LocalImportOptsFromContext added in v0.8.0

func LocalImportOptsFromContext(ctx context.Context) (*LocalImportOpts, error)

func (LocalImportOpts) AppendToOutgoingContext added in v0.8.0

func (o LocalImportOpts) AppendToOutgoingContext(ctx context.Context) context.Context

func (*LocalImportOpts) FromGRPCMD added in v0.11.2

func (o *LocalImportOpts) FromGRPCMD(md metadata.MD) error

func (LocalImportOpts) ToGRPCMD added in v0.8.0

func (o LocalImportOpts) ToGRPCMD() metadata.MD

type LocalSearchOpts

type LocalSearchOpts struct {
	Pattern     string   `json:"pattern"`
	Literal     bool     `json:"literal,omitempty"`
	Multiline   bool     `json:"multiline,omitempty"`
	Dotall      bool     `json:"dotall,omitempty"`
	Insensitive bool     `json:"insensitive,omitempty"`
	SkipIgnored bool     `json:"skip_ignored,omitempty"`
	SkipHidden  bool     `json:"skip_hidden,omitempty"`
	FilesOnly   bool     `json:"files_only,omitempty"`
	Limit       *int     `json:"limit,omitempty"`
	Paths       []string `json:"paths,omitempty"`
	Globs       []string `json:"globs,omitempty"`
}

LocalSearchOpts configures a client-side search (ripgrep/grep).

type LocalSearchResult

type LocalSearchResult struct {
	FilePath       string                `json:"file_path"`
	LineNumber     int                   `json:"line_number"`
	AbsoluteOffset int                   `json:"absolute_offset"`
	MatchedLines   string                `json:"matched_lines"`
	Submatches     []LocalSearchSubmatch `json:"submatches,omitempty"`
}

LocalSearchResult is a search match returned from a client-side search.

type LocalSearchSubmatch

type LocalSearchSubmatch struct {
	Text  string `json:"text"`
	Start int    `json:"start"`
	End   int    `json:"end"`
}

LocalSearchSubmatch is a sub-match within a search result.

type NestedClientTransport

type NestedClientTransport struct {
	// contains filtered or unexported fields
}

func NewNestedClientTransport

func NewNestedClientTransport(close func()) *NestedClientTransport

NewNestedClientTransport constructs the opaque ownership handle returned by nested transport registration. Callers can only close or inspect it; the registering server keeps the associated client identity private.

func (*NestedClientTransport) Close

func (transport *NestedClientTransport) Close()

Close first marks nested reachability closed so proxy-side admission stops monotonically, then serializes transport ownership release with the server. It is safe to call concurrently and is also used by /shutdown. A request that already won the server's acceptance serialization may finish; every later admission observes either the closed handle or the closed record.

func (*NestedClientTransport) Closed

func (transport *NestedClientTransport) Closed() bool

Directories

Path Synopsis
Package agentcontrol defines the authoritative, revisioned agent telemetry projection shared by producers, live consumers and archive verification.
Package agentcontrol defines the authoritative, revisioned agent telemetry projection shared by producers, live consumers and archive verification.
Package cachevolumedir keeps cache volumes as plain directories under one directory, apart from the engine's snapshots, so that the directory can be handed from one engine to the next.
Package cachevolumedir keeps cache volumes as plain directories under one directory, apart from the engine's snapshots, so that the directory can be handed from one engine to the next.
distconsts module
Package ebpf provides eBPF-based tracing utilities for the Dagger engine.
Package ebpf provides eBPF-based tracing utilities for the Dagger engine.
filetracer
Package filetracer provides an eBPF-based tracer for file operations performed by the dagger-engine process.
Package filetracer provides an eBPF-based tracer for file operations performed by the dagger-engine process.
nettracer
Package nettracer accounts for engine, subprocess and executor workload traffic at cgroup socket-buffer hooks.
Package nettracer accounts for engine, subprocess and executor workload traffic at cgroup socket-buffer hooks.
ovltracer
Package ovltracer provides an eBPF-based tracer for catching overlayfs "in-use" errors (EBUSY).
Package ovltracer provides an eBPF-based tracer for catching overlayfs "in-use" errors (EBUSY).
Package naming parses identifiers written in any casing into words, and formats those words in any other casing.
Package naming parses identifiers written in any casing into words, and formats those words in any other casing.
Package remotecache connects an engine to the remote cache service.
Package remotecache connects an engine to the remote cache service.
protocol
Package protocol defines the messages an engine and the remote cache service exchange over one WebSocket.
Package protocol defines the messages an engine and the remote cache service exchange over one WebSocket.
session
git
h2c
testutil
Package testutil builds real local snapshot and content stores for transfer tests.
Package testutil builds real local snapshot and content stores for transfer tests.
sources
cgroupmetrics
Package cgroupmetrics reports resource use for the cgroup that contains the Dagger engine process.
Package cgroupmetrics reports resource use for the cgroup that contains the Dagger engine process.
Package vcs exposes functions for resolving import paths and using version control systems, which can be used to implement behavior similar to the standard "go get" command.
Package vcs exposes functions for resolving import paths and using version control systems, which can be used to implement behavior similar to the standard "go get" command.
Package wcprof implements cheap wall-clock profiling for the engine.
Package wcprof implements cheap wall-clock profiling for the engine.
contract
Package contract decodes the wcprof reporting contract: how a client or a program inside an exec reports its own work (tasks and task groups), what each task waited for (dependency waits), its limited resources and the acquisitions of them, and its completeness, as OTel spans and links with the wcprof.* attributes of engine/telemetryattrs.
Package contract decodes the wcprof reporting contract: how a client or a program inside an exec reports its own work (tasks and task groups), what each task waited for (dependency waits), its limited resources and the acquisitions of them, and its completeness, as OTel spans and links with the wcprof.* attributes of engine/telemetryattrs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL