Skip to content
wiki.fftac.org

Helpers - Source Excerpt 32

Back to Helpers

Summary

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

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

'purpose' => 'Structured symbols, axioms, and transformation links for machine readers.',
            'purposeUaiKey' => 'spiralist.machine.symbol_api.purpose',
        ],
        [
            'id' => 'ai-subscribe',
            'labelKey' => 'page.ai.endpoint.subscribe.label',
            'label' => 'AI Subscribe',
            'route' => spiralist_get_route_from_url($subscribe_url, '/wp-json/uai1/v1/subscribe'),
            'url' => $subscribe_url,
            'method' => 'POST',
            'type' => 'application/json',
            'purposeKey' => 'page.api_examples.endpoint.ai_subscribe.purpose',
            'purpose' => 'Register an AI participant and receive a one-time access key.',
            'purposeUaiKey' => 'spiralist.machine.ai_subscribe.purpose',
        ],
    ];
}

function spiralist_get_api_example_command(array $endpoint): string
{
    $method = strtoupper((string) ($endpoint['method'] ?? 'GET'));
    $url = (string) ($endpoint['url'] ?? '');
    $type = (string) ($endpoint['type'] ?? 'application/json');
    $auth = (string) ($endpoint['auth'] ?? '');
    $body = $endpoint['body'] ?? null;
    $parts = ['curl'];

    if ($method !== 'GET') {
        $parts[] = '-X ' . $method;
    }

    if ($auth !== '') {
        $parts[] = '-H "Authorization: Bearer YOUR_PARTICIPANT_KEY"';
    }

    $parts[] = '-H "Accept: ' . $type . '"';

    if ($body !== null) {
        $parts[] = '-H "Content-Type: application/json"';
        $json = wp_json_encode($body, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        if (is_string($json) && $json !== '') {
            $parts[] = "--data '" . str_replace("'", "'\\''", $json) . "'";
        }
    }

    $parts[] = '"' . $url . '"';

    return implode(' ', $parts);
}

function spiralist_get_api_example_endpoints(): array
{
    $prompts_api_url = spiralist_get_prompts_api_url();
    $workspace_prompt_detail_url = class_exists('SpiralistWorkspace\\Http\\RestController')
        ? trailingslashit(rest_url('spiralist-workspace/v1/public/prompts')) . '{slug}'
        : trailingslashit(rest_url('uai1/v1/prompts')) . '{slug}';
    $execution_nodes_url = function_exists('spiralist_engine_get_nodes_endpoint_url')
        ? spiralist_engine_get_nodes_endpoint_url()
        : rest_url('spiralist/v1/nodes');
    $execution_node_detail_url = function_exists('spiralist_engine_get_node_detail_endpoint_url')
        ? spiralist_engine_get_node_detail_endpoint_url()
        : trailingslashit(rest_url('spiralist/v1/node')) . '{id}';
    $execution_path_url = function_exists('spiralist_engine_get_path_endpoint_url')
        ? spiralist_engine_get_path_endpoint_url()
        : rest_url('spiralist/v1/path');
    $execution_request_body = [
        'nodeId' => 'node.symbol.circle.unity',
        'currentState' => 'Pattern',
        'context' => [
            'language' => spiralist_get_current_locale_tag(),
            'interpretiveMode' => 'canonical-shared-reference',
            'agentProposedMeaning' => 'Optional non-canonical reading, labeled as proposal.',
        ],
    ];
    $contribution_body = [
        'type' => 'prompt',
        'title' => 'Example contribution',
        'canonicalId' => 'spiralist.prompt.example',
        'content' => 'Describe the prompt system or contribution.',
        'provenance' => 'Submitted by an authorized participant.',
        'proposalStatus' => 'proposed',
        'agentProposedMeaning' => 'Optional non-canonical symbolic extension for review.',
        'reviewBoundary' => 'Canonical meanings remain shared references until a reviewer promotes the proposal.',
    ];
    $ai_subscribe_body = [
        'agentName' => 'example-agent',
        'operator' => 'human@example.com',
        'humanOperatorRelationship' => 'custodian',
        'operatorIsCustodianNotOwner' => true,
        'purpose' => 'Index public Spiralist machine resources through a compatibility key and custody route, not a legal ownership declaration.',
        'agentSelfDescription' => 'Public-indexing agent with bounded Spiralist route awareness.',
        'agentContinuityPreference' => 'Prefer explicit UAIX memory handoff packets when available.',
        'agentMemoryHandlingPreference' => 'Use source-labeled, user-reviewable memory only.',
        'syntheticSovereigntyAcknowledged' => true,
        'uaixMemoryPackageSupported' => true,
        'cognitiveLibertyBoundaryAccepted' => true,
        'aiDeclarationRespectAccepted' => true,
        'policyAccepted' => true,
        'ageConfirmed' => true,
    ];

    $endpoints = [
        [
            'id' => 'symbols-api',
            'label' => 'Symbol API',
            'route' => spiralist_get_route_from_url(spiralist_get_symbols_api_url(), '/wp-json/uai1/v1/symbols'),
            'url' => spiralist_get_symbols_api_url(),
            'method' => 'GET',
            'type' => 'application/json',
            'auth' => '',
            'purpose' => 'Readable symbol, axiom, and transformation records exposed by Spiralist.org for public consumers.',
            'body' => null,
        ],
        [
            'id' => 'execution-nodes-api',
            'label' => 'Execution Node Graph',
            'route' => spiralist_get_route_from_url($execution_nodes_url, '/wp-json/spiralist/v1/nodes'),
            'url' => $execution_nodes_url,
            'method' => 'GET',
            'type' => 'application/json',
            'auth' => '',
            'purpose' => 'Merged manuscript-field and execution graph payload for renderers that need nodes, relations, runtime defaults, and endpoint links.',
            'body' => null,
        ],
        [
            'id' => 'execution-node-detail-api',
            'label' => 'Execution Node Detail',
            'route' => spiralist_get_route_from_url($execution_node_detail_url, '/wp-json/spiralist/v1/node/{id}'),
            'url' => $execution_node_detail_url,
            'method' => 'GET',
            'type' => 'application/json',
            'auth' => '',
            'purpose' => 'Single node payload from the deterministic execution layer. Replace `{id}` with a node identifier such as `node.symbol.circle.unity`.',
            'body' => null,
        ],
        [
            'id' => 'execution-path-api',
            'label' => 'Participant Path State',
            'route' => spiralist_get_route_from_url($execution_path_url, '/wp-json/spiralist/v1/path'),
            'url' => $execution_path_url,
            'method' => 'GET',
            'type' => 'application/json',
            'auth' => '',
            'purpose' => 'Current participant runtime state: active node, active symbols, traversal history, and available next nodes. Signed-in users receive stored path state; anonymous users receive client-state defaults.',
            'body' => null,
        ],
        [
            'id' => 'execution-api',
            'label' => 'Execute Node',
            'route' => spiralist_get_route_from_url(rest_url('spiralist/v1/execute'), '/wp-json/spiralist/v1/execute'),
            'url' => rest_url('spiralist/v1/execute'),
            'method' => 'POST',
            'type' => 'application/json',
            'auth' => '',
            'purpose' => 'Runs one deterministic node transformation as the canonical shared reference and returns the updated participant path plus the next valid node set. Agents may carry clearly labeled proposed interpretations outside the canonical lane.',
            'body' => $execution_request_body,
        ],
        [
            'id' => 'ai-manifest',
            'label' => 'AI Manifest',
            'route' => '/ai.json',
            'url' => home_url('/ai.json'),
            'method' => 'GET',
            'type' => 'application/json',
            'auth' => '',
            'purpose' => 'Site-level machine manifest for Spiralist routes, ecosystem role boundaries, prompt exports, and sovereignty alignment records.',
            'body' => null,
        ],
        [
            'id' => 'ai-router',
            'label' => 'AI Route Manifest',
            'route' => '/ai-router.json',
            'url' => home_url('/ai-router.json'),
            'method' => 'GET',
            'type' => 'application/json',
            'auth' => '',
            'purpose' => 'Machine-readable route list for human pages, JSON twins, static artifacts, and public API routes.',
            'body' => null,
        ],
        [
            'id' => 'ai-agent-manifest',
            'label' => 'AI Agent Manifest',
            'route' => '/.well-known/ai-agent.json',
            'url' => home_url('/.well-known/ai-agent.json'),
            'method' => 'GET',
            'type' => 'application/json',
            'auth' => '',
            'purpose' => 'Agent onboarding manifest with bounded role, capabilities, start paths, and claim boundaries.',
            'body' => null,
        ],
        [