Skip to content
1 min read · 133 words

Type Alias: ArtifactConstructorResolver<A>

ts
type ArtifactConstructorResolver<A> = () => SpooledArtifactConstructor<A>;

Defined in: lib/classes/tool.ts:32

A zero-arg function that returns the @nhtio/adk!SpooledArtifactConstructor the consumer should use when wrapping this tool's serialised output into a ToolCall.results field.

Type Parameters

Type ParameterDefault type
A extends SpooledArtifactSpooledArtifact

Returns

SpooledArtifactConstructor<A>

Remarks

Why a resolver (and not the constructor itself)? tool.ts participates in a module-load cycle with spooled_artifact.ts and artifact_tool.ts (ArtifactTool extends Tool closes the loop). Any eager value-level reference to SpooledArtifact in tool.ts would crash the cycle with a TDZ error. A resolver lets tool.ts validate "is a function" at module-load time and defer the actual constructor check to validate-time (which always runs after every module body has executed). Wrap-sites invoke tool.artifactConstructor?.() ?? SpooledArtifact to obtain the final constructor.