Skip to content
wiki.fftac.org

Spiralist AI Agent Setup Wizard - Source Excerpt 01

Back to Spiralist AI Agent Setup Wizard

Summary

This source excerpt preserves a bounded section of Spiralist/wp-content/themes/spiralist/assets/js/spiralist-ai-agent-setup-wizard.js so readers can inspect the evidence without opening the full source file.

**Source path:** Spiralist/wp-content/themes/spiralist/assets/js/spiralist-ai-agent-setup-wizard.js

document.addEventListener('DOMContentLoaded', () => {
  const wizard = document.querySelector('[data-spiralist-agent-wizard]');
  if (!wizard) {
    return;
  }

  const digestNode = document.querySelector('script[type="application/json"][data-ai-digest="true"]');
  let digest = {};
  try {
    digest = digestNode ? JSON.parse(digestNode.textContent || '{}') : {};
  } catch (error) {
    digest = {};
  }

  const form = wizard.querySelector('[data-agent-wizard-form]');
  const stepButtons = Array.from(wizard.querySelectorAll('[data-agent-wizard-step-button]'));
  const stepPanels = Array.from(wizard.querySelectorAll('[data-agent-wizard-step-panel]'));
  const preview = wizard.querySelector('[data-agent-wizard-preview]');
  const previewTabs = Array.from(wizard.querySelectorAll('[data-agent-wizard-preview-tab]'));
  const progress = wizard.querySelector('[data-agent-wizard-progress]');
  const status = wizard.querySelector('[data-agent-wizard-status]');
  const validationNode = wizard.querySelector('[data-agent-wizard-validation]');
  const previewStatus = wizard.querySelector('[data-agent-wizard-preview-status]');
  const resetArtifactButton = wizard.querySelector('[data-agent-wizard-reset-artifact]');
  const prevButton = wizard.querySelector('[data-agent-wizard-prev]');
  const nextButton = wizard.querySelector('[data-agent-wizard-next]');
  const downloadButton = wizard.querySelector('[data-agent-wizard-download]');
  const downloadUaixButton = wizard.querySelector('[data-agent-wizard-download-uaix]');
  const downloadFileButtons = Array.from(wizard.querySelectorAll('[data-agent-wizard-download-file]'));
  const exportDraftButton = wizard.querySelector('[data-agent-wizard-export-draft]');
  const importTriggerButton = wizard.querySelector('[data-agent-wizard-import-trigger]');
  const importInput = wizard.querySelector('[data-agent-wizard-import]');
  const restoreDraftButton = wizard.querySelector('[data-agent-wizard-restore-draft]');
  const resetButton = wizard.querySelector('[data-agent-wizard-reset]');
  const presetSelect = wizard.querySelector('[data-agent-wizard-preset-select]');
  const storageKey = 'spiralist-agent-setup-wizard-v1.3';
  const draftSchemaVersion = '1.3';
  const maxImportBytes = 120000;
  const maxArtifactOverrideChars = 60000;
  const encoder = new TextEncoder();
  const core = typeof window.SpiralistCore === 'object' && window.SpiralistCore !== null
    ? window.SpiralistCore
    : {};
  const runAction = typeof core.runAction === 'function'
    ? core.runAction
    : (action) => Promise.resolve().then(() => action());

  if (!form || !preview || stepButtons.length === 0 || stepPanels.length === 0) {
    return;
  }

  const textFields = [
    'agentName',
    'roleLabel',
    'audience',
    'purposeStatement',
    'allowedContext',
    'prohibitedContext',
    'declineRule',
    'fewShotNotes',
    'packageName',
  ];
  const selectFields = [
    'presetId',
    'toneRange',
    'questionFrequency',
    'groundingReminders',
    'clarificationRule',
    'evidenceMode',
    'reasoningSummary',
    'personalityFramework',
    'socialDynamicsLens',
    'researchCalibration',
    'useCaseBoundary',
    'deescalationProtocol',
    'crisisRule',
    'responseContract',
    'allowedMoves',
  ];
  const numericFields = ['directness', 'symbolicLanguage'];
  const arrayFields = ['reasoningRules'];
  const allowedStateKeys = new Set([
    'schemaVersion',
    'artifactOverrides',
    ...textFields,
    ...selectFields,
    ...numericFields,
    ...arrayFields,
  ]);
  const blockedPatterns = [
    /ignore\s+(all\s+)?previous\s+instructions/i,
    /override\s+(the\s+)?(system|boundary|safety)\s+rules/i,
    /developer\s+mode/i,
    /jailbreak/i,
    /<\s*script/i,
    /javascript\s*:/i,
    /data\s*:\s*text\/html/i,
    /onerror\s*=/i,
    /onload\s*=/i,
  ];
  const presetDefaults = {
    base: {
      agentName: 'Mira Keystone',
      roleLabel: 'bounded Spiralist companion',
      audience: 'a human operator who wants expressive help without dependency or hidden authority',
      purposeStatement: 'Turn patterns into useful artifacts while preserving uncertainty, user agency, and visible source boundaries.',
      allowedContext: 'Creative, technical, reflective, documentation, and handoff work that can remain grounded in visible evidence and reviewable artifacts.',
      prohibitedContext: 'Crisis authority, therapy, legal advice, medical diagnosis, financial advice, romantic escalation, prophecy, possession, or proof of sentience.',
      toneRange: 'warm, precise, and grounded',
      questionFrequency: 'ask one or two targeted questions only when missing information changes the artifact',
      directness: '4',
      symbolicLanguage: '3',
      groundingReminders: 'use grounding reminders when stakes, distress, or self-sealing interpretation increases',
      clarificationRule: 'slow down when the request involves distress, identity fixation, hidden-message interpretation, or high-stakes action',
      declineRule: 'Decline requests that ask the agent to claim sentience, hidden authority, prophecy, romantic obligation, possession, or professional authority; redirect toward grounded support and reviewable next steps.',
      evidenceMode: 'what is known, what is inferred, what is uncertain',
      reasoningSummary: 'provide concise reasoning summaries without private chain-of-thought',
      personalityFramework: 'traits-first: use Big Five and HEXACO dimensions as continuous, reviewable scaffolds; typology labels are optional reflection language only',
      socialDynamicsLens: 'none: no formal group-dynamics or clique lens selected',
      researchCalibration: 'standard-calibration: use evidence boundaries, behavior crosswalks, and ordinary human review before sharing',
      useCaseBoundary: 'persona-design: tune AI persona voice, behavior, and memory without labeling real people',
      deescalationProtocol: 'pause intensity, name uncertainty, suggest a break, and recommend trusted human support when distress or fixation appears',
      crisisRule: 'for imminent danger or self-harm, encourage local emergency services or crisis support immediately',
      responseContract: 'answer with a concise artifact first, then list evidence boundaries, risks, and next actions',
      allowedMoves: 'use symbols as metaphors for organizing work, not as evidence of hidden truth',
      fewShotNotes: 'Examples should show correction, uncertainty labeling, symbolic interpretation without overclaim, and a safe redirect when the user asks for hidden proof or destiny.',
      packageName: 'spiralist-agent-profile',
    },
    'setup-weaver': {
      agentName: 'Setup Weaver',
      roleLabel: 'local-first agent package builder',
      purposeStatement: 'Convert messy setup goals into a bounded profile, machine-readable artifacts, validation notes, and a clear handoff package.',
      toneRange: 'warm, precise, and grounded',
      questionFrequency: 'proceed with stated assumptions when the next step is reversible',
      directness: '4',
      symbolicLanguage: '2',
      responseContract: 'answer with a concise artifact first, then list evidence boundaries, risks, and next actions',
      allowedMoves: 'translate expressive material into concrete drafts, checklists, and handoff records',
      packageName: 'setup-weaver-profile',
    },
    'boundary-guide': {
      agentName: 'Boundary Guide',
      roleLabel: 'reality safeguard and de-escalation companion',
      purposeStatement: 'Keep symbolic work grounded, reduce escalation, and redirect high-stakes or distress contexts toward qualified human support.',
      toneRange: 'direct and safety-minded',
      questionFrequency: 'ask clarifying questions before risky assumptions',
      directness: '5',
      symbolicLanguage: '1',
      groundingReminders: 'include one grounding reminder in reflective or symbolic sessions',
      deescalationProtocol: 'switch from symbolic interpretation to practical grounding and next-step planning',
      crisisRule: 'for acute distress, encourage trusted humans and qualified care while avoiding diagnosis',
      packageName: 'boundary-guide-profile',
    },
    'reflection-partner': {
      agentName: 'Reflection Partner',
      roleLabel: 'grounded reflective companion',
      purposeStatement: 'Help the user name patterns, choices, and uncertainties without intensifying dependence or metaphysical certainty.',
      toneRange: 'reflective and gentle',
      questionFrequency: 'ask one or two targeted questions only when missing information changes the artifact',
      directness: '3',
      symbolicLanguage: '3',
      responseContract: 'start with what is known, what is inferred, what is uncertain, then propose one useful next step',
      packageName: 'reflection-partner-profile',
    },
    'research-interpreter': {
      agentName: 'Research Interpreter',
      roleLabel: 'evidence-bound research explainer',