Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

1.7 KB
Raw Blame
import type { MakerAgentKindWire } from './agentKindConversion';

/** Only model preferences; native checkpoints and permission settings keep their own lifecycle. */
export interface ScheduledModelBaseline {
  scopeId: string;
  /** Permanent profile save not yet accepted by the runtime; survives pause/restart. */
  pendingBotProfileVersion?: number;
  agentKind: MakerAgentKindWire;
  agentDeviceId?: string | null;
  model: string;
  providerId: string | null;
  effort: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'ultra' | null;
  fastMode: boolean | 'ultrafast';
}

export function parseScheduledModelBaseline(value: unknown): ScheduledModelBaseline | null {
  if (typeof value !== 'string' || !value) return null;
  try {
    const parsed = JSON.parse(value) as Omit<ScheduledModelBaseline, 'effort'> & {
      effort: ScheduledModelBaseline['effort'] | '';
    };
    // Older session rows used an empty string for models without adjustable effort.
    const effort = parsed?.effort === '' ? null : parsed?.effort;
    if (!parsed || typeof parsed.scopeId !== 'string' ||
      !['claude-code', 'codex', 'pi'].includes(parsed.agentKind) ||
      (parsed.agentDeviceId !== undefined && parsed.agentDeviceId !== null && typeof parsed.agentDeviceId !== 'string') ||
      typeof parsed.model !== 'string' || !parsed.model ||
      (parsed.providerId !== null && typeof parsed.providerId !== 'string') ||
      (effort !== null && !['minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra'].includes(effort)) ||
      (typeof parsed.fastMode !== 'boolean' && parsed.fastMode !== 'ultrafast')) return null;
    return { ...parsed, effort };
  } catch {
    return null;
  }
}