@inflexa-ai/harness 0.1.1 → 0.3.0
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/README.md +48 -0
- package/dist/agents/conversation-agent.d.ts +15 -11
- package/dist/agents/conversation-agent.js +31 -34
- package/dist/agents/report-builder.js +2 -1
- package/dist/agents/sandbox/bulk-transcriptomics-agent.js +1 -1
- package/dist/agents/sandbox/cheminformatics-agent.js +1 -19
- package/dist/agents/sandbox/chromatin-agent.js +1 -10
- package/dist/agents/sandbox/dna-methylation-agent.js +1 -10
- package/dist/agents/sandbox/drug-repurposing-agent.js +4 -14
- package/dist/agents/sandbox/enrichment-agent.js +1 -10
- package/dist/agents/sandbox/ephemeral-executor.js +1 -10
- package/dist/agents/sandbox/genomic-variant-agent.js +1 -3
- package/dist/agents/sandbox/immune-profiling-agent.js +1 -13
- package/dist/agents/sandbox/metabolomics-agent.js +1 -1
- package/dist/agents/sandbox/microbiome-agent.js +1 -1
- package/dist/agents/sandbox/multi-omics-integration-agent.js +1 -12
- package/dist/agents/sandbox/multimodal-sc-agent.js +1 -1
- package/dist/agents/sandbox/network-agent.js +1 -10
- package/dist/agents/sandbox/pkpd-clinical-response-agent.js +2 -8
- package/dist/agents/sandbox/proteomics-agent.js +1 -1
- package/dist/agents/sandbox/scientific-executor.js +1 -10
- package/dist/agents/sandbox/shared.d.ts +20 -6
- package/dist/agents/sandbox/shared.js +50 -39
- package/dist/agents/sandbox/single-cell-agent.js +1 -1
- package/dist/agents/sandbox/spatial-omics-agent.js +1 -1
- package/dist/agents/sandbox/statistical-modeling-agent.js +1 -1
- package/dist/agents/sandbox/translational-safety-agent.js +3 -9
- package/dist/agents/sandbox/types.d.ts +1 -1
- package/dist/agents/system-prompt.d.ts +37 -11
- package/dist/agents/system-prompt.js +35 -12
- package/dist/app/chat-turn.d.ts +3 -0
- package/dist/app/chat-turn.js +3 -1
- package/dist/app/data-profile-orientation.d.ts +34 -0
- package/dist/app/data-profile-orientation.js +117 -0
- package/dist/app/synthesize-run.d.ts +3 -0
- package/dist/app/synthesize-run.js +3 -1
- package/dist/contracts/schemas/chat-parts.d.ts +9 -9
- package/dist/execution/artifact-metadata.d.ts +3 -0
- package/dist/execution/artifact-metadata.js +10 -3
- package/dist/execution/artifact-registration.d.ts +2 -1
- package/dist/execution/artifact-registration.js +8 -2
- package/dist/execution/ephemeral-runner.d.ts +16 -0
- package/dist/execution/ephemeral-runner.js +31 -5
- package/dist/execution/post-step-pipeline.d.ts +3 -0
- package/dist/execution/post-step-pipeline.js +24 -4
- package/dist/execution/reconcile-manifest.d.ts +7 -0
- package/dist/execution/reconcile-manifest.js +19 -5
- package/dist/execution/report-runner.d.ts +3 -0
- package/dist/execution/report-runner.js +4 -4
- package/dist/execution/run-synthesis.js +20 -19
- package/dist/execution/step-summary.d.ts +3 -0
- package/dist/execution/step-summary.js +6 -3
- package/dist/index.d.ts +9 -2
- package/dist/index.js +24 -5
- package/dist/lib/chrome.d.ts +4 -1
- package/dist/lib/chrome.js +10 -7
- package/dist/lib/console-logger.d.ts +19 -0
- package/dist/lib/console-logger.js +62 -0
- package/dist/lib/logger.d.ts +88 -0
- package/dist/lib/logger.js +37 -0
- package/dist/lib/otel.d.ts +2 -1
- package/dist/lib/otel.js +8 -3
- package/dist/loop/__fixtures__/scripted-provider.d.ts +2 -2
- package/dist/loop/__fixtures__/scripted-provider.js +2 -1
- package/dist/loop/metrics.d.ts +33 -1
- package/dist/loop/metrics.js +56 -2
- package/dist/loop/run-agent.d.ts +13 -1
- package/dist/loop/run-agent.js +19 -4
- package/dist/memory/card-builders.d.ts +8 -1
- package/dist/memory/card-builders.js +20 -3
- package/dist/memory/reconstruct-cards.js +4 -3
- package/dist/memory/thread-history.d.ts +27 -2
- package/dist/memory/thread-history.js +45 -5
- package/dist/memory/working-memory.d.ts +93 -10
- package/dist/memory/working-memory.js +220 -84
- package/dist/prompts/SOUL.d.ts +22 -9
- package/dist/prompts/SOUL.js +56 -37
- package/dist/prompts/analogical-reasoner.d.ts +1 -1
- package/dist/prompts/analogical-reasoner.js +2 -2
- package/dist/prompts/briefing.d.ts +100 -0
- package/dist/prompts/briefing.js +166 -0
- package/dist/prompts/conversation.d.ts +1 -1
- package/dist/prompts/conversation.js +94 -440
- package/dist/prompts/literature-reviewer.d.ts +1 -1
- package/dist/prompts/literature-reviewer.js +10 -10
- package/dist/prompts/planner.js +28 -59
- package/dist/prompts/report-builder.d.ts +1 -1
- package/dist/prompts/report-builder.js +71 -24
- package/dist/prompts/sandbox/bulk-transcriptomics-agent.d.ts +1 -1
- package/dist/prompts/sandbox/bulk-transcriptomics-agent.js +2 -7
- package/dist/prompts/sandbox/cheminformatics-agent.d.ts +1 -1
- package/dist/prompts/sandbox/cheminformatics-agent.js +11 -15
- package/dist/prompts/sandbox/chromatin-agent.d.ts +1 -1
- package/dist/prompts/sandbox/chromatin-agent.js +3 -7
- package/dist/prompts/sandbox/data-profiler.d.ts +1 -1
- package/dist/prompts/sandbox/data-profiler.js +13 -8
- package/dist/prompts/sandbox/dna-methylation-agent.d.ts +1 -1
- package/dist/prompts/sandbox/dna-methylation-agent.js +2 -7
- package/dist/prompts/sandbox/drug-repurposing-agent.d.ts +1 -1
- package/dist/prompts/sandbox/drug-repurposing-agent.js +15 -16
- package/dist/prompts/sandbox/enrichment-agent.d.ts +1 -1
- package/dist/prompts/sandbox/enrichment-agent.js +2 -9
- package/dist/prompts/sandbox/genomic-variant-agent.d.ts +1 -1
- package/dist/prompts/sandbox/genomic-variant-agent.js +2 -6
- package/dist/prompts/sandbox/immune-profiling-agent.d.ts +1 -1
- package/dist/prompts/sandbox/immune-profiling-agent.js +3 -8
- package/dist/prompts/sandbox/metabolomics-agent.d.ts +1 -1
- package/dist/prompts/sandbox/metabolomics-agent.js +1 -7
- package/dist/prompts/sandbox/microbiome-agent.d.ts +1 -1
- package/dist/prompts/sandbox/microbiome-agent.js +2 -7
- package/dist/prompts/sandbox/multi-omics-integration-agent.d.ts +1 -1
- package/dist/prompts/sandbox/multi-omics-integration-agent.js +2 -8
- package/dist/prompts/sandbox/multimodal-sc-agent.d.ts +1 -1
- package/dist/prompts/sandbox/multimodal-sc-agent.js +2 -7
- package/dist/prompts/sandbox/network-agent.d.ts +1 -1
- package/dist/prompts/sandbox/network-agent.js +2 -7
- package/dist/prompts/sandbox/proteomics-agent.d.ts +1 -1
- package/dist/prompts/sandbox/proteomics-agent.js +2 -9
- package/dist/prompts/sandbox/single-cell-agent.d.ts +1 -1
- package/dist/prompts/sandbox/single-cell-agent.js +2 -9
- package/dist/prompts/sandbox/spatial-omics-agent.d.ts +1 -1
- package/dist/prompts/sandbox/spatial-omics-agent.js +3 -6
- package/dist/prompts/sandbox/statistical-modeling-agent.d.ts +1 -1
- package/dist/prompts/sandbox/statistical-modeling-agent.js +2 -7
- package/dist/prompts/sandbox/translational-safety-agent.d.ts +1 -1
- package/dist/prompts/sandbox/translational-safety-agent.js +13 -14
- package/dist/prompts/sandbox-standards.d.ts +22 -14
- package/dist/prompts/sandbox-standards.js +91 -71
- package/dist/prompts/synthesis-agent.d.ts +1 -1
- package/dist/prompts/synthesis-agent.js +33 -131
- package/dist/provenance/collector.js +1 -1
- package/dist/providers/ai-sdk.js +31 -4
- package/dist/providers/prompt-cache.d.ts +74 -0
- package/dist/providers/prompt-cache.js +77 -0
- package/dist/providers/types.d.ts +33 -0
- package/dist/reference-data/catalog.d.ts +131 -0
- package/dist/reference-data/catalog.js +348 -0
- package/dist/reference-data/receipt.d.ts +41 -0
- package/dist/reference-data/receipt.js +40 -0
- package/dist/runtime/boot.d.ts +2 -2
- package/dist/runtime/boot.js +1 -1
- package/dist/runtime/connection-budget.d.ts +2 -2
- package/dist/runtime/connection-budget.js +5 -3
- package/dist/runtime/dbos.d.ts +7 -7
- package/dist/runtime/dbos.js +14 -11
- package/dist/runtime/shutdown.d.ts +2 -2
- package/dist/runtime/shutdown.js +4 -3
- package/dist/sandbox/create-sandbox.d.ts +2 -2
- package/dist/sandbox/docker-client.d.ts +2 -2
- package/dist/sandbox/docker-client.js +4 -1
- package/dist/sandbox/k8s-client.d.ts +3 -0
- package/dist/sandbox/k8s-client.js +5 -4
- package/dist/sandbox/notification-sweep.d.ts +3 -3
- package/dist/sandbox/notification-sweep.js +4 -2
- package/dist/sandbox/reaper.d.ts +3 -3
- package/dist/sandbox/reaper.js +7 -4
- package/dist/sandbox/watchdog.d.ts +3 -3
- package/dist/sandbox/watchdog.js +8 -2
- package/dist/schemas/data-profile-schemas.js +5 -3
- package/dist/schemas/plan-schemas.d.ts +21 -21
- package/dist/schemas/plan-schemas.js +9 -3
- package/dist/schemas/run-synthesis.d.ts +8 -4
- package/dist/schemas/run-synthesis.js +92 -56
- package/dist/schemas/validate-plan.js +1 -1
- package/dist/schemas/workflow-state.d.ts +7 -1
- package/dist/schemas/workflow-state.js +33 -19
- package/dist/state/artifacts.d.ts +13 -0
- package/dist/state/artifacts.js +27 -0
- package/dist/state/data-profile.d.ts +64 -5
- package/dist/state/index.d.ts +3 -3
- package/dist/state/index.js +1 -1
- package/dist/state/init.d.ts +2 -1
- package/dist/state/init.js +5 -6
- package/dist/tasks/data-profile.d.ts +25 -2
- package/dist/tasks/data-profile.js +95 -39
- package/dist/tools/bio/chembl.d.ts +38 -0
- package/dist/tools/bio/chembl.js +138 -0
- package/dist/tools/bio/comptox.d.ts +50 -0
- package/dist/tools/bio/comptox.js +149 -0
- package/dist/tools/bio/get-impc-ko-profile.js +9 -6
- package/dist/tools/bio/index.d.ts +5 -17
- package/dist/tools/bio/index.js +5 -17
- package/dist/tools/bio/keys.d.ts +14 -9
- package/dist/tools/bio/keys.js +16 -16
- package/dist/tools/bio/opentargets.d.ts +38 -0
- package/dist/tools/bio/opentargets.js +89 -0
- package/dist/tools/bio/pubchem.d.ts +29 -0
- package/dist/tools/bio/pubchem.js +92 -0
- package/dist/tools/bio/pubmed.d.ts +51 -0
- package/dist/tools/bio/pubmed.js +100 -0
- package/dist/tools/bio/search-bgee-expression.js +12 -6
- package/dist/tools/bio/search-clinical-trials.js +16 -5
- package/dist/tools/bio/search-dgidb.d.ts +11 -1
- package/dist/tools/bio/search-dgidb.js +92 -78
- package/dist/tools/bio/search-faers.js +8 -4
- package/dist/tools/bio/search-geo-datasets.js +20 -6
- package/dist/tools/bio/search-gwas-catalog.d.ts +1 -1
- package/dist/tools/bio/search-pharmgkb.js +10 -4
- package/dist/tools/display/index.d.ts +1 -0
- package/dist/tools/display/index.js +1 -0
- package/dist/tools/display/normalize-echart-spec.d.ts +61 -0
- package/dist/tools/display/normalize-echart-spec.js +211 -0
- package/dist/tools/display/show-user.d.ts +6 -1
- package/dist/tools/display/show-user.js +25 -12
- package/dist/tools/execute-plan.js +5 -2
- package/dist/tools/iterate-report.d.ts +171 -118
- package/dist/tools/iterate-report.js +336 -96
- package/dist/tools/lib/chembl-client.d.ts +12 -0
- package/dist/tools/lib/chembl-client.js +127 -0
- package/dist/tools/lib/ctx-ops.d.ts +224 -0
- package/dist/tools/lib/ctx-ops.js +450 -0
- package/dist/tools/lib/iuphar-client.js +10 -1
- package/dist/tools/lib/openfda-client.js +11 -3
- package/dist/tools/lib/pathway-client.js +10 -4
- package/dist/tools/lib/pubchem-ops.d.ts +74 -0
- package/dist/tools/lib/pubchem-ops.js +224 -0
- package/dist/tools/memory/update-working-memory.d.ts +45 -7
- package/dist/tools/memory/update-working-memory.js +111 -41
- package/dist/tools/report/index.d.ts +3 -2
- package/dist/tools/report/index.js +3 -2
- package/dist/tools/research/generate-analogy-report.js +25 -12
- package/dist/tools/research/generate-plan.d.ts +12 -5
- package/dist/tools/research/generate-plan.js +168 -37
- package/dist/tools/research/index.d.ts +1 -0
- package/dist/tools/research/index.js +1 -0
- package/dist/tools/research/inspect-data-profile.d.ts +85 -0
- package/dist/tools/research/inspect-data-profile.js +161 -0
- package/dist/tools/research/literature-reviewer.d.ts +3 -0
- package/dist/tools/research/literature-reviewer.js +5 -6
- package/dist/tools/sandbox/list-available-packages.d.ts +79 -5
- package/dist/tools/sandbox/list-available-packages.js +152 -10
- package/dist/tools/sandbox/list-available-refs.d.ts +141 -5
- package/dist/tools/sandbox/list-available-refs.js +647 -134
- package/dist/tools/sandbox/report-blocker.d.ts +39 -9
- package/dist/tools/sandbox/report-blocker.js +43 -20
- package/dist/tools/workspace/execute-command.d.ts +3 -0
- package/dist/tools/workspace/execute-command.js +3 -1
- package/dist/tools/workspace/read-file.js +4 -5
- package/dist/tools/workspace/run-exec.d.ts +4 -4
- package/dist/tools/workspace/run-exec.js +4 -4
- package/dist/tools/workspace/show-file.js +10 -6
- package/dist/tools/workspace/show-plan.js +12 -6
- package/dist/tools/workspace/workspace-search.d.ts +1 -1
- package/dist/tools/workspace/workspace-search.js +11 -5
- package/dist/workflows/execute-analysis.d.ts +46 -4
- package/dist/workflows/execute-analysis.js +118 -13
- package/dist/workflows/execute-target-assessment.d.ts +3 -0
- package/dist/workflows/execute-target-assessment.js +19 -15
- package/dist/workflows/sandbox-step.d.ts +9 -0
- package/dist/workflows/sandbox-step.js +39 -17
- package/dist/workflows/target-assessment/lib/citation-validator.js +2 -2
- package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.js +2 -1
- package/dist/workflows/target-assessment/lib/llm-step.d.ts +3 -0
- package/dist/workflows/target-assessment/lib/llm-step.js +3 -1
- package/dist/workflows/target-assessment/lib/structured-llm.d.ts +3 -0
- package/dist/workflows/target-assessment/lib/structured-llm.js +1 -0
- package/dist/workflows/target-assessment/phase5-persist.d.ts +3 -0
- package/dist/workflows/target-assessment/phase5-persist.js +8 -3
- package/dist/workflows/target-assessment/progress.d.ts +2 -1
- package/dist/workflows/target-assessment/progress.js +4 -3
- package/dist/workspace/filesystem.js +163 -74
- package/dist/workspace/paths.d.ts +2 -2
- package/dist/workspace/paths.js +2 -2
- package/package.json +95 -96
- package/dist/execution/filesystem-artifact-registry.d.ts +0 -57
- package/dist/execution/filesystem-artifact-registry.js +0 -92
- package/dist/lib/identifiers.d.ts +0 -8
- package/dist/lib/identifiers.js +0 -10
- package/dist/lib/mime-detect.d.ts +0 -17
- package/dist/lib/mime-detect.js +0 -29
- package/dist/lib/streamed-download.d.ts +0 -28
- package/dist/lib/streamed-download.js +0 -111
- package/dist/lib/trace-context.d.ts +0 -11
- package/dist/lib/trace-context.js +0 -49
- package/dist/providers/llm-capabilities.d.ts +0 -33
- package/dist/providers/llm-capabilities.js +0 -58
- package/dist/schemas/render-step-prompt.d.ts +0 -32
- package/dist/schemas/render-step-prompt.js +0 -76
- package/dist/tools/bio/find-approval-precedent.d.ts +0 -32
- package/dist/tools/bio/find-approval-precedent.js +0 -72
- package/dist/tools/bio/get-article-details.d.ts +0 -11
- package/dist/tools/bio/get-article-details.js +0 -20
- package/dist/tools/bio/get-article-full-text.d.ts +0 -19
- package/dist/tools/bio/get-article-full-text.js +0 -32
- package/dist/tools/bio/get-bioactivity.d.ts +0 -11
- package/dist/tools/bio/get-bioactivity.js +0 -23
- package/dist/tools/bio/get-drug-info.d.ts +0 -9
- package/dist/tools/bio/get-drug-info.js +0 -22
- package/dist/tools/bio/get-mechanism.d.ts +0 -8
- package/dist/tools/bio/get-mechanism.js +0 -18
- package/dist/tools/bio/get-pubchem-assays.d.ts +0 -22
- package/dist/tools/bio/get-pubchem-assays.js +0 -107
- package/dist/tools/bio/get-pubchem-cross-refs.d.ts +0 -15
- package/dist/tools/bio/get-pubchem-cross-refs.js +0 -68
- package/dist/tools/bio/get-target-safety.d.ts +0 -18
- package/dist/tools/bio/get-target-safety.js +0 -26
- package/dist/tools/bio/search-compounds.d.ts +0 -22
- package/dist/tools/bio/search-compounds.js +0 -160
- package/dist/tools/bio/search-ctx-chemical.d.ts +0 -50
- package/dist/tools/bio/search-ctx-chemical.js +0 -130
- package/dist/tools/bio/search-ctx-exposure.d.ts +0 -55
- package/dist/tools/bio/search-ctx-exposure.js +0 -176
- package/dist/tools/bio/search-ctx-hazard.d.ts +0 -111
- package/dist/tools/bio/search-ctx-hazard.js +0 -178
- package/dist/tools/bio/search-opentargets.d.ts +0 -11
- package/dist/tools/bio/search-opentargets.js +0 -25
- package/dist/tools/bio/search-pubchem-compound.d.ts +0 -26
- package/dist/tools/bio/search-pubchem-compound.js +0 -110
- package/dist/tools/bio/search-pubmed.d.ts +0 -17
- package/dist/tools/bio/search-pubmed.js +0 -31
- package/dist/tools/bio/search-targets.d.ts +0 -9
- package/dist/tools/bio/search-targets.js +0 -20
- package/dist/tools/bio/search-toxcast.d.ts +0 -36
- package/dist/tools/bio/search-toxcast.js +0 -141
- package/dist/workflows/register-workflows.d.ts +0 -51
- package/dist/workflows/register-workflows.js +0 -48
- package/dist/workflows/resume-execute-analysis.d.ts +0 -70
- package/dist/workflows/resume-execute-analysis.js +0 -80
- package/dist/workflows/target-assessment/correction-loop.d.ts +0 -45
- package/dist/workflows/target-assessment/correction-loop.js +0 -62
- package/dist/workflows/target-assessment/steps/phase0-resolve.d.ts +0 -71
- package/dist/workflows/target-assessment/steps/phase0-resolve.js +0 -21
- package/dist/workflows/target-assessment/steps/phase1-aggregate.d.ts +0 -1018
- package/dist/workflows/target-assessment/steps/phase1-aggregate.js +0 -25
- package/dist/workspace/mount-strategy.d.ts +0 -50
- package/dist/workspace/mount-strategy.js +0 -67
- package/dist/workspace/provenance-collector.d.ts +0 -34
- package/dist/workspace/provenance-collector.js +0 -16
- package/dist/workspace/workspace-paths.d.ts +0 -26
- package/dist/workspace/workspace-paths.js +0 -31
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* getPubchemCrossRefs tool — retrieve external database identifiers for a PubChem CID.
|
|
3
|
-
*
|
|
4
|
-
* Bridges PubChem compounds to ChEMBL, DrugBank, KEGG, PDB, and other registries.
|
|
5
|
-
*/
|
|
6
|
-
import { ok } from "neverthrow";
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
import { defineTool } from "../define-tool.js";
|
|
9
|
-
import { apiFetchValidated, describeApiError } from "../lib/api-utils.js";
|
|
10
|
-
import { PUBCHEM_HEADERS as HEADERS, PUBCHEM_BASE } from "../lib/pubchem-config.js";
|
|
11
|
-
// The PUG-REST xrefs wire shape, validated at the fetch boundary: one
|
|
12
|
-
// `Information` entry per CID with parallel `RegistryID[]` / `SourceName[]`
|
|
13
|
-
// arrays. Every field is optional — PubChem omits absent values.
|
|
14
|
-
const PubChemXrefResponseSchema = z.object({
|
|
15
|
-
InformationList: z
|
|
16
|
-
.object({
|
|
17
|
-
Information: z
|
|
18
|
-
.array(z.object({
|
|
19
|
-
CID: z.number().optional(),
|
|
20
|
-
RegistryID: z.array(z.string()).optional(),
|
|
21
|
-
SourceName: z.array(z.string()).optional(),
|
|
22
|
-
}))
|
|
23
|
-
.optional(),
|
|
24
|
-
})
|
|
25
|
-
.optional(),
|
|
26
|
-
});
|
|
27
|
-
function mapCrossRef(raw) {
|
|
28
|
-
return {
|
|
29
|
-
source: raw.SourceName ?? "Unknown",
|
|
30
|
-
id: raw.RegistryID ?? "",
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export const getPubchemCrossRefsTool = defineTool({
|
|
34
|
-
id: "get_pubchem_cross_refs",
|
|
35
|
-
description: "Get external database cross-references for a PubChem CID. " +
|
|
36
|
-
"Returns linked identifiers from ChEMBL, DrugBank, KEGG, PDB, and other registries. " +
|
|
37
|
-
"Use this to bridge PubChem compounds to other databases (e.g., get ChEMBL ID to then " +
|
|
38
|
-
"query bioactivity via ChEMBL tools).",
|
|
39
|
-
inputSchema: z.object({
|
|
40
|
-
cid: z.number().int().positive().describe("PubChem Compound ID (CID)"),
|
|
41
|
-
}),
|
|
42
|
-
execute: async ({ cid }) => {
|
|
43
|
-
const url = `${PUBCHEM_BASE}/compound/cid/${cid}/xrefs/RegistryID,SourceName/JSON`;
|
|
44
|
-
const res = await apiFetchValidated(url, PubChemXrefResponseSchema, { headers: HEADERS });
|
|
45
|
-
if (res.isErr()) {
|
|
46
|
-
// PubChem returns 404 when the CID has no cross-references — expected.
|
|
47
|
-
if (res.error.type === "http_status" && res.error.status === 404)
|
|
48
|
-
return ok({ crossRefs: [] });
|
|
49
|
-
throw new Error(describeApiError(res.error));
|
|
50
|
-
}
|
|
51
|
-
// PUG-REST xrefs returns an InformationList with one entry per CID.
|
|
52
|
-
// Each entry has parallel RegistryID[] and SourceName[] arrays.
|
|
53
|
-
const info = res.value.InformationList?.Information?.[0];
|
|
54
|
-
if (!info?.RegistryID?.length) {
|
|
55
|
-
return ok({ crossRefs: [] });
|
|
56
|
-
}
|
|
57
|
-
const crossRefs = [];
|
|
58
|
-
const registryIds = info.RegistryID;
|
|
59
|
-
const sourceNames = info.SourceName ?? [];
|
|
60
|
-
for (let i = 0; i < registryIds.length; i++) {
|
|
61
|
-
crossRefs.push(mapCrossRef({
|
|
62
|
-
RegistryID: registryIds[i],
|
|
63
|
-
SourceName: sourceNames[i],
|
|
64
|
-
}));
|
|
65
|
-
}
|
|
66
|
-
return ok({ crossRefs });
|
|
67
|
-
},
|
|
68
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* getTargetSafety — fetch known safety liabilities for a target from
|
|
3
|
-
* Open Targets.
|
|
4
|
-
*/
|
|
5
|
-
import { getTargetSafetyLiabilities } from "../lib/opentargets-client.js";
|
|
6
|
-
type SafetyLiabilities = NonNullable<Awaited<ReturnType<typeof getTargetSafetyLiabilities>>>["safetyLiabilities"];
|
|
7
|
-
type GetTargetSafetyOutput = {
|
|
8
|
-
found: false;
|
|
9
|
-
ensemblId: string;
|
|
10
|
-
} | {
|
|
11
|
-
found: true;
|
|
12
|
-
targetSymbol: string;
|
|
13
|
-
safetyLiabilities: SafetyLiabilities;
|
|
14
|
-
};
|
|
15
|
-
export declare const getTargetSafetyTool: import("../define-tool.js").Tool<{
|
|
16
|
-
ensemblId: string;
|
|
17
|
-
}, GetTargetSafetyOutput>;
|
|
18
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* getTargetSafety — fetch known safety liabilities for a target from
|
|
3
|
-
* Open Targets.
|
|
4
|
-
*/
|
|
5
|
-
import { ok } from "neverthrow";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
import { defineTool } from "../define-tool.js";
|
|
8
|
-
import { getTargetSafetyLiabilities } from "../lib/opentargets-client.js";
|
|
9
|
-
export const getTargetSafetyTool = defineTool({
|
|
10
|
-
id: "get_target_safety",
|
|
11
|
-
description: "Get known safety liabilities for a target from Open Targets. Returns organ-specific toxicity signals, adverse events, and safety-related phenotypes linked to the target.",
|
|
12
|
-
inputSchema: z.object({
|
|
13
|
-
ensemblId: z.string().describe("Ensembl gene ID (e.g. ENSG00000141510)"),
|
|
14
|
-
}),
|
|
15
|
-
execute: async ({ ensemblId }) => {
|
|
16
|
-
const result = await getTargetSafetyLiabilities(ensemblId);
|
|
17
|
-
// "Target not found" is an expected outcome — a data variant, not an error.
|
|
18
|
-
if (!result)
|
|
19
|
-
return ok({ found: false, ensemblId });
|
|
20
|
-
return ok({
|
|
21
|
-
found: true,
|
|
22
|
-
targetSymbol: result.targetSymbol,
|
|
23
|
-
safetyLiabilities: result.safetyLiabilities,
|
|
24
|
-
});
|
|
25
|
-
},
|
|
26
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* searchCompounds tool — search ChEMBL for compounds by target, name, or SMILES.
|
|
3
|
-
*
|
|
4
|
-
* Supports three search modes:
|
|
5
|
-
* - "target": resolves target ChEMBL ID, fetches activities, extracts unique molecules
|
|
6
|
-
* - "compound": free-text search on molecule names
|
|
7
|
-
* - "smiles": flexmatch on canonical SMILES
|
|
8
|
-
*/
|
|
9
|
-
export declare const searchCompoundsTool: import("../define-tool.js").Tool<{
|
|
10
|
-
query: string;
|
|
11
|
-
searchType: "target" | "smiles" | "compound";
|
|
12
|
-
limit: number;
|
|
13
|
-
}, {
|
|
14
|
-
compounds: {
|
|
15
|
-
chemblId: string;
|
|
16
|
-
preferredCompoundName: string | null;
|
|
17
|
-
canonicalSmiles: string | null;
|
|
18
|
-
molecularWeight: number | null;
|
|
19
|
-
alogp: number | null;
|
|
20
|
-
molecularFormula: string | null;
|
|
21
|
-
}[];
|
|
22
|
-
}>;
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* searchCompounds tool — search ChEMBL for compounds by target, name, or SMILES.
|
|
3
|
-
*
|
|
4
|
-
* Supports three search modes:
|
|
5
|
-
* - "target": resolves target ChEMBL ID, fetches activities, extracts unique molecules
|
|
6
|
-
* - "compound": free-text search on molecule names
|
|
7
|
-
* - "smiles": flexmatch on canonical SMILES
|
|
8
|
-
*/
|
|
9
|
-
import { ok } from "neverthrow";
|
|
10
|
-
import { z } from "zod";
|
|
11
|
-
import { defineTool } from "../define-tool.js";
|
|
12
|
-
import { apiFetchValidated, describeApiError } from "../lib/api-utils.js";
|
|
13
|
-
import { CHEMBL_BASE, CHEMBL_HEADERS as HEADERS } from "../lib/chembl-config.js";
|
|
14
|
-
// A single schema that both validates and normalizes one ChEMBL molecule
|
|
15
|
-
// record: the `.object(...)` half is the snake_case wire shape (every field
|
|
16
|
-
// optional — ChEMBL omits absent values), the `.transform(...)` half maps it to
|
|
17
|
-
// the camelCase `Compound` we return. Parsing IS the validation, and because
|
|
18
|
-
// the transform rides on the schema, `z.infer` below is the OUTPUT type — no
|
|
19
|
-
// separate raw interface or mapper.
|
|
20
|
-
const MoleculeSchema = z
|
|
21
|
-
.object({
|
|
22
|
-
molecule_chembl_id: z.string().optional(),
|
|
23
|
-
// ChEMBL sends explicit `null` (not omission) for an unnamed compound, and
|
|
24
|
-
// `null` for the whole structures/properties blocks on biologics/antibodies
|
|
25
|
-
// — `.nullable()` so those rows parse instead of failing the `molecules` array.
|
|
26
|
-
pref_name: z.string().nullable().optional(),
|
|
27
|
-
molecule_structures: z
|
|
28
|
-
.object({
|
|
29
|
-
canonical_smiles: z.string().nullable().optional(),
|
|
30
|
-
})
|
|
31
|
-
.nullable()
|
|
32
|
-
.optional(),
|
|
33
|
-
molecule_properties: z
|
|
34
|
-
.object({
|
|
35
|
-
full_mwt: z.string().nullable().optional(),
|
|
36
|
-
alogp: z.string().nullable().optional(),
|
|
37
|
-
molecular_formula: z.string().nullable().optional(),
|
|
38
|
-
})
|
|
39
|
-
.nullable()
|
|
40
|
-
.optional(),
|
|
41
|
-
})
|
|
42
|
-
.transform((raw) => ({
|
|
43
|
-
chemblId: raw.molecule_chembl_id ?? "",
|
|
44
|
-
preferredCompoundName: raw.pref_name ?? null,
|
|
45
|
-
canonicalSmiles: raw.molecule_structures?.canonical_smiles ?? null,
|
|
46
|
-
molecularWeight: raw.molecule_properties?.full_mwt ? parseFloat(raw.molecule_properties.full_mwt) : null,
|
|
47
|
-
alogp: raw.molecule_properties?.alogp ? parseFloat(raw.molecule_properties.alogp) : null,
|
|
48
|
-
molecularFormula: raw.molecule_properties?.molecular_formula ?? null,
|
|
49
|
-
}));
|
|
50
|
-
const TargetSearchResponseSchema = z.object({
|
|
51
|
-
targets: z.array(z.object({ target_chembl_id: z.string().optional() })).optional(),
|
|
52
|
-
});
|
|
53
|
-
const ActivityResponseSchema = z.object({
|
|
54
|
-
activities: z.array(z.object({ molecule_chembl_id: z.string().optional() })).optional(),
|
|
55
|
-
});
|
|
56
|
-
const MoleculeResponseSchema = z.object({
|
|
57
|
-
molecules: z.array(MoleculeSchema).optional(),
|
|
58
|
-
});
|
|
59
|
-
async function searchByTarget(query, limit) {
|
|
60
|
-
// Step 1: Search targets to resolve ChEMBL ID
|
|
61
|
-
const targetRes = await apiFetchValidated(`${CHEMBL_BASE}/target/search.json?q=${encodeURIComponent(query)}&limit=1`, TargetSearchResponseSchema, {
|
|
62
|
-
headers: HEADERS,
|
|
63
|
-
});
|
|
64
|
-
if (targetRes.isErr()) {
|
|
65
|
-
if (targetRes.error.type === "http_status" && targetRes.error.status === 404)
|
|
66
|
-
return [];
|
|
67
|
-
throw new Error(describeApiError(targetRes.error));
|
|
68
|
-
}
|
|
69
|
-
if (!targetRes.value.targets?.length)
|
|
70
|
-
return [];
|
|
71
|
-
const targetChemblId = targetRes.value.targets[0].target_chembl_id;
|
|
72
|
-
if (!targetChemblId)
|
|
73
|
-
return [];
|
|
74
|
-
// Step 2: Fetch activities for that target
|
|
75
|
-
const activityRes = await apiFetchValidated(`${CHEMBL_BASE}/activity.json?target_chembl_id=${targetChemblId}&limit=${limit}`, ActivityResponseSchema, {
|
|
76
|
-
headers: HEADERS,
|
|
77
|
-
});
|
|
78
|
-
if (activityRes.isErr()) {
|
|
79
|
-
if (activityRes.error.type === "http_status" && activityRes.error.status === 404)
|
|
80
|
-
return [];
|
|
81
|
-
throw new Error(describeApiError(activityRes.error));
|
|
82
|
-
}
|
|
83
|
-
if (!activityRes.value.activities?.length)
|
|
84
|
-
return [];
|
|
85
|
-
// Step 3: Extract unique molecule IDs
|
|
86
|
-
const uniqueIds = new Set();
|
|
87
|
-
for (const act of activityRes.value.activities) {
|
|
88
|
-
if (act.molecule_chembl_id)
|
|
89
|
-
uniqueIds.add(act.molecule_chembl_id);
|
|
90
|
-
}
|
|
91
|
-
// Step 4: Fetch molecule details for unique compounds
|
|
92
|
-
const compounds = [];
|
|
93
|
-
const idArray = [...uniqueIds];
|
|
94
|
-
// Fetch in batches of 50 to avoid overly long URLs
|
|
95
|
-
const batchSize = 50;
|
|
96
|
-
for (let i = 0; i < idArray.length; i += batchSize) {
|
|
97
|
-
const batch = idArray.slice(i, i + batchSize);
|
|
98
|
-
const idsParam = batch.join(";");
|
|
99
|
-
const molRes = await apiFetchValidated(`${CHEMBL_BASE}/molecule/set/${idsParam}.json`, MoleculeResponseSchema, { headers: HEADERS });
|
|
100
|
-
if (molRes.isErr()) {
|
|
101
|
-
if (!(molRes.error.type === "http_status" && molRes.error.status === 404)) {
|
|
102
|
-
throw new Error(describeApiError(molRes.error));
|
|
103
|
-
}
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
if (molRes.value.molecules) {
|
|
107
|
-
for (const mol of molRes.value.molecules) {
|
|
108
|
-
compounds.push(mol);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return compounds;
|
|
113
|
-
}
|
|
114
|
-
async function searchByCompound(query, limit) {
|
|
115
|
-
const res = await apiFetchValidated(`${CHEMBL_BASE}/molecule/search.json?q=${encodeURIComponent(query)}&limit=${limit}`, MoleculeResponseSchema, {
|
|
116
|
-
headers: HEADERS,
|
|
117
|
-
});
|
|
118
|
-
if (res.isErr()) {
|
|
119
|
-
if (res.error.type === "http_status" && res.error.status === 404)
|
|
120
|
-
return [];
|
|
121
|
-
throw new Error(describeApiError(res.error));
|
|
122
|
-
}
|
|
123
|
-
return res.value.molecules ?? [];
|
|
124
|
-
}
|
|
125
|
-
async function searchBySmiles(smiles, limit) {
|
|
126
|
-
const res = await apiFetchValidated(`${CHEMBL_BASE}/molecule.json?molecule_structures__canonical_smiles__flexmatch=${encodeURIComponent(smiles)}&limit=${limit}`, MoleculeResponseSchema, { headers: HEADERS });
|
|
127
|
-
if (res.isErr()) {
|
|
128
|
-
if (res.error.type === "http_status" && res.error.status === 404)
|
|
129
|
-
return [];
|
|
130
|
-
throw new Error(describeApiError(res.error));
|
|
131
|
-
}
|
|
132
|
-
return res.value.molecules ?? [];
|
|
133
|
-
}
|
|
134
|
-
export const searchCompoundsTool = defineTool({
|
|
135
|
-
id: "search_compounds",
|
|
136
|
-
description: "Search ChEMBL for compounds by target name/ChEMBL ID, compound name, or SMILES. " +
|
|
137
|
-
"Returns compound metadata including ChEMBL IDs, SMILES, molecular weight, and LogP. " +
|
|
138
|
-
"Use searchType='target' to find compounds active against a target, " +
|
|
139
|
-
"'compound' for name search, 'smiles' for structure matching.",
|
|
140
|
-
inputSchema: z.object({
|
|
141
|
-
query: z.string().min(1).describe("Search term: target name/ID, compound name, or SMILES string"),
|
|
142
|
-
searchType: z
|
|
143
|
-
.enum(["target", "compound", "smiles"])
|
|
144
|
-
.describe("What to search by: 'target' (find active compounds), 'compound' (name search), 'smiles' (structure match)"),
|
|
145
|
-
limit: z.number().int().min(1).max(500).default(500).describe("Maximum number of results to return"),
|
|
146
|
-
}),
|
|
147
|
-
execute: async ({ query, searchType, limit = 500 }) => {
|
|
148
|
-
let compounds;
|
|
149
|
-
if (searchType === "target") {
|
|
150
|
-
compounds = await searchByTarget(query, limit);
|
|
151
|
-
}
|
|
152
|
-
else if (searchType === "smiles") {
|
|
153
|
-
compounds = await searchBySmiles(query, limit);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
compounds = await searchByCompound(query, limit);
|
|
157
|
-
}
|
|
158
|
-
return ok({ compounds });
|
|
159
|
-
},
|
|
160
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* searchCtxChemical — look up chemical details and physicochemical
|
|
3
|
-
* properties from EPA's CompTox Chemicals Dashboard (CTX API).
|
|
4
|
-
*/
|
|
5
|
-
interface ChemicalDetail {
|
|
6
|
-
dtxsid: string;
|
|
7
|
-
dtxcid: string;
|
|
8
|
-
casrn: string | null;
|
|
9
|
-
preferredName: string;
|
|
10
|
-
iupacName: string;
|
|
11
|
-
molFormula: string;
|
|
12
|
-
smiles: string;
|
|
13
|
-
inchikey: string;
|
|
14
|
-
monoisotopicMass: number | null;
|
|
15
|
-
averageMass: number | null;
|
|
16
|
-
qcLevel: number | null;
|
|
17
|
-
totalAssays: number | null;
|
|
18
|
-
activeAssays: number | null;
|
|
19
|
-
percentAssays: number | null;
|
|
20
|
-
pubchemCid: number | null;
|
|
21
|
-
pubmedCount: number | null;
|
|
22
|
-
sourcesCount: number | null;
|
|
23
|
-
}
|
|
24
|
-
interface PropertySummary {
|
|
25
|
-
propName: string;
|
|
26
|
-
unit: string;
|
|
27
|
-
experimentalCount: number | null;
|
|
28
|
-
experimentalMedian: number | null;
|
|
29
|
-
experimentalMin: number | null;
|
|
30
|
-
experimentalMax: number | null;
|
|
31
|
-
predictedCount: number | null;
|
|
32
|
-
predictedMedian: number | null;
|
|
33
|
-
predictedMin: number | null;
|
|
34
|
-
predictedMax: number | null;
|
|
35
|
-
}
|
|
36
|
-
type CtxChemicalOutput = {
|
|
37
|
-
found: false;
|
|
38
|
-
query: string;
|
|
39
|
-
} | {
|
|
40
|
-
found: true;
|
|
41
|
-
detail: ChemicalDetail;
|
|
42
|
-
properties?: PropertySummary[];
|
|
43
|
-
};
|
|
44
|
-
export declare function createSearchCtxChemicalTool(deps: {
|
|
45
|
-
apiKey: string;
|
|
46
|
-
}): import("../define-tool.js").Tool<{
|
|
47
|
-
query: string;
|
|
48
|
-
includeProperties: boolean;
|
|
49
|
-
}, CtxChemicalOutput>;
|
|
50
|
-
export {};
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* searchCtxChemical — look up chemical details and physicochemical
|
|
3
|
-
* properties from EPA's CompTox Chemicals Dashboard (CTX API).
|
|
4
|
-
*/
|
|
5
|
-
import { ok } from "neverthrow";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
import { defineTool } from "../define-tool.js";
|
|
8
|
-
import { apiFetchValidated, describeApiError } from "../lib/api-utils.js";
|
|
9
|
-
import { EPA_CCTE_BASE, getEpaCcteHeaders } from "../lib/toxcast-config.js";
|
|
10
|
-
// The chemical-search endpoint returns rows the code reads `[0].dtxsid` from
|
|
11
|
-
// after a length guard, so `dtxsid` stays required — a row missing it is a
|
|
12
|
-
// contract break surfaced as `invalid_response`, not a silent `undefined`.
|
|
13
|
-
const CtxChemicalSearchRowSchema = z.object({
|
|
14
|
-
dtxsid: z.string(),
|
|
15
|
-
});
|
|
16
|
-
// Raw CTX chemical-detail wire shape, validated at the fetch boundary. Every
|
|
17
|
-
// field is optional (the API omits absent values); the mapper below normalizes
|
|
18
|
-
// it into `ChemicalDetail`, folding in the resolved `dtxsid` fallback.
|
|
19
|
-
const RawChemicalDetailSchema = z.object({
|
|
20
|
-
dtxsid: z.string().optional(),
|
|
21
|
-
dtxcid: z.string().nullable().optional(),
|
|
22
|
-
casrn: z.string().nullable().optional(),
|
|
23
|
-
preferredName: z.string().nullable().optional(),
|
|
24
|
-
iupacName: z.string().nullable().optional(),
|
|
25
|
-
molFormula: z.string().nullable().optional(),
|
|
26
|
-
smiles: z.string().nullable().optional(),
|
|
27
|
-
inchikey: z.string().nullable().optional(),
|
|
28
|
-
monoisotopicMass: z.number().nullable().optional(),
|
|
29
|
-
averageMass: z.number().nullable().optional(),
|
|
30
|
-
qcLevel: z.number().nullable().optional(),
|
|
31
|
-
totalAssays: z.number().nullable().optional(),
|
|
32
|
-
activeAssays: z.number().nullable().optional(),
|
|
33
|
-
percentAssays: z.number().nullable().optional(),
|
|
34
|
-
pubchemCid: z.number().nullable().optional(),
|
|
35
|
-
pubmedCount: z.number().nullable().optional(),
|
|
36
|
-
sourcesCount: z.number().nullable().optional(),
|
|
37
|
-
});
|
|
38
|
-
const RawPropertySummarySchema = z.object({
|
|
39
|
-
propName: z.string().nullable().optional(),
|
|
40
|
-
unit: z.string().nullable().optional(),
|
|
41
|
-
experimentalCount: z.number().nullable().optional(),
|
|
42
|
-
experimentalMedian: z.number().nullable().optional(),
|
|
43
|
-
experimentalMin: z.number().nullable().optional(),
|
|
44
|
-
experimentalMax: z.number().nullable().optional(),
|
|
45
|
-
predictedCount: z.number().nullable().optional(),
|
|
46
|
-
predictedMedian: z.number().nullable().optional(),
|
|
47
|
-
predictedMin: z.number().nullable().optional(),
|
|
48
|
-
predictedMax: z.number().nullable().optional(),
|
|
49
|
-
});
|
|
50
|
-
export function createSearchCtxChemicalTool(deps) {
|
|
51
|
-
return defineTool({
|
|
52
|
-
id: "search_ctx_chemical",
|
|
53
|
-
description: "Look up chemical details and physicochemical properties from EPA's CompTox Chemicals Dashboard (CTX API). " +
|
|
54
|
-
"Returns chemical identifiers (DTXSID, CASRN, SMILES, InChIKey), molecular formula, mass, " +
|
|
55
|
-
"and a summary of predicted and experimental properties (logP, water solubility, vapor pressure, " +
|
|
56
|
-
"melting/boiling point, bioconcentration factor, Henry's law constant). " +
|
|
57
|
-
"Use for ADMET property assessment, compound characterization, and safety-relevant physicochemical profiling. " +
|
|
58
|
-
"Requires EPA_CCTE_API_KEY environment variable.",
|
|
59
|
-
inputSchema: z.object({
|
|
60
|
-
query: z
|
|
61
|
-
.string()
|
|
62
|
-
.describe("Chemical identifier: DTXSID (e.g. DTXSID7020182), CASRN (e.g. 80-05-7), " + "chemical name (e.g. bisphenol A), or InChIKey"),
|
|
63
|
-
includeProperties: z.boolean().default(true).describe("Include predicted/experimental property summaries (logP, solubility, etc.)"),
|
|
64
|
-
}),
|
|
65
|
-
execute: async ({ query, includeProperties = true }) => {
|
|
66
|
-
const headers = getEpaCcteHeaders(deps.apiKey);
|
|
67
|
-
const resolved = await resolveDtxsid(query, headers);
|
|
68
|
-
// "No chemical found" is an expected outcome — a data variant, not an error.
|
|
69
|
-
if (!resolved)
|
|
70
|
-
return ok({ found: false, query });
|
|
71
|
-
const { dtxsid } = resolved;
|
|
72
|
-
const detailUrl = `${EPA_CCTE_BASE}/chemical/detail/search/by-dtxsid/${dtxsid}?projection=chemicaldetailstandard`;
|
|
73
|
-
const detailRes = await apiFetchValidated(detailUrl, RawChemicalDetailSchema, { headers });
|
|
74
|
-
if (detailRes.isErr())
|
|
75
|
-
throw new Error(describeApiError(detailRes.error));
|
|
76
|
-
const d = detailRes.value ?? {};
|
|
77
|
-
const detail = {
|
|
78
|
-
dtxsid: d.dtxsid ?? dtxsid,
|
|
79
|
-
dtxcid: d.dtxcid ?? "",
|
|
80
|
-
casrn: d.casrn ?? null,
|
|
81
|
-
preferredName: d.preferredName ?? "",
|
|
82
|
-
iupacName: d.iupacName ?? "",
|
|
83
|
-
molFormula: d.molFormula ?? "",
|
|
84
|
-
smiles: d.smiles ?? "",
|
|
85
|
-
inchikey: d.inchikey ?? "",
|
|
86
|
-
monoisotopicMass: d.monoisotopicMass ?? null,
|
|
87
|
-
averageMass: d.averageMass ?? null,
|
|
88
|
-
qcLevel: d.qcLevel ?? null,
|
|
89
|
-
totalAssays: d.totalAssays ?? null,
|
|
90
|
-
activeAssays: d.activeAssays ?? null,
|
|
91
|
-
percentAssays: d.percentAssays ?? null,
|
|
92
|
-
pubchemCid: d.pubchemCid ?? null,
|
|
93
|
-
pubmedCount: d.pubmedCount ?? null,
|
|
94
|
-
sourcesCount: d.sourcesCount ?? null,
|
|
95
|
-
};
|
|
96
|
-
const result = { found: true, detail };
|
|
97
|
-
if (includeProperties) {
|
|
98
|
-
const propUrl = `${EPA_CCTE_BASE}/chemical/property/summary/search/by-dtxsid/${dtxsid}`;
|
|
99
|
-
const propRes = await apiFetchValidated(propUrl, z.array(RawPropertySummarySchema), { headers });
|
|
100
|
-
if (propRes.isOk() && Array.isArray(propRes.value)) {
|
|
101
|
-
result.properties = propRes.value.map((p) => ({
|
|
102
|
-
propName: p.propName ?? "",
|
|
103
|
-
unit: p.unit ?? "",
|
|
104
|
-
experimentalCount: p.experimentalCount ?? null,
|
|
105
|
-
experimentalMedian: p.experimentalMedian ?? null,
|
|
106
|
-
experimentalMin: p.experimentalMin ?? null,
|
|
107
|
-
experimentalMax: p.experimentalMax ?? null,
|
|
108
|
-
predictedCount: p.predictedCount ?? null,
|
|
109
|
-
predictedMedian: p.predictedMedian ?? null,
|
|
110
|
-
predictedMin: p.predictedMin ?? null,
|
|
111
|
-
predictedMax: p.predictedMax ?? null,
|
|
112
|
-
}));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return ok(result);
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
async function resolveDtxsid(query, headers) {
|
|
120
|
-
if (query.startsWith("DTXSID")) {
|
|
121
|
-
return { dtxsid: query };
|
|
122
|
-
}
|
|
123
|
-
const url = `${EPA_CCTE_BASE}/chemical/search/equal/${encodeURIComponent(query)}`;
|
|
124
|
-
const res = await apiFetchValidated(url, z.array(CtxChemicalSearchRowSchema), { headers });
|
|
125
|
-
if (res.isErr())
|
|
126
|
-
throw new Error(describeApiError(res.error));
|
|
127
|
-
if (!res.value?.length)
|
|
128
|
-
return null;
|
|
129
|
-
return { dtxsid: res.value[0].dtxsid };
|
|
130
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* searchCtxExposure — look up chemical exposure data from EPA's CTX
|
|
3
|
-
* Exposure APIs.
|
|
4
|
-
*/
|
|
5
|
-
interface SeemPrediction {
|
|
6
|
-
dtxsid: string;
|
|
7
|
-
productionVolume: number | null;
|
|
8
|
-
units: string;
|
|
9
|
-
probabilityDietary: number | null;
|
|
10
|
-
probabilityResidential: number | null;
|
|
11
|
-
probabilityPesticide: number | null;
|
|
12
|
-
probabilityIndustrial: number | null;
|
|
13
|
-
}
|
|
14
|
-
interface HttkParameter {
|
|
15
|
-
parameter: string;
|
|
16
|
-
measured: number | null;
|
|
17
|
-
predicted: number | null;
|
|
18
|
-
units: string;
|
|
19
|
-
model: string;
|
|
20
|
-
species: string;
|
|
21
|
-
reference: string;
|
|
22
|
-
}
|
|
23
|
-
interface FunctionalUse {
|
|
24
|
-
functionCategory: string;
|
|
25
|
-
reportedFunction: string;
|
|
26
|
-
docTitle: string;
|
|
27
|
-
}
|
|
28
|
-
interface ProductData {
|
|
29
|
-
productName: string;
|
|
30
|
-
generalCategory: string;
|
|
31
|
-
productFamily: string;
|
|
32
|
-
productType: string;
|
|
33
|
-
centralWeightFraction: number | null;
|
|
34
|
-
weightFractionType: string;
|
|
35
|
-
}
|
|
36
|
-
interface ExposureOutput {
|
|
37
|
-
found: true;
|
|
38
|
-
dtxsid: string;
|
|
39
|
-
seem?: SeemPrediction;
|
|
40
|
-
httk?: HttkParameter[];
|
|
41
|
-
functionalUse?: FunctionalUse[];
|
|
42
|
-
productData?: ProductData[];
|
|
43
|
-
}
|
|
44
|
-
type ExposureResult = {
|
|
45
|
-
found: false;
|
|
46
|
-
query: string;
|
|
47
|
-
} | ExposureOutput;
|
|
48
|
-
export declare function createSearchCtxExposureTool(deps: {
|
|
49
|
-
apiKey: string;
|
|
50
|
-
}): import("../define-tool.js").Tool<{
|
|
51
|
-
query: string;
|
|
52
|
-
dataType: "all" | "seem" | "httk" | "functional-use" | "product-data";
|
|
53
|
-
limit: number;
|
|
54
|
-
}, ExposureResult>;
|
|
55
|
-
export {};
|