Getting Started
Installation
pnpm add @hira-core/sdk[!NOTE] The SDK requires
puppeteer-coreas a peer dependency. An anti-detect browser (GPM, Hidemium) provides the actual browser instance.
Create Your First Flow
Define the config
Use defineFlowConfig() to declare your flowβs inputs and outputs with full type safety:
import { defineFlowConfig } from '@hira-core/sdk'
export const config = defineFlowConfig({
globalInput: [
{ key: 'targetUrl', label: 'Target URL', type: 'text', required: true },
{ key: 'maxPages', label: 'Max Pages', type: 'number', defaultValue: 5 },
],
profileInput: [
{ key: 'email', label: 'Email', type: 'text', required: true },
{ key: 'password', label: 'Password', type: 'text', required: true },
],
output: [
{ index: 0, key: 'loginStatus', label: 'Login Status' },
{ index: 1, key: 'pageTitle', label: 'Page Title' },
],
})Create the flow class
Extend AntidetectBaseFlow and implement the script() method β this is where your automation logic runs for each profile:
import {
AntidetectBaseFlow, AntidetectProvider, BrowserUtils,
FlowLogger, IScriptContext,
} from '@hira-core/sdk'
import { config } from './config'
type Config = typeof config
export default class MyFirstFlow extends AntidetectBaseFlow<Config> {
constructor(provider: AntidetectProvider = AntidetectProvider.GPM) {
super(provider, new FlowLogger('MyFirstFlow'), config)
}
async script(context: IScriptContext<Config>) {
const browser = new BrowserUtils(context)
const { targetUrl } = context.globalInput
const { email, password } = context.profileInput
// Navigate to target
await browser.goto(targetUrl)
// Log: π Navigate β https://example.com
// Login
await browser.type('#email', email)
// Log: β¨οΈ Type "user@exam..." β #email
await browser.type('#password', password)
// Log: β¨οΈ Type "secret123" β #password
await browser.click('#login-btn')
// Log: π±οΈ Click: #login-btn
// Wait for page to load
await browser.waitForNavigation()
// Log: π Waiting for navigation...
// Write output
await browser.writeOutput('loginStatus', 'Success')
// Log: π€ Write Output [loginStatus] = Success
const title = await browser.getText('h1')
await browser.writeOutput('pageTitle', title ?? 'N/A')
// Log: π€ Write Output [pageTitle] = Dashboard
}
}Set up project structure
my-flow/
βββ src/
β βββ config.ts β defineFlowConfig()
β βββ index.ts β Flow class (default export)
βββ package.json
βββ tsconfig.jsonConfigure package.json
{
"name": "my-first-flow",
"version": "1.0.0",
"main": "src/index.ts",
"dependencies": {
"@hira-core/sdk": "^1.0.16"
}
}Flow Lifecycle
When your flow runs, the SDK calls these methods in order:
run() β Orchestrate profiles (concurrency, delay, retry)
β
For each profile:
Open browser β Anti-detect adapter opens profile
script() β β
Your main automation logic
Close browser β Auto-close profile
β
All profiles done β Flow complete[!TIP] You only need to implement
script(). The SDK handles browser opening/closing, retry, concurrency, and error handling automatically.
Whatβs Next?
- Core Concepts β Deep dive into lifecycle, config, and type system
- Browser Utils β All available browser methods
- Excel Storage β Read/write data from Excel files
Last updated on