/** * @license * Copyright 2025 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import type { IRunConfig, TaskConfig } from "@workglow/task-graph"; import { CreateWorkflow, IExecuteContext, IExecutePreviewContext, Task } from "@workglow/task-graph"; import { DataPortSchema } from "@workglow/util/schema"; import type { Capability } from "../capability/Capabilities"; import type { ModelConfig } from "../model/ModelSchema"; export declare const ContextFormat: { readonly SIMPLE: "simple"; readonly NUMBERED: "numbered"; readonly XML: "xml"; readonly MARKDOWN: "markdown"; readonly JSON: "json"; }; export type ContextFormat = (typeof ContextFormat)[keyof typeof ContextFormat]; export type ContextBuilderTaskInput = { maxLength?: number | undefined; format?: "simple" | "markdown" | "numbered" | "xml" | "json" | undefined; model?: string | ModelConfig | undefined; metadata?: { [x: string]: unknown; }[] | undefined; maxTokens?: number | undefined; scores?: number[] | undefined; includeMetadata?: boolean | undefined; separator?: string | undefined; chunks: string[]; }; export type ContextBuilderTaskOutput = { context: string; chunksUsed: number; totalLength: number; totalTokens: number; }; export type ContextBuilderTaskConfig = TaskConfig; /** * Task for formatting retrieved chunks into context for LLM prompts. * Supports various formatting styles and length/token constraints. * * Token budgeting (for `maxTokens`) uses {@link estimateTokens} to approximate * the token count of the generated context. This is a character-based estimate * rather than an exact tokenizer tied to a specific model. */ export declare class ContextBuilderTask extends Task { static type: string; /** Pure-compute formatting task — no provider capability required. */ static readonly requires: readonly Capability[]; static category: string; static title: string; static description: string; static cacheable: boolean; static inputSchema(): DataPortSchema; static outputSchema(): DataPortSchema; execute(input: ContextBuilderTaskInput, context: IExecuteContext): Promise; executePreview(input: ContextBuilderTaskInput, context: IExecutePreviewContext): Promise; private formatChunk; private formatNumbered; private formatXML; private formatMarkdown; private formatJSON; private formatMetadataInline; private escapeXML; } export declare const contextBuilder: (input: ContextBuilderTaskInput, config?: ContextBuilderTaskConfig, runConfig?: Partial) => Promise; declare module "@workglow/task-graph" { interface Workflow { contextBuilder: CreateWorkflow; } } //# sourceMappingURL=ContextBuilderTask.d.ts.map