@hailer/sdk
v0.12.2
Published
CLI tool for generating TypeScript types from Hailer workspace
Maintainers
Readme
hailer-sdk
CLI toolkit for Hailer workspace development - initialize projects, manage workflows, and generate TypeScript types.
Features
- 🚀 Project initialization - scaffold new Hailer projects with best practices
- 📦 Workflow management - pull/push workflow configurations between Hailer and local files
- 🎯 Type generation - generate TypeScript types and enums from workflows and insights
- 🔐 Secure authentication - credential management with environment variables
- 📝 TypeScript-first - full type safety with generated definitions
- 🌐 Multi-environment support - connect to production or local development Hailer instances
- 🧪 Testing support - Vitest setup with test templates for function fields
Getting Started
1. Initialize a new project
Create a new Hailer project with proper structure and configuration:
npx @hailer/sdk@latest initThis interactive wizard will:
- Let you choose between production or local development API
- Authenticate with your Hailer account
- Let you select a workspace or create a new one
- Let you choose if you want to create a bot user and add it to your workspace
- Let you choose if you want to set up the MCP server in your project
- Create project structure with TypeScript configuration
- Set up environment variables and
.gitignore - Copy type definitions
After initialization, navigate to your project:
cd my-project
npm installIf you chose to set up the MCP server, the npm install step will automatically install the @hailer/mcp package and copy the .claude/ and .opencode/ configuration via the postinstall script.
Start the MCP server with:
npm run mcp-startThen open a new terminal and start Claude Code to interact with your MCP server.
2. Pull workflows from Hailer
Use the npm script created during initialization:
npm run pullThis generates:
workspace/enums.ts- Type-safe enums for workflow, field, phase, and member IDsworkspace/groups.ts- Definitions for user groups in the workspaceworkspace/insights.ts- Insight definitionsworkspace/teams.ts- Team definitionsworkspace/apps.ts- App configurationsworkspace/workflows.ts- Registry of all workflowsworkspace/WorkflowName_id/- Individual workflow folders containing:main.ts- Workflow configurationfields.ts- Field definitionsphases.ts- Phase definitionsfunctions/- Extracted function fields (if workflow has calculated fields)main.test.ts- Test template for function fields (generated once, editable)
3. Start developing!
You now have type-safe workflow definitions ready to use in your project.
Examples
Here are common tasks you'll perform after initializing your project:
Example 1: Creating a New Workflow
After initialization, you can create a new workflow from scratch:
Pull existing workflows to see the structure:
npm run pullAdd the workflow to the registry in
workspace/workflows.ts:export const workflows: HailerWorkflow[] = [ // ... existing workflows { name: "My new workflow", // When `unlinkedMode` is enabled it will create a dataset, when disabled it will create a workflow enableUnlinkedMode: false, } ];Sync the workflows:
npm run workflows-syncPull from Hailer to generate the new workflow folder:
npm run pull
To remove a workflow, delete it from the array and sync again.
Create phases
workspace/Customer_Support_new_workflow_id_12345/phases.ts:import type { HailerPhaseUpdatePayload } from "../hailer"; export const phases: HailerPhaseUpdatePayload[] = [ { name: "New", }, { name: "In Progress", }, { name: "Resolved", }, ];Create fields
workspace/Customer_Support_new_workflow_id_12345/fields.ts:import type { HailerField } from "../hailer"; export const fields: HailerField[] = [ { label: "Customer Email", type: "text", required: true, }, { label: "Issue Type", type: "textpredefinedoptions", data: ["Bug", "Feature Request", "Question"], required: true }, ];Push to Hailer:
npm run pushPull from Hailer to get get the newly pushed fields and phases:
npm run pull
Example 2: Adding a New Phase to an Existing Workflow
Pull the latest configuration:
npm run pullEdit the phases file for your workflow (e.g.,
workspace/MyWorkflow_abc123/phases.ts):export const phases: HailerPhaseUpdatePayload[] = [ { name: "Draft", isInitial: true, }, { name: "Pending", }, { name: "Done", isEndpoint: true, }, ];Push only phases (faster than pushing everything):
npm run phases-pushPull to sync the generated IDs:
npm run pull
To remove a phase, delete it from the array and push again.
Example 3: Modifying Workflow Settings
Pull the latest configuration:
npm run pullEdit workflow configuration in
workspace/MyWorkflow_abc123/main.ts:export const workflow: HailerWorkflow = { _id: "abc123", name: "Updated Workflow Name", description: "Updated description", nameFunctionEnabled: true, nameFunction:"return 'This will be a name to all the activities in this workflow';" };Push only workflow configs:
npm run workflows-push
Example 4: Adding Custom Fields to a Workflow
Pull the latest configuration:
npm run pullEdit the fields file
workspace/MyWorkflow_abc123/fields.ts:export const fields: HailerField[] = [ // ... existing fields { label: "Total price", type: "numericunit", required: true, unit: "€", }, { label: "Due Date", type: "date", required: false, }, ];Push only fields:
npm run fields-pushPull to get generated field IDs:
npm run pull
To remove a field, delete it from the array and push again.
Example 5: Managing Workspace Groups
Pull the latest configuration:
npm run pullAdd group in
workspace/groups.ts:export const groups: HailerGroup[] = [ { name: "Product Managers", members: ["user_id_3", "user_id_4"], }, ];Push groups:
npm run groups-push
To remove a group, delete it from the array and push again.
Example 6: Managing Workspace Teams
- Pull the latest configuration:
npm run pull - Add team in
workspace/teams.ts:export const teams: HailerTeam[] = [ { name: "Support Team", members: ["user_id_5", "user_id_6"], }, ]; - Push teams:
npm run teams-push
To remove a team, delete it from the array and push again.
Example 7: Managing Workspace Apps
- Pull the latest configuration:
npm run pull - Add app in
workspace/apps.ts:export const apps: HailerAppUpdatePayload[] = [ { // Leave _id empty for new apps name: "Sales Dashboard", description: "Custom dashboard for sales team", url: "https://dashboard.example.com", members: [ { id: WorkspaceTeams.Sales_Team, type: "team" } ], }, ]; - Push apps:
npm run apps-push - Pull to get the generated app ID:
npm run pull
To remove an app, delete it from the array and push again.
Example 8: Using Generated Enums
After pulling, use the generated enums for type-safe IDs:
import {
WorkflowIds,
MyWorkflow_FieldIds,
MyWorkflow_PhaseIds,
WorkspaceMembers
} from "./workspace/enums";
// Use enums instead of hardcoded IDs
const workflowId = WorkflowIds.CustomerSupport;
const fieldId = MyWorkflow_FieldIds.CustomerEmail;
const phaseId = MyWorkflow_PhaseIds.InProgress;
const assignee = WorkspaceMembers.John_Doe;Git
One of the intention of this SDK is to keep all workflow configurations in code and under version control. If you would like to setup git for your newly created you should create a new repository on GitHub or GitLab and then follow the instructions to push an existing repository from the command line.
Commands
For detailed documentation on all available commands, see:
init- Initialize new projectsgenerate- Generate TypeScript typesws-config- Manage workspace configurations
Common Options
Most commands support these options:
| Option | Alias | Description |
| ----------------------- | ----- | -------------------------------------------- |
| --email <email> | -e | Hailer account email |
| --password <password> | -p | Hailer account password |
| --workspace <id> | -w | Workspace ID |
| --api-url <url> | -a | API URL (defaults to https://api.hailer.com) |
| --verbose | | Show detailed logging |
| --force | | Skip confirmation prompts (ws-config only) |
Development
Run locally without building
npm run dev -- init
npm run dev -- ws-config pull -e email -w workspace-idProject Structure
src/
├── cli/
│ ├── index.ts # CLI entry point
│ └── commands/
│ ├── init.ts # Project initialization
│ ├── workspace-config.ts # Workflow pull/push
│ └── generate.ts # Type generation
├── lib/
│ ├── actions/ # Command implementations
│ ├── hailer-client.ts # API client
│ ├── generator.ts # Type generation logic
│ └── helpers/ # Utility functions
└── types/
└── hailer.d.ts # Core type definitionsTroubleshooting
Permission denied when running CLI
After building, make sure the CLI is executable:
npm run build
chmod +x dist/cli/index.js
npm link"Unknown file extension .ts" error
This happens when the CLI tries to import TypeScript files from user projects. Make sure jiti is installed as a dependency (not devDependency).
Authentication fails
- Verify credentials are correct
- Check environment variables are loaded
