/** The scope folder inside the project root. */ export declare const RUN_SCOPE_DIR_NAME = ".teamshare-runs"; /** * The opencode project directory. NEVER linked into a scope: it holds the * run's `opencode.json` (its MCP identity), and a link would make every run of * the project share - and fight over - the HUMAN's own config file. */ export declare const OPENCODE_DIR_NAME = ".opencode"; /** * Every harness config directory a RUN writes its MCP identity into. * * These are mirrored into the scope as PRIVATE directories (real dir, contents * linked/copied) instead of being linked whole. A link would put the run's * identity into the human's file, and two concurrent runs would overwrite and * then restore/delete it under each other - the loser falls back to the global * config, i.e. the human's own key. See the module comment. */ export declare const PRIVATE_CONFIG_DIRS: readonly string[]; export interface RunScope { /** The scope directory - the harness runs HERE (its own opencode project). */ dir: string; /** The real project root the scope mirrors. */ projectRoot: string; /** Remove the scope (links first, so a junction's TARGET is never touched). */ cleanup: () => void; } /** * Does this run need a scope of its own? * * FALSE when the cwd is already an isolated tree (the mirror marker) or when * there is no cwd at all. TRUE for a shared folder - the human's own project * root - where the run's identity config would otherwise hijack the human's * session. */ export declare function needsRunScope(cwd?: string): boolean; /** * How long a scope with no live run survives before the sweeper reaps it. * * The scope path is stable per conversation (see `spawn.ts`), so the NEXT run * of the same chat/doc/board/plan conversation resumes in it. Reaping it too * eagerly costs the conversation its directory, so a dead scope waits a * working day. */ export declare const SCOPE_IDLE_REAP_MS: number; /** * The dead URL a 2026-11-14 build wrote into a kept scope at run end * (`poisonRunScopeIdentity`, since removed). * * Kept as a DETECTOR only. The build that wrote it also left every conversation * it touched resuming a session with no `teamshare` MCP server, so the next run * of such a scope must start a FRESH harness session - its tools are resolved * when the session is created, and a session born without them never gets them * back. See {@link scopeIdentityWasRevoked}. */ export declare const REVOKED_MCP_URL = "http://127.0.0.1:9/mcp-identity-disabled"; /** Where a conversation's scope lives (stable per conversation). */ export declare function scopeDirFor(projectRoot: string, runId: string): string; /** * Does this scope still carry the REVOKED identity a 2026-11-14 run wrote? * * A healing check, not a policy: the fix is to keep the run's own identity, so * a scope written by any current build answers false. When it answers true the * caller must NOT resume that conversation's harness session - the session was * created while the `teamshare` server was unreachable and its tool list has no * TeamShare tools at all, which is why an agent answered "Working on it" and * then produced nothing it could deliver. */ export declare function scopeIdentityWasRevoked(scopeDir: string): boolean; /** * Create the run scope: a directory of its own that mirrors the project root. * * Returns null when the scope cannot be created - the caller then runs in the * original directory (the old behaviour), which is a degradation, not a * failure: a run must still work. */ export declare function createRunScope(projectRoot: string, runId: string): RunScope | null; /** * Remove a scope directory. The links are unlinked EXPLICITLY first: a * recursive delete of a directory holding junctions must never follow them * into the user's project. Hardened (2026-10-27): `.opencode` first (it holds * the identity config), then links, then copies; EBUSY on Windows is retried, * and a survivor is left for `sweepStaleScopes` rather than half-deleted. */ export declare function removeRunScope(dir: string): void; /** * The block the agent sees when its session runs in a scope. Without it the * agent would guess that the scope IS the project root and write a top-level * file into a COPY. */ export declare function scopeWorkingDirectoryNotice(scope: RunScope): string; /** * Keep the scope out of the human's git status while it exists. LOCAL only * (`.git/info/exclude`) - the user's own `.gitignore` is never touched. * The entry is a MARKED block so cleanup can strip exactly what it added and * leave every other line (including older unmarked bridge lines) alone. */ export declare function excludeRunScopeFromGit(gitRoot: string): void; /** * Strip the marked scope block added by `excludeRunScopeFromGit`. Removes the * block ONLY - every other line is preserved byte-for-byte. Safe to call when * no scopes remain; also restores the file to zero-length difference when the * block was the only addition. */ export declare function unexcludeRunScopeFromGit(gitRoot: string): void; /** * Reap crash-leftover scopes: `/.teamshare-runs/*` with no live * harness record. A scope whose `scopeDir` is still claimed by * `~/.teamshare/sessions/harness-*.json` is SKIPPED - a question pause, an * idle kill or a stop-in-flight resume reuses the same tree. */ export declare function sweepStaleScopes(projectRoots: string[]): string[];