import { SandboxFilesystem } from '@mastra/code-sdk/agents/sandbox-filesystem'; import type { getDynamicWorkspace } from '@mastra/code-sdk/agents/workspace'; import { Workspace } from '@mastra/core/workspace'; import type { FactorySandbox, SkillSource, SkillSourceEntry, SkillSourceStat, WorkspaceSandbox } from '@mastra/core/workspace'; import type { RepositoryAccess, VersionControl } from './capabilities/version-control.js'; import type { GithubIntegration } from './integrations/github/integration.js'; import type { FactorySandboxContext } from './sandbox/session-sandbox.js'; import type { FactoryProject, FactoryProjectsStorage } from './storage/domains/projects/base.js'; import type { SourceControlStorageHandle } from './storage/domains/source-control/base.js'; import type { WorkItemsStorage } from './storage/domains/work-items/base.js'; export declare const BUNDLED_FACTORY_SKILLS_PATH: string; /** * Resolve the consumer repo's local Factory skills root, if any. Checked in * addition to the bundled skills so projects can add (or override) Factory * skills without patching the installed package. Candidates cover the cwd * variants the dev server runs with (`repo root`, `--dir src/mastra` which * runs with cwd `src/mastra/public`). */ export declare function resolveLocalFactorySkillsPath(cwd?: string): string | undefined; export declare const FACTORY_SKILL_NAMES: Set; /** Review skills only sessions with an active review run binding may discover or load. */ export declare const REVIEW_ONLY_FACTORY_SKILLS: Set; /** * Rescan a session's skill cache so a role gained after the cache was built * (a review binding minted after the session's workspace resolved) takes effect. * The source still checks the live binding, so this never widens access. */ export declare function rescanFactorySkills(skills: NonNullable): Promise; export declare class FactorySkillSource implements SkillSource { #private; readonly fallback: SkillSource; /** Evaluated per call because a session's bound role changes across stages. */ readonly isReviewSession: () => Promise; constructor(fallback: SkillSource, fallbackSkillRoots: string[], localSkillsPath?: string | undefined, /** Evaluated per call because a session's bound role changes across stages. */ isReviewSession?: () => Promise); exists(skillPath: string): Promise; stat(skillPath: string): Promise; readFile(skillPath: string): Promise; readdir(skillPath: string): Promise; realpath(skillPath: string): Promise; } type DynamicWorkspaceContext = Parameters[0]; /** * When a session's sandbox boots: on the agent's first command (`'lazy'`, the * default) or as soon as the session's workspace is first resolved (`'eager'`). * An eager start is fire-and-forget; if it fails, the lazy path still runs. */ export type FactorySandboxStart = 'lazy' | 'eager'; export interface WorkspaceSourceControlProvider { /** Stable integration id used to select the provider-owned storage partition. */ id: string; /** Provider capability used to resolve fresh repository credentials. */ versionControl: Pick; /** Provider-owned source-control rows, including Factory sessions. */ storage: SourceControlStorageHandle; /** Present only for GitHub, whose CLI PAT rotation has additional semantics. */ github?: GithubIntegration; } export interface CreateWorkspaceFactoryOptions { /** The normalized factory sandbox constructing one sandbox per session. */ sandbox?: FactorySandbox; /** Defaults to `'lazy'`. */ sandboxStart?: FactorySandboxStart; /** Source-control providers whose repositories may back Factory sessions. */ sourceControls?: WorkspaceSourceControlProvider[]; /** @deprecated GitHub-only compatibility path; prefer sourceControls. */ github?: GithubIntegration; /** Work-items storage used to resolve the session's run-binding role, so * review-board sessions get the reviewer PAT as `GH_TOKEN`. Optional — * without it every session uses the default (worker) PAT. */ workItems?: Pick; /** Projects storage used to authorize workspace-free supervisor sessions. */ projects?: Pick; /** Runtime workspace/token registrations invalidated when a session retires. */ workspaceRegistry?: FactoryWorkspaceRegistry; } type WorkspaceUnregister = () => Promise | void; /** Tracks dynamic Factory workspaces by persisted session id for retirement. */ export declare class FactoryWorkspaceRegistry { #private; generation(sessionId: string): number; register(sessionId: string, workspaceId: string, generation: number, unregister: WorkspaceUnregister): Promise; invalidateSession(sessionId: string): Promise; } /** One environment repository as the sandbox context and the boot need it, in position order. */ export interface SessionEnvironmentRepo { projectRepositoryId: string; repositoryId: string; slug: string; /** The session's base branch: the link's branch when set, else the repository default. */ defaultBranch: string; /** The repository's own default branch, which the template image clones and pins. */ templateBranch: string; position: number; setupCommand: string | undefined; teardownCommand: string | undefined; } /** The session's factory environment, resolved from the project and its `inEnvironment` links. */ export interface SessionEnvironment { repos: SessionEnvironmentRepo[]; workspaceSetupCommand: string | undefined; /** Only an absolute root is passed on; the templates reject anything else. */ workingDirectory: string | undefined; /** The project's stored provider settings document, `{}` when nothing was set. */ settings: Record; } /** * The project's environment as a session (or an environment build) sees it: * every `inEnvironment` link under this source-control integration in * position order, plus the project's settings, setup command and workdir. */ export declare function resolveProjectEnvironment(storage: Pick, project: FactoryProject): Promise; /** * The context fields the list form of the repo templates needs: one entry per * environment repository, each minting its own token at build time, with * `getRepositoryAccess` present but undefined (the two are mutually exclusive * for the template). Shared by session boot and environment builds so both * resolve the same template identity; `resolveHead` is only set when given. */ export declare function environmentSandboxContext(environment: SessionEnvironment, options: { orgId: string; getRepositoryAccess: (args: { orgId: string; repositoryId: string; }) => Promise; resolveHead?: FactorySandboxContext['resolveHead']; }): Omit; export declare function createWorkspaceFactory(options?: CreateWorkspaceFactoryOptions): ({ requestContext, mastra, skillExtension }: DynamicWorkspaceContext) => Promise | Workspace | undefined>; export {}; //# sourceMappingURL=workspace.d.ts.map