Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
feat: add cover letter tool schema, result type and nested-tool registry
Khuram Niaz46a09712da3d
diff --git a/__tests__/agentSchema.spec.ts b/__tests__/agentSchema.spec.tsindex b2e7f8e..0ded43f 100644--- a/__tests__/agentSchema.spec.ts+++ b/__tests__/agentSchema.spec.ts@@ -3,7 +3,13 @@ import {AgentAddJobSchema,AgentAddJobParseSchema,AgentChatRequestSchema,+ AgentCoverLetterSchema,} from "@/models/agent.schema";+import {+ AGENT_CHAT_TERMINAL_TOOLS,+ AGENT_NESTED_TOOLS,+ isNestedTool,+} from "@/models/agent.model";import { McpAddJobInputShape } from "@/models/mcp.schema";import { JOB_STATUS_VALUES } from "@/lib/constants";@@ -86,3 +92,36 @@ describe("AgentChatRequestSchema", () => {expect(AgentChatRequestSchema.safeParse({}).success).toBe(false);});});++describe("AgentCoverLetterSchema", () => {+ // The letter is written for the job the user is looking at. Any job-shaped+ // input is an IDOR surface the model could be talked into filling.+ it("exposes exactly one optional field and no job identifier", () => {+ expect(Object.keys(AgentCoverLetterSchema.shape)).toEqual(["resumeTitle"]);+ expect(AgentCoverLetterSchema.safeParse({}).success).toBe(true);+ });++ it("tells the model to omit the title unless the user named one", () => {+ expect(AgentCoverLetterSchema.shape.resumeTitle.description).toMatch(/omit/i);+ });+});++describe("nested tool registry", () => {+ it("names every tool that runs its own generation", () => {+ expect([...AGENT_NESTED_TOOLS]).toEqual([+ "review_resume",+ "match_job",+ "generate_cover_letter",+ ]);+ expect(isNestedTool("generate_cover_letter")).toBe(true);+ expect(isNestedTool("add_job")).toBe(false);+ });++ // A tool that runs its own generation MUST end the turn, or one turn can+ // chain two of them past the turn deadline and discard both.+ it("makes every nested tool terminal", () => {+ for (const name of AGENT_NESTED_TOOLS) {+ expect([...AGENT_CHAT_TERMINAL_TOOLS]).toContain(name);+ }+ });+});diff --git a/src/models/agent.model.ts b/src/models/agent.model.tsindex e07a01a..533419b 100644--- a/src/models/agent.model.ts+++ b/src/models/agent.model.ts@@ -126,6 +126,43 @@ export type AgentMatchJobResult =| { status: "unreadable"; what: "job" | "resume"; title: string; reason: string }| { status: "generation_failed"; jobTitle: string; reason: string };+// What generate_cover_letter returns to the model AND to the result card. The+// letter body is here so a follow-up ("make it shorter") answers from it; the+// resume text and the job description are not.+export type AgentCoverLetterResult =+ | {+ status: "ok";+ jobId: string;+ jobTitle: string;+ company: string;+ resumeId: string;+ resumeTitle: string;+ body: string;+ coverLetterId?: string;+ coverLetterTitle?: string;+ saved: boolean;+ saveError?: string;+ }+ | { status: "no_job" }+ | { status: "no_description"; jobTitle: string }+ | { status: "needs_selection"; resumes: { id: string; title: string }[] }+ | { status: "no_resumes" }+ | { status: "unreadable"; what: "job" | "resume"; title: string; reason: string }+ | { status: "generation_failed"; jobTitle: string; reason: string };++// Tools that run their own generation and stream it as transient parts. The+// transcript and the provider both branch on this rather than on a chain of+// name comparisons that grows with every nested tool.+export const AGENT_NESTED_TOOLS = [+ "review_resume",+ "match_job",+ "generate_cover_letter",+] as const;++export function isNestedTool(name: string): boolean {+ return (AGENT_NESTED_TOOLS as readonly string[]).includes(name);+}+// Tools that end the turn. The result card renders deterministically from// structured fields, so a second generation just to narrate it is 10-30s of// local inference for a sentence that could be wrong. A tool that runs its@@ -133,6 +170,5 @@ export type AgentMatchJobResult =// and blow the turn timeout, discarding both.export const AGENT_CHAT_TERMINAL_TOOLS = ["add_job",- "review_resume",- "match_job",+ ...AGENT_NESTED_TOOLS,] as const;diff --git a/src/models/agent.schema.ts b/src/models/agent.schema.tsindex 791a18c..1dc0215 100644--- a/src/models/agent.schema.ts+++ b/src/models/agent.schema.ts@@ -65,3 +65,12 @@ export const AgentMatchJobSchema = z.object({});export type AgentMatchJobInput = z.infer<typeof AgentMatchJobSchema>;++// No job field of any kind, for the same reason AgentMatchJobSchema has none:+// the letter is written for the job the user is viewing, and the id comes from+// server-held page context.+export const AgentCoverLetterSchema = z.object({+ resumeTitle: z.string().optional().describe("The title of the resume the letter should draw on, as the user referred to it. Omit this entirely if the user did not name one — the app then uses the resume linked to the job, or their default resume."),+});++export type AgentCoverLetterInput = z.infer<typeof AgentCoverLetterSchema>;