import { CallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js"; //#region packages/extension-sdk/src/workflow.d.ts interface RetryPolicy { maxAttempts: number; backoffMs: number; multiplier?: number; } interface ToolNode { readonly kind: 'tool'; readonly id: string; readonly toolName: string; readonly input?: Record; readonly inputFrom?: Record; readonly timeoutMs?: number; readonly retry?: RetryPolicy; } interface SequenceNode { readonly kind: 'sequence'; readonly id: string; readonly steps: WorkflowNode[]; } interface ParallelNode { readonly kind: 'parallel'; readonly id: string; readonly steps: WorkflowNode[]; readonly maxConcurrency?: number; readonly failFast?: boolean; } interface BranchNode { readonly kind: 'branch'; readonly id: string; readonly predicateId: string; readonly predicateFn?: (ctx: WorkflowExecutionContext) => boolean | Promise; readonly whenTrue: WorkflowNode; readonly whenFalse?: WorkflowNode; } interface FallbackNode { readonly kind: 'fallback'; readonly id: string; readonly primary: WorkflowNode; readonly fallback: WorkflowNode; } type WorkflowNode = ToolNode | SequenceNode | ParallelNode | BranchNode | FallbackNode; interface WorkflowExecutionContext { readonly workflowRunId: string; readonly profile: string; readonly stepResults: ReadonlyMap; invokeTool(toolName: string, args: Record): Promise; emitSpan(name: string, attrs?: Record): void; emitMetric(name: string, value: number, type: 'counter' | 'gauge' | 'histogram', attrs?: Record): void; getConfig(path: string, fallback?: T): T; } interface WorkflowRouteStep { readonly id: string; readonly toolName: string; readonly description: string; readonly prerequisites: string[]; readonly parallel?: boolean; readonly expectedInputs?: Record; readonly evidenceNodeType?: string; } type WorkflowRouteKind = 'preset' | 'workflow'; interface WorkflowRouteMetadata { readonly kind: WorkflowRouteKind; readonly triggerPatterns: RegExp[]; readonly steps: WorkflowRouteStep[]; readonly requiredDomains: string[]; readonly priority: number; } interface WorkflowContract { readonly kind: 'workflow-contract'; readonly version: 1; readonly id: string; readonly displayName: string; readonly description?: string; readonly tags?: string[]; readonly timeoutMs?: number; readonly defaultMaxConcurrency?: number; readonly route?: WorkflowRouteMetadata; build(ctx: WorkflowExecutionContext): WorkflowNode; onStart?(ctx: WorkflowExecutionContext): Promise | void; onFinish?(ctx: WorkflowExecutionContext, result: unknown): Promise | void; onError?(ctx: WorkflowExecutionContext, error: Error): Promise | void; } //#endregion //#region packages/extension-sdk/src/plugin.d.ts type ToolProfileId = 'search' | 'workflow' | 'full'; type ToolArgs$1 = Record; type ToolResponse = CallToolResult; type PluginState = 'loaded' | 'validated' | 'registered' | 'activated' | 'deactivated' | 'unloaded'; interface PluginLifecycleContext { readonly pluginId: string; readonly pluginRoot: string; readonly config: Record; readonly state: PluginState; registerMetric(metricName: string): void; invokeTool(name: string, args?: ToolArgs$1): Promise; hasPermission(capability: string): boolean; getConfig(path: string, fallback?: T): T; setRuntimeData(key: string, value: unknown): void; getRuntimeData(key: string): T | undefined; } type ExtensionToolHandler = (args: ToolArgs$1, ctx: PluginLifecycleContext) => Promise; type ExtensionToolInputSchema = Tool['inputSchema']; interface ExtensionToolDefinition { name: string; description: string; schema: ExtensionToolInputSchema; handler: ExtensionToolHandler; profiles?: ToolProfileId[]; } type ExtensionWorkflowDefinition = WorkflowContract; declare const jsonResponse: (payload: Record) => ToolResponse; declare const errorResponse: (tool: string, error: unknown, extra?: Record) => ToolResponse; declare class ExtensionBuilder { private readonly idValue; private readonly versionValue; private compatibleCoreValue; private profilesValue; private toolsValue; private workflowsValue; private allowedCommandsValue; private allowedHostsValue; private allowedToolsValue; private metricsValue; private configDefaultsValue; private onLoadHandlerValue?; private onValidateHandlerValue?; private onActivateHandlerValue?; private onDeactivateHandlerValue?; constructor(id: string, version: string); get id(): string; get version(): string; get compatibleCoreRange(): string; get profiles(): ToolProfileId[]; get tools(): ExtensionToolDefinition[]; get workflows(): ExtensionWorkflowDefinition[]; get allowedCommands(): string[]; get allowedHosts(): string[]; get allowedTools(): string[]; get declaredMetrics(): string[]; get configDefaults(): Record; get onLoadHandler(): ((ctx: PluginLifecycleContext) => Promise | void) | undefined; get onValidateHandler(): ((ctx: PluginLifecycleContext) => Promise<{ valid: boolean; errors: string[]; }> | { valid: boolean; errors: string[]; }) | undefined; get onActivateHandler(): ((ctx: PluginLifecycleContext) => Promise | void) | undefined; get onDeactivateHandler(): ((ctx: PluginLifecycleContext) => Promise | void) | undefined; compatibleCore(range: string): this; profile(p: ToolProfileId | ToolProfileId[]): this; allowCommand(cmd: string | string[]): this; allowHost(host: string | string[]): this; allowTool(tool: string | string[]): this; metric(m: string | string[]): this; configDefault(key: string, value: unknown): this; tool(name: string, desc: string, schema: Record, handler: ExtensionToolHandler, profiles?: ToolProfileId[]): this; workflow(workflow: ExtensionWorkflowDefinition | ExtensionWorkflowDefinition[]): this; onLoad(h: (ctx: PluginLifecycleContext) => Promise | void): this; onValidate(h: (ctx: PluginLifecycleContext) => Promise<{ valid: boolean; errors: string[]; }> | { valid: boolean; errors: string[]; }): this; onActivate(h: (ctx: PluginLifecycleContext) => Promise | void): this; onDeactivate(h: (ctx: PluginLifecycleContext) => Promise | void): this; } declare function createExtension(id: string, version: string): ExtensionBuilder; //#endregion //#region src/server/types.d.ts type ToolArgs = Record; //#endregion //#region src/server/extensions/plugin-config.d.ts declare function getPluginBooleanConfig(ctx: PluginLifecycleContext, pluginId: string, key: string, fallback: boolean): boolean; type BoostTier = 'search' | 'workflow' | 'full'; declare function getPluginBoostTier(pluginId: string): BoostTier; //#endregion //#region src/server/extensions/plugin-env.d.ts declare function loadPluginEnv(manifestLocation: string): void; //#endregion export { type ExtensionBuilder, type PluginLifecycleContext, type ToolArgs, createExtension, errorResponse, getPluginBooleanConfig, getPluginBoostTier, jsonResponse, loadPluginEnv };