Usage
Create client​
import { Conduit } from "@mappa-ai/conduit"
const conduitClient = new Conduit({ apiKey: process.env.CONDUIT_API_KEY! })
Create report job (recommended)​
const receipt = await conduitClient.reports.create({
source: { url: "https://example.com/call.mp3" },
output: { template: "general_report" },
target: { strategy: "dominant" },
webhook: { url: "https://your-app.com/webhooks/conduit" },
idempotencyKey: `report:${userId}:${mediaHash}`,
})
console.info(receipt.jobId, receipt.status)
Source variants​
await conduitClient.reports.create({
source: { mediaId: "media_123" },
output: { template: "general_report" },
target: { strategy: "dominant" },
webhook: { url: "https://your-app.com/webhooks/conduit" },
})
await conduitClient.reports.create({
source: { file: audioBytes, label: "candidate-call" },
output: { template: "general_report" },
target: { strategy: "dominant" },
webhook: { url: "https://your-app.com/webhooks/conduit" },
})
await conduitClient.reports.create({
source: { path: "./calls/candidate-call.mp3", label: "candidate-call" },
output: { template: "general_report" },
target: { strategy: "dominant" },
webhook: { url: "https://your-app.com/webhooks/conduit" },
})
source.urlfetches from the SDK host runtime, then uploads the bytes to Conduit.source.pathresolves from the current working directory in filesystem-capable runtimes.source.url,source.path, and someReadableStreamuploads may buffer in memory before upload when streaming is not available end-to-end.
Webhook consumer​
const payload = await req.text()
await conduitClient.webhooks.verifySignature({
payload,
headers: Object.fromEntries(req.headers),
secret: process.env.CONDUIT_WEBHOOK_SECRET!,
})
const event = conduitClient.webhooks.parseEvent(payload)
if (event.type !== "report.completed") return new Response("ok")
const report = await conduitClient.reports.get(event.data.reportId)
console.info(report.id)
Fallback handle flow​
Use only when you cannot consume webhooks.
const receipt = await conduitClient.reports.create({
source: { url: "https://example.com/call.mp3" },
output: { template: "general_report" },
target: { strategy: "dominant" },
})
for await (const event of receipt.handle?.stream() ?? []) {
if (event.type === "stage") console.info(event.stage, event.progress)
if (event.type === "terminal") break
}
const report = await receipt.handle?.wait({ timeoutMs: 10 * 60_000 })
console.info(report?.id)
Matching​
import { Conduit } from "@mappa-ai/conduit"
const conduitClient = new Conduit({ apiKey: process.env.CONDUIT_API_KEY! })
const receipt = await conduitClient.matching.create({
context: "hiring_team_fit",
target: { entityId: "entity_1" },
group: [{ entityId: "entity_2" }],
})