import { TypeRegistry } from '../registry/index.js'; import { RelationGraph } from '../relations/index.js'; import type { Minion, CreateMinionInput, UpdateMinionInput, RelationType } from '../types/index.js'; import type { StorageAdapter, StorageFilter } from '../storage/index.js'; import type { IndexAdapter, IndexEntry } from '../index-layer/IndexAdapter.js'; import type { MinionPlugin } from './Plugin.js'; import type { MinionMiddleware } from './Middleware.js'; export interface MinionsConfig { plugins?: MinionPlugin[]; /** Optional storage adapter for persisting minions (data layer). */ storage?: StorageAdapter; /** * Optional index adapter for fast listing, filtering, and search. * * When configured alongside a `storage` adapter, the SDK keeps both * layers in sync automatically: `save()` writes to both, `remove()` * deletes from both. The new `listIndex()` and `searchIndex()` * methods query the index layer for lightweight `IndexEntry[]` results, * which contain enough data for table/grid/list views without loading * full minion objects. * * When not configured, the SDK falls back to single-layer mode, * preserving full backwards compatibility. */ index?: IndexAdapter; /** * Optional middleware pipeline. * Middleware functions are executed in order for every client operation. * Each middleware can run logic before and/or after the core operation. * * @example * ```typescript * const minions = new Minions({ * middleware: [ * async (ctx, next) => { * console.log(`→ ${ctx.operation}`, ctx.args); * await next(); * console.log(`← ${ctx.operation}`, ctx.result); * }, * ], * }); * ``` */ middleware?: MinionMiddleware[]; } /** * Enhanced Wrapper for a Minion instance that provides chainable, instance-level methods. */ export declare class MinionWrapper { data: Minion; private client; constructor(data: Minion, client: Minions); /** * Create a directed relation from this minion to a target minion. */ linkTo(targetId: string, type: RelationType): this; } /** * Central Client facade for the Minions ecosystem. * Orchestrates TypeRegistry and RelationGraph directly, and supports * plugin mounting and an optional middleware pipeline. * * Pass a `storage` adapter in the config to enable minion persistence: * * ```typescript * const storage = await JsonFileStorageAdapter.create('./data/minions'); * const minions = new Minions({ storage }); * const wrapper = await minions.create('note', { title: 'Hello', fields: { content: 'World' } }); * await minions.save(wrapper.data); * ``` * * Add middleware for cross-cutting concerns: * * ```typescript * const minions = new Minions({ * middleware: [ * async (ctx, next) => { * console.log(`${ctx.operation} started`); * await next(); * console.log(`${ctx.operation} completed`); * }, * ], * }); * ``` */ export declare class Minions { registry: TypeRegistry; graph: RelationGraph; storage?: StorageAdapter; index?: IndexAdapter; private _middleware; [key: string]: any; constructor(config?: MinionsConfig); /** * Run the middleware pipeline for an operation. If no middleware is * configured, `core` is called directly to avoid unnecessary overhead. */ private _run; /** * Creates a new minion and returns an enhanced MinionWrapper. * Looks up the appropriate schema from the internal TypeRegistry using the slug. * * @param typeSlug The slug of the MinionType to create (e.g. "agent") * @param input Data for the minion (title, fields, etc.) */ create(typeSlug: string, input: CreateMinionInput): Promise; /** * Updates an existing minion's data. */ update(minion: Minion, input: UpdateMinionInput): Promise; /** * Soft deletes a minion. */ softDelete(minion: Minion): Promise; /** * Hard deletes a minion from the relation graph. * Note: This does not remove it from your external storage. */ hardDelete(minion: Minion): Promise; /** * Restores a soft-deleted minion. */ restore(minion: Minion): Promise; /** @throws {Error} if no storage adapter has been configured. */ private requireStorage; /** * Persist a minion to the configured storage adapter. * Throws if no storage adapter has been configured. */ save(minion: Minion): Promise; /** * Load a minion from the configured storage adapter by ID. * Returns `undefined` if the minion does not exist. * Throws if no storage adapter has been configured. */ load(id: string): Promise; /** * Remove a minion from the configured storage adapter. * Also removes all of its relations from the in-memory graph. * Throws if no storage adapter has been configured. */ remove(minion: Minion): Promise; /** * List persisted minions from the configured storage adapter. * Throws if no storage adapter has been configured. */ listMinions(filter?: StorageFilter): Promise; /** * Full-text search across persisted minions. * Throws if no storage adapter has been configured. */ searchMinions(query: string): Promise; /** * List minion index entries from the index layer. * * Returns lightweight {@link IndexEntry} objects containing enough data * for table / grid / list views without loading full minion objects. * * When no index adapter is configured, falls back to the storage * adapter's `list()` and converts the results to `IndexEntry[]`. */ listIndex(filter?: StorageFilter): Promise; /** * Full-text search across the index layer. * * Returns lightweight {@link IndexEntry} objects. When no index adapter * is configured, falls back to the storage adapter's `search()`. */ searchIndex(query: string): Promise; /** * Count minions matching a filter using the index layer. * Falls back to `list().length` when no index is configured. */ countMinions(filter?: StorageFilter): Promise; } //# sourceMappingURL=Minions.d.ts.map