/**
 * 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';
import { RESERVED_ENTITY_TYPES } from '../../core/validation.js';
export function renderEntityTypesSection(options = {}) {
    const lines = [];
    lines.push('## Entry Types');
    lines.push('');
    const creatableTypes = CURATED_ENTITY_TYPES;
    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]}`);
    }
    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.
 *
 * `comment` is 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.
 *
 * `material` is NOT excluded: like `document`/`dataset` it's a general entity
 * type whose `asset_ref` (the embedded binary) is OPTIONAL and set only by
 * import. An agent-created material is a notes/catalog entry with no binary —
 * the same shape as an agent-created document (authored body, no file) — which
 * is valid, so it stays creatable.
 */
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('comment');
    // Retired types stay un-creatable even if a legacy workspace still carries a
    // `schema_extensions.<name>` for them (Phase F — `asset`).
    for (const reserved of RESERVED_ENTITY_TYPES)
        unique.delete(reserved);
    return Array.from(unique);
}
//# sourceMappingURL=entity-types-section.js.map