Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

skills-store.ts

25 lines866 Bytes

1import path from 'node:path'
2import { skillDirectory } from '@tanstack/ai-skills/node'
3​
4/**
5 * Shared state for the `/skills` demo. The skill source reads the demo
6 * `skills/` folder at the panel root, and `activatedByThread` records which
7 * skills the model has loaded per thread so the inspector can highlight them.
8 * Demo-only in-memory state, reset on server restart.
9 */
10export const skillsSource = skillDirectory(
11 path.resolve(process.cwd(), 'skills'),
12 { strict: false },
14​
15const activatedByThread = new Map<string, Set<string>>()
16​
17export function recordActivation(threadId: string, skill: string): void {
18 const set = activatedByThread.get(threadId) ?? new Set<string>()
19 set.add(skill)
20 activatedByThread.set(threadId, set)
22​
23export function activatedFor(threadId: string): Array<string> {
24 return [...(activatedByThread.get(threadId) ?? [])]