text
stringlengths
3
8.33k
repo
stringclasses
52 values
path
stringlengths
6
141
language
stringclasses
35 values
sha
stringlengths
64
64
chunk_index
int32
0
273
n_tokens
int32
1
896
, "sponsored by", "funded by ngo", "donated equipment", "temporary facility", "pop-up clinic", "field hospital", "community outreach", "free medical", "free health", "free eye", "free dental", "free screening", ]; /** * Patterns indicating weak operational capability (Q5.3). * Strong clinical...
hacknation
www/lib/ai/tools/medical/classifyServices.ts
TypeScript
dd17816af18f8b8e799c5f3cc6e349c8772dce054b43a08884f817064299f623
1
896
start({ facilityId, region, serviceFilter, focusArea }); try { const conditions = [isNotNull(facilities.id)]; if (facilityId) { conditions.push(eq(facilities.id, facilityId)); } if (region) { conditions.push(ilike(facilities.addressRegion, `%${region}%`)); } if (...
hacknation
www/lib/ai/tools/medical/classifyServices.ts
TypeScript
7783e8418b13fc1040c96081a147f6a236e6c5ade0dfd9bd82ef97a1ec7c9531
2
896
individual_tied" && individualTiedMatches.length > 0) || (focusArea === "camp_missions" && campMissionMatches.length > 0) || (focusArea === "weak_operations" && weakOpMatches.length > 0) || Boolean(facilityId); if (hasRelevantFindings && matchesFocusFilter) { ...
hacknation
www/lib/ai/tools/medical/classifyServices.ts
TypeScript
5bf492cb1d50e84a7339c44519586af06e254d855a1c0895958e7fcd672521d7
3
417
import { tool } from "ai"; import { and, eq, ilike, isNotNull } from "drizzle-orm"; import { z } from "zod"; import { db } from "../../../db"; import { facilities } from "../../../db/schema.facilities"; import { MEDICAL_KNOWLEDGE } from "../../../medical-knowledge"; import { createToolLogger } from "../debug"; import {...
hacknation
www/lib/ai/tools/medical/crossValidateClaims.ts
TypeScript
4d69c62bc70048a70b2f682c82842b2094083c793d24bd6c8c262e37722508df
0
896
, finding: `Claims "${procedure}" but none of the required equipment found (${requiredEquipment.join(", ")}).`, evidence: { claimedProcedure: procedure, requiredEquipment, listedEquipment: equipText.slice(0, 200), ...
hacknation
www/lib/ai/tools/medical/crossValidateClaims.ts
TypeScript
18c24ddcdc5ef058eb45a16010179b06997fae82f1ff2734e798fc08822d83aa
1
610
import { tool } from "ai"; import { eq } from "drizzle-orm"; import { z } from "zod"; import { db } from "../../../db"; import { facilities } from "../../../db/schema.facilities"; import { createToolLogger } from "../debug"; import { DB_QUERY_TIMEOUT_MS, withTimeout } from "../safeguards"; /** * Enrichment validation...
hacknation
www/lib/ai/tools/medical/validateEnrichment.ts
TypeScript
f8d041dc1776f603a4dd45859d24f1b42650faec0b179173f11ef11a8f02fc20
0
896
find((r) => r.toLowerCase().includes(normalized.toLowerCase()) ); if (partial) { return { valid: true, reason: `Partial match to region: ${partial} (verify exact name)`, }; } return { valid: false, reason: `"${value}" is not a recognized region. Known regions for ${countryCode}: ...
hacknation
www/lib/ai/tools/medical/validateEnrichment.ts
TypeScript
75101f79eac83f7ff5c6acf2f847d5148d6c1f5b6ef5ceabbaeb8daba960f9d4
1
896
------------------------------------------------------------------ export const validateEnrichment = tool({ description: "Validate proposed data enrichments or corrections from research/scraping agents before they are applied to the database. Checks for plausibility, contradictions with existing data, and data q...
hacknation
www/lib/ai/tools/medical/validateEnrichment.ts
TypeScript
8c419b08b5a3080aa4a2e3149d0ee52c029f000b6e1fb9b9fe6c5d3cb8700fdb
2
896
().trim(); const isValid = VALID_FACILITY_TYPES.some( (t) => t === normalizedType ); if (!isValid) { status = "flagged"; reason = `Facility type "${value}" is not in standard types: ${VALID_FACILITY_TYPES.join(", ")}. Needs manual review.`; f...
hacknation
www/lib/ai/tools/medical/validateEnrichment.ts
TypeScript
3cc6b02693555e590806bbaf9f8758e8cb6b3c2724636bc43d6c0436df3e80ab
3
896
import FirecrawlApp from "@mendable/firecrawl-js"; import { tool } from "ai"; import { and, eq, ilike, isNotNull } from "drizzle-orm"; import { z } from "zod"; import { db } from "../../../db"; import { facilities } from "../../../db/schema.facilities"; import { createToolLogger } from "../debug"; import { DB_QUERY_TIM...
hacknation
www/lib/ai/tools/web/corroborateClaims.ts
TypeScript
3e1cfe11d7a033604ab5c24e60269d181e5b453e73e91b739c1d0fb021cc00e8
0
896
.specialties, equipment: facilities.equipment, proceduresRaw: facilities.proceduresRaw, specialtiesRaw: facilities.specialtiesRaw, equipmentRaw: facilities.equipmentRaw, website: facilities.website, officialWebsite: facilities.officialWebsite, ...
hacknation
www/lib/ai/tools/web/corroborateClaims.ts
TypeScript
d59051ff7520dc29edd0a33198857341f5d86c92498af69effcc35d28e8ad555
1
896
; for (const result of webResults) { const r = result as Record<string, unknown>; const source = { title: String(r.title ?? "No title"), url: String(r.url ?? ""), snippet: String( r.description ?? r.summary ?? r.ma...
hacknation
www/lib/ai/tools/web/corroborateClaims.ts
TypeScript
27cfe9579229699acfcfb0f9c6f4436d5eebc4968906007c002d884f9460ff36
2
815
import FirecrawlApp from "@mendable/firecrawl-js"; import { tool } from "ai"; import { z } from "zod"; import { createToolLogger } from "../debug"; function getFirecrawlClient() { const apiKey = process.env.FIRECRAWL_API_KEY; if (!apiKey) { throw new Error("FIRECRAWL_API_KEY environment variable is not set"); ...
hacknation
www/lib/ai/tools/web/firecrawl-extract.ts
TypeScript
e395c877607eb5fb138c840966da81d3bbff2b24aff44b6dc4de284899ba6d8b
0
516
import FirecrawlApp from "@mendable/firecrawl-js"; import { tool } from "ai"; import { z } from "zod"; import { createToolLogger } from "../debug"; const MAX_CONTENT_LENGTH = 10_000; function getFirecrawlClient() { const apiKey = process.env.FIRECRAWL_API_KEY; if (!apiKey) { throw new Error("FIRECRAWL_API_KEY...
hacknation
www/lib/ai/tools/web/firecrawl-scrape.ts
TypeScript
c3800540d3bcde6745440c709cc2dc6afef3b2fac8d33a0b89886f6131a13cd9
0
441
import FirecrawlApp from "@mendable/firecrawl-js"; import { tool } from "ai"; import { z } from "zod"; import { createToolLogger } from "../debug"; function getFirecrawlClient() { const apiKey = process.env.FIRECRAWL_API_KEY; if (!apiKey) { throw new Error("FIRECRAWL_API_KEY environment variable is not set"); ...
hacknation
www/lib/ai/tools/web/firecrawl-search.ts
TypeScript
cd99e8e153539d580b37e160ea47815e3c56bd9de0f8ef7d023acbba625502eb
0
532
import { tool } from "ai"; import { z } from "zod"; import { createToolLogger } from "../debug"; /** * OpenRouteService travel time tool. * * Free tier: 2,000 requests/day (no credit card required). * Sign up at: https://openrouteservice.org/dev/#/signup * Requires ORS_API_KEY environment variable. * * Covers V...
hacknation
www/lib/ai/tools/web/openrouteservice.ts
TypeScript
75a9dba7f0d1d6af4f50a8d67b08d80a5e43ef2ed8d030665bddf13cabd2fe4d
0
896
origin || !destination) { return { error: "Route mode requires origin and destination" }; } const url = `${ORS_BASE}/v2/directions/${profile}?api_key=${apiKey}&start=${String(origin.lng)},${String(origin.lat)}&end=${String(destination.lng)},${String(destination.lat)}`; const response...
hacknation
www/lib/ai/tools/web/openrouteservice.ts
TypeScript
6eaaacc2bf0a23a41599ef55b34e8dff2bc98a0705a02fb92a8c3a1998144a16
1
896
(srcLabel, si) => { const row: Record<string, unknown> = { from: srcLabel }; destLabels.forEach((destLabel, di) => { const dur = durations[si]?.[di]; const dist = distances[si]?.[di]; row[destLabel] = dur !== null && dur !== undefined ? `${formatDu...
hacknation
www/lib/ai/tools/web/openrouteservice.ts
TypeScript
b8b61dc2ce8b13287d538eec544ce1aa2612fc49342db6a85893a32ace8b2d9c
2
896
-Type": "application/json", }, body: JSON.stringify({ locations: [[center.lng, center.lat]], range: rangeSeconds, range_type: "time", attributes: ["area", "reachfactor"], }), signal: AbortSignal.timeout(30_000), } ); if (!response.ok...
hacknation
www/lib/ai/tools/web/openrouteservice.ts
TypeScript
24da5fe2e13bef8b2cacdfc48142f17cfa508a23a42881d0b17c27cdca9cea5e
3
234
import { tool } from "ai"; import { z } from "zod"; import { createToolLogger } from "../debug"; /** * Overpass API tool — cross-reference facility data with OpenStreetMap. * * Free, no API key required. * Finds healthcare facilities in OpenStreetMap near a given location. * * Covers VF Agent question 3.5: * "W...
hacknation
www/lib/ai/tools/web/overpass-facilities.ts
TypeScript
c1ffe8cc4c0be4ec91acb2bbf5db15747298a0f561e0b82a88c32e652dce3cf3
0
896
] ?? "Unnamed", amenity: tags.amenity ?? "unknown", lat: elLat, lng: elLng, address: [tags["addr:street"], tags["addr:city"], tags["addr:state"]] .filter(Boolean) .join(", ") || null, phone: tags.phone ?? tags["contact:phone"] ?? ...
hacknation
www/lib/ai/tools/web/overpass-facilities.ts
TypeScript
fc3d2d460ffb9bf73eb0e562390ab0742e46470f59974edf9c05e1ec0c3e94bb
1
377
import { tool } from "ai"; import { z } from "zod"; import { createToolLogger } from "../debug"; /** * WHO Global Health Observatory (GHO) API tool. * * Free, no API key required. * API docs: https://www.who.int/data/gho/info/gho-odata-api * Base URL: https://ghoapi.azureedge.net/api/ * * Covers VF Agent questi...
hacknation
www/lib/ai/tools/web/who-gho.ts
TypeScript
19ce489157f582e631050593fef6a662defef4f3b9945ea279f78025bc285a73
0
896
{ const url = `${WHO_GHO_BASE}/${indicatorCode}?$filter=SpatialDim eq '${countryCode}'&$orderby=TimeDim desc&$top=${String(limit)}`; const response = await fetch(url, { signal: AbortSignal.timeout(15_000), }); if (!response.ok) { throw new Error(`WHO GHO API returned ${String(response.status)}`); } ...
hacknation
www/lib/ai/tools/web/who-gho.ts
TypeScript
e432f57e4d80e40c53365f1ecff7e0f33c2b3a4949a0c6f00953c92d398bec94
1
896
year.", }; if (countries.length === 1) { const countryData = results[countryCode] ?? {}; output.country = countryCode; output.indicators = countryData; // Generate quick summary const summaryLines: string[] = []; for (const key of indicators) { con...
hacknation
www/lib/ai/tools/web/who-gho.ts
TypeScript
96f626e74f8a7e3a85e1f7b3b740605222a9fbadb888fbfb19978e6c4b99cd49
2
408
import type { UIMessageStreamWriter } from "ai"; import type { Session } from "next-auth"; import { codeDocumentHandler } from "@/artifacts/code/server"; import { sheetDocumentHandler } from "@/artifacts/sheet/server"; import { textDocumentHandler } from "@/artifacts/text/server"; import type { ArtifactKind } from "@/c...
hacknation
www/lib/artifacts/server.ts
TypeScript
30f018f415f44e3de5467d8dea4d5eb812c97e3cb87d995e53f5b02a266d65ea
0
631
import { drizzle } from "drizzle-orm/postgres-js"; import postgres from "postgres"; // biome-ignore lint: Forbidden non-null assertion. export const client = postgres(process.env.POSTGRES_URL!); export const db = drizzle(client);
hacknation
www/lib/db/index.ts
TypeScript
ae2e65c5c10ab4380d3a7b5659a94e0103291f8da675efe23c39385bf6ba467d
0
58
import { config } from "dotenv"; import { drizzle } from "drizzle-orm/postgres-js"; import { migrate } from "drizzle-orm/postgres-js/migrator"; import postgres from "postgres"; config({ path: ".env.local", }); const runMigrate = async () => { if (!process.env.POSTGRES_URL) { console.log("⏭️ POSTGRES_URL not ...
hacknation
www/lib/db/migrate.ts
TypeScript
8e6365d2589b7d08798a93f8cb9ed24aae66ef27e653ae5249e40830a6a479b6
0
253
import "server-only"; import { and, asc, count, desc, eq, gt, gte, inArray, lt, type SQL, } from "drizzle-orm"; import type { ArtifactKind } from "@/components/artifact"; import type { VisibilityType } from "@/components/visibility-selector"; import { ChatSDKError } from "../errors"; import { gener...
hacknation
www/lib/db/queries.ts
TypeScript
0c4ee734384cc8ec9dc7da9ebe4483e8246079097ccdbf034c266bf652f60cef
0
896
}) .where(and(eq(vote.messageId, messageId), eq(vote.chatId, chatId))); } return await db.insert(vote).values({ chatId, messageId, isUpvoted: type === "up", }); } catch (_error) { throw new ChatSDKError("bad_request:database", "Failed to vote message"); } } export async fu...
hacknation
www/lib/db/queries.ts
TypeScript
c88a8722d99894489cb55f78072ffe789812fe5906db86f6789a9eb6f08cf154
2
896
createdAt, timestamp)) ); const messageIds = messagesToDelete.map( (currentMessage) => currentMessage.id ); if (messageIds.length > 0) { await db .delete(vote) .where( and(eq(vote.chatId, chatId), inArray(vote.messageId, messageIds)) ); return awa...
hacknation
www/lib/db/queries.ts
TypeScript
8c1fbfc5ae2fbffdbf9e836672a6ffafb5a966ff98babe377a85dfbe021be916
3
896
chatId, userId, name, contentType, url, textContent, }: { chatId: string; userId: string; name: string; contentType: string; url: string; textContent: string | null; }): Promise<ChatDocument> { try { const [saved] = await db .insert(chatDocument) .values({ chatId, ...
hacknation
www/lib/db/queries.ts
TypeScript
74aac1015fd5239bc1bba366cb4867a960d87e28f789b0fdade67c46538b2eba
4
896
search cached providers" ); } } export async function getProviderById({ id, }: { id: string; }): Promise<Provider | null> { try { const [found] = await db .select() .from(provider) .where(eq(provider.id, id)) .limit(1); return found ?? null; } catch (_error) { throw ne...
hacknation
www/lib/db/queries.ts
TypeScript
661306a46d911c937a4fb02736bee6289606c2bb040e7e286b7b264ee360c14f
5
103
import { bigint, doublePrecision, index, pgTable, serial, text, timestamp, uniqueIndex, varchar, } from "drizzle-orm/pg-core"; // --------------------------------------------------------------------------- // demographics_countries — one row per country (national-level indicators) // ----------------...
hacknation
www/lib/db/schema.demographics.ts
TypeScript
ba62aa5308d6b86aad35bddb1a25e3694648b6d687fb520a96ad800119a3b2a6
0
896
--------------------------------------------------------------------- // demographics_benchmarks — WHO / developed country reference values // --------------------------------------------------------------------------- export const demographicsBenchmarks = pgTable("demographics_benchmarks", { id: serial("id").primar...
hacknation
www/lib/db/schema.demographics.ts
TypeScript
04dbef63562dab7451a70253324420e2a968f15cb9961621f2215f51705d41c4
1
294
import { boolean, doublePrecision, index, integer, pgTable, serial, text, timestamp, vector, } from "drizzle-orm/pg-core"; export const facilities = pgTable( "facilities", { id: serial("id").primaryKey(), pkUniqueId: integer("pk_unique_id").unique(), name: text("name").notNull(), ...
hacknation
www/lib/db/schema.facilities.ts
TypeScript
aba599c82f40df2f96c3d145b72d4357097aff14df3c04c1729d62d9cfbcff4f
0
662
import type { InferSelectModel } from "drizzle-orm"; import { boolean, doublePrecision, foreignKey, index, integer, json, pgTable, primaryKey, serial, text, timestamp, uuid, varchar, } from "drizzle-orm/pg-core"; export const user = pgTable("User", { id: uuid("id").primaryKey().notNull().de...
hacknation
www/lib/db/schema.ts
TypeScript
3336fc5707630882ed280af4d2e3e8ef2f3c977010d0d1a9d50fc23796da3c42
0
896
(), createdAt: timestamp("createdAt").notNull(), title: text("title").notNull(), content: text("content"), kind: varchar("text", { enum: [ "text", "code", "image", "sheet", "facility-map", "medical-desert", "stats-dashboard", "mission...
hacknation
www/lib/db/schema.ts
TypeScript
18f15929f0fa648fbdfba3d58bdc5842f299a45d9ffcd7994c9ecc2db926635c
1
896
: index("idx_conv_messages_chat").on(table.chatId, table.timestamp), }) ); // ─── Chat-scoped document uploads ─────────────────────────────────────── export const chatDocument = pgTable( "ChatDocument", { id: uuid("id").primaryKey().notNull().defaultRandom(), chatId: uuid("chatId") .notNull() ...
hacknation
www/lib/db/schema.ts
TypeScript
3e620b6f32917438fec1e5fad3a4bcc5cfade76b58fede59762d92f2f0378a53
2
602
ALTER TABLE "Chat" DROP COLUMN IF EXISTS "lastContext";
hacknation
www/lib/db/migrations/0008_flat_forgotten_one.sql
SQL
91b47413f2bb010c75221ffcae2aaf1207b9628091beb1ae2ab7721914d285fd
0
13
CREATE TABLE IF NOT EXISTS "ConversationMessage" ( "id" serial PRIMARY KEY NOT NULL, "chat_id" text NOT NULL, "user_id" text, "role" text NOT NULL, "content" text NOT NULL, "timestamp" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "WorkingMemory" ( "id" text PRIMARY KEY ...
hacknation
www/lib/db/migrations/0009_futuristic_crusher_hogan.sql
SQL
2e21361baa0a4d53c9a2b6b8d1da17d70d7c22918665650b3c6e154e37e92e64
0
543
CREATE TABLE IF NOT EXISTS "demographics_benchmarks" ( "id" serial PRIMARY KEY NOT NULL, "benchmark_name" text NOT NULL, "doctors_per_1000" double precision, "nurses_per_1000" double precision, "beds_per_1000" double precision, "maternal_mortality_per_100k" double precision, "under5_mortality_per_1k" double prec...
hacknation
www/lib/db/migrations/0010_ordinary_devos.sql
SQL
9a3982e0fad0edc7152607441e2e1d378be452051caa0f0d101720f1040222a6
0
402
CREATE TABLE IF NOT EXISTS "ChatDocument" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "chatId" uuid NOT NULL, "userId" uuid NOT NULL, "name" text NOT NULL, "contentType" text NOT NULL, "url" text NOT NULL, "textContent" text, "createdAt" timestamp NOT NULL ); --> statement-breakpoint CREATE TABL...
hacknation
www/lib/db/migrations/0011_romantic_santa_claus.sql
SQL
5cf5253bb1da973d358c19cb7e44f6dc3bb22e675b92b0ad9c7296b6a5e0c07d
0
419
{ "id": "e8347120-0684-4fd2-ab9f-63b917a205ff", "prevId": "31934f42-f6af-42a3-9320-b2e86fb67e81", "version": "7", "dialect": "postgresql", "tables": { "public.Chat": { "name": "Chat", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "...
hacknation
www/lib/db/migrations/meta/0009_snapshot.json
JSON
3f73e1ea0e0ae695ca8c2eb66526044850cc07e0b10b60352c3979df407b016d
0
896
": true } }, "indexes": {}, "foreignKeys": { "Message_chatId_Chat_id_fk": { "name": "Message_chatId_Chat_id_fk", "tableFrom": "Message", "tableTo": "Chat", "columnsFrom": ["chatId"], "columnsTo": ["id"], "onDelete": "no action...
hacknation
www/lib/db/migrations/meta/0009_snapshot.json
JSON
0e5451e5704bd2490c65a78d371911f20f8d3ac8b465ee541909b8053515183d
2
896
], "columnsTo": ["id", "createdAt"], "onDelete": "no action", "onUpdate": "no action" } }, "compositePrimaryKeys": { "Suggestion_id_pk": { "name": "Suggestion_id_pk", "columns": ["id"] } }, "uniqueConstraints": {} }, ...
hacknation
www/lib/db/migrations/meta/0009_snapshot.json
JSON
537012a461060b5358220e3899b9b7641b583efc72e628bf673dc608b42b39d3
3
896
: "no action", "onUpdate": "no action" } }, "compositePrimaryKeys": { "Vote_chatId_messageId_pk": { "name": "Vote_chatId_messageId_pk", "columns": ["chatId", "messageId"] } }, "uniqueConstraints": {} }, "public.WorkingMemory": { ...
hacknation
www/lib/db/migrations/meta/0009_snapshot.json
JSON
64e47b14d53591fe8c7a85358303ed5c078e2eaa150598838869e17e6d70707f
4
896
, "address_country": { "name": "address_country", "type": "text", "primaryKey": false, "notNull": false, "default": "'Ghana'" }, "country_code": { "name": "country_code", "type": "text", "primaryKey": false, ...
hacknation
www/lib/db/migrations/meta/0009_snapshot.json
JSON
cfa7f652f9ea30367cec907b53cbcfa696924df88709666995ac224715cfbfc3
5
896
"primaryKey": false, "notNull": false }, "capabilities": { "name": "capabilities", "type": "text[]", "primaryKey": false, "notNull": false }, "affiliation_types": { "name": "affiliation_types", "type": "text[]", ...
hacknation
www/lib/db/migrations/meta/0009_snapshot.json
JSON
87958b5cf3fdeca6ee1bed5a5babb195a7eb32a5a88af2ebf5afa1d22e128905
6
645
", "primaryKey": false, "notNull": false }, "capabilities": { "name": "capabilities", "type": "text[]", "primaryKey": false, "notNull": false }, "affiliation_types": { "name": "affiliation_types", "type": "te...
hacknation
www/lib/db/migrations/meta/0010_snapshot.json
JSON
5d5eb0a1c41bbf2705183b942880078dad90f34e2d49d0cb700474e0c66b561f
6
896
, "under5_mortality_per_1k": { "name": "under5_mortality_per_1k", "type": "double precision", "primaryKey": false, "notNull": false }, "ophthalmologists_per_capita": { "name": "ophthalmologists_per_capita", "type": "double precision", ...
hacknation
www/lib/db/migrations/meta/0010_snapshot.json
JSON
4c447df23ebf8038481749eeceaa31cfefc494f9dad81d856639ea08cf0477c4
7
896
: "country_code", "type": "varchar(3)", "primaryKey": false, "notNull": true }, "region": { "name": "region", "type": "text", "primaryKey": false, "notNull": true }, "capital": { "name": "capital", ...
hacknation
www/lib/db/migrations/meta/0010_snapshot.json
JSON
d8ebc1badaf05cf4018bad519e2b40506812cafea9bd5ed9808edcc24d9e830c
8
896
expression": "country_code", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": {}, "composi...
hacknation
www/lib/db/migrations/meta/0010_snapshot.json
JSON
d00ea746734a9e97ec7789c9477a5b7682c454d9f8f6f082d6e7ecd339c1b66d
9
129
{ "id": "aa66ba94-63b2-421d-9ebb-c0e45df356d2", "prevId": "88315cd9-ddcf-4a14-9cf4-86feda2b8e44", "version": "7", "dialect": "postgresql", "tables": { "public.Chat": { "name": "Chat", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "...
hacknation
www/lib/db/migrations/meta/0011_snapshot.json
JSON
ac9748d1c87893cd04c1c1f1f5216da421138eb1083c16b6d25f313ae1c20574
0
896
onUpdate": "no action" }, "ChatDocument_userId_User_id_fk": { "name": "ChatDocument_userId_User_id_fk", "tableFrom": "ChatDocument", "tableTo": "User", "columnsFrom": [ "userId" ], "columnsTo": [ "id" ], ...
hacknation
www/lib/db/migrations/meta/0011_snapshot.json
JSON
b1435d3076b8b0f6de665fcd987cb42b1516ee14ad3a5e9b5eb8667099940b95
1
896
" ] } }, "uniqueConstraints": {} }, "public.Message_v2": { "name": "Message_v2", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_...
hacknation
www/lib/db/migrations/meta/0011_snapshot.json
JSON
9f96ebf2c02d4d37700d676b0c70795978c9fbe12950ff6041125d1e3db0634e
2
896
{ "name": "address", "type": "text", "primaryKey": false, "notNull": false }, "city": { "name": "city", "type": "text", "primaryKey": false, "notNull": false }, "region": { "name": "region", ...
hacknation
www/lib/db/migrations/meta/0011_snapshot.json
JSON
8ee0f2fee81c3ad0059c00cfd2eb96dedd778657472de6cc772fe6da05ffadab
3
896
: "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": false, "notNull": true, "default": "gen_random_uuid()" }, "chatId": { "name": "chatId", "type": "uuid", "primaryKey": false, "not...
hacknation
www/lib/db/migrations/meta/0011_snapshot.json
JSON
804df52ef15761f5f0a076a7d11250e6a1f81e7df0adeef51140d52d3e2d5459
4
896
", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "email": { "name": "email", "type": "varchar(64)", "primaryKey": false, "notNull": true }, "password": { "name": "password", ...
hacknation
www/lib/db/migrations/meta/0011_snapshot.json
JSON
16afe7ae9aad2b5af4f84c890d61437564933a556976af0552d599b02e9a829d
5
896
"scope": { "name": "scope", "type": "text", "primaryKey": false, "notNull": true }, "chat_id": { "name": "chat_id", "type": "text", "primaryKey": false, "notNull": false }, "user_id": { "name": "use...
hacknation
www/lib/db/migrations/meta/0011_snapshot.json
JSON
4bde326e49690fad62971574534ed85905896fa25f6039402aa2532fc461bdf2
6
896
: false }, "lng": { "name": "lng", "type": "double precision", "primaryKey": false, "notNull": false }, "num_doctors": { "name": "num_doctors", "type": "integer", "primaryKey": false, "notNull": false ...
hacknation
www/lib/db/migrations/meta/0011_snapshot.json
JSON
48a570d1688dd2fd69def62b1bdcf087dfe20cb50a0a7e888fd9b4ffb3766d47
7
896
embedding": { "name": "embedding", "type": "vector(1536)", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp", "primaryKey": false, "notNull": false, "default": "now(...
hacknation
www/lib/db/migrations/meta/0011_snapshot.json
JSON
9dc11dc02c7ba73245e0a2300aeab67e9ea91105a821671847746bad1f481ff5
8
896
false, "notNull": false }, "urban_percent": { "name": "urban_percent", "type": "double precision", "primaryKey": false, "notNull": false }, "rural_percent": { "name": "rural_percent", "type": "double precision", ...
hacknation
www/lib/db/migrations/meta/0011_snapshot.json
JSON
2e8873802136275d73470166c9c538c408b6ba16dcd943a999c14600b67f9177
10
839
{ "version": "7", "dialect": "postgresql", "entries": [ { "idx": 0, "version": "7", "when": 1728598022383, "tag": "0000_keen_devos", "breakpoints": true }, { "idx": 1, "version": "7", "when": 1730207363999, "tag": "0001_sparkling_blue_marvel", ...
hacknation
www/lib/db/migrations/meta/_journal.json
JSON
7ef349b4eb40923e45afd4417da388e40ad2694236078a1a59489ed223a45753
0
467
import { textblockTypeInputRule } from "prosemirror-inputrules"; import type { Transaction } from "prosemirror-state"; import type { EditorView } from "prosemirror-view"; import type { MutableRefObject } from "react"; import { schema as markdownSchema } from "prosemirror-markdown"; import { buildContentFromDocument } ...
hacknation
www/lib/editor/config.ts
TypeScript
89736dc31ccb76f576c212b4d4b97347037873b608c17a142500e957a9acadc4
0
279
"use client"; import { defaultMarkdownParser, defaultMarkdownSerializer } from "prosemirror-markdown"; import type { Node } from "prosemirror-model"; import { Decoration, DecorationSet, type EditorView } from "prosemirror-view"; import { createSuggestionWidget, type UISuggestion } from "./suggestions"; export const ...
hacknation
www/lib/editor/functions.tsx
TypeScript
9c3a26c17c739981420f1ac32e39132773cfd01f791b5677a187c2d35a8d0be3
0
280
/** * Enrichment application — merges, validates, and applies proposed changes. * * Deduplicates changes from multiple strategies, validates each using * the same rules as the validateEnrichment tool, and applies only * accepted changes to the database. */ import { eq } from "drizzle-orm"; import { VALID_FACIL...
hacknation
www/lib/enrichment/apply.ts
TypeScript
0dd3cb85e2d99f75756722aa119f015ff2789dd439bdb2e874623117d3c53103
0
896
: StrategyResult[] ): Promise<EnrichmentSummary> { // 1. Flatten all proposed changes const allChanges: ProposedChange[] = []; for (const result of results) { for (const change of result.changes) { allChanges.push(change); } } if (allChanges.length === 0) { return { applied: 0, flagged: 0, ...
hacknation
www/lib/enrichment/apply.ts
TypeScript
d3a94ca7884036065605e5bcf4ecd64a483263c755edcf0842c67151128eec9a
1
896
{String(existingValue)}`, }); continue; } } // Skip if existing value is present and not contradicted (confirms existing data) if ( existingValue !== null && existingValue !== "" && !contradiction.contradicts ) { details.push({ field, value:...
hacknation
www/lib/enrichment/apply.ts
TypeScript
a4a668d218755c7b0991033cbb40d222b1b16f13fc15d419681c2753219b9d76
2
362
/** * Gap detection for facility enrichment. * * Analyzes a facility row and determines which enrichment strategies * should run based on missing fields. */ import { facilities } from "../db/schema.facilities"; // --------------------------------------------------------------------------- // Types // -----------...
hacknation
www/lib/enrichment/detect-gaps.ts
TypeScript
c7a22f21ffc7cc76ae2655cd7b75e0433119990dbc093f710db7222a79bffd44
0
896
add("web-search"); missingFields.push("year_established"); } if (!facility.addressRegion) { strategies.add("web-search"); missingFields.push("address_region"); } if (!facility.description) { strategies.add("web-search"); missingFields.push("description"); } // OSM lookup for cross-refer...
hacknation
www/lib/enrichment/detect-gaps.ts
TypeScript
18aed56b94fa14bfee4a2e0a33176ea2bcfa28a31bd116edee3c2e35efa4c492
1
196
/** * On-demand facility enrichment orchestrator. * * When a facility is viewed, this module checks for missing data and * runs parallel enrichment strategies (geocoding, web search, OSM) * to fill gaps — without blocking the API response. * * Guardrails: * - 7-day cooldown between enrichment attempts per facil...
hacknation
www/lib/enrichment/index.ts
TypeScript
db4d94a56662d38a51c9604276143c8b3e5ca62c19da3963d3ee02865bfa23f5
0
896
.enrichmentStatus === "enriching") { if (facility.enrichedAt) { const elapsed = Date.now() - facility.enrichedAt.getTime(); if (elapsed < STALE_ENRICHING_MS) { return; } } // Stale "enriching" — allow retry } // 3. Cooldown check — skip if recently enriched if ( facility...
hacknation
www/lib/enrichment/index.ts
TypeScript
151daeaf569a165643ff4d64e7b29ee44f22261c753c6e06ed21a84342537c8f
1
706
/** * Geocode enrichment strategy. * * Resolves missing lat/lng coordinates using OpenStreetMap Nominatim. * Free API, no key required. Rate limit: 1 request per second. */ import type { Facility, StrategyResult } from "../detect-gaps"; const NOMINATIM_BASE = "https://nominatim.openstreetmap.org/search"; const S...
hacknation
www/lib/enrichment/strategies/geocode.ts
TypeScript
3619449edfcbef28d3048650ffd9b7c10c226cb93bdcec6bc6d3599c157c7251
0
560
/** * OpenStreetMap enrichment strategy. * * Queries the Overpass API for healthcare facilities near the facility's * location and cross-references data from OpenStreetMap. */ import { CITY_COORDS } from "../../ghana"; import type { Facility, ProposedChange, StrategyResult } from "../detect-gaps"; const OVERPASS...
hacknation
www/lib/enrichment/strategies/osm-lookup.ts
TypeScript
10bd327bc2004d26a81b4b49694a4676a2324b4531dd0a7237b983b613e783b4
0
896
", value: tags["healthcare:speciality"], source: osmSource, confidence: "medium", }); } // Extract precise coordinates if facility is missing them const matchLat = match.lat ?? match.center?.lat; const matchLng = match.lon ?? match.center?.lon; if (!facility.lat && ma...
hacknation
www/lib/enrichment/strategies/osm-lookup.ts
TypeScript
e5caba63cdd96e069fd7eecb86ee104982d4ef15472db00ccc83f2b0cc13eb6a
1
347
/** * Web search enrichment strategy. * * Uses Firecrawl to search the web for facility information, * then extracts structured data from the top results. */ import FirecrawlApp from "@mendable/firecrawl-js"; import type { Facility, ProposedChange, StrategyResult } from "../detect-gaps"; function getFirecrawlCli...
hacknation
www/lib/enrichment/strategies/web-search.ts
TypeScript
136a742b0a75d1cc14d978085e73b94ad5d388a505217b28308c6ed7e46216ee
0
896
>; // Step 4: Map extracted data to proposed changes if (!facility.numDoctors) { const val = parseNumeric( extractField( data, "number_of_doctors", "numberOfDoctors", "doctors", "physician_count" ) ); if (val !== null && val > ...
hacknation
www/lib/enrichment/strategies/web-search.ts
TypeScript
d50f5251401b6a67754374efd030b53293239998d80a93b82f84b8da0c2711b8
1
785
/** * Geocode facilities that are missing lat/lng using OSM Nominatim. * * Free, no API key required. Rate limit: 1 request per second. * Only geocodes facilities that have an address_city but no coordinates. * * Usage: * npx tsx scripts/geocode-facilities.ts * npx tsx scripts/geocode-facilities.ts --dry-ru...
hacknation
www/scripts/geocode-facilities.ts
TypeScript
382634b2c2e3d6a485a772a4d90d90d424c57684911de7edd3e9f50674f848fa
0
896
if (!isDryRun) { await db .update(facilities) .set({ lat: coords.lat, lng: coords.lng }) .where(sql`${facilities.id} = ${fac.id}`); } updated++; } else { console.log(` ✗ ${fac.name} (${fac.city}) — not found`); failed++; } // Respect Nominatim ...
hacknation
www/scripts/geocode-facilities.ts
TypeScript
45abe4f8395341604d7fbf23e4741409dd3407e9e1f58c690ac0460dd7e79a7e
1
208
import dotenv from "dotenv"; import postgres from "postgres"; dotenv.config({ path: ".env.local" }); const connectionString = process.env.POSTGRES_URL; if (!connectionString) { throw new Error("POSTGRES_URL environment variable is not set"); } const sql = postgres(connectionString, { max: 1 }); async function ma...
hacknation
www/scripts/migrate.ts
TypeScript
75890591fd497e72422799179d6067be6edb95e15e4673d6e47e31855972b0c8
0
419
/** * Seed script for demographics tables. * * Reads from the existing ghana-demographics.ts hardcoded data and inserts * into the demographics_countries, demographics_regions, and demographics_benchmarks * tables. Uses upsert (ON CONFLICT DO UPDATE) so it's safe to re-run. * * Usage: * pnpm db:seed-demograph...
hacknation
www/scripts/seed-demographics.ts
TypeScript
e3e15f71486c337000bccaeb120f1db6f59477ef469181c565234de3189247cf
0
896
, under5MortalityPer1k: r.healthIndicators.under5MortalityPer1k, doctorsPer1000: r.healthIndicators.doctorsPerCapita * 1000, nursesPer1000: r.healthIndicators.nursesPerCapita * 1000, diseaseBurden: r.diseaseBurden, dataSource: "Ghana Statistical Service 2021 Census, WHO...
hacknation
www/scripts/seed-demographics.ts
TypeScript
c10777f6bbde089b7a7a1edd44ac752fe204d06b9d72060e97ab4d67add40fa5
1
523
import dotenv from "dotenv"; import { eq, isNull } from "drizzle-orm"; import { drizzle } from "drizzle-orm/postgres-js"; import postgres from "postgres"; import { facilities } from "../lib/db/schema.facilities"; import { embed } from "../lib/embed"; dotenv.config({ path: ".env.local" }); const connectionString = pro...
hacknation
www/scripts/seed-embeddings.ts
TypeScript
f325fceb13c9d193a2ec24fd9fd2ff70ef1bde738a9f16200d2d230454c8ade2
0
794
import fs from "node:fs"; import path from "node:path"; import { parse } from "csv-parse/sync"; import dotenv from "dotenv"; import { drizzle } from "drizzle-orm/postgres-js"; import postgres from "postgres"; import { facilities } from "../lib/db/schema.facilities"; import { CITY_COORDS } from "../lib/ghana"; dotenv.c...
hacknation
www/scripts/seed-facilities.ts
TypeScript
b677e10dc46e11915eccbc6d6dc588cf1475fb7fc2bf3ac65f61d8b7ca153c80
0
896
/ Wait, I don't see lat/lng in the header I read earlier! // "source_url,name,pk_unique_id,mongo DB,specialties,procedure,equipment,capability,organization_type,content_table_id,phone_numbers,email,websites,officialWebsite,yearEstablished,acceptsVolunteers,facebookLink,twitterLink,linkedinLink,instagramLink,logo,addr...
hacknation
www/scripts/seed-facilities.ts
TypeScript
df488724f1c7eef5d8d1dc88a4b7bd3294ecd7173e4f30ff8372f58a69f10d6f
1
896
= 50; for (let i = 0; i < facilitiesData.length; i += chunkSize) { const chunk = facilitiesData.slice(i, i + chunkSize); await db.insert(facilities).values(chunk).onConflictDoNothing(); console.log(`Inserted chunk ${i / chunkSize + 1}`); } console.log("Seeding completed successfully."); await clien...
hacknation
www/scripts/seed-facilities.ts
TypeScript
7c3675019b2870aed05177a8925dec83145dfb13904e43556625caa08dee0e97
2
121
import { expect, test } from "@playwright/test"; const MODEL_BUTTON_REGEX = /Gemini|Claude|GPT|Grok/i; test.describe("Model Selector", () => { test.beforeEach(async ({ page }) => { await page.goto("/"); }); test("displays a model button", async ({ page }) => { // Look for any button with model-related ...
hacknation
www/tests/e2e/model-selector.test.ts
TypeScript
6e9746d2a41292202437a217deb44d568bde85cf1dcbfa02153d41e1e8e9284b
0
696
import type { NextConfig } from "next"; const nextConfig: NextConfig = { /* config options here */ }; export default nextConfig;
hacknation-landing
magicuidesign-agent-template-67c4ec6bf25256173c4d6a87d3033f21d3200443/next.config.ts
TypeScript
614bce25b089c3f19b1e17a6346c74b858034040154c6621e7d35303004767cc
0
29
{ "name": "agent-template", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev --turbopack", "build": "next build", "start": "next start", "lint": "next lint" }, "dependencies": { "@number-flow/react": "^0.5.7", "@radix-ui/react-accordion": "^1.2.3", "@radix-ui/re...
hacknation-landing
magicuidesign-agent-template-67c4ec6bf25256173c4d6a87d3033f21d3200443/package.json
JSON
11d2ca6c81c1ba4374b12a722b2c59d00de93bf7391d92827593c8d91fd4a639
0
500
: oklch(0.145 0 0); --primary: oklch(0.205 0 0); --primary-foreground: oklch(0.985 0 0); --secondary: oklch(54.65% 0.246 262.87); --secondary-foreground: oklch(0.205 0 0); --muted: oklch(0.97 0 0); --muted-foreground: oklch(0.556 0 0); --accent: oklch(100% 0 0); --accent-foreground: oklch(96.7% 0.003 26...
hacknation-landing
magicuidesign-agent-template-67c4ec6bf25256173c4d6a87d3033f21d3200443/src/app/globals.css
CSS
7011c7e95c147e0a7c557bb26886521dcd03319f6c3445036638d543fa51c006
2
798
import { Navbar } from "@/components/sections/navbar"; import { ThemeProvider } from "@/components/theme-provider"; import { siteConfig } from "@/lib/site"; import type { Metadata, Viewport } from "next"; import { Geist, Geist_Mono } from "next/font/google"; import "./globals.css"; const geistSans = Geist({ variable...
hacknation-landing
magicuidesign-agent-template-67c4ec6bf25256173c4d6a87d3033f21d3200443/src/app/layout.tsx
TypeScript
262dde02d3c563feddfaf3f0d7c3f26a318fe72d67b639099638214963c0dba7
0
433
import { Metadata } from "next"; import { siteConfig } from "@/lib/site"; export const metadata: Metadata = { title: siteConfig.name, description: siteConfig.description, keywords: [ "SkyAgent", "AI", "Agent", "Magic UI", "Freelancer", "UI/UX", "Developer", "React Template", "...
hacknation-landing
magicuidesign-agent-template-67c4ec6bf25256173c4d6a87d3033f21d3200443/src/app/metadata.ts
TypeScript
e570bb41e23ff08b828a88b21b1d82447cfcc748fdf82a5dde5a21c307a4223f
0
266
import { headers } from "next/headers"; import { ImageResponse } from "next/og"; // Configuration exports export const runtime = "edge"; export const alt = "SkyAgent - AI-powered agents with Magic UI"; export const size = { width: 1200, height: 630, }; export const contentType = "image/png"; export default async ...
hacknation-landing
magicuidesign-agent-template-67c4ec6bf25256173c4d6a87d3033f21d3200443/src/app/opengraph-image.tsx
TypeScript
591960ab804c3c9988e22046bc14c9a662ad4bdf20659f38b988cefd2a5b9885
0
317
import { BentoSection } from "@/components/sections/bento-section"; import { CompanyShowcase } from "@/components/sections/company-showcase"; import { CTASection } from "@/components/sections/cta-section"; import { FAQSection } from "@/components/sections/faq-section"; import { FeatureSection } from "@/components/secti...
hacknation-landing
magicuidesign-agent-template-67c4ec6bf25256173c4d6a87d3033f21d3200443/src/app/page.tsx
TypeScript
33e08de4f4a5d3a62070a1377970ecd5164eb3e36e3b7d4495229ea64ad02704
0
278
import { cn } from "@/lib/utils"; export const Icons = { logo: ({ className }: { className?: string }) => ( <svg width="42" height="24" viewBox="0 0 42 24" fill="none" xmlns="http://www.w3.org/2000/svg" className={cn("size-4 fill-[var(--secondary)]", className)} > <g...
hacknation-landing
magicuidesign-agent-template-67c4ec6bf25256173c4d6a87d3033f21d3200443/src/components/icons.tsx
TypeScript
4d08345fc60aad7e87d434d66b3ae23702a0eb3fb85a666ab4160f38ce6ffd8a
0
896
.0537 17.8882L14.9621 12.6566H15.6253L17.5263 17.8882H16.9811L16.4211 16.3187H14.159L13.599 17.8882H13.0537ZM14.3285 15.8324H16.2516L15.2937 13.1061L14.3285 15.8324ZM18.026 17.8882V12.6566H18.5271V17.8882H18.026ZM21.5495 18.0061C20.1642 18.0061 19.2506 16.9745 19.2506 15.2798C19.2506 13.585 20.1642 12.5387 21.5495 12.5...
hacknation-landing
magicuidesign-agent-template-67c4ec6bf25256173c4d6a87d3033f21d3200443/src/components/icons.tsx
TypeScript
bd67723c43d1b8b0ff5096fffe814138d4f5d1b8e105395d38473b6922be4ddd
1
896
26.3271 14.8059 26.3959 15.1252 26.4696C15.5869 26.5678 15.9553 26.6931 16.2304 26.8454C16.5055 26.9927 16.702 27.1671 16.8199 27.3685C16.9427 27.565 17.0041 27.7984 17.0041 28.0685C17.0041 28.3829 16.9231 28.658 16.761 28.8938C16.5989 29.1247 16.368 29.304 16.0683 29.4317C15.7736 29.5594 15.4322 29.6233 15.0441 29.623...
hacknation-landing
magicuidesign-agent-template-67c4ec6bf25256173c4d6a87d3033f21d3200443/src/components/icons.tsx
TypeScript
ee2701583d12f06144dcdd57f09ee0c791628783f38897c0ccbf627de3d53463
2
896
L23.781 16.0977C23.6877 16.6871 23.4519 17.1538 23.0736 17.4977C22.7003 17.8366 22.214 18.0061 21.6147 18.0061ZM24.571 12.6566H26.4058C26.784 12.6566 27.1082 12.7205 27.3784 12.8482C27.6535 12.971 27.8647 13.1503 28.0121 13.3861C28.1594 13.617 28.2331 13.8945 28.2331 14.2187C28.2331 14.538 28.1594 14.8156 28.0121 15.05...
hacknation-landing
magicuidesign-agent-template-67c4ec6bf25256173c4d6a87d3033f21d3200443/src/components/icons.tsx
TypeScript
4b6e139640a5c1ba153389966c009dbbd70314ee41b9f59f3aa6a5ac5f2e8ff4
3
896
C19.9746 15.7197 20.5823 15.1432 20.8306 14.6275C20.8349 14.6186 20.8427 14.6117 20.8525 14.6082C20.917 14.5857 20.7513 14.9203 20.694 15.036L20.694 15.036L20.694 15.036C20.6842 15.0557 20.6777 15.069 20.6759 15.0731C20.6145 15.2129 20.5891 15.3212 20.5999 15.398C20.6298 15.6155 20.8211 15.675 21.0262 15.6307C21.5992 1...
hacknation-landing
magicuidesign-agent-template-67c4ec6bf25256173c4d6a87d3033f21d3200443/src/components/icons.tsx
TypeScript
adf8250289f58da37e3d4bc0ac72fcb453d3b4aae065d9eaf40da7731c8dc054
4
896
L25.1897 9.80346L25.1897 9.80343L25.1898 9.80339L25.1898 9.80335C25.2475 9.31007 25.3026 8.83918 25.5743 8.39709C25.8844 7.89295 26.4303 7.68143 27.0394 7.63903C27.8626 7.58143 28.5885 7.82244 29.3168 8.19341C30.1191 8.60232 30.9333 8.98772 31.7594 9.34963C31.7987 9.36683 31.7968 9.37636 31.7537 9.3782C31.7442 9.37881 ...
hacknation-landing
magicuidesign-agent-template-67c4ec6bf25256173c4d6a87d3033f21d3200443/src/components/icons.tsx
TypeScript
ac3715355cec7da66752dc3ae6e8d5fb2966d7945ddfb25041b847e5426a0983
5
896