Skip to content
1 min read · 158 words

Function: resolveArtifactById()

ts
function resolveArtifactById(
  ctx: {
    turnRetrievables: Iterable<{
      content: unknown;
      id: string;
      inline: boolean;
    }>;
    turnToolCalls: Iterable<{
      fromArtifactTool?: boolean;
      id: string;
      results: unknown;
    }>;
  },
  id: string,
  requires: SpooledArtifactConstructor,
):
  | {
      artifact: SpooledArtifact;
      source: "toolCall" | "retrievable";
    }
  | undefined;

Defined in: src/lib/classes/spooled_artifact.ts:113

Resolve an artifact by ID from the current turn's tool calls or retrievables, with type narrowing.

Parameters

ParameterTypeDescription
ctx{ turnRetrievables: Iterable<{ content: unknown; id: string; inline: boolean; }>; turnToolCalls: Iterable<{ fromArtifactTool?: boolean; id: string; results: unknown; }>; }The dispatch context containing tool calls and retrievables.
ctx.turnRetrievablesIterable<{ content: unknown; id: string; inline: boolean; }>-
ctx.turnToolCallsIterable<{ fromArtifactTool?: boolean; id: string; results: unknown; }>-
idstringThe artifact ID to resolve.
requiresSpooledArtifactConstructorThe artifact class constructor to narrow by; only artifacts of this type are returned.

Returns

| { artifact: SpooledArtifact; source: "toolCall" | "retrievable"; } | undefined

The resolved artifact and its source (tool call or retrievable), or undefined if not found.