@inflexa-ai/harness 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +58 -0
- package/dist/agents/conversation-agent.d.ts +105 -0
- package/dist/agents/conversation-agent.js +140 -0
- package/dist/agents/report-builder.d.ts +32 -0
- package/dist/agents/report-builder.js +31 -0
- package/dist/agents/sandbox/__fixtures__/deps.d.ts +23 -0
- package/dist/agents/sandbox/__fixtures__/deps.js +96 -0
- package/dist/agents/sandbox/bulk-transcriptomics-agent.d.ts +8 -0
- package/dist/agents/sandbox/bulk-transcriptomics-agent.js +22 -0
- package/dist/agents/sandbox/cheminformatics-agent.d.ts +9 -0
- package/dist/agents/sandbox/cheminformatics-agent.js +62 -0
- package/dist/agents/sandbox/chromatin-agent.d.ts +8 -0
- package/dist/agents/sandbox/chromatin-agent.js +24 -0
- package/dist/agents/sandbox/data-profiler.d.ts +10 -0
- package/dist/agents/sandbox/data-profiler.js +24 -0
- package/dist/agents/sandbox/dna-methylation-agent.d.ts +8 -0
- package/dist/agents/sandbox/dna-methylation-agent.js +24 -0
- package/dist/agents/sandbox/drug-repurposing-agent.d.ts +8 -0
- package/dist/agents/sandbox/drug-repurposing-agent.js +54 -0
- package/dist/agents/sandbox/enrichment-agent.d.ts +8 -0
- package/dist/agents/sandbox/enrichment-agent.js +24 -0
- package/dist/agents/sandbox/ephemeral-executor.d.ts +9 -0
- package/dist/agents/sandbox/ephemeral-executor.js +29 -0
- package/dist/agents/sandbox/genomic-variant-agent.d.ts +8 -0
- package/dist/agents/sandbox/genomic-variant-agent.js +27 -0
- package/dist/agents/sandbox/immune-profiling-agent.d.ts +8 -0
- package/dist/agents/sandbox/immune-profiling-agent.js +43 -0
- package/dist/agents/sandbox/index.d.ts +31 -0
- package/dist/agents/sandbox/index.js +96 -0
- package/dist/agents/sandbox/metabolomics-agent.d.ts +8 -0
- package/dist/agents/sandbox/metabolomics-agent.js +15 -0
- package/dist/agents/sandbox/microbiome-agent.d.ts +8 -0
- package/dist/agents/sandbox/microbiome-agent.js +15 -0
- package/dist/agents/sandbox/multi-omics-integration-agent.d.ts +8 -0
- package/dist/agents/sandbox/multi-omics-integration-agent.js +33 -0
- package/dist/agents/sandbox/multimodal-sc-agent.d.ts +8 -0
- package/dist/agents/sandbox/multimodal-sc-agent.js +15 -0
- package/dist/agents/sandbox/network-agent.d.ts +8 -0
- package/dist/agents/sandbox/network-agent.js +25 -0
- package/dist/agents/sandbox/pkpd-clinical-response-agent.d.ts +8 -0
- package/dist/agents/sandbox/pkpd-clinical-response-agent.js +59 -0
- package/dist/agents/sandbox/proteomics-agent.d.ts +8 -0
- package/dist/agents/sandbox/proteomics-agent.js +15 -0
- package/dist/agents/sandbox/scientific-executor.d.ts +9 -0
- package/dist/agents/sandbox/scientific-executor.js +56 -0
- package/dist/agents/sandbox/shared.d.ts +100 -0
- package/dist/agents/sandbox/shared.js +195 -0
- package/dist/agents/sandbox/single-cell-agent.d.ts +8 -0
- package/dist/agents/sandbox/single-cell-agent.js +25 -0
- package/dist/agents/sandbox/spatial-omics-agent.d.ts +8 -0
- package/dist/agents/sandbox/spatial-omics-agent.js +15 -0
- package/dist/agents/sandbox/statistical-modeling-agent.d.ts +8 -0
- package/dist/agents/sandbox/statistical-modeling-agent.js +37 -0
- package/dist/agents/sandbox/translational-safety-agent.d.ts +8 -0
- package/dist/agents/sandbox/translational-safety-agent.js +59 -0
- package/dist/agents/sandbox/types.d.ts +34 -0
- package/dist/agents/sandbox/types.js +15 -0
- package/dist/agents/sandbox/validate-skills.d.ts +18 -0
- package/dist/agents/sandbox/validate-skills.js +40 -0
- package/dist/agents/sandbox-catalog.d.ts +33 -0
- package/dist/agents/sandbox-catalog.js +44 -0
- package/dist/agents/system-prompt.d.ts +25 -0
- package/dist/agents/system-prompt.js +23 -0
- package/dist/app/chat-turn.d.ts +35 -0
- package/dist/app/chat-turn.js +64 -0
- package/dist/app/data-profile-policy.d.ts +36 -0
- package/dist/app/data-profile-policy.js +37 -0
- package/dist/app/message-assembly.d.ts +65 -0
- package/dist/app/message-assembly.js +61 -0
- package/dist/app/synthesize-run.d.ts +57 -0
- package/dist/app/synthesize-run.js +103 -0
- package/dist/auth/local-auth-context.d.ts +19 -0
- package/dist/auth/local-auth-context.js +20 -0
- package/dist/auth/local-run-authorizer.d.ts +10 -0
- package/dist/auth/local-run-authorizer.js +23 -0
- package/dist/auth/types.d.ts +166 -0
- package/dist/auth/types.js +61 -0
- package/dist/billing/cached-resolver.d.ts +23 -0
- package/dist/billing/cached-resolver.js +61 -0
- package/dist/billing/noop-resolver.d.ts +6 -0
- package/dist/billing/noop-resolver.js +7 -0
- package/dist/billing/noop-run-charge.d.ts +6 -0
- package/dist/billing/noop-run-charge.js +10 -0
- package/dist/billing/resolver.d.ts +64 -0
- package/dist/billing/resolver.js +24 -0
- package/dist/billing/run-charge.d.ts +24 -0
- package/dist/billing/run-charge.js +9 -0
- package/dist/config/resource-limits.d.ts +76 -0
- package/dist/config/resource-limits.js +116 -0
- package/dist/contracts/analogy-report.d.ts +120 -0
- package/dist/contracts/analogy-report.js +50 -0
- package/dist/contracts/chat-events.d.ts +61 -0
- package/dist/contracts/chat-events.js +13 -0
- package/dist/contracts/chat-parts.d.ts +308 -0
- package/dist/contracts/chat-parts.js +13 -0
- package/dist/contracts/content-url.d.ts +49 -0
- package/dist/contracts/content-url.js +56 -0
- package/dist/contracts/index.d.ts +12 -0
- package/dist/contracts/index.js +5 -0
- package/dist/contracts/message.d.ts +36 -0
- package/dist/contracts/message.js +9 -0
- package/dist/contracts/part-registry.d.ts +18 -0
- package/dist/contracts/part-registry.js +28 -0
- package/dist/contracts/schemas/chat-events.d.ts +90 -0
- package/dist/contracts/schemas/chat-events.js +43 -0
- package/dist/contracts/schemas/chat-parts.d.ts +683 -0
- package/dist/contracts/schemas/chat-parts.js +295 -0
- package/dist/contracts/schemas/index.d.ts +2 -0
- package/dist/contracts/schemas/index.js +2 -0
- package/dist/contracts/target-assessment-row.d.ts +85 -0
- package/dist/contracts/target-assessment-row.js +37 -0
- package/dist/contracts/target-dossier.d.ts +16720 -0
- package/dist/contracts/target-dossier.js +1339 -0
- package/dist/data/clinical-benchmarks.json +108 -0
- package/dist/data/protein-family-modality.json +101 -0
- package/dist/data/safety-panel-schema.d.ts +64 -0
- package/dist/data/safety-panel-schema.js +34 -0
- package/dist/data/safety-panel.json +436 -0
- package/dist/execution/artifact-metadata.d.ts +74 -0
- package/dist/execution/artifact-metadata.js +203 -0
- package/dist/execution/artifact-record.d.ts +19 -0
- package/dist/execution/artifact-record.js +7 -0
- package/dist/execution/artifact-registration.d.ts +36 -0
- package/dist/execution/artifact-registration.js +61 -0
- package/dist/execution/artifact-registry.d.ts +82 -0
- package/dist/execution/artifact-registry.js +17 -0
- package/dist/execution/dbos-run-launcher.d.ts +7 -0
- package/dist/execution/dbos-run-launcher.js +38 -0
- package/dist/execution/ephemeral-runner.d.ts +81 -0
- package/dist/execution/ephemeral-runner.js +161 -0
- package/dist/execution/filesystem-artifact-registry.d.ts +57 -0
- package/dist/execution/filesystem-artifact-registry.js +92 -0
- package/dist/execution/noop-artifact-registry.d.ts +11 -0
- package/dist/execution/noop-artifact-registry.js +17 -0
- package/dist/execution/post-step-pipeline.d.ts +70 -0
- package/dist/execution/post-step-pipeline.js +207 -0
- package/dist/execution/post-step.d.ts +20 -0
- package/dist/execution/post-step.js +65 -0
- package/dist/execution/reconcile-manifest.d.ts +25 -0
- package/dist/execution/reconcile-manifest.js +132 -0
- package/dist/execution/report-render.d.ts +39 -0
- package/dist/execution/report-render.js +98 -0
- package/dist/execution/report-runner.d.ts +87 -0
- package/dist/execution/report-runner.js +227 -0
- package/dist/execution/run-authorizer.d.ts +43 -0
- package/dist/execution/run-authorizer.js +17 -0
- package/dist/execution/run-launcher.d.ts +36 -0
- package/dist/execution/run-launcher.js +15 -0
- package/dist/execution/run-synthesis.d.ts +107 -0
- package/dist/execution/run-synthesis.js +329 -0
- package/dist/execution/staged-input.d.ts +41 -0
- package/dist/execution/staged-input.js +15 -0
- package/dist/execution/step-summary-metrics.d.ts +10 -0
- package/dist/execution/step-summary-metrics.js +22 -0
- package/dist/execution/step-summary.d.ts +55 -0
- package/dist/execution/step-summary.js +106 -0
- package/dist/execution/topo-sort.d.ts +33 -0
- package/dist/execution/topo-sort.js +99 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +157 -0
- package/dist/input-sanitization.d.ts +22 -0
- package/dist/input-sanitization.js +64 -0
- package/dist/lib/async-utils.d.ts +10 -0
- package/dist/lib/async-utils.js +24 -0
- package/dist/lib/chrome.d.ts +15 -0
- package/dist/lib/chrome.js +95 -0
- package/dist/lib/db-result.d.ts +93 -0
- package/dist/lib/db-result.js +197 -0
- package/dist/lib/fs-helpers.d.ts +74 -0
- package/dist/lib/fs-helpers.js +119 -0
- package/dist/lib/fs-result.d.ts +98 -0
- package/dist/lib/fs-result.js +137 -0
- package/dist/lib/host-concurrency.d.ts +16 -0
- package/dist/lib/host-concurrency.js +60 -0
- package/dist/lib/identifiers.d.ts +8 -0
- package/dist/lib/identifiers.js +10 -0
- package/dist/lib/metrics.d.ts +7 -0
- package/dist/lib/metrics.js +12 -0
- package/dist/lib/mime-detect.d.ts +17 -0
- package/dist/lib/mime-detect.js +29 -0
- package/dist/lib/otel.d.ts +30 -0
- package/dist/lib/otel.js +102 -0
- package/dist/lib/regulatory-corpus/fetch-fda-guidance.d.ts +35 -0
- package/dist/lib/regulatory-corpus/fetch-fda-guidance.js +107 -0
- package/dist/lib/regulatory-corpus/fetch-ich.d.ts +46 -0
- package/dist/lib/regulatory-corpus/fetch-ich.js +173 -0
- package/dist/lib/regulatory-corpus.d.ts +88 -0
- package/dist/lib/regulatory-corpus.js +141 -0
- package/dist/lib/result.d.ts +87 -0
- package/dist/lib/result.js +103 -0
- package/dist/lib/storage.d.ts +29 -0
- package/dist/lib/storage.js +37 -0
- package/dist/lib/streamed-download.d.ts +28 -0
- package/dist/lib/streamed-download.js +111 -0
- package/dist/lib/trace-context.d.ts +11 -0
- package/dist/lib/trace-context.js +49 -0
- package/dist/loop/__fixtures__/scripted-provider.d.ts +31 -0
- package/dist/loop/__fixtures__/scripted-provider.js +57 -0
- package/dist/loop/budget-exceeded.d.ts +22 -0
- package/dist/loop/budget-exceeded.js +41 -0
- package/dist/loop/metrics.d.ts +25 -0
- package/dist/loop/metrics.js +46 -0
- package/dist/loop/run-agent.d.ts +28 -0
- package/dist/loop/run-agent.js +204 -0
- package/dist/loop/run-step.d.ts +29 -0
- package/dist/loop/run-step.js +34 -0
- package/dist/loop/run-to-terminal.d.ts +46 -0
- package/dist/loop/run-to-terminal.js +51 -0
- package/dist/loop/types.d.ts +95 -0
- package/dist/loop/types.js +10 -0
- package/dist/memory/ai-sdk-message-storage.d.ts +20 -0
- package/dist/memory/ai-sdk-message-storage.js +114 -0
- package/dist/memory/card-builders.d.ts +114 -0
- package/dist/memory/card-builders.js +231 -0
- package/dist/memory/content-to-cortex.d.ts +42 -0
- package/dist/memory/content-to-cortex.js +85 -0
- package/dist/memory/count-tokens.d.ts +18 -0
- package/dist/memory/count-tokens.js +64 -0
- package/dist/memory/derive-thread-title.d.ts +14 -0
- package/dist/memory/derive-thread-title.js +26 -0
- package/dist/memory/message-backfill.d.ts +2 -0
- package/dist/memory/message-backfill.js +38 -0
- package/dist/memory/reconstruct-cards.d.ts +23 -0
- package/dist/memory/reconstruct-cards.js +64 -0
- package/dist/memory/thread-history.d.ts +80 -0
- package/dist/memory/thread-history.js +187 -0
- package/dist/memory/thread-store.d.ts +66 -0
- package/dist/memory/thread-store.js +88 -0
- package/dist/memory/working-memory.d.ts +135 -0
- package/dist/memory/working-memory.js +185 -0
- package/dist/prompts/SOUL.d.ts +17 -0
- package/dist/prompts/SOUL.js +173 -0
- package/dist/prompts/analogical-reasoner.d.ts +1 -0
- package/dist/prompts/analogical-reasoner.js +170 -0
- package/dist/prompts/conversation.d.ts +1 -0
- package/dist/prompts/conversation.js +697 -0
- package/dist/prompts/execute-analysis/step-summary.d.ts +1 -0
- package/dist/prompts/execute-analysis/step-summary.js +38 -0
- package/dist/prompts/literature-reviewer.d.ts +1 -0
- package/dist/prompts/literature-reviewer.js +107 -0
- package/dist/prompts/planner.d.ts +2 -0
- package/dist/prompts/planner.js +259 -0
- package/dist/prompts/report-builder.d.ts +1 -0
- package/dist/prompts/report-builder.js +127 -0
- package/dist/prompts/sandbox/bulk-transcriptomics-agent.d.ts +1 -0
- package/dist/prompts/sandbox/bulk-transcriptomics-agent.js +78 -0
- package/dist/prompts/sandbox/cheminformatics-agent.d.ts +1 -0
- package/dist/prompts/sandbox/cheminformatics-agent.js +224 -0
- package/dist/prompts/sandbox/chromatin-agent.d.ts +1 -0
- package/dist/prompts/sandbox/chromatin-agent.js +100 -0
- package/dist/prompts/sandbox/data-profiler.d.ts +1 -0
- package/dist/prompts/sandbox/data-profiler.js +291 -0
- package/dist/prompts/sandbox/dna-methylation-agent.d.ts +1 -0
- package/dist/prompts/sandbox/dna-methylation-agent.js +96 -0
- package/dist/prompts/sandbox/drug-repurposing-agent.d.ts +1 -0
- package/dist/prompts/sandbox/drug-repurposing-agent.js +144 -0
- package/dist/prompts/sandbox/enrichment-agent.d.ts +1 -0
- package/dist/prompts/sandbox/enrichment-agent.js +89 -0
- package/dist/prompts/sandbox/ephemeral-executor.d.ts +1 -0
- package/dist/prompts/sandbox/ephemeral-executor.js +66 -0
- package/dist/prompts/sandbox/genomic-variant-agent.d.ts +1 -0
- package/dist/prompts/sandbox/genomic-variant-agent.js +83 -0
- package/dist/prompts/sandbox/immune-profiling-agent.d.ts +1 -0
- package/dist/prompts/sandbox/immune-profiling-agent.js +101 -0
- package/dist/prompts/sandbox/metabolomics-agent.d.ts +1 -0
- package/dist/prompts/sandbox/metabolomics-agent.js +89 -0
- package/dist/prompts/sandbox/microbiome-agent.d.ts +1 -0
- package/dist/prompts/sandbox/microbiome-agent.js +109 -0
- package/dist/prompts/sandbox/multi-omics-integration-agent.d.ts +1 -0
- package/dist/prompts/sandbox/multi-omics-integration-agent.js +122 -0
- package/dist/prompts/sandbox/multimodal-sc-agent.d.ts +1 -0
- package/dist/prompts/sandbox/multimodal-sc-agent.js +90 -0
- package/dist/prompts/sandbox/network-agent.d.ts +1 -0
- package/dist/prompts/sandbox/network-agent.js +95 -0
- package/dist/prompts/sandbox/pkpd-clinical-response-agent.d.ts +1 -0
- package/dist/prompts/sandbox/pkpd-clinical-response-agent.js +71 -0
- package/dist/prompts/sandbox/proteomics-agent.d.ts +1 -0
- package/dist/prompts/sandbox/proteomics-agent.js +93 -0
- package/dist/prompts/sandbox/scientific-executor.d.ts +1 -0
- package/dist/prompts/sandbox/scientific-executor.js +68 -0
- package/dist/prompts/sandbox/single-cell-agent.d.ts +1 -0
- package/dist/prompts/sandbox/single-cell-agent.js +129 -0
- package/dist/prompts/sandbox/spatial-omics-agent.d.ts +1 -0
- package/dist/prompts/sandbox/spatial-omics-agent.js +94 -0
- package/dist/prompts/sandbox/statistical-modeling-agent.d.ts +1 -0
- package/dist/prompts/sandbox/statistical-modeling-agent.js +112 -0
- package/dist/prompts/sandbox/translational-safety-agent.d.ts +1 -0
- package/dist/prompts/sandbox/translational-safety-agent.js +105 -0
- package/dist/prompts/sandbox-standards.d.ts +18 -0
- package/dist/prompts/sandbox-standards.js +358 -0
- package/dist/prompts/synthesis-agent.d.ts +1 -0
- package/dist/prompts/synthesis-agent.js +289 -0
- package/dist/prompts/target-assessment/briefs/executive-recommendation.d.ts +1 -0
- package/dist/prompts/target-assessment/briefs/executive-recommendation.js +85 -0
- package/dist/prompts/target-assessment/briefs/index.d.ts +4 -0
- package/dist/prompts/target-assessment/briefs/index.js +4 -0
- package/dist/prompts/target-assessment/briefs/liability-bullets.d.ts +1 -0
- package/dist/prompts/target-assessment/briefs/liability-bullets.js +114 -0
- package/dist/prompts/target-assessment/briefs/target-organ-liabilities.d.ts +1 -0
- package/dist/prompts/target-assessment/briefs/target-organ-liabilities.js +29 -0
- package/dist/prompts/target-assessment/briefs/translational-commentary.d.ts +1 -0
- package/dist/prompts/target-assessment/briefs/translational-commentary.js +23 -0
- package/dist/prompts/target-assessment/drugs-in-class.d.ts +1 -0
- package/dist/prompts/target-assessment/drugs-in-class.js +29 -0
- package/dist/prompts/target-assessment/modulator-triage.d.ts +1 -0
- package/dist/prompts/target-assessment/modulator-triage.js +31 -0
- package/dist/prompts/target-assessment/off-target-annotator.d.ts +1 -0
- package/dist/prompts/target-assessment/off-target-annotator.js +28 -0
- package/dist/prompts/target-assessment/tox-voice/core.d.ts +1 -0
- package/dist/prompts/target-assessment/tox-voice/core.js +74 -0
- package/dist/prompts/target-assessment/tox-voice/critique.d.ts +7 -0
- package/dist/prompts/target-assessment/tox-voice/critique.js +109 -0
- package/dist/prompts/target-assessment/tox-voice/exemplars.d.ts +8 -0
- package/dist/prompts/target-assessment/tox-voice/exemplars.js +24 -0
- package/dist/prompts/target-assessment/tox-voice/index.d.ts +4 -0
- package/dist/prompts/target-assessment/tox-voice/index.js +4 -0
- package/dist/prompts/target-assessment/tox-voice/vocabulary.d.ts +15 -0
- package/dist/prompts/target-assessment/tox-voice/vocabulary.js +72 -0
- package/dist/provenance/collector.d.ts +148 -0
- package/dist/provenance/collector.js +296 -0
- package/dist/provenance/exec-frame.d.ts +36 -0
- package/dist/provenance/exec-frame.js +49 -0
- package/dist/provenance/types.d.ts +95 -0
- package/dist/provenance/types.js +64 -0
- package/dist/providers/__fixtures__/session.d.ts +16 -0
- package/dist/providers/__fixtures__/session.js +20 -0
- package/dist/providers/ai-sdk.d.ts +47 -0
- package/dist/providers/ai-sdk.js +142 -0
- package/dist/providers/anthropic.d.ts +22 -0
- package/dist/providers/anthropic.js +26 -0
- package/dist/providers/embedding.d.ts +32 -0
- package/dist/providers/embedding.js +42 -0
- package/dist/providers/errors.d.ts +80 -0
- package/dist/providers/errors.js +137 -0
- package/dist/providers/llm-capabilities.d.ts +33 -0
- package/dist/providers/llm-capabilities.js +58 -0
- package/dist/providers/streaming-chat.d.ts +23 -0
- package/dist/providers/streaming-chat.js +61 -0
- package/dist/providers/types.d.ts +59 -0
- package/dist/providers/types.js +8 -0
- package/dist/runtime/assemble.d.ts +68 -0
- package/dist/runtime/assemble.js +46 -0
- package/dist/runtime/boot.d.ts +73 -0
- package/dist/runtime/boot.js +65 -0
- package/dist/runtime/connection-budget.d.ts +48 -0
- package/dist/runtime/connection-budget.js +57 -0
- package/dist/runtime/dbos.d.ts +94 -0
- package/dist/runtime/dbos.js +160 -0
- package/dist/runtime/lifecycle.d.ts +12 -0
- package/dist/runtime/lifecycle.js +19 -0
- package/dist/runtime/pools.d.ts +25 -0
- package/dist/runtime/pools.js +30 -0
- package/dist/runtime/shutdown.d.ts +33 -0
- package/dist/runtime/shutdown.js +39 -0
- package/dist/sandbox/await-exec.d.ts +143 -0
- package/dist/sandbox/await-exec.js +406 -0
- package/dist/sandbox/client.d.ts +82 -0
- package/dist/sandbox/client.js +23 -0
- package/dist/sandbox/create-sandbox.d.ts +105 -0
- package/dist/sandbox/create-sandbox.js +132 -0
- package/dist/sandbox/deliver-exec-event.d.ts +25 -0
- package/dist/sandbox/deliver-exec-event.js +29 -0
- package/dist/sandbox/docker-client.d.ts +75 -0
- package/dist/sandbox/docker-client.js +315 -0
- package/dist/sandbox/estimate-data-profile-resources.d.ts +5 -0
- package/dist/sandbox/estimate-data-profile-resources.js +73 -0
- package/dist/sandbox/exec-id.d.ts +12 -0
- package/dist/sandbox/exec-id.js +20 -0
- package/dist/sandbox/execution-id.d.ts +30 -0
- package/dist/sandbox/execution-id.js +47 -0
- package/dist/sandbox/hmac.d.ts +54 -0
- package/dist/sandbox/hmac.js +67 -0
- package/dist/sandbox/identity.d.ts +15 -0
- package/dist/sandbox/identity.js +22 -0
- package/dist/sandbox/ignored-dirs.d.ts +7 -0
- package/dist/sandbox/ignored-dirs.js +7 -0
- package/dist/sandbox/k8s-client.d.ts +71 -0
- package/dist/sandbox/k8s-client.js +488 -0
- package/dist/sandbox/liveness.d.ts +60 -0
- package/dist/sandbox/liveness.js +82 -0
- package/dist/sandbox/mount-plan.d.ts +77 -0
- package/dist/sandbox/mount-plan.js +84 -0
- package/dist/sandbox/notification-sweep.d.ts +42 -0
- package/dist/sandbox/notification-sweep.js +74 -0
- package/dist/sandbox/reaper.d.ts +70 -0
- package/dist/sandbox/reaper.js +124 -0
- package/dist/sandbox/sandbox-error.d.ts +105 -0
- package/dist/sandbox/sandbox-error.js +92 -0
- package/dist/sandbox/sandbox-step-translate.d.ts +35 -0
- package/dist/sandbox/sandbox-step-translate.js +76 -0
- package/dist/sandbox/submit-exec.d.ts +33 -0
- package/dist/sandbox/submit-exec.js +68 -0
- package/dist/sandbox/types.d.ts +277 -0
- package/dist/sandbox/types.js +147 -0
- package/dist/sandbox/watchdog.d.ts +71 -0
- package/dist/sandbox/watchdog.js +150 -0
- package/dist/schemas/artifact-manifest.d.ts +34 -0
- package/dist/schemas/artifact-manifest.js +36 -0
- package/dist/schemas/data-profile-schemas.d.ts +92 -0
- package/dist/schemas/data-profile-schemas.js +89 -0
- package/dist/schemas/file-metadata.d.ts +51 -0
- package/dist/schemas/file-metadata.js +39 -0
- package/dist/schemas/plan-schemas.d.ts +110 -0
- package/dist/schemas/plan-schemas.js +50 -0
- package/dist/schemas/render-step-prompt.d.ts +32 -0
- package/dist/schemas/render-step-prompt.js +76 -0
- package/dist/schemas/run-synthesis.d.ts +148 -0
- package/dist/schemas/run-synthesis.js +87 -0
- package/dist/schemas/step-summary.d.ts +18 -0
- package/dist/schemas/step-summary.js +20 -0
- package/dist/schemas/validate-plan.d.ts +39 -0
- package/dist/schemas/validate-plan.js +120 -0
- package/dist/schemas/workflow-state.d.ts +314 -0
- package/dist/schemas/workflow-state.js +139 -0
- package/dist/state/active-sandboxes.d.ts +58 -0
- package/dist/state/active-sandboxes.js +100 -0
- package/dist/state/analyses-metrics.d.ts +21 -0
- package/dist/state/analyses-metrics.js +59 -0
- package/dist/state/analyses.d.ts +58 -0
- package/dist/state/analyses.js +132 -0
- package/dist/state/artifacts.d.ts +53 -0
- package/dist/state/artifacts.js +175 -0
- package/dist/state/data-profile.d.ts +176 -0
- package/dist/state/data-profile.js +284 -0
- package/dist/state/db.d.ts +10 -0
- package/dist/state/db.js +9 -0
- package/dist/state/index.d.ts +29 -0
- package/dist/state/index.js +20 -0
- package/dist/state/init.d.ts +14 -0
- package/dist/state/init.js +406 -0
- package/dist/state/plans.d.ts +56 -0
- package/dist/state/plans.js +117 -0
- package/dist/state/runs.d.ts +69 -0
- package/dist/state/runs.js +206 -0
- package/dist/state/schema.d.ts +150 -0
- package/dist/state/schema.js +100 -0
- package/dist/state/step-executions.d.ts +77 -0
- package/dist/state/step-executions.js +175 -0
- package/dist/state/target-assessments.d.ts +68 -0
- package/dist/state/target-assessments.js +222 -0
- package/dist/state/vector-store.d.ts +53 -0
- package/dist/state/vector-store.js +89 -0
- package/dist/tasks/data-profile.d.ts +171 -0
- package/dist/tasks/data-profile.js +461 -0
- package/dist/tasks/refresh-regulatory-corpus.d.ts +59 -0
- package/dist/tasks/refresh-regulatory-corpus.js +146 -0
- package/dist/tasks/regulatory-corpus-boot-refresh.d.ts +55 -0
- package/dist/tasks/regulatory-corpus-boot-refresh.js +149 -0
- package/dist/tools/__fixtures__/tool-context.d.ts +13 -0
- package/dist/tools/__fixtures__/tool-context.js +18 -0
- package/dist/tools/bio/check-safety-panel.d.ts +35 -0
- package/dist/tools/bio/check-safety-panel.js +76 -0
- package/dist/tools/bio/find-approval-precedent.d.ts +32 -0
- package/dist/tools/bio/find-approval-precedent.js +72 -0
- package/dist/tools/bio/get-article-details.d.ts +11 -0
- package/dist/tools/bio/get-article-details.js +20 -0
- package/dist/tools/bio/get-article-full-text.d.ts +19 -0
- package/dist/tools/bio/get-article-full-text.js +32 -0
- package/dist/tools/bio/get-bioactivity.d.ts +11 -0
- package/dist/tools/bio/get-bioactivity.js +23 -0
- package/dist/tools/bio/get-drug-info.d.ts +9 -0
- package/dist/tools/bio/get-drug-info.js +22 -0
- package/dist/tools/bio/get-impc-ko-profile.d.ts +9 -0
- package/dist/tools/bio/get-impc-ko-profile.js +20 -0
- package/dist/tools/bio/get-mechanism.d.ts +8 -0
- package/dist/tools/bio/get-mechanism.js +18 -0
- package/dist/tools/bio/get-pubchem-assays.d.ts +22 -0
- package/dist/tools/bio/get-pubchem-assays.js +107 -0
- package/dist/tools/bio/get-pubchem-cross-refs.d.ts +15 -0
- package/dist/tools/bio/get-pubchem-cross-refs.js +68 -0
- package/dist/tools/bio/get-target-safety.d.ts +18 -0
- package/dist/tools/bio/get-target-safety.js +26 -0
- package/dist/tools/bio/index.d.ts +41 -0
- package/dist/tools/bio/index.js +48 -0
- package/dist/tools/bio/keys.d.ts +31 -0
- package/dist/tools/bio/keys.js +30 -0
- package/dist/tools/bio/lookup-go-term.d.ts +31 -0
- package/dist/tools/bio/lookup-go-term.js +116 -0
- package/dist/tools/bio/search-bgee-expression.d.ts +10 -0
- package/dist/tools/bio/search-bgee-expression.js +24 -0
- package/dist/tools/bio/search-clinical-trials.d.ts +12 -0
- package/dist/tools/bio/search-clinical-trials.js +21 -0
- package/dist/tools/bio/search-clinvar.d.ts +13 -0
- package/dist/tools/bio/search-clinvar.js +28 -0
- package/dist/tools/bio/search-compounds.d.ts +22 -0
- package/dist/tools/bio/search-compounds.js +160 -0
- package/dist/tools/bio/search-ctx-chemical.d.ts +50 -0
- package/dist/tools/bio/search-ctx-chemical.js +130 -0
- package/dist/tools/bio/search-ctx-exposure.d.ts +55 -0
- package/dist/tools/bio/search-ctx-exposure.js +176 -0
- package/dist/tools/bio/search-ctx-hazard.d.ts +111 -0
- package/dist/tools/bio/search-ctx-hazard.js +178 -0
- package/dist/tools/bio/search-dgidb.d.ts +43 -0
- package/dist/tools/bio/search-dgidb.js +199 -0
- package/dist/tools/bio/search-disgenet.d.ts +30 -0
- package/dist/tools/bio/search-disgenet.js +84 -0
- package/dist/tools/bio/search-drugbank.d.ts +38 -0
- package/dist/tools/bio/search-drugbank.js +109 -0
- package/dist/tools/bio/search-faers.d.ts +11 -0
- package/dist/tools/bio/search-faers.js +23 -0
- package/dist/tools/bio/search-gene.d.ts +11 -0
- package/dist/tools/bio/search-gene.js +19 -0
- package/dist/tools/bio/search-geo-datasets.d.ts +20 -0
- package/dist/tools/bio/search-geo-datasets.js +86 -0
- package/dist/tools/bio/search-gwas-catalog.d.ts +33 -0
- package/dist/tools/bio/search-gwas-catalog.js +172 -0
- package/dist/tools/bio/search-interactions.d.ts +17 -0
- package/dist/tools/bio/search-interactions.js +31 -0
- package/dist/tools/bio/search-opentargets.d.ts +11 -0
- package/dist/tools/bio/search-opentargets.js +25 -0
- package/dist/tools/bio/search-pathway.d.ts +12 -0
- package/dist/tools/bio/search-pathway.js +32 -0
- package/dist/tools/bio/search-pharmgkb.d.ts +17 -0
- package/dist/tools/bio/search-pharmgkb.js +46 -0
- package/dist/tools/bio/search-pubchem-compound.d.ts +26 -0
- package/dist/tools/bio/search-pubchem-compound.js +110 -0
- package/dist/tools/bio/search-pubmed.d.ts +17 -0
- package/dist/tools/bio/search-pubmed.js +31 -0
- package/dist/tools/bio/search-targets.d.ts +9 -0
- package/dist/tools/bio/search-targets.js +20 -0
- package/dist/tools/bio/search-toxcast.d.ts +36 -0
- package/dist/tools/bio/search-toxcast.js +141 -0
- package/dist/tools/define-tool.d.ts +80 -0
- package/dist/tools/define-tool.js +48 -0
- package/dist/tools/display/index.d.ts +4 -0
- package/dist/tools/display/index.js +4 -0
- package/dist/tools/display/show-user.d.ts +33 -0
- package/dist/tools/display/show-user.js +67 -0
- package/dist/tools/execute-plan.d.ts +64 -0
- package/dist/tools/execute-plan.js +208 -0
- package/dist/tools/iterate-report.d.ts +172 -0
- package/dist/tools/iterate-report.js +521 -0
- package/dist/tools/lib/api-utils.d.ts +80 -0
- package/dist/tools/lib/api-utils.js +128 -0
- package/dist/tools/lib/bgee-client.d.ts +36 -0
- package/dist/tools/lib/bgee-client.js +150 -0
- package/dist/tools/lib/cbioportal-client.d.ts +34 -0
- package/dist/tools/lib/cbioportal-client.js +159 -0
- package/dist/tools/lib/chembl-client.d.ts +123 -0
- package/dist/tools/lib/chembl-client.js +458 -0
- package/dist/tools/lib/chembl-config.d.ts +5 -0
- package/dist/tools/lib/chembl-config.js +3 -0
- package/dist/tools/lib/clinical-benchmarks-client.d.ts +33 -0
- package/dist/tools/lib/clinical-benchmarks-client.js +54 -0
- package/dist/tools/lib/clinical-trials-client.d.ts +216 -0
- package/dist/tools/lib/clinical-trials-client.js +339 -0
- package/dist/tools/lib/clinicaltrials-config.d.ts +4 -0
- package/dist/tools/lib/clinicaltrials-config.js +2 -0
- package/dist/tools/lib/clinvar-client.d.ts +25 -0
- package/dist/tools/lib/clinvar-client.js +126 -0
- package/dist/tools/lib/disgenet-config.d.ts +2 -0
- package/dist/tools/lib/disgenet-config.js +11 -0
- package/dist/tools/lib/drugbank-config.d.ts +2 -0
- package/dist/tools/lib/drugbank-config.js +12 -0
- package/dist/tools/lib/ema-client.d.ts +45 -0
- package/dist/tools/lib/ema-client.js +127 -0
- package/dist/tools/lib/ema-config.d.ts +7 -0
- package/dist/tools/lib/ema-config.js +7 -0
- package/dist/tools/lib/ensembl-client.d.ts +27 -0
- package/dist/tools/lib/ensembl-client.js +82 -0
- package/dist/tools/lib/gwas-catalog-config.d.ts +4 -0
- package/dist/tools/lib/gwas-catalog-config.js +2 -0
- package/dist/tools/lib/identifier-resolver.d.ts +85 -0
- package/dist/tools/lib/identifier-resolver.js +333 -0
- package/dist/tools/lib/impc-client.d.ts +44 -0
- package/dist/tools/lib/impc-client.js +239 -0
- package/dist/tools/lib/iuphar-client.d.ts +75 -0
- package/dist/tools/lib/iuphar-client.js +230 -0
- package/dist/tools/lib/iuphar-config.d.ts +5 -0
- package/dist/tools/lib/iuphar-config.js +3 -0
- package/dist/tools/lib/ncbi-utils.d.ts +58 -0
- package/dist/tools/lib/ncbi-utils.js +286 -0
- package/dist/tools/lib/openfda-client.d.ts +53 -0
- package/dist/tools/lib/openfda-client.js +192 -0
- package/dist/tools/lib/openfda-config.d.ts +2 -0
- package/dist/tools/lib/openfda-config.js +2 -0
- package/dist/tools/lib/opentargets-client.d.ts +64 -0
- package/dist/tools/lib/opentargets-client.js +290 -0
- package/dist/tools/lib/opentargets-config.d.ts +5 -0
- package/dist/tools/lib/opentargets-config.js +5 -0
- package/dist/tools/lib/path-validation.d.ts +14 -0
- package/dist/tools/lib/path-validation.js +26 -0
- package/dist/tools/lib/pathway-client.d.ts +27 -0
- package/dist/tools/lib/pathway-client.js +149 -0
- package/dist/tools/lib/pharmgkb-config.d.ts +4 -0
- package/dist/tools/lib/pharmgkb-config.js +2 -0
- package/dist/tools/lib/preview-lock.d.ts +20 -0
- package/dist/tools/lib/preview-lock.js +35 -0
- package/dist/tools/lib/protein-family-modality.d.ts +16 -0
- package/dist/tools/lib/protein-family-modality.js +42 -0
- package/dist/tools/lib/protein-family-normalize.d.ts +12 -0
- package/dist/tools/lib/protein-family-normalize.js +46 -0
- package/dist/tools/lib/pubchem-client.d.ts +40 -0
- package/dist/tools/lib/pubchem-client.js +128 -0
- package/dist/tools/lib/pubchem-config.d.ts +5 -0
- package/dist/tools/lib/pubchem-config.js +3 -0
- package/dist/tools/lib/pubmed-client.d.ts +28 -0
- package/dist/tools/lib/pubmed-client.js +91 -0
- package/dist/tools/lib/report-preflight.d.ts +39 -0
- package/dist/tools/lib/report-preflight.js +283 -0
- package/dist/tools/lib/string-client.d.ts +33 -0
- package/dist/tools/lib/string-client.js +93 -0
- package/dist/tools/lib/toxcast-config.d.ts +2 -0
- package/dist/tools/lib/toxcast-config.js +11 -0
- package/dist/tools/lib/uniprot-client.d.ts +28 -0
- package/dist/tools/lib/uniprot-client.js +103 -0
- package/dist/tools/lib/uniprot-config.d.ts +5 -0
- package/dist/tools/lib/uniprot-config.js +3 -0
- package/dist/tools/memory/index.d.ts +4 -0
- package/dist/tools/memory/index.js +4 -0
- package/dist/tools/memory/update-working-memory.d.ts +25 -0
- package/dist/tools/memory/update-working-memory.js +112 -0
- package/dist/tools/registry.d.ts +15 -0
- package/dist/tools/registry.js +26 -0
- package/dist/tools/report/build-report.d.ts +13 -0
- package/dist/tools/report/build-report.js +26 -0
- package/dist/tools/report/index.d.ts +14 -0
- package/dist/tools/report/index.js +14 -0
- package/dist/tools/report/mint-preview-url.d.ts +26 -0
- package/dist/tools/report/mint-preview-url.js +44 -0
- package/dist/tools/report/preview-publisher.d.ts +37 -0
- package/dist/tools/report/preview-publisher.js +25 -0
- package/dist/tools/report/preview-snapshot.d.ts +26 -0
- package/dist/tools/report/preview-snapshot.js +121 -0
- package/dist/tools/report/submit-report.d.ts +25 -0
- package/dist/tools/report/submit-report.js +126 -0
- package/dist/tools/report/version-fs.d.ts +15 -0
- package/dist/tools/report/version-fs.js +154 -0
- package/dist/tools/research/context7-docs.d.ts +31 -0
- package/dist/tools/research/context7-docs.js +61 -0
- package/dist/tools/research/generate-analogy-report.d.ts +60 -0
- package/dist/tools/research/generate-analogy-report.js +288 -0
- package/dist/tools/research/generate-plan.d.ts +39 -0
- package/dist/tools/research/generate-plan.js +393 -0
- package/dist/tools/research/index.d.ts +15 -0
- package/dist/tools/research/index.js +15 -0
- package/dist/tools/research/inspect-run.d.ts +54 -0
- package/dist/tools/research/inspect-run.js +85 -0
- package/dist/tools/research/literature-reviewer.d.ts +29 -0
- package/dist/tools/research/literature-reviewer.js +84 -0
- package/dist/tools/research/search-arxiv.d.ts +32 -0
- package/dist/tools/research/search-arxiv.js +123 -0
- package/dist/tools/research/search-github-repos.d.ts +32 -0
- package/dist/tools/research/search-github-repos.js +86 -0
- package/dist/tools/research/search-semantic-scholar.d.ts +33 -0
- package/dist/tools/research/search-semantic-scholar.js +93 -0
- package/dist/tools/run-ephemeral.d.ts +33 -0
- package/dist/tools/run-ephemeral.js +65 -0
- package/dist/tools/sandbox/index.d.ts +7 -0
- package/dist/tools/sandbox/index.js +7 -0
- package/dist/tools/sandbox/list-available-packages.d.ts +7 -0
- package/dist/tools/sandbox/list-available-packages.js +27 -0
- package/dist/tools/sandbox/list-available-refs.d.ts +7 -0
- package/dist/tools/sandbox/list-available-refs.js +147 -0
- package/dist/tools/sandbox/report-blocker.d.ts +23 -0
- package/dist/tools/sandbox/report-blocker.js +39 -0
- package/dist/tools/sandbox/skills.d.ts +72 -0
- package/dist/tools/sandbox/skills.js +144 -0
- package/dist/tools/workspace/edit-file.d.ts +46 -0
- package/dist/tools/workspace/edit-file.js +100 -0
- package/dist/tools/workspace/execute-command.d.ts +80 -0
- package/dist/tools/workspace/execute-command.js +95 -0
- package/dist/tools/workspace/file-stat.d.ts +24 -0
- package/dist/tools/workspace/file-stat.js +37 -0
- package/dist/tools/workspace/grep.d.ts +57 -0
- package/dist/tools/workspace/grep.js +154 -0
- package/dist/tools/workspace/index.d.ts +26 -0
- package/dist/tools/workspace/index.js +27 -0
- package/dist/tools/workspace/list-files.d.ts +24 -0
- package/dist/tools/workspace/list-files.js +38 -0
- package/dist/tools/workspace/mutator.d.ts +83 -0
- package/dist/tools/workspace/mutator.js +81 -0
- package/dist/tools/workspace/read-file.d.ts +39 -0
- package/dist/tools/workspace/read-file.js +93 -0
- package/dist/tools/workspace/result-bounds.d.ts +42 -0
- package/dist/tools/workspace/result-bounds.js +50 -0
- package/dist/tools/workspace/run-exec.d.ts +32 -0
- package/dist/tools/workspace/run-exec.js +34 -0
- package/dist/tools/workspace/show-file.d.ts +37 -0
- package/dist/tools/workspace/show-file.js +54 -0
- package/dist/tools/workspace/show-plan.d.ts +23 -0
- package/dist/tools/workspace/show-plan.js +44 -0
- package/dist/tools/workspace/workspace-search.d.ts +25 -0
- package/dist/tools/workspace/workspace-search.js +78 -0
- package/dist/tools/workspace/write-file.d.ts +16 -0
- package/dist/tools/workspace/write-file.js +33 -0
- package/dist/workflows/execute-analysis-scheduler.d.ts +94 -0
- package/dist/workflows/execute-analysis-scheduler.js +186 -0
- package/dist/workflows/execute-analysis.d.ts +271 -0
- package/dist/workflows/execute-analysis.js +746 -0
- package/dist/workflows/execute-target-assessment.d.ts +101 -0
- package/dist/workflows/execute-target-assessment.js +528 -0
- package/dist/workflows/metrics.d.ts +37 -0
- package/dist/workflows/metrics.js +55 -0
- package/dist/workflows/plan/level.d.ts +12 -0
- package/dist/workflows/plan/level.js +12 -0
- package/dist/workflows/register-workflows.d.ts +51 -0
- package/dist/workflows/register-workflows.js +48 -0
- package/dist/workflows/resume-execute-analysis.d.ts +70 -0
- package/dist/workflows/resume-execute-analysis.js +80 -0
- package/dist/workflows/sandbox-step.d.ts +243 -0
- package/dist/workflows/sandbox-step.js +573 -0
- package/dist/workflows/target-assessment/assemblers/index.d.ts +5 -0
- package/dist/workflows/target-assessment/assemblers/index.js +4 -0
- package/dist/workflows/target-assessment/assemblers/literature.d.ts +299 -0
- package/dist/workflows/target-assessment/assemblers/literature.js +987 -0
- package/dist/workflows/target-assessment/assemblers/orchestrator.d.ts +109 -0
- package/dist/workflows/target-assessment/assemblers/orchestrator.js +835 -0
- package/dist/workflows/target-assessment/assemblers/safety.d.ts +352 -0
- package/dist/workflows/target-assessment/assemblers/safety.js +985 -0
- package/dist/workflows/target-assessment/assemblers/trials.d.ts +30 -0
- package/dist/workflows/target-assessment/assemblers/trials.js +75 -0
- package/dist/workflows/target-assessment/collectors/index.d.ts +105 -0
- package/dist/workflows/target-assessment/collectors/index.js +468 -0
- package/dist/workflows/target-assessment/correction-loop.d.ts +45 -0
- package/dist/workflows/target-assessment/correction-loop.js +62 -0
- package/dist/workflows/target-assessment/coverage.d.ts +81 -0
- package/dist/workflows/target-assessment/coverage.js +82 -0
- package/dist/workflows/target-assessment/decisions/index.d.ts +86 -0
- package/dist/workflows/target-assessment/decisions/index.js +127 -0
- package/dist/workflows/target-assessment/fanout/index.d.ts +31 -0
- package/dist/workflows/target-assessment/fanout/index.js +155 -0
- package/dist/workflows/target-assessment/lib/approval-precedents.d.ts +52 -0
- package/dist/workflows/target-assessment/lib/approval-precedents.js +119 -0
- package/dist/workflows/target-assessment/lib/citation-validator.d.ts +46 -0
- package/dist/workflows/target-assessment/lib/citation-validator.js +316 -0
- package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.d.ts +62 -0
- package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.js +172 -0
- package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.d.ts +45 -0
- package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.js +156 -0
- package/dist/workflows/target-assessment/lib/compute-derived.d.ts +19 -0
- package/dist/workflows/target-assessment/lib/compute-derived.js +252 -0
- package/dist/workflows/target-assessment/lib/compute-selectivity.d.ts +15 -0
- package/dist/workflows/target-assessment/lib/compute-selectivity.js +18 -0
- package/dist/workflows/target-assessment/lib/dedup-modulators.d.ts +37 -0
- package/dist/workflows/target-assessment/lib/dedup-modulators.js +157 -0
- package/dist/workflows/target-assessment/lib/evidence-conflict-detector.d.ts +17 -0
- package/dist/workflows/target-assessment/lib/evidence-conflict-detector.js +100 -0
- package/dist/workflows/target-assessment/lib/expression-constants.d.ts +21 -0
- package/dist/workflows/target-assessment/lib/expression-constants.js +21 -0
- package/dist/workflows/target-assessment/lib/family-complex-supplement.d.ts +21 -0
- package/dist/workflows/target-assessment/lib/family-complex-supplement.js +37 -0
- package/dist/workflows/target-assessment/lib/heterodimer-filter.d.ts +39 -0
- package/dist/workflows/target-assessment/lib/heterodimer-filter.js +54 -0
- package/dist/workflows/target-assessment/lib/intended-polypharm-filter.d.ts +4 -0
- package/dist/workflows/target-assessment/lib/intended-polypharm-filter.js +24 -0
- package/dist/workflows/target-assessment/lib/llm-step.d.ts +77 -0
- package/dist/workflows/target-assessment/lib/llm-step.js +99 -0
- package/dist/workflows/target-assessment/lib/meddra-organ-map.d.ts +30 -0
- package/dist/workflows/target-assessment/lib/meddra-organ-map.js +126 -0
- package/dist/workflows/target-assessment/lib/recommendation-quality-gates.d.ts +17 -0
- package/dist/workflows/target-assessment/lib/recommendation-quality-gates.js +99 -0
- package/dist/workflows/target-assessment/lib/recommendation-sanitizer.d.ts +2 -0
- package/dist/workflows/target-assessment/lib/recommendation-sanitizer.js +51 -0
- package/dist/workflows/target-assessment/lib/regulatory-actions.d.ts +26 -0
- package/dist/workflows/target-assessment/lib/regulatory-actions.js +147 -0
- package/dist/workflows/target-assessment/lib/structured-llm.d.ts +58 -0
- package/dist/workflows/target-assessment/lib/structured-llm.js +101 -0
- package/dist/workflows/target-assessment/lib/target-identity-filter.d.ts +60 -0
- package/dist/workflows/target-assessment/lib/target-identity-filter.js +86 -0
- package/dist/workflows/target-assessment/lib/therapeutic-programs.d.ts +20 -0
- package/dist/workflows/target-assessment/lib/therapeutic-programs.js +68 -0
- package/dist/workflows/target-assessment/metrics.d.ts +21 -0
- package/dist/workflows/target-assessment/metrics.js +42 -0
- package/dist/workflows/target-assessment/phase4-assemble.d.ts +1841 -0
- package/dist/workflows/target-assessment/phase4-assemble.js +39 -0
- package/dist/workflows/target-assessment/phase5-persist.d.ts +57 -0
- package/dist/workflows/target-assessment/phase5-persist.js +461 -0
- package/dist/workflows/target-assessment/progress.d.ts +38 -0
- package/dist/workflows/target-assessment/progress.js +76 -0
- package/dist/workflows/target-assessment/schemas.d.ts +931 -0
- package/dist/workflows/target-assessment/schemas.js +293 -0
- package/dist/workflows/target-assessment/steps/collectors/pathways.d.ts +15 -0
- package/dist/workflows/target-assessment/steps/collectors/pathways.js +58 -0
- package/dist/workflows/target-assessment/steps/fanout/aes-for-one-class-drug-step.d.ts +34 -0
- package/dist/workflows/target-assessment/steps/fanout/aes-for-one-class-drug-step.js +31 -0
- package/dist/workflows/target-assessment/steps/fanout/aes-for-one-trial-step.d.ts +57 -0
- package/dist/workflows/target-assessment/steps/fanout/aes-for-one-trial-step.js +54 -0
- package/dist/workflows/target-assessment/steps/fanout/faers-for-one-modulator-step.d.ts +35 -0
- package/dist/workflows/target-assessment/steps/fanout/faers-for-one-modulator-step.js +32 -0
- package/dist/workflows/target-assessment/steps/fanout/index.d.ts +14 -0
- package/dist/workflows/target-assessment/steps/fanout/index.js +10 -0
- package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.d.ts +28 -0
- package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.js +27 -0
- package/dist/workflows/target-assessment/steps/phase0-resolve.d.ts +71 -0
- package/dist/workflows/target-assessment/steps/phase0-resolve.js +21 -0
- package/dist/workflows/target-assessment/steps/phase1-aggregate.d.ts +1018 -0
- package/dist/workflows/target-assessment/steps/phase1-aggregate.js +25 -0
- package/dist/workflows/target-assessment/steps/phase2-aggregate.d.ts +696 -0
- package/dist/workflows/target-assessment/steps/phase2-aggregate.js +38 -0
- package/dist/workflows/target-assessment/steps/phase3-aggregate.d.ts +936 -0
- package/dist/workflows/target-assessment/steps/phase3-aggregate.js +22 -0
- package/dist/workflows/target-assessment/steps/synthesis/diagnostics.d.ts +34 -0
- package/dist/workflows/target-assessment/steps/synthesis/diagnostics.js +45 -0
- package/dist/workflows/target-assessment/sub-workflows/index.d.ts +15 -0
- package/dist/workflows/target-assessment/sub-workflows/index.js +11 -0
- package/dist/workflows/target-assessment/sub-workflows/per-class-drug-aes.d.ts +41 -0
- package/dist/workflows/target-assessment/sub-workflows/per-class-drug-aes.js +12 -0
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-faers.d.ts +41 -0
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-faers.js +12 -0
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-polypharm.d.ts +36 -0
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-polypharm.js +12 -0
- package/dist/workflows/target-assessment/sub-workflows/per-trial-aes.d.ts +66 -0
- package/dist/workflows/target-assessment/sub-workflows/per-trial-aes.js +12 -0
- package/dist/workflows/target-assessment/synthesis/index.d.ts +560 -0
- package/dist/workflows/target-assessment/synthesis/index.js +351 -0
- package/dist/workflows/target-assessment/synthesis-probes.d.ts +56 -0
- package/dist/workflows/target-assessment/synthesis-probes.js +320 -0
- package/dist/workspace/filesystem.d.ts +117 -0
- package/dist/workspace/filesystem.js +304 -0
- package/dist/workspace/mount-strategy.d.ts +50 -0
- package/dist/workspace/mount-strategy.js +67 -0
- package/dist/workspace/paths.d.ts +185 -0
- package/dist/workspace/paths.js +219 -0
- package/dist/workspace/provenance-collector.d.ts +34 -0
- package/dist/workspace/provenance-collector.js +16 -0
- package/dist/workspace/search-config.d.ts +23 -0
- package/dist/workspace/search-config.js +43 -0
- package/dist/workspace/workspace-paths.d.ts +26 -0
- package/dist/workspace/workspace-paths.js +31 -0
- package/package.json +101 -0
|
@@ -0,0 +1,1339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Target Dossier — schema-driven document produced by the
|
|
3
|
+
* `executeTargetAssessment` workflow and rendered by the frontend.
|
|
4
|
+
*
|
|
5
|
+
* Single source of truth for the persisted JSONB shape and the rendered
|
|
6
|
+
* UI shape. Both Cortex and the frontend import from this module.
|
|
7
|
+
*
|
|
8
|
+
* Coverage discipline: every section that depends on enrichment data
|
|
9
|
+
* carries a `coverage` discriminator (`available | queried_no_data |
|
|
10
|
+
* not_loaded`). Sections that fall back to inference also carry an
|
|
11
|
+
* `inference_path`. Aggregate rows preserve their contributing evidence
|
|
12
|
+
* under `evidence: [...]` arrays.
|
|
13
|
+
*
|
|
14
|
+
* `DossierSchema` is a single v3 shape — no backwards-compatibility union.
|
|
15
|
+
* Old v1/v2 persisted rows will not parse; that is intentional.
|
|
16
|
+
*
|
|
17
|
+
* See `TARGET_DOSSIER.md` for the full editorial specification.
|
|
18
|
+
*/
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
// ── Coverage primitives ─────────────────────────────────────────────
|
|
21
|
+
export const CoverageSchema = z.enum(["available", "queried_no_data", "not_loaded"]);
|
|
22
|
+
const CoverageError = z.object({
|
|
23
|
+
message: z.string(),
|
|
24
|
+
source: z.string().optional(),
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Build a discriminated section schema: when `coverage` is `available`,
|
|
28
|
+
* `data` is required and matches the inner schema. Otherwise `data` is
|
|
29
|
+
* absent and an optional `error` payload may be present.
|
|
30
|
+
*/
|
|
31
|
+
function withCoverage(data) {
|
|
32
|
+
return z.discriminatedUnion("coverage", [
|
|
33
|
+
z.object({
|
|
34
|
+
coverage: z.literal("available"),
|
|
35
|
+
data,
|
|
36
|
+
inference_path: z.string().optional(),
|
|
37
|
+
truncated: z.boolean().optional(),
|
|
38
|
+
}),
|
|
39
|
+
z.object({
|
|
40
|
+
coverage: z.literal("queried_no_data"),
|
|
41
|
+
error: CoverageError.optional(),
|
|
42
|
+
inference_path: z.string().optional(),
|
|
43
|
+
}),
|
|
44
|
+
z.object({
|
|
45
|
+
coverage: z.literal("not_loaded"),
|
|
46
|
+
reason: z.string().optional(),
|
|
47
|
+
}),
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
// ── Section blurbs (renderer source of truth) ───────────────────────
|
|
51
|
+
export const SECTION_BLURBS = {
|
|
52
|
+
entity: "Canonical identity for the assessed target, including ontology, identifiers, and synonyms.",
|
|
53
|
+
safety_profile: "Per-organ liabilities derived from genetic, expression, FAERS, and class-precedent evidence. Each row carries an audit trail and a mechanism hypothesis where supportable.",
|
|
54
|
+
therapeutic_area_associations: "Disease and therapeutic-area associations from genetics, literature, and Open Targets evidence rows; intended as orientation for indication selection.",
|
|
55
|
+
indications: "Candidate indications ranked by combined evidence weight; each row carries the contributing evidence sources.",
|
|
56
|
+
clinical_development: "Active and completed trials of modulators of this target, indexed from ClinicalTrials.gov.",
|
|
57
|
+
reference_biology: "Preclinical biology, expression, KO phenotype, and PPI context supporting the target's mechanistic basis.",
|
|
58
|
+
executive_recommendation: "Disposition (pursue / conditional / de-prioritize / insufficient evidence) with cited rationale, key strengths, and key risks.",
|
|
59
|
+
};
|
|
60
|
+
// ── Shared evidence primitives ──────────────────────────────────────
|
|
61
|
+
export const EvidenceItemSchema = z.object({
|
|
62
|
+
pmid: z.string().optional(),
|
|
63
|
+
doi: z.string().optional(),
|
|
64
|
+
source: z.string(),
|
|
65
|
+
predicate: z.string().optional(),
|
|
66
|
+
score: z.number().optional(),
|
|
67
|
+
strength: z.string().optional(),
|
|
68
|
+
is_human: z.boolean().optional(),
|
|
69
|
+
is_clinical: z.boolean().optional(),
|
|
70
|
+
excerpt: z.string().optional(),
|
|
71
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
72
|
+
regulatory_reference: z
|
|
73
|
+
.object({
|
|
74
|
+
document: z.string(),
|
|
75
|
+
section: z.string().optional(),
|
|
76
|
+
doc_id: z.string().optional(),
|
|
77
|
+
doc_url: z.string().url().optional(),
|
|
78
|
+
})
|
|
79
|
+
.optional(),
|
|
80
|
+
});
|
|
81
|
+
const EvidenceList = z.array(EvidenceItemSchema);
|
|
82
|
+
// ── §1.1 Entity ─────────────────────────────────────────────────────
|
|
83
|
+
export const EntitySchema = z.object({
|
|
84
|
+
canonicalId: z.string(),
|
|
85
|
+
symbol: z.string(),
|
|
86
|
+
displayName: z.string(),
|
|
87
|
+
/**
|
|
88
|
+
* Cortex's Phase-0 resolver currently only emits `"gene"`. The schema
|
|
89
|
+
* keeps the broader enum so the contract is forward-compatible with
|
|
90
|
+
* protein-/rna-/complex-level entities once the resolver supports them.
|
|
91
|
+
*/
|
|
92
|
+
entityType: z.enum(["gene", "protein", "rna", "complex"]),
|
|
93
|
+
ontology: z.string(),
|
|
94
|
+
identifiers: z.object({
|
|
95
|
+
hgnc: z.string().optional(),
|
|
96
|
+
ensembl: z.string().optional(),
|
|
97
|
+
uniprot: z.string().optional(),
|
|
98
|
+
chembl: z.string().optional(),
|
|
99
|
+
ncbiGene: z.string().optional(),
|
|
100
|
+
}),
|
|
101
|
+
synonyms: z.array(z.string()).default([]),
|
|
102
|
+
proteinFamily: z.string().optional(),
|
|
103
|
+
});
|
|
104
|
+
// ── §1.2 Summary ────────────────────────────────────────────────────
|
|
105
|
+
export const SummarySchema = z.object({
|
|
106
|
+
total_evidence_items: z.number().int().nonnegative(),
|
|
107
|
+
total_distinct_papers: z.number().int().nonnegative(),
|
|
108
|
+
has_human_evidence: z.boolean(),
|
|
109
|
+
has_clinical_evidence: z.boolean(),
|
|
110
|
+
strongest_strength_label: z.string().nullable(),
|
|
111
|
+
highest_score: z.number().nullable(),
|
|
112
|
+
highest_score_is_conflicted: z.boolean(),
|
|
113
|
+
total_distinct_clinical_trials: z.number().int().nonnegative(),
|
|
114
|
+
});
|
|
115
|
+
// ── §2.1 Liability summary ──────────────────────────────────────────
|
|
116
|
+
export const LiabilityBulletSchema = z.object({
|
|
117
|
+
text: z.string(),
|
|
118
|
+
rationale: z.string(),
|
|
119
|
+
category: z.enum(["fatal_post_market", "class_liability", "off_target_safety", "high_safety_organ_expression", "broad_expression", "other"]),
|
|
120
|
+
});
|
|
121
|
+
export const LiabilitySummarySchema = z.object({
|
|
122
|
+
liability_bullets: z.array(LiabilityBulletSchema),
|
|
123
|
+
modality_recommendation: z.string().nullable(),
|
|
124
|
+
expression_breadth: z.object({
|
|
125
|
+
high_expression_tissue_count: z.number().int().nonnegative(),
|
|
126
|
+
total_assessed_tissues: z.number().int().nonnegative(),
|
|
127
|
+
}),
|
|
128
|
+
class_liability_count: z.number().int().nonnegative(),
|
|
129
|
+
safety_target_off_target_count: z.number().int().nonnegative(),
|
|
130
|
+
off_tissue_risk_organ_count: z.number().int().nonnegative(),
|
|
131
|
+
same_class_drug_count: z.number().int().nonnegative(),
|
|
132
|
+
safety_data_sources_checked: z.number().int().nonnegative(),
|
|
133
|
+
inferred_therapeutic_area: z.string().nullable(),
|
|
134
|
+
no_liabilities_disclosure: z.string().optional(),
|
|
135
|
+
});
|
|
136
|
+
// ── §2.2 Tractability ───────────────────────────────────────────────
|
|
137
|
+
export const TractabilityModalitySchema = z.object({
|
|
138
|
+
/**
|
|
139
|
+
* Phase-4 currently emits only `small_molecule`, `antibody`, and
|
|
140
|
+
* `other_clinical`. The remaining variants are reserved for future
|
|
141
|
+
* Phase-2 modality-fallback expansions (PROTAC, oligonucleotide, peptide
|
|
142
|
+
* libraries) — keep them in the enum so persisted dossiers don't reject
|
|
143
|
+
* once those land.
|
|
144
|
+
*/
|
|
145
|
+
modality: z.enum(["small_molecule", "antibody", "protac", "other_clinical", "oligonucleotide", "peptide"]),
|
|
146
|
+
levels: z.array(z.string()),
|
|
147
|
+
has_approved_drug: z.boolean(),
|
|
148
|
+
has_clinical_stage: z.boolean(),
|
|
149
|
+
is_inferred_from_family: z.boolean(),
|
|
150
|
+
approved_drug_ids: z.array(z.string()).optional(),
|
|
151
|
+
note: z.string().optional(),
|
|
152
|
+
});
|
|
153
|
+
export const TractabilitySchema = withCoverage(z.object({
|
|
154
|
+
modalities: z.array(TractabilityModalitySchema),
|
|
155
|
+
preferred_modality: z.string().nullable(),
|
|
156
|
+
}));
|
|
157
|
+
// ── §2.3 Indications ────────────────────────────────────────────────
|
|
158
|
+
export const IndicationRowSchema = z.object({
|
|
159
|
+
disease_id: z.string(),
|
|
160
|
+
disease_name: z.string(),
|
|
161
|
+
composite_score: z.number(),
|
|
162
|
+
composite_score_breakdown: z
|
|
163
|
+
.object({
|
|
164
|
+
base: z.number(),
|
|
165
|
+
source_bonuses: z.record(z.string(), z.number()),
|
|
166
|
+
paper_depth: z.number(),
|
|
167
|
+
})
|
|
168
|
+
.optional(),
|
|
169
|
+
evidence_score: z.number(),
|
|
170
|
+
source_count: z.number().int().nonnegative(),
|
|
171
|
+
unique_paper_count: z.number().int().nonnegative(),
|
|
172
|
+
sources: z.array(z.string()),
|
|
173
|
+
evidence: EvidenceList,
|
|
174
|
+
});
|
|
175
|
+
export const IndicationsSchema = withCoverage(z.object({
|
|
176
|
+
rows: z.array(IndicationRowSchema),
|
|
177
|
+
excluded_unsupported_count: z.number().int().nonnegative().optional(),
|
|
178
|
+
unsupported_associations: z
|
|
179
|
+
.array(z.object({
|
|
180
|
+
disease_id: z.string(),
|
|
181
|
+
disease_name: z.string(),
|
|
182
|
+
}))
|
|
183
|
+
.optional(),
|
|
184
|
+
}));
|
|
185
|
+
// ── §2.4 Drug interactions ──────────────────────────────────────────
|
|
186
|
+
export const DrugInteractionRowSchema = z.object({
|
|
187
|
+
drug_id: z.string().nullable(),
|
|
188
|
+
drug_name: z.string(),
|
|
189
|
+
best_score: z.number(),
|
|
190
|
+
predicates: z.array(z.string()),
|
|
191
|
+
sources: z.array(z.string()),
|
|
192
|
+
paper_count: z.number().int().nonnegative(),
|
|
193
|
+
dominant_direction: z.enum(["positive", "negative", "mixed", "unknown"]),
|
|
194
|
+
has_human_evidence: z.boolean(),
|
|
195
|
+
has_clinical_evidence: z.boolean(),
|
|
196
|
+
evidence: EvidenceList,
|
|
197
|
+
});
|
|
198
|
+
export const DrugInteractionsSchema = withCoverage(z.object({ rows: z.array(DrugInteractionRowSchema) }));
|
|
199
|
+
// ── §2.5 Clinical development ───────────────────────────────────────
|
|
200
|
+
export const ClinicalTrialRowSchema = z.object({
|
|
201
|
+
nct_id: z.string(),
|
|
202
|
+
title: z.string(),
|
|
203
|
+
phase: z.string().nullable(),
|
|
204
|
+
status: z.string(),
|
|
205
|
+
conditions: z.array(z.string()),
|
|
206
|
+
start_date: z.string().nullable(),
|
|
207
|
+
completion_date: z.string().nullable(),
|
|
208
|
+
match_confidence: z.enum(["high", "medium", "low", "off_target"]),
|
|
209
|
+
});
|
|
210
|
+
export const TrialOutcomeRowSchema = z.object({
|
|
211
|
+
nct_id: z.string(),
|
|
212
|
+
outcome_type: z.enum(["primary", "secondary", "serious_ae", "non_serious_ae", "other_ae"]),
|
|
213
|
+
measure: z.string(),
|
|
214
|
+
description: z.string().optional(),
|
|
215
|
+
result: z.string().optional(),
|
|
216
|
+
});
|
|
217
|
+
export const FailedTrialRowSchema = z.object({
|
|
218
|
+
nct_id: z.string(),
|
|
219
|
+
title: z.string(),
|
|
220
|
+
why_stopped: z.string(),
|
|
221
|
+
failure_category: z.enum(["safety", "efficacy", "strategic", "other"]),
|
|
222
|
+
classifier: z.enum(["rules", "llm"]),
|
|
223
|
+
});
|
|
224
|
+
const FailureCategoryV4Schema = z.discriminatedUnion("category", [
|
|
225
|
+
z.object({ category: z.literal("safety"), safety_evidence_excerpt: z.string() }),
|
|
226
|
+
z.object({ category: z.literal("strategic"), category_evidence_excerpt: z.string() }),
|
|
227
|
+
z.object({ category: z.literal("operational"), category_evidence_excerpt: z.string() }),
|
|
228
|
+
z.object({ category: z.literal("efficacy"), category_evidence_excerpt: z.string() }),
|
|
229
|
+
]);
|
|
230
|
+
export const FailedTrialRowV4Schema = z
|
|
231
|
+
.object({
|
|
232
|
+
nct_id: z.string(),
|
|
233
|
+
title: z.string(),
|
|
234
|
+
why_stopped: z.string(),
|
|
235
|
+
classifier: z.enum(["rules", "llm"]),
|
|
236
|
+
failure_category: FailureCategoryV4Schema,
|
|
237
|
+
})
|
|
238
|
+
.superRefine((v, ctx) => {
|
|
239
|
+
const excerpt = "safety_evidence_excerpt" in v.failure_category ? v.failure_category.safety_evidence_excerpt : v.failure_category.category_evidence_excerpt;
|
|
240
|
+
// CT.gov sometimes terminates trials without recording a `whyStopped`
|
|
241
|
+
// reason. In that case the assembler emits `why_stopped: ""` with
|
|
242
|
+
// `category: "operational"` and `excerpt: ""` — there's nothing to
|
|
243
|
+
// classify and nothing to excerpt. Both being empty is the valid
|
|
244
|
+
// "no recorded reason" shape; mismatched emptiness is an error.
|
|
245
|
+
const whyEmpty = v.why_stopped.length === 0;
|
|
246
|
+
const excerptEmpty = excerpt.length === 0;
|
|
247
|
+
if (whyEmpty !== excerptEmpty) {
|
|
248
|
+
ctx.addIssue({
|
|
249
|
+
code: "custom",
|
|
250
|
+
message: whyEmpty
|
|
251
|
+
? `failure_category evidence_excerpt is non-empty but why_stopped is empty`
|
|
252
|
+
: `failure_category evidence_excerpt is empty but why_stopped is non-empty`,
|
|
253
|
+
path: ["failure_category"],
|
|
254
|
+
});
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (whyEmpty)
|
|
258
|
+
return;
|
|
259
|
+
if (!v.why_stopped.toLowerCase().includes(excerpt.toLowerCase())) {
|
|
260
|
+
ctx.addIssue({
|
|
261
|
+
code: "custom",
|
|
262
|
+
message: `failure_category evidence_excerpt is not a substring of why_stopped`,
|
|
263
|
+
path: ["failure_category"],
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
export const ClinicalBenchmarksSchema = z.object({
|
|
268
|
+
therapeutic_area: z.string().nullable(),
|
|
269
|
+
fallback_to_all_areas: z.boolean(),
|
|
270
|
+
phase_transitions: z.record(z.string(), z.number()),
|
|
271
|
+
likelihood_of_approval: z.number().nullable(),
|
|
272
|
+
source_attribution: z.string(),
|
|
273
|
+
});
|
|
274
|
+
export const ClinicalDevelopmentSchema = z.object({
|
|
275
|
+
trials: withCoverage(z.object({
|
|
276
|
+
rows: z.array(ClinicalTrialRowSchema),
|
|
277
|
+
related_target_trials: z
|
|
278
|
+
.array(ClinicalTrialRowSchema.extend({
|
|
279
|
+
match_confidence: z.literal("off_target"),
|
|
280
|
+
}))
|
|
281
|
+
.optional(),
|
|
282
|
+
related_receptor: z.string().optional(),
|
|
283
|
+
selection_criteria: z
|
|
284
|
+
.object({
|
|
285
|
+
derived_from: z.literal("analytics.discovery_trials"),
|
|
286
|
+
min_confidence: z.enum(["high", "medium"]),
|
|
287
|
+
excluded_off_target_count: z.number().int().nonnegative(),
|
|
288
|
+
})
|
|
289
|
+
.optional(),
|
|
290
|
+
})),
|
|
291
|
+
outcomes: withCoverage(z.object({ rows: z.array(TrialOutcomeRowSchema) })),
|
|
292
|
+
failed_trials: withCoverage(z.object({
|
|
293
|
+
rows: z.array(FailedTrialRowSchema),
|
|
294
|
+
related_target_trials: z.array(FailedTrialRowSchema).optional(),
|
|
295
|
+
related_receptor: z.string().optional(),
|
|
296
|
+
})),
|
|
297
|
+
benchmarks: withCoverage(ClinicalBenchmarksSchema),
|
|
298
|
+
});
|
|
299
|
+
// ── §2.6 Safety profile ─────────────────────────────────────────────
|
|
300
|
+
export const OrganRiskRowSchema = z.object({
|
|
301
|
+
organ: z.enum(["cardiac", "hepatic", "cns", "renal", "gi", "hematologic", "metabolic", "immune", "respiratory"]),
|
|
302
|
+
risk_level: z.enum(["high", "medium", "low"]),
|
|
303
|
+
signal_type_count: z.number().int().nonnegative(),
|
|
304
|
+
signals: z.object({
|
|
305
|
+
chembl_polypharm_count: z.number().int().nonnegative(),
|
|
306
|
+
faers_count: z.number().int().nonnegative(),
|
|
307
|
+
trial_ae_count: z.number().int().nonnegative(),
|
|
308
|
+
class_liability_present: z.boolean(),
|
|
309
|
+
}),
|
|
310
|
+
evidence: EvidenceList,
|
|
311
|
+
});
|
|
312
|
+
export const FaersSummarySchema = z.object({
|
|
313
|
+
total_reports: z.number().int().nonnegative(),
|
|
314
|
+
fatal_report_count: z.number().int().nonnegative(),
|
|
315
|
+
any_fatal: z.boolean(),
|
|
316
|
+
seriousness_profile: z
|
|
317
|
+
.object({
|
|
318
|
+
death: z.number().int().nonnegative(),
|
|
319
|
+
hospitalization: z.number().int().nonnegative(),
|
|
320
|
+
life_threatening: z.number().int().nonnegative(),
|
|
321
|
+
disabling: z.number().int().nonnegative(),
|
|
322
|
+
congenital_anomaly: z.number().int().nonnegative(),
|
|
323
|
+
other_serious: z.number().int().nonnegative(),
|
|
324
|
+
})
|
|
325
|
+
.optional(),
|
|
326
|
+
top_signals: z.array(z.object({
|
|
327
|
+
meddra_term: z.string(),
|
|
328
|
+
organ: z.string().optional(),
|
|
329
|
+
report_count: z.number().int().nonnegative(),
|
|
330
|
+
proportional_reporting_ratio: z.number().optional(),
|
|
331
|
+
})),
|
|
332
|
+
per_modulator: z.array(z.object({
|
|
333
|
+
modulator: z.string(),
|
|
334
|
+
modulator_id: z.string().nullable(),
|
|
335
|
+
report_count: z.number().int().nonnegative(),
|
|
336
|
+
coverage: CoverageSchema,
|
|
337
|
+
})),
|
|
338
|
+
});
|
|
339
|
+
const SeriousnessAvailableV4Schema = z
|
|
340
|
+
.object({
|
|
341
|
+
coverage: z.literal("available"),
|
|
342
|
+
total_reports: z.number().int().nonnegative(),
|
|
343
|
+
by_seriousness: z.object({
|
|
344
|
+
death: z.number().int().nonnegative(),
|
|
345
|
+
life_threatening: z.number().int().nonnegative(),
|
|
346
|
+
hospitalization: z.number().int().nonnegative(),
|
|
347
|
+
disabling: z.number().int().nonnegative(),
|
|
348
|
+
other_serious: z.number().int().nonnegative(),
|
|
349
|
+
congenital_anomaly: z.number().int().nonnegative(),
|
|
350
|
+
}),
|
|
351
|
+
fatal_report_count: z.number().int().nonnegative(),
|
|
352
|
+
})
|
|
353
|
+
.superRefine((v, ctx) => {
|
|
354
|
+
// NOTE: by_seriousness categories are independent binary flags on
|
|
355
|
+
// each FAERS report — a single fatal hospitalisation increments
|
|
356
|
+
// both `death` and `hospitalization` — so sum(by_seriousness) can
|
|
357
|
+
// legitimately exceed total_reports. Do not invariant on the sum.
|
|
358
|
+
if (v.fatal_report_count > v.by_seriousness.death) {
|
|
359
|
+
ctx.addIssue({
|
|
360
|
+
code: "custom",
|
|
361
|
+
message: `fatal_report_count=${v.fatal_report_count} exceeds by_seriousness.death=${v.by_seriousness.death}`,
|
|
362
|
+
path: ["fatal_report_count"],
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
const sum = v.by_seriousness.death +
|
|
366
|
+
v.by_seriousness.life_threatening +
|
|
367
|
+
v.by_seriousness.hospitalization +
|
|
368
|
+
v.by_seriousness.disabling +
|
|
369
|
+
v.by_seriousness.other_serious +
|
|
370
|
+
v.by_seriousness.congenital_anomaly;
|
|
371
|
+
if (v.total_reports > 1000 && sum === 0) {
|
|
372
|
+
ctx.addIssue({
|
|
373
|
+
code: "custom",
|
|
374
|
+
message: `seriousness is all-zero across ${v.total_reports} reports; emit coverage:"queried_no_data" instead of fabricated zeros`,
|
|
375
|
+
path: ["by_seriousness"],
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
const SeriousnessQueriedNoDataV4Schema = z.object({
|
|
380
|
+
coverage: z.literal("queried_no_data"),
|
|
381
|
+
total_reports: z.number().int().nonnegative(),
|
|
382
|
+
});
|
|
383
|
+
export const FaersSummaryV4Schema = z.object({
|
|
384
|
+
total_reports: z.number().int().nonnegative(),
|
|
385
|
+
seriousness: z.discriminatedUnion("coverage", [SeriousnessAvailableV4Schema, SeriousnessQueriedNoDataV4Schema]),
|
|
386
|
+
top_signals: z.array(z.object({
|
|
387
|
+
meddra_term: z.string(),
|
|
388
|
+
organ: z.string().optional(),
|
|
389
|
+
report_count: z.number().int().nonnegative(),
|
|
390
|
+
proportional_reporting_ratio: z.number().optional(),
|
|
391
|
+
})),
|
|
392
|
+
per_modulator: z.array(z.object({
|
|
393
|
+
modulator: z.string(),
|
|
394
|
+
modulator_id: z.string().nullable(),
|
|
395
|
+
report_count: z.number().int().nonnegative(),
|
|
396
|
+
coverage: CoverageSchema,
|
|
397
|
+
})),
|
|
398
|
+
});
|
|
399
|
+
export const TrialAesSchema = z.object({
|
|
400
|
+
serious: z.array(z.object({
|
|
401
|
+
term: z.string(),
|
|
402
|
+
incidence_pct: z.number(),
|
|
403
|
+
organ: z.string().optional(),
|
|
404
|
+
nct_ids: z.array(z.string()),
|
|
405
|
+
})),
|
|
406
|
+
non_serious: z.array(z.object({
|
|
407
|
+
term: z.string(),
|
|
408
|
+
incidence_pct: z.number(),
|
|
409
|
+
organ: z.string().optional(),
|
|
410
|
+
nct_ids: z.array(z.string()),
|
|
411
|
+
})),
|
|
412
|
+
/**
|
|
413
|
+
* Floor pct for non-serious AEs. PR-E lowered the operational value
|
|
414
|
+
* from 5 to 2 so real low-incidence AEs survive the filter; older
|
|
415
|
+
* persisted dossiers with the prior 5% floor still parse.
|
|
416
|
+
*/
|
|
417
|
+
non_serious_floor_pct: z.number().nonnegative().default(2),
|
|
418
|
+
/**
|
|
419
|
+
* Count of rows dropped by the catch-all-bucket filter (e.g., "Other"
|
|
420
|
+
* term or term equal to organ system). Surfaced for auditability.
|
|
421
|
+
*/
|
|
422
|
+
dropped_uninformative_count: z.number().int().nonnegative().optional(),
|
|
423
|
+
coverage_qualifier: z
|
|
424
|
+
.object({
|
|
425
|
+
trials_queried: z.number().int().nonnegative(),
|
|
426
|
+
trials_with_ae_data: z.number().int().nonnegative(),
|
|
427
|
+
serious_floor_applied: z.number().optional(),
|
|
428
|
+
non_serious_floor_pct_applied: z.number().optional(),
|
|
429
|
+
})
|
|
430
|
+
.optional(),
|
|
431
|
+
});
|
|
432
|
+
export const OffTargetRowSchema = z.object({
|
|
433
|
+
off_target_id: z.string().nullable(),
|
|
434
|
+
off_target_name: z.string(),
|
|
435
|
+
target_class: z.string().optional(),
|
|
436
|
+
pchembl: z.number(),
|
|
437
|
+
is_safety_panel_target: z.boolean(),
|
|
438
|
+
organ_system: z.string().nullable(),
|
|
439
|
+
clinical_consequence: z.string().nullable(),
|
|
440
|
+
selectivity: z.object({
|
|
441
|
+
log_units: z.number(),
|
|
442
|
+
fold: z.number(),
|
|
443
|
+
legacy_alias: z.number().optional(),
|
|
444
|
+
}),
|
|
445
|
+
selectivity_window_below_threshold: z.boolean(),
|
|
446
|
+
evidence: EvidenceList,
|
|
447
|
+
metadata: z
|
|
448
|
+
.object({
|
|
449
|
+
merged_chembl_ids: z.array(z.string()).optional(),
|
|
450
|
+
})
|
|
451
|
+
.optional(),
|
|
452
|
+
});
|
|
453
|
+
const SelectivityV4Schema = z.union([
|
|
454
|
+
z.object({
|
|
455
|
+
vs_primary_potency: z.object({
|
|
456
|
+
primary_pchembl_used: z.number(),
|
|
457
|
+
primary_source: z.enum(["chembl_target_drug_indication", "literature_curated"]),
|
|
458
|
+
fold: z.number().positive().finite(),
|
|
459
|
+
log_units: z.number(),
|
|
460
|
+
}),
|
|
461
|
+
}),
|
|
462
|
+
z.object({
|
|
463
|
+
selectivity_unknown: z.literal(true),
|
|
464
|
+
reason: z.string().min(1),
|
|
465
|
+
}),
|
|
466
|
+
]);
|
|
467
|
+
const OffTargetRowV4Base = z.object({
|
|
468
|
+
off_target_id: z.string().nullable(),
|
|
469
|
+
off_target_name: z.string(),
|
|
470
|
+
target_class: z.string().optional(),
|
|
471
|
+
pchembl: z.number(),
|
|
472
|
+
is_safety_panel_target: z.boolean(),
|
|
473
|
+
organ_system: z.string().nullable(),
|
|
474
|
+
clinical_consequence: z.string().nullable(),
|
|
475
|
+
selectivity: SelectivityV4Schema,
|
|
476
|
+
selectivity_window_below_threshold: z.boolean(),
|
|
477
|
+
evidence: EvidenceList,
|
|
478
|
+
metadata: z.object({ merged_chembl_ids: z.array(z.string()).optional() }).optional(),
|
|
479
|
+
});
|
|
480
|
+
export const OffTargetRowV4Schema = OffTargetRowV4Base.extend({
|
|
481
|
+
relationship: z.literal("off_target"),
|
|
482
|
+
});
|
|
483
|
+
export const ExcludedOffTargetRowV4Schema = OffTargetRowV4Base.extend({
|
|
484
|
+
relationship: z.enum(["intended_co_target", "on_target_self_hit", "obligate_cofactor"]),
|
|
485
|
+
reason: z.string().min(1),
|
|
486
|
+
});
|
|
487
|
+
export const OffTargetPanelV4Schema = z.object({
|
|
488
|
+
rows: z.array(OffTargetRowV4Schema),
|
|
489
|
+
excluded_rows: z.array(ExcludedOffTargetRowV4Schema),
|
|
490
|
+
});
|
|
491
|
+
export const ClassLiabilityOrganSchema = z.object({
|
|
492
|
+
organ: z.string(),
|
|
493
|
+
drug_count_in_class: z.number().int().nonnegative(),
|
|
494
|
+
drugs_with_signal: z.number().int().nonnegative(),
|
|
495
|
+
signal_fraction: z.number(),
|
|
496
|
+
is_class_liability: z.boolean(),
|
|
497
|
+
suppressed_reason: z.string().nullable(),
|
|
498
|
+
top_aes: z.array(z.object({
|
|
499
|
+
term: z.string(),
|
|
500
|
+
report_count: z.number().int().nonnegative(),
|
|
501
|
+
})),
|
|
502
|
+
});
|
|
503
|
+
export const ClassPrecedentSchema = z.object({
|
|
504
|
+
drugs_in_class: z.array(z.object({
|
|
505
|
+
drug_id: z.string().nullable(),
|
|
506
|
+
drug_name: z.string(),
|
|
507
|
+
max_phase: z.number().int(),
|
|
508
|
+
mechanism: z.string().optional(),
|
|
509
|
+
})),
|
|
510
|
+
per_organ: z.array(ClassLiabilityOrganSchema),
|
|
511
|
+
});
|
|
512
|
+
export const SafetyFlagSchema = z.object({
|
|
513
|
+
organ: z.string(),
|
|
514
|
+
trail: z.string(),
|
|
515
|
+
mechanism_hypothesis: z.string().nullable().optional(),
|
|
516
|
+
});
|
|
517
|
+
export const RiskSummarySchema = z.object({
|
|
518
|
+
highest_risk_organ: z.string().nullable(),
|
|
519
|
+
off_target_safety_target_hits: z.number().int().nonnegative(),
|
|
520
|
+
class_liability_count: z.number().int().nonnegative(),
|
|
521
|
+
any_fatal_signal: z.boolean(),
|
|
522
|
+
});
|
|
523
|
+
export const SafetyProfileSchema = z.object({
|
|
524
|
+
organ_rollup: withCoverage(z.object({ rows: z.array(OrganRiskRowSchema) })),
|
|
525
|
+
faers: withCoverage(FaersSummarySchema),
|
|
526
|
+
trial_aes: withCoverage(TrialAesSchema),
|
|
527
|
+
off_target_panel: withCoverage(z.object({ rows: z.array(OffTargetRowSchema) })),
|
|
528
|
+
failed_trials_safety_lens: withCoverage(z.object({
|
|
529
|
+
rows: z.array(FailedTrialRowSchema),
|
|
530
|
+
related_target_trials: z.array(FailedTrialRowSchema).optional(),
|
|
531
|
+
related_receptor: z.string().optional(),
|
|
532
|
+
})),
|
|
533
|
+
class_precedent: withCoverage(ClassPrecedentSchema),
|
|
534
|
+
target_organ_liabilities: z.array(SafetyFlagSchema),
|
|
535
|
+
risk_summary: RiskSummarySchema,
|
|
536
|
+
});
|
|
537
|
+
// ── §2.7 Off-tissue risk ────────────────────────────────────────────
|
|
538
|
+
export const OffTissueRowSchema = z.object({
|
|
539
|
+
tissue: z.string(),
|
|
540
|
+
organ: z.string(),
|
|
541
|
+
tpm: z.number(),
|
|
542
|
+
});
|
|
543
|
+
export const OffTissueRiskSchema = withCoverage(z.object({ rows: z.array(OffTissueRowSchema) }));
|
|
544
|
+
// ── §3.1–3.6 Reference biology — keyed evidence sections ────────────
|
|
545
|
+
export const KeyedEvidenceRowSchema = z.object({
|
|
546
|
+
partner_id: z.string().nullable(),
|
|
547
|
+
partner_name: z.string(),
|
|
548
|
+
predicate: z.string(),
|
|
549
|
+
best_score: z.number(),
|
|
550
|
+
source_count: z.number().int().nonnegative(),
|
|
551
|
+
paper_count: z.number().int().nonnegative(),
|
|
552
|
+
evidence: EvidenceList,
|
|
553
|
+
});
|
|
554
|
+
export const DiseaseAssociationsSchema = withCoverage(z.object({ rows: z.array(KeyedEvidenceRowSchema) }));
|
|
555
|
+
export const MolecularInteractionsSchema = withCoverage(z.object({ rows: z.array(KeyedEvidenceRowSchema) }));
|
|
556
|
+
export const BiomarkerEvidenceRowSchema = KeyedEvidenceRowSchema.extend({
|
|
557
|
+
metrics: z.object({
|
|
558
|
+
sensitivity: z.number().optional(),
|
|
559
|
+
specificity: z.number().optional(),
|
|
560
|
+
auc: z.number().optional(),
|
|
561
|
+
hazard_ratio: z.number().optional(),
|
|
562
|
+
}),
|
|
563
|
+
});
|
|
564
|
+
export const BiomarkerPotentialSchema = withCoverage(z.object({ rows: z.array(BiomarkerEvidenceRowSchema) }));
|
|
565
|
+
export const ResistanceEvidenceSchema = withCoverage(z.object({ rows: z.array(KeyedEvidenceRowSchema) }));
|
|
566
|
+
export const CombinationEvidenceSchema = withCoverage(z.object({ rows: z.array(KeyedEvidenceRowSchema) }));
|
|
567
|
+
// ── §3.4 Genetic alterations ────────────────────────────────────────
|
|
568
|
+
export const SomaticMutationRowSchema = z.object({
|
|
569
|
+
cancer_type: z.string(),
|
|
570
|
+
cohort: z.string(),
|
|
571
|
+
mutation_count: z.number().int().nonnegative(),
|
|
572
|
+
total_samples: z.number().int().nonnegative(),
|
|
573
|
+
frequency: z.number(),
|
|
574
|
+
source: z.string(),
|
|
575
|
+
});
|
|
576
|
+
export const ClinvarVariantRowSchema = z.object({
|
|
577
|
+
variant_id: z.string(),
|
|
578
|
+
hgvs: z.string(),
|
|
579
|
+
classification: z.string(),
|
|
580
|
+
condition: z.string(),
|
|
581
|
+
review_status: z.string(),
|
|
582
|
+
});
|
|
583
|
+
export const GeneticAlterationsSchema = z.object({
|
|
584
|
+
somatic: withCoverage(z.object({ rows: z.array(SomaticMutationRowSchema) })),
|
|
585
|
+
clinvar: withCoverage(z.object({ rows: z.array(ClinvarVariantRowSchema) })),
|
|
586
|
+
});
|
|
587
|
+
// ── §3.7 Pathway context ────────────────────────────────────────────
|
|
588
|
+
export const PathwayRowSchema = z.object({
|
|
589
|
+
pathway_id: z.string(),
|
|
590
|
+
pathway_name: z.string(),
|
|
591
|
+
database: z.enum(["reactome", "kegg", "wikipathways", "msigdb"]),
|
|
592
|
+
evidence_score: z.number(),
|
|
593
|
+
entity_uniprots: z.array(z.string()).optional(),
|
|
594
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
595
|
+
});
|
|
596
|
+
export const PathwayContextSchema = withCoverage(z.object({
|
|
597
|
+
rows: z.array(PathwayRowSchema),
|
|
598
|
+
databases_queried: z.array(z.string()),
|
|
599
|
+
databases_skipped: z.array(z.string()),
|
|
600
|
+
}));
|
|
601
|
+
// ── §3.8 PPI network ────────────────────────────────────────────────
|
|
602
|
+
export const PpiPartnerRowSchema = z.object({
|
|
603
|
+
partner_id: z.string().nullable(),
|
|
604
|
+
partner_name: z.string(),
|
|
605
|
+
string_score: z.number().nullable(),
|
|
606
|
+
literature_score: z.number().nullable(),
|
|
607
|
+
combined_score: z.number(),
|
|
608
|
+
sources: z.array(z.string()),
|
|
609
|
+
has_human_evidence: z.boolean(),
|
|
610
|
+
has_clinical_evidence: z.boolean(),
|
|
611
|
+
});
|
|
612
|
+
export const PpiNetworkSchema = withCoverage(z.object({ partners: z.array(PpiPartnerRowSchema) }));
|
|
613
|
+
// ── §3.9 Normal tissue expression ───────────────────────────────────
|
|
614
|
+
export const NormalTissueRowSchema = z.object({
|
|
615
|
+
tissue: z.string(),
|
|
616
|
+
organ: z.string().optional(),
|
|
617
|
+
tpm: z.number(),
|
|
618
|
+
is_safety_relevant: z.boolean(),
|
|
619
|
+
});
|
|
620
|
+
export const NormalTissueExpressionSchema = withCoverage(z.object({ rows: z.array(NormalTissueRowSchema) }));
|
|
621
|
+
// ── §3.10 Preclinical ───────────────────────────────────────────────
|
|
622
|
+
export const KoPhenotypeSchema = z.object({
|
|
623
|
+
marker_symbol: z.string().nullable(),
|
|
624
|
+
viability: z.string().nullable(),
|
|
625
|
+
sex_dimorphism: z.boolean(),
|
|
626
|
+
organ_systems_with_phenotype: z.array(z.string()),
|
|
627
|
+
top_mp_terms: z.array(z.string()),
|
|
628
|
+
total_phenotype_count: z.number().int().nonnegative(),
|
|
629
|
+
pre_weaning_lethal: z.boolean(),
|
|
630
|
+
supporting_literature: EvidenceList,
|
|
631
|
+
});
|
|
632
|
+
const ExpressionRank = z.enum(["absent", "low", "medium", "high", "no_data", "not_loaded"]);
|
|
633
|
+
export const ExpressionHeatmapCellSchema = z.object({
|
|
634
|
+
tissue: z.string(),
|
|
635
|
+
species: z.enum(["human", "mouse", "rat", "macaque", "dog"]),
|
|
636
|
+
rank: ExpressionRank,
|
|
637
|
+
});
|
|
638
|
+
export const ExpressionHeatmapSchema = z.object({
|
|
639
|
+
cells: z.array(ExpressionHeatmapCellSchema),
|
|
640
|
+
per_species_coverage: z.record(z.string(), CoverageSchema),
|
|
641
|
+
});
|
|
642
|
+
export const TranslationalCommentaryRowSchema = z.object({
|
|
643
|
+
severity: z.enum(["ok", "caution", "gap"]),
|
|
644
|
+
organ: z.string().optional(),
|
|
645
|
+
species: z.string().optional(),
|
|
646
|
+
text: z.string(),
|
|
647
|
+
});
|
|
648
|
+
export const PreclinicalLiteratureRowSchema = z.object({
|
|
649
|
+
pmid: z.string().nullable(),
|
|
650
|
+
claim: z.string(),
|
|
651
|
+
excerpt: z.string().optional(),
|
|
652
|
+
model_system: z.string(),
|
|
653
|
+
species: z.string(),
|
|
654
|
+
});
|
|
655
|
+
export const PreclinicalDataCoverageSchema = z.object({
|
|
656
|
+
ko: z.enum(["available", "no_phenotypes", "none", "queried_no_data", "not_loaded"]),
|
|
657
|
+
expression: CoverageSchema,
|
|
658
|
+
literature: CoverageSchema,
|
|
659
|
+
per_species: z.record(z.string(), z.boolean()),
|
|
660
|
+
});
|
|
661
|
+
export const PreclinicalProfileSchema = z.object({
|
|
662
|
+
ko_phenotype: withCoverage(KoPhenotypeSchema),
|
|
663
|
+
expression_heatmap: withCoverage(ExpressionHeatmapSchema),
|
|
664
|
+
translational_commentary: withCoverage(z.object({ rows: z.array(TranslationalCommentaryRowSchema) })),
|
|
665
|
+
preclinical_literature: withCoverage(z.object({
|
|
666
|
+
rows: z.array(PreclinicalLiteratureRowSchema),
|
|
667
|
+
total_claim_count: z.number().int().nonnegative(),
|
|
668
|
+
truncated: z.boolean(),
|
|
669
|
+
})),
|
|
670
|
+
data_coverage: PreclinicalDataCoverageSchema,
|
|
671
|
+
});
|
|
672
|
+
// ── §3.11 Key papers ────────────────────────────────────────────────
|
|
673
|
+
export const KeyPaperRowSchema = z.object({
|
|
674
|
+
pmid: z.string(),
|
|
675
|
+
title: z.string(),
|
|
676
|
+
internal_reference_count: z.number().int().nonnegative(),
|
|
677
|
+
year: z.number().int().optional(),
|
|
678
|
+
});
|
|
679
|
+
export const KeyPapersSchema = withCoverage(z.object({ rows: z.array(KeyPaperRowSchema) }));
|
|
680
|
+
// ── §4.1 Evidence conflicts ─────────────────────────────────────────
|
|
681
|
+
export const EvidenceConflictRowSchema = z.object({
|
|
682
|
+
evidence_item_id: z.string(),
|
|
683
|
+
predicate: z.string(),
|
|
684
|
+
contradicting_predicates: z.array(z.string()),
|
|
685
|
+
surfaced_in_section: z.string(),
|
|
686
|
+
evidence: EvidenceList,
|
|
687
|
+
});
|
|
688
|
+
export const EvidenceConflictsSchema = withCoverage(z.object({ rows: z.array(EvidenceConflictRowSchema) }));
|
|
689
|
+
// ── §4.2 Evidence timeline ──────────────────────────────────────────
|
|
690
|
+
export const EvidenceTimelineSchema = withCoverage(z.object({
|
|
691
|
+
histogram: z.record(z.string(), z.number().int().nonnegative()),
|
|
692
|
+
first_reported_year: z.number().int().nullable(),
|
|
693
|
+
last_reported_year: z.number().int().nullable(),
|
|
694
|
+
trend_labels: z.array(z.string()),
|
|
695
|
+
}));
|
|
696
|
+
// ── §4.3 Translational chain ────────────────────────────────────────
|
|
697
|
+
const TranslationalTier = z.enum(["computational", "basic_in_vitro", "complex_in_vitro", "in_vivo_animal", "ex_vivo_human", "clinical"]);
|
|
698
|
+
export const TranslationalChainSchema = withCoverage(z.object({
|
|
699
|
+
tiers: z.array(z.object({
|
|
700
|
+
tier: TranslationalTier,
|
|
701
|
+
claim_count: z.number().int().nonnegative(),
|
|
702
|
+
paper_count: z.number().int().nonnegative(),
|
|
703
|
+
})),
|
|
704
|
+
peak_evidence_tier: TranslationalTier.nullable(),
|
|
705
|
+
progression_complete: z.boolean(),
|
|
706
|
+
weakest_progression_gap: TranslationalTier.nullable().optional(),
|
|
707
|
+
}));
|
|
708
|
+
// ── §4.4 Additional evidence ────────────────────────────────────────
|
|
709
|
+
export const AdditionalEvidenceSchema = withCoverage(z.object({
|
|
710
|
+
rows: z.array(z.object({
|
|
711
|
+
predicate: z.string(),
|
|
712
|
+
evidence: EvidenceList,
|
|
713
|
+
})),
|
|
714
|
+
score_floor: z.number(),
|
|
715
|
+
}));
|
|
716
|
+
// ── V4 schema refinements ────────────────────────────────────────────
|
|
717
|
+
// Trial outcome with required discriminated effect block
|
|
718
|
+
export const TrialOutcomeRowV4Schema = z.object({
|
|
719
|
+
nct_id: z.string(),
|
|
720
|
+
measure: z.string(),
|
|
721
|
+
outcome_type: z.enum(["primary", "secondary", "other"]),
|
|
722
|
+
description: z.string().optional(),
|
|
723
|
+
time_frame: z.string().optional(),
|
|
724
|
+
effect: z.discriminatedUnion("kind", [
|
|
725
|
+
z.object({
|
|
726
|
+
kind: z.literal("quantitative"),
|
|
727
|
+
value: z.number(),
|
|
728
|
+
ci_low: z.number().optional(),
|
|
729
|
+
ci_high: z.number().optional(),
|
|
730
|
+
units: z.string(),
|
|
731
|
+
}),
|
|
732
|
+
z.object({
|
|
733
|
+
kind: z.literal("qualitative"),
|
|
734
|
+
direction: z.enum(["increase", "decrease", "no_change"]),
|
|
735
|
+
magnitude_label: z.string(),
|
|
736
|
+
}),
|
|
737
|
+
z.object({
|
|
738
|
+
kind: z.literal("not_extracted"),
|
|
739
|
+
reason: z.enum(["ctgov_no_numeric_result", "ctgov_no_result_groups", "parse_failure"]),
|
|
740
|
+
}),
|
|
741
|
+
]),
|
|
742
|
+
});
|
|
743
|
+
// Normal tissue expression with source + unit pair and required normalization_notes
|
|
744
|
+
export const NormalTissueExpressionV4Schema = z
|
|
745
|
+
.object({
|
|
746
|
+
source: z.enum(["gtex", "hpa_consensus", "hpa_rna_tissue"]),
|
|
747
|
+
unit: z.enum(["tpm", "ntpm", "consensus_normalized"]),
|
|
748
|
+
normalization_notes: z.string().min(1),
|
|
749
|
+
rows: z.array(z.object({
|
|
750
|
+
tissue: z.string(),
|
|
751
|
+
value: z.number(),
|
|
752
|
+
percentile_rank: z.number().optional(),
|
|
753
|
+
})),
|
|
754
|
+
})
|
|
755
|
+
.superRefine((v, ctx) => {
|
|
756
|
+
if (v.unit === "tpm" && v.source !== "gtex") {
|
|
757
|
+
ctx.addIssue({
|
|
758
|
+
code: "custom",
|
|
759
|
+
message: `unit:"tpm" is only valid with source:"gtex" (got source:"${v.source}")`,
|
|
760
|
+
path: ["unit"],
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
if (v.unit === "ntpm" && !(v.source === "hpa_rna_tissue" || v.source === "hpa_consensus")) {
|
|
764
|
+
ctx.addIssue({
|
|
765
|
+
code: "custom",
|
|
766
|
+
message: `unit:"ntpm" is only valid with HPA sources`,
|
|
767
|
+
path: ["unit"],
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
// Tractability with modality enumeration refinement
|
|
772
|
+
const MOLECULE_TYPE_TO_MODALITY = {
|
|
773
|
+
Protein: ["peptide", "antibody"],
|
|
774
|
+
"Small molecule": ["small_molecule"],
|
|
775
|
+
Oligonucleotide: ["oligonucleotide"],
|
|
776
|
+
};
|
|
777
|
+
export const TractabilityV4Schema = withCoverage(z
|
|
778
|
+
.object({
|
|
779
|
+
modalities: z.array(TractabilityModalitySchema),
|
|
780
|
+
preferred_modality: z.string().nullable(),
|
|
781
|
+
drug_molecule_types_present: z.array(z.string()).default([]),
|
|
782
|
+
})
|
|
783
|
+
.superRefine((v, ctx) => {
|
|
784
|
+
for (const moleculeType of v.drug_molecule_types_present) {
|
|
785
|
+
const allowed = MOLECULE_TYPE_TO_MODALITY[moleculeType];
|
|
786
|
+
if (!allowed)
|
|
787
|
+
continue; // unknown molecule_type — skip rather than block
|
|
788
|
+
const hasMatching = v.modalities.some((m) => allowed.includes(m.modality) && !m.is_inferred_from_family);
|
|
789
|
+
if (!hasMatching) {
|
|
790
|
+
ctx.addIssue({
|
|
791
|
+
code: "custom",
|
|
792
|
+
message: `drug molecule_type "${moleculeType}" has no matching enumerated modality row`,
|
|
793
|
+
path: ["modalities"],
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}));
|
|
798
|
+
// Discovery trial row with required relevance_basis discriminator
|
|
799
|
+
export const DiscoveryTrialRowV4Schema = z
|
|
800
|
+
.object({
|
|
801
|
+
nct_id: z.string(),
|
|
802
|
+
title: z.string(),
|
|
803
|
+
phase: z.string().nullable().optional(),
|
|
804
|
+
status: z.string().optional(),
|
|
805
|
+
conditions: z.array(z.string()),
|
|
806
|
+
start_date: z.string().optional(),
|
|
807
|
+
completion_date: z.string().optional(),
|
|
808
|
+
match_confidence: z.enum(["high", "medium", "low"]),
|
|
809
|
+
relevance_basis: z.discriminatedUnion("kind", [
|
|
810
|
+
z.object({
|
|
811
|
+
kind: z.literal("drug_in_class_match"),
|
|
812
|
+
drug_id: z.string(),
|
|
813
|
+
matched_term: z.string().optional(),
|
|
814
|
+
}),
|
|
815
|
+
z.object({ kind: z.literal("title_keyword"), matched_term: z.string() }),
|
|
816
|
+
z.object({ kind: z.literal("condition_match"), matched_term: z.string().optional() }),
|
|
817
|
+
z.object({ kind: z.literal("manual") }),
|
|
818
|
+
]),
|
|
819
|
+
})
|
|
820
|
+
.superRefine((v, ctx) => {
|
|
821
|
+
// Low-confidence rows that only match by condition (no drug link) are unreliable;
|
|
822
|
+
// collector must drop them rather than emitting them.
|
|
823
|
+
if (v.match_confidence === "low" && v.relevance_basis.kind === "condition_match") {
|
|
824
|
+
ctx.addIssue({
|
|
825
|
+
code: "custom",
|
|
826
|
+
message: `low-confidence rows must not have relevance_basis.kind="condition_match" without an intervention drug match (drop at collector)`,
|
|
827
|
+
path: ["relevance_basis"],
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
});
|
|
831
|
+
// ── V4 derived sub-tree ─────────────────────────────────────────────
|
|
832
|
+
// Shape produced by computeDerivedFields(body) and validated at phase-5
|
|
833
|
+
// persist. `.strict()` rejects unknown keys to prevent accidental extras.
|
|
834
|
+
export const DerivedV4Schema = z
|
|
835
|
+
.object({
|
|
836
|
+
summary: z.object({
|
|
837
|
+
has_human_evidence: z.boolean(),
|
|
838
|
+
has_clinical_evidence: z.boolean(),
|
|
839
|
+
total_evidence_items: z.number().int().nonnegative(),
|
|
840
|
+
total_distinct_papers: z.number().int().nonnegative(),
|
|
841
|
+
total_distinct_clinical_trials: z.number().int().nonnegative(),
|
|
842
|
+
strongest_strength_label: z.string().nullable(),
|
|
843
|
+
highest_score: z.number().nullable(),
|
|
844
|
+
highest_score_is_conflicted: z.boolean(),
|
|
845
|
+
}),
|
|
846
|
+
risk_summary: z.object({
|
|
847
|
+
any_fatal_signal: z.union([z.boolean(), z.literal("unknown")]),
|
|
848
|
+
highest_risk_organ: z.string().nullable(),
|
|
849
|
+
off_target_safety_target_hits: z.number().int().nonnegative(),
|
|
850
|
+
class_liability_count: z.number().int().nonnegative(),
|
|
851
|
+
}),
|
|
852
|
+
liability_summary: z.object({
|
|
853
|
+
counts: z.object({
|
|
854
|
+
class_liability_count: z.number().int().nonnegative(),
|
|
855
|
+
safety_target_off_target_count: z.number().int().nonnegative(),
|
|
856
|
+
off_tissue_risk_organ_count: z.number().int().nonnegative(),
|
|
857
|
+
}),
|
|
858
|
+
expression_breadth: z.object({
|
|
859
|
+
total_assessed_tissues: z.number().int().nonnegative(),
|
|
860
|
+
high_expression_tissue_count: z.number().int().nonnegative(),
|
|
861
|
+
}),
|
|
862
|
+
same_class_drug_count: z.number().int().nonnegative(),
|
|
863
|
+
safety_data_sources_checked: z.number().int().nonnegative(),
|
|
864
|
+
}),
|
|
865
|
+
organ_rollup_completeness: z
|
|
866
|
+
.object({
|
|
867
|
+
expected_organs: z.array(z.string()),
|
|
868
|
+
present_organs: z.array(z.string()),
|
|
869
|
+
missing_organs: z.array(z.string()),
|
|
870
|
+
})
|
|
871
|
+
.refine((v) => v.missing_organs.length === 0, {
|
|
872
|
+
message: "missing_organs must be empty for the dossier to ship",
|
|
873
|
+
path: ["missing_organs"],
|
|
874
|
+
}),
|
|
875
|
+
})
|
|
876
|
+
.strict();
|
|
877
|
+
// ── §4.5 Discovery trials ───────────────────────────────────────────
|
|
878
|
+
export const DiscoveryTrialRowSchema = ClinicalTrialRowSchema.extend({
|
|
879
|
+
match_confidence: z.enum(["high", "medium", "low", "off_target"]),
|
|
880
|
+
});
|
|
881
|
+
export const DiscoveryTrialsSchema = withCoverage(z.object({
|
|
882
|
+
rows: z.array(DiscoveryTrialRowV4Schema),
|
|
883
|
+
related_target_trials: z
|
|
884
|
+
.array(ClinicalTrialRowSchema.extend({
|
|
885
|
+
match_confidence: z.literal("off_target"),
|
|
886
|
+
}))
|
|
887
|
+
.optional(),
|
|
888
|
+
related_receptor: z.string().optional(),
|
|
889
|
+
}));
|
|
890
|
+
// ── §1.0 Executive recommendation (v2) ──────────────────────────────
|
|
891
|
+
export const ExecutiveRecommendationDataSchema = z.object({
|
|
892
|
+
disposition: z.enum(["pursue", "conditional", "de_prioritize", "insufficient_evidence"]),
|
|
893
|
+
confidence: z.enum(["high", "medium", "low"]),
|
|
894
|
+
rationale: z.string(),
|
|
895
|
+
key_strengths: z.array(z.string()).max(8).default([]),
|
|
896
|
+
key_risks: z.array(z.string()).max(8).default([]),
|
|
897
|
+
key_risks_dropped: z
|
|
898
|
+
.array(z.object({
|
|
899
|
+
text: z.string(),
|
|
900
|
+
reason: z.string(),
|
|
901
|
+
cited_pmid: z.string().optional(),
|
|
902
|
+
}))
|
|
903
|
+
.optional(),
|
|
904
|
+
// Deprecated; kept for one release for backward compat with previously
|
|
905
|
+
// persisted dossiers. New writes use `key_risks_dropped`. v5 will remove.
|
|
906
|
+
key_risks_downgraded: z
|
|
907
|
+
.array(z.object({
|
|
908
|
+
bullet_index: z.number().int().nonnegative(),
|
|
909
|
+
reason: z.string(),
|
|
910
|
+
cited_pmid: z.string().optional(),
|
|
911
|
+
}))
|
|
912
|
+
.optional(),
|
|
913
|
+
modality_choice: z.object({
|
|
914
|
+
modality: z.string(),
|
|
915
|
+
rationale: z.string(),
|
|
916
|
+
}),
|
|
917
|
+
coverage_qualifier: z.object({
|
|
918
|
+
sections_consulted: z.array(z.string()).default([]),
|
|
919
|
+
sections_unavailable: z.array(z.string()).default([]),
|
|
920
|
+
note: z.string(),
|
|
921
|
+
unverified_bullets: z
|
|
922
|
+
.array(z.object({
|
|
923
|
+
text: z.string(),
|
|
924
|
+
bullet_category: z.string(),
|
|
925
|
+
surface: z.literal("organ_claim_without_probe_pass"),
|
|
926
|
+
}))
|
|
927
|
+
.optional(),
|
|
928
|
+
}),
|
|
929
|
+
});
|
|
930
|
+
export const ExecutiveRecommendationSchema = withCoverage(ExecutiveRecommendationDataSchema);
|
|
931
|
+
// ── §4.6 Synthesis diagnostics (v2) ─────────────────────────────────
|
|
932
|
+
export const SynthesisDiagnosticRowSchema = z.object({
|
|
933
|
+
step_id: z.enum(["liability-bullets", "safety-flags-trail", "translational-commentary", "dossier-recommendation"]),
|
|
934
|
+
model_id: z.string(),
|
|
935
|
+
attempt_count: z.number().int().min(1).max(2),
|
|
936
|
+
retry_critique: z.string().nullable(),
|
|
937
|
+
output_chars: z.number().int().nonnegative(),
|
|
938
|
+
probe_verdict: z.enum([
|
|
939
|
+
"pass",
|
|
940
|
+
"fail-length",
|
|
941
|
+
"fail-section-references",
|
|
942
|
+
"fail-key-strengths-risks",
|
|
943
|
+
"fail-source-references",
|
|
944
|
+
"fail-numeric-claim",
|
|
945
|
+
"fail-voice",
|
|
946
|
+
"relaxed",
|
|
947
|
+
"skipped",
|
|
948
|
+
]),
|
|
949
|
+
final_coverage: z.enum(["available", "queried_no_data"]),
|
|
950
|
+
error_kind: z.enum(["synthesis-too-shallow", "synthesis-unavailable", "voice-violation"]).nullable().optional(),
|
|
951
|
+
error_message: z.string().nullable().optional(),
|
|
952
|
+
});
|
|
953
|
+
export const SynthesisDiagnosticsSchema = withCoverage(z.object({ rows: z.array(SynthesisDiagnosticRowSchema) }));
|
|
954
|
+
// ── §4.7 Recommendation citation audit ──────────────────────────────
|
|
955
|
+
export const RecommendationAuditEntrySchema = z.union([
|
|
956
|
+
z.object({
|
|
957
|
+
surface: z.enum(["rationale", "key_strengths", "key_risks", "modality_choice"]),
|
|
958
|
+
path: z.string(),
|
|
959
|
+
excerpt: z.string(),
|
|
960
|
+
}),
|
|
961
|
+
z.object({
|
|
962
|
+
surface: z.literal("external_missing"),
|
|
963
|
+
id: z.string(),
|
|
964
|
+
excerpt: z.string(),
|
|
965
|
+
}),
|
|
966
|
+
z.object({
|
|
967
|
+
surface: z.literal("organ_claim_without_probe_pass"),
|
|
968
|
+
excerpt: z.string(),
|
|
969
|
+
bullet_category: z.string(),
|
|
970
|
+
}),
|
|
971
|
+
z.object({
|
|
972
|
+
surface: z.literal("nct_wrong_class"),
|
|
973
|
+
id: z.string(),
|
|
974
|
+
excerpt: z.string(),
|
|
975
|
+
}),
|
|
976
|
+
z.object({
|
|
977
|
+
surface: z.literal("pmid_not_in_key_papers"),
|
|
978
|
+
id: z.string(),
|
|
979
|
+
excerpt: z.string(),
|
|
980
|
+
}),
|
|
981
|
+
z.object({
|
|
982
|
+
surface: z.literal("direction_mismatch"),
|
|
983
|
+
pmid: z.string(),
|
|
984
|
+
excerpt: z.string(),
|
|
985
|
+
paper_conclusion_direction: z.enum(["supports", "contradicts", "ambiguous"]).optional(),
|
|
986
|
+
}),
|
|
987
|
+
z.object({
|
|
988
|
+
surface: z.literal("abstract_unavailable"),
|
|
989
|
+
pmid: z.string(),
|
|
990
|
+
excerpt: z.string(),
|
|
991
|
+
}),
|
|
992
|
+
z.object({
|
|
993
|
+
surface: z.literal("off_topic_citation"),
|
|
994
|
+
pmid: z.string(),
|
|
995
|
+
excerpt: z.string(),
|
|
996
|
+
}),
|
|
997
|
+
]);
|
|
998
|
+
export const RecommendationAuditSchema = withCoverage(z.object({
|
|
999
|
+
citations_total: z.number().int().nonnegative(),
|
|
1000
|
+
citations_unresolved: z.array(RecommendationAuditEntrySchema),
|
|
1001
|
+
non_dossier_citations: z.array(z.object({ token: z.string(), source: z.string() })),
|
|
1002
|
+
}));
|
|
1003
|
+
// ── Top-level Dossier ───────────────────────────────────────────────
|
|
1004
|
+
//
|
|
1005
|
+
// `DossierSchema` is a single v3 shape. No backwards-compatibility union.
|
|
1006
|
+
// Old v1/v2 persisted rows will not parse; that is intentional.
|
|
1007
|
+
const ReferenceBiologyShape = z.object({
|
|
1008
|
+
therapeutic_area_associations: DiseaseAssociationsSchema,
|
|
1009
|
+
molecular_interactions: MolecularInteractionsSchema,
|
|
1010
|
+
biomarker_potential: BiomarkerPotentialSchema,
|
|
1011
|
+
genetic_alterations: GeneticAlterationsSchema,
|
|
1012
|
+
resistance_evidence: ResistanceEvidenceSchema,
|
|
1013
|
+
combination_evidence: CombinationEvidenceSchema,
|
|
1014
|
+
pathway_context: PathwayContextSchema,
|
|
1015
|
+
ppi_network: PpiNetworkSchema,
|
|
1016
|
+
normal_tissue_expression: NormalTissueExpressionSchema,
|
|
1017
|
+
preclinical: PreclinicalProfileSchema,
|
|
1018
|
+
key_papers: KeyPapersSchema,
|
|
1019
|
+
});
|
|
1020
|
+
const AnalyticsShape = z.object({
|
|
1021
|
+
evidence_conflicts: EvidenceConflictsSchema,
|
|
1022
|
+
evidence_timeline: EvidenceTimelineSchema,
|
|
1023
|
+
translational_chain: TranslationalChainSchema,
|
|
1024
|
+
additional_evidence: AdditionalEvidenceSchema,
|
|
1025
|
+
discovery_trials: DiscoveryTrialsSchema,
|
|
1026
|
+
synthesis_diagnostics: SynthesisDiagnosticsSchema,
|
|
1027
|
+
recommendation_audit: RecommendationAuditSchema.optional(),
|
|
1028
|
+
});
|
|
1029
|
+
const DossierCommonShape = {
|
|
1030
|
+
generated_at: z.string(),
|
|
1031
|
+
entity: EntitySchema,
|
|
1032
|
+
summary: SummarySchema,
|
|
1033
|
+
liability_summary: LiabilitySummarySchema,
|
|
1034
|
+
tractability: TractabilitySchema,
|
|
1035
|
+
indications: IndicationsSchema,
|
|
1036
|
+
drug_interactions: DrugInteractionsSchema,
|
|
1037
|
+
clinical_development: ClinicalDevelopmentSchema,
|
|
1038
|
+
safety_profile: SafetyProfileSchema,
|
|
1039
|
+
off_tissue_risk: OffTissueRiskSchema,
|
|
1040
|
+
off_target_panel: withCoverage(z.object({ rows: z.array(OffTargetRowSchema) })),
|
|
1041
|
+
reference_biology: ReferenceBiologyShape,
|
|
1042
|
+
};
|
|
1043
|
+
export const DossierSchema = z.object({
|
|
1044
|
+
schema_version: z.literal("3"),
|
|
1045
|
+
...DossierCommonShape,
|
|
1046
|
+
analytics: AnalyticsShape,
|
|
1047
|
+
executive_recommendation: ExecutiveRecommendationSchema,
|
|
1048
|
+
});
|
|
1049
|
+
// ── V4 section wrappers ─────────────────────────────────────────────
|
|
1050
|
+
// OrganRiskRow V4 — extends v3 with a richer organ enum
|
|
1051
|
+
export const OrganRiskRowV4Schema = OrganRiskRowSchema.extend({
|
|
1052
|
+
organ: z.enum([
|
|
1053
|
+
"cardiac",
|
|
1054
|
+
"hepatic",
|
|
1055
|
+
"cns",
|
|
1056
|
+
"renal",
|
|
1057
|
+
"gi",
|
|
1058
|
+
"pancreas",
|
|
1059
|
+
"endocrine_thyroid",
|
|
1060
|
+
"metabolic",
|
|
1061
|
+
"hematologic",
|
|
1062
|
+
"immune",
|
|
1063
|
+
"respiratory",
|
|
1064
|
+
"reproductive",
|
|
1065
|
+
"dermatologic",
|
|
1066
|
+
"musculoskeletal",
|
|
1067
|
+
"oncology",
|
|
1068
|
+
]),
|
|
1069
|
+
});
|
|
1070
|
+
// Liability bullets removed post-synthesis because they cited a PMID the
|
|
1071
|
+
// direction-of-effect auditor found contradicts the bullet's framing.
|
|
1072
|
+
// Mirrors `executive_recommendation.key_risks_dropped` — the dropped
|
|
1073
|
+
// content is preserved with the reason for an audit trail.
|
|
1074
|
+
export const LiabilityBulletDroppedSchema = LiabilityBulletSchema.extend({
|
|
1075
|
+
reason: z.string(),
|
|
1076
|
+
cited_pmid: z.string().optional(),
|
|
1077
|
+
});
|
|
1078
|
+
// LiabilitySummaryV4Schema — strict() rejects derived counter keys that moved to derived sub-tree
|
|
1079
|
+
export const LiabilitySummaryV4Schema = z
|
|
1080
|
+
.object({
|
|
1081
|
+
liability_bullets: z.array(LiabilityBulletSchema),
|
|
1082
|
+
liability_bullets_dropped: z.array(LiabilityBulletDroppedSchema).optional(),
|
|
1083
|
+
modality_recommendation: z.string().nullable(),
|
|
1084
|
+
same_class_drug_count: z.number().int().nonnegative(),
|
|
1085
|
+
inferred_therapeutic_area: z.string().nullable(),
|
|
1086
|
+
no_liabilities_disclosure: z.string().optional(),
|
|
1087
|
+
})
|
|
1088
|
+
.strict();
|
|
1089
|
+
// ClinicalDevelopmentV4Schema — swaps in V4 outcome and failed-trial rows
|
|
1090
|
+
export const ClinicalDevelopmentV4Schema = z.object({
|
|
1091
|
+
trials: withCoverage(z.object({
|
|
1092
|
+
rows: z.array(ClinicalTrialRowSchema),
|
|
1093
|
+
selection_criteria: z
|
|
1094
|
+
.object({
|
|
1095
|
+
derived_from: z.string().optional(),
|
|
1096
|
+
min_confidence: z.string().optional(),
|
|
1097
|
+
excluded_off_target_count: z.number().int().nonnegative().optional(),
|
|
1098
|
+
})
|
|
1099
|
+
.optional(),
|
|
1100
|
+
})),
|
|
1101
|
+
outcomes: withCoverage(z.object({ rows: z.array(TrialOutcomeRowV4Schema) })),
|
|
1102
|
+
failed_trials: withCoverage(z.object({ rows: z.array(FailedTrialRowV4Schema) })),
|
|
1103
|
+
benchmarks: ClinicalBenchmarksSchema,
|
|
1104
|
+
});
|
|
1105
|
+
const RegulatoryActionRowSchema = z.object({
|
|
1106
|
+
drug_chembl_id: z.string(),
|
|
1107
|
+
drug_name: z.string(),
|
|
1108
|
+
agency: z.enum(["FDA", "EMA", "MHRA", "PMDA", "Health Canada", "TGA"]),
|
|
1109
|
+
action_kind: z.enum(["referral", "withdrawal", "indication_restriction", "REMS", "black_box", "DHCP", "safety_communication", "label_warning"]),
|
|
1110
|
+
action_date: z.string(),
|
|
1111
|
+
finding: z.string(),
|
|
1112
|
+
source_url: z.string().url().optional(),
|
|
1113
|
+
source_kind: z.enum(["label_warning", "referral", "rems", "withdrawal", "boxed_warning", "safety_communication"]).optional(),
|
|
1114
|
+
application_number: z.string().optional(),
|
|
1115
|
+
label_section: z.string().optional(),
|
|
1116
|
+
source_date: z.string().optional(),
|
|
1117
|
+
evidence: EvidenceList,
|
|
1118
|
+
});
|
|
1119
|
+
// SafetyProfileV4Schema — swaps in V4 FAERS / off-target / failed-trial / OrganRiskRow
|
|
1120
|
+
export const SafetyProfileV4Schema = z.object({
|
|
1121
|
+
organ_rollup: withCoverage(z.object({ rows: z.array(OrganRiskRowV4Schema) })),
|
|
1122
|
+
faers: withCoverage(FaersSummaryV4Schema),
|
|
1123
|
+
trial_aes: withCoverage(TrialAesSchema),
|
|
1124
|
+
off_target_panel: withCoverage(OffTargetPanelV4Schema),
|
|
1125
|
+
failed_trials_safety_lens: withCoverage(z.object({ rows: z.array(FailedTrialRowV4Schema) })),
|
|
1126
|
+
class_precedent: withCoverage(ClassPrecedentSchema),
|
|
1127
|
+
target_organ_liabilities: z.array(SafetyFlagSchema),
|
|
1128
|
+
regulatory_actions: withCoverage(z.object({ rows: z.array(RegulatoryActionRowSchema) })).optional(),
|
|
1129
|
+
});
|
|
1130
|
+
// ReferenceBiologyV4Shape — swaps normal_tissue_expression for V4 version
|
|
1131
|
+
export const ReferenceBiologyV4Shape = z.object({
|
|
1132
|
+
...ReferenceBiologyShape.shape,
|
|
1133
|
+
normal_tissue_expression: withCoverage(NormalTissueExpressionV4Schema),
|
|
1134
|
+
});
|
|
1135
|
+
// ── V4 top-level DossierV4Schema ────────────────────────────────────
|
|
1136
|
+
export const DossierV4Schema = z.object({
|
|
1137
|
+
schema_version: z.literal("4"),
|
|
1138
|
+
entity: EntitySchema,
|
|
1139
|
+
generated_at: z.string(),
|
|
1140
|
+
liability_summary: LiabilitySummaryV4Schema,
|
|
1141
|
+
tractability: TractabilityV4Schema,
|
|
1142
|
+
indications: IndicationsSchema,
|
|
1143
|
+
drug_interactions: DrugInteractionsSchema,
|
|
1144
|
+
clinical_development: ClinicalDevelopmentV4Schema,
|
|
1145
|
+
safety_profile: SafetyProfileV4Schema,
|
|
1146
|
+
off_tissue_risk: OffTissueRiskSchema,
|
|
1147
|
+
off_target_panel: withCoverage(OffTargetPanelV4Schema),
|
|
1148
|
+
reference_biology: ReferenceBiologyV4Shape,
|
|
1149
|
+
analytics: AnalyticsShape,
|
|
1150
|
+
executive_recommendation: ExecutiveRecommendationSchema,
|
|
1151
|
+
derived: DerivedV4Schema,
|
|
1152
|
+
});
|
|
1153
|
+
// Body-only v4 shape: everything the Phase-4 assembler is responsible for
|
|
1154
|
+
// building, WITHOUT the derived sub-tree. Phase-5 persist computes derived
|
|
1155
|
+
// from the stamped body and validates the complete dossier against
|
|
1156
|
+
// DossierV4Schema. Keeping Phase4OutputSchema loose prevents an assembler
|
|
1157
|
+
// organ-rollup miss from surfacing as a generic workflow-error instead
|
|
1158
|
+
// of the explicit derived-invariant-violation path in phase5-persist.
|
|
1159
|
+
export const DossierV4BodySchema = DossierV4Schema.omit({ derived: true });
|
|
1160
|
+
// ── V5 evidence attribution and quality gates ────────────────────────
|
|
1161
|
+
export const ClinicalTrialAttributionBasisV5Schema = z.object({
|
|
1162
|
+
kind: z.enum([
|
|
1163
|
+
"mechanism_target_match",
|
|
1164
|
+
"known_class_drug",
|
|
1165
|
+
"therapeutic_program_match",
|
|
1166
|
+
"related_family_target",
|
|
1167
|
+
"biomarker_endpoint",
|
|
1168
|
+
"condition_only",
|
|
1169
|
+
"text_match",
|
|
1170
|
+
"manual",
|
|
1171
|
+
]),
|
|
1172
|
+
source: z.string(),
|
|
1173
|
+
excerpt: z.string().optional(),
|
|
1174
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
1175
|
+
});
|
|
1176
|
+
export const ResolvedTrialInterventionV5Schema = z.object({
|
|
1177
|
+
name: z.string(),
|
|
1178
|
+
intervention_type: z.string().nullable().optional(),
|
|
1179
|
+
chembl_id: z.string().nullable().optional(),
|
|
1180
|
+
therapeutic_program_id: z.string().nullable().optional(),
|
|
1181
|
+
target_uniprots: z.array(z.string()).default([]),
|
|
1182
|
+
resolver_source: z.string(),
|
|
1183
|
+
});
|
|
1184
|
+
export const ClinicalTrialAttributionV5Schema = z
|
|
1185
|
+
.object({
|
|
1186
|
+
relationship: z.enum([
|
|
1187
|
+
"direct_modulator",
|
|
1188
|
+
"class_modulator",
|
|
1189
|
+
"related_family_target",
|
|
1190
|
+
"target_biomarker",
|
|
1191
|
+
"pathway_biomarker",
|
|
1192
|
+
"condition_only",
|
|
1193
|
+
"unrelated",
|
|
1194
|
+
"unknown",
|
|
1195
|
+
]),
|
|
1196
|
+
evidence_role: z.enum(["supports_target", "contextual", "excluded"]),
|
|
1197
|
+
basis: z.array(ClinicalTrialAttributionBasisV5Schema).min(1),
|
|
1198
|
+
resolved_interventions: z.array(ResolvedTrialInterventionV5Schema).default([]),
|
|
1199
|
+
exclusion_reason: z.string().optional(),
|
|
1200
|
+
})
|
|
1201
|
+
.superRefine((v, ctx) => {
|
|
1202
|
+
if (v.evidence_role !== "supports_target" && !v.exclusion_reason) {
|
|
1203
|
+
ctx.addIssue({
|
|
1204
|
+
code: "custom",
|
|
1205
|
+
message: "contextual/excluded trial evidence requires exclusion_reason",
|
|
1206
|
+
path: ["exclusion_reason"],
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
if (v.evidence_role === "supports_target" && v.relationship !== "direct_modulator" && v.relationship !== "class_modulator") {
|
|
1210
|
+
ctx.addIssue({
|
|
1211
|
+
code: "custom",
|
|
1212
|
+
message: "supports_target evidence must be direct_modulator or class_modulator",
|
|
1213
|
+
path: ["relationship"],
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
export const ClinicalTrialRowV5Schema = ClinicalTrialRowSchema.extend({
|
|
1218
|
+
attribution: ClinicalTrialAttributionV5Schema,
|
|
1219
|
+
eligible_for_toxicology_aggregation: z.boolean(),
|
|
1220
|
+
});
|
|
1221
|
+
export const FailedTrialRowV5Schema = FailedTrialRowV4Schema.extend({
|
|
1222
|
+
attribution: ClinicalTrialAttributionV5Schema,
|
|
1223
|
+
eligible_for_toxicology_aggregation: z.boolean(),
|
|
1224
|
+
});
|
|
1225
|
+
export const TrialOutcomeRowV5Schema = TrialOutcomeRowV4Schema.extend({
|
|
1226
|
+
attribution: ClinicalTrialAttributionV5Schema.optional(),
|
|
1227
|
+
eligible_for_toxicology_aggregation: z.boolean().default(false),
|
|
1228
|
+
});
|
|
1229
|
+
export const ClinicalDevelopmentV5Schema = z.object({
|
|
1230
|
+
trials: withCoverage(z.object({
|
|
1231
|
+
rows: z.array(ClinicalTrialRowV5Schema),
|
|
1232
|
+
excluded_rows: z.array(ClinicalTrialRowV5Schema).default([]),
|
|
1233
|
+
selection_criteria: z
|
|
1234
|
+
.object({
|
|
1235
|
+
derived_from: z.string().optional(),
|
|
1236
|
+
min_confidence: z.string().optional(),
|
|
1237
|
+
excluded_off_target_count: z.number().int().nonnegative().optional(),
|
|
1238
|
+
})
|
|
1239
|
+
.optional(),
|
|
1240
|
+
})),
|
|
1241
|
+
outcomes: withCoverage(z.object({ rows: z.array(TrialOutcomeRowV5Schema) })),
|
|
1242
|
+
failed_trials: withCoverage(z.object({
|
|
1243
|
+
rows: z.array(FailedTrialRowV5Schema),
|
|
1244
|
+
excluded_rows: z.array(FailedTrialRowV5Schema).default([]),
|
|
1245
|
+
})),
|
|
1246
|
+
benchmarks: ClinicalBenchmarksSchema,
|
|
1247
|
+
});
|
|
1248
|
+
export const RegulatoryActionRowV5Schema = RegulatoryActionRowSchema.extend({
|
|
1249
|
+
action_kind: z.enum(["referral", "withdrawal", "indication_restriction", "REMS", "black_box", "DHCP", "safety_communication", "label_warning"]),
|
|
1250
|
+
source_kind: z.enum(["label_warning", "referral", "rems", "withdrawal", "boxed_warning", "safety_communication"]),
|
|
1251
|
+
application_number: z.string().optional(),
|
|
1252
|
+
label_section: z.string().optional(),
|
|
1253
|
+
source_date: z.string().optional(),
|
|
1254
|
+
}).superRefine((v, ctx) => {
|
|
1255
|
+
if (v.source_kind === "label_warning" && v.action_kind === "safety_communication") {
|
|
1256
|
+
ctx.addIssue({
|
|
1257
|
+
code: "custom",
|
|
1258
|
+
message: "FDA label warnings must not be represented as action_kind:safety_communication",
|
|
1259
|
+
path: ["action_kind"],
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
});
|
|
1263
|
+
export const SafetyProfileV5Schema = SafetyProfileV4Schema.extend({
|
|
1264
|
+
regulatory_actions: withCoverage(z.object({ rows: z.array(RegulatoryActionRowV5Schema) })).optional(),
|
|
1265
|
+
});
|
|
1266
|
+
export const QualityGateStatusSchema = z.object({
|
|
1267
|
+
gate_id: z.string(),
|
|
1268
|
+
status: z.enum(["pass", "warning", "blocked"]),
|
|
1269
|
+
message: z.string(),
|
|
1270
|
+
affected_sections: z.array(z.string()).default([]),
|
|
1271
|
+
unresolved_count: z.number().int().nonnegative().optional(),
|
|
1272
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
1273
|
+
});
|
|
1274
|
+
export const QualityGatesSchema = withCoverage(z.object({ rows: z.array(QualityGateStatusSchema) }));
|
|
1275
|
+
export const DiscoveryTrialRowV5Schema = DiscoveryTrialRowV4Schema.extend({
|
|
1276
|
+
attribution: ClinicalTrialAttributionV5Schema,
|
|
1277
|
+
eligible_for_toxicology_aggregation: z.boolean(),
|
|
1278
|
+
});
|
|
1279
|
+
export const DiscoveryTrialsV5Schema = withCoverage(z.object({
|
|
1280
|
+
rows: z.array(DiscoveryTrialRowV5Schema),
|
|
1281
|
+
excluded_rows: z.array(DiscoveryTrialRowV5Schema).default([]),
|
|
1282
|
+
}));
|
|
1283
|
+
const AnalyticsV5Shape = AnalyticsShape.extend({
|
|
1284
|
+
discovery_trials: DiscoveryTrialsV5Schema,
|
|
1285
|
+
quality_gates: QualityGatesSchema,
|
|
1286
|
+
recommendation_audit: RecommendationAuditSchema.optional(),
|
|
1287
|
+
});
|
|
1288
|
+
export const DossierV5Schema = z.object({
|
|
1289
|
+
schema_version: z.literal("5"),
|
|
1290
|
+
entity: EntitySchema,
|
|
1291
|
+
generated_at: z.string(),
|
|
1292
|
+
liability_summary: LiabilitySummaryV4Schema,
|
|
1293
|
+
tractability: TractabilityV4Schema,
|
|
1294
|
+
indications: IndicationsSchema,
|
|
1295
|
+
drug_interactions: DrugInteractionsSchema,
|
|
1296
|
+
clinical_development: ClinicalDevelopmentV5Schema,
|
|
1297
|
+
safety_profile: SafetyProfileV5Schema,
|
|
1298
|
+
off_tissue_risk: OffTissueRiskSchema,
|
|
1299
|
+
off_target_panel: withCoverage(OffTargetPanelV4Schema),
|
|
1300
|
+
reference_biology: ReferenceBiologyV4Shape,
|
|
1301
|
+
analytics: AnalyticsV5Shape,
|
|
1302
|
+
executive_recommendation: ExecutiveRecommendationSchema,
|
|
1303
|
+
derived: DerivedV4Schema,
|
|
1304
|
+
});
|
|
1305
|
+
export const DossierV5BodySchema = DossierV5Schema.omit({ derived: true });
|
|
1306
|
+
// Retain the v3 export under a legacy alias for any code that still reads
|
|
1307
|
+
// persisted v3 dossiers (phase4-assemble, tests, integration).
|
|
1308
|
+
export const DossierSchemaV3Legacy = z.object({
|
|
1309
|
+
schema_version: z.literal("3"),
|
|
1310
|
+
...DossierCommonShape,
|
|
1311
|
+
analytics: AnalyticsShape,
|
|
1312
|
+
executive_recommendation: ExecutiveRecommendationSchema,
|
|
1313
|
+
});
|
|
1314
|
+
// ── Type guards ─────────────────────────────────────────────────────
|
|
1315
|
+
export function isDossier(value) {
|
|
1316
|
+
return DossierV5Schema.safeParse(value).success;
|
|
1317
|
+
}
|
|
1318
|
+
/** JSON Schema export for runtime validation in non-TS environments. */
|
|
1319
|
+
export function dossierJsonSchema() {
|
|
1320
|
+
return z.toJSONSchema(DossierV5Schema);
|
|
1321
|
+
}
|
|
1322
|
+
// ── Progress events ─────────────────────────────────────────────────
|
|
1323
|
+
export const TargetAssessmentPhaseSchema = z.enum([
|
|
1324
|
+
"resolving",
|
|
1325
|
+
"collecting",
|
|
1326
|
+
"deciding",
|
|
1327
|
+
"fanning_out",
|
|
1328
|
+
"assembling",
|
|
1329
|
+
"synthesizing",
|
|
1330
|
+
"completed",
|
|
1331
|
+
"failed",
|
|
1332
|
+
"suspended",
|
|
1333
|
+
]);
|
|
1334
|
+
export const TargetAssessmentProgressEventSchema = z.object({
|
|
1335
|
+
phase: TargetAssessmentPhaseSchema,
|
|
1336
|
+
message: z.string(),
|
|
1337
|
+
percent: z.number().min(0).max(100),
|
|
1338
|
+
at: z.string(),
|
|
1339
|
+
});
|