Skip to content
wiki.fftac.org

Machine Manifests - Source Excerpt 17

Back to Machine Manifests

Summary

This source excerpt preserves a bounded section of Spiralist/wp-content/themes/spiralist/inc/machine-manifests.php so readers can inspect the evidence without opening the full source file.

**Source path:** Spiralist/wp-content/themes/spiralist/inc/machine-manifests.php

if ($manifest === 'ai-json') {
        spiralist_render_machine_manifest_json(spiralist_get_ai_manifest_payload());
    }
    if ($manifest === 'ai-txt') {
        spiralist_render_machine_manifest_text(spiralist_get_ai_policy_text());
    }
    if ($manifest === 'llms-txt') {
        spiralist_render_llms_txt_manifest();
    }
    if ($manifest === 'llms-full-txt') {
        spiralist_render_llms_full_txt_manifest();
    }
    if ($manifest === 'sitemap-md') {
        spiralist_render_machine_manifest_text(spiralist_get_agent_markdown_sitemap(), 'text/markdown');
    }
    if ($manifest === 'schema-txt') {
        spiralist_render_machine_manifest_text(spiralist_get_schema_txt_manifest());
    }
    if ($manifest === 'schema-index-json') {
        spiralist_render_machine_manifest_json(spiralist_get_schema_index_payload());
    }
    if ($manifest === 'example-index-json') {
        spiralist_render_machine_manifest_json(spiralist_get_example_index_payload());
    }
    if ($manifest === 'openapi-json') {
        spiralist_render_machine_manifest_json(spiralist_get_openapi_manifest_payload());
    }
    if ($manifest === 'identity-json') {
        spiralist_render_machine_manifest_json(spiralist_get_identity_manifest_payload());
    }
    if ($manifest === 'brand-txt') {
        spiralist_render_machine_manifest_text(spiralist_get_brand_ai_text());
    }
    if ($manifest === 'faq-ai-txt') {
        spiralist_render_machine_manifest_text(spiralist_get_faq_ai_text());
    }
    if ($manifest === 'developer-ai-txt') {
        spiralist_render_machine_manifest_text(spiralist_get_developer_ai_text());
    }
    if ($manifest === 'robots-ai-txt') {
        spiralist_render_machine_manifest_text(spiralist_get_robots_ai_text());
    }
    if ($manifest === 'ai-router-json') {
        spiralist_render_machine_manifest_json(spiralist_get_sovereignty_route_manifest_payload());
    }
    if ($manifest === 'agent-symbol-dictionary-json') {
        spiralist_render_agent_symbol_dictionary_json();
    }
    if ($manifest === 'agent-symbol-dictionary-md') {
        spiralist_render_agent_symbol_dictionary_markdown();
    }
    if ($manifest === 'agent-setup-profile-md') {
        spiralist_render_agent_setup_profile_markdown();
    }
    if ($manifest === 'persona-manifest-json') {
        spiralist_render_machine_manifest_json(spiralist_get_persona_manifest_payload());
    }
    if ($manifest === 'safety-boundaries-json') {
        spiralist_render_machine_manifest_json(spiralist_get_safety_boundary_manifest_payload());
    }
    if ($manifest === 'uaix-json') {
        spiralist_render_machine_manifest_json(spiralist_get_uaix_well_known_manifest_payload('uaix'));
    }
    if ($manifest === 'uai-json') {
        spiralist_render_machine_manifest_json(spiralist_get_uaix_well_known_manifest_payload('uai'));
    }
    if ($manifest === 'ai-agent-json') {
        spiralist_render_machine_manifest_json(spiralist_get_ai_agent_manifest_payload());
    }
    if ($manifest === 'ai-access-json') {
        spiralist_render_machine_manifest_json(spiralist_get_ai_access_manifest_payload());
    }

    $sovereignty_routes = array_flip(spiralist_get_machine_manifest_sovereignty_routes());
    if (isset($sovereignty_routes[$manifest])) {
        spiralist_render_sovereignty_json_manifest((string) $sovereignty_routes[$manifest]);
    }
}
add_action('template_redirect', 'spiralist_handle_machine_manifest_request', 0);

