{
  "name": "@forge-sdk/generate",
  "language": "typescript",
  "version": "0.1.0",
  "description": "Text generation, streaming, structured output, and multi-step generation for the Forge SDK.",
  "manifest": "forge-ts/packages/forge-generate/package.json",
  "manifestSha256": "9cd066916f0a3a2d7dea195eee72617ce0181c5d2fa61662a5564e0d8a1c1d65",
  "status": "source-reference",
  "registryPublicationVerified": false,
  "route": "/libraries/typescript/generate",
  "features": {},
  "files": [
    {
      "path": "forge-ts/packages/forge-generate/src/error.ts",
      "sha256": "0e35d8572112c85b8729523f20241e521acf055bdda35f706e2e09eea5a01b56",
      "artifactSha256": "ddebed0e4e6472ddc47551f55c4b57558cc9b43a29345c88b17a252e8696b451",
      "url": "/reference/source/forge-ts/packages/forge-generate/src/error.ts.txt",
      "declarations": [
        {
          "name": "export const ForgeGenerateErrorCode = {",
          "line": 16,
          "signature": "export const ForgeGenerateErrorCode /* type inferred in source */;",
          "documentation": "Error types for the forge-generate package.\n\nAll errors are typed and actionable. Every variant includes enough context\nfor the developer to diagnose the issue without reading source code.\n\nANVIL Spec section 14.2 -- Error Handling requires all errors are typed,\nloggable, and carry enough context for audit trail entries.\nError codes for generation operations."
        },
        {
          "name": "ForgeGenerateErrorCodeType",
          "line": 32,
          "signature": "export type ForgeGenerateErrorCodeType =\n  (typeof ForgeGenerateErrorCode)[keyof typeof ForgeGenerateErrorCode];",
          "documentation": "A forge-generate error code value."
        },
        {
          "name": "ForgeGenerateError",
          "line": 48,
          "signature": "export class ForgeGenerateError extends Error {\n  readonly code: ForgeGenerateErrorCodeType;\n  readonly model?: string;\n  static modelError(model: string, reason: string): ForgeGenerateError;\n  static schemaViolation(model: string, path: string, reason: string): ForgeGenerateError;\n  static stepLimitReached(\n    stepsCompleted: number,\n    limit: number,\n    totalTokens: number\n  ): ForgeGenerateError;\n  static streamInterrupted(\n    model: string,\n    chunksReceived: number,\n    reason: string\n  ): ForgeGenerateError;\n  static noResponse(model: string, messagesCount: number): ForgeGenerateError;\n  static deserializationFailed(\n    model: string,\n    targetType: string,\n    reason: string\n  ): ForgeGenerateError;\n}",
          "documentation": "Error type for generation operations.\n\nCovers model call failures, schema violations, streaming interruptions,\nstep limit exhaustion, and missing responses."
        }
      ]
    },
    {
      "path": "forge-ts/packages/forge-generate/src/index.ts",
      "sha256": "58151f022e47d033e7472eec481ff52dbfd20fc0330643654c497d3a04cf9eb7",
      "artifactSha256": "629b7ed22fa05d4d933d27ec9bdc4130dd31ed0edb842794b23e9d916cd7b2de",
      "url": "/reference/source/forge-ts/packages/forge-generate/src/index.ts.txt",
      "declarations": [
        {
          "name": "export { ForgeGenerateError, ForgeGenerateErrorCode, type ForgeGenerateErrorCodeType } from './error.js';",
          "line": 15,
          "signature": "export { ForgeGenerateError, ForgeGenerateErrorCode, type ForgeGenerateErrorCodeType } from './error.js';",
          "documentation": ""
        },
        {
          "name": "export { GenerateTextResult, generateText } from './text.js';",
          "line": 18,
          "signature": "export { GenerateTextResult, generateText } from './text.js';",
          "documentation": ""
        },
        {
          "name": "export { TextStreamResult, streamText } from './stream.js';",
          "line": 21,
          "signature": "export { TextStreamResult, streamText } from './stream.js';",
          "documentation": ""
        },
        {
          "name": "export { type ObjectResult, generateObject, streamObject } from './object.js';",
          "line": 24,
          "signature": "export { type ObjectResult, generateObject, streamObject } from './object.js';",
          "documentation": ""
        },
        {
          "name": "export {",
          "line": 27,
          "signature": "export {\n  type StopCondition,\n  type StopReason,\n  type StepResult,\n  maxSteps,\n  maxTokens,\n  textMatch,\n  customStop,\n  formatStopReason,\n  finalText,\n  stepCount,\n  completedNaturally,\n  generateSteps,\n} from './step.js';",
          "documentation": ""
        }
      ]
    },
    {
      "path": "forge-ts/packages/forge-generate/src/object.ts",
      "sha256": "fa20e2428020f59767e7248b0d7521584e03d8ceb38d2ea877d8a2fba1349d42",
      "artifactSha256": "b10276a0df5c8f2a7b70de59612f09b76d35cd93601b353e3ae33a4072dccd99",
      "url": "/reference/source/forge-ts/packages/forge-generate/src/object.ts.txt",
      "declarations": [
        {
          "name": "ObjectResult",
          "line": 47,
          "signature": "export interface ObjectResult<T> {\n  /** The deserialized object. */\n  readonly object: T;\n  /** The raw JSON string from the model output. */\n  readonly rawJson: string;\n  /** Token usage statistics. */\n  readonly usage: Usage;\n  /** Why generation stopped. */\n  readonly finishReason: FinishReason;\n}",
          "documentation": ""
        },
        {
          "name": "generateObject",
          "line": 83,
          "signature": "export async function generateObject<T>(\n  model: LanguageModel,\n  messages: readonly ModelMessage[],\n  schema: JsonSchema,\n  options: GenerateOptions\n): Promise<ObjectResult<T>>;",
          "documentation": "Generates a structured object from a language model.\n\nSends the conversation history to the model with a JSON schema constraint,\nvalidates the response against the schema, and parses it as JSON.\n\nANVIL Spec section 6.1: Structured output generation uses the cognitive\ninterface infer() with a schema constraint."
        },
        {
          "name": "streamObject",
          "line": 164,
          "signature": "export async function streamObject<T>(\n  model: LanguageModel,\n  messages: readonly ModelMessage[],\n  schema: JsonSchema,\n  options: GenerateOptions\n): Promise<ObjectResult<T>>;",
          "documentation": ""
        }
      ]
    },
    {
      "path": "forge-ts/packages/forge-generate/src/step.ts",
      "sha256": "ca69fdc92362404ebcac07a01890379a9d78e5bcbbf44ba25ceccdec6a229ded",
      "artifactSha256": "241b8805d73cf996466b98102cd178ac60988e10a4a946afc0eb65ef38d85b0d",
      "url": "/reference/source/forge-ts/packages/forge-generate/src/step.ts.txt",
      "declarations": [
        {
          "name": "StopCondition",
          "line": 45,
          "signature": "export type StopCondition =\n  | { readonly type: 'max_steps'; readonly maxSteps: number }\n  | { readonly type: 'max_tokens'; readonly maxTokens: number }\n  | { readonly type: 'text_match'; readonly pattern: string }\n  | { readonly type: 'custom'; readonly predicate: (result: GenerateResult) => boolean };",
          "documentation": "A condition that determines when multi-step generation stops.\n\nANVIL Spec section 6.1: The cognitive interface tool loop continues until a\nterminal condition: the model stops requesting tools, a step limit is reached,\nor a token budget is exhausted."
        },
        {
          "name": "maxSteps",
          "line": 57,
          "signature": "export function maxSteps(maxSteps: number): StopCondition;",
          "documentation": "Creates a MaxSteps stop condition."
        },
        {
          "name": "maxTokens",
          "line": 67,
          "signature": "export function maxTokens(maxTokens: number): StopCondition;",
          "documentation": "Creates a MaxTokens stop condition."
        },
        {
          "name": "textMatch",
          "line": 77,
          "signature": "export function textMatch(pattern: string): StopCondition;",
          "documentation": "Creates a TextMatch stop condition."
        },
        {
          "name": "customStop",
          "line": 88,
          "signature": "export function customStop(predicate: (result: GenerateResult) => boolean): StopCondition;",
          "documentation": "Creates a Custom stop condition."
        },
        {
          "name": "StopReason",
          "line": 98,
          "signature": "export type StopReason =\n  | { readonly type: 'model_stopped' }\n  | { readonly type: 'step_limit_reached'; readonly steps: number; readonly limit: number }\n  | { readonly type: 'token_limit_reached'; readonly totalTokens: number; readonly limit: number }\n  | { readonly type: 'text_match_found'; readonly pattern: string }\n  | { readonly type: 'custom_condition' };",
          "documentation": "The reason why multi-step generation stopped.\n\nIncluded in StepResult to let the caller determine whether generation\ncompleted naturally or was cut short by a limit."
        },
        {
          "name": "formatStopReason",
          "line": 111,
          "signature": "export function formatStopReason(reason: StopReason): string;",
          "documentation": "Formats a StopReason as a human-readable string."
        },
        {
          "name": "StepResult",
          "line": 139,
          "signature": "export interface StepResult {\n  /** The ordered sequence of generation results, one per step. */\n  readonly steps: readonly GenerateResult[];\n  /** Cumulative token usage across all steps. */\n  readonly totalUsage: Usage;\n  /** Why multi-step generation stopped. */\n  readonly stopReason: StopReason;\n}",
          "documentation": ""
        },
        {
          "name": "finalText",
          "line": 154,
          "signature": "export function finalText(result: StepResult): string;",
          "documentation": "Returns the text from the final step, or an empty string if no steps completed."
        },
        {
          "name": "stepCount",
          "line": 167,
          "signature": "export function stepCount(result: StepResult): number;",
          "documentation": "Returns the number of completed steps."
        },
        {
          "name": "completedNaturally",
          "line": 177,
          "signature": "export function completedNaturally(result: StepResult): boolean;",
          "documentation": "Returns `true` if the model stopped naturally (no limits hit)."
        },
        {
          "name": "generateSteps",
          "line": 213,
          "signature": "export async function generateSteps(\n  model: LanguageModel,\n  initialMessages: readonly ModelMessage[],\n  tools: readonly ToolDefinition[],\n  options: GenerateOptions,\n  stop: StopCondition\n): Promise<StepResult>;",
          "documentation": "Runs multi-step generation until a stop condition is met.\n\nEach step calls LanguageModel.generate(), appends the model's response\nto the conversation, and checks the stop condition. Generation continues\nuntil the stop condition fires or the model produces a response without\ntool calls (natural completion).\n\nANVIL Spec section 6.1: Implements the tool loop pattern from the\ncognitive interface specification."
        }
      ]
    },
    {
      "path": "forge-ts/packages/forge-generate/src/stream.ts",
      "sha256": "0690e9b3e90ccf2d3a312fe93f440f44f1b36671ca5fde34ef46498628bb340e",
      "artifactSha256": "98ce25be9a660d27125efe8abc8d04e8a8ac6f33de615c62fdbaa3ee0e7386a5",
      "url": "/reference/source/forge-ts/packages/forge-generate/src/stream.ts.txt",
      "declarations": [
        {
          "name": "TextStreamResult",
          "line": 44,
          "signature": "export class TextStreamResult {\n  constructor(chunks: readonly StreamChunk[]);\n  get fullText(): string;\n  get chunks(): readonly StreamChunk[];\n  get chunkCount(): number;\n  get usage(): Usage;\n  get finishReason(): FinishReason | undefined;\n  get isComplete(): boolean;\n}",
          "documentation": ""
        },
        {
          "name": "streamText",
          "line": 158,
          "signature": "export async function streamText(\n  model: LanguageModel,\n  messages: readonly ModelMessage[],\n  tools: readonly ToolDefinition[],\n  options: GenerateOptions\n): Promise<TextStreamResult>;",
          "documentation": "Streams a text response from a language model.\n\nSends the conversation history and available tools to the model, receives\nthe streamed response as chunks, and wraps the result in a TextStreamResult.\n\nANVIL Spec section 6.1: Implements the infer_stream() operation defined by\nthe ANVIL cognitive interface."
        }
      ]
    },
    {
      "path": "forge-ts/packages/forge-generate/src/text.ts",
      "sha256": "8ca65cf41a1888cb1311ae919ed27caae9d243fc72da08a858b7179a4b97fc20",
      "artifactSha256": "07bbbede2d28421c26254b0f9db56ff594647b83b90644053e8047f901cbac5c",
      "url": "/reference/source/forge-ts/packages/forge-generate/src/text.ts.txt",
      "declarations": [
        {
          "name": "GenerateTextResult",
          "line": 42,
          "signature": "export class GenerateTextResult {\n  constructor(inner: GenerateResult);\n  get text(): string;\n  get usage(): Usage;\n  get finishReason(): FinishReason;\n  get message(): ModelMessage;\n  get hasToolCalls(): boolean;\n  get inner(): GenerateResult;\n}",
          "documentation": ""
        },
        {
          "name": "generateText",
          "line": 134,
          "signature": "export async function generateText(\n  model: LanguageModel,\n  messages: readonly ModelMessage[],\n  tools: readonly ToolDefinition[],\n  options: GenerateOptions\n): Promise<GenerateTextResult>;",
          "documentation": "Generates a complete text response from a language model.\n\nThis is the primary entry point for buffered (non-streaming) inference. It\nsends the conversation history and available tools to the model, waits for\nthe complete response, and returns it wrapped in a GenerateTextResult.\n\nANVIL Spec section 6.1: Implements the infer() operation defined by the\nANVIL cognitive interface."
        }
      ]
    }
  ]
}
