Skip to content
wiki.fftac.org

Gateway

**Site relevance:** Spiralist.org

**Memory type:** plugin source memory

**Source path:** Spiralist/wp-content/plugins/spiralist-ai-runtime/includes/Services/Gateway.php

**Size:** 1.4 KB

Summary

namespace SpiralistAIRuntime\Services;

Source Preview

This source file is short enough to preview directly on its source-memory page.

<?php

namespace SpiralistAIRuntime\Services;

use SpiralistAIRuntime\Config\Settings;
use SpiralistAIRuntime\Domain\UserPreferences;
use SpiralistAIRuntime\Support\RuntimeBoundary;

if (!defined('ABSPATH')) {
    exit;
}

class Gateway
{
    public function __construct(Settings $settings, UserPreferences $preferences)
    {
    }

    public function create_response(array $payload, array $context = [])
    {
        return RuntimeBoundary::disabled_error();
    }

    public function redact_payload(array $payload): array
    {
        array_walk_recursive(
            $payload,
            static function (&$value, $key): void {
                if (!is_scalar($value)) {
                    return;
                }

                $string_value = (string) $value;
                $normalized_key = strtolower((string) $key);

                if (
                    $normalized_key === 'authorization' ||
                    strpos($normalized_key, 'secret') !== false ||
                    strpos($normalized_key, 'token') !== false ||
                    strpos($normalized_key, 'credential') !== false
                ) {
                    $value = '[redacted]';
                    return;
                }

                if (strlen($string_value) > 2000) {
                    $value = substr($string_value, 0, 2000) . '...';
                }
            }
        );

        return $payload;
    }
}