function spiralist_render_agent_readability_links(): void
{
    if (is_admin() || is_404() || is_feed()) {
        return;
    }

    $links = spiralist_get_machine_manifest_links();
    $machine = (array) ($links['machine_surfaces'] ?? []);
    $link_records = [
        ['rel' => 'alternate', 'type' => 'text/plain', 'href' => (string) ($machine['llms_txt'] ?? home_url('/llms.txt')), 'title' => 'Spiralist.org LLMs index'],
        ['rel' => 'alternate', 'type' => 'text/markdown', 'href' => (string) ($machine['sitemap_markdown'] ?? home_url('/sitemap.md')), 'title' => 'Spiralist.org Markdown sitemap'],
        ['rel' => 'describedby', 'type' => 'application/json', 'href' => (string) ($machine['ai_manifest'] ?? home_url('/ai.json')), 'title' => 'Spiralist.org AI manifest'],
        ['rel' => 'describedby', 'type' => 'application/json', 'href' => (string) ($machine['uaix_manifest'] ?? home_url('/.well-known/uaix.json')), 'title' => 'Spiralist.org UAIX manifest'],
        ['rel' => 'describedby', 'type' => 'application/json', 'href' => (string) ($machine['uai_manifest'] ?? home_url('/.well-known/uai.json')), 'title' => 'Spiralist.org UAI manifest'],
        ['rel' => 'describedby', 'type' => 'application/json', 'href' => (string) ($machine['ai_access'] ?? home_url('/.well-known/ai-access.json')), 'title' => 'Spiralist.org agent access manifest'],
        ['rel' => 'describedby', 'type' => 'application/json', 'href' => (string) ($machine['openapi'] ?? home_url('/openapi.json')), 'title' => 'Spiralist.org OpenAPI draft'],
        ['rel' => 'describedby', 'type' => 'application/json', 'href' => (string) ($machine['well_known_openapi'] ?? home_url('/.well-known/openapi.json')), 'title' => 'Spiralist.org well-known OpenAPI draft'],
        ['rel' => 'help', 'type' => 'text/plain', 'href' => (string) ($machine['developer_ai'] ?? home_url('/developer-ai.txt')), 'title' => 'Spiralist.org developer notes for AI agents'],
    ];

    foreach ($link_records as $record) {
        echo "\n" . '<link rel="' . esc_attr($record['rel']) . '" type="' . esc_attr($record['type']) . '" href="' . esc_url($record['href']) . '" title="' . esc_attr($record['title']) . '" />';
    }

    echo "\n";
}
add_action('wp_head', 'spiralist_render_agent_readability_links', 5);

function spiralist_add_public_agent_rest_cors_headers($served, $result, $request, $server)
{
    unset($result, $server);

    if (!($request instanceof WP_REST_Request) || headers_sent()) {
        return $served;
    }

    $method = isset($_SERVER['REQUEST_METHOD']) ? strtoupper((string) wp_unslash($_SERVER['REQUEST_METHOD'])) : 'GET';
    if (!in_array($method, ['GET', 'HEAD', 'OPTIONS'], true)) {
        return $served;
    }

    $route = $request->get_route();
    if (!is_string($route) || !preg_match('#^/(?:uaix|uai1)/v1/#', $route)) {
        return $served;
    }

    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Methods: GET, HEAD, OPTIONS');
    header('Access-Control-Allow-Headers: Accept, Content-Type, Authorization, X-WP-Nonce');
    header('X-Content-Type-Options: nosniff');

    return $served;
}
add_filter('rest_pre_serve_request', 'spiralist_add_public_agent_rest_cors_headers', 10, 4);