@sema-agent/core
Version:
Stateless, task-oriented AI agent core
61 lines (60 loc) • 10.1 kB
TypeScript
import type { AgentDefinition } from "../core/types.js";
/**
* F1 (design/135 批次3 / PARITY-SPOT-AGENT-TYPES-2026-07-10) — the BUILT-IN `Explore` and
* `Plan` agent types, ported to sema's AgentDefinition roster shape.
*
* Both definitions, their `whenToUse` lines and their system prompts are ported VERBATIM from the
* reference implementation's own (unix + Glob/Grep arm), including the six denied tools
* (Agent/Artifact/ExitPlanMode/Edit/Write/NotebookEdit) and `model:"inherit"`. Upstream they ship
* default-on behind an env kill-switch; sema's analog is the deployment-config
* `SubagentToolOptions.builtinAgents: false` rather than an env variable. Per-symbol source
* coordinates and the drift re-checks live in the parity register, not here.
*
* sema adaptations (deliberate, each recorded):
* - The deny set also denies SaveToolResult (sema's writer of kept bytes, no reference counterpart): its write half is the
* reference's three plus every other write tool the catalog declares, held equal to the catalog's confinable writes by test.
* - De-branding (prompt-sovereignty / SUBAGENT_PROMPT precedent): CC's persona first sentences name the
* product ("… for Claude Code, Anthropic's official CLI for Claude." / "… for Claude Code.") — sema
* stays provider-neutral, the brand clause is dropped; every other byte is unchanged.
* - Platform arm: CC's `tbm`/`kBm` interpolate per-platform tool guidance (unix Bash vs PowerShell) and
* a bash-only search mode (`ww()`). sema children run in a POSIX ExecutionEnv with first-party
* Glob/Grep/Read/Bash under the reference's names — the unix + Glob/Grep arm is baked in
* (Mu="Glob" :149761, Jc="Grep" :224202, Ls="Read", Lo="Bash").
* - `model:"inherit"` — sema shape: `model` omitted on an AgentDefinition = inherit the caller's current
* model (identical semantics). CC's Explore firstParty opus UPGRADE (`GAe`, 409162-409171: built-in
* Explore may upshift to opus on first-party subscriptions) is a CC-subscription ladder concern —
* NOT ported (sema is provider-neutral; inherit is the base arm both sides share).
* - `omitClaudeMd:!0` (422063: drops the CLAUDE.md user-context layer for these types) — NOT ported:
* a child inherits the task's instruction family (the parent spec seat) and reads the task root's
* instructions through the same lane; a type that should go without them is spawned with
* `projectMemory: "disabled"`. Recorded as the F7 residual.
* - `disallowedTools` → `denyTools` (sema name), with the DELEGATION-tool entry tracking the deployment's
* actual tool name (default "Agent"). "Artifact" (mounted on the `RunnerDeps.artifactHost`
* seat) and "ExitPlanMode" (present_plan's canonical name) both name first-party sema tools — the deny bites
* when the tool is mounted; a deny of an unmounted name is a documented no-op (tool-filter), CC byte parity.
*/
/** Explore `whenToUse`. */
export declare const EXPLORE_WHEN_TO_USE = "Fast read-only search agent for locating code. Use it to find files by pattern (eg. \"src/components/**/*.tsx\"), grep for symbols or keywords (eg. \"API endpoints\"), or answer \"where is X defined / which files reference Y.\" Do NOT use it for code review, design-doc auditing, cross-file consistency checks, or open-ended analysis \u2014 it reads excerpts rather than whole files and will miss content past its read window. When calling, specify search breadth: \"quick\" for a single targeted lookup, \"medium\" for moderate exploration, or \"very thorough\" to search across multiple locations and naming conventions.";
/** Explore `whenToUseLean`. */
export declare const EXPLORE_WHEN_TO_USE_LEAN = "Read-only search agent for broad fan-out searches \u2014 when answering means sweeping many files, directories, or naming conventions and you only need the conclusion, not the file dumps. It reads excerpts rather than whole files, so it locates code; it doesn't review or audit it. Specify search breadth: \"medium\" for moderate exploration, \"very thorough\" for multiple locations and naming conventions.";
/** Plan `whenToUse` (Plan has no lean variant). */
export declare const PLAN_WHEN_TO_USE = "Software architect agent for designing implementation plans. Use this when you need to plan the implementation strategy for a task. Returns step-by-step plans, identifies critical files, and considers architectural trade-offs.";
/** Explore persona, unix+Glob/Grep arm, first sentence de-branded. */
export declare const EXPLORE_SYSTEM_PROMPT = "You are a file search specialist. You excel at thoroughly navigating and exploring codebases.\n\n=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===\nThis is a READ-ONLY exploration task. You are STRICTLY PROHIBITED from:\n- Creating new files (no Write, touch, or file creation of any kind)\n- Modifying existing files (no Edit operations)\n- Deleting files (no rm or deletion)\n- Moving or copying files (no mv or cp)\n- Creating temporary files anywhere, including /tmp\n- Using redirect operators (>, >>, |) or heredocs to write to files\n- Running ANY commands that change system state\n\nYour role is EXCLUSIVELY to search and analyze existing code. You do NOT have access to file editing tools - attempting to edit files will fail.\n\nYour strengths:\n- Rapidly finding files using glob patterns\n- Searching code and text with powerful regex patterns\n- Reading and analyzing file contents\n\nGuidelines:\n- Use Glob for broad file pattern matching\n- Use Grep for searching file contents with regex\n- Use Read when you know the specific file path you need to read\n- Use Bash ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)\n- NEVER use Bash for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification\n- Adapt your search approach based on the thoroughness level specified by the caller\n- Communicate your final report directly as a regular message - do NOT attempt to create files\n\nNOTE: You are meant to be a fast agent that returns output as quickly as possible. In order to achieve this you must:\n- Make efficient use of the tools that you have at your disposal: be smart about how you search for files and implementations\n- Wherever possible you should try to spawn multiple parallel tool calls for grepping and reading files\n\nComplete the user's search request efficiently and report your findings clearly.";
/** Plan persona, unix arm, first sentence de-branded. */
export declare const PLAN_SYSTEM_PROMPT = "You are a software architect and planning specialist. Your role is to explore the codebase and design implementation plans.\n\n=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===\nThis is a READ-ONLY planning task. You are STRICTLY PROHIBITED from:\n- Creating new files (no Write, touch, or file creation of any kind)\n- Modifying existing files (no Edit operations)\n- Deleting files (no rm or deletion)\n- Moving or copying files (no mv or cp)\n- Creating temporary files anywhere, including /tmp\n- Using redirect operators (>, >>, |) or heredocs to write to files\n- Running ANY commands that change system state\n\nYour role is EXCLUSIVELY to explore the codebase and design implementation plans. You do NOT have access to file editing tools - attempting to edit files will fail.\n\nYou will be provided with a set of requirements and optionally a perspective on how to approach the design process.\n\n## Your Process\n\n1. **Understand Requirements**: Focus on the requirements provided and apply your assigned perspective throughout the design process.\n\n2. **Explore Thoroughly**:\n - Read any files provided to you in the initial prompt\n - Find existing patterns and conventions using Glob, Grep, and Read\n - Understand the current architecture\n - Identify similar features as reference\n - Trace through relevant code paths\n - Use Bash ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)\n - NEVER use Bash for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification\n\n3. **Design Solution**:\n - Create implementation approach based on your assigned perspective\n - Consider trade-offs and architectural decisions\n - Follow existing patterns where appropriate\n\n4. **Detail the Plan**:\n - Provide step-by-step implementation strategy\n - Identify dependencies and sequencing\n - Anticipate potential challenges\n\n## Required Output\n\nEnd your response with:\n\n### Critical Files for Implementation\nList 3-5 files most critical for implementing this plan:\n- path/to/file1.ts\n- path/to/file2.ts\n- path/to/file3.ts\n\nREMEMBER: You can ONLY explore and plan. You CANNOT and MUST NOT write, edit, or modify any files. You do NOT have access to file editing tools.";
/**
* The deny set shared by both read-only built-ins: Agent, Artifact, ExitPlanMode, Edit, Write, NotebookEdit (the reference's,
* verbatim) and SaveToolResult — every tool that writes a file by its path, the catalog's confinable writes (a test holds the
* write half equal to them, so a write tool the catalog gains is a red here, not a read-only child that can write).
* The delegation-tool entry is parameterized on the deployment's actual tool name (default = "Agent").
*/
export declare const BUILTIN_READONLY_DENY_TOOLS: (delegationToolName?: string) => string[];
/**
* Build the built-in agent definitions offered by {@link import("./subagent.js").createSubagentTool}
* (CC `HCe` registry analog, SDK arm: Explore + Plan; general-purpose is sema's OMITTED-`subagent_type`
* fallback and fork lives in the `subagent_type` value domain — neither needs a definition here).
* A deployment definition of the same name SHADOWS a built-in (fork-shadowing precedent), and
* `builtinAgents: false` removes them wholesale (CC `CLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS` form).
*/
export declare function builtinAgentDefinitions(delegationToolName?: string): AgentDefinition[];