/** * @license * Copyright 2025 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import type { IExecuteContext, TaskEntitlements } from "@workglow/task-graph"; import { CreateWorkflow } from "@workglow/task-graph"; import type { DataPortSchema } from "@workglow/util/schema"; import type { FileLoaderTaskConfig, FileLoaderTaskInput, FileLoaderTaskOutput } from "./FileLoaderTask"; import { FileLoaderTask as BaseFileLoaderTask } from "./FileLoaderTask"; export type { FileLoaderTaskConfig, FileLoaderTaskInput, FileLoaderTaskOutput }; /** * Server-only task for loading documents from the filesystem. * Uses Node.js/Bun file APIs directly for better performance. * Only available in Node.js and Bun environments. * * A local path is resolved and realpath'd before it is opened, and constrained * to `config.roots` — which defaults to the process working directory, so a * task with no stated root reads from there and nowhere else. Set * `config.allowAnyRoot` to opt out. Reading requires the `filesystem:read` * entitlement, declared scoped to the resolved path. * * For cross-platform document loading (including browser), use FileLoaderTask with URLs. */ export declare class FileLoaderTask extends BaseFileLoaderTask { static hasDynamicEntitlements: boolean; static configSchema(): DataPortSchema; /** * The owned `FetchUrlTask` does the network access for the http(s) branch, * but an owned child is created inside `execute()` and so is absent from the * graph-start snapshot `computeGraphEntitlements` takes. Declaring the * fetch's entitlements here is what puts them in front of the enforcer, * alongside the read this build adds. */ static entitlements(): TaskEntitlements; /** * Declares whichever half of the surface this url actually uses: the fetch * entitlements for http(s), otherwise `filesystem:read` scoped to the * resolved real path. An unknown url fails closed to both, unscoped. * * Never throws — entitlement evaluation runs before `execute()` and must * produce a declaration for any input, so an unresolvable path degrades to * the unscoped declaration and is refused later, at open time. */ entitlements(): TaskEntitlements; /** * Refuses a path the instance did not declare. Entitlements are evaluated * on the unresolved input, so without this a declare-then-swap would let the * open authorize itself — and a standalone `fileLoader(...)` with no graph * and no enforcer would honour no `roots` at all. */ private assertResolvedPathDeclared; execute(input: FileLoaderTaskInput, context: IExecuteContext): Promise; } export declare const fileLoader: (input: FileLoaderTaskInput, config?: FileLoaderTaskConfig) => Promise<{ csv?: unknown[] | undefined; frontmatter?: { [x: string]: unknown; } | undefined; image?: string | undefined; json?: unknown; metadata: { format?: string | undefined; mimeType?: string | undefined; size?: number | undefined; title?: string | undefined; url?: string | undefined; }; pdf?: string | undefined; text?: string | undefined; }>; declare module "@workglow/task-graph" { interface Workflow { fileLoader: CreateWorkflow; } }