/**
 * Renders the `## Entry Types` section injected into the agent system prompt.
 *
 * Consumers (orchestrator.ts, cli/commands/start.ts) replace the
 * `{{ENTITY_TYPES}}` placeholder in system.md with the output of this function.
 *
 * The agent now has the full curated catalog available at all times. The
 * "basic" vs "show more" distinction is a UI concern in the New Entry
 * picker, not a creation-permission gate. Workspace-defined custom types
 * (via schema_extensions) are appended after the canonical list.
 */
import { CURATED_ENTITY_TYPES, CURATED_ENTITY_TYPE_DESCRIPTIONS, DEFAULT_BASIC_ENTITY_TYPES, isCuratedEntityType, } from '../../core/entity-types-catalog.js';
export function renderEntityTypesSection(options = {}) {
    const lines = [];
    lines.push('## Entry Types');
    lines.push('');
    // `asset` is canonical and surfaces in the catalog so the agent can read,
    // search, and link to existing asset entries — but it's filtered out of
    // the create_entity-creatable list because asset entries require a binary
    // blob in the storage backend, which create_entity can't materialize.
    // See `getAgentAllowedEntityTypes` below.
    const creatableTypes = CURATED_ENTITY_TYPES.filter(t => t !== 'asset');
    lines.push(`You have access to ${creatableTypes.length} canonical entry types via create_entity. ` +
        `Any type can live in any folder. Use the most specific type that fits — ` +
        `don't collapse a deck into a document, or a service into a note, just ` +
        `because they're simpler.`);
    lines.push('');
    for (const type of creatableTypes) {
        lines.push(`- \`${type}\`: ${CURATED_ENTITY_TYPE_DESCRIPTIONS[type]}`);
    }
    // Asset is documented separately so the agent knows what asset entries
    // ARE (for read/search/link purposes) without being tempted to call
    // create_entity for them.
    lines.push('');
    lines.push('**Asset entries:** there is also a canonical `asset` entry type for ' +
        'hosted binaries (images, video, audio, PDFs, spreadsheets, and other ' +
        'opaque files). You can list, search, link to, and read existing asset ' +
        'entries — but they cannot be created via `create_entity` because they ' +
        'require a binary in the storage backend. Use the `import_file` tool ' +
        'with a local file path to create one, or ask the user to upload via ' +
        'the workspace UI.');
    const customTypes = (options.customTypes ?? []).filter(t => t && t.trim().length > 0 && !isCuratedEntityType(t));
    if (customTypes.length > 0) {
        lines.push('');
        lines.push('**Custom types defined in this workspace:**');
        for (const type of customTypes) {
            lines.push(`- \`${type}\``);
        }
    }
    lines.push('');
    lines.push('**Defaulting and suggestion flow:**');
    lines.push('- For freeform captured content with no obvious fit, use `note`.');
    lines.push('- If the captured content clearly matches a more specific canonical type ' +
        '(for example the user describes a meeting/workshop/call, a decision, a deal, a deck, or a deliverable), ' +
        'ask once before creating: *"This looks like a meeting — want me to save it as an Event entry?"* ' +
        'If the user accepts, create it as that type. (Meetings, calls, workshops, reviews, etc. all use `event` with the appropriate `type` value.)');
    lines.push(`- The "basic" tier in the user-facing picker starts with ${DEFAULT_BASIC_ENTITY_TYPES.join(', ')}, ` +
        'but you are not restricted to that subset — use whichever canonical type fits.');
    return lines.join('\n');
}
/**
 * List of entity type names the agent is allowed to create in a given
 * workspace: the full canonical catalog plus any custom workspace types.
 * Used for tool-schema enum construction and runtime guard checks.
 *
 * `asset` is intentionally excluded. Asset entities are bound to a binary
 * blob in the storage backend (R2 or local volume) plus an `asset_url` and
 * (for PDFs) a text sidecar. `create_entity` only writes markdown
 * frontmatter — it can't materialize the binary or sidecar, so accepting
 * `asset` would let an LLM (via prompt injection) create stub entities
 * with attacker-controlled `asset_url` values. Use `import_file` (with a
 * real file path) or the upload routes instead.
 *
 * `comment` is also excluded. Comments are SQLite-backed virtual entities
 * exposed through the MCP virtual-entity adapter; they're created via the
 * comments API (`POST /api/comments/...`), not via `create_entity`. A
 * file-backed comment markdown entry would never appear in the rail or
 * the notifications dropdown.
 */
export function getAgentAllowedEntityTypes(customTypes = []) {
    const unique = new Set(CURATED_ENTITY_TYPES);
    for (const t of customTypes) {
        if (t && t.trim().length > 0)
            unique.add(t);
    }
    unique.delete('asset');
    unique.delete('comment');
    return Array.from(unique);
}
//# sourceMappingURL=entity-types-section.js.map