import type { AgentSendOpts } from './types.js'; /** Portable bgjob wrapper expression for role books / prompts. * Shell expands this to an absolute path on any user home (Linux / macOS). * Do NOT bake host-specific `/home//...` into AGENTS.md. */ export declare const AGIM_BGJOB_WRAPPER_EXPR = "\"${AGIM_HOME:-$HOME/.agim}/scripts/bgjob\""; export declare const AGIM_BGJOBS_DIR_EXPR = "${AGIM_HOME:-$HOME/.agim}/bgjobs"; export declare const AGIM_HOME_EXPR = "${AGIM_HOME:-$HOME/.agim}"; /** Root for all per-agent IM workspaces. Kept stable so memory persists. * Honors the `AGIM_WORKSPACES_ROOT` env override; otherwise resolves via * core/agim-paths. */ export declare function agimWorkspacesRoot(): string; /** Default cwd for a given agent under the workspaces root. */ export declare function defaultAgentCwd(agentName: string): string; export declare function roleFileForAgent(agentName: string): string; export declare const AGIM_MEMORY_LINK_START = ""; /** Managed IM / bgjob SOP — baseline for EVERY IM agent workspace * (Agim / Claude / opencode / Codex / …). Upserted on bootstrap into * each agent's CLAUDE.md / AGENTS.md; operator edits outside the markers * are preserved. Paths are portable shell expressions, never host-absolute. * * Upgrade policy: never rewrite the whole role file. Seed only creates * missing files; existing AGENTS.md / CLAUDE.md are patched solely inside * these markers after a content diff. Put `AGIM_IM_OPS_FREEZE` anywhere in * the file (or set AGIM_IM_OPS_REFRESH=off) to opt out of managed refresh. */ export declare const AGIM_IM_OPS_START = ""; export declare const AGIM_IM_OPS_END = ""; /** Opt-out marker: when present, bootstrap will not refresh im-ops. */ export declare const AGIM_IM_OPS_FREEZE = ""; /** Shared 「对话逻辑」block — also embedded in Agim seed above 任务执行. */ export declare function buildAgimDialogueLogicSection(): string; export declare function buildAgimImOpsBlock(agentName?: string, opts?: { includeDialogueLogic?: boolean; }): string; export type ImOpsUpsertPlan = { kind: 'skip-refresh-disabled'; } | { kind: 'skip-frozen'; } | { kind: 'skip-unchanged'; } | { kind: 'append'; next: string; } | { kind: 'patch'; next: string; changedLines: number; beforeBlock: string; afterBlock: string; }; /** * Pure planner for managed im-ops upsert. Never rewrites the whole file — * only appends a missing block, or patches the marked section when the * desired block actually differs (diff-gated). */ export declare function planImOpsUpsert(raw: string, block: string): ImOpsUpsertPlan; /** * Upsert the managed IM / bgjob SOP into an agent's role file * (AGENTS.md / CLAUDE.md). Applies to **all** IM agent workspaces. * * Safety rules (upgrade / version bump): * - Never overwrite the entire role file. * - Content outside `` is always preserved. * - Existing managed block is replaced only when a content diff exists. * - Freeze marker / AGIM_IM_OPS_REFRESH=off skips refresh entirely. */ export declare function ensureAgimImOpsGuide(agentName: string, filename?: string): Promise; /** * Migration hook for the Web-created MEMORY.md file. We preserve the user's * CLAUDE.md / AGENTS.md content and append one managed block that teaches * external CLI agents to read MEMORY.md from their pinned Agim workspace. */ export declare function ensureAgentMemoryLink(agentName: string, filename?: string): Promise; /** * Resolve the cwd to spawn an agent CLI in. * * Decision order: * 1. Env override `AGIM__CWD` always wins. * 2. If we're in an IM context (threadId + platform both present), pin to * `~/.agim-workspaces//`. * 3. Otherwise return undefined → adapter inherits agim's cwd. This * keeps web/scheduler/intent-llm judge paths exactly as they were. */ export declare function resolveAgentCwd(agentName: string, opts: AgentSendOpts): string | undefined; /** * Idempotent: create the workspace dir and seed initial CLAUDE.md / AGENTS.md * if they don't exist. * * **Existing files are NEVER overwritten** — not on version bump, not when * the packaged seed template changes. Operators may freely edit persona / * rules; only the marked im-ops block is eligible for diff-gated refresh * via `ensureAgimImOpsGuide`. * * Honors AGIM__CWD overrides — if set, we bootstrap THAT path * instead. Skips bootstrapping when the override is empty / unset and we * compute it from defaultAgentCwd; either way the resolved path is what * spawnStream will pass as cwd. */ export declare function ensureAgentWorkspace(agentName: string, seed: { filename: string; content: string; }): Promise; /** * Bootstrap the workspaces for the built-in agents we ship by default. * Safe to call multiple times. Returns a summary suitable for logging. */ export declare function bootstrapAgentWorkspaces(): Promise>; //# sourceMappingURL=agent-cwd.d.ts.map