import { EastType, EastTypeValue, ValueTypeOf } from '@elaraai/east'; import { PlatformFunction } from '@elaraai/east/internal'; import { FuncErrorType } from '@elaraai/e3-ui/internal'; import { ExecuteResult, FunctionSignature } from '@elaraai/e3-api-client'; import { TrackedChannelStore } from './tracked-channel.js'; /** Request shape for {@link FunctionApi.call} — beast2-encoded positional * args. Runner/limit overrides are deliberately not exposed (the deployed * function's runner is authoritative). */ export interface FunctionCallArgs { args: Uint8Array[]; } /** * Adapter for the workspace function endpoints. The default wraps * `@elaraai/e3-api-client`'s `workspaceFunctionList` / * `workspaceFunctionCall`. */ export interface FunctionApi { /** List the workspace's deployed functions with their signatures. */ list(workspace: string): Promise; /** Call a function synchronously, returning its terminal ExecuteResult. */ call(workspace: string, fn: string, req: FunctionCallArgs): Promise; } /** * Build the default {@link FunctionApi} that talks to a real e3 server via * `@elaraai/e3-api-client`. */ export declare function createDefaultFunctionApi(apiUrl: string, repo: string, getToken: () => string | null): FunctionApi; type FuncError = ValueTypeOf; type FuncStatusTag = "idle" | "running" | "succeeded" | "failed" | "cancelled"; /** A handle's signature, recovered from the instantiated handle type. */ interface FuncHandleSignature { readonly inputs: EastTypeValue[]; readonly output: EastTypeValue; } /** * Introspect the instantiated handle struct type `H`: the input types come * from the `call` field's FunctionType, the output type from the `read` * field's `Option(Output)` return. The handle's shape IS the signature — * there are no duplicate signature arguments to drift out of sync. */ export declare function signatureOfFuncHandleType(handleType: EastTypeValue): FuncHandleSignature; /** One tracked channel per `(workspace, name)`. */ interface FuncEntry { status: FuncStatusTag; /** Monotonic; a settling call whose seq is no longer current is * discarded (latest-wins, and `cancel` orphans by bumping it). */ launchSeq: number; /** Decoded Output of the last `succeeded` call. */ result?: unknown; /** Detail of the last `failed` call. */ error?: FuncError; } /** Tracked-channel key. */ export declare function funcChannelKey(workspace: string, name: string): string; /** * Encapsulates all `Func.bind` runtime state. The module-level * {@link defaultFuncRuntime} instance backs the registered platform; tests * construct their own for isolation. */ export declare class FuncRuntime extends TrackedChannelStore { private api; private workspace; private signatureLists; protected createEntry(): FuncEntry; /** Install the API adapter + workspace — called by the React provider * (or a test/showcase harness) before any handle is used. */ initialize(api: FunctionApi, workspace: string): void; /** Tear down the adapter and all call state. */ clear(): void; /** The deployed signature list for a workspace (fetched once). */ private signatures; /** Validate a declared signature against the deployed list. Returns a * FuncError when the name is unknown or the signature disagrees. */ private validate; private launch; /** Build the handle value for one `Func.bind` platform evaluation. */ buildHandle(handleType: EastTypeValue, name: string): Record; /** Build a `Func.bind` PlatformFunction bound to this runtime. Pass * `allowed=null` for an unscoped impl; pass a Set of function names * for manifest scoping. */ buildPlatform(allowed: ReadonlySet | null): PlatformFunction; } /** Process-global runtime backing the `FuncPlatform` export. */ export declare const defaultFuncRuntime: FuncRuntime; /** Install the function API adapter + workspace — called by the React * provider on mount (or by a test/showcase harness). */ export declare function initializeFunctionApi(api: FunctionApi, workspace: string): void; /** Tear down the function API adapter and all call state. */ export declare function clearFunctionApi(): void; /** Global, manifest-unscoped `Func.bind` impl. Registered on module load. */ export declare const FuncPlatform: PlatformFunction[]; /** Build a manifest-scoped `Func.bind` implementation. */ export declare function createScopedFuncPlatform(functions: readonly string[]): PlatformFunction[]; /** One offline function implementation for {@link createInMemoryFunctionApi}. */ export interface InMemoryFunctionDef { /** Function name (what `Func.bind` is bound to). */ name: string; /** Positional parameter types. */ inputTypes: (EastType | EastTypeValue)[]; /** Return type. */ outputType: EastType | EastTypeValue; /** The implementation — receives decoded args, returns the result * value (or a promise of it). */ fn: (...args: unknown[]) => unknown; } /** * Build an offline {@link FunctionApi} from local implementations — the * showcase/snapshot harnesses' stand-in for a deployed package. */ export declare function createInMemoryFunctionApi(functions: InMemoryFunctionDef[]): FunctionApi; export {}; //# sourceMappingURL=func-runtime.d.ts.map