Documentation
¶
Overview ¶
Package domain provides E2B-compatible conversion utilities. It maps AgentBox native API models directly to E2B generated types.
Index ¶
- Constants
- func BuildE2BEndpointURL(scheme, gatewayDomain, sandboxID string, port int32) string
- func EnvdVersionForEnv(env *agentsv1alpha1.SandboxEnv) string
- func EnvdVersionForPool(pool *agentsv1alpha1.SandboxPool) string
- func ExtractCPUFromQuantity(q resource.Quantity) int32
- func ExtractMemoryMBFromQuantity(q resource.Quantity) int64
- func IsLive(sb *gen.Sandbox) bool
- func IsLiveStatus(status string) bool
- func IsValidSandboxID(id string) bool
- func SandboxStateFromStatus(status string) string
- func ToE2BListedSandbox(sb *gen.Sandbox, pool *agentsv1alpha1.SandboxPool) e2bgen.ListedSandbox
- func ToE2BSandbox(sb *gen.Sandbox, pool *agentsv1alpha1.SandboxPool, gatewayDomain string) e2bgen.Sandbox
- func ToE2BSandboxDetail(sb *gen.Sandbox, pool *agentsv1alpha1.SandboxPool, gatewayDomain string) e2bgen.SandboxDetail
- func ToE2BTemplate(pool *agentsv1alpha1.SandboxPool) e2bgen.Template
Constants ¶
const ( // DefaultEnvdVersion is what an E2B response reports when the version of // the sandbox's own envd cannot be derived from its template. // // It is the version this platform builds and ships — see // docs/e2b/envd-upgrade-runbook.md, whose "当前状态" table is the record and // which this constant is checked against by hack/check-envd-version.sh // before every develop push. That check is the whole reason the value is // safe to hold: a fallback that drifts from the images is a claim the SDK // acts on, and the SDK's version gates decide how it talks to envd (the // `user` parameter, octet-stream uploads, file metadata, recursive watch) // as well as whether `get_metrics()` is allowed at all. // // (The floor the SDK accepts at create time is 0.1.0, and 0.1.0 is what a // response used to say. It is deliberately not the fallback: claiming the // floor is what made `get_metrics()` answer "You need to update the // template to use the new SDK" on images whose envd was 0.9.0.) DefaultEnvdVersion = "0.9.0" // EnvdVersionAnnotation overrides the derived version, for a template whose // envd does not come from a tagged image. EnvdVersionAnnotation = "agentbox.navix.sh/envd-version" )
Variables ¶
This section is empty.
Functions ¶
func BuildE2BEndpointURL ¶
BuildE2BEndpointURL builds the E2B-style connection URL for a sandbox. Uses the private path protocol: scheme://domain/agentbox/<sandboxID>/<port>
func EnvdVersionForEnv ¶ added in v0.0.11
func EnvdVersionForEnv(env *agentsv1alpha1.SandboxEnv) string
EnvdVersionForEnv reports the version for the Envs a template listing shows. Members of one Env are all rendered from the same SandboxTemplate, so the first member that carries a snapshot answers for the Env.
func EnvdVersionForPool ¶ added in v0.0.11
func EnvdVersionForPool(pool *agentsv1alpha1.SandboxPool) string
EnvdVersionForPool reports the version of the envd the sandboxes from this pool are running.
The platform does not choose envd — the TEMPLATE does, by copying the binary into the pod from an init container (`/mnt/agentbox/envd`), and that container's image tag is where the version already lives. Reading it there means a bump moves both things at once: the image the init container copies from, and the version every E2B response reports. Nothing else has to be remembered, which is the property that makes this stay true.
The tag is a TAG, though, not a version (`0.9.0-2` names a build of 0.9.0), so what is reported is the version part of it. The SDK parses this string with PEP 440 and raises on what it cannot parse — in `connect()` and in the list path, not just in the call that wanted it — so a tag that is not a version at all falls back to the known-good floor instead of being passed through.
func ExtractCPUFromQuantity ¶
ExtractCPUFromQuantity converts a resource.Quantity to an int32 CPU count.
func ExtractMemoryMBFromQuantity ¶
ExtractMemoryMBFromQuantity converts a resource.Quantity to int64 MB.
func IsLive ¶ added in v0.0.10
IsLive reports whether a sandbox record describes a live sandbox.
Checks the termination timestamp as well as the status, because they are set on different paths: a historical record carries terminatedAt, while a status alone can lag behind a release that has already happened.
func IsLiveStatus ¶ added in v0.0.10
IsLiveStatus reports whether a native sandbox status describes a sandbox that still exists to be acted on.
The native API keeps terminated sandboxes queryable, merging historical records into its listing so a finished run stays inspectable. The E2B surface has no way to express "finished": its state enum holds only `running` and `paused`. So the compatibility layer has to drop what it cannot describe rather than mislabel it — upstream E2B likewise does not list a killed sandbox. Callers that want the history should read the native API, which is where it lives.
func IsValidSandboxID ¶
IsValidSandboxID returns true if the sandbox ID matches the expected format.
func SandboxStateFromStatus ¶
SandboxStateFromStatus maps AgentBox sandbox status to E2B state. E2B only has "running" and "paused" states.
func ToE2BListedSandbox ¶
func ToE2BListedSandbox(sb *gen.Sandbox, pool *agentsv1alpha1.SandboxPool) e2bgen.ListedSandbox
ToE2BListedSandbox converts a native gen.Sandbox directly to an e2bgen.ListedSandbox.
func ToE2BSandbox ¶
func ToE2BSandbox(sb *gen.Sandbox, pool *agentsv1alpha1.SandboxPool, gatewayDomain string) e2bgen.Sandbox
ToE2BSandbox converts a native gen.Sandbox + SandboxPool directly to an e2bgen.Sandbox. gatewayDomain is the gateway domain name used to build connection URLs.
func ToE2BSandboxDetail ¶
func ToE2BSandboxDetail(sb *gen.Sandbox, pool *agentsv1alpha1.SandboxPool, gatewayDomain string) e2bgen.SandboxDetail
ToE2BSandboxDetail converts a native gen.Sandbox + SandboxPool to an e2bgen.SandboxDetail. gatewayDomain is the gateway domain name used to build connection URLs.
func ToE2BTemplate ¶
func ToE2BTemplate(pool *agentsv1alpha1.SandboxPool) e2bgen.Template
ToE2BTemplate converts an AgentBox SandboxPool directly to an e2bgen.Template.
Types ¶
This section is empty.