tdsk-domain

Documents shared TypeScript types, models, and utilities for the Threaded Stack monorepo.

Updated Jan 4, 2026
One-click install
npx skills add https://github.com/threadedstack/threadedstack --skill tdsk-domain-threadedstack
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tdsk-domain
Source: https://github.com/threadedstack/threadedstack/tree/main/.claude/skills/tdsk-domain
Command: npx skills add https://github.com/threadedstack/threadedstack --skill tdsk-domain-threadedstack

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers working across the Threaded Stack monorepo need a single reference for the shared @tdsk/domain package, which defines the types, models, constants, and utilities used by the backend, proxy, admin, agent, and sandbox services. Without it, engineers must manually search 29 type files and 24 model classes to find correct imports and field definitions. ## Core Features & Use Cases - Type & Model Reference: Catalogs all enums, interfaces, and 24 model classes (Agent, ApiKey, Secret, Subscription, etc.) with their fields, computed properties, and methods. - Utility Documentation: Covers crypto functions (AES-256-GCM encryption, API key generation), permission checks (role hierarchy, canPerform), and Express API helpers (auth headers, Exception class). - Integration Guidance: Explains the two export entry points (index.ts for Node.js, web.ts for frontend-safe imports) and which services consume which exports. - Use Case: When adding a new endpoint to the backend, use this Skill to confirm the correct TRequest/TResponse types, the Exception.throw error pattern, and the permission check via canPerform before writing code. ## Quick Start Ask the AI to show the fields and methods of the Secret model and how to encrypt its value using the domain crypto utilities.

Frequently Asked Questions about tdsk-domain

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I import shared types from the tdsk domain package?▼

Import types using the `@TDM/*` alias, for example `import { User } from '@TDM/models'`. Use `index.ts` for Node.js services and `web.ts` for frontend code, since web.ts excludes api, environment, services, and crypto modules.

What models are available in the tdsk domain repo?▼

There are 24 model classes including Agent, ApiKey, Asset, Domain, Endpoint, Function, Invitation, Memory, Message, Organization, Project, Provider, Quota, Role, Sandbox, Schedule, Secret, Skill, Subscription, Thread, and User. Most extend a Base class with id, createdAt, and updatedAt fields.

How does encryption work for secrets in the domain package?▼

Secrets use AES-256-GCM encryption via functions in src/crypto/crypto.ts. A derived key is created with HKDF-SHA256 from a user ID and the TDSK_MASTER_KEY environment variable, then encryptValue and decryptValue handle the ciphertext with a 12-byte IV and 16-byte auth tag.

Can I use the domain crypto utilities in frontend code?▼

No, the crypto module is excluded from the web.ts export entry point because it requires Node.js and the TDSK_MASTER_KEY environment variable. Frontend code should only import from web.ts, which includes models, constants, and the Exception class.

How do I check user permissions with the domain utilities?▼

Use canPerform(userRole, action, resource) from src/utils/permissions/permissions.ts as the main permission check. Roles follow a hierarchy from viewer (0) to super (4), and helpers like hasMinRole, isSuperAdmin, and canManageRole handle specific comparisons.

Why does my domain import fail in the admin frontend?▼

The admin app must import only from web.ts, which excludes Node.js-only modules like api, environment, services, and crypto. Importing from index.ts in a browser context pulls in server dependencies that cannot resolve.