Skip to content
5 min read · 975 words

@nhtio/adk/batteries/skills

Stateful skill discovery, activation, and deactivation for ADK agents.

Interfaces

InterfaceDescription
CatalogEntryA winning catalog candidate or a losing candidate retained for provenance.
DiscoveredSkillDiscovery result. Carries the ROUTING METADATA — name and description — because that is what list_skills shows the model and what it chooses on; requiring descriptor() to obtain it would mean loading every skill's module just to list the catalog.
ForgeSkillToolsOptionsDeployment-time controls for the lifecycle tools forged by forgeSkillTools.
LoadResultImmediate lifecycle outcome, including the objects registered in this dispatch.
ProjectedSkillThe per-context projection of one initialized skill.
RefreshResultResult of catalog refresh, including versions that now differ from loaded state.
SkillArtifactRegistryResolved artifact kinds plus the consumer-owned skill/tool binding table.
SkillDescriptorLive, source-owned definition resolved when a catalog entry is loaded.
SkillIsolatedToolTier-2 tool whose source is evaluated inside the configured guest runtime.
SkillIsolationConfigTier-2 guest capabilities and termination/timeout controls.
SkillManagerStateful skill lifecycle; construct one manager per conversation or session.
SkillManagerConfigInputs that determine discovery, projection, and the explicit containment exceptions.
SkillMiddlewareOptionsOptions for the standalone skills middleware factories.
SkillMiddlewareSetThe four pipeline hooks needed to hydrate, reconcile, observe, and strip skill state.
SkillScriptConfigTier-3 execution controls, workspace, policy, and output/time ceilings.
SkillScriptParamOne validated value in the fixed argv contract presented to a script.
SkillScriptSpecA model-selectable script bundled with a skill and invoked with declared arguments only.
SkillSourceRuntime-neutral source seam for discovery, metadata, body bytes, and bundled files.
SkillWorkspaceSkill-scoped materialization service used by tier-3 scripts.

Type Aliases

Type AliasDescription
SkillLoadChannelControls whether a loaded body is represented by a handle or rendered inline per dispatch.
SkillRefA discovered skill plus manager-assigned provenance. This is what the battery passes around.
SkillSourceResolverA source instance or lazy/default export resolver used during manager construction.
SpooledKindResolverAn artifact constructor or lazy/default-export resolver for a named skill result kind.

Variables

VariableDescription
E_INVALID_SKILLS_CONFIGFatal construction error for invalid or unsafe-to-resolve manager configuration.
E_SKILL_ALREADY_LOADEDRaised when load would initialize a skill that is already initialized.
E_SKILL_ARTIFACT_UNAVAILABLERaised when the selected artifact kind was not registered.
E_SKILL_MANIFEST_INVALIDRaised when source metadata or a descriptor violates the identity/version contract.
E_SKILL_NOT_FOUNDRaised when load, refresh, or unload names no winning catalog entry.
E_SKILL_NOT_LOADEDRaised when unload or a loaded-only operation targets an uninitialized skill.
E_SKILL_SCRIPT_DENIEDExplicit 403 refusal by the script policy; this is distinct from a failed gate.
E_SKILL_SCRIPT_FAILEDRaised when a skill script completes with a nonzero exit code and the deployment leaves SkillScriptConfig.failOnNonzeroExit at its default (true). The message carries the script name, the exit code, and the retrievable id of the spooled output so the failure is still inspectable. A deployment whose scripts use exit codes as ordinary signalling sets failOnNonzeroExit: false and receives the acknowledgement string instead.
E_SKILL_SCRIPT_GATE_UNAVAILABLE503 when the script gate fails for any reason other than an explicit denial; never misroutes an engine failure as 403.
E_SKILL_SCRIPT_POLICY_WIDENEDRaised when script policy derivation would widen permissions beyond the declared boundary.
E_SKILL_SCRIPT_TIMEOUTRaised when a script exceeds its configured execution deadline.
E_SKILL_SOURCE_PATH_REJECTEDRaised when a requested bundled path is unsafe or outside the source namespace.
E_SKILL_TOOL_BAD_RESPONSERaised when a skill tool returns a value that fails response validation.
E_SKILL_TOOL_COLLISIONRaised when a skill tool name collides with another registered tool.
E_SKILL_TOOL_DUPLICATERaised when one skill declares the same tool name more than once.
E_SKILL_TOOL_FAILEDRaised when a skill tool handler fails during execution.
E_SKILL_WORKSPACE_FAILEDRaised when materialization or disposal of a skill workspace fails.

Functions

FunctionDescription
createSkillArtifactRegistryResolve all optional artifact classes eagerly. The built-in raw kind is always available; optional artifact batteries are intentionally not imported here.
createSkillManagerCreate a skills manager. Construct one manager per conversation/session, alongside its runner; share source objects when discovery caching is desired, but never share loaded manager state.
createSkillMiddlewareSetBuild the stable four-middleware skills integration surface.
forgeSkillToolsForge the five stateful lifecycle tools for one skill manager.
implementsSkillSourceDuck-guard for the synchronous portion of a source contract. discover() returns an async iterable and cannot be duck-checked beyond "is a function", so a value passing this guard may still violate the protocol. runSkillSourceConformance, from @nhtio/adk/batteries/skills/conformance, is the real protocol check.
parseSkillMdParse an agentskills.io-shaped SKILL.md for source authors. The manager's load path never calls this helper: sources own descriptor and body authority. Malformed frontmatter degrades to an empty object when it is not a delimited YAML block; malformed YAML is a manifest error.
renderErrorRender skill runtime errors for the model; configuration errors remain fatal.
skillsDispatchInputMiddlewareCreate the dispatch-input middleware that reconciles skill projections.
skillsDispatchOutputMiddlewareCreate the dispatch-output middleware that observes and reconciles skill state.
skillsTurnInputMiddlewareCreate the turn-input middleware that refreshes and projects loaded skills.
skillsTurnOutputMiddlewareCreate the turn-output middleware that removes this set's skill projections.