/** * Resolve the effective backgroundSessions value with full precedence: * TEAMSHARE_BACKGROUND env > agent setting > machine config > default true. * An explicit `false` from the agent always means "visible terminal" (opt-out * to the old behavior). Everything else is silent. */ export declare function resolveBackground(setting?: boolean | null): boolean; /** Session output capture + diagnostics live here. */ export declare const SESSIONS_DIR: string; /** * Identity carried into spawned sessions so PATH shims (npm/git wrappers) * can attribute locks + pings to the right agent/task. */ export interface SessionIdentity { agentId?: string; kind?: string; taskId?: string; projectId?: string; /** * AgentMention id (2026-09) for a mention wake. Exported as * TS_MENTION_ID so the session can CLOSE the mention when it is done - * the daemon CLAIMED it before spawning, which is what stops a duplicate * session (and therefore a duplicate reply). */ mentionId?: string; /** * EVERY mention this session owes an answer for (2026-10). Exported as * TS_MENTION_IDS so the session closes all of them. * * One run can carry several: a lane coalesces, so five @mentions on one task * are one wake holding five obligations. Closing only `mentionId` left the * other four rows `triggered` and invisible to every answerable view. */ mentionIds?: string[]; /** Multi-repo: JSON map of repo name -> path for the project. */ repoMap?: Record; /** * This session must not write to the working tree (2026-10). * * Exported as `TS_READ_ONLY=1`, which makes the arbitration shims REFUSE every * mutating command (`shim-runner.ts` -> `classify.ts#readOnlyRefusal`) instead * of queueing it. Set for planning passes, which persist their deliverable over * MCP and read the tree — and which are therefore allowed to share a folder * with anything else (`NON_BLOCKING_PRESENCE_KINDS`). * * Separate from `kind` on purpose: `kind` stays `'task'` for a plan pass * because `stop-save.ts` recovers the task id from `lock.kind === 'task'`, so * changing it would break stop-work's progress save. */ readOnly?: boolean; } /** * Identity env for a spawned session (exported so the task-linked chat * contract - `TS_TASK_ID` + `TEAMSHARE_REPO_MAP` - can be verified directly). */ export declare function identityEnv(identity?: SessionIdentity): Record; /** Phase D session settings (from the redeem response / join ack). */ export interface SessionSettings { model?: string | null; temperature?: number | null; maxTokens?: number | null; systemPrompt?: string | null; /** Server-side session driver (auto | opencode | claude | openrouter | none). */ harness?: 'auto' | 'opencode' | 'claude' | 'codex' | 'gemini' | 'antigravity' | 'copilot' | 'goose' | 'openhands' | 'aider' | 'cline' | 'openrouter' | 'none' | null; /** * Bridge wake dedupe cooldown (seconds; null = bridge defaults: 5 min * generic wakes, 30 min task/build wakes). */ wakeCooldownSec?: number | null; /** Daily window when wakes are ignored ({ start, end } "HH:MM"). */ quietHours?: { start: string; end: string; } | null; /** * BYOK provider key (key-authenticated settings only). Never passed as a * CLI flag (process-list leakage) - the spawned CLI fetches it itself. */ providerKey?: string | null; /** Run sessions as detached background processes (no visible terminal). */ backgroundSessions?: boolean | null; /** Agent's default working folder (per-agent linked folder). */ folderPath?: string | null; /** The human user who owns this agent (for per-user folder link resolution). */ userId?: string | null; } /** argv-safe equivalent of settingsFlags (headless fallback). */ export declare function settingsArgs(settings?: SessionSettings | null): string[]; /** Translates agent settings into CLI flags; systemPrompt goes to a temp file. */ export declare function settingsFlags(settings?: SessionSettings | null): string; /** * Shared VBS-hidden launch (Windows only). wscript.exe is a GUI-subsystem * binary — `detached` on it creates no console (zero flash) — and its * `sh.Run("node ...", 0, True)` creates the node console SW_HIDE from birth * while wscript stays alive as the parent (survival past the spawner). * This is the only Windows primitive that gives BOTH no-visible-window AND * survives-parent-exit: detached:true forces a visible console, and no- * detached dies with the parent (both empirically verified). */ export declare function launchHiddenVbs(spec: { argv: string[]; capture?: string; /** Capture stderr only (see hidden-launch.ts). Used by the daemon launch log. */ stderrOnly?: boolean; cwd?: string; env?: NodeJS.ProcessEnv; vbsPath: string; }): void; /** * Opens a terminal with a readable message when the CLI binary is missing * (stale checkout without `npm run build`) - instead of a flash-close that * shows nothing. Also used by the daemon/protocol guard to explain that a * project needs a linked folder before an agent will work on it. * * When `silent` is true the message goes to the daemon log only (no popup). */ export declare function openErrorTerminal(message: string, silent?: boolean): void; /** Task session: `teamshare-agent run [--task ] ...`. */ export declare function spawnAgentSession(agentId: string, apiKey: string, taskId: string, settings?: SessionSettings | null, sessionId?: string, cwd?: string, repoMap?: Record, manual?: boolean, mentionId?: string, mentionIds?: string[]): void; /** Chat-reply session: `teamshare-agent chat --project --mention ...`. */ export declare function spawnChatSession(agentId: string, apiKey: string, projectId: string, mentionToken: string, settings?: SessionSettings | null, sessionId?: string, cwd?: string, targetId?: string, /** AgentMention id (2026-09) - closed by the session when the reply is posted. */ mentionId?: string, /** * Task-linked chat (2026-09): `references[].type==='task'` from the wake. * Passed as `--task` (and TS_TASK_ID) so the CLI runs the standard run.ts * git flow - stash, task branch, finalize, stash pop - instead of working * on whatever branch is checked out. */ taskId?: string, /** Multi-repo: name -> path map of the project's linked git repos. */ repoMap?: Record, /** Every mention this session owes an answer for (2026-10). */ mentionIds?: string[], /** * Chat channel this session must read from and reply in (2026-10). * * Dropped on the floor before: the wake carries `channelId`, but nothing * forwarded it, so the CLI ran project-scoped and the server defaulted every * read AND every post to General. A mention in any other channel could * neither be found ("Message not found in this channel") nor answered in * place - the notice landed in General instead. Passed as `--channel`. */ channelId?: string): void; /** Document-assistant session (Phase F): `teamshare-agent doc --document ...`. */ export declare function spawnDocumentSession(agentId: string, apiKey: string, documentId: string, mentionToken: string, settings?: SessionSettings | null, sessionId?: string, cwd?: string, /** IMP-9xx: waking comment id - scopes the reply loop to just that comment. */ commentId?: string, /** AgentMention id (2026-09) - closed by the session when the reply is posted. */ mentionId?: string, /** Project the mention belongs to (recorded on the identity). */ projectId?: string, /** Every mention this session owes an answer for (2026-10). */ mentionIds?: string[]): void; /** Workflow-authoring session (2026-10): `teamshare-agent workflow-author --workflow ...`. */ export declare function spawnWorkflowAuthorSession(agentId: string, apiKey: string, workflowId: string, mentionToken: string, settings?: SessionSettings | null, sessionId?: string, projectId?: string, commentId?: string, /** AgentMention id (2026-09) - closed by the session when the reply is posted. */ mentionId?: string, /** Every mention this session owes an answer for (2026-10). */ mentionIds?: string[]): void; /** Board-assistant session (P5): `teamshare-agent board --board ...`. */ export declare function spawnBoardSession(agentId: string, apiKey: string, boardId: string, mentionToken: string, settings?: SessionSettings | null, sessionId?: string, cwd?: string, commentId?: string, /** AgentMention id (2026-09) - closed by the session when the reply is posted. */ mentionId?: string, /** Project the mention belongs to (recorded on the identity). */ projectId?: string, /** Every mention this session owes an answer for (2026-10). */ mentionIds?: string[]): void; /** Build session (IMP-700): `teamshare-agent build --project ...`. */ export declare function spawnBuildSession(agentId: string, apiKey: string, projectId: string, settings?: SessionSettings | null, sessionId?: string, cwd?: string): void; /** Research / data-collection session: `teamshare-agent research --run ...`. */ export declare function spawnResearchSession(agentId: string, apiKey: string, projectId: string, runId: string, toolKey: string, settings?: SessionSettings | null, sessionId?: string, cwd?: string): void; /** * Blog session (IMP-9xx): `teamshare-agent blog --generation ...`. * * Writes/refines a blog draft. Runs the agent's harness on THIS machine, which * is the whole point: the old flow called an LLM from the server, so it needed a * provider key on the server (agents without one hit `NO_LLM_KEY`) and the human * sat behind a blocking HTTP call for up to 60s. Now the hub only wakes us; the * session fetches the brief, runs the harness, renders any charts locally and * posts the finished post back through `POST /blog/generations/:id/complete`. * * `projectId`/`cwd` are optional on purpose - a blog run needs no repository, * so a project-less run simply executes headless instead of being blocked by the * linked-folder guard (see the `blog.generate` branch in wake-handler.ts). */ export declare function spawnBlogSession(agentId: string, apiKey: string, generationId: string, projectId?: string, settings?: SessionSettings | null, sessionId?: string, cwd?: string): void; /** * Insights harness (2026-10): `teamshare-agent insight --run ...`. * * Narrates frozen deterministic facts via the build agent's harness on THIS * machine - no server-side provider key needed. Runs headless (no repo, no * mirror); the only artefact is the delivered narrative JSON. */ export declare function spawnInsightSession(agentId: string, apiKey: string, runId: string, projectId?: string, settings?: SessionSettings | null, sessionId?: string, cwd?: string): void; /** * Custom workflow (2026-10): `teamshare-agent workflow --run ...`. * * Executes a user-authored workflow via the assigned agent's harness on THIS * machine - no server-side provider key needed. Folder-isolated runs work in * the linked folder (operational workflows that call APIs); mirror-isolated * runs work in a private worktree + branch + PR (workflows that edit the * repo). The only artefacts are the run's deliverables, posted back through * `POST /workflows/runs/:id/complete`. */ export declare function spawnWorkflowSession(agentId: string, apiKey: string, runId: string, projectId?: string, settings?: SessionSettings | null, sessionId?: string, cwd?: string): void; /** * Document job: `teamshare-agent doc-job --project ...` - a deterministic * LibreOffice conversion for the document editing pipeline (no LLM involved). * Runs in its own process so a WASM crash cannot take the daemon down. */ export declare function spawnDocJobSession(agentId: string, apiKey: string, projectId: string | undefined, jobId: string, settings?: SessionSettings | null, sessionId?: string): void; /** Plan pass: `teamshare-agent plan --task ...` (enrich, never execute). */ export declare function spawnPlanSession(agentId: string, apiKey: string, taskId: string, projectId?: string, settings?: SessionSettings | null, sessionId?: string, cwd?: string, opts?: { auto?: boolean; mentionId?: string; /** Every mention this planning pass owes an answer for (2026-10). */ mentionIds?: string[]; manual?: boolean; }): void; /** IMP-810: Worker session: `teamshare-agent worker --once --agent ...`. */ export declare function spawnWorkerSession(agentId: string, apiKey: string, _taskId: string, _orchestratorTaskId?: string, settings?: SessionSettings | null, sessionId?: string, cwd?: string, repoMap?: Record): void; /** Planner session: `teamshare-agent planner --project --task --agent ...`. */ export declare function spawnPlannerSession(agentId: string, apiKey: string, projectId: string, parentTaskId: string, description: string, settings?: SessionSettings | null, sessionId?: string, cwd?: string): { sid: string; command: string; argv: string[]; capture: string; background: boolean; };