Client SDK¶
The Nydus class is the main entry point for
using PyNydus programmatically. It mirrors CLI behavior, but Typer entry points
call the same engines directly rather than delegating to this class.
Example¶
from pathlib import Path
from pynydus import Nydus
ny = Nydus()
# Spawn
egg = ny.spawn() # reads ./Nydusfile
egg = ny.spawn(nydusfile="other/Nydusfile")
# Save / load
path = ny.save(egg, Path("agent.egg"))
path = ny.save(egg, Path("agent.egg"), sign=True)
# Load and inspect (includes raw/ and spawn log)
egg = ny.load(Path("agent.egg"))
egg.skills.skills # list of AgentSkill
egg.mcp.configs # dict of MCP server configs
egg.memory.memory # list of MemoryRecord
egg.inspect_secrets()
report = ny.validate(egg)
diff = ny.diff(egg_a, egg_b)
# Hatch (rebuild mode, the default)
result = ny.hatch(
egg,
target="letta",
output_dir=Path("out"),
secrets="agent.env",
)
print(result.output_dir, result.files_created, result.warnings)
Notes:
spawn()fillsegg.raw_artifactsandegg.spawn_log.save()writes them to the archive by default.hatch()defaults to rebuild mode (regenerate files from structured Egg modules). Setmode="passthrough"to replay the egg’s redactedraw/snapshot verbatim. Passthrough requiresegg.raw_artifactsto be non-empty, which it is afterspawn()orload()with the defaultinclude_raw=True.If you loaded with
load(..., include_raw=False),raw_artifactsis empty. Either reload withinclude_raw=Trueor passraw_artifacts=frompynydus.engine.packager.read_raw_artifacts(path).Configure LLM and registry via environment variables (
NYDUS_LLM_TYPE,NYDUS_LLM_API_KEY,NYDUS_REGISTRY_URL, etc.). See Configuration.Registry
pull()defaultsversionto"latest"if omitted. Thenydus pullCLI still requires--version. See Nest Registry.
Nydus¶
- class Nydus¶
Main SDK entry point (mirrors CLI behavior).
Initialization
Load LLM and registry settings from environment variables.
Set
NYDUS_LLM_TYPEandNYDUS_LLM_API_KEYfor refinement. SetNYDUS_REGISTRY_URL(and optionallyNYDUS_REGISTRY_AUTHOR) for registry operations. See :mod:pynydus.config.- spawn(nydusfile: pathlib.Path | str | None = None) pynydus.api.schemas.Egg¶
Spawn an Egg from a Nydusfile.
Args: nydusfile: Path to a Nydusfile. If
None, resolves one in the current working directory.Returns:
Eggwithraw_artifactsandspawn_logpopulated from the pipeline. Use :meth:saveto write a.eggfile.
- hatch(egg: pynydus.api.schemas.Egg, *, target: pynydus.common.enums.AgentType, output_dir: pathlib.Path | None = None, secrets: str | pathlib.Path | None = None, mode: pynydus.common.enums.HatchMode = HatchMode.REBUILD, spawn_log: list[dict] | None = None, raw_artifacts: dict[str, str] | None = None) pynydus.api.schemas.HatchResult¶
Hatch an Egg into a target runtime.
Args: egg: Loaded Egg to render. target: Destination platform. output_dir: Directory for output files (connector default if omitted). secrets: Path to
.envfor placeholder substitution. mode:rebuild(structured modules) orpassthrough(raw snapshot). spawn_log: Spawn pipeline log for the hatch LLM. defaults toegg.spawn_log. raw_artifacts: Redactedraw/snapshot. defaults toegg.raw_artifacts. required forpassthroughwhen empty on the egg.Returns:
HatchResultwith paths and written files.
- save(egg: pynydus.api.schemas.Egg, output: pathlib.Path, *, raw_artifacts: dict[str, str] | None = None, spawn_log: list[dict] | None = None, nydusfile_text: str | None = None, sign: bool = False) pathlib.Path¶
Write an Egg to a
.eggarchive.Args: egg: The Egg to save. output: Destination file path (gets
.eggsuffix). raw_artifacts: Overrideegg.raw_artifactsfor the archive. spawn_log: Overrideegg.spawn_logfor the archive. nydusfile_text: Embed Nydusfile text in the archive. sign: IfTrue, sign with the user’s Ed25519 private key.Returns: Path to the written
.eggfile.
- load(egg_path: pathlib.Path, *, include_raw: bool = True) pynydus.api.schemas.Egg¶
Load a
.eggarchive into a fully populated :class:~pynydus.api.schemas.Egg.Args: egg_path: Path to the
.eggfile. include_raw: IfFalse,raw/is not read intoegg.raw_artifacts(empty dict). Use for large eggs when only structured modules are needed. for passthrough hatch, load withinclude_raw=Trueor passread_raw_artifacts(egg_path)to :meth:hatch.Returns: Fully populated Egg with spawn_log, raw_artifacts, and nydusfile.
- validate(egg: pynydus.api.schemas.Egg) pynydus.api.schemas.ValidationReport¶
Validate structural integrity of an Egg.
Args: egg: Egg to check.
Returns: Report with errors and warnings.
- diff(egg_a: pynydus.api.schemas.Egg, egg_b: pynydus.api.schemas.Egg) pynydus.api.schemas.DiffReport¶
Compare two Eggs.
Args: egg_a: First Egg. egg_b: Second Egg.
Returns: Structured diff report.
- push(egg_path: pathlib.Path, *, name: str, version: str | None = None, author: str | None = None) dict¶
Push a packed
.eggto the Nest registry.Args: egg_path: Packed archive path. name: Registry name (e.g.
user/my-agent). version: Semver. ifNone, taken fromegg.manifest.egg_version. author: Optional author override.Returns: Server JSON response body.
- pull(name: str, *, version: str = 'latest', output: pathlib.Path = Path('pulled.egg')) pathlib.Path¶
Pull an Egg from the Nest registry.
Args: name: Registry name (e.g.
user/my-agent). version: Semver tag. defaultlatest. output: Destination path for the downloaded.egg.Returns: Path written on disk.
- list_versions(name: str) list[dict]¶
List published versions for name.
Args: name: Registry-qualified egg name.
Returns: List of version metadata dicts from the server.
- _get_registry_client()¶
Build a
NestClientfromNYDUS_REGISTRY_URL.
See the full auto-generated reference with all method signatures:
pynydus.client.client.Nydus