hirebase-ai-sdk 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hirebase LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,69 @@
1
- # Temporary Holding Version
1
+ # hirebase-ai-sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [Hirebase](https://www.hirebase.org) job data tools for the [Vercel AI SDK](https://ai-sdk.dev). Give your agent live job postings from company career sites, full posting details, and salary and hiring-trend numbers.
4
+
5
+ ```bash
6
+ npm install hirebase-ai-sdk
7
+ ```
8
+
9
+ Requires `ai` 6 or 7. Get a free API key at [app.hirebase.org](https://app.hirebase.org/user/settings?section=api) and set it as `HIREBASE_API_KEY`.
10
+
11
+ ## Quick start
12
+
13
+ ```ts
14
+ import { generateText, isStepCount } from 'ai';
15
+ import { hirebaseTools } from 'hirebase-ai-sdk';
16
+
17
+ const { text } = await generateText({
18
+ model: 'openai/gpt-5-mini',
19
+ prompt: 'Find remote senior data engineer jobs posted this week that pay over $180k.',
20
+ tools: hirebaseTools(),
21
+ stopWhen: isStepCount(5),
22
+ });
23
+
24
+ console.log(text);
25
+ ```
26
+
27
+ ## Tools
28
+
29
+ | Tool | What it does |
30
+ | --- | --- |
31
+ | `searchJobs` | Search live postings by title, keywords, location, remote, experience, job type, salary or posting date, or by a plain-language description (`query`). Returns compact rows with application links. |
32
+ | `getJob` | Read one posting in full: description as plain text, skills, technologies, benefits, salary. |
33
+ | `jobMarketInsights` | Salary percentiles, pay by experience level, top hiring companies, locations, skills and technologies for any set of filters, in one call. |
34
+
35
+ Use them all with `hirebaseTools()`, or pick one:
36
+
37
+ ```ts
38
+ import { searchJobs, jobMarketInsights } from 'hirebase-ai-sdk';
39
+
40
+ const tools = {
41
+ searchJobs: searchJobs(),
42
+ jobMarketInsights: jobMarketInsights(),
43
+ };
44
+ ```
45
+
46
+ ## Options
47
+
48
+ Every tool factory takes the same options:
49
+
50
+ ```ts
51
+ hirebaseTools({
52
+ apiKey: 'hb_...', // default: process.env.HIREBASE_API_KEY
53
+ baseUrl: 'https://api.hirebase.org', // default
54
+ });
55
+ ```
56
+
57
+ ## Usage and pricing
58
+
59
+ Calls count against your Hirebase plan: each job row returned by `searchJobs` and each `getJob` uses one job unit, and `jobMarketInsights` uses one insights call. The free plan covers testing; see [pricing](https://www.hirebase.org/pricing). When a limit is reached the tool returns an error telling the model not to retry.
60
+
61
+ ## Links
62
+
63
+ - [AI SDK guide](https://www.hirebase.org/docs/ai-sdk)
64
+ - [API reference](https://www.hirebase.org/docs)
65
+ - [Hirebase MCP server](https://www.hirebase.org/docs/mcp-server), if your agent speaks MCP
66
+
67
+ ## License
68
+
69
+ MIT
@@ -0,0 +1,14 @@
1
+ export declare const VERSION = "0.1.0";
2
+ export interface HirebaseOptions {
3
+ /** Hirebase API key. Defaults to the HIREBASE_API_KEY environment variable. */
4
+ apiKey?: string;
5
+ /** API base URL. Defaults to https://api.hirebase.org. */
6
+ baseUrl?: string;
7
+ /** Custom fetch, for tests or proxies. Defaults to the global fetch. */
8
+ fetch?: typeof fetch;
9
+ }
10
+ export declare class HirebaseError extends Error {
11
+ readonly status: number;
12
+ constructor(message: string, status: number);
13
+ }
14
+ export declare function hirebaseRequest<T>(options: HirebaseOptions, method: 'GET' | 'POST', path: string, body?: unknown, signal?: AbortSignal): Promise<T>;
package/dist/client.js ADDED
@@ -0,0 +1,54 @@
1
+ export const VERSION = '0.1.0';
2
+ const DEFAULT_BASE_URL = 'https://api.hirebase.org';
3
+ export class HirebaseError extends Error {
4
+ status;
5
+ constructor(message, status) {
6
+ super(message);
7
+ this.status = status;
8
+ this.name = 'HirebaseError';
9
+ }
10
+ }
11
+ export async function hirebaseRequest(options, method, path, body, signal) {
12
+ const apiKey = options.apiKey ?? process.env.HIREBASE_API_KEY;
13
+ if (!apiKey) {
14
+ throw new HirebaseError('Missing Hirebase API key. Set HIREBASE_API_KEY or pass { apiKey }. ' +
15
+ 'Get a free key at https://app.hirebase.org/user/settings?section=api', 401);
16
+ }
17
+ const doFetch = options.fetch ?? fetch;
18
+ const response = await doFetch(`${options.baseUrl ?? DEFAULT_BASE_URL}${path}`, {
19
+ method,
20
+ headers: {
21
+ 'x-api-key': apiKey,
22
+ 'content-type': 'application/json',
23
+ 'user-agent': `hirebase-ai-sdk/${VERSION}`,
24
+ },
25
+ body: body === undefined ? undefined : JSON.stringify(body),
26
+ signal,
27
+ });
28
+ const text = await response.text();
29
+ let data;
30
+ try {
31
+ data = text ? JSON.parse(text) : undefined;
32
+ }
33
+ catch {
34
+ data = text;
35
+ }
36
+ if (!response.ok) {
37
+ throw new HirebaseError(errorMessage(response.status, data), response.status);
38
+ }
39
+ return data;
40
+ }
41
+ function errorMessage(status, data) {
42
+ const detail = data && typeof data === 'object' && 'detail' in data
43
+ ? data.detail
44
+ : data;
45
+ const text = typeof detail === 'string' ? detail : JSON.stringify(detail);
46
+ if (status === 401 || status === 403) {
47
+ return `Hirebase rejected the API key or this plan lacks access (${status}): ${text}`;
48
+ }
49
+ if (status === 402 || status === 429) {
50
+ return (`Hirebase usage limit reached (${status}): ${text}. ` +
51
+ 'Do not retry; see https://www.hirebase.org/pricing');
52
+ }
53
+ return `Hirebase API error (${status}): ${text}`;
54
+ }
@@ -0,0 +1,68 @@
1
+ import { z } from 'zod';
2
+ /** Job filters shared by searchJobs and jobMarketInsights. */
3
+ export declare const jobFilters: {
4
+ jobTitles: z.ZodOptional<z.ZodArray<z.ZodString>>;
5
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
+ locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
7
+ city: z.ZodOptional<z.ZodString>;
8
+ region: z.ZodOptional<z.ZodString>;
9
+ country: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strip>>>;
11
+ locationTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
12
+ Remote: "Remote";
13
+ Hybrid: "Hybrid";
14
+ "In-Person": "In-Person";
15
+ }>>>;
16
+ experience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
17
+ Entry: "Entry";
18
+ Junior: "Junior";
19
+ Mid: "Mid";
20
+ Senior: "Senior";
21
+ Executive: "Executive";
22
+ }>>>;
23
+ jobTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
24
+ "Full Time": "Full Time";
25
+ "Part Time": "Part Time";
26
+ Contract: "Contract";
27
+ Internship: "Internship";
28
+ }>>>;
29
+ salaryMin: z.ZodOptional<z.ZodNumber>;
30
+ currency: z.ZodOptional<z.ZodString>;
31
+ daysAgo: z.ZodOptional<z.ZodNumber>;
32
+ };
33
+ declare const jobFiltersSchema: z.ZodObject<{
34
+ jobTitles: z.ZodOptional<z.ZodArray<z.ZodString>>;
35
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
36
+ locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
37
+ city: z.ZodOptional<z.ZodString>;
38
+ region: z.ZodOptional<z.ZodString>;
39
+ country: z.ZodOptional<z.ZodString>;
40
+ }, z.core.$strip>>>;
41
+ locationTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
42
+ Remote: "Remote";
43
+ Hybrid: "Hybrid";
44
+ "In-Person": "In-Person";
45
+ }>>>;
46
+ experience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
47
+ Entry: "Entry";
48
+ Junior: "Junior";
49
+ Mid: "Mid";
50
+ Senior: "Senior";
51
+ Executive: "Executive";
52
+ }>>>;
53
+ jobTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
54
+ "Full Time": "Full Time";
55
+ "Part Time": "Part Time";
56
+ Contract: "Contract";
57
+ Internship: "Internship";
58
+ }>>>;
59
+ salaryMin: z.ZodOptional<z.ZodNumber>;
60
+ currency: z.ZodOptional<z.ZodString>;
61
+ daysAgo: z.ZodOptional<z.ZodNumber>;
62
+ }, z.core.$strip>;
63
+ export type JobFilters = z.infer<typeof jobFiltersSchema>;
64
+ /** Maps the tool filters to a Hirebase API request body. */
65
+ export declare function toApiBody(f: JobFilters, opts?: {
66
+ semantic?: boolean;
67
+ }): Record<string, unknown>;
68
+ export {};
@@ -0,0 +1,68 @@
1
+ import { z } from 'zod';
2
+ const location = z
3
+ .object({
4
+ city: z.string().optional(),
5
+ region: z.string().optional().describe('State or region'),
6
+ country: z.string().optional(),
7
+ })
8
+ .refine((l) => l.city || l.region || l.country, {
9
+ message: 'A location needs a city, region or country',
10
+ });
11
+ /** Job filters shared by searchJobs and jobMarketInsights. */
12
+ export const jobFilters = {
13
+ jobTitles: z
14
+ .array(z.string())
15
+ .optional()
16
+ .describe('Job titles, any of which may match. Quote for an exact phrase.'),
17
+ keywords: z
18
+ .array(z.string())
19
+ .optional()
20
+ .describe('Skills, technologies or other terms to match in the posting.'),
21
+ locations: z
22
+ .array(location)
23
+ .optional()
24
+ .describe('Where the job is. Matches the surrounding metro area.'),
25
+ locationTypes: z.array(z.enum(['Remote', 'Hybrid', 'In-Person'])).optional(),
26
+ experience: z
27
+ .array(z.enum(['Entry', 'Junior', 'Mid', 'Senior', 'Executive']))
28
+ .optional()
29
+ .describe('Years-of-experience bands (Entry 0-2y, Mid 2-5y, ...), not a seniority label.'),
30
+ jobTypes: z.array(z.enum(['Full Time', 'Part Time', 'Contract', 'Internship'])).optional(),
31
+ salaryMin: z
32
+ .number()
33
+ .min(0)
34
+ .optional()
35
+ .describe('Minimum yearly salary. Only postings that state a salary match.'),
36
+ currency: z.string().length(3).optional().describe('Currency for salaryMin. Default USD.'),
37
+ daysAgo: z.number().int().min(1).max(90).optional().describe('Posted in the last N days.'),
38
+ };
39
+ const jobFiltersSchema = z.object(jobFilters);
40
+ /** Maps the tool filters to a Hirebase API request body. */
41
+ export function toApiBody(f, opts = {}) {
42
+ const body = { hide_recruiting_agencies: 'true' };
43
+ // The API rejects brackets in text filters.
44
+ const titles = (f.jobTitles ?? []).map((t) => t.replace(/[()[\]]/g, '').trim()).filter(Boolean);
45
+ if (titles.length)
46
+ body.job_titles = titles;
47
+ if (f.keywords?.length)
48
+ body.keywords = f.keywords;
49
+ if (f.locations?.length) {
50
+ body.geo_locations = f.locations;
51
+ body.geofilter_params = { mode: 'auto' };
52
+ }
53
+ if (f.locationTypes?.length)
54
+ body.location_types = f.locationTypes;
55
+ // Semantic search ignores experience.
56
+ if (f.experience?.length && !opts.semantic)
57
+ body.experience = f.experience;
58
+ if (f.jobTypes?.length)
59
+ body.job_types = f.jobTypes;
60
+ if (f.salaryMin !== undefined) {
61
+ body.salary = { min: f.salaryMin };
62
+ body.include_no_salary = 'false';
63
+ body.currency = (f.currency ?? 'USD').toUpperCase();
64
+ }
65
+ if (f.daysAgo !== undefined)
66
+ body.days_ago = f.daysAgo;
67
+ return body;
68
+ }
@@ -0,0 +1,4 @@
1
+ export { searchJobs, getJob, jobMarketInsights, hirebaseTools, type SearchJobsInput, type SearchJobsResult, type GetJobInput, type JobMarketInsightsInput, type JobMarketInsightsResult, type Bucket, } from './tools.js';
2
+ export type { CompactJob, FullJob } from './shaping.js';
3
+ export type { JobFilters } from './filters.js';
4
+ export { HirebaseError, type HirebaseOptions } from './client.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { searchJobs, getJob, jobMarketInsights, hirebaseTools, } from './tools.js';
2
+ export { HirebaseError } from './client.js';
@@ -0,0 +1,72 @@
1
+ interface ApiLocation {
2
+ city?: string | null;
3
+ region?: string | null;
4
+ country?: string | null;
5
+ }
6
+ export interface ApiJob {
7
+ _id?: string;
8
+ job_title?: string;
9
+ company_name?: string;
10
+ company_slug?: string;
11
+ locations?: ApiLocation[];
12
+ location_type?: string;
13
+ salary_range?: {
14
+ min?: number;
15
+ max?: number;
16
+ currency?: string;
17
+ period?: string;
18
+ } | null;
19
+ experience_level?: string;
20
+ yoe_range?: {
21
+ min?: number;
22
+ max?: number;
23
+ } | null;
24
+ job_type?: string;
25
+ date_posted?: string;
26
+ requirements_summary?: string;
27
+ application_link?: string;
28
+ description?: string;
29
+ skills?: string[];
30
+ technologies?: string[];
31
+ benefits?: string[];
32
+ education_level?: string;
33
+ visa_sponsored?: boolean;
34
+ }
35
+ /** Plain text from posting HTML: keeps paragraphs and bullets, drops tags and scripts. */
36
+ export declare function htmlToText(html: string | undefined): string;
37
+ export interface CompactJob {
38
+ id: string | null;
39
+ title: string | null;
40
+ company: string | null;
41
+ companySlug: string | null;
42
+ location: string | null;
43
+ otherLocations: number;
44
+ locationType: string | null;
45
+ salary: {
46
+ min: number | null;
47
+ max: number | null;
48
+ currency: string | null;
49
+ period: string | null;
50
+ } | null;
51
+ seniority: string | null;
52
+ yearsExperience: {
53
+ min?: number;
54
+ max?: number;
55
+ } | null;
56
+ jobType: string | null;
57
+ datePosted: string | null;
58
+ summary: string;
59
+ applyUrl: string | null;
60
+ }
61
+ export interface FullJob extends CompactJob {
62
+ locations: string[];
63
+ description: string;
64
+ skills: string[];
65
+ technologies: string[];
66
+ benefits: string[];
67
+ education: string | null;
68
+ visaSponsored: boolean | null;
69
+ }
70
+ export declare function compactJob(job: ApiJob): CompactJob;
71
+ export declare function fullJob(job: ApiJob): FullJob;
72
+ export {};
@@ -0,0 +1,71 @@
1
+ // Shapes Hirebase job records into small, model-friendly objects. Posting text comes from
2
+ // employers' sites, so it is only ever returned as data.
3
+ const SUMMARY_CHARS = 300;
4
+ const DESCRIPTION_CHARS = 6000;
5
+ function formatLocation(l) {
6
+ if (!l)
7
+ return null;
8
+ return [l.city, l.region, l.country].filter(Boolean).join(', ') || null;
9
+ }
10
+ function salary(job) {
11
+ const s = job.salary_range;
12
+ if (!s || !(s.min || s.max))
13
+ return null;
14
+ return { min: s.min ?? null, max: s.max ?? null, currency: s.currency ?? null, period: s.period ?? null };
15
+ }
16
+ function cut(text, limit) {
17
+ const t = text ?? '';
18
+ return t.length <= limit ? t : `${t.slice(0, limit).trimEnd()}…`;
19
+ }
20
+ /** Plain text from posting HTML: keeps paragraphs and bullets, drops tags and scripts. */
21
+ export function htmlToText(html) {
22
+ if (!html)
23
+ return '';
24
+ return html
25
+ .replace(/<(script|style|noscript|template|svg)[\s\S]*?<\/\1>/gi, '')
26
+ .replace(/<li[^>]*>/gi, '\n- ')
27
+ .replace(/<(br|hr)\s*\/?>/gi, '\n')
28
+ .replace(/<\/?(p|div|h[1-6]|ul|ol|section|article|header|footer|table|tr|blockquote|pre)[^>]*>/gi, '\n')
29
+ .replace(/<[^>]+>/g, '')
30
+ .replace(/&nbsp;/g, ' ')
31
+ .replace(/&amp;/g, '&')
32
+ .replace(/&lt;/g, '<')
33
+ .replace(/&gt;/g, '>')
34
+ .replace(/&quot;/g, '"')
35
+ .replace(/&#39;|&apos;/g, "'")
36
+ .split('\n')
37
+ .map((line) => line.replace(/\s+/g, ' ').trim())
38
+ .filter((line) => line && line !== '-')
39
+ .join('\n');
40
+ }
41
+ export function compactJob(job) {
42
+ const locations = job.locations ?? [];
43
+ return {
44
+ id: job._id ?? null,
45
+ title: job.job_title ?? null,
46
+ company: job.company_name ?? null,
47
+ companySlug: job.company_slug ?? null,
48
+ location: formatLocation(locations[0]),
49
+ otherLocations: Math.max(0, locations.length - 1),
50
+ locationType: job.location_type ?? null,
51
+ salary: salary(job),
52
+ seniority: job.experience_level ?? null,
53
+ yearsExperience: job.yoe_range ?? null,
54
+ jobType: job.job_type ?? null,
55
+ datePosted: job.date_posted ?? null,
56
+ summary: cut(job.requirements_summary, SUMMARY_CHARS),
57
+ applyUrl: job.application_link ?? null,
58
+ };
59
+ }
60
+ export function fullJob(job) {
61
+ return {
62
+ ...compactJob(job),
63
+ locations: (job.locations ?? []).map(formatLocation).filter((l) => Boolean(l)),
64
+ description: cut(htmlToText(job.description), DESCRIPTION_CHARS),
65
+ skills: job.skills ?? [],
66
+ technologies: job.technologies ?? [],
67
+ benefits: job.benefits ?? [],
68
+ education: job.education_level ?? null,
69
+ visaSponsored: job.visa_sponsored ?? null,
70
+ };
71
+ }
@@ -0,0 +1,83 @@
1
+ import { type Tool } from 'ai';
2
+ import { z } from 'zod';
3
+ import { type HirebaseOptions } from './client.js';
4
+ import { type JobFilters } from './filters.js';
5
+ import { type CompactJob, type FullJob } from './shaping.js';
6
+ declare const searchJobsInput: z.ZodObject<{
7
+ sort: z.ZodOptional<z.ZodEnum<{
8
+ salary: "salary";
9
+ relevance: "relevance";
10
+ date_posted: "date_posted";
11
+ }>>;
12
+ limit: z.ZodDefault<z.ZodNumber>;
13
+ jobTitles: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
15
+ locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
16
+ city: z.ZodOptional<z.ZodString>;
17
+ region: z.ZodOptional<z.ZodString>;
18
+ country: z.ZodOptional<z.ZodString>;
19
+ }, z.core.$strip>>>;
20
+ locationTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
21
+ Remote: "Remote";
22
+ Hybrid: "Hybrid";
23
+ "In-Person": "In-Person";
24
+ }>>>;
25
+ experience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
26
+ Entry: "Entry";
27
+ Junior: "Junior";
28
+ Mid: "Mid";
29
+ Senior: "Senior";
30
+ Executive: "Executive";
31
+ }>>>;
32
+ jobTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
33
+ "Full Time": "Full Time";
34
+ "Part Time": "Part Time";
35
+ Contract: "Contract";
36
+ Internship: "Internship";
37
+ }>>>;
38
+ salaryMin: z.ZodOptional<z.ZodNumber>;
39
+ currency: z.ZodOptional<z.ZodString>;
40
+ daysAgo: z.ZodOptional<z.ZodNumber>;
41
+ query: z.ZodOptional<z.ZodString>;
42
+ }, z.core.$strip>;
43
+ export type SearchJobsInput = z.infer<typeof searchJobsInput>;
44
+ export interface SearchJobsResult {
45
+ totalMatches: number | null;
46
+ companyCount: number | null;
47
+ jobs: CompactJob[];
48
+ }
49
+ /** Search live job postings by filters or a plain-language description. */
50
+ export declare function searchJobs(options?: HirebaseOptions): Tool<SearchJobsInput, SearchJobsResult>;
51
+ export interface GetJobInput {
52
+ jobId: string;
53
+ }
54
+ /** Read one job posting in full. */
55
+ export declare function getJob(options?: HirebaseOptions): Tool<GetJobInput, FullJob>;
56
+ export type Bucket = Record<string, unknown>;
57
+ export type JobMarketInsightsInput = JobFilters;
58
+ export interface JobMarketInsightsResult {
59
+ headline: Bucket | null;
60
+ salary: Bucket;
61
+ salaryByLevel: Bucket[];
62
+ salaryByLocationType: Bucket[];
63
+ experienceLevels: Bucket[];
64
+ locationTypes: Bucket[];
65
+ companySizes: Bucket[];
66
+ topCompanies: Bucket[];
67
+ topLocations: Bucket[];
68
+ topSkills: Bucket[];
69
+ topTechnologies: Bucket[];
70
+ topBenefits: Bucket[];
71
+ visaSponsorshipRatePercent: number | null;
72
+ medianYearsExperience: number | null;
73
+ note: string;
74
+ }
75
+ /** Salary percentiles, top hiring companies, skills and trends for a set of job filters. */
76
+ export declare function jobMarketInsights(options?: HirebaseOptions): Tool<JobMarketInsightsInput, JobMarketInsightsResult>;
77
+ /** All Hirebase tools, ready to pass to generateText or streamText. */
78
+ export declare function hirebaseTools(options?: HirebaseOptions): {
79
+ searchJobs: Tool<SearchJobsInput, SearchJobsResult>;
80
+ getJob: Tool<GetJobInput, FullJob>;
81
+ jobMarketInsights: Tool<JobMarketInsightsInput, JobMarketInsightsResult>;
82
+ };
83
+ export {};
package/dist/tools.js ADDED
@@ -0,0 +1,95 @@
1
+ import { tool } from 'ai';
2
+ import { z } from 'zod';
3
+ import { hirebaseRequest } from './client.js';
4
+ import { jobFilters, toApiBody } from './filters.js';
5
+ import { compactJob, fullJob } from './shaping.js';
6
+ const searchJobsInput = z.object({
7
+ query: z
8
+ .string()
9
+ .min(1)
10
+ .max(500)
11
+ .optional()
12
+ .describe('Plain-language role description; turns on semantic search. Put places in locations.'),
13
+ ...jobFilters,
14
+ sort: z.enum(['relevance', 'date_posted', 'salary']).optional().describe('Ignored with query.'),
15
+ limit: z.number().int().min(1).max(25).default(10),
16
+ });
17
+ /** Search live job postings by filters or a plain-language description. */
18
+ export function searchJobs(options = {}) {
19
+ return tool({
20
+ description: 'Search live job postings from company career sites, by filters or a plain-language ' +
21
+ 'description (query). Returns compact rows with application links. Each row returned ' +
22
+ "counts against the user's Hirebase plan, so ask for only as many as needed. For pay " +
23
+ 'ranges, top hiring companies or other totals, use jobMarketInsights instead.',
24
+ inputSchema: searchJobsInput,
25
+ execute: async ({ query, sort, limit, ...filters }, { abortSignal }) => {
26
+ const lexical = toApiBody(filters, { semantic: Boolean(query) });
27
+ const data = query
28
+ ? await hirebaseRequest(options, 'POST', '/v2/jobs/neural-search', { vector: { query }, lexical, page: 1, limit }, abortSignal)
29
+ : await hirebaseRequest(options, 'POST', '/v2/jobs/search', { ...lexical, ...(sort ? { sort_by: sort } : {}), page: 1, limit }, abortSignal);
30
+ return {
31
+ totalMatches: data.total_count ?? null,
32
+ companyCount: data.company_count ?? null,
33
+ jobs: (data.jobs ?? []).map(compactJob),
34
+ };
35
+ },
36
+ });
37
+ }
38
+ /** Read one job posting in full. */
39
+ export function getJob(options = {}) {
40
+ return tool({
41
+ description: 'Read one job posting in full by its id (from searchJobs): description as plain text, ' +
42
+ 'skills, technologies, benefits, salary and the application link.',
43
+ inputSchema: z.object({
44
+ jobId: z
45
+ .string()
46
+ .regex(/^[0-9a-fA-F]{24}$/, 'A Hirebase job id is 24 hexadecimal characters')
47
+ .describe('The id of a searchJobs row.'),
48
+ }),
49
+ execute: async ({ jobId }, { abortSignal }) => {
50
+ const job = await hirebaseRequest(options, 'GET', `/v2/jobs/${jobId.toLowerCase()}`, undefined, abortSignal);
51
+ return fullJob(job);
52
+ },
53
+ });
54
+ }
55
+ const top = (rows, n = 10) => (rows ?? []).slice(0, n);
56
+ /** Salary percentiles, top hiring companies, skills and trends for a set of job filters. */
57
+ export function jobMarketInsights(options = {}) {
58
+ return tool({
59
+ description: 'Job-market numbers for the open postings matching the filters, in one call: salary ' +
60
+ 'percentiles, pay by experience level, top hiring companies, locations, skills, ' +
61
+ 'technologies, remote share and how many are new this week. Use it instead of paging ' +
62
+ 'through searchJobs for counts or pay.',
63
+ inputSchema: z.object(jobFilters),
64
+ execute: async (filters, { abortSignal }) => {
65
+ const d = await hirebaseRequest(options, 'POST', '/v2/jobs/insights', toApiBody(filters), abortSignal);
66
+ const { histogram: _h, fitted_normal: _f, ...salary } = d.salary ?? {};
67
+ const companies = top(d.top_companies).map(({ company_logo: _logo, ...rest }) => rest);
68
+ return {
69
+ headline: d.headline ?? null,
70
+ salary,
71
+ salaryByLevel: d.salary_by_level ?? [],
72
+ salaryByLocationType: d.salary_by_location_type ?? [],
73
+ experienceLevels: d.level_breakdown ?? [],
74
+ locationTypes: d.location_type_split ?? [],
75
+ companySizes: d.company_size_split ?? [],
76
+ topCompanies: companies,
77
+ topLocations: top(d.top_locations),
78
+ topSkills: top(d.top_skills),
79
+ topTechnologies: top(d.top_technologies),
80
+ topBenefits: top(d.top_benefits),
81
+ visaSponsorshipRatePercent: d.visa_sponsorship_rate ?? null,
82
+ medianYearsExperience: d.yoe_median ?? null,
83
+ note: 'Breakdowns come from a sample of the matching postings (headline.sample_size).',
84
+ };
85
+ },
86
+ });
87
+ }
88
+ /** All Hirebase tools, ready to pass to generateText or streamText. */
89
+ export function hirebaseTools(options = {}) {
90
+ return {
91
+ searchJobs: searchJobs(options),
92
+ getJob: getJob(options),
93
+ jobMarketInsights: jobMarketInsights(options),
94
+ };
95
+ }
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "hirebase-ai-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Hirebase job data tools for the Vercel AI SDK: search live job postings, read a posting, and get salary and hiring-trend numbers.",
5
+ "keywords": [
6
+ "ai-sdk",
7
+ "vercel",
8
+ "ai",
9
+ "tools",
10
+ "agents",
11
+ "jobs",
12
+ "job-search",
13
+ "hiring",
14
+ "salary",
15
+ "hirebase"
16
+ ],
17
+ "homepage": "https://www.hirebase.org/docs/ai-sdk",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/HireBase-1/hirebase-ai-sdk.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/HireBase-1/hirebase-ai-sdk/issues"
24
+ },
25
+ "license": "MIT",
26
+ "author": "Hirebase (https://www.hirebase.org)",
27
+ "type": "module",
28
+ "main": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js"
34
+ }
35
+ },
36
+ "files": [
37
+ "dist"
38
+ ],
39
+ "engines": {
40
+ "node": ">=18"
41
+ },
42
+ "scripts": {
43
+ "build": "tsc -p tsconfig.build.json",
44
+ "typecheck": "tsc --noEmit",
45
+ "test": "vitest run",
46
+ "prepublishOnly": "npm run build"
47
+ },
48
+ "peerDependencies": {
49
+ "ai": "^6.0.0 || ^7.0.0"
50
+ },
51
+ "dependencies": {
52
+ "zod": "^4.0.0"
53
+ },
54
+ "devDependencies": {
55
+ "@types/node": "^22.20.7",
56
+ "ai": "^7.0.188",
57
+ "typescript": "^5.9.3",
58
+ "vitest": "^3.2.7"
59
+ }
60
+ }