@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,835 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase-4 deterministic assemblers.
|
|
3
|
+
*
|
|
4
|
+
* Each assembler maps Phase-1 / Phase-2 / Phase-3 outputs onto the
|
|
5
|
+
* corresponding dossier section schema. Coverage is honored end-to-end:
|
|
6
|
+
* when an upstream came back `queried_no_data` or the derived row set is
|
|
7
|
+
* empty, the section is marked `queried_no_data` / `not_loaded` rather
|
|
8
|
+
* than fabricated. Aggregate rows preserve their contributing evidence
|
|
9
|
+
* under `evidence: [...]` arrays.
|
|
10
|
+
*/
|
|
11
|
+
import { inferTherapeuticArea, getBenchmarks, getDatasetAttribution } from "../../../tools/lib/clinical-benchmarks-client.js";
|
|
12
|
+
import { inferModalityFromFamily } from "../../../tools/lib/protein-family-modality.js";
|
|
13
|
+
import { resolveFamilySiblingUniprots, resolveOnTargetChemblIds } from "../lib/target-identity-filter.js";
|
|
14
|
+
import { getDrugPrimaryTargetUniprots } from "../../../tools/lib/chembl-client.js";
|
|
15
|
+
import { annotateOffTargetPanel } from "../lib/clinical-consequence-annotator.js";
|
|
16
|
+
import { coverageFromRows } from "../coverage.js";
|
|
17
|
+
import { fetchRegulatoryActions } from "../lib/regulatory-actions.js";
|
|
18
|
+
import { HIGH_EXPRESSION_TPM_THRESHOLD } from "../lib/expression-constants.js";
|
|
19
|
+
export { HIGH_EXPRESSION_TPM_THRESHOLD };
|
|
20
|
+
import { resolveModulatorMoleculeType } from "../lib/dedup-modulators.js";
|
|
21
|
+
import { searchFailedTrialsForDrugNames } from "../../../tools/lib/clinical-trials-client.js";
|
|
22
|
+
import { aggregateFaersAcrossModulators, aggregateTrialAes, aggregateOffTargetPanel, aggregateClassPrecedent, buildOrganRollup, assembleDrugInteractions, assembleLiabilitySummary, meetsTpmFloor, isSafetyRelevant, } from "./safety.js";
|
|
23
|
+
import { assemblePreclinicalLiterature, assembleKoSupportingLiterature, tallyInternalReferences, assembleKeyPapers, assembleEvidenceTimeline, assembleTranslationalChain, assembleMolecularInteractions, assembleBiomarkerPotential, assembleResistanceEvidence, assembleCombinationEvidence, assembleEvidenceConflicts, assembleAdditionalEvidence, isSelfReference, isClinicalMeasurement, indicationCompositeScore, partitionTrialsByAttribution, classifyClinicalTrialConfidence, assembleDiscoveryTrials, dedupePpiPartners, } from "./literature.js";
|
|
24
|
+
import { buildTrialOutcomeFilter, aggregateTrialOutcomes } from "./trials.js";
|
|
25
|
+
import { buildFailureCategoryDiscriminated } from "./literature.js";
|
|
26
|
+
const NOT_LOADED_PHASE5 = "Phase 5 synthesis not yet implemented";
|
|
27
|
+
// Order matches evidence-priority rank: genetic > known_drug > animal_model > somatic > literature.
|
|
28
|
+
function makeAssociationEvidence(a) {
|
|
29
|
+
const out = [];
|
|
30
|
+
if (a.geneticAssociationScore != null) {
|
|
31
|
+
out.push({
|
|
32
|
+
source: "opentargets:genetic_association",
|
|
33
|
+
score: a.geneticAssociationScore,
|
|
34
|
+
predicate: "associated_with",
|
|
35
|
+
is_human: true,
|
|
36
|
+
metadata: { disease_id: a.diseaseId },
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (a.knownDrugScore != null) {
|
|
40
|
+
out.push({
|
|
41
|
+
source: "opentargets:known_drug",
|
|
42
|
+
score: a.knownDrugScore,
|
|
43
|
+
predicate: "therapeutic_target",
|
|
44
|
+
is_human: true,
|
|
45
|
+
is_clinical: true,
|
|
46
|
+
metadata: { disease_id: a.diseaseId },
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (a.animalModelScore != null) {
|
|
50
|
+
out.push({
|
|
51
|
+
source: "opentargets:animal_model",
|
|
52
|
+
score: a.animalModelScore,
|
|
53
|
+
predicate: "validated_in_animal_model",
|
|
54
|
+
metadata: { disease_id: a.diseaseId },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (a.somaticMutationScore != null) {
|
|
58
|
+
out.push({
|
|
59
|
+
source: "opentargets:somatic_mutation",
|
|
60
|
+
score: a.somaticMutationScore,
|
|
61
|
+
predicate: "somatic_mutation_associated",
|
|
62
|
+
is_human: true,
|
|
63
|
+
metadata: { disease_id: a.diseaseId },
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (a.literatureScore != null) {
|
|
67
|
+
out.push({
|
|
68
|
+
source: "opentargets:literature",
|
|
69
|
+
score: a.literatureScore,
|
|
70
|
+
predicate: "literature_co_occurrence",
|
|
71
|
+
metadata: { disease_id: a.diseaseId },
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
// ── Section assemblers ───────────────────────────────────────────────
|
|
77
|
+
export function assembleEntity(resolved) {
|
|
78
|
+
return {
|
|
79
|
+
canonicalId: resolved.canonicalId,
|
|
80
|
+
symbol: resolved.geneSymbol,
|
|
81
|
+
displayName: resolved.approvedName,
|
|
82
|
+
entityType: "gene",
|
|
83
|
+
ontology: resolved.canonicalOntology === "hgnc" ? "HGNC" : "Ensembl",
|
|
84
|
+
identifiers: {
|
|
85
|
+
hgnc: resolved.ids.hgnc ?? undefined,
|
|
86
|
+
ensembl: resolved.ids.ensembl ?? undefined,
|
|
87
|
+
uniprot: resolved.ids.uniprot ?? undefined,
|
|
88
|
+
chembl: resolved.ids.chembl ?? undefined,
|
|
89
|
+
ncbiGene: resolved.ids.entrez ?? undefined,
|
|
90
|
+
},
|
|
91
|
+
synonyms: resolved.synonyms,
|
|
92
|
+
proteinFamily: resolved.proteinFamily ?? undefined,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// Maps ChEMBL molecule_type (lowercase) to the tractability modality bucket.
|
|
96
|
+
const MOLECULE_TYPE_TO_MODALITY = {
|
|
97
|
+
"small molecule": "small_molecule",
|
|
98
|
+
antibody: "antibody",
|
|
99
|
+
"antibody-drug conjugate": "antibody",
|
|
100
|
+
protein: "other_clinical",
|
|
101
|
+
peptide: "other_clinical",
|
|
102
|
+
enzyme: "other_clinical",
|
|
103
|
+
};
|
|
104
|
+
function normalizeDrugMoleculeType(drug) {
|
|
105
|
+
const name = (drug.drug_name ?? "").trim().toUpperCase();
|
|
106
|
+
// SMC021 is oral salmon calcitonin, not a non-peptide small molecule. Some
|
|
107
|
+
// source paths can describe the formulation as oral and accidentally leave a
|
|
108
|
+
// small-molecule annotation downstream; keep the therapeutic substance class.
|
|
109
|
+
if (name === "SMC021" || name.includes("SALMON CALCITONIN") || name.includes("CALCITONIN SALMON")) {
|
|
110
|
+
return "Peptide";
|
|
111
|
+
}
|
|
112
|
+
return drug.molecule_type;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Pure helper that flips `has_approved_drug=true` and populates
|
|
116
|
+
* `approved_drug_ids` on any modality that has a max_phase=4 drug in
|
|
117
|
+
* the provided list. Unrecognised molecule_types are silently ignored.
|
|
118
|
+
*/
|
|
119
|
+
export function enrichTractabilityModalitiesWithApprovals(modalities, drugs) {
|
|
120
|
+
const approvedByModality = new Map();
|
|
121
|
+
for (const d of drugs) {
|
|
122
|
+
if ((d.max_phase ?? 0) < 4)
|
|
123
|
+
continue;
|
|
124
|
+
const mod = MOLECULE_TYPE_TO_MODALITY[(normalizeDrugMoleculeType(d) ?? "").toLowerCase()];
|
|
125
|
+
if (!mod)
|
|
126
|
+
continue;
|
|
127
|
+
const arr = approvedByModality.get(mod) ?? [];
|
|
128
|
+
arr.push(d.drug_id);
|
|
129
|
+
approvedByModality.set(mod, arr);
|
|
130
|
+
}
|
|
131
|
+
return modalities.map((m) => {
|
|
132
|
+
const ids = approvedByModality.get(m.modality);
|
|
133
|
+
if (!ids || ids.length === 0)
|
|
134
|
+
return m;
|
|
135
|
+
return { ...m, has_approved_drug: true, approved_drug_ids: [...new Set(ids)].sort() };
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
export function assembleTractability(resolved, ot, drugs) {
|
|
139
|
+
const familyFallback = () => {
|
|
140
|
+
const fallback = inferModalityFromFamily(resolved.proteinFamily);
|
|
141
|
+
return {
|
|
142
|
+
coverage: "available",
|
|
143
|
+
data: {
|
|
144
|
+
modalities: [
|
|
145
|
+
{
|
|
146
|
+
modality: "small_molecule",
|
|
147
|
+
levels: [],
|
|
148
|
+
has_approved_drug: false,
|
|
149
|
+
has_clinical_stage: false,
|
|
150
|
+
is_inferred_from_family: true,
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
preferred_modality: fallback.preferred_modality,
|
|
154
|
+
drug_molecule_types_present: [],
|
|
155
|
+
},
|
|
156
|
+
inference_path: `family-fallback (${fallback.source}: ${fallback.family ?? "default"}) — ${fallback.rationale}`,
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
if (ot.coverage !== "available")
|
|
160
|
+
return familyFallback();
|
|
161
|
+
const t = ot.data.tractability;
|
|
162
|
+
if (!t)
|
|
163
|
+
return familyFallback();
|
|
164
|
+
const modalities = [
|
|
165
|
+
{
|
|
166
|
+
modality: "small_molecule",
|
|
167
|
+
levels: t.smallMolecule ? ["validated"] : [],
|
|
168
|
+
has_approved_drug: false,
|
|
169
|
+
has_clinical_stage: !!t.smallMolecule,
|
|
170
|
+
is_inferred_from_family: false,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
modality: "antibody",
|
|
174
|
+
levels: t.antibody ? ["validated"] : [],
|
|
175
|
+
has_approved_drug: false,
|
|
176
|
+
has_clinical_stage: !!t.antibody,
|
|
177
|
+
is_inferred_from_family: false,
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
modality: "other_clinical",
|
|
181
|
+
levels: t.otherModalities ? ["validated"] : [],
|
|
182
|
+
has_approved_drug: false,
|
|
183
|
+
has_clinical_stage: !!t.otherModalities,
|
|
184
|
+
is_inferred_from_family: false,
|
|
185
|
+
},
|
|
186
|
+
];
|
|
187
|
+
const preferred = t.smallMolecule ? "small_molecule" : t.antibody ? "antibody" : t.otherModalities ? "other_clinical" : null;
|
|
188
|
+
const modalitiesEnriched = enrichTractabilityModalitiesWithApprovals(modalities, drugs);
|
|
189
|
+
// Collect molecule types from approved/clinical drugs for the v4 field.
|
|
190
|
+
const drugMoleculeTypes = [...new Set(drugs.map((d) => d.molecule_type).filter((m) => !!m))];
|
|
191
|
+
return {
|
|
192
|
+
coverage: "available",
|
|
193
|
+
data: {
|
|
194
|
+
modalities: modalitiesEnriched,
|
|
195
|
+
preferred_modality: preferred,
|
|
196
|
+
drug_molecule_types_present: drugMoleculeTypes,
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
// ── Top-level dossier assembly ──────────────────────────────────────
|
|
201
|
+
/**
|
|
202
|
+
* Build a body-only dossier from Phase-2 (and optionally Phase-3)
|
|
203
|
+
* outputs. Synthesis-dependent fields stay `not_loaded` until Phase 5
|
|
204
|
+
* stamps them in `phase5-persist.ts`. The derived sub-tree is NOT
|
|
205
|
+
* attached here — phase5-persist computes it after synthesis is stamped
|
|
206
|
+
* so the final derived values reflect liability bullets and safety flags.
|
|
207
|
+
*/
|
|
208
|
+
export async function assembleDossier(pool, phase2, phase3, annotatorDeps) {
|
|
209
|
+
const fanout = phase3?.fanout;
|
|
210
|
+
const faersAgg = aggregateFaersAcrossModulators(fanout);
|
|
211
|
+
const trialAesAgg = aggregateTrialAes(fanout);
|
|
212
|
+
// Off-target panel needs the assessment UniProt and gene symbol: UniProt to
|
|
213
|
+
// recognise alternate ChEMBL IDs as self-hits, gene symbol to detect
|
|
214
|
+
// obligate-cofactor heterodimers (e.g., CALCR/RAMP3 = AMY3 for CALCR).
|
|
215
|
+
const assessmentUniprot = phase2.phase1.resolved.ids.uniprot ?? "";
|
|
216
|
+
const geneSymbol = phase2.phase1.resolved.geneSymbol ?? "";
|
|
217
|
+
const familyComplexesCollector = phase2.phase1.collectors.familyComplexes;
|
|
218
|
+
const familyComplexesBundle = familyComplexesCollector.coverage === "available" ? familyComplexesCollector.data : null;
|
|
219
|
+
const [onTargetChemblIds, familySiblingUniprots] = await Promise.all([
|
|
220
|
+
resolveOnTargetChemblIds(assessmentUniprot),
|
|
221
|
+
resolveFamilySiblingUniprots(assessmentUniprot || geneSymbol),
|
|
222
|
+
]);
|
|
223
|
+
const offTargetPanel = aggregateOffTargetPanel(phase2, fanout, assessmentUniprot, geneSymbol, familyComplexesBundle, onTargetChemblIds);
|
|
224
|
+
if (offTargetPanel) {
|
|
225
|
+
await annotateOffTargetPanel(pool, offTargetPanel, geneSymbol, annotatorDeps);
|
|
226
|
+
}
|
|
227
|
+
const offTargetRows = offTargetPanel?.rows ?? null;
|
|
228
|
+
const classP = aggregateClassPrecedent(phase2, fanout);
|
|
229
|
+
// Enrich modulator metadata before any downstream assembly so that
|
|
230
|
+
// tractability, drug_interactions, and class-precedent all see the same
|
|
231
|
+
// PubChem-refined molecule_type for entries that ChEMBL labelled "Unknown".
|
|
232
|
+
const chemblModsCollector = phase2.phase1.collectors.chemblModulators;
|
|
233
|
+
const enrichedModulators = chemblModsCollector.coverage === "available" ? await resolveModulatorMoleculeType(chemblModsCollector.data.modulators) : [];
|
|
234
|
+
// drugInteractionRows must be computed before buildOrganRollup so we can
|
|
235
|
+
// derive the drug IDs for regulatory_actions lookup and pass them in.
|
|
236
|
+
const drugInteractionRows = assembleDrugInteractions(phase2, enrichedModulators);
|
|
237
|
+
const regulatoryActionRows = await fetchRegulatoryActions((drugInteractionRows ?? []).map((d) => ({ chemblId: d.drug_id, name: d.drug_name })));
|
|
238
|
+
const organRollupRows = buildOrganRollup(faersAgg, trialAesAgg, offTargetRows, classP, regulatoryActionRows.length > 0 ? regulatoryActionRows : null);
|
|
239
|
+
const preclinicalLitData = assemblePreclinicalLiterature(phase2);
|
|
240
|
+
const koSupportingLiterature = assembleKoSupportingLiterature(phase2);
|
|
241
|
+
const internalRefCounts = tallyInternalReferences([
|
|
242
|
+
koSupportingLiterature,
|
|
243
|
+
...(organRollupRows ?? []).map((r) => r.evidence),
|
|
244
|
+
...(offTargetRows ?? []).map((r) => r.evidence),
|
|
245
|
+
]);
|
|
246
|
+
const keyPapersRows = assembleKeyPapers(phase2, internalRefCounts);
|
|
247
|
+
const evidenceTimeline = assembleEvidenceTimeline(phase2);
|
|
248
|
+
const translationalChain = assembleTranslationalChain(phase2);
|
|
249
|
+
const attrCtx = {
|
|
250
|
+
assessmentUniprot,
|
|
251
|
+
assessmentSymbol: phase2.phase1.resolved.geneSymbol,
|
|
252
|
+
familyUniprots: familySiblingUniprots,
|
|
253
|
+
drugTargetResolver: getDrugPrimaryTargetUniprots,
|
|
254
|
+
};
|
|
255
|
+
// Derive known class drug names from ChEMBL modulators (uppercase) for
|
|
256
|
+
// drug_in_class_match classification inside assembleDiscoveryTrials.
|
|
257
|
+
const knownClassDrugNames = new Set((drugInteractionRows ?? []).map((r) => r.drug_name.toUpperCase()));
|
|
258
|
+
// Build the attribution filter for aggregateTrialOutcomes by partitioning
|
|
259
|
+
// all ctgov trials (active + failed) with the same attribution logic used
|
|
260
|
+
// for clinical_development.trials. This drops erenumab/paralog trials from
|
|
261
|
+
// clinical_development.outcomes when their ChEMBL IDs resolve to a related
|
|
262
|
+
// receptor rather than the assessment target.
|
|
263
|
+
const trialOutcomeFilter = await buildTrialOutcomeFilter(phase2, attrCtx, knownClassDrugNames, phase2.phase1.resolved.geneSymbol);
|
|
264
|
+
const trialOutcomesRows = aggregateTrialOutcomes(fanout, trialOutcomeFilter);
|
|
265
|
+
const discoveryTrialData = await assembleDiscoveryTrials(phase2, phase2.phase1.resolved.geneSymbol, attrCtx, knownClassDrugNames);
|
|
266
|
+
const resolved = phase2.phase1.resolved;
|
|
267
|
+
const ot = phase2.phase1.collectors.opentargets;
|
|
268
|
+
const ctgov = phase2.phase1.collectors.ctgov;
|
|
269
|
+
const clinvar = phase2.phase1.collectors.clinvar;
|
|
270
|
+
const cbioportal = phase2.phase1.collectors.cbioportal;
|
|
271
|
+
const expression = phase2.phase1.collectors.expressionHuman;
|
|
272
|
+
const expressionMulti = phase2.phase1.collectors.expressionMultiSpecies;
|
|
273
|
+
const impc = phase2.phase1.collectors.impc;
|
|
274
|
+
const pubmed = phase2.phase1.collectors.pubmedIndex;
|
|
275
|
+
const pathways = phase2.phase1.collectors.pathways;
|
|
276
|
+
const ppi = phase2.phase1.collectors.stringPpi;
|
|
277
|
+
const indicationsRaw = ot.coverage === "available" ? ot.data.associations : [];
|
|
278
|
+
const filteredIndications = indicationsRaw.filter((a) => !isSelfReference(resolved.canonicalId, a.diseaseId, resolved.geneSymbol, a.diseaseName) && !isClinicalMeasurement(a.diseaseName));
|
|
279
|
+
const ta = inferTherapeuticArea(filteredIndications.map((a) => a.diseaseName));
|
|
280
|
+
const benchmarks = getBenchmarks(ta);
|
|
281
|
+
const datasetAttr = getDatasetAttribution();
|
|
282
|
+
const offTissueRows = expression.coverage === "available"
|
|
283
|
+
? expression.data.tissues
|
|
284
|
+
.filter((t) => meetsTpmFloor(t.tissueLabel, t.value ?? 0) && isSafetyRelevant(t.tissueLabel, t.organSystem))
|
|
285
|
+
.map((t) => ({
|
|
286
|
+
tissue: t.tissueLabel,
|
|
287
|
+
organ: t.organSystem ?? "unspecified",
|
|
288
|
+
tpm: t.value ?? 0,
|
|
289
|
+
}))
|
|
290
|
+
: [];
|
|
291
|
+
const drugsForTractability = enrichedModulators.map((m) => ({
|
|
292
|
+
drug_id: m.moleculeChemblId,
|
|
293
|
+
drug_name: m.preferredName,
|
|
294
|
+
molecule_type: m.moleculeType,
|
|
295
|
+
max_phase: m.maxPhase,
|
|
296
|
+
}));
|
|
297
|
+
const tractabilitySection = assembleTractability(resolved, ot, drugsForTractability);
|
|
298
|
+
const preferredModality = tractabilitySection.coverage === "available" ? tractabilitySection.data.preferred_modality : null;
|
|
299
|
+
const liabilitySummary = assembleLiabilitySummary(phase2, {
|
|
300
|
+
offTargetRows,
|
|
301
|
+
preferredModality,
|
|
302
|
+
});
|
|
303
|
+
const allRowCandidates = filteredIndications.slice(0, 50).map((a) => {
|
|
304
|
+
const sources = [
|
|
305
|
+
a.geneticAssociationScore != null ? "ot_genetics" : null,
|
|
306
|
+
a.knownDrugScore != null ? "ot_known_drug" : null,
|
|
307
|
+
a.animalModelScore != null ? "ot_animal_model" : null,
|
|
308
|
+
a.somaticMutationScore != null ? "ot_somatic_mutation" : null,
|
|
309
|
+
a.literatureScore != null ? "literature" : null,
|
|
310
|
+
].filter((s) => s !== null);
|
|
311
|
+
const evidence = makeAssociationEvidence(a);
|
|
312
|
+
return { a, sources, evidence };
|
|
313
|
+
});
|
|
314
|
+
const supportedCandidates = allRowCandidates.filter(({ sources, evidence }) => sources.length > 0 || evidence.length > 0);
|
|
315
|
+
const unsupportedCandidates = allRowCandidates.filter(({ sources, evidence }) => sources.length === 0 && evidence.length === 0);
|
|
316
|
+
const indicationRows = supportedCandidates.map(({ a, sources, evidence }) => {
|
|
317
|
+
const uniquePaperCount = a.literaturePmids?.length ?? 0;
|
|
318
|
+
const { composite, breakdown } = indicationCompositeScore(a.score, sources, uniquePaperCount);
|
|
319
|
+
return {
|
|
320
|
+
disease_id: a.diseaseId,
|
|
321
|
+
disease_name: a.diseaseName,
|
|
322
|
+
composite_score: composite,
|
|
323
|
+
composite_score_breakdown: breakdown,
|
|
324
|
+
evidence_score: a.score,
|
|
325
|
+
source_count: sources.length,
|
|
326
|
+
unique_paper_count: uniquePaperCount,
|
|
327
|
+
sources,
|
|
328
|
+
evidence,
|
|
329
|
+
};
|
|
330
|
+
});
|
|
331
|
+
// Run partitionTrialsByAttribution on active trials first to detect off-target
|
|
332
|
+
// before building clinical_development.trials and discovery_trials sections.
|
|
333
|
+
// Since ctgov interventions are plain strings (no ChEMBL IDs), the resolver
|
|
334
|
+
// cannot fire and all trials land in primary — off-target detection activates
|
|
335
|
+
// only when ChEMBL IDs are available downstream.
|
|
336
|
+
const activeTrialsPartitioned = ctgov.coverage === "available" ? await partitionTrialsByAttribution(ctgov.data.active, attrCtx) : null;
|
|
337
|
+
// Map ctgov active trials to clinical-trial row shape with text-based confidence,
|
|
338
|
+
// then remove rows identified as off-target by the attribution filter.
|
|
339
|
+
// Drug-in-class matches (calcitonin drugs for CALCR, GLP-1 drugs for GLP1R, etc.)
|
|
340
|
+
// are promoted to "medium" via classifyClinicalTrialConfidence so they survive
|
|
341
|
+
// the ≥ medium threshold even when the gene symbol is absent from intervention names.
|
|
342
|
+
const clinicalTrialRows = activeTrialsPartitioned !== null
|
|
343
|
+
? activeTrialsPartitioned.primary
|
|
344
|
+
.map((t) => {
|
|
345
|
+
const text_confidence = classifyClinicalTrialConfidence(t, resolved.geneSymbol, knownClassDrugNames);
|
|
346
|
+
return {
|
|
347
|
+
nct_id: t.nctId,
|
|
348
|
+
title: t.title,
|
|
349
|
+
phase: t.phase,
|
|
350
|
+
status: t.status,
|
|
351
|
+
conditions: t.conditions,
|
|
352
|
+
start_date: t.startDate,
|
|
353
|
+
completion_date: t.primaryCompletionDate,
|
|
354
|
+
match_confidence: text_confidence,
|
|
355
|
+
};
|
|
356
|
+
})
|
|
357
|
+
.filter((r) => r.match_confidence !== "low")
|
|
358
|
+
: null;
|
|
359
|
+
// Build failed-trial rows with off-target partitioning. The gene-symbol
|
|
360
|
+
// query in collectCtgov misses terminated trials whose intervention is
|
|
361
|
+
// recorded only by sponsor code or brand name (e.g., SMC021 for oral
|
|
362
|
+
// salmon calcitonin), so we supplement with a drug-name query against
|
|
363
|
+
// CT.gov keyed by the assembled drug interactions. The function self-
|
|
364
|
+
// throttles via withHost("ctgov", ...) on its per-drug call, so the
|
|
365
|
+
// assembler does not need its own outer wrapper. Per-drug failures
|
|
366
|
+
// inside searchFailedTrialsForDrugNames are isolated.
|
|
367
|
+
const drugNameFailedTrials = drugInteractionRows && drugInteractionRows.length > 0
|
|
368
|
+
? await searchFailedTrialsForDrugNames(drugInteractionRows.map((d) => d.drug_name).filter(Boolean))
|
|
369
|
+
.then((r) => r.trials)
|
|
370
|
+
.catch(() => [])
|
|
371
|
+
: [];
|
|
372
|
+
const failedById = new Map();
|
|
373
|
+
if (ctgov.coverage === "available") {
|
|
374
|
+
for (const t of ctgov.data.failed) {
|
|
375
|
+
failedById.set(t.nctId, {
|
|
376
|
+
nctId: t.nctId,
|
|
377
|
+
title: t.title,
|
|
378
|
+
interventions: t.interventions,
|
|
379
|
+
conditions: t.conditions,
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
for (const t of drugNameFailedTrials) {
|
|
384
|
+
if (!failedById.has(t.nctId)) {
|
|
385
|
+
failedById.set(t.nctId, {
|
|
386
|
+
nctId: t.nctId,
|
|
387
|
+
title: t.title,
|
|
388
|
+
interventions: t.interventions,
|
|
389
|
+
conditions: t.conditions,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
const rawFailedTrials = [...failedById.values()].map((t) => {
|
|
394
|
+
const fanoutItem = fanout?.perTrialAes.results.find((r) => r.coverage === "available" && r.data.nctId === t.nctId);
|
|
395
|
+
const whyStopped = fanoutItem?.coverage === "available" ? (fanoutItem.data.whyStopped ?? "") : "";
|
|
396
|
+
return {
|
|
397
|
+
nctId: t.nctId,
|
|
398
|
+
title: t.title,
|
|
399
|
+
interventions: t.interventions,
|
|
400
|
+
conditions: t.conditions,
|
|
401
|
+
why_stopped: whyStopped,
|
|
402
|
+
failure_category: buildFailureCategoryDiscriminated(whyStopped),
|
|
403
|
+
classifier: "rules",
|
|
404
|
+
};
|
|
405
|
+
});
|
|
406
|
+
const failedTrialsPartitioned = rawFailedTrials.length > 0 ? await partitionTrialsByAttribution(rawFailedTrials, attrCtx) : null;
|
|
407
|
+
const failedTrialRows = failedTrialsPartitioned?.primary.map((t) => ({
|
|
408
|
+
nct_id: t.nctId,
|
|
409
|
+
title: t.title,
|
|
410
|
+
why_stopped: t.why_stopped,
|
|
411
|
+
failure_category: t.failure_category,
|
|
412
|
+
classifier: t.classifier,
|
|
413
|
+
})) ?? [];
|
|
414
|
+
const failedRelatedRows = failedTrialsPartitioned?.related.map((t) => ({
|
|
415
|
+
nct_id: t.nctId,
|
|
416
|
+
title: t.title,
|
|
417
|
+
why_stopped: t.why_stopped,
|
|
418
|
+
failure_category: t.failure_category,
|
|
419
|
+
classifier: t.classifier,
|
|
420
|
+
})) ?? [];
|
|
421
|
+
// Typed explicitly so literal string coverage values narrow correctly.
|
|
422
|
+
// Phase-5 persist attaches the derived sub-tree after synthesis is stamped.
|
|
423
|
+
const dossierBody = {
|
|
424
|
+
schema_version: "4",
|
|
425
|
+
generated_at: new Date().toISOString(),
|
|
426
|
+
entity: assembleEntity(resolved),
|
|
427
|
+
liability_summary: liabilitySummary,
|
|
428
|
+
tractability: tractabilitySection,
|
|
429
|
+
indications: ot.coverage === "available"
|
|
430
|
+
? {
|
|
431
|
+
coverage: "available",
|
|
432
|
+
data: {
|
|
433
|
+
rows: indicationRows,
|
|
434
|
+
excluded_unsupported_count: unsupportedCandidates.length,
|
|
435
|
+
...(unsupportedCandidates.length > 0
|
|
436
|
+
? {
|
|
437
|
+
unsupported_associations: unsupportedCandidates.map(({ a }) => ({
|
|
438
|
+
disease_id: a.diseaseId,
|
|
439
|
+
disease_name: a.diseaseName,
|
|
440
|
+
})),
|
|
441
|
+
}
|
|
442
|
+
: {}),
|
|
443
|
+
},
|
|
444
|
+
}
|
|
445
|
+
: {
|
|
446
|
+
coverage: "queried_no_data",
|
|
447
|
+
error: {
|
|
448
|
+
message: ot.coverage === "queried_no_data" && ot.error?.message ? ot.error.message : "Open Targets unavailable",
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
drug_interactions: drugInteractionRows
|
|
452
|
+
? { coverage: "available", data: { rows: drugInteractionRows } }
|
|
453
|
+
: { coverage: "queried_no_data", error: { message: "no ChEMBL modulators available" } },
|
|
454
|
+
clinical_development: {
|
|
455
|
+
trials: clinicalTrialRows === null
|
|
456
|
+
? { coverage: "queried_no_data", error: { message: "ClinicalTrials.gov unavailable" } }
|
|
457
|
+
: (() => {
|
|
458
|
+
const base = coverageFromRows(clinicalTrialRows, { reason: "no trials matched the assessment target with confidence ≥ medium" });
|
|
459
|
+
if (base.coverage !== "available")
|
|
460
|
+
return base;
|
|
461
|
+
return {
|
|
462
|
+
coverage: "available",
|
|
463
|
+
data: {
|
|
464
|
+
rows: base.data.rows,
|
|
465
|
+
selection_criteria: {
|
|
466
|
+
derived_from: "analytics.discovery_trials",
|
|
467
|
+
min_confidence: "medium",
|
|
468
|
+
excluded_off_target_count: activeTrialsPartitioned?.related.length ?? 0,
|
|
469
|
+
},
|
|
470
|
+
...(activeTrialsPartitioned && activeTrialsPartitioned.related.length > 0
|
|
471
|
+
? {
|
|
472
|
+
related_target_trials: activeTrialsPartitioned.related.map((t) => ({
|
|
473
|
+
nct_id: t.nctId,
|
|
474
|
+
title: t.title,
|
|
475
|
+
phase: t.phase,
|
|
476
|
+
status: t.status,
|
|
477
|
+
conditions: t.conditions,
|
|
478
|
+
start_date: t.startDate,
|
|
479
|
+
completion_date: t.primaryCompletionDate,
|
|
480
|
+
match_confidence: "off_target",
|
|
481
|
+
})),
|
|
482
|
+
related_receptor: activeTrialsPartitioned.related_receptor,
|
|
483
|
+
}
|
|
484
|
+
: {}),
|
|
485
|
+
},
|
|
486
|
+
};
|
|
487
|
+
})(),
|
|
488
|
+
outcomes: trialOutcomesRows
|
|
489
|
+
? { coverage: "available", data: { rows: trialOutcomesRows } }
|
|
490
|
+
: phase3
|
|
491
|
+
? { coverage: "queried_no_data", error: { message: "no per-trial outcomes available" } }
|
|
492
|
+
: { coverage: "not_loaded", reason: "Phase-3 fan-out not run" },
|
|
493
|
+
failed_trials: ctgov.coverage === "available"
|
|
494
|
+
? {
|
|
495
|
+
coverage: "available",
|
|
496
|
+
data: {
|
|
497
|
+
rows: failedTrialRows,
|
|
498
|
+
...(failedRelatedRows.length > 0
|
|
499
|
+
? {
|
|
500
|
+
related_target_trials: failedRelatedRows,
|
|
501
|
+
related_receptor: failedTrialsPartitioned?.related_receptor,
|
|
502
|
+
}
|
|
503
|
+
: {}),
|
|
504
|
+
},
|
|
505
|
+
}
|
|
506
|
+
: { coverage: "queried_no_data" },
|
|
507
|
+
benchmarks: {
|
|
508
|
+
therapeutic_area: benchmarks.therapeutic_area,
|
|
509
|
+
fallback_to_all_areas: benchmarks.source === "fallback",
|
|
510
|
+
phase_transitions: benchmarks.transitions,
|
|
511
|
+
likelihood_of_approval: benchmarks.transitions.phase1_to_approval,
|
|
512
|
+
source_attribution: `${datasetAttr.source} (${datasetAttr.data_version}, ${datasetAttr.data_window})`,
|
|
513
|
+
},
|
|
514
|
+
},
|
|
515
|
+
safety_profile: {
|
|
516
|
+
organ_rollup: organRollupRows
|
|
517
|
+
? { coverage: "available", data: { rows: organRollupRows } }
|
|
518
|
+
: phase3
|
|
519
|
+
? { coverage: "queried_no_data", error: { message: "no organ-level signals" } }
|
|
520
|
+
: { coverage: "not_loaded", reason: "Phase-3 fan-out not run" },
|
|
521
|
+
faers: (() => {
|
|
522
|
+
const classPrecedentSection = classP
|
|
523
|
+
? { coverage: "available", data: classP }
|
|
524
|
+
: phase3
|
|
525
|
+
? { coverage: "queried_no_data", error: { message: "no class precedent data" } }
|
|
526
|
+
: { coverage: "not_loaded", reason: "Phase-3 fan-out not run" };
|
|
527
|
+
const rawFaers = faersAgg
|
|
528
|
+
? { coverage: "available", data: faersAgg }
|
|
529
|
+
: phase3
|
|
530
|
+
? { coverage: "queried_no_data", error: { message: "FAERS returned no reports" } }
|
|
531
|
+
: { coverage: "not_loaded", reason: "Phase-3 fan-out not run" };
|
|
532
|
+
return reconcileFaersCoverage({ faers: rawFaers, class_precedent: classPrecedentSection });
|
|
533
|
+
})(),
|
|
534
|
+
trial_aes: trialAesAgg
|
|
535
|
+
? { coverage: "available", data: trialAesAgg }
|
|
536
|
+
: phase3
|
|
537
|
+
? { coverage: "queried_no_data", error: { message: "no trial AE data" } }
|
|
538
|
+
: { coverage: "not_loaded", reason: "Phase-3 fan-out not run" },
|
|
539
|
+
off_target_panel: offTargetPanel
|
|
540
|
+
? { coverage: "available", data: offTargetPanel }
|
|
541
|
+
: phase3
|
|
542
|
+
? { coverage: "queried_no_data", error: { message: "no off-target data" } }
|
|
543
|
+
: { coverage: "not_loaded", reason: "Phase-3 fan-out not run" },
|
|
544
|
+
failed_trials_safety_lens: ctgov.coverage === "available" && failedTrialRows.length > 0
|
|
545
|
+
? {
|
|
546
|
+
coverage: "available",
|
|
547
|
+
data: {
|
|
548
|
+
rows: failedTrialRows,
|
|
549
|
+
...(failedRelatedRows.length > 0
|
|
550
|
+
? {
|
|
551
|
+
related_target_trials: failedRelatedRows,
|
|
552
|
+
related_receptor: failedTrialsPartitioned?.related_receptor,
|
|
553
|
+
}
|
|
554
|
+
: {}),
|
|
555
|
+
},
|
|
556
|
+
}
|
|
557
|
+
: ctgov.coverage === "available"
|
|
558
|
+
? { coverage: "queried_no_data", error: { message: "no failed trials" } }
|
|
559
|
+
: { coverage: "queried_no_data", error: { message: "ClinicalTrials.gov unavailable" } },
|
|
560
|
+
class_precedent: classP
|
|
561
|
+
? { coverage: "available", data: classP }
|
|
562
|
+
: phase3
|
|
563
|
+
? { coverage: "queried_no_data", error: { message: "no class precedent data" } }
|
|
564
|
+
: { coverage: "not_loaded", reason: "Phase-3 fan-out not run" },
|
|
565
|
+
target_organ_liabilities: [],
|
|
566
|
+
regulatory_actions: regulatoryActionRows.length > 0
|
|
567
|
+
? { coverage: "available", data: { rows: regulatoryActionRows } }
|
|
568
|
+
: { coverage: "queried_no_data" },
|
|
569
|
+
},
|
|
570
|
+
off_tissue_risk: expression.coverage === "available" ? { coverage: "available", data: { rows: offTissueRows } } : { coverage: "queried_no_data" },
|
|
571
|
+
off_target_panel: offTargetPanel
|
|
572
|
+
? { coverage: "available", data: offTargetPanel }
|
|
573
|
+
: phase3
|
|
574
|
+
? { coverage: "queried_no_data", error: { message: "no off-target data" } }
|
|
575
|
+
: { coverage: "not_loaded", reason: "Phase-3 fan-out not run" },
|
|
576
|
+
reference_biology: {
|
|
577
|
+
therapeutic_area_associations: ot.coverage === "available"
|
|
578
|
+
? {
|
|
579
|
+
coverage: "available",
|
|
580
|
+
data: {
|
|
581
|
+
rows: filteredIndications.slice(0, 200).map((a) => {
|
|
582
|
+
const evidence = makeAssociationEvidence(a);
|
|
583
|
+
return {
|
|
584
|
+
partner_id: a.diseaseId,
|
|
585
|
+
partner_name: a.diseaseName,
|
|
586
|
+
predicate: a.geneticAssociationScore != null
|
|
587
|
+
? "associated_with"
|
|
588
|
+
: a.knownDrugScore != null
|
|
589
|
+
? "therapeutic_target"
|
|
590
|
+
: a.animalModelScore != null
|
|
591
|
+
? "validated_in_animal_model"
|
|
592
|
+
: "literature_co_occurrence",
|
|
593
|
+
best_score: a.score,
|
|
594
|
+
source_count: [
|
|
595
|
+
a.geneticAssociationScore,
|
|
596
|
+
a.knownDrugScore,
|
|
597
|
+
a.animalModelScore,
|
|
598
|
+
a.somaticMutationScore,
|
|
599
|
+
a.literatureScore,
|
|
600
|
+
].filter((s) => s != null).length,
|
|
601
|
+
paper_count: a.literaturePmids?.length ?? 0,
|
|
602
|
+
evidence,
|
|
603
|
+
};
|
|
604
|
+
}),
|
|
605
|
+
},
|
|
606
|
+
}
|
|
607
|
+
: { coverage: "queried_no_data" },
|
|
608
|
+
molecular_interactions: (() => {
|
|
609
|
+
const rows = assembleMolecularInteractions(phase2, fanout);
|
|
610
|
+
return rows ? { coverage: "available", data: { rows } } : { coverage: "queried_no_data" };
|
|
611
|
+
})(),
|
|
612
|
+
biomarker_potential: (() => {
|
|
613
|
+
const rows = assembleBiomarkerPotential(phase2);
|
|
614
|
+
return rows ? { coverage: "available", data: { rows } } : { coverage: "queried_no_data" };
|
|
615
|
+
})(),
|
|
616
|
+
genetic_alterations: {
|
|
617
|
+
somatic: cbioportal.coverage === "available"
|
|
618
|
+
? coverageFromRows(cbioportal.data.rows.map((r) => ({
|
|
619
|
+
cancer_type: r.cancerTypeName,
|
|
620
|
+
cohort: r.studies.join(", "),
|
|
621
|
+
mutation_count: r.mutatedSamples,
|
|
622
|
+
total_samples: r.totalSamples,
|
|
623
|
+
frequency: r.frequency,
|
|
624
|
+
source: "cbioportal",
|
|
625
|
+
})), { reason: "cBioPortal returned no somatic mutation cohorts for this gene" })
|
|
626
|
+
: { coverage: "queried_no_data" },
|
|
627
|
+
clinvar: clinvar.coverage === "available"
|
|
628
|
+
? coverageFromRows(clinvar.data.variants.map((v) => ({
|
|
629
|
+
variant_id: v.variationId,
|
|
630
|
+
hgvs: v.title,
|
|
631
|
+
classification: v.clinicalSignificance,
|
|
632
|
+
condition: v.conditions[0] ?? "",
|
|
633
|
+
review_status: v.reviewStatus,
|
|
634
|
+
})), { reason: "ClinVar returned 0 variants for this gene" })
|
|
635
|
+
: { coverage: "queried_no_data" },
|
|
636
|
+
},
|
|
637
|
+
resistance_evidence: (() => {
|
|
638
|
+
const rows = assembleResistanceEvidence(phase2);
|
|
639
|
+
return rows ? { coverage: "available", data: { rows } } : { coverage: "queried_no_data" };
|
|
640
|
+
})(),
|
|
641
|
+
combination_evidence: (() => {
|
|
642
|
+
const rows = assembleCombinationEvidence(phase2);
|
|
643
|
+
return rows ? { coverage: "available", data: { rows } } : { coverage: "queried_no_data" };
|
|
644
|
+
})(),
|
|
645
|
+
pathway_context: pathways.coverage === "available"
|
|
646
|
+
? (() => {
|
|
647
|
+
const presentDbs = new Set(pathways.data.pathways.map((p) => p.source));
|
|
648
|
+
const ALL_DBS = ["reactome", "kegg", "wikipathways", "msigdb"];
|
|
649
|
+
const QUERIED = ["reactome", "kegg"];
|
|
650
|
+
return {
|
|
651
|
+
coverage: "available",
|
|
652
|
+
data: {
|
|
653
|
+
rows: pathways.data.pathways.map((p) => ({
|
|
654
|
+
pathway_id: p.id,
|
|
655
|
+
pathway_name: p.name,
|
|
656
|
+
database: p.source,
|
|
657
|
+
evidence_score: 1,
|
|
658
|
+
})),
|
|
659
|
+
databases_queried: QUERIED.filter((db) => presentDbs.has(db)).length === QUERIED.length
|
|
660
|
+
? QUERIED
|
|
661
|
+
: QUERIED.filter((db) => presentDbs.has(db)),
|
|
662
|
+
databases_skipped: ALL_DBS.filter((db) => !presentDbs.has(db)),
|
|
663
|
+
},
|
|
664
|
+
};
|
|
665
|
+
})()
|
|
666
|
+
: { coverage: "queried_no_data" },
|
|
667
|
+
ppi_network: ppi.coverage === "available"
|
|
668
|
+
? {
|
|
669
|
+
coverage: "available",
|
|
670
|
+
data: { partners: dedupePpiPartners(ppi.data.partners) },
|
|
671
|
+
}
|
|
672
|
+
: { coverage: "queried_no_data" },
|
|
673
|
+
normal_tissue_expression: expression.coverage === "available"
|
|
674
|
+
? {
|
|
675
|
+
coverage: "available",
|
|
676
|
+
data: {
|
|
677
|
+
source: expression.data.source,
|
|
678
|
+
unit: expression.data.unit,
|
|
679
|
+
normalization_notes: expression.data.normalization_notes,
|
|
680
|
+
rows: expression.data.tissues
|
|
681
|
+
.filter((t) => t.value != null)
|
|
682
|
+
.sort((a, b) => (b.value ?? 0) - (a.value ?? 0))
|
|
683
|
+
.map((t) => ({
|
|
684
|
+
tissue: t.tissueLabel,
|
|
685
|
+
value: t.value ?? 0,
|
|
686
|
+
})),
|
|
687
|
+
},
|
|
688
|
+
}
|
|
689
|
+
: { coverage: "queried_no_data" },
|
|
690
|
+
preclinical: {
|
|
691
|
+
ko_phenotype: impc.coverage === "available"
|
|
692
|
+
? {
|
|
693
|
+
coverage: "available",
|
|
694
|
+
data: {
|
|
695
|
+
marker_symbol: impc.data.mouseMarkerSymbol,
|
|
696
|
+
viability: impc.data.viability,
|
|
697
|
+
sex_dimorphism: impc.data.sexDimorphic,
|
|
698
|
+
organ_systems_with_phenotype: impc.data.organSystems,
|
|
699
|
+
top_mp_terms: impc.data.mpTerms.slice(0, 25).map((m) => m.term),
|
|
700
|
+
total_phenotype_count: impc.data.phenotypeCount,
|
|
701
|
+
pre_weaning_lethal: impc.data.viability === "lethal_pre_weaning",
|
|
702
|
+
supporting_literature: koSupportingLiterature,
|
|
703
|
+
},
|
|
704
|
+
}
|
|
705
|
+
: { coverage: "queried_no_data" },
|
|
706
|
+
expression_heatmap: expressionMulti.coverage === "available"
|
|
707
|
+
? {
|
|
708
|
+
coverage: "available",
|
|
709
|
+
data: {
|
|
710
|
+
cells: expressionMulti.data.bySpecies.flatMap((s) => {
|
|
711
|
+
const speciesKey = s.species === "homo_sapiens"
|
|
712
|
+
? "human"
|
|
713
|
+
: s.species === "mus_musculus"
|
|
714
|
+
? "mouse"
|
|
715
|
+
: s.species === "rattus_norvegicus"
|
|
716
|
+
? "rat"
|
|
717
|
+
: s.species === "macaca_mulatta"
|
|
718
|
+
? "macaque"
|
|
719
|
+
: "dog";
|
|
720
|
+
return s.tissues.map((t) => ({
|
|
721
|
+
tissue: t.tissue,
|
|
722
|
+
species: speciesKey,
|
|
723
|
+
rank: t.rank,
|
|
724
|
+
}));
|
|
725
|
+
}),
|
|
726
|
+
per_species_coverage: Object.fromEntries(expressionMulti.data.bySpecies.map((s) => [
|
|
727
|
+
s.species,
|
|
728
|
+
s.tissues.length > 0 ? "available" : "queried_no_data",
|
|
729
|
+
])),
|
|
730
|
+
},
|
|
731
|
+
}
|
|
732
|
+
: { coverage: "queried_no_data" },
|
|
733
|
+
translational_commentary: {
|
|
734
|
+
coverage: "not_loaded",
|
|
735
|
+
reason: NOT_LOADED_PHASE5,
|
|
736
|
+
},
|
|
737
|
+
preclinical_literature: preclinicalLitData
|
|
738
|
+
? { coverage: "available", data: preclinicalLitData }
|
|
739
|
+
: { coverage: "queried_no_data", error: { message: "no species-tagged literature" } },
|
|
740
|
+
data_coverage: {
|
|
741
|
+
ko: impc.coverage === "available" ? "available" : "queried_no_data",
|
|
742
|
+
expression: expressionMulti.coverage,
|
|
743
|
+
literature: pubmed.coverage,
|
|
744
|
+
per_species: expressionMulti.coverage === "available"
|
|
745
|
+
? Object.fromEntries(expressionMulti.data.bySpecies.map((s) => [s.species, s.tissues.length > 0]))
|
|
746
|
+
: {},
|
|
747
|
+
},
|
|
748
|
+
},
|
|
749
|
+
key_papers: keyPapersRows
|
|
750
|
+
? { coverage: "available", data: { rows: keyPapersRows } }
|
|
751
|
+
: { coverage: "queried_no_data", error: { message: "no PubMed results" } },
|
|
752
|
+
},
|
|
753
|
+
analytics: {
|
|
754
|
+
evidence_conflicts: (() => {
|
|
755
|
+
const rows = assembleEvidenceConflicts(phase2);
|
|
756
|
+
return rows ? { coverage: "available", data: { rows } } : { coverage: "queried_no_data" };
|
|
757
|
+
})(),
|
|
758
|
+
evidence_timeline: evidenceTimeline
|
|
759
|
+
? { coverage: "available", data: evidenceTimeline }
|
|
760
|
+
: pubmed.coverage === "not_loaded"
|
|
761
|
+
? { coverage: "not_loaded", reason: "PubMed not queried" }
|
|
762
|
+
: { coverage: "queried_no_data", error: { message: "no PubMed years available" } },
|
|
763
|
+
translational_chain: translationalChain
|
|
764
|
+
? { coverage: "available", data: translationalChain }
|
|
765
|
+
: pubmed.coverage === "not_loaded" && ctgov.coverage === "not_loaded" && impc.coverage === "not_loaded"
|
|
766
|
+
? { coverage: "not_loaded", reason: "no upstream tier evidence" }
|
|
767
|
+
: { coverage: "queried_no_data", error: { message: "no tier evidence" } },
|
|
768
|
+
additional_evidence: (() => {
|
|
769
|
+
const data = assembleAdditionalEvidence(phase2);
|
|
770
|
+
return data ? { coverage: "available", data } : { coverage: "queried_no_data" };
|
|
771
|
+
})(),
|
|
772
|
+
discovery_trials: discoveryTrialData
|
|
773
|
+
? { coverage: "available", data: discoveryTrialData }
|
|
774
|
+
: { coverage: "queried_no_data", error: { message: "no medium/low-confidence trials" } },
|
|
775
|
+
// Stamped by Phase 5 after synthesis agents run; not available at assembly time.
|
|
776
|
+
synthesis_diagnostics: { coverage: "not_loaded", reason: "Phase-5 synthesis not yet run" },
|
|
777
|
+
},
|
|
778
|
+
// Stamped by Phase 5 after the dossier-recommendation agent runs.
|
|
779
|
+
executive_recommendation: { coverage: "not_loaded", reason: "Phase-5 synthesis not yet run" },
|
|
780
|
+
};
|
|
781
|
+
return dossierBody;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Reconciles target-level FAERS with class_precedent aggregates.
|
|
785
|
+
*
|
|
786
|
+
* When target-level FAERS has data (coverage: "available"), pass through
|
|
787
|
+
* unchanged. When class_precedent has FAERS-derived reports in per_organ,
|
|
788
|
+
* fold them into a class-scoped FaersSummaryV4 payload with
|
|
789
|
+
* coverage: "available" and inference_path tagged — rather than leaving
|
|
790
|
+
* the section as queried_no_data, which creates an evidence conflict
|
|
791
|
+
* that the conflict-detector flags. When neither has data, return
|
|
792
|
+
* faers unchanged.
|
|
793
|
+
*/
|
|
794
|
+
export function reconcileFaersCoverage(input) {
|
|
795
|
+
const { faers, class_precedent: classPrecedent } = input;
|
|
796
|
+
// Target-level FAERS already has data — identity pass-through.
|
|
797
|
+
if (faers.coverage === "available")
|
|
798
|
+
return faers;
|
|
799
|
+
if (!classPrecedent || classPrecedent.coverage === "queried_no_data" || classPrecedent.coverage === "not_loaded")
|
|
800
|
+
return faers;
|
|
801
|
+
const perOrgan = classPrecedent.data?.per_organ ?? [];
|
|
802
|
+
const aes = perOrgan.flatMap((po) => (po.top_aes ?? []).map((ae) => ({
|
|
803
|
+
meddra_term: ae.term ?? "",
|
|
804
|
+
organ: po.organ,
|
|
805
|
+
report_count: ae.report_count ?? 0,
|
|
806
|
+
})));
|
|
807
|
+
// No class-level AEs either — leave the section as-is.
|
|
808
|
+
if (aes.length === 0)
|
|
809
|
+
return faers;
|
|
810
|
+
// Each AE-term count in top_aes counts reports that have that specific AE.
|
|
811
|
+
// A report with multiple AEs (e.g. NAUSEA + DIZZINESS) contributes to each
|
|
812
|
+
// term's count, so this sum is an upper bound on unique reports, not the
|
|
813
|
+
// true unique count. The class_precedent structure does not preserve unique
|
|
814
|
+
// report counts — this is the best approximation available.
|
|
815
|
+
const total = aes.reduce((s, ae) => s + ae.report_count, 0);
|
|
816
|
+
return {
|
|
817
|
+
coverage: "available",
|
|
818
|
+
data: {
|
|
819
|
+
total_reports: total,
|
|
820
|
+
seriousness: { coverage: "queried_no_data", total_reports: total },
|
|
821
|
+
top_signals: aes
|
|
822
|
+
.slice()
|
|
823
|
+
.sort((a, b) => b.report_count - a.report_count)
|
|
824
|
+
.slice(0, 20),
|
|
825
|
+
// class_precedent.per_organ aggregates across drugs without preserving
|
|
826
|
+
// per-drug report counts. Emitting per_modulator entries with
|
|
827
|
+
// report_count: 0 would look like real measured zeros to any consumer
|
|
828
|
+
// summing them to cross-check total_reports. Returning an empty array
|
|
829
|
+
// is the honest representation — the per-drug breakdown is not known
|
|
830
|
+
// at this layer.
|
|
831
|
+
per_modulator: [],
|
|
832
|
+
},
|
|
833
|
+
inference_path: "class_precedent.per_organ → FAERS",
|
|
834
|
+
};
|
|
835
|
+
}
|