{"version":3,"file":"index.cjs","names":["z.coerce.number","ConduitError","parseRes","parseReq","targetSelector","webhookConfig","jobReceipt","z.coerce.number","sharingStatus","toggleSharingBody","sharingQuery","z.coerce.boolean","z.coerce.number","UnsupportedRuntimeError","materializeSource","InvalidSourceError","parseRes","ConduitError","parseReq","z.coerce\n\t\t.number","parseRes","withDeadline","TimeoutError","JobFailedError","JobCanceledError","StreamError","ConduitError","reportsTargetSelector","z.coerce.number","randomId","parseReq","parseRes","toJobStage","ConduitError","validateTarget","validateTimerangeTarget","InvalidSourceError","ConduitError","UnsupportedRuntimeError","materializeSource","parseRes","PsychometricsModel.psychometricsResult","parseReq","parseRes","jobReceipt","ConduitError","randomId","InvalidSourceError","WebhookVerificationError","ConduitError","InitializationError","Transport","ConduitError","ApiError","AuthError","InitializationError","InsufficientCreditsError","InvalidSourceError","JobCanceledError","JobFailedError","RateLimitError","RemoteFetchError","RemoteFetchTimeoutError","RemoteFetchTooLargeError","RequestAbortedError","SourceError","StreamError","TimeoutError","UnsupportedRuntimeError","ValidationError","WebhookVerificationError"],"sources":["../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/compat.js","../../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/coerce.js","../../contracts/src/v1/entities.ts","../src/resources/entities.ts","../../contracts/src/v1/reports.ts","../../contracts/src/v1/files.ts","../src/resources/files.ts","../../contracts/src/v1/jobs.ts","../src/resources/jobs.ts","../../contracts/src/v1/matching-analysis.ts","../src/resources/matching-analysis.ts","../../contracts/src/v2/psychometrics.ts","../src/resources/psychometrics.ts","../src/resources/reports.ts","../src/resources/webhooks.ts","../src/Conduit.ts","../src/index.ts"],"sourcesContent":["// Zod 3 compat layer\nimport * as core from \"../core/index.js\";\n/** @deprecated Use the raw string literal codes instead, e.g. \"invalid_type\". */\nexport const ZodIssueCode = {\n    invalid_type: \"invalid_type\",\n    too_big: \"too_big\",\n    too_small: \"too_small\",\n    invalid_format: \"invalid_format\",\n    not_multiple_of: \"not_multiple_of\",\n    unrecognized_keys: \"unrecognized_keys\",\n    invalid_union: \"invalid_union\",\n    invalid_key: \"invalid_key\",\n    invalid_element: \"invalid_element\",\n    invalid_value: \"invalid_value\",\n    custom: \"custom\",\n};\nexport { $brand, config } from \"../core/index.js\";\n/** @deprecated Use `z.config(params)` instead. */\nexport function setErrorMap(map) {\n    core.config({\n        customError: map,\n    });\n}\n/** @deprecated Use `z.config()` instead. */\nexport function getErrorMap() {\n    return core.config().customError;\n}\n/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */\nexport var ZodFirstPartyTypeKind;\n(function (ZodFirstPartyTypeKind) {\n})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));\n","import * as core from \"../core/index.js\";\nimport * as schemas from \"./schemas.js\";\nexport function string(params) {\n    return core._coercedString(schemas.ZodString, params);\n}\nexport function number(params) {\n    return core._coercedNumber(schemas.ZodNumber, params);\n}\nexport function boolean(params) {\n    return core._coercedBoolean(schemas.ZodBoolean, params);\n}\nexport function bigint(params) {\n    return core._coercedBigint(schemas.ZodBigInt, params);\n}\nexport function date(params) {\n    return core._coercedDate(schemas.ZodDate, params);\n}\n","import { z } from \"zod\";\n\n/**\n * Entities module Zod schemas and types.\n *\n * Provides workspace-scoped labels for speaker entities.\n * Labels allow workspaces to identify analyzed speakers with human-readable names.\n */\n/**\n * Label validation schema.\n * - Max 64 characters\n * - Trimmed whitespace\n * - Free-form text (allows spaces, special characters)\n */\nexport const label = z\n\t.string()\n\t.trim()\n\t.min(1, \"Label must be at least 1 character\")\n\t.max(64, \"Label must be at most 64 characters\");\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Query Parameters\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Query parameters for listing entities.\n */\nexport const listEntitiesQuery = z.object({\n\t/** Cursor for pagination */\n\tcursor: z.string().optional(),\n\t/** Number of entities per page (1-100, default 20) */\n\tlimit: z.coerce.number().min(1).max(100).default(20),\n});\nexport type ListEntitiesQuery = z.infer<typeof listEntitiesQuery>;\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Request Bodies\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Request body for updating an entity (PATCH).\n */\nexport const updateEntityBody = z.object({\n\t/** Human-readable label for this entity (null to clear) */\n\tlabel: label.nullable().optional(),\n});\nexport type UpdateEntityBody = z.infer<typeof updateEntityBody>;\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Response Schemas\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Single entity response with label and metadata.\n */\nexport const entityResponse = z.object({\n\tcreatedAt: z.iso.datetime(),\n\tid: z.string(),\n\t/** Workspace-scoped human-readable label */\n\tlabel: z.string().nullable(),\n\t/** When this entity was last seen in a processed media file */\n\tlastSeenAt: z.iso.datetime().nullable(),\n\t/** Number of media files where this entity appears */\n\tmediaCount: z.number(),\n});\nexport type EntityResponse = z.infer<typeof entityResponse>;\n\n/**\n * Paginated list of entities response.\n */\nexport const listEntitiesResponse = z.object({\n\tcursor: z.string().nullable(),\n\tentities: z.array(entityResponse),\n\thasMore: z.boolean(),\n});\nexport type ListEntitiesResponse = z.infer<typeof listEntitiesResponse>;\n","import {\n\tentityResponse,\n\tlistEntitiesQuery,\n\tlistEntitiesResponse,\n\tupdateEntityBody,\n} from \"@mappa-ai/contracts/v1/entities\";\nimport { ConduitError } from \"../errors\";\nimport type { Entity, ListEntitiesResponse } from \"../types\";\nimport type { Transport } from \"./transport\";\nimport { parseReq, parseRes } from \"./validate\";\n\nexport type ListEntitiesOptions = {\n\tlimit?: number;\n\tcursor?: string;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\nexport class EntitiesResource {\n\tprivate readonly transport: Transport;\n\n\tconstructor(transport: Transport) {\n\t\tthis.transport = transport;\n\t}\n\n\tasync get(\n\t\tentityId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Entity> {\n\t\tif (!entityId)\n\t\t\tthrow new ConduitError(\"entityId must be a non-empty string\", {\n\t\t\t\tcode: \"invalid_request\",\n\t\t\t});\n\t\tconst res = await this.transport.request<Entity>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/entities/${encodeURIComponent(entityId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\treturn parseRes(entityResponse, res.data, \"entities.get\");\n\t}\n\n\tasync list(opts?: ListEntitiesOptions): Promise<ListEntitiesResponse> {\n\t\tconst query = parseReq(\n\t\t\tlistEntitiesQuery,\n\t\t\t{ cursor: opts?.cursor, limit: opts?.limit },\n\t\t\t\"entities.list query\",\n\t\t);\n\n\t\tconst res = await this.transport.request<ListEntitiesResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/v1/entities\",\n\t\t\tquery: {\n\t\t\t\tlimit: String(query.limit),\n\t\t\t\t...(query.cursor ? { cursor: query.cursor } : {}),\n\t\t\t},\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\treturn parseRes(listEntitiesResponse, res.data, \"entities.list\");\n\t}\n\n\tasync *listAll(\n\t\topts?: Omit<ListEntitiesOptions, \"cursor\">,\n\t): AsyncIterable<Entity> {\n\t\tlet cursor: string | undefined;\n\t\tlet hasMore = true;\n\t\twhile (hasMore) {\n\t\t\t// biome-ignore lint/performance/noAwaitInLoops: cursor-based pagination is inherently sequential\n\t\t\tconst page = await this.list({ ...opts, cursor });\n\t\t\tfor (const entity of page.entities) {\n\t\t\t\tyield entity;\n\t\t\t}\n\t\t\tcursor = page.cursor ?? undefined;\n\t\t\thasMore = page.hasMore;\n\t\t}\n\t}\n\n\tasync update(\n\t\tentityId: string,\n\t\tbody: { label?: string | null },\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Entity> {\n\t\tif (!entityId)\n\t\t\tthrow new ConduitError(\"entityId must be a non-empty string\", {\n\t\t\t\tcode: \"invalid_request\",\n\t\t\t});\n\t\tconst payload = parseReq(updateEntityBody, body, \"entities.update body\");\n\t\tconst res = await this.transport.request<Entity>({\n\t\t\tbody: payload,\n\t\t\tmethod: \"PATCH\",\n\t\t\tpath: `/v1/entities/${encodeURIComponent(entityId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\treturn parseRes(entityResponse, res.data, \"entities.update\");\n\t}\n}\n","import { z } from \"zod\";\n\nconst targetSelector = z\n\t.object({\n\t\tentity_id: z.string().min(1).max(256).trim().nullish(),\n\t\thint: z.string().min(1).max(1024).trim().nullish(),\n\t\ton_miss: z.enum([\"fallback_dominant\", \"error\"]).default(\"error\"),\n\t\tspeaker_index: z.number().int().min(0).nullish(),\n\t\tstrategy: z.enum([\n\t\t\t\"dominant\",\n\t\t\t\"timerange\",\n\t\t\t\"entity_id\",\n\t\t\t\"magic_hint\",\n\t\t\t\"speaker_index\",\n\t\t]),\n\t\ttimerange: z\n\t\t\t.object({\n\t\t\t\tend_seconds: z.number().min(0).nullish(),\n\t\t\t\tstart_seconds: z.number().min(0).nullish(),\n\t\t\t})\n\t\t\t.nullish(),\n\t})\n\t.refine(\n\t\t(data) => {\n\t\t\t// Validate strategy-specific fields\n\t\t\tif (data.strategy === \"entity_id\" && !data.entity_id) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tdata.strategy === \"magic_hint\" &&\n\t\t\t\t(!data.hint || data.hint.trim() === \"\")\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tdata.strategy === \"speaker_index\" &&\n\t\t\t\ttypeof data.speaker_index !== \"number\"\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t\t{\n\t\t\tmessage:\n\t\t\t\t\"entity_id is required for entity_id strategy, hint is required for magic_hint strategy, speaker_index is required for speaker_index strategy\",\n\t\t},\n\t);\ntype TargetSelector = z.infer<typeof targetSelector>;\n\n/**\n * Available report templates.\n * All templates analyze the same behavioral map (LayeredLenses) but apply\n * different lenses optimized for specific use cases.\n */\nconst reportTemplates = z.enum([\"sales_playbook\", \"general_report\"]);\ntype ReportTemplate = z.infer<typeof reportTemplates>;\ntype TemplateParams = {\n\tgeneral_report: Record<string, never>;\n\tsales_playbook: Record<string, never>;\n};\nconst reportOutput = z\n\t.object({\n\t\ttemplate: reportTemplates,\n\t\ttemplateParams: z.record(z.string(), z.unknown()).optional(),\n\t})\n\t.strict();\nconst webhookConfig = z\n\t.object({\n\t\theaders: z.record(z.string(), z.string()).optional(),\n\t\turl: z.url(),\n\t})\n\t.optional();\n\n/**\n * Human-readable template labels for auto-generating report names.\n */\nconst templateLabels: Record<string, string> = {\n\tgeneral_report: \"General Report\",\n\tsales_playbook: \"Sales Playbook\",\n};\nfunction generateDefaultLabel(template: string): string {\n\tconst templateName = templateLabels[template] ?? template;\n\tconst dateStr = new Date().toLocaleDateString(\"en-US\", {\n\t\tday: \"numeric\",\n\t\tmonth: \"short\",\n\t\tyear: \"numeric\",\n\t});\n\treturn `${templateName} - ${dateStr}`;\n}\n/**\n * Report output language (ISO 639-1). Treated as English when omitted.\n */\nconst reportLanguage = z.enum([\"en\", \"es\", \"pt\"]);\ntype ReportLanguage = z.infer<typeof reportLanguage>;\nconst reportCreateJobBody = z.object({\n\t/** Optional explicit override for the resolved entity's workspace-scoped label */\n\tentityLabel: z.string().trim().min(1).max(64).optional(),\n\tidempotencyKey: z.string().optional(),\n\t/** Optional output language (en, es, pt). Defaults to en when omitted. */\n\tlanguage: reportLanguage.optional(),\n\t/** Custom label for the report (auto-generated from template + date if omitted) */\n\tlabel: z.string().trim().min(1).max(64).optional(),\n\tmedia: z.object({ mediaId: z.string() }),\n\toutput: reportOutput,\n\ttarget: targetSelector, // REQUIRED - must specify target strategy\n\twebhook: webhookConfig,\n});\ntype ReportCreateJobBody = z.infer<typeof reportCreateJobBody>;\nconst jobReceipt = z.object({\n\testimatedWaitSec: z.number().optional(),\n\tjobId: z.string(),\n\tstage: z.string().optional(),\n\tstatus: z.enum([\"queued\", \"running\"]),\n});\ntype JobReceipt = z.infer<typeof jobReceipt>;\nconst listStatus = z.enum([\"completed\", \"processing\", \"failed\"]);\ntype ListStatus = z.infer<typeof listStatus>;\nconst listDateRange = z.enum([\n\t\"all\",\n\t\"last_7_days\",\n\t\"last_30_days\",\n\t\"last_90_days\",\n]);\ntype ListDateRange = z.infer<typeof listDateRange>;\nconst listOutputFormat = z.enum([\"markdown\", \"json\"]);\ntype ListOutputFormat = z.infer<typeof listOutputFormat>;\nconst listReportsQuery = z.object({\n\tdateRange: listDateRange.default(\"all\"),\n\tentityId: z.string().optional(),\n\tlimit: z.coerce.number().int().min(1).max(50).default(5),\n\tmediaId: z.string().optional(),\n\tpage: z.coerce.number().int().min(1).default(1),\n\tsearch: z.string().trim().min(1).max(128).optional(),\n\tstatus: listStatus.optional(),\n\tworkspaceId: z.string(),\n\ttemplate: reportTemplates.optional(),\n});\ntype ListReportsQuery = z.infer<typeof listReportsQuery>;\nconst listReportItem = z.object({\n\tcreatedAt: z.iso.datetime(),\n\tentity: z\n\t\t.object({\n\t\t\tid: z.string(),\n\t\t\tlabel: z.string().nullable(),\n\t\t})\n\t\t.nullable(),\n\tid: z.string(),\n\tlabel: z.string().nullable(),\n\toutput: z.object({\n\t\tavailableFormats: z.array(listOutputFormat),\n\t}),\n\tstatus: listStatus,\n\ttemplate: reportTemplates,\n});\ntype ListReportItem = z.infer<typeof listReportItem>;\nconst listReportsResponse = z.object({\n\titems: z.array(listReportItem),\n\tpagination: z.object({\n\t\tlimit: z.number().int().min(1),\n\t\tpage: z.number().int().min(1),\n\t\ttotalItems: z.number().int().min(0),\n\t\ttotalPages: z.number().int().min(0),\n\t}),\n});\ntype ListReportsResponse = z.infer<typeof listReportsResponse>;\nconst reportViewQuery = z.object({\n\tworkspaceId: z.string(),\n});\ntype ReportViewQuery = z.infer<typeof reportViewQuery>;\nconst reportJsonSectionKey = z.enum([\n\t\"dominating_traits\",\n\t\"how_they_think\",\n\t\"how_they_operate\",\n\t\"what_drives_them\",\n\t\"how_they_connect\",\n\t\"how_they_handle_feedback\",\n\t\"pressure_response\",\n\t\"how_to_get_their_best\",\n\t\"how_to_handle_the_hard_parts\",\n\t\"bottom_line\",\n\t\"what_drives_a_yes\",\n\t\"how_to_build_rapport_fast\",\n\t\"buying_tendencies\",\n\t\"how_they_handle_pushback_and_objections\",\n\t\"how_they_deal_when_a_deal_gets_sticky\",\n\t\"how_to_close\",\n\t\"how_to_follow_up\",\n]);\ntype ReportJsonSectionKey = z.infer<typeof reportJsonSectionKey>;\nconst reportJsonParagraphSectionKey = z.enum([\n\t\"how_they_think\",\n\t\"how_they_operate\",\n\t\"what_drives_them\",\n\t\"how_they_connect\",\n\t\"how_they_handle_feedback\",\n\t\"pressure_response\",\n\t\"bottom_line\",\n\t\"what_drives_a_yes\",\n\t\"how_to_build_rapport_fast\",\n\t\"buying_tendencies\",\n\t\"how_they_handle_pushback_and_objections\",\n\t\"how_they_deal_when_a_deal_gets_sticky\",\n]);\nconst reportJsonActionItem = z\n\t.object({\n\t\tcontext: z.string().min(1),\n\t\ttitle: z.string().min(1),\n\t})\n\t.strict();\nconst reportJsonParagraphSection = z\n\t.object({\n\t\tbody: z.string().min(1),\n\t\tkey: reportJsonParagraphSectionKey,\n\t\tkind: z.literal(\"paragraph\"),\n\t\ttitle: z.string().min(1),\n\t})\n\t.strict();\nconst reportJsonTraitsSection = z\n\t.object({\n\t\tbody: z.string().min(1),\n\t\tkey: z.literal(\"dominating_traits\"),\n\t\tkind: z.literal(\"traits\"),\n\t\tphrases: z.tuple([z.string().min(1), z.string().min(1), z.string().min(1)]),\n\t\ttitle: z.string().min(1),\n\t})\n\t.strict();\nconst reportJsonActionsSection = z\n\t.object({\n\t\titems: z.array(reportJsonActionItem).min(1),\n\t\tkey: z.enum([\n\t\t\t\"how_to_get_their_best\",\n\t\t\t\"how_to_handle_the_hard_parts\",\n\t\t\t\"how_to_close\",\n\t\t\t\"how_to_follow_up\",\n\t\t]),\n\t\tkind: z.literal(\"actions\"),\n\t\ttitle: z.string().min(1),\n\t})\n\t.strict();\nconst reportJsonSection = z.discriminatedUnion(\"kind\", [\n\treportJsonParagraphSection,\n\treportJsonTraitsSection,\n\treportJsonActionsSection,\n]);\ntype ReportJsonSection = z.infer<typeof reportJsonSection>;\nconst reportJson = z\n\t.object({\n\t\tmeta: z\n\t\t\t.object({\n\t\t\t\tprompt: z\n\t\t\t\t\t.object({\n\t\t\t\t\t\tlabels: z.array(z.string()),\n\t\t\t\t\t\tname: z.string().min(1),\n\t\t\t\t\t\tversion: z.number().int().positive(),\n\t\t\t\t\t})\n\t\t\t\t\t.strict(),\n\t\t\t\trender: z\n\t\t\t\t\t.object({\n\t\t\t\t\t\tattempts: z.number().int().positive(),\n\t\t\t\t\t\tmodel: z.string().min(1),\n\t\t\t\t\t\tprovider: z.enum([\"openai\", \"anthropic\"]),\n\t\t\t\t\t})\n\t\t\t\t\t.strict(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tschemaVersion: z.literal(2),\n\t\tsections: z.array(reportJsonSection).min(1),\n\t\tsummary: z.string().min(1),\n\t\ttemplate: reportTemplates,\n\t\ttitle: z.string().min(1),\n\t})\n\t.strict();\ntype ReportJson = z.infer<typeof reportJson>;\nconst cardContent = z.object({\n\tcontent: z.string(),\n\ticon: z.string(),\n\ttitle: z.string(),\n\ttype: z.literal(\"card\"),\n});\ntype CardContent = z.infer<typeof cardContent>;\nconst textContent = z.object({\n\tcontent: z.string(),\n\ttitle: z.string().optional(),\n\ttype: z.literal(\"text\"),\n});\ntype TextContent = z.infer<typeof textContent>;\nconst gridContent = z.object({\n\tcolumns: z.union([z.literal(2), z.literal(3), z.literal(4)]),\n\titems: z.array(cardContent),\n\ttype: z.literal(\"grid\"),\n});\ntype GridContent = z.infer<typeof gridContent>;\nconst illustrationContent = z.object({\n\ttype: z.literal(\"illustration\"),\n\tvariant: z.enum([\"conversation\", \"growth\", \"connection\", \"analysis\"]),\n});\ntype IllustrationContent = z.infer<typeof illustrationContent>;\nconst sectionContent = z.discriminatedUnion(\"type\", [\n\tcardContent,\n\ttextContent,\n\tgridContent,\n\tillustrationContent,\n]);\ntype SectionContent = z.infer<typeof sectionContent>;\nconst reportSection = z.object({\n\tsection_content: z.union([\n\t\tsectionContent,\n\t\tz.array(sectionContent),\n\t\tz.unknown(), // Legacy fallback for backward compatibility\n\t]),\n\tsection_title: z.string(),\n});\ntype ReportSection = z.infer<typeof reportSection>;\nconst reportProvenance = z\n\t.object({\n\t\tbaselineSampleIds: z.array(z.string()).min(1),\n\t\tbehaviorMapId: z.string(),\n\t})\n\t.strict();\ntype ReportProvenance = z.infer<typeof reportProvenance>;\nconst reportResponse = z\n\t.object({\n\t\tcreatedAt: z.string(),\n\t\tentity: z\n\t\t\t.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tlabel: z.string().nullable(),\n\t\t\t})\n\t\t\t.strict()\n\t\t\t.optional(),\n\t\tid: z.string(),\n\t\tjson: reportJson.nullish(),\n\t\tjobId: z.string().optional(),\n\t\tlabel: z.string().optional(),\n\t\tmarkdown: z.string().nullish(),\n\t\tmedia: z\n\t\t\t.object({\n\t\t\t\tmediaId: z.string().optional(),\n\t\t\t\turl: z.string().optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\toutput: z\n\t\t\t.object({\n\t\t\t\ttemplate: z.enum([\"sales_playbook\", \"general_report\"]),\n\t\t\t})\n\t\t\t.strict(),\n\t\tprovenance: reportProvenance.optional(),\n\t})\n\t.strict();\ntype ReportResponse = z.infer<typeof reportResponse>;\nconst sharingStatus = z.object({\n\tactive: z.boolean(),\n\tshareUrl: z.url().nullable(),\n});\ntype SharingStatus = z.infer<typeof sharingStatus>;\nconst toggleSharingBody = z.object({\n\tactive: z.boolean(),\n\tworkspaceId: z.string(),\n});\ntype ToggleSharingBody = z.infer<typeof toggleSharingBody>;\nconst sharingQuery = z.object({\n\tworkspaceId: z.string(),\n});\ntype SharingQuery = z.infer<typeof sharingQuery>;\n\nexport type {\n\tCardContent,\n\tGridContent,\n\tIllustrationContent,\n\tJobReceipt,\n\tListDateRange,\n\tListOutputFormat,\n\tListReportItem,\n\tListReportsQuery,\n\tListReportsResponse,\n\tListStatus,\n\tReportCreateJobBody,\n\tReportJson,\n\tReportJsonSection,\n\tReportJsonSectionKey,\n\tReportLanguage,\n\tReportProvenance,\n\tReportResponse,\n\tReportSection,\n\tReportTemplate,\n\tReportViewQuery,\n\tSectionContent,\n\tSharingQuery,\n\tSharingStatus,\n\tTargetSelector,\n\tTemplateParams,\n\tTextContent,\n\tToggleSharingBody,\n};\nexport {\n\tcardContent,\n\tgenerateDefaultLabel,\n\tgridContent,\n\tillustrationContent,\n\tjobReceipt,\n\tlistDateRange,\n\tlistOutputFormat,\n\tlistReportItem,\n\tlistReportsQuery,\n\tlistReportsResponse,\n\tlistStatus,\n\treportCreateJobBody,\n\treportJson,\n\treportJsonSection,\n\treportLanguage,\n\treportOutput,\n\treportProvenance,\n\treportResponse,\n\treportSection,\n\treportTemplates,\n\treportViewQuery,\n\tsectionContent,\n\tsharingQuery,\n\tsharingStatus,\n\ttargetSelector,\n\ttextContent,\n\ttoggleSharingBody,\n\twebhookConfig,\n};\n","import { z } from \"zod\";\nimport { reportTemplates } from \"./reports\";\n\n// ═══════════════════════════════════════════════════════════════════════\n// RETENTION SCHEMAS\n// ═══════════════════════════════════════════════════════════════════════\n\nexport const retentionInfo = z.object({\n\tdaysRemaining: z\n\t\t.number()\n\t\t.int()\n\t\t.nullable()\n\t\t.describe(\"Days until expiry (null if locked or deleted)\"),\n\texpiresAt: z.iso\n\t\t.datetime()\n\t\t.nullable()\n\t\t.describe(\"When the file will expire (null if locked)\"),\n\tlocked: z\n\t\t.boolean()\n\t\t.describe(\"Whether the file is locked from automatic deletion\"),\n});\nexport type RetentionInfo = z.infer<typeof retentionInfo>;\n\nexport const retentionUpdateBody = z.object({\n\tlock: z.boolean().describe(\"Set to true to lock, false to unlock\"),\n});\nexport type RetentionUpdateBody = z.infer<typeof retentionUpdateBody>;\n\nexport const retentionUpdateResponse = z.object({\n\tmediaId: z.string(),\n\tmessage: z.string(),\n\tretentionLock: z.boolean(),\n});\nexport type RetentionUpdateResponse = z.infer<typeof retentionUpdateResponse>;\n\n// ═══════════════════════════════════════════════════════════════════════\n// FILE SCHEMAS\n// ═══════════════════════════════════════════════════════════════════════\n\nexport const mediaSource = z.enum([\n\t\"NOTETAKER\",\n\t\"MANUAL_UPLOAD\",\n\t\"PLAYGROUND\",\n\t\"SDK\",\n]);\nexport type MediaSource = z.infer<typeof mediaSource>;\n\nexport const mediaProcessingStatus = z.enum([\n\t\"PENDING\",\n\t\"PROCESSING\",\n\t\"COMPLETED\",\n\t\"FAILED\",\n]);\nexport type MediaProcessingStatus = z.infer<typeof mediaProcessingStatus>;\n\nexport const manualUploadReportTemplates = z.preprocess(\n\t(val) => (typeof val === \"string\" ? [val] : val),\n\tz\n\t\t.array(reportTemplates)\n\t\t.min(1)\n\t\t.max(2)\n\t\t.refine((value) => new Set(value).size === value.length, {\n\t\t\tmessage: \"Report templates must be unique\",\n\t\t}),\n);\nexport type ManualUploadReportTemplate = z.infer<\n\ttypeof manualUploadReportTemplates\n>[number];\n\nexport const uploadResponse = z.object({\n\tcontentType: z.string(),\n\tcreatedByApiKeyId: z.string().nullable(),\n\tcreatedByUserId: z.string(),\n\tcreatedAt: z.string(),\n\tdurationSeconds: z.number().nullish(),\n\tlabel: z.string(),\n\tmediaId: z.string(),\n\tsource: mediaSource,\n\tsizeBytes: z.number().int().nullish(),\n\tworkspaceId: z.string(),\n});\nexport type UploadResponse = z.infer<typeof uploadResponse>;\n\nexport const fileResponse = z.object({\n\tcontentType: z.string(),\n\tcreatedByApiKeyId: z.string().nullable(),\n\tcreatedByUserId: z.string(),\n\tcreatedAt: z.iso.datetime(),\n\tdurationSeconds: z.number().nullish(),\n\thasReports: z.boolean(),\n\tlabel: z.string(),\n\tlastUsedAt: z.iso.datetime().nullable(),\n\tmediaId: z.string(),\n\tprocessingStatus: mediaProcessingStatus,\n\tretention: retentionInfo,\n\tsource: mediaSource,\n\tsizeBytes: z.number().int().nullish(),\n\tworkspaceId: z.string(),\n});\nexport type FileResponse = z.infer<typeof fileResponse>;\n\nexport const listFilesQuery = z.object({\n\tcreatedAfter: z.iso.datetime().optional(),\n\tcreatedByUserId: z.string().optional(),\n\tcursor: z.string().optional(),\n\tincludeDeleted: z.coerce.boolean().default(false),\n\tlimit: z.coerce.number().int().min(1).max(100).default(20),\n\tsearch: z.string().trim().min(1).max(200).optional(),\n});\nexport type ListFilesQuery = z.infer<typeof listFilesQuery>;\n\nexport const listFilesResponse = z.object({\n\tfiles: z.array(fileResponse),\n\thasMore: z.boolean(),\n\tnextCursor: z.string().nullable(),\n});\nexport type ListFilesResponse = z.infer<typeof listFilesResponse>;\n\nexport const transcriptUtterance = z.object({\n\tendSeconds: z.number(),\n\tspeakerIndex: z.number().int().nonnegative(),\n\tstartSeconds: z.number(),\n\ttext: z.string(),\n});\nexport type TranscriptUtterance = z.infer<typeof transcriptUtterance>;\n\nexport const mediaSpeaker = z.object({\n\tentityId: z.string().nullable(),\n\tentityLabel: z.string().nullable(),\n\tspeakerIndex: z.number().int().nonnegative(),\n\ttotalDurationSeconds: z.number().nonnegative(),\n\tutteranceCount: z.number().int().nonnegative(),\n});\nexport type MediaSpeaker = z.infer<typeof mediaSpeaker>;\n\nexport const fileDetailResponse = fileResponse.extend({\n\tspeakers: z.array(mediaSpeaker),\n\ttranscription: z.object({\n\t\tdurationSeconds: z.number().nonnegative(),\n\t\tspeakerCount: z.number().int().nonnegative(),\n\t\tutterances: z.array(transcriptUtterance),\n\t}),\n});\nexport type FileDetailResponse = z.infer<typeof fileDetailResponse>;\n\nexport const fileSpeaker = z.object({\n\tspeechSeconds: z.number().nonnegative(),\n\tspeakerIndex: z.number().int().nonnegative(),\n\ttranscript: z.string(),\n});\nexport type FileSpeaker = z.infer<typeof fileSpeaker>;\n\nexport const fileSpeakersResponse = z.object({\n\tdurationSeconds: z.number().nonnegative().nullable(),\n\tmediaId: z.string().min(1),\n\tspeakers: z.array(fileSpeaker),\n\tstatus: z.enum([\"processing\", \"ready\", \"failed\"]),\n});\nexport type FileSpeakersResponse = z.infer<typeof fileSpeakersResponse>;\n\nexport const audioUrlResponse = z.object({\n\turl: z.string().url(),\n});\nexport type AudioUrlResponse = z.infer<typeof audioUrlResponse>;\n\nexport const audioMetadataWarningBody = z.object({\n\tmetadataDurationSeconds: z.number().nonnegative(),\n\ttranscriptDurationSeconds: z.number().nonnegative(),\n});\nexport type AudioMetadataWarningBody = z.infer<typeof audioMetadataWarningBody>;\n\nexport const audioMetadataWarningResponse = z.object({\n\tenqueuedRemediation: z.boolean(),\n\tmediaId: z.string(),\n\tseverity: z.enum([\"minor\", \"major\"]),\n});\nexport type AudioMetadataWarningResponse = z.infer<\n\ttypeof audioMetadataWarningResponse\n>;\n\nexport const deleteResponse = z.object({\n\tdeleted: z.literal(true),\n\tmediaId: z.string(),\n});\nexport type DeleteResponse = z.infer<typeof deleteResponse>;\n\n// ═══════════════════════════════════════════════════════════════════════\n// ERROR SCHEMAS\n// ═══════════════════════════════════════════════════════════════════════\n\nexport const goneError = z.object({\n\tdeletedAt: z.iso.datetime(),\n\terror: z.literal(\"gone\"),\n\tmessage: z.string(),\n});\nexport type GoneError = z.infer<typeof goneError>;\n\nexport const notFoundError = z.object({\n\terror: z.object({\n\t\tcode: z.literal(\"not_found\"),\n\t\tmessage: z.string(),\n\t}),\n});\nexport type NotFoundError = z.infer<typeof notFoundError>;\n\nexport const unsupportedMediaTypeError = z.object({\n\terror: z.object({\n\t\tcode: z.literal(\"unsupported_media_type\"),\n\t\tmessage: z.string(),\n\t}),\n});\nexport type UnsupportedMediaTypeError = z.infer<\n\ttypeof unsupportedMediaTypeError\n>;\n","import {\n\tdeleteResponse,\n\tfileResponse,\n\tfileSpeakersResponse,\n\tlistFilesQuery,\n\tlistFilesResponse,\n\tretentionUpdateResponse,\n\tuploadResponse,\n} from \"@mappa-ai/contracts/v1/files\";\nimport {\n\tConduitError,\n\tInvalidSourceError,\n\tUnsupportedRuntimeError,\n} from \"../errors\";\nimport type {\n\tFileDeleteReceipt,\n\tListFilesResponse,\n\tMediaFile,\n\tMediaObject,\n\tMediaSpeakers,\n\tMediaUploadRequest,\n\tRetentionLockResult,\n} from \"../types\";\nimport { DEFAULT_MAX_SOURCE_BYTES, materializeSource } from \"./source\";\nimport type { Transport } from \"./transport\";\nimport { parseReq, parseRes } from \"./validate\";\n\nconst LABEL_SUFFIX_REGEX = /(\\.[^.]+)+$/;\n\ntype ListFilesOptions = {\n\tlimit?: number;\n\tcursor?: string;\n\tincludeDeleted?: boolean;\n\trequestId?: string;\n\tsignal?: AbortSignal;\n};\n\nclass FilesResource {\n\tprivate readonly transport: Transport;\n\tprivate readonly fetchImpl: typeof fetch;\n\tprivate readonly timeoutMs: number;\n\tprivate readonly maxSourceBytes: number;\n\n\tconstructor(\n\t\ttransport: Transport,\n\t\topts?: {\n\t\t\tfetchImpl?: typeof fetch;\n\t\t\ttimeoutMs?: number;\n\t\t\tmaxSourceBytes?: number;\n\t\t},\n\t) {\n\t\tthis.transport = transport;\n\t\tthis.fetchImpl = opts?.fetchImpl ?? fetch;\n\t\tthis.timeoutMs = opts?.timeoutMs ?? 300000;\n\t\tthis.maxSourceBytes = opts?.maxSourceBytes ?? DEFAULT_MAX_SOURCE_BYTES;\n\t}\n\n\tasync upload(req: MediaUploadRequest): Promise<MediaObject> {\n\t\tif (typeof FormData === \"undefined\") {\n\t\t\tthrow new UnsupportedRuntimeError(\n\t\t\t\t\"FormData is not available in this runtime; cannot perform multipart upload\",\n\t\t\t\t{ code: \"unsupported_runtime\" },\n\t\t\t);\n\t\t}\n\n\t\tconst source = validateUploadSource(req);\n\t\tconst { file, label: rawLabel } = await materializeSource(source, {\n\t\t\tfetchImpl: this.fetchImpl,\n\t\t\tmaxSourceBytes: this.maxSourceBytes,\n\t\t\tsignal: req.signal,\n\t\t\ttimeoutMs: this.timeoutMs,\n\t\t});\n\t\tconst label = filesLabel(rawLabel);\n\t\tif (!label) {\n\t\t\tthrow new InvalidSourceError(\"label is required\", {\n\t\t\t\tcode: \"invalid_source\",\n\t\t\t});\n\t\t}\n\n\t\tconst form = new FormData();\n\t\tform.append(\"file\", file, label);\n\t\tform.append(\"label\", label);\n\n\t\tconst res = await this.transport.request<MediaObject>({\n\t\t\tbody: form,\n\t\t\tidempotencyKey: req.idempotencyKey,\n\t\t\tmethod: \"POST\",\n\t\t\tpath: \"/v1/files\",\n\t\t\trequestId: req.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: req.signal,\n\t\t});\n\t\treturn parseRes(uploadResponse, res.data, \"files.upload\");\n\t}\n\n\tasync get(\n\t\tmediaId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<MediaFile> {\n\t\tif (!mediaId) {\n\t\t\tthrow new ConduitError(\"mediaId is required\", {\n\t\t\t\tcode: \"invalid_request\",\n\t\t\t});\n\t\t}\n\t\tconst res = await this.transport.request<MediaFile>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/files/${encodeURIComponent(mediaId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\treturn parseRes(fileResponse, res.data, \"files.get\");\n\t}\n\n\tasync speakers(\n\t\tmediaId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<MediaSpeakers> {\n\t\tif (!mediaId) {\n\t\t\tthrow new ConduitError(\"mediaId is required\", {\n\t\t\t\tcode: \"invalid_request\",\n\t\t\t});\n\t\t}\n\t\tconst res = await this.transport.request<MediaSpeakers>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/files/${encodeURIComponent(mediaId)}/speakers`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\treturn parseRes(fileSpeakersResponse, res.data, \"files.speakers\");\n\t}\n\n\tasync list(opts?: ListFilesOptions): Promise<ListFilesResponse> {\n\t\tconst query = parseReq(\n\t\t\tlistFilesQuery,\n\t\t\t{\n\t\t\t\tcursor: opts?.cursor,\n\t\t\t\tincludeDeleted: opts?.includeDeleted,\n\t\t\t\tlimit: opts?.limit,\n\t\t\t},\n\t\t\t\"files.list query\",\n\t\t) as {\n\t\t\tcursor?: string;\n\t\t\tincludeDeleted: boolean;\n\t\t\tlimit: number;\n\t\t};\n\n\t\tconst res = await this.transport.request<ListFilesResponse>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: \"/v1/files\",\n\t\t\tquery: {\n\t\t\t\tlimit: String(query.limit),\n\t\t\t\t...(query.cursor ? { cursor: query.cursor } : {}),\n\t\t\t\tincludeDeleted: String(query.includeDeleted),\n\t\t\t},\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\treturn parseRes(listFilesResponse, res.data, \"files.list\");\n\t}\n\n\tasync *listAll(\n\t\topts?: Omit<ListFilesOptions, \"cursor\">,\n\t): AsyncIterable<MediaFile> {\n\t\tlet cursor: string | undefined;\n\t\tlet hasMore = true;\n\t\twhile (hasMore) {\n\t\t\t// biome-ignore lint/performance/noAwaitInLoops: cursor-based pagination is inherently sequential\n\t\t\tconst page = await this.list({ ...opts, cursor });\n\t\t\tfor (const file of page.files) {\n\t\t\t\tyield file;\n\t\t\t}\n\t\t\tcursor = page.nextCursor ?? undefined;\n\t\t\thasMore = page.hasMore;\n\t\t}\n\t}\n\n\tasync setRetentionLock(\n\t\tmediaId: string,\n\t\tlocked: boolean,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<RetentionLockResult> {\n\t\tif (!mediaId) {\n\t\t\tthrow new ConduitError(\"mediaId is required\", {\n\t\t\t\tcode: \"invalid_request\",\n\t\t\t});\n\t\t}\n\t\tconst res = await this.transport.request<RetentionLockResult>({\n\t\t\tbody: { lock: locked },\n\t\t\tmethod: \"PATCH\",\n\t\t\tpath: `/v1/files/${encodeURIComponent(mediaId)}/retention`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\treturn parseRes(\n\t\t\tretentionUpdateResponse,\n\t\t\tres.data,\n\t\t\t\"files.setRetentionLock\",\n\t\t);\n\t}\n\n\tasync delete(\n\t\tmediaId: string,\n\t\topts?: {\n\t\t\tidempotencyKey?: string;\n\t\t\trequestId?: string;\n\t\t\tsignal?: AbortSignal;\n\t\t},\n\t): Promise<FileDeleteReceipt> {\n\t\tif (!mediaId) {\n\t\t\tthrow new ConduitError(\"mediaId is required\", {\n\t\t\t\tcode: \"invalid_request\",\n\t\t\t});\n\t\t}\n\t\tconst res = await this.transport.request<FileDeleteReceipt>({\n\t\t\tidempotencyKey: opts?.idempotencyKey,\n\t\t\tmethod: \"DELETE\",\n\t\t\tpath: `/v1/files/${encodeURIComponent(mediaId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\treturn parseRes(deleteResponse, res.data, \"files.delete\");\n\t}\n}\n\nfunction filesLabel(value: string) {\n\tconst label = value.replace(LABEL_SUFFIX_REGEX, \"\").trim();\n\tif (label) return label;\n\treturn \"\";\n}\n\nfunction validateUploadSource(req: MediaUploadRequest) {\n\tconst keys = [\"file\", \"url\", \"path\"].filter((key) => key in req);\n\tif (keys.length === 1) return req;\n\tthrow new InvalidSourceError(\n\t\t\"upload() must include exactly one of file, url, or path\",\n\t\t{ code: \"invalid_source\" },\n\t);\n}\n\nexport type { ListFilesOptions };\nexport { FilesResource };\n","import { z } from \"zod\";\n\nconst jobStatus = z.enum([\n\t\"queued\",\n\t\"running\",\n\t\"succeeded\",\n\t\"failed\",\n\t\"canceled\",\n]);\ntype JobStatus = z.infer<typeof jobStatus>;\nconst jobStage = z.enum([\n\t\"uploaded\",\n\t\"queued\",\n\t\"transcoding\",\n\t\"extracting\",\n\t\"scoring\",\n\t\"rendering\",\n\t\"finalizing\",\n]);\ntype JobStage = z.infer<typeof jobStage>;\nconst jobResponse = z.object({\n\tcreatedAt: z.string(),\n\tcredits: z\n\t\t.object({\n\t\t\treservationStatus: z.enum([\"active\", \"released\", \"applied\"]).nullable(),\n\t\t\treservedCredits: z.number().nullable(),\n\t\t})\n\t\t.optional(),\n\terror: z\n\t\t.object({\n\t\t\tcode: z.string(),\n\t\t\tdetails: z.unknown().optional(),\n\t\t\tmessage: z.string(),\n\t\t\tretryable: z.boolean().optional(),\n\t\t})\n\t\t.optional(),\n\tid: z.string(),\n\tmatchingId: z.string().optional(),\n\tprogress: z.number().optional(),\n\treleasedCredits: z.number().nullable().optional(),\n\treportId: z.string().optional(),\n\tstage: z\n\t\t.enum([\n\t\t\t\"uploaded\",\n\t\t\t\"queued\",\n\t\t\t\"transcoding\",\n\t\t\t\"extracting\",\n\t\t\t\"scoring\",\n\t\t\t\"rendering\",\n\t\t\t\"finalizing\",\n\t\t])\n\t\t.optional(),\n\tstatus: z.enum([\"queued\", \"running\", \"succeeded\", \"failed\", \"canceled\"]),\n\ttype: z.enum([\"report.generate\", \"matching.generate\"]),\n\tupdatedAt: z.string(),\n\tusage: z\n\t\t.object({\n\t\t\tcreditsDiscounted: z.number().optional(),\n\t\t\tcreditsNetUsed: z.number(),\n\t\t\tcreditsUsed: z.number(),\n\t\t\tdurationMs: z.number().optional(),\n\t\t\tmodelVersion: z.string().optional(),\n\t\t})\n\t\t.optional(),\n});\ntype JobResponse = z.infer<typeof jobResponse>;\nconst streamEventType = z.enum([\"status\", \"stage\", \"terminal\", \"heartbeat\"]);\ntype StreamEventType = z.infer<typeof streamEventType>;\n\n/**\n * Base SSE event structure with event ID for Last-Event-ID support.\n */\nconst baseStreamEvent = z.object({\n\tid: z.string().describe(\"Monotonically increasing event ID for resumption\"),\n});\nconst statusStreamEvent = baseStreamEvent.extend({\n\tdata: z.object({\n\t\tjob: jobResponse,\n\t\tprogress: z.number().optional(),\n\t\tstage: jobStage.optional(),\n\t\tstatus: jobStatus,\n\t}),\n\tevent: z.literal(\"status\"),\n});\ntype StatusStreamEvent = z.infer<typeof statusStreamEvent>;\nconst stageStreamEvent = baseStreamEvent.extend({\n\tdata: z.object({\n\t\tjob: jobResponse,\n\t\tprogress: z.number().optional(),\n\t\tstage: jobStage,\n\t}),\n\tevent: z.literal(\"stage\"),\n});\ntype StageStreamEvent = z.infer<typeof stageStreamEvent>;\nconst terminalStreamEvent = baseStreamEvent.extend({\n\tdata: z.object({\n\t\terror: z\n\t\t\t.object({\n\t\t\t\tcode: z.string(),\n\t\t\t\tmessage: z.string(),\n\t\t\t})\n\t\t\t.optional(),\n\t\tjob: jobResponse,\n\t\tmatchingId: z.string().optional(),\n\t\treportId: z.string().optional(),\n\t\tstatus: z.enum([\"succeeded\", \"failed\", \"canceled\"]),\n\t}),\n\tevent: z.literal(\"terminal\"),\n});\ntype TerminalStreamEvent = z.infer<typeof terminalStreamEvent>;\nconst heartbeatStreamEvent = baseStreamEvent.extend({\n\tdata: z.object({\n\t\ttimestamp: z.string(),\n\t}),\n\tevent: z.literal(\"heartbeat\"),\n});\ntype HeartbeatStreamEvent = z.infer<typeof heartbeatStreamEvent>;\nconst jobStreamEvent = z.discriminatedUnion(\"event\", [\n\tstatusStreamEvent,\n\tstageStreamEvent,\n\tterminalStreamEvent,\n\theartbeatStreamEvent,\n]);\ntype JobStreamEvent = z.infer<typeof jobStreamEvent>;\nconst streamQueryParams = z.object({\n\ttimeout: z.coerce\n\t\t.number()\n\t\t.min(1000)\n\t\t.max(300000)\n\t\t.default(300000)\n\t\t.describe(\"Stream timeout in milliseconds (default: 300000, max: 300000)\"),\n});\ntype StreamQueryParams = z.infer<typeof streamQueryParams>;\n\nexport type {\n\tHeartbeatStreamEvent,\n\tJobResponse,\n\tJobStage,\n\tJobStatus,\n\tJobStreamEvent,\n\tStageStreamEvent,\n\tStatusStreamEvent,\n\tStreamEventType,\n\tStreamQueryParams,\n\tTerminalStreamEvent,\n};\nexport {\n\theartbeatStreamEvent,\n\tjobResponse,\n\tjobStage,\n\tjobStatus,\n\tjobStreamEvent,\n\tstageStreamEvent,\n\tstatusStreamEvent,\n\tstreamEventType,\n\tstreamQueryParams,\n\tterminalStreamEvent,\n};\n","import { jobResponse, jobStreamEvent } from \"@mappa-ai/contracts/v1/jobs\";\nimport {\n\tConduitError,\n\tJobCanceledError,\n\tJobFailedError,\n\tStreamError,\n\tTimeoutError,\n} from \"../errors\";\nimport type { Job, JobEvent, WaitOptions } from \"../types\";\nimport { withDeadline } from \"../utils\";\nimport type { SSEEvent, Transport } from \"./transport\";\nimport { parseRes } from \"./validate\";\n\nclass JobsResource {\n\tprivate readonly transport: Transport;\n\n\tconstructor(transport: Transport) {\n\t\tthis.transport = transport;\n\t}\n\n\tasync get(\n\t\tjobId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Job> {\n\t\tconst res = await this.transport.request<Job>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/jobs/${encodeURIComponent(jobId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\treturn parseRes(jobResponse, res.data, \"jobs.get\");\n\t}\n\n\tasync cancel(\n\t\tjobId: string,\n\t\topts?: {\n\t\t\tidempotencyKey?: string;\n\t\t\trequestId?: string;\n\t\t\tsignal?: AbortSignal;\n\t\t},\n\t): Promise<Job> {\n\t\tconst res = await this.transport.request<Job>({\n\t\t\tidempotencyKey: opts?.idempotencyKey,\n\t\t\tmethod: \"POST\",\n\t\t\tpath: `/v1/jobs/${encodeURIComponent(jobId)}/cancel`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\treturn parseRes(jobResponse, res.data, \"jobs.cancel\");\n\t}\n\n\tasync wait(jobId: string, opts?: WaitOptions): Promise<Job> {\n\t\tconst timeoutMs = opts?.timeoutMs ?? 300000;\n\t\tconst deadline = withDeadline(timeoutMs, {\n\t\t\tonTimeout: () =>\n\t\t\t\tnew TimeoutError(\n\t\t\t\t\t`Timed out waiting for job ${jobId} after ${timeoutMs}ms`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: \"timeout\",\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\tsignal: opts?.signal,\n\t\t});\n\n\t\ttry {\n\t\t\tfor await (const event of this.stream(jobId, {\n\t\t\t\tonEvent: opts?.onEvent,\n\t\t\t\tsignal: deadline.signal,\n\t\t\t})) {\n\t\t\t\tif (event.type !== \"terminal\") continue;\n\t\t\t\tconst job = event.job;\n\t\t\t\tif (job.status === \"succeeded\") return job;\n\t\t\t\tif (job.status === \"failed\") {\n\t\t\t\t\tthrow new JobFailedError(jobId, job.error?.message ?? \"Job failed\", {\n\t\t\t\t\t\tcause: job.error,\n\t\t\t\t\t\tcode: job.error?.code,\n\t\t\t\t\t\trequestId: job.requestId,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (job.status === \"canceled\") {\n\t\t\t\t\tthrow new JobCanceledError(jobId, \"Job canceled\", {\n\t\t\t\t\t\tcause: job.error,\n\t\t\t\t\t\trequestId: job.requestId,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow new TimeoutError(\n\t\t\t\t`Timed out waiting for job ${jobId} after ${timeoutMs}ms`,\n\t\t\t\t{\n\t\t\t\t\tcode: \"timeout\",\n\t\t\t\t},\n\t\t\t);\n\t\t} finally {\n\t\t\tdeadline.cleanup();\n\t\t}\n\t}\n\n\tasync *stream(\n\t\tjobId: string,\n\t\topts?: { signal?: AbortSignal; onEvent?: (e: JobEvent) => void },\n\t): AsyncIterable<JobEvent> {\n\t\tyield* this.streamWithRetry(jobId, opts);\n\t}\n\n\tprivate async *streamWithRetry(\n\t\tjobId: string,\n\t\topts?: { signal?: AbortSignal; onEvent?: (e: JobEvent) => void },\n\t): AsyncGenerator<JobEvent> {\n\t\tconst maxRetries = 3;\n\t\tlet state: { lastEventId?: string; retries: number } = { retries: 0 };\n\n\t\twhile (state.retries < maxRetries) {\n\t\t\tstate = yield* this.runStreamAttempt(jobId, opts, state, maxRetries);\n\t\t\tif (state.retries < 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tthrow new StreamError(\n\t\t\t`Failed to get status for job ${jobId} after ${maxRetries} retries`,\n\t\t\t{\n\t\t\t\tjobId,\n\t\t\t\tlastEventId: state.lastEventId,\n\t\t\t\tretryCount: maxRetries,\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async *runStreamAttempt(\n\t\tjobId: string,\n\t\topts: { signal?: AbortSignal; onEvent?: (e: JobEvent) => void } | undefined,\n\t\tstate: { lastEventId?: string; retries: number },\n\t\tmaxRetries: number,\n\t): AsyncGenerator<JobEvent, { lastEventId?: string; retries: number }> {\n\t\ttry {\n\t\t\tconst terminal = yield* this.streamAttempt(jobId, opts, state);\n\t\t\tif (terminal) {\n\t\t\t\treturn { ...state, retries: -1 };\n\t\t\t}\n\t\t\tconst retries = state.retries + 1;\n\t\t\tif (retries < maxRetries) {\n\t\t\t\tawait this.backoff(retries);\n\t\t\t}\n\t\t\treturn { ...state, retries };\n\t\t} catch (err) {\n\t\t\tif (opts?.signal?.aborted) throw err;\n\t\t\tconst retries = state.retries + 1;\n\t\t\tif (retries >= maxRetries) {\n\t\t\t\tthrow new StreamError(\n\t\t\t\t\t`Stream connection failed for job ${jobId} after ${maxRetries} retries`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: err,\n\t\t\t\t\t\tjobId,\n\t\t\t\t\t\tlastEventId: state.lastEventId,\n\t\t\t\t\t\tretryCount: retries,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait this.backoff(retries);\n\t\t\treturn { ...state, retries };\n\t\t}\n\t}\n\n\tprivate async *streamAttempt(\n\t\tjobId: string,\n\t\topts: { signal?: AbortSignal; onEvent?: (e: JobEvent) => void } | undefined,\n\t\tstate: { lastEventId?: string; retries: number },\n\t): AsyncGenerator<JobEvent, boolean> {\n\t\tconst stream = this.transport.streamSSE<unknown>(\n\t\t\t`/v1/jobs/${encodeURIComponent(jobId)}/stream`,\n\t\t\t{ lastEventId: state.lastEventId, signal: opts?.signal },\n\t\t);\n\t\tfor await (const sse of stream) {\n\t\t\tstate.lastEventId = sse.id;\n\t\t\tconst handled = this.handleSseEvent(sse);\n\t\t\tif (!handled.event) {\n\t\t\t\tif (handled.terminal) return true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tstate.retries = 0;\n\t\t\topts?.onEvent?.(handled.event);\n\t\t\tyield handled.event;\n\t\t\tif (handled.terminal) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate handleSseEvent(sse: SSEEvent<unknown>): {\n\t\tevent?: JobEvent;\n\t\tterminal: boolean;\n\t} {\n\t\tif (sse.event === \"error\") {\n\t\t\tconst err = readSseError(sse.data);\n\t\t\tthrow new ConduitError(err.message ?? \"Unknown SSE error\", {\n\t\t\t\tcode: err.code,\n\t\t\t});\n\t\t}\n\t\tif (sse.event === \"heartbeat\") {\n\t\t\treturn { terminal: false };\n\t\t}\n\t\tconst event = this.mapSSEToJobEvent(sse);\n\t\tif (!event) {\n\t\t\treturn { terminal: sse.event === \"terminal\" };\n\t\t}\n\t\treturn { event, terminal: sse.event === \"terminal\" };\n\t}\n\n\tprivate mapSSEToJobEvent(sse: SSEEvent<unknown>): JobEvent | null {\n\t\tconst parsed = parseRes(\n\t\t\tjobStreamEvent,\n\t\t\t{\n\t\t\t\tdata: sse.data,\n\t\t\t\tevent: sse.event,\n\t\t\t\tid: sse.id ?? \"\",\n\t\t\t},\n\t\t\t\"jobs.stream event\",\n\t\t);\n\t\tif (parsed.event === \"status\")\n\t\t\treturn { job: parsed.data.job, type: \"status\" };\n\t\tif (parsed.event === \"stage\") {\n\t\t\treturn {\n\t\t\t\tjob: parsed.data.job,\n\t\t\t\tprogress: parsed.data.progress,\n\t\t\t\tstage: parsed.data.stage,\n\t\t\t\ttype: \"stage\",\n\t\t\t};\n\t\t}\n\t\tif (parsed.event === \"terminal\")\n\t\t\treturn { job: parsed.data.job, type: \"terminal\" };\n\t\treturn null;\n\t}\n\n\tprivate async backoff(attempt: number): Promise<void> {\n\t\tconst base = Math.min(1000 * 2 ** attempt, 10000);\n\t\tconst offset = base * 0.5 * Math.random();\n\t\tawait new Promise((r) => setTimeout(r, base + offset));\n\t}\n}\n\nfunction readSseError(data: unknown): { code?: string; message?: string } {\n\tif (!data || typeof data !== \"object\") return {};\n\tconst err = data as Record<string, unknown>;\n\treturn {\n\t\tcode: typeof err.code === \"string\" ? err.code : undefined,\n\t\tmessage: typeof err.message === \"string\" ? err.message : undefined,\n\t};\n}\n\nexport { JobsResource };\n","import { z } from \"zod\";\nimport {\n\treportSection,\n\ttargetSelector as reportsTargetSelector,\n} from \"./reports\";\n\nconst targetSelector = reportsTargetSelector;\nconst matchingContext = z.literal(\"behavioral_compatibility\");\n\nconst subjectRef = z.discriminatedUnion(\"type\", [\n\tz.object({\n\t\tentityId: z.string().min(1).max(256).trim(),\n\t\ttype: z.literal(\"entity_id\"),\n\t}),\n\tz.object({\n\t\tmediaId: z.string().min(1).max(256).trim(),\n\t\tselector: targetSelector,\n\t\ttype: z.literal(\"media_target\"),\n\t}),\n]);\nconst entitySource = subjectRef;\n\nconst resolvedSubject = z.object({\n\tentityId: z.string().optional(),\n\tresolvedLabel: z.string().nullable().optional(),\n\tsource: subjectRef,\n});\n\nconst requestSubjects = z\n\t.object({\n\t\tgroup: z.array(subjectRef).min(1),\n\t\ttarget: subjectRef,\n\t})\n\t.strict();\n\nconst resolvedSubjects = z\n\t.object({\n\t\tgroup: z.array(resolvedSubject).min(1),\n\t\ttarget: resolvedSubject,\n\t})\n\t.strict();\n\nconst output = z\n\t.object({\n\t\ttemplate: z.literal(\"matching\"),\n\t})\n\t.strict();\n\nconst webhookConfig = z\n\t.object({\n\t\theaders: z.record(z.string(), z.string()).optional(),\n\t\turl: z.url(),\n\t})\n\t.optional();\n\nconst createJobBody = requestSubjects\n\t.extend({\n\t\tcontext: matchingContext,\n\t\tidempotencyKey: z.string().optional(),\n\t\tlabel: z.string().trim().min(1).max(64).optional(),\n\t\twebhook: webhookConfig,\n\t})\n\t.superRefine((data, ctx) => {\n\t\tconst directEntityIds = new Set<string>();\n\t\tconst directRefs = [data.target, ...data.group];\n\n\t\tfor (const [index, item] of directRefs.entries()) {\n\t\t\tif (item.type !== \"entity_id\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (directEntityIds.has(item.entityId)) {\n\t\t\t\tconst path = index === 0 ? [\"target\"] : [\"group\", index - 1];\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"target and group must reference different direct entity IDs\",\n\t\t\t\t\tpath,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tdirectEntityIds.add(item.entityId);\n\t\t}\n\t});\n\nconst jobReceipt = z.object({\n\testimatedWaitSec: z.number().optional(),\n\tjobId: z.string(),\n\tstage: z.string().optional(),\n\tstatus: z.enum([\"queued\", \"running\"]),\n});\n\nconst matchingAnalysisJson = z\n\t.object({\n\t\tschemaVersion: z.literal(1),\n\t\tsections: z.array(reportSection).min(1),\n\t\tsummary: z.string().min(1),\n\t\ttitle: z.string().min(1),\n\t})\n\t.strict();\n\nconst matchingAnalysisResponse = z\n\t.object({\n\t\tcontext: matchingContext,\n\t\tcreatedAt: z.string(),\n\t\tgroup: z.array(resolvedSubject).min(1),\n\t\tid: z.string(),\n\t\tjson: matchingAnalysisJson.nullish(),\n\t\tjobId: z.string().optional(),\n\t\tlabel: z.string().optional(),\n\t\tmarkdown: z.string().nullish(),\n\t\toutput,\n\t\ttarget: resolvedSubject,\n\t})\n\t.strict();\n\nconst listQuery = z.object({\n\tentityId: z.string().optional(),\n\tlimit: z.coerce.number().int().min(1).max(100).default(25),\n\tpage: z.coerce.number().int().min(1).default(1),\n\tworkspaceId: z.string(),\n});\n\nconst listItem = z.object({\n\tcreatedAt: z.string(),\n\tgroup: z.array(resolvedSubject).min(1),\n\tid: z.string(),\n\tjobId: z.string().optional(),\n\tlabel: z.string().optional(),\n\ttarget: resolvedSubject,\n});\n\nconst listResponse = z.object({\n\titems: z.array(listItem),\n\tpagination: z.object({\n\t\tlimit: z.number().int().min(1),\n\t\tpage: z.number().int().min(1),\n\t\ttotalItems: z.number().int().min(0),\n\t\ttotalPages: z.number().int().min(0),\n\t}),\n});\n\nconst sharingStatus = z.object({\n\tactive: z.boolean(),\n\tshareUrl: z.url().nullable(),\n});\n\nconst toggleSharingBody = z.object({\n\tactive: z.boolean(),\n\tworkspaceId: z.string(),\n});\n\nconst sharingQuery = z.object({\n\tworkspaceId: z.string(),\n});\n\nfunction generateDefaultLabel(): string {\n\tconst dateStr = new Date().toLocaleDateString(\"en-US\", {\n\t\tday: \"numeric\",\n\t\tmonth: \"short\",\n\t\tyear: \"numeric\",\n\t});\n\treturn `Matching Analysis - ${dateStr}`;\n}\n\ntype MatchingContext = z.infer<typeof matchingContext>;\ntype TargetSelector = z.infer<typeof targetSelector>;\ntype SubjectRef = z.infer<typeof subjectRef>;\ntype EntitySource = SubjectRef;\ntype ResolvedSubject = z.infer<typeof resolvedSubject>;\ntype RequestSubjects = z.infer<typeof requestSubjects>;\ntype ResolvedSubjects = z.infer<typeof resolvedSubjects>;\ntype CreateJobBody = z.infer<typeof createJobBody>;\ntype JobReceipt = z.infer<typeof jobReceipt>;\ntype MatchingAnalysisJson = z.infer<typeof matchingAnalysisJson>;\ntype MatchingAnalysisResponse = z.infer<typeof matchingAnalysisResponse>;\ntype ListQuery = z.infer<typeof listQuery>;\ntype ListItem = z.infer<typeof listItem>;\ntype ListResponse = z.infer<typeof listResponse>;\ntype SharingStatus = z.infer<typeof sharingStatus>;\ntype ToggleSharingBody = z.infer<typeof toggleSharingBody>;\ntype SharingQuery = z.infer<typeof sharingQuery>;\n\nexport type {\n\tCreateJobBody,\n\tEntitySource,\n\tJobReceipt,\n\tListItem,\n\tListQuery,\n\tListResponse,\n\tMatchingAnalysisJson,\n\tMatchingAnalysisResponse,\n\tMatchingContext,\n\tRequestSubjects,\n\tResolvedSubject,\n\tResolvedSubjects,\n\tSharingQuery,\n\tSharingStatus,\n\tSubjectRef,\n\tTargetSelector,\n\tToggleSharingBody,\n};\nexport {\n\tcreateJobBody,\n\ttype entitySource,\n\tgenerateDefaultLabel,\n\tjobReceipt,\n\tlistItem,\n\tlistQuery,\n\tlistResponse,\n\tmatchingAnalysisJson,\n\tmatchingAnalysisResponse,\n\tmatchingContext,\n\toutput,\n\trequestSubjects,\n\tresolvedSubject,\n\tresolvedSubjects,\n\tsharingQuery,\n\tsharingStatus,\n\tsubjectRef,\n\ttargetSelector,\n\ttoggleSharingBody,\n\twebhookConfig,\n};\n","import {\n\tcreateJobBody,\n\tjobReceipt,\n\tmatchingAnalysisResponse,\n} from \"@mappa-ai/contracts/v1/matching\";\nimport { ConduitError } from \"../errors\";\nimport type {\n\tJob,\n\tJobEvent,\n\tJobStage,\n\tMatchingAnalysisCreateJobRequest,\n\tMatchingAnalysisEntitySource,\n\tMatchingAnalysisForOutputType,\n\tMatchingAnalysisJobReceipt,\n\tMatchingAnalysisResponse,\n\tMatchingAnalysisRunHandle,\n\tMatchingSubjectRef,\n\tTargetSelector,\n\tWaitOptions,\n} from \"../types\";\nimport { randomId } from \"../utils\";\nimport type { JobsResource } from \"./jobs\";\nimport type { Transport } from \"./transport\";\nimport { parseReq, parseRes } from \"./validate\";\n\ntype RawTargetSelector = {\n\tstrategy:\n\t\t| \"dominant\"\n\t\t| \"timerange\"\n\t\t| \"entity_id\"\n\t\t| \"magic_hint\"\n\t\t| \"speaker_index\";\n\ton_miss?: \"fallback_dominant\" | \"error\";\n\tentity_id?: string | null;\n\thint?: string | null;\n\tspeaker_index?: number | null;\n\ttimerange?: {\n\t\tstart_seconds?: number | null;\n\t\tend_seconds?: number | null;\n\t} | null;\n};\n\ntype RawMatchingSubjectRef =\n\t| {\n\t\t\ttype: \"entity_id\";\n\t\t\tentityId: string;\n\t  }\n\t| {\n\t\t\ttype: \"media_target\";\n\t\t\tmediaId: string;\n\t\t\tselector: RawTargetSelector;\n\t  };\n\ntype RawMatchingResolvedSubject = {\n\tentityId?: string;\n\tresolvedLabel?: string | null;\n\tsource: RawMatchingSubjectRef;\n};\n\ntype RawMatchingAnalysis = {\n\tcontext: \"behavioral_compatibility\";\n\tcreatedAt: string;\n\tgroup: RawMatchingResolvedSubject[];\n\tid: string;\n\tjobId?: string;\n\tlabel?: string;\n\tmarkdown?: string | null;\n\tjson?: MatchingAnalysisResponse[\"output\"][\"json\"];\n\ttarget: RawMatchingResolvedSubject;\n};\n\nclass MatchingAnalysisResource {\n\tprivate readonly transport: Transport;\n\tprivate readonly jobs: JobsResource;\n\n\tconstructor(transport: Transport, jobs: JobsResource) {\n\t\tthis.transport = transport;\n\t\tthis.jobs = jobs;\n\t}\n\n\tcreate(\n\t\treq: MatchingAnalysisCreateJobRequest,\n\t): Promise<MatchingAnalysisJobReceipt> {\n\t\treturn this.createJob(req);\n\t}\n\n\tasync createJob(\n\t\treq: MatchingAnalysisCreateJobRequest,\n\t): Promise<MatchingAnalysisJobReceipt> {\n\t\tvalidateMatchingRequest(req);\n\t\tconst idempotencyKey = req.idempotencyKey ?? randomId(\"idem\");\n\t\tconst body = parseReq(\n\t\t\tcreateJobBody,\n\t\t\tthis.normalizeBody(req),\n\t\t\t\"matching.create body\",\n\t\t);\n\t\tconst res = await this.transport.request<\n\t\t\tOmit<MatchingAnalysisJobReceipt, \"handle\">\n\t\t>({\n\t\t\tbody,\n\t\t\tidempotencyKey,\n\t\t\tmethod: \"POST\",\n\t\t\tpath: \"/v1/matching/jobs\",\n\t\t\trequestId: req.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: req.signal,\n\t\t});\n\n\t\tconst receiptData = parseRes(jobReceipt, res.data, \"matching.create\") as {\n\t\t\testimatedWaitSec?: number;\n\t\t\tjobId: string;\n\t\t\tstage?: string;\n\t\t\tstatus: \"queued\" | \"running\";\n\t\t};\n\t\tconst receipt: MatchingAnalysisJobReceipt = {\n\t\t\t...receiptData,\n\t\t\trequestId: res.requestId ?? res.data.requestId,\n\t\t\tstage: toJobStage(receiptData.stage),\n\t\t};\n\t\treceipt.handle = this.makeHandle(receipt.jobId);\n\t\treturn receipt;\n\t}\n\n\tasync get(\n\t\tmatchingId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<MatchingAnalysisResponse> {\n\t\tconst res = await this.transport.request<unknown>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/matching/${encodeURIComponent(matchingId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\treturn toMatchingAnalysis(\n\t\t\tparseRes(matchingAnalysisResponse, res.data, \"matching.get\"),\n\t\t);\n\t}\n\n\tasync getByJob(\n\t\tjobId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<MatchingAnalysisResponse | null> {\n\t\tconst res = await this.transport.request<unknown>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/matching/by-job/${encodeURIComponent(jobId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\tif (res.data === null) return null;\n\t\treturn toMatchingAnalysis(\n\t\t\tparseRes(matchingAnalysisResponse, res.data, \"matching.getByJob\"),\n\t\t);\n\t}\n\n\tasync generate(\n\t\treq: MatchingAnalysisCreateJobRequest,\n\t\topts?: { wait?: WaitOptions },\n\t): Promise<MatchingAnalysisForOutputType> {\n\t\tconst receipt = await this.createJob(req);\n\t\tif (!receipt.handle)\n\t\t\tthrow new ConduitError(\"Job receipt is missing handle\", {\n\t\t\t\tcode: \"invalid_response\",\n\t\t\t});\n\t\treturn receipt.handle.wait(opts?.wait);\n\t}\n\n\tmakeHandle(jobId: string): MatchingAnalysisRunHandle {\n\t\treturn {\n\t\t\tcancel: (): Promise<Job> => this.jobs.cancel(jobId),\n\t\t\tjob: (): Promise<Job> => this.jobs.get(jobId),\n\t\t\tjobId,\n\t\t\tmatching: () =>\n\t\t\t\tthis.getByJob(jobId) as Promise<MatchingAnalysisForOutputType | null>,\n\t\t\tstream: (opts?: {\n\t\t\t\tsignal?: AbortSignal;\n\t\t\t\tonEvent?: (e: JobEvent) => void;\n\t\t\t}) => this.jobs.stream(jobId, opts),\n\t\t\twait: async (\n\t\t\t\topts?: WaitOptions,\n\t\t\t): Promise<MatchingAnalysisForOutputType> => {\n\t\t\t\tconst terminal = await this.jobs.wait(jobId, opts);\n\t\t\t\tconst matchingId = terminal.matchingId;\n\t\t\t\tif (!matchingId) {\n\t\t\t\t\tthrow new ConduitError(\n\t\t\t\t\t\t`Job ${jobId} succeeded but no matching id was returned`,\n\t\t\t\t\t\t{ code: \"invalid_response\" },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this.get(matchingId) as Promise<MatchingAnalysisForOutputType>;\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate normalizeBody(\n\t\treq: MatchingAnalysisCreateJobRequest,\n\t): Record<string, unknown> {\n\t\treturn {\n\t\t\tcontext: req.context,\n\t\t\tgroup: req.group.map((item) => this.normalizeEntitySource(item)),\n\t\t\tidempotencyKey: req.idempotencyKey,\n\t\t\tlabel: req.label,\n\t\t\ttarget: this.normalizeEntitySource(req.target),\n\t\t\twebhook: req.webhook,\n\t\t};\n\t}\n\n\tprivate normalizeEntitySource(\n\t\tsource: MatchingAnalysisEntitySource,\n\t): Record<string, unknown> {\n\t\tif (isEntitySource(source)) {\n\t\t\treturn {\n\t\t\t\tentityId: source.entityId,\n\t\t\t\ttype: \"entity_id\",\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tmediaId: source.mediaId,\n\t\t\tselector: this.normalizeTarget(source.selector),\n\t\t\ttype: \"media_target\",\n\t\t};\n\t}\n\n\tprivate normalizeTarget(target: TargetSelector): Record<string, unknown> {\n\t\tif (target.strategy === \"dominant\") {\n\t\t\treturn {\n\t\t\t\tstrategy: target.strategy,\n\t\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\t};\n\t\t}\n\n\t\tif (target.strategy === \"timerange\") {\n\t\t\treturn {\n\t\t\t\tstrategy: target.strategy,\n\t\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\t\ttimerange: {\n\t\t\t\t\tend_seconds: target.timeRange?.endSeconds ?? null,\n\t\t\t\t\tstart_seconds: target.timeRange?.startSeconds ?? null,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (target.strategy === \"entity_id\") {\n\t\t\treturn {\n\t\t\t\tstrategy: target.strategy,\n\t\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\t\tentity_id: target.entityId,\n\t\t\t};\n\t\t}\n\n\t\tif (target.strategy === \"speaker_index\") {\n\t\t\treturn {\n\t\t\t\tstrategy: target.strategy,\n\t\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\t\tspeaker_index: target.speakerIndex,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tstrategy: target.strategy,\n\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\thint: target.hint,\n\t\t};\n\t}\n}\n\nfunction validateMatchingRequest(req: MatchingAnalysisCreateJobRequest): void {\n\tif (req.context !== \"behavioral_compatibility\") {\n\t\tthrow new ConduitError(\"context must be behavioral_compatibility\", {\n\t\t\tcode: \"invalid_request\",\n\t\t});\n\t}\n\n\tif (req.group.length < 1) {\n\t\tthrow new ConduitError(\"group must include at least one subject\", {\n\t\t\tcode: \"invalid_request\",\n\t\t});\n\t}\n\n\tconst ids = new Set<string>();\n\tfor (const item of [req.target, ...req.group]) {\n\t\tif (!isEntitySource(item)) {\n\t\t\tif (!item.mediaId.trim()) {\n\t\t\t\tthrow new ConduitError(\"mediaId is required\", {\n\t\t\t\t\tcode: \"invalid_request\",\n\t\t\t\t});\n\t\t\t}\n\t\t\tvalidateTarget(item.selector);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!item.entityId.trim()) {\n\t\t\tthrow new ConduitError(\"entityId is required\", {\n\t\t\t\tcode: \"invalid_request\",\n\t\t\t});\n\t\t}\n\n\t\tif (ids.has(item.entityId)) {\n\t\t\tthrow new ConduitError(\n\t\t\t\t\"target and group must reference different direct entity IDs\",\n\t\t\t\t{\n\t\t\t\t\tcode: \"invalid_request\",\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tids.add(item.entityId);\n\t}\n}\n\nfunction isEntitySource(\n\tsource: MatchingAnalysisEntitySource,\n): source is Extract<MatchingSubjectRef, { entityId: string }> {\n\treturn \"entityId\" in source;\n}\n\nfunction toMatchingAnalysis(\n\tmatching: RawMatchingAnalysis,\n): MatchingAnalysisResponse {\n\treturn {\n\t\tcontext: matching.context,\n\t\tcreatedAt: matching.createdAt,\n\t\tgroup: matching.group.map((subject) => ({\n\t\t\tentityId: subject.entityId,\n\t\t\tresolvedLabel: subject.resolvedLabel,\n\t\t\tsource: toSubjectRef(subject.source),\n\t\t})),\n\t\tid: matching.id,\n\t\tjobId: matching.jobId,\n\t\tlabel: matching.label,\n\t\toutput: {\n\t\t\tjson: matching.json ?? null,\n\t\t\tmarkdown: matching.markdown ?? null,\n\t\t},\n\t\ttarget: {\n\t\t\tentityId: matching.target.entityId,\n\t\t\tresolvedLabel: matching.target.resolvedLabel,\n\t\t\tsource: toSubjectRef(matching.target.source),\n\t\t},\n\t};\n}\n\nfunction toSubjectRef(source: RawMatchingSubjectRef): MatchingSubjectRef {\n\tif (source.type === \"entity_id\") {\n\t\treturn { entityId: source.entityId };\n\t}\n\n\treturn {\n\t\tmediaId: source.mediaId,\n\t\tselector: toTargetSelector(source.selector),\n\t};\n}\n\nfunction toTargetSelector(selector: RawTargetSelector): TargetSelector {\n\tif (selector.strategy === \"dominant\") {\n\t\treturn {\n\t\t\tonMiss: selector.on_miss,\n\t\t\tstrategy: \"dominant\",\n\t\t};\n\t}\n\n\tif (selector.strategy === \"timerange\") {\n\t\treturn {\n\t\t\tonMiss: selector.on_miss,\n\t\t\tstrategy: \"timerange\",\n\t\t\ttimeRange: {\n\t\t\t\tendSeconds: selector.timerange?.end_seconds ?? undefined,\n\t\t\t\tstartSeconds: selector.timerange?.start_seconds ?? undefined,\n\t\t\t},\n\t\t};\n\t}\n\n\tif (selector.strategy === \"entity_id\") {\n\t\treturn {\n\t\t\tentityId: selector.entity_id ?? \"\",\n\t\t\tonMiss: selector.on_miss,\n\t\t\tstrategy: \"entity_id\",\n\t\t};\n\t}\n\n\tif (selector.strategy === \"speaker_index\") {\n\t\treturn {\n\t\t\tonMiss: selector.on_miss,\n\t\t\tspeakerIndex: selector.speaker_index ?? 0,\n\t\t\tstrategy: \"speaker_index\",\n\t\t};\n\t}\n\n\treturn {\n\t\thint: selector.hint ?? \"\",\n\t\tonMiss: selector.on_miss,\n\t\tstrategy: \"magic_hint\",\n\t};\n}\n\nfunction validateTarget(target: TargetSelector): void {\n\tif (target.strategy === \"timerange\") {\n\t\tvalidateTimerangeTarget(target.timeRange);\n\t\treturn;\n\t}\n\n\tif (target.strategy === \"entity_id\" && !target.entityId.trim()) {\n\t\tthrow new ConduitError(\"target.entityId is required for entity_id\", {\n\t\t\tcode: \"invalid_request\",\n\t\t});\n\t}\n\n\tif (\n\t\ttarget.strategy === \"speaker_index\" &&\n\t\t(!Number.isInteger(target.speakerIndex) || target.speakerIndex < 0)\n\t) {\n\t\tthrow new ConduitError(\n\t\t\t\"target.speakerIndex is required for speaker_index\",\n\t\t\t{\n\t\t\t\tcode: \"invalid_request\",\n\t\t\t},\n\t\t);\n\t}\n\n\tif (target.strategy === \"magic_hint\" && !target.hint.trim()) {\n\t\tthrow new ConduitError(\"target.hint is required for magic_hint\", {\n\t\t\tcode: \"invalid_request\",\n\t\t});\n\t}\n}\n\nfunction validateTimerangeTarget(\n\ttimeRange: { startSeconds?: number; endSeconds?: number } | undefined,\n) {\n\tif (!timeRange) {\n\t\tthrow new ConduitError(\"target.timeRange is required for timerange\", {\n\t\t\tcode: \"invalid_request\",\n\t\t});\n\t}\n\n\tconst start = timeRange.startSeconds;\n\tconst end = timeRange.endSeconds;\n\tif (start === undefined && end === undefined) {\n\t\tthrow new ConduitError(\n\t\t\t\"target.timeRange must include startSeconds or endSeconds\",\n\t\t\t{ code: \"invalid_request\" },\n\t\t);\n\t}\n\tif (start !== undefined && end !== undefined && !(start < end)) {\n\t\tthrow new ConduitError(\n\t\t\t\"target.timeRange.startSeconds must be less than endSeconds\",\n\t\t\t{ code: \"invalid_request\" },\n\t\t);\n\t}\n}\n\nfunction toJobStage(stage: string | undefined): JobStage | undefined {\n\tif (!stage) return;\n\tif (\n\t\tstage === \"uploaded\" ||\n\t\tstage === \"queued\" ||\n\t\tstage === \"transcoding\" ||\n\t\tstage === \"extracting\" ||\n\t\tstage === \"scoring\" ||\n\t\tstage === \"rendering\" ||\n\t\tstage === \"finalizing\"\n\t) {\n\t\treturn stage;\n\t}\n}\n\nexport { MatchingAnalysisResource };\n","import { z } from \"zod\";\n\nexport const psychometricsTargetStrategy = z.enum([\"dominant\", \"magic_hint\"]);\nexport type PsychometricsTargetStrategy = z.infer<\n\ttypeof psychometricsTargetStrategy\n>;\n\nexport const psychometricsIngestionState = z.enum([\n\t\"processing\",\n\t\"ready\",\n\t\"rejected\",\n\t\"failed\",\n]);\nexport type PsychometricsIngestionState = z.infer<\n\ttypeof psychometricsIngestionState\n>;\n\nexport const psychometricsIngestionStarted = z.object({\n\taudioId: z.string().min(1),\n\tstatus: psychometricsIngestionState,\n});\nexport type PsychometricsIngestionStarted = z.infer<\n\ttypeof psychometricsIngestionStarted\n>;\n\nexport const psychometricsIngestionSpeaker = z.object({\n\tcleanSpeechSeconds: z.number().nonnegative(),\n\tspeakerIndex: z.number().int().nonnegative(),\n\ttranscriptExcerpt: z.string(),\n});\nexport type PsychometricsIngestionSpeaker = z.infer<\n\ttypeof psychometricsIngestionSpeaker\n>;\n\nexport const psychometricsIngestion = z.object({\n\taudioId: z.string().min(1),\n\tdurationSeconds: z.number().nonnegative().nullable(),\n\tspeakers: z.array(psychometricsIngestionSpeaker),\n\tstatus: psychometricsIngestionState,\n});\nexport type PsychometricsIngestion = z.infer<typeof psychometricsIngestion>;\n\n// Per-stage summary of the survey-2.0 pipeline (Service 1 ingest -> Service 2\n// voiceprint -> Service 3 predict). Structured facts only; the frontend turns\n// these into plain-language copy for the internal Reports lab. Present only on\n// the psychometrics_v2 path; omitted for survey-1.0.\nexport const psychometricsPipelineClip = z.object({\n\tname: z.string(),\n\turl: z.string(),\n});\nexport type PsychometricsPipelineClip = z.infer<\n\ttypeof psychometricsPipelineClip\n>;\n\nexport const psychometricsPipelineSpeaker = z.object({\n\tanalyzed: z.boolean(),\n\tcleanSpeechSeconds: z.number().nonnegative(),\n\tclips: z.array(psychometricsPipelineClip),\n\tspeakerId: z.string(),\n\ttranscriptExcerpt: z.string(),\n});\nexport type PsychometricsPipelineSpeaker = z.infer<\n\ttypeof psychometricsPipelineSpeaker\n>;\n\nexport const psychometricsPipeline = z.object({\n\tanalysis: z.object({\n\t\tanalyzedSeconds: z.number().nullable(),\n\t\tclipUri: z.string().nullable(),\n\t\tmodelVersion: z.string().nullable(),\n\t\ttargetSpeakerId: z.string().nullable(),\n\t\ttraitCount: z.number().int().nonnegative(),\n\t}),\n\taudio: z.object({\n\t\taudioId: z.string(),\n\t\tdurationSeconds: z.number().nullable(),\n\t\tfileName: z.string(),\n\t\tspeakerCount: z.number().int().nonnegative(),\n\t\tspeakers: z.array(psychometricsPipelineSpeaker),\n\t}),\n});\nexport type PsychometricsPipeline = z.infer<typeof psychometricsPipeline>;\n\n// Per-clip mappa-llm-service output, surfaced only on the survey-2.5 path so the\n// internal lab can visualize the LLM judge features that feed the champion model.\nexport const psychometricsTextFeatureClip = z.object({\n\tclipId: z.string(),\n\tgte: z.object({\n\t\tdimensions: z.number().int().nonnegative(),\n\t\tmodel: z.string(),\n\t}),\n\tjudgment: z.record(z.string(), z.number()),\n\ttranscript: z.string(),\n});\nexport type PsychometricsTextFeatureClip = z.infer<\n\ttypeof psychometricsTextFeatureClip\n>;\n\nexport const psychometricsResult = z.object({\n\tanalysisId: z.string(),\n\tcreatedAt: z.iso.datetime(),\n\texpiresAt: z.iso.datetime(),\n\tpipeline: psychometricsPipeline.optional(),\n\tpsychometrics: z.record(z.string(), z.number()),\n\ttextFeatures: z.array(psychometricsTextFeatureClip).optional(),\n});\nexport type PsychometricsResult = z.infer<typeof psychometricsResult>;\n\nexport const getPsychometricsParams = z.object({\n\tanalysisId: z.string().min(1),\n});\nexport type GetPsychometricsParams = z.infer<typeof getPsychometricsParams>;\n\nexport const psychometricsExpiredError = z.object({\n\terror: z.object({\n\t\tcode: z.literal(\"gone\"),\n\t\tmessage: z.string(),\n\t}),\n});\nexport type PsychometricsExpiredError = z.infer<\n\ttypeof psychometricsExpiredError\n>;\n\nexport const psychometricsNotFoundError = z.object({\n\terror: z.object({\n\t\tcode: z.literal(\"not_found\"),\n\t\tmessage: z.string(),\n\t}),\n});\nexport type PsychometricsNotFoundError = z.infer<\n\ttypeof psychometricsNotFoundError\n>;\n","import * as PsychometricsModel from \"@mappa-ai/contracts/v2/psychometrics\";\nimport {\n\tConduitError,\n\tInvalidSourceError,\n\tUnsupportedRuntimeError,\n} from \"../errors\";\nimport type {\n\tPsychometricsCreateRequest,\n\tPsychometricsResult,\n\tPsychometricsSource,\n\tPsychometricsTarget,\n} from \"../psychometrics-types\";\nimport { DEFAULT_MAX_SOURCE_BYTES, materializeSource } from \"./source\";\nimport type { Transport } from \"./transport\";\nimport { parseRes } from \"./validate\";\n\nfunction psychometricsValidateSource(source: PsychometricsSource) {\n\tconst keys = [\"file\", \"url\", \"path\"].filter((key) => key in source);\n\tif (keys.length === 1) {\n\t\treturn source;\n\t}\n\n\tthrow new InvalidSourceError(\n\t\t\"source must include exactly one of file, url, or path\",\n\t\t{\n\t\t\tcode: \"invalid_source\",\n\t\t},\n\t);\n}\n\nfunction psychometricsValidateTarget(target: PsychometricsTarget) {\n\tif (target.strategy === \"dominant\") {\n\t\treturn target;\n\t}\n\n\tif (!target.hint.trim()) {\n\t\tthrow new ConduitError(\"target.hint is required for magic_hint\", {\n\t\t\tcode: \"invalid_request\",\n\t\t});\n\t}\n\n\treturn target;\n}\n\nexport class PsychometricsResource {\n\tprivate readonly transport: Transport;\n\tprivate readonly fetchImpl: typeof fetch;\n\tprivate readonly timeoutMs: number;\n\tprivate readonly maxSourceBytes: number;\n\n\tconstructor(\n\t\ttransport: Transport,\n\t\topts?: {\n\t\t\tfetchImpl?: typeof fetch;\n\t\t\ttimeoutMs?: number;\n\t\t\tmaxSourceBytes?: number;\n\t\t},\n\t) {\n\t\tthis.transport = transport;\n\t\tthis.fetchImpl = opts?.fetchImpl ?? fetch;\n\t\tthis.timeoutMs = opts?.timeoutMs ?? 300000;\n\t\tthis.maxSourceBytes = opts?.maxSourceBytes ?? DEFAULT_MAX_SOURCE_BYTES;\n\t}\n\n\tasync create(req: PsychometricsCreateRequest): Promise<PsychometricsResult> {\n\t\tif (typeof FormData === \"undefined\") {\n\t\t\tthrow new UnsupportedRuntimeError(\n\t\t\t\t\"FormData is not available in this runtime; cannot perform multipart upload\",\n\t\t\t\t{ code: \"unsupported_runtime\" },\n\t\t\t);\n\t\t}\n\n\t\tconst source = psychometricsValidateSource(req.source);\n\t\tconst target = psychometricsValidateTarget(req.target);\n\t\tconst materialized = await materializeSource(source, {\n\t\t\tfetchImpl: this.fetchImpl,\n\t\t\tmaxSourceBytes: this.maxSourceBytes,\n\t\t\tsignal: req.signal,\n\t\t\ttimeoutMs: this.timeoutMs,\n\t\t});\n\n\t\tconst form = new FormData();\n\t\tform.append(\"file\", materialized.file, materialized.label);\n\t\tform.append(\"strategy\", target.strategy);\n\t\tif (target.strategy === \"magic_hint\") {\n\t\t\tform.append(\"hint\", target.hint);\n\t\t}\n\n\t\tconst res = await this.transport.request<unknown>({\n\t\t\tbody: form,\n\t\t\tidempotencyKey: req.idempotencyKey,\n\t\t\tmethod: \"POST\",\n\t\t\tpath: \"/v2/psychometrics\",\n\t\t\trequestId: req.requestId,\n\t\t\tretryable: false,\n\t\t\tsignal: req.signal,\n\t\t});\n\n\t\treturn parseRes(\n\t\t\tPsychometricsModel.psychometricsResult,\n\t\t\tres.data,\n\t\t\t\"psychometrics.create\",\n\t\t);\n\t}\n\n\tasync get(\n\t\tanalysisId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<PsychometricsResult> {\n\t\tif (!analysisId.trim()) {\n\t\t\tthrow new ConduitError(\"analysisId must be a non-empty string\", {\n\t\t\t\tcode: \"invalid_request\",\n\t\t\t});\n\t\t}\n\n\t\tconst res = await this.transport.request<unknown>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v2/psychometrics/${encodeURIComponent(analysisId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\n\t\treturn parseRes(\n\t\t\tPsychometricsModel.psychometricsResult,\n\t\t\tres.data,\n\t\t\t\"psychometrics.get\",\n\t\t);\n\t}\n}\n","import type { ReportResponse as ContractReportResponse } from \"@mappa-ai/contracts/v1/reports\";\nimport {\n\tjobReceipt,\n\treportCreateJobBody,\n\treportResponse,\n} from \"@mappa-ai/contracts/v1/reports\";\nimport { ConduitError, InvalidSourceError } from \"../errors\";\nimport type {\n\tJobEvent,\n\tJobStage,\n\tReport,\n\tReportCreateRequest,\n\tReportForOutputType,\n\tReportJobReceipt,\n\tReportRunHandle,\n\tReportSource,\n\tWaitOptions,\n} from \"../types\";\nimport { randomId } from \"../utils\";\nimport type { FilesResource } from \"./files\";\nimport type { JobsResource } from \"./jobs\";\nimport type { Transport } from \"./transport\";\nimport { parseReq, parseRes } from \"./validate\";\n\nclass ReportsResource {\n\tprivate readonly transport: Transport;\n\tprivate readonly jobs: JobsResource;\n\tprivate readonly files: FilesResource;\n\n\tconstructor(transport: Transport, jobs: JobsResource, files: FilesResource) {\n\t\tthis.transport = transport;\n\t\tthis.jobs = jobs;\n\t\tthis.files = files;\n\t}\n\n\tasync create(req: ReportCreateRequest): Promise<ReportJobReceipt> {\n\t\tvalidateTarget(req.target);\n\t\tconst mediaId = await this.resolveSource(req.source, {\n\t\t\tidempotencyKey: req.idempotencyKey,\n\t\t\trequestId: req.requestId,\n\t\t\tsignal: req.signal,\n\t\t});\n\n\t\tconst idem = req.idempotencyKey ?? this.defaultIdempotencyKey();\n\t\tconst body = parseReq(\n\t\t\treportCreateJobBody,\n\t\t\tthis.normalizeCreateRequest(req, mediaId),\n\t\t\t\"reports.create body\",\n\t\t);\n\n\t\tconst res = await this.transport.request<Omit<ReportJobReceipt, \"handle\">>({\n\t\t\tbody,\n\t\t\tidempotencyKey: idem,\n\t\t\tmethod: \"POST\",\n\t\t\tpath: \"/v1/reports/jobs\",\n\t\t\trequestId: req.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: req.signal,\n\t\t});\n\n\t\tconst receiptData = parseRes(jobReceipt, res.data, \"reports.createJob\") as {\n\t\t\testimatedWaitSec?: number;\n\t\t\tjobId: string;\n\t\t\tstage?: string;\n\t\t\tstatus: \"queued\" | \"running\";\n\t\t};\n\t\tconst receipt: ReportJobReceipt = {\n\t\t\t...receiptData,\n\t\t\tmediaId,\n\t\t\trequestId: res.requestId ?? res.data.requestId,\n\t\t\tstage: toJobStage(receiptData.stage),\n\t\t};\n\t\treceipt.handle = this.handle(receipt.jobId);\n\t\treturn receipt;\n\t}\n\n\tasync get(\n\t\treportId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Report> {\n\t\tconst res = await this.transport.request<unknown>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/reports/${encodeURIComponent(reportId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\treturn toReport(parseRes(reportResponse, res.data, \"reports.get\"));\n\t}\n\n\tprivate async getByJob(\n\t\tjobId: string,\n\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t): Promise<Report | null> {\n\t\tconst res = await this.transport.request<unknown>({\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `/v1/reports/by-job/${encodeURIComponent(jobId)}`,\n\t\t\trequestId: opts?.requestId,\n\t\t\tretryable: true,\n\t\t\tsignal: opts?.signal,\n\t\t});\n\t\tif (res.data === null) return null;\n\t\treturn toReport(parseRes(reportResponse, res.data, \"reports.getByJob\"));\n\t}\n\n\tprivate handle(jobId: string): ReportRunHandle {\n\t\treturn {\n\t\t\tcancel: () => this.jobs.cancel(jobId),\n\t\t\tjob: () => this.jobs.get(jobId),\n\t\t\tjobId,\n\t\t\treport: () => this.getByJob(jobId) as Promise<ReportForOutputType | null>,\n\t\t\tstream: (opts?: {\n\t\t\t\tsignal?: AbortSignal;\n\t\t\t\tonEvent?: (e: JobEvent) => void;\n\t\t\t}) => this.jobs.stream(jobId, opts),\n\t\t\twait: async (opts?: WaitOptions): Promise<ReportForOutputType> => {\n\t\t\t\tconst terminal = await this.jobs.wait(jobId, opts);\n\t\t\t\tif (!terminal.reportId) {\n\t\t\t\t\tthrow new ConduitError(\n\t\t\t\t\t\t`Job ${jobId} succeeded but no reportId was returned`,\n\t\t\t\t\t\t{ code: \"invalid_response\" },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this.get(terminal.reportId) as Promise<ReportForOutputType>;\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate defaultIdempotencyKey(): string {\n\t\treturn randomId(\"idem\");\n\t}\n\n\tprivate async resolveSource(\n\t\tsource: ReportSource,\n\t\topts: {\n\t\t\tidempotencyKey?: string;\n\t\t\trequestId?: string;\n\t\t\tsignal?: AbortSignal;\n\t\t},\n\t): Promise<string> {\n\t\tconst keys = [\"mediaId\", \"file\", \"url\", \"path\"].filter(\n\t\t\t(key) => key in source,\n\t\t);\n\t\tif (keys.length !== 1) {\n\t\t\tthrow new InvalidSourceError(\n\t\t\t\t\"source must include exactly one of mediaId, file, url, or path\",\n\t\t\t\t{ code: \"invalid_source\" },\n\t\t\t);\n\t\t}\n\n\t\tif (\"mediaId\" in source) {\n\t\t\tif (!source.mediaId) {\n\t\t\t\tthrow new InvalidSourceError(\n\t\t\t\t\t\"source.mediaId must be a non-empty string\",\n\t\t\t\t\t{ code: \"invalid_source\" },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn source.mediaId;\n\t\t}\n\n\t\tif (\"file\" in source) {\n\t\t\tconst upload = await this.files.upload({\n\t\t\t\tfile: source.file,\n\t\t\t\tidempotencyKey: opts.idempotencyKey,\n\t\t\t\tlabel: source.label,\n\t\t\t\trequestId: opts.requestId,\n\t\t\t\tsignal: opts.signal,\n\t\t\t});\n\t\t\treturn upload.mediaId;\n\t\t}\n\n\t\tif (\"path\" in source) {\n\t\t\tconst upload = await this.files.upload({\n\t\t\t\tidempotencyKey: opts.idempotencyKey,\n\t\t\t\tlabel: source.label,\n\t\t\t\tpath: source.path,\n\t\t\t\trequestId: opts.requestId,\n\t\t\t\tsignal: opts.signal,\n\t\t\t});\n\t\t\treturn upload.mediaId;\n\t\t}\n\n\t\tconst upload = await this.files.upload({\n\t\t\tidempotencyKey: opts.idempotencyKey,\n\t\t\tlabel: source.label,\n\t\t\trequestId: opts.requestId,\n\t\t\tsignal: opts.signal,\n\t\t\turl: source.url,\n\t\t});\n\t\treturn upload.mediaId;\n\t}\n\n\tprivate normalizeCreateRequest(\n\t\treq: ReportCreateRequest,\n\t\tmediaId: string,\n\t): Record<string, unknown> {\n\t\treturn {\n\t\t\tentityLabel: req.entityLabel,\n\t\t\tidempotencyKey: req.idempotencyKey,\n\t\t\tlanguage: req.language,\n\t\t\tlabel: req.label,\n\t\t\tmedia: { mediaId },\n\t\t\toutput: req.output,\n\t\t\ttarget: normalizeTarget(req.target),\n\t\t\twebhook: req.webhook,\n\t\t};\n\t}\n}\n\nfunction normalizeTarget(\n\ttarget: ReportCreateRequest[\"target\"],\n): Record<string, unknown> {\n\tif (target.strategy === \"dominant\") {\n\t\treturn {\n\t\t\tstrategy: target.strategy,\n\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t};\n\t}\n\n\tif (target.strategy === \"timerange\") {\n\t\treturn {\n\t\t\tstrategy: target.strategy,\n\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\ttimerange: {\n\t\t\t\tend_seconds: target.timeRange?.endSeconds ?? null,\n\t\t\t\tstart_seconds: target.timeRange?.startSeconds ?? null,\n\t\t\t},\n\t\t};\n\t}\n\n\tif (target.strategy === \"entity_id\") {\n\t\treturn {\n\t\t\tstrategy: target.strategy,\n\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\tentity_id: target.entityId,\n\t\t};\n\t}\n\n\tif (target.strategy === \"speaker_index\") {\n\t\treturn {\n\t\t\tstrategy: target.strategy,\n\t\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\t\tspeaker_index: target.speakerIndex,\n\t\t};\n\t}\n\n\treturn {\n\t\tstrategy: target.strategy,\n\t\t...(target.onMiss ? { on_miss: target.onMiss } : {}),\n\t\thint: target.hint,\n\t};\n}\n\nfunction validateTarget(target: ReportCreateRequest[\"target\"]): void {\n\tif (target.strategy === \"timerange\") {\n\t\tvalidateTimerangeTarget(target.timeRange);\n\t\treturn;\n\t}\n\n\tif (target.strategy === \"entity_id\" && !target.entityId.trim()) {\n\t\tthrow new ConduitError(\"target.entityId is required for entity_id\", {\n\t\t\tcode: \"invalid_request\",\n\t\t});\n\t}\n\n\tif (\n\t\ttarget.strategy === \"speaker_index\" &&\n\t\t(!Number.isInteger(target.speakerIndex) || target.speakerIndex < 0)\n\t) {\n\t\tthrow new ConduitError(\n\t\t\t\"target.speakerIndex is required for speaker_index\",\n\t\t\t{\n\t\t\t\tcode: \"invalid_request\",\n\t\t\t},\n\t\t);\n\t}\n\n\tif (target.strategy === \"magic_hint\" && !target.hint.trim()) {\n\t\tthrow new ConduitError(\"target.hint is required for magic_hint\", {\n\t\t\tcode: \"invalid_request\",\n\t\t});\n\t}\n}\n\nfunction validateTimerangeTarget(\n\ttimeRange: { startSeconds?: number; endSeconds?: number } | undefined,\n) {\n\tif (!timeRange) {\n\t\tthrow new ConduitError(\"target.timeRange is required for timerange\", {\n\t\t\tcode: \"invalid_request\",\n\t\t});\n\t}\n\n\tconst start = timeRange.startSeconds;\n\tconst end = timeRange.endSeconds;\n\tif (start === undefined && end === undefined) {\n\t\tthrow new ConduitError(\n\t\t\t\"target.timeRange must include startSeconds or endSeconds\",\n\t\t\t{ code: \"invalid_request\" },\n\t\t);\n\t}\n\tif (start !== undefined && end !== undefined && !(start < end)) {\n\t\tthrow new ConduitError(\n\t\t\t\"target.timeRange.startSeconds must be less than endSeconds\",\n\t\t\t{ code: \"invalid_request\" },\n\t\t);\n\t}\n}\n\nfunction toJobStage(stage: string | undefined): JobStage | undefined {\n\tif (!stage) return;\n\tif (\n\t\tstage === \"uploaded\" ||\n\t\tstage === \"queued\" ||\n\t\tstage === \"transcoding\" ||\n\t\tstage === \"extracting\" ||\n\t\tstage === \"scoring\" ||\n\t\tstage === \"rendering\" ||\n\t\tstage === \"finalizing\"\n\t) {\n\t\treturn stage;\n\t}\n}\n\nfunction toReport(report: ContractReportResponse): Report {\n\treturn {\n\t\tcreatedAt: report.createdAt,\n\t\tentityId: report.entity?.id,\n\t\tentityLabel: report.entity?.label,\n\t\tid: report.id,\n\t\tjobId: report.jobId,\n\t\tlabel: report.label,\n\t\tmediaId: report.media.mediaId,\n\t\tprovenance: report.provenance,\n\t\toutput: {\n\t\t\tjson: report.json ?? null,\n\t\t\tmarkdown: report.markdown ?? null,\n\t\t\ttemplate: report.output.template,\n\t\t},\n\t};\n}\n\nexport { ReportsResource };\n","import { ConduitError, WebhookVerificationError } from \"../errors\";\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n\treturn v !== null && typeof v === \"object\";\n}\n\ntype WebhookEventType =\n\t| \"report.completed\"\n\t| \"report.failed\"\n\t| \"matching.completed\"\n\t| \"matching.failed\";\n\ntype WebhookEvent<T = unknown> = {\n\tcreatedAt: string;\n\tdata: T;\n\tid: string;\n\ttimestamp: string;\n\ttype: string;\n};\n\ntype ReportCompletedData = {\n\tjobId: string;\n\treportId: string;\n\tstatus: \"succeeded\";\n};\n\ntype ReportFailedData = {\n\terror: {\n\t\tcode: string;\n\t\tmessage: string;\n\t};\n\tjobId: string;\n\tstatus: \"failed\";\n};\n\ntype MatchingCompletedData = {\n\tjobId: string;\n\tmatchingId: string;\n\tstatus: \"succeeded\";\n};\n\ntype MatchingFailedData = {\n\terror: {\n\t\tcode: string;\n\t\tmessage: string;\n\t};\n\tjobId: string;\n\tstatus: \"failed\";\n};\n\ntype ReportCompletedEvent = WebhookEvent<ReportCompletedData> & {\n\ttype: \"report.completed\";\n};\n\ntype ReportFailedEvent = WebhookEvent<ReportFailedData> & {\n\ttype: \"report.failed\";\n};\n\ntype MatchingCompletedEvent = WebhookEvent<MatchingCompletedData> & {\n\ttype: \"matching.completed\";\n};\n\ntype MatchingFailedEvent = WebhookEvent<MatchingFailedData> & {\n\ttype: \"matching.failed\";\n};\n\nclass WebhooksResource {\n\tasync verifySignature(params: {\n\t\tpayload: string;\n\t\theaders: Record<string, string | string[] | undefined>;\n\t\tsecret: string;\n\t\ttoleranceSec?: number;\n\t}): Promise<{ ok: true }> {\n\t\tconst tolerance = params.toleranceSec ?? 300;\n\t\tconst sigHeader = getHeader(params.headers, \"conduit-signature\");\n\t\tif (!sigHeader) {\n\t\t\tthrow new WebhookVerificationError(\"Missing conduit-signature header\", {\n\t\t\t\tcode: \"webhook_signature_missing\",\n\t\t\t});\n\t\t}\n\n\t\tconst sig = parseSignature(sigHeader);\n\t\tconst ts = Number(sig.t);\n\t\tif (!Number.isFinite(ts)) {\n\t\t\tthrow new WebhookVerificationError(\"Invalid signature timestamp\", {\n\t\t\t\tcode: \"webhook_signature_invalid\",\n\t\t\t});\n\t\t}\n\n\t\tconst now = Math.floor(Date.now() / 1000);\n\t\tif (Math.abs(now - ts) > tolerance) {\n\t\t\tthrow new WebhookVerificationError(\n\t\t\t\t\"Signature timestamp outside tolerance\",\n\t\t\t\t{ code: \"webhook_signature_stale\" },\n\t\t\t);\n\t\t}\n\n\t\tconst expected = await hmacHex(params.secret, `${sig.t}.${params.payload}`);\n\t\tif (!timingSafeEqualHex(expected, sig.v1)) {\n\t\t\tthrow new WebhookVerificationError(\"Invalid signature\", {\n\t\t\t\tcode: \"webhook_signature_invalid\",\n\t\t\t});\n\t\t}\n\n\t\treturn { ok: true };\n\t}\n\n\tparseEvent(\n\t\tpayload: string,\n\t):\n\t\t| ReportCompletedEvent\n\t\t| ReportFailedEvent\n\t\t| MatchingCompletedEvent\n\t\t| MatchingFailedEvent\n\t\t| WebhookEvent<unknown>;\n\tparseEvent<T = unknown>(payload: string): WebhookEvent<T>;\n\tparseEvent<T = unknown>(payload: string): WebhookEvent<T> {\n\t\tlet raw: unknown;\n\t\ttry {\n\t\t\traw = JSON.parse(payload) as unknown;\n\t\t} catch (cause) {\n\t\t\tthrow new ConduitError(\"Invalid webhook payload: invalid JSON\", {\n\t\t\t\tcause,\n\t\t\t\tcode: \"invalid_webhook_payload\",\n\t\t\t});\n\t\t}\n\t\tif (!isObject(raw)) {\n\t\t\tthrow new ConduitError(\"Invalid webhook payload: not an object\", {\n\t\t\t\tcode: \"invalid_webhook_payload\",\n\t\t\t});\n\t\t}\n\t\tif (typeof raw.id !== \"string\") {\n\t\t\tthrow new ConduitError(\"Invalid webhook payload: id must be a string\", {\n\t\t\t\tcode: \"invalid_webhook_payload\",\n\t\t\t});\n\t\t}\n\t\tif (typeof raw.type !== \"string\") {\n\t\t\tthrow new ConduitError(\"Invalid webhook payload: type must be a string\", {\n\t\t\t\tcode: \"invalid_webhook_payload\",\n\t\t\t});\n\t\t}\n\t\tif (typeof raw.createdAt !== \"string\") {\n\t\t\tthrow new ConduitError(\n\t\t\t\t\"Invalid webhook payload: createdAt must be a string\",\n\t\t\t\t{ code: \"invalid_webhook_payload\" },\n\t\t\t);\n\t\t}\n\t\tif (!isIsoTimestamp(raw.createdAt)) {\n\t\t\tthrow new ConduitError(\n\t\t\t\t\"Invalid webhook payload: createdAt must be an ISO8601 string\",\n\t\t\t\t{ code: \"invalid_webhook_payload\" },\n\t\t\t);\n\t\t}\n\t\tif (typeof raw.timestamp !== \"string\") {\n\t\t\tthrow new ConduitError(\n\t\t\t\t\"Invalid webhook payload: timestamp must be a string\",\n\t\t\t\t{ code: \"invalid_webhook_payload\" },\n\t\t\t);\n\t\t}\n\t\tif (!isIsoTimestamp(raw.timestamp)) {\n\t\t\tthrow new ConduitError(\n\t\t\t\t\"Invalid webhook payload: timestamp must be an ISO8601 string\",\n\t\t\t\t{ code: \"invalid_webhook_payload\" },\n\t\t\t);\n\t\t}\n\n\t\tconst data = \"data\" in raw ? raw.data : undefined;\n\t\tif (raw.type === \"report.completed\") {\n\t\t\treturn {\n\t\t\t\tcreatedAt: raw.createdAt,\n\t\t\t\tdata: parseReportCompletedData(data) as T,\n\t\t\t\tid: raw.id,\n\t\t\t\ttimestamp: raw.timestamp,\n\t\t\t\ttype: raw.type,\n\t\t\t};\n\t\t}\n\n\t\tif (raw.type === \"report.failed\") {\n\t\t\treturn {\n\t\t\t\tcreatedAt: raw.createdAt,\n\t\t\t\tdata: parseReportFailedData(data) as T,\n\t\t\t\tid: raw.id,\n\t\t\t\ttimestamp: raw.timestamp,\n\t\t\t\ttype: raw.type,\n\t\t\t};\n\t\t}\n\n\t\tif (raw.type === \"matching.completed\") {\n\t\t\treturn {\n\t\t\t\tcreatedAt: raw.createdAt,\n\t\t\t\tdata: parseMatchingCompletedData(data) as T,\n\t\t\t\tid: raw.id,\n\t\t\t\ttimestamp: raw.timestamp,\n\t\t\t\ttype: raw.type,\n\t\t\t};\n\t\t}\n\n\t\tif (raw.type === \"matching.failed\") {\n\t\t\treturn {\n\t\t\t\tcreatedAt: raw.createdAt,\n\t\t\t\tdata: parseMatchingFailedData(data) as T,\n\t\t\t\tid: raw.id,\n\t\t\t\ttimestamp: raw.timestamp,\n\t\t\t\ttype: raw.type,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tcreatedAt: raw.createdAt,\n\t\t\tdata: data as T,\n\t\t\tid: raw.id,\n\t\t\ttimestamp: raw.timestamp,\n\t\t\ttype: raw.type,\n\t\t};\n\t}\n}\n\nfunction parseReportCompletedData(data: unknown): ReportCompletedData {\n\tif (!isObject(data)) {\n\t\tthrow invalidPayloadError(\"Invalid report.completed data: not an object\");\n\t}\n\tif (typeof data.jobId !== \"string\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid report.completed data: jobId must be a string\",\n\t\t);\n\t}\n\tif (typeof data.reportId !== \"string\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid report.completed data: reportId must be a string\",\n\t\t);\n\t}\n\tif (data.status !== \"succeeded\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid report.completed data: status must be succeeded\",\n\t\t);\n\t}\n\treturn { jobId: data.jobId, reportId: data.reportId, status: data.status };\n}\n\nfunction parseReportFailedData(data: unknown): ReportFailedData {\n\tif (!isObject(data)) {\n\t\tthrow invalidPayloadError(\"Invalid report.failed data: not an object\");\n\t}\n\tif (typeof data.jobId !== \"string\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid report.failed data: jobId must be a string\",\n\t\t);\n\t}\n\tif (data.status !== \"failed\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid report.failed data: status must be failed\",\n\t\t);\n\t}\n\tif (!isObject(data.error)) {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid report.failed data: error must be an object\",\n\t\t);\n\t}\n\tif (typeof data.error.code !== \"string\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid report.failed data: error.code must be a string\",\n\t\t);\n\t}\n\tif (typeof data.error.message !== \"string\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid report.failed data: error.message must be a string\",\n\t\t);\n\t}\n\treturn {\n\t\terror: {\n\t\t\tcode: data.error.code,\n\t\t\tmessage: data.error.message,\n\t\t},\n\t\tjobId: data.jobId,\n\t\tstatus: data.status,\n\t};\n}\n\nfunction parseMatchingCompletedData(data: unknown): MatchingCompletedData {\n\tif (!isObject(data)) {\n\t\tthrow invalidPayloadError(\"Invalid matching.completed data: not an object\");\n\t}\n\tif (typeof data.jobId !== \"string\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid matching.completed data: jobId must be a string\",\n\t\t);\n\t}\n\tif (typeof data.matchingId !== \"string\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid matching.completed data: matchingId must be a string\",\n\t\t);\n\t}\n\tif (data.status !== \"succeeded\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid matching.completed data: status must be succeeded\",\n\t\t);\n\t}\n\treturn {\n\t\tjobId: data.jobId,\n\t\tmatchingId: data.matchingId,\n\t\tstatus: data.status,\n\t};\n}\n\nfunction parseMatchingFailedData(data: unknown): MatchingFailedData {\n\tif (!isObject(data)) {\n\t\tthrow invalidPayloadError(\"Invalid matching.failed data: not an object\");\n\t}\n\tif (typeof data.jobId !== \"string\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid matching.failed data: jobId must be a string\",\n\t\t);\n\t}\n\tif (data.status !== \"failed\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid matching.failed data: status must be failed\",\n\t\t);\n\t}\n\tif (!isObject(data.error)) {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid matching.failed data: error must be an object\",\n\t\t);\n\t}\n\tif (typeof data.error.code !== \"string\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid matching.failed data: error.code must be a string\",\n\t\t);\n\t}\n\tif (typeof data.error.message !== \"string\") {\n\t\tthrow invalidPayloadError(\n\t\t\t\"Invalid matching.failed data: error.message must be a string\",\n\t\t);\n\t}\n\treturn {\n\t\terror: {\n\t\t\tcode: data.error.code,\n\t\t\tmessage: data.error.message,\n\t\t},\n\t\tjobId: data.jobId,\n\t\tstatus: data.status,\n\t};\n}\n\nfunction invalidPayloadError(message: string): ConduitError {\n\treturn new ConduitError(message, { code: \"invalid_webhook_payload\" });\n}\n\nfunction isIsoTimestamp(value: string): boolean {\n\treturn !Number.isNaN(Date.parse(value));\n}\n\nfunction getHeader(\n\theaders: Record<string, string | string[] | undefined>,\n\tname: string,\n): string | undefined {\n\tconst key = Object.keys(headers).find(\n\t\t(k) => k.toLowerCase() === name.toLowerCase(),\n\t);\n\tif (!key) return;\n\tconst value = headers[key];\n\tif (!value) return;\n\tif (Array.isArray(value)) return value[0];\n\treturn value;\n}\n\nfunction parseSignature(value: string): { t: string; v1: string } {\n\tconst out: Record<string, string> = {};\n\tfor (const part of value.split(\",\")) {\n\t\tconst [k, v] = part.split(\"=\");\n\t\tif (!(k && v)) {\n\t\t\tthrow invalidSignatureError(\"Invalid signature format\");\n\t\t}\n\t\tconst key = k.trim();\n\t\tif (key in out) {\n\t\t\tthrow invalidSignatureError(\n\t\t\t\t\"Invalid signature format: duplicate component\",\n\t\t\t);\n\t\t}\n\t\tout[key] = v.trim();\n\t}\n\tif (!(out.t && out.v1)) {\n\t\tthrow invalidSignatureError(\"Invalid signature format\");\n\t}\n\treturn { t: out.t, v1: out.v1 };\n}\n\nfunction invalidSignatureError(message: string): WebhookVerificationError {\n\treturn new WebhookVerificationError(message, {\n\t\tcode: \"webhook_signature_invalid\",\n\t});\n}\n\nasync function hmacHex(secret: string, message: string): Promise<string> {\n\tconst enc = new TextEncoder();\n\tconst key = await crypto.subtle.importKey(\n\t\t\"raw\",\n\t\tenc.encode(secret),\n\t\t{ hash: \"SHA-256\", name: \"HMAC\" },\n\t\tfalse,\n\t\t[\"sign\"],\n\t);\n\tconst sig = await crypto.subtle.sign(\"HMAC\", key, enc.encode(message));\n\tconst bytes = new Uint8Array(sig);\n\tlet out = \"\";\n\tfor (const b of bytes) out += b.toString(16).padStart(2, \"0\");\n\treturn out;\n}\n\nfunction timingSafeEqualHex(a: string, b: string): boolean {\n\tif (a.length !== b.length) return false;\n\tlet diff = 0;\n\tfor (let i = 0; i < a.length; i++) {\n\t\tdiff |= a.charCodeAt(i) ^ b.charCodeAt(i);\n\t}\n\treturn diff === 0;\n}\n\nexport type {\n\tMatchingCompletedData,\n\tMatchingCompletedEvent,\n\tMatchingFailedData,\n\tMatchingFailedEvent,\n\tReportCompletedData,\n\tReportCompletedEvent,\n\tReportFailedData,\n\tReportFailedEvent,\n\tWebhookEvent,\n\tWebhookEventType,\n};\nexport { WebhooksResource };\n","import { InitializationError } from \"./errors\";\nimport type {\n\tPsychometricsCreateRequest,\n\tPsychometricsResult,\n} from \"./psychometrics-types\";\nimport { EntitiesResource } from \"./resources/entities\";\nimport { FilesResource } from \"./resources/files\";\nimport { JobsResource } from \"./resources/jobs\";\nimport { MatchingAnalysisResource } from \"./resources/matching-analysis\";\nimport { PsychometricsResource } from \"./resources/psychometrics\";\nimport { ReportsResource } from \"./resources/reports\";\nimport { DEFAULT_MAX_SOURCE_BYTES } from \"./resources/source\";\nimport { type Telemetry, Transport } from \"./resources/transport\";\nimport { WebhooksResource } from \"./resources/webhooks\";\nimport type {\n\tEntity,\n\tFileDeleteReceipt,\n\tJob,\n\tListEntitiesResponse,\n\tListFilesResponse,\n\tMatchingAnalysisCreateJobRequest,\n\tMatchingAnalysisJobReceipt,\n\tMatchingAnalysisResponse,\n\tMediaFile,\n\tMediaObject,\n\tMediaSpeakers,\n\tMediaUploadRequest,\n\tRetentionLockResult,\n} from \"./types\";\n\ntype ConduitClientOptions = {\n\t/** API key used for Conduit authenticated requests. */\n\tapiKey: string;\n\t/** Base API URL. Defaults to https://api.mappa.ai. */\n\tbaseUrl?: string;\n\t/** Per-request timeout in milliseconds. Defaults to 300000. */\n\ttimeoutMs?: number;\n\t/** Number of retry attempts for retryable requests. Defaults to 2. */\n\tmaxRetries?: number;\n\t/** Headers included on every request. */\n\tdefaultHeaders?: Record<string, string>;\n\t/** Custom fetch implementation. */\n\tfetch?: typeof fetch;\n\t/** User-Agent header value sent on requests. */\n\tuserAgent?: string;\n\t/** Request/response/error instrumentation hooks. */\n\ttelemetry?: Telemetry;\n\t/** Maximum source size accepted for file/url/path uploads. Defaults to 5GB. */\n\tmaxSourceBytes?: number;\n\t/**\n\t * Allow use from browser-like runtimes.\n\t *\n\t * This is unsafe for secret API keys and should only be used when\n\t * credentials are intentionally exposed.\n\t */\n\tdangerouslyAllowBrowser?: boolean;\n};\n\ntype ConduitPrimitives = {\n\tentities: {\n\t\tget: (\n\t\t\tentityId: string,\n\t\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t\t) => Promise<Entity>;\n\t\tlist: (opts?: {\n\t\t\tlimit?: number;\n\t\t\tcursor?: string;\n\t\t\trequestId?: string;\n\t\t\tsignal?: AbortSignal;\n\t\t}) => Promise<ListEntitiesResponse>;\n\t\tupdate: (\n\t\t\tentityId: string,\n\t\t\tbody: { label?: string | null },\n\t\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t\t) => Promise<Entity>;\n\t};\n\tmedia: {\n\t\tupload: (req: MediaUploadRequest) => Promise<MediaObject>;\n\t\tget: (\n\t\t\tmediaId: string,\n\t\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t\t) => Promise<MediaFile>;\n\t\tlist: (opts?: {\n\t\t\tlimit?: number;\n\t\t\tcursor?: string;\n\t\t\tincludeDeleted?: boolean;\n\t\t\trequestId?: string;\n\t\t\tsignal?: AbortSignal;\n\t\t}) => Promise<ListFilesResponse>;\n\t\tspeakers: (\n\t\t\tmediaId: string,\n\t\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t\t) => Promise<MediaSpeakers>;\n\t\tdelete: (\n\t\t\tmediaId: string,\n\t\t\topts?: {\n\t\t\t\tidempotencyKey?: string;\n\t\t\t\trequestId?: string;\n\t\t\t\tsignal?: AbortSignal;\n\t\t\t},\n\t\t) => Promise<FileDeleteReceipt>;\n\t\tsetRetentionLock: (\n\t\t\tmediaId: string,\n\t\t\tlocked: boolean,\n\t\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t\t) => Promise<RetentionLockResult>;\n\t};\n\tjobs: {\n\t\tget: (\n\t\t\tjobId: string,\n\t\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t\t) => Promise<Job>;\n\t\tcancel: (\n\t\t\tjobId: string,\n\t\t\topts?: {\n\t\t\t\tidempotencyKey?: string;\n\t\t\t\trequestId?: string;\n\t\t\t\tsignal?: AbortSignal;\n\t\t\t},\n\t\t) => Promise<Job>;\n\t};\n};\n\nclass Conduit {\n\tpublic readonly matching: {\n\t\tcreate: (\n\t\t\treq: MatchingAnalysisCreateJobRequest,\n\t\t) => Promise<MatchingAnalysisJobReceipt>;\n\t\tget: (\n\t\t\tmatchingId: string,\n\t\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t\t) => Promise<MatchingAnalysisResponse>;\n\t};\n\tpublic readonly psychometrics: {\n\t\tcreate: (req: PsychometricsCreateRequest) => Promise<PsychometricsResult>;\n\t\tget: (\n\t\t\tanalysisId: string,\n\t\t\topts?: { requestId?: string; signal?: AbortSignal },\n\t\t) => Promise<PsychometricsResult>;\n\t};\n\tpublic readonly reports: ReportsResource;\n\tpublic readonly primitives: ConduitPrimitives;\n\tpublic readonly webhooks: WebhooksResource;\n\n\t/** Create a new client instance. */\n\tconstructor(options: ConduitClientOptions) {\n\t\tif (!options.apiKey) {\n\t\t\tthrow new InitializationError(\"apiKey is required\", {\n\t\t\t\tcode: \"config_error\",\n\t\t\t});\n\t\t}\n\t\tif (isBrowserRuntime() && !options.dangerouslyAllowBrowser) {\n\t\t\tthrow new InitializationError(\n\t\t\t\t\"Conduit SDK cannot run in browser environments by default because API keys are secret. Use a server/edge proxy or pass dangerouslyAllowBrowser: true only if you understand the risk.\",\n\t\t\t\t{ code: \"unsupported_runtime\" },\n\t\t\t);\n\t\t}\n\n\t\tconst baseUrl = options.baseUrl ?? \"https://api.mappa.ai\";\n\t\tif (!isValidUrl(baseUrl)) {\n\t\t\tthrow new InitializationError(\"baseUrl must be a valid URL\", {\n\t\t\t\tcode: \"config_error\",\n\t\t\t});\n\t\t}\n\t\tconst timeoutMs = options.timeoutMs ?? 300000;\n\t\tconst maxRetries = options.maxRetries ?? 2;\n\t\tconst maxSourceBytes = options.maxSourceBytes ?? DEFAULT_MAX_SOURCE_BYTES;\n\n\t\tconst transport = new Transport({\n\t\t\tapiKey: options.apiKey,\n\t\t\tbaseUrl,\n\t\t\tdefaultHeaders: options.defaultHeaders,\n\t\t\tfetch: options.fetch,\n\t\t\tmaxRetries,\n\t\t\ttelemetry: options.telemetry,\n\t\t\ttimeoutMs,\n\t\t\tuserAgent: options.userAgent,\n\t\t});\n\n\t\tconst files = new FilesResource(transport, {\n\t\t\tfetchImpl: options.fetch,\n\t\t\tmaxSourceBytes,\n\t\t\ttimeoutMs,\n\t\t});\n\t\tconst jobs = new JobsResource(transport);\n\t\tconst entities = new EntitiesResource(transport);\n\t\tconst matching = new MatchingAnalysisResource(transport, jobs);\n\t\tconst psychometrics = new PsychometricsResource(transport, {\n\t\t\tfetchImpl: options.fetch,\n\t\t\tmaxSourceBytes,\n\t\t\ttimeoutMs,\n\t\t});\n\t\tthis.matching = {\n\t\t\tcreate: matching.create.bind(matching),\n\t\t\tget: matching.get.bind(matching),\n\t\t};\n\t\tthis.psychometrics = {\n\t\t\tcreate: psychometrics.create.bind(psychometrics),\n\t\t\tget: psychometrics.get.bind(psychometrics),\n\t\t};\n\t\tthis.reports = new ReportsResource(transport, jobs, files);\n\t\tthis.primitives = {\n\t\t\tentities: {\n\t\t\t\tget: entities.get.bind(entities),\n\t\t\t\tlist: entities.list.bind(entities),\n\t\t\t\tupdate: entities.update.bind(entities),\n\t\t\t},\n\t\t\tjobs: {\n\t\t\t\tcancel: jobs.cancel.bind(jobs),\n\t\t\t\tget: jobs.get.bind(jobs),\n\t\t\t},\n\t\t\tmedia: {\n\t\t\t\tdelete: files.delete.bind(files),\n\t\t\t\tget: files.get.bind(files),\n\t\t\t\tlist: files.list.bind(files),\n\t\t\t\tsetRetentionLock: files.setRetentionLock.bind(files),\n\t\t\t\tspeakers: files.speakers.bind(files),\n\t\t\t\tupload: files.upload.bind(files),\n\t\t\t},\n\t\t};\n\t\tthis.webhooks = new WebhooksResource();\n\t}\n}\n\nfunction isBrowserRuntime(): boolean {\n\tif (typeof globalThis.window === \"undefined\") return false;\n\tif (typeof document === \"undefined\") return false;\n\treturn true;\n}\n\nfunction isValidUrl(value: string): boolean {\n\ttry {\n\t\tnew URL(value);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport type { ConduitClientOptions, ConduitPrimitives };\nexport { Conduit };\n","import {\n\tApiError,\n\tAuthError,\n\tConduitError,\n\tInitializationError,\n\tInsufficientCreditsError,\n\tInvalidSourceError,\n\tJobCanceledError,\n\tJobFailedError,\n\tRateLimitError,\n\tRemoteFetchError,\n\tRemoteFetchTimeoutError,\n\tRemoteFetchTooLargeError,\n\tRequestAbortedError,\n\tSourceError,\n\tStreamError,\n\tTimeoutError,\n\tUnsupportedRuntimeError,\n\tValidationError,\n\tWebhookVerificationError,\n} from \"./errors\";\n\nfunction isConduitError(err: unknown): err is ConduitError {\n\treturn err instanceof ConduitError;\n}\n\nfunction isApiError(err: unknown): err is ApiError {\n\treturn err instanceof ApiError;\n}\n\nfunction isAuthError(err: unknown): err is AuthError {\n\treturn err instanceof AuthError;\n}\n\nfunction isInitializationError(err: unknown): err is InitializationError {\n\treturn err instanceof InitializationError;\n}\n\nfunction isInsufficientCreditsError(\n\terr: unknown,\n): err is InsufficientCreditsError {\n\treturn err instanceof InsufficientCreditsError;\n}\n\nfunction isInvalidSourceError(err: unknown): err is InvalidSourceError {\n\treturn err instanceof InvalidSourceError;\n}\n\nfunction isJobCanceledError(err: unknown): err is JobCanceledError {\n\treturn err instanceof JobCanceledError;\n}\n\nfunction isJobFailedError(err: unknown): err is JobFailedError {\n\treturn err instanceof JobFailedError;\n}\n\nfunction isRateLimitError(err: unknown): err is RateLimitError {\n\treturn err instanceof RateLimitError;\n}\n\nfunction isRemoteFetchError(err: unknown): err is RemoteFetchError {\n\treturn err instanceof RemoteFetchError;\n}\n\nfunction isRemoteFetchTimeoutError(\n\terr: unknown,\n): err is RemoteFetchTimeoutError {\n\treturn err instanceof RemoteFetchTimeoutError;\n}\n\nfunction isRemoteFetchTooLargeError(\n\terr: unknown,\n): err is RemoteFetchTooLargeError {\n\treturn err instanceof RemoteFetchTooLargeError;\n}\n\nfunction isRequestAbortedError(err: unknown): err is RequestAbortedError {\n\treturn err instanceof RequestAbortedError;\n}\n\nfunction isSourceError(err: unknown): err is SourceError {\n\treturn err instanceof SourceError;\n}\n\nfunction isStreamError(err: unknown): err is StreamError {\n\treturn err instanceof StreamError;\n}\n\nfunction isTimeoutError(err: unknown): err is TimeoutError {\n\treturn err instanceof TimeoutError;\n}\n\nfunction isUnsupportedRuntimeError(\n\terr: unknown,\n): err is UnsupportedRuntimeError {\n\treturn err instanceof UnsupportedRuntimeError;\n}\n\nfunction isValidationError(err: unknown): err is ValidationError {\n\treturn err instanceof ValidationError;\n}\n\nfunction isWebhookVerificationError(\n\terr: unknown,\n): err is WebhookVerificationError {\n\treturn err instanceof WebhookVerificationError;\n}\n\nexport { Conduit } from \"./Conduit\";\nexport {\n\tApiError,\n\tAuthError,\n\tConduitError,\n\tInitializationError,\n\tInsufficientCreditsError,\n\tInvalidSourceError,\n\tJobCanceledError,\n\tJobFailedError,\n\tRateLimitError,\n\tRemoteFetchError,\n\tRemoteFetchTimeoutError,\n\tRemoteFetchTooLargeError,\n\tRequestAbortedError,\n\tSourceError,\n\tStreamError,\n\tTimeoutError,\n\tUnsupportedRuntimeError,\n\tValidationError,\n\tWebhookVerificationError,\n} from \"./errors\";\nexport type {\n\tPsychometricsCreateRequest,\n\tPsychometricsResult,\n\tPsychometricsSource,\n\tPsychometricsTarget,\n\tPsychometricsTargetStrategy,\n} from \"./psychometrics-types\";\nexport type {\n\tMatchingCompletedData,\n\tMatchingCompletedEvent,\n\tMatchingFailedData,\n\tMatchingFailedEvent,\n\tReportCompletedData,\n\tReportCompletedEvent,\n\tReportFailedData,\n\tReportFailedEvent,\n\tWebhookEvent,\n\tWebhookEventType,\n} from \"./resources/webhooks\";\nexport type {\n\tJob,\n\tJobEvent,\n\tJobStage,\n\tJobStatus,\n\tMatchingAnalysisCreateJobRequest,\n\tMatchingAnalysisEntitySource,\n\tMatchingAnalysisJobReceipt,\n\tMatchingAnalysisResponse,\n\tMatchingAnalysisRunHandle,\n\tMatchingSubjectRef,\n\tMediaSpeaker,\n\tMediaSpeakers,\n\tMediaUploadRequest,\n\tReport,\n\tReportCreateRequest,\n\tReportJobReceipt,\n\tReportLanguage,\n\tReportOutput,\n\tReportRunHandle,\n\tReportSource,\n\tTargetSelector,\n\tWebhookConfig,\n} from \"./types\";\nexport {\n\tisApiError,\n\tisAuthError,\n\tisConduitError,\n\tisInitializationError,\n\tisInsufficientCreditsError,\n\tisInvalidSourceError,\n\tisJobCanceledError,\n\tisJobFailedError,\n\tisRateLimitError,\n\tisRemoteFetchError,\n\tisRemoteFetchTimeoutError,\n\tisRemoteFetchTooLargeError,\n\tisRequestAbortedError,\n\tisSourceError,\n\tisStreamError,\n\tisTimeoutError,\n\tisUnsupportedRuntimeError,\n\tisValidationError,\n\tisWebhookVerificationError,\n};\n"],"x_google_ignoreList":[0,1],"mappings":";;;;;AAGA,MAAa,eAAe;CACxB,cAAc;CACd,SAAS;CACT,WAAW;CACX,gBAAgB;CAChB,iBAAiB;CACjB,mB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