profileOrgs (nightly 05:45, 25/run, easy-win orgs best-first per the plan's coarse-match-gates-profiling rule): two-pass Gemini flash — Google Search-grounded research (groundingMetadata = citation universe) then JSON-schema extraction citing only from it. Overwrites the stub profile (mission/programs/geography/funders/staff/news/sources/ confidence); re-embeds mission fit from researched text unless identity unconfirmed or confidence <0.5 (then the NTEE embedding stays — unverified research must not steer scoring). Detail page renders researched programs w/ source links, funders, staff. Fixes: org_profiles.confidence is float4 — 0.2 stores as 0.20000000298 so 'confidence <= 0.2' excluded every stub (epsilon comparison); RR7 loader serialization turns unknown into never (hoisted casts). Live: 55 orgs profiled (41 research-grade, 2 low-confidence, 0 failed). Scoring effect verified both directions: Annie's Angels x NIH mammalian models fit 19->12; Seacoast Pathways x Foundation for Seacoast Health fit 25/30 — and the researched knownFunders independently names that funder. 161 tests green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@novelpad/outreach-ai
LLM access layer for the HelmDocs grant-match outreach engine. Modeled on
novelpad-desktop's packages/ai, trimmed to what this engine needs: a
Vertex/Gemini client, an embeddings helper, model-tier constants, and two
structured-output agents (org profiler, mission-fit judge).
Provenance
src/gemini.ts and src/embeddings.ts are copied near-verbatim from
novelpad-desktop at commit 62c56b87 (see the header comment in each file
for the exact source path). They are kept as close to the original as
compiles standalone in this workspace — do not "clean up" drift between them
and the source without checking whether the source has moved on too.
src/agents/*/run.ts follow the structured-JSON-output pattern from
novelpad-desktop's packages/ai/src/agents/grant/section-drafter/run.ts
(prompt builder + generateContent with responseMimeType: 'application/json'
and a hand-written responseSchema), but are new code for this repo's domain,
not copies — both are currently NOT IMPLEMENTED stubs pending the
source-fetching / hard-gate scoring infrastructure they depend on. Each stub's
doc comment shows the intended call shape.
Never mix embedding models
generateQueryEmbedding / generateDocumentEmbedding / generateDocumentEmbeddings
are pinned to gemini-embedding-001 at outputDimensionality: 1536. Do not
change either value, and do not add a second embedding model/dimensionality
into this package. Every vector this package produces has to remain
comparable (same model, same dimensionality) against every other vector
already stored in the HelmDocs RAG index — switching models or dimensions
silently corrupts similarity search for anything embedded before the switch,
with no error at write time. If a better embedding model becomes available,
that's a deliberate, full-reindex migration, not a constant change here.
Model tiering
See src/models.ts: BULK_MODEL (gemini-2.5-flash) for high-volume
mechanical work (classification, effort estimates, first-pass org-profile
extraction); JUDGE_MODEL (gemini-2.5-pro) for anything a wrong answer
could put in front of a real prospect (mission-fit judge, email
personalization QA).
Layout
src/gemini.ts—getAi()Vertex client singleton +CHAT_MODEL.src/embeddings.ts— query/document embedding helpers.src/models.ts—BULK_MODEL/JUDGE_MODELconstants.src/agents/org-profiler/—OrgProfileSchema(per-field source URL + confidence) and the profiler agent stub.src/agents/mission-fit-judge/—MissionFitVerdictSchema(fit,citedOrgProgram,citedGrantPriority,reasoning) and the judge agent stub.src/index.ts— barrel export.