import { type Theme } from "../modes/interactive/theme/theme.ts"; import type { ResourceDiagnostic } from "./diagnostics.ts"; export type { ResourceCollision, ResourceDiagnostic } from "./diagnostics.ts"; import { type EventBus } from "./event-bus.ts"; import type { Extension, ExtensionFactory, LoadExtensionsResult } from "./extensions/types.ts"; import { type PathMetadata } from "./package-manager.ts"; import type { PromptTemplate } from "./prompt-templates.ts"; import { SettingsManager } from "./settings-manager.ts"; import type { Skill } from "./skills.ts"; export { hasInvisibleUnicode, scanContextFileThreats, stripInvisibleUnicode, type ThreatScope, } from "./security/context-threat-scanner.ts"; export interface ResourceExtensionPaths { skillPaths?: Array<{ path: string; metadata: PathMetadata; }>; promptPaths?: Array<{ path: string; metadata: PathMetadata; }>; themePaths?: Array<{ path: string; metadata: PathMetadata; }>; } export interface ResourceReloadOptions { /** Throw instead of accepting a hot reload that produced extension load/conflict errors. */ failOnExtensionErrors?: boolean; /** Keep the previous extension generation alive until commitReload()/rollbackReload(). */ deferExtensionDispose?: boolean; /** The caller already loaded the settings generation this resource pass must use. */ skipSettingsReload?: boolean; } export interface ResourceLoader { getExtensions(): LoadExtensionsResult; getSkills(): { skills: Skill[]; diagnostics: ResourceDiagnostic[]; }; /** Skills allowed by the currently active resource profile — use for selection/invocation/agent-visibility. */ getActiveSkills(): Skill[]; getPrompts(): { prompts: PromptTemplate[]; diagnostics: ResourceDiagnostic[]; }; /** Prompt templates allowed by the currently active resource profile — use for selection/invocation/agent-visibility. */ getActivePrompts(): PromptTemplate[]; getThemes(): { themes: Theme[]; diagnostics: ResourceDiagnostic[]; }; /** Themes allowed by the currently active resource profile. */ getActiveThemes(): Theme[]; getAgentsFiles(): { agentsFiles: Array<{ path: string; content?: string; }>; }; /** Warnings about context files withheld by the active profile (empty when none). */ getAgentsDiagnostics(): ResourceDiagnostic[]; /** Profile-INDEPENDENT discovery (editor universe; metadata only, never loads content). */ getDiscoverableSkillPaths(): string[]; getDiscoverablePromptPaths(): string[]; getDiscoverableAgentsFilePaths(): string[]; getSystemPrompt(): string | undefined; getAppendSystemPrompt(): string[]; getLoadedExtension(path: string): Extension | undefined; removeLoadedExtension(path: string): Extension | undefined; loadSingleExtension(path: string): Promise<{ extension: Extension | null; error: string | null; }>; /** Load one draft against a fresh runtime without mutating the live extension generation. */ loadIsolatedExtension?(path: string, cwd: string): Promise<{ extension: Extension | null; error: string | null; }>; extendResources(paths: ResourceExtensionPaths): void; reload(options?: ResourceReloadOptions): Promise; /** * Re-scan skill files so a just-written or archived skill is selectable this session. * Full `/reload` is not required. Optional on custom loaders. */ refreshSkills?(): void; commitReload?(): void | Promise; rollbackReload?(): void | Promise; /** Release the current (and any deferred) extension generation. Session dispose must call this. */ dispose?(): void | Promise; /** Get all discoverable extension paths (enabled and disabled) */ getDiscoverableExtensionPaths(): Promise; } /** * RAW (unsanitized) context files from `dir`. Sanitization/threat-scanning is DEFERRED to the caller * so a profile-DENIED file's content is never processed into the session — only its embedded * `` blocks are read for discovery (see {@link loadRawProjectContextFiles}). */ export declare function isGlobalAgentsFile(filePath: string, agentDir: string, platform?: NodeJS.Platform): boolean; /** * Discover project/agent context files with their RAW content (profile blocks intact, no sanitize). * The agents-kind profile filter can be DEFINED inside these same files (embedded `` * blocks), so callers must read raw to discover profiles before knowing which files the filter denies; * sanitization/exposure is then applied only to files the filter allows. */ export declare function loadRawProjectContextFiles(options: { cwd: string; agentDir: string; projectTrusted?: boolean; /** When true, walk cwd/ancestor context files. Default is global `agentDir` files only. */ includeProject?: boolean; /** Testable filesystem case semantics; production defaults to the current platform. */ platform?: NodeJS.Platform; }): Array<{ path: string; rawContent: string; }>; /** * Discover project/agent context files with SANITIZED content (profile blocks stripped, invisible/bidi * chars removed, prompt-injection scanned). Every discovered file is sanitized — callers that must * respect a profile's agents-kind denial should use {@link loadRawProjectContextFiles} and sanitize * only the allowed subset instead, so denied content is never processed. */ export declare function loadProjectContextFiles(options: { cwd: string; agentDir: string; projectTrusted?: boolean; /** When true, list cwd/ancestor files as paths. Default is global `agentDir` files only. */ includeProject?: boolean; platform?: NodeJS.Platform; }): Array<{ path: string; content?: string; }>; export interface DefaultResourceLoaderOptions { cwd: string; agentDir: string; settingsManager?: SettingsManager; eventBus?: EventBus; additionalExtensionPaths?: string[]; additionalSkillPaths?: string[]; additionalPromptTemplatePaths?: string[]; additionalThemePaths?: string[]; extensionFactories?: ExtensionFactory[]; noExtensions?: boolean; noSkills?: boolean; noPromptTemplates?: boolean; noThemes?: boolean; noContextFiles?: boolean; systemPrompt?: string; appendSystemPrompt?: string[]; extensionsOverride?: (base: LoadExtensionsResult) => LoadExtensionsResult; skillsOverride?: (base: { skills: Skill[]; diagnostics: ResourceDiagnostic[]; }) => { skills: Skill[]; diagnostics: ResourceDiagnostic[]; }; promptsOverride?: (base: { prompts: PromptTemplate[]; diagnostics: ResourceDiagnostic[]; }) => { prompts: PromptTemplate[]; diagnostics: ResourceDiagnostic[]; }; themesOverride?: (base: { themes: Theme[]; diagnostics: ResourceDiagnostic[]; }) => { themes: Theme[]; diagnostics: ResourceDiagnostic[]; }; agentsFilesOverride?: (base: { agentsFiles: Array<{ path: string; content?: string; }>; }) => { agentsFiles: Array<{ path: string; content?: string; }>; }; systemPromptOverride?: (base: string | undefined) => string | undefined; appendSystemPromptOverride?: (base: string[]) => string[]; } export declare class DefaultResourceLoader implements ResourceLoader { private cwd; private agentDir; private settingsManager; private eventBus; private packageManager; private additionalExtensionPaths; private additionalSkillPaths; private additionalPromptTemplatePaths; private additionalThemePaths; private extensionFactories; private noExtensions; private noSkills; private noPromptTemplates; private noThemes; private noContextFiles; private systemPromptSource?; private appendSystemPromptSource?; private extensionsOverride?; private skillsOverride?; private promptsOverride?; private themesOverride?; private agentsFilesOverride?; private systemPromptOverride?; private appendSystemPromptOverride?; private extensionsResult; private skills; private skillDiagnostics; private prompts; private promptDiagnostics; private themes; private themeDiagnostics; private agentsFiles; private systemPrompt?; private appendSystemPrompt; private lastSkillPaths; private lastAgentsFilePaths; private discoverableSkillPaths; private discoverablePromptPaths; private agentsDiagnostics; private extensionSkillSourceInfos; private extensionPromptSourceInfos; private extensionThemeSourceInfos; private lastPromptPaths; private lastThemePaths; private pendingReloadSnapshot; constructor(options: DefaultResourceLoaderOptions); getExtensions(): LoadExtensionsResult; getSkills(): { skills: Skill[]; diagnostics: ResourceDiagnostic[]; }; /** * Skills permitted by the CURRENTLY active resource profile (the loaded set intersected with the * live profile filter). Use this everywhere a skill can be SELECTED, INVOKED, or shown to the * agent — so neither the user (autocomplete / typed `/skill:`) nor the agent (system prompt / * expansion / command API / RPC) can use a skill the active profile blocks, including after a * runtime profile switch (router-managed / `/profile`). The full loaded set (`getSkills`) is * reserved for the profile editor and resource listings, which must show blockable skills. */ getActiveSkills(): Skill[]; /** * Re-scan the user skills directory plus already-discovered skill paths so a newly written or * archived skill is visible to `skill` search/load without a full extension reload. */ refreshSkills(): void; getPrompts(): { prompts: PromptTemplate[]; diagnostics: ResourceDiagnostic[]; }; /** * Prompt templates permitted by the CURRENTLY active resource profile (the loaded set intersected with the * live profile filter). Use this everywhere a prompt template can be SELECTED, INVOKED, or shown to the * agent — so neither the user (autocomplete / typed slash command) nor the agent can use a prompt template * the active profile blocks. The full loaded set (`getPrompts`) is reserved for the profile editor. */ getActivePrompts(): PromptTemplate[]; getThemes(): { themes: Theme[]; diagnostics: ResourceDiagnostic[]; }; /** * Themes permitted by the CURRENTLY active resource profile. */ getActiveThemes(): Theme[]; getAgentsFiles(): { agentsFiles: Array<{ path: string; content?: string; }>; }; /** Warnings about context files withheld by the active profile (empty when none). */ getAgentsDiagnostics(): ResourceDiagnostic[]; /** * Profile-INDEPENDENT discovery for the profile editor's universe (same rule as * getDiscoverableExtensionPaths): the full pre-filter path sets retained from the last * reload. Discovery is metadata, not loading — granting a currently-blocked skill/prompt/ * context file requires being able to SEE it; strict UAC only forbids reading denied * CONTENT into the session. */ getDiscoverableSkillPaths(): string[]; getDiscoverablePromptPaths(): string[]; getDiscoverableAgentsFilePaths(): string[]; getSystemPrompt(): string | undefined; getAppendSystemPrompt(): string[]; /** * Get all discoverable extension paths (enabled and disabled). * Used for profile resource filtering to show the full universe of available extensions. */ getDiscoverableExtensionPaths(): Promise; /** * Discover extension directories under every external resource root (`/extensions/` with an * index.ts/index.js/package.json). Single source of truth shared by the load path and the profile * editor's universe so the two never diverge. */ private discoverExternalExtensionPaths; private discoverBundledExtensionPaths; private discoverExtensionPathsInDirectory; /** * Get a loaded extension by path. * Matches by path or resolvedPath. */ getLoadedExtension(extensionPath: string): Extension | undefined; /** * Remove and return a loaded extension from the extensions array. */ removeLoadedExtension(extensionPath: string): Extension | undefined; /** * Load a single extension with fresh import, reusing the shared runtime. * Returns the loaded extension or null with error details. */ loadSingleExtension(extensionPath: string): Promise<{ extension: Extension | null; error: string | null; }>; loadIsolatedExtension(extensionPath: string, cwd: string): Promise<{ extension: Extension | null; error: string | null; }>; /** * Apply the active resource-profile allow/block to a list of discovered resource paths. * Used for every source that does NOT pass through the package manager's * resolve/applyResourceProfileFilters pipeline (external roots, bundled defaults, and * extension-contributed resources) so no source bypasses the active profile. */ private filterPathsByProfile; extendResources(paths: ResourceExtensionPaths): void; private createSnapshot; private restoreSnapshot; commitReload(): Promise; rollbackReload(): Promise; dispose(): Promise; reload(options?: ResourceReloadOptions): Promise; private normalizeExtensionPaths; private updateSkillsFromPaths; private updatePromptsFromPaths; private updateThemesFromPaths; private applyExtensionSourceInfo; private findSourceInfoForPath; private getDefaultSourceInfoForPath; private mergePaths; private resolveResourcePath; private loadThemes; private loadThemesFromDir; private loadThemeFromFile; private loadExtensionFactories; private dedupePrompts; private dedupeThemes; private discoverSystemPromptFile; private discoverAppendSystemPromptFile; private detectExtensionConflicts; } //# sourceMappingURL=resource-loader.d.ts.map