/** * GitHub World Import Utilities * * Purpose: * - Resolve supported GitHub shorthand world sources for import flows. * - Safely fetch and stage remote world folders into a temporary local directory. * * Key Features: * - Supports legacy `@awesome-agent-world/` world shorthand mapping. * - Requires explicit `owner/repo` input for generic GitHub repo imports. * - Enforces strict alias allowlist and world-path derivation. * - Applies safety checks for unsupported entry types and unsafe paths. * - Enforces bounded file-count and byte limits during staging. * - Returns source metadata including commit SHA when available. * * Implementation Notes: * - Uses GitHub REST contents API with recursive traversal. * - Treats remote content as untrusted and validates every staged path. * - Uses temp directories and explicit cleanup callbacks. * * Recent Changes: * - 2026-02-25: Added shorthand resolver and secure GitHub staging for world import. */ export type GitHubWorldImportErrorCode = 'invalid-shorthand' | 'unsupported-alias' | 'source-not-found' | 'fetch-failed' | 'unsupported-entry-type' | 'unsafe-path' | 'limits-exceeded'; export declare class GitHubWorldImportError extends Error { code: GitHubWorldImportErrorCode; details?: Record; constructor(code: GitHubWorldImportErrorCode, message: string, details?: Record); } export interface ResolvedGitHubWorldSource { shorthand: string; alias: string; worldName: string; owner: string; repo: string; branch: string; worldPath: string; } export interface ResolvedGitHubRepoSource { repoInput: string; owner: string; repo: string; branch: string; } interface StageRemoteWorldOptions { maxFileCount?: number; maxTotalBytes?: number; requestTimeoutMs?: number; tempPrefix?: string; } export interface StagedGitHubWorldResult { stagingRootPath: string; worldFolderPath: string; source: { shorthand: string; owner: string; repo: string; branch: string; worldPath: string; commitSha: string | null; }; cleanup: () => Promise; } export interface StagedGitHubFolderResult { stagingRootPath: string; folderPath: string; source: { repoInput: string; owner: string; repo: string; branch: string; folderPath: string; commitSha: string | null; }; cleanup: () => Promise; } export declare function ensureSafeRelativePath(relativePath: string): string; export declare function resolveGitHubWorldShorthand(source: string): ResolvedGitHubWorldSource; export declare function resolveGitHubRepoSource(repoInput: string): ResolvedGitHubRepoSource; export declare function stageGitHubFolderFromRepo(repoInput: string, folderPath: string, options?: StageRemoteWorldOptions & { folderName?: string; }): Promise; export declare function stageGitHubWorldFromShorthand(shorthand: string, options?: StageRemoteWorldOptions): Promise; export {};