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; /** Filesystem-safe account id for `~/.agim-workspaces/users//`. */ export declare function sanitizeAccountWorkspaceId(userId: string): string; /** Show `~/…` when the path is inside the current home; otherwise keep absolute. */ export declare function toDisplayWorkspacePath(absPath: string): string; export type AgentWorkspaceDirOpts = { dir?: string; workspaceRoot?: string; }; /** Per-account agent cwd: `~/.agim-workspaces/users///`. */ export declare function agentCwdForAccount(agentName: string, userId: string): string; /** True for a Portal login id (`usr_*`). Ignores `web:` token/loopback ids. */ export declare function isAccountWorkspaceUserId(userId: string | undefined | null): userId is string; /** Logged-in Portal / web account id from ALS or `opts.userId` (`usr_*` only). */ export declare function accountIdForWorkspace(opts?: { userId?: string; }): string | undefined; /** * Keep a Portal `workspacePath` only when it belongs to this account. * Shared `~/.agim-workspaces//` paths from a previous login are dropped * so a new user is not pinned to the shared IM tree (or another member). * With no account, the raw path is returned unchanged (legacy IM / tests). */ export declare function bindableWorkspacePath(raw: string | undefined | null, agentName: string, accountUserId?: string): string | undefined; /** * Root shown in Agent Files. Env `AGIM__CWD` still wins; otherwise * a logged-in account gets its own tree so members cannot browse each * others' files (or the shared IM workspace). */ export declare function resolveAgentFilesRoot(agentName: string, accountUserId?: string): string; /** * Agent workspace root for role / memory / PROJECTS — not the Portal * subdirectory bound as process cwd. * * Env `AGIM__CWD` wins (same as bootstrap). Portal `workspacePath` * never moves this root: selected folders are for project file I/O only. */ export declare function resolveAgentWorkspaceRoot(agentName: string, accountUserId?: string): string; /** * Ephemeral hint when Portal binds a subdirectory as the working directory. * Project files follow `workspacePath`; AGENTS.md / MEMORY.md stay at root. */ export declare function buildPortalWorkspaceHint(agentName: string, workspacePath: string, accountUserId?: 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; workspaceRoot?: string; }): 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, opts?: AgentWorkspaceDirOpts): 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, opts?: AgentWorkspaceDirOpts): Promise; /** * Resolve the cwd to spawn an agent CLI in. * * Decision order: * 1. Env override `AGIM__CWD` always wins. * 2. Explicit Portal / web `opts.workspacePath` when it is inside this * account's tree (or any path when no account is in scope). * 3. If we're in an IM / web context (threadId + platform both present), * pin to `~/.agim-workspaces/users///` for a logged-in * account, otherwise `~/.agim-workspaces//`. * 4. Otherwise return undefined → adapter inherits agim's cwd. This * keeps 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; }, opts?: AgentWorkspaceDirOpts): 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