@inflexa-ai/harness 0.17.0 → 0.18.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/dist/agents/report-builder.d.ts +2 -0
- package/dist/agents/report-builder.js +2 -0
- package/dist/app/spawn-report-session.d.ts +85 -0
- package/dist/app/spawn-report-session.js +83 -0
- package/dist/contracts/chat-events.d.ts +9 -0
- package/dist/contracts/index.d.ts +6 -2
- package/dist/contracts/index.js +3 -1
- package/dist/contracts/organ-system.d.ts +49 -0
- package/dist/contracts/organ-system.js +67 -0
- package/dist/contracts/report-blocks.d.ts +564 -0
- package/dist/contracts/report-blocks.js +117 -0
- package/dist/contracts/report-reference.d.ts +459 -0
- package/dist/contracts/report-reference.js +256 -0
- package/dist/contracts/schemas/chat-events.d.ts +2 -0
- package/dist/contracts/schemas/chat-events.js +2 -0
- package/dist/contracts/severity.d.ts +15 -0
- package/dist/contracts/severity.js +10 -0
- package/dist/contracts/target-dossier.d.ts +8675 -12972
- package/dist/contracts/target-dossier.js +534 -591
- package/dist/data/safety-panel-schema.d.ts +18 -5
- package/dist/data/safety-panel-schema.js +4 -4
- package/dist/execution/artifact-metadata.js +1 -0
- package/dist/execution/report-runner.js +1 -3
- package/dist/execution/run-synthesis.js +2 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +19 -0
- package/dist/lib/async-utils.d.ts +16 -4
- package/dist/lib/async-utils.js +20 -15
- package/dist/lib/host-concurrency.js +1 -0
- package/dist/loop/__fixtures__/scripted-provider.js +23 -2
- package/dist/loop/run-agent.js +58 -10
- package/dist/loop/tool-detail.d.ts +40 -0
- package/dist/loop/tool-detail.js +35 -3
- package/dist/loop/types.d.ts +13 -0
- package/dist/memory/thread-history.d.ts +10 -0
- package/dist/memory/thread-history.js +12 -1
- package/dist/prompts/target-assessment/briefs/executive-recommendation.d.ts +1 -1
- package/dist/prompts/target-assessment/briefs/executive-recommendation.js +5 -5
- package/dist/prompts/target-assessment/briefs/liability-bullets.d.ts +1 -1
- package/dist/prompts/target-assessment/briefs/liability-bullets.js +1 -1
- package/dist/prompts/target-assessment/briefs/target-organ-liabilities.d.ts +1 -1
- package/dist/prompts/target-assessment/briefs/target-organ-liabilities.js +11 -3
- package/dist/prompts/target-assessment/investigation/adversarial-critique.d.ts +1 -0
- package/dist/prompts/target-assessment/investigation/adversarial-critique.js +67 -0
- package/dist/prompts/target-assessment/investigation/claim-reverification.d.ts +1 -0
- package/dist/prompts/target-assessment/investigation/claim-reverification.js +49 -0
- package/dist/prompts/target-assessment/investigation/index.d.ts +3 -0
- package/dist/prompts/target-assessment/investigation/index.js +3 -0
- package/dist/prompts/target-assessment/investigation/mechanism-proposal.d.ts +1 -0
- package/dist/prompts/target-assessment/investigation/mechanism-proposal.js +49 -0
- package/dist/prompts/target-assessment/tox-voice/index.d.ts +1 -1
- package/dist/prompts/target-assessment/tox-voice/vocabulary.d.ts +8 -5
- package/dist/prompts/target-assessment/tox-voice/vocabulary.js +9 -20
- package/dist/providers/__fixtures__/session.d.ts +5 -4
- package/dist/providers/__fixtures__/session.js +4 -4
- package/dist/report-model/block-walk.d.ts +56 -0
- package/dist/report-model/block-walk.js +89 -0
- package/dist/report-model/draft-finish.d.ts +60 -0
- package/dist/report-model/draft-finish.js +56 -0
- package/dist/report-model/draft-operations.d.ts +125 -0
- package/dist/report-model/draft-operations.js +341 -0
- package/dist/report-model/draft-read.d.ts +59 -0
- package/dist/report-model/draft-read.js +109 -0
- package/dist/report-model/draft.d.ts +51 -0
- package/dist/report-model/draft.js +32 -0
- package/dist/report-model/fixture-resolver.d.ts +8 -0
- package/dist/report-model/fixture-resolver.js +252 -0
- package/dist/report-model/mint-snapshot.d.ts +30 -0
- package/dist/report-model/mint-snapshot.js +40 -0
- package/dist/report-model/reference-resolver.d.ts +113 -0
- package/dist/report-model/reference-resolver.js +60 -0
- package/dist/report-model/structural-validation.d.ts +22 -0
- package/dist/report-model/structural-validation.js +68 -0
- package/dist/report-model/validate.d.ts +40 -0
- package/dist/report-model/validate.js +80 -0
- package/dist/report-render/chart.d.ts +33 -0
- package/dist/report-render/chart.js +538 -0
- package/dist/report-render/page.d.ts +127 -0
- package/dist/report-render/page.js +307 -0
- package/dist/report-render/references.d.ts +32 -0
- package/dist/report-render/references.js +44 -0
- package/dist/report-render/render.d.ts +25 -0
- package/dist/report-render/render.js +125 -0
- package/dist/report-render/script-json.d.ts +13 -0
- package/dist/report-render/script-json.js +15 -0
- package/dist/report-render/types.d.ts +39 -0
- package/dist/report-render/types.js +10 -0
- package/dist/report-render/views/chart-view.d.ts +11 -0
- package/dist/report-render/views/chart-view.js +23 -0
- package/dist/report-render/views/page-view.d.ts +20 -0
- package/dist/report-render/views/page-view.js +49 -0
- package/dist/report-render/views/prose.d.ts +28 -0
- package/dist/report-render/views/prose.js +75 -0
- package/dist/report-render/views/references-view.d.ts +20 -0
- package/dist/report-render/views/references-view.js +64 -0
- package/dist/report-render/views/values.d.ts +42 -0
- package/dist/report-render/views/values.js +43 -0
- package/dist/runtime/boot.d.ts +3 -3
- package/dist/runtime/boot.js +15 -4
- package/dist/runtime/dbos.d.ts +4 -4
- package/dist/state/artifacts.d.ts +16 -0
- package/dist/state/artifacts.js +18 -0
- package/dist/state/init.js +31 -0
- package/dist/state/purge-analysis.js +1 -0
- package/dist/state/report-versions.d.ts +132 -0
- package/dist/state/report-versions.js +194 -0
- package/dist/tasks/data-profile.js +1 -0
- package/dist/tools/bio/chembl.js +1 -0
- package/dist/tools/bio/comptox.js +1 -0
- package/dist/tools/bio/drug-gene-interactions.js +1 -0
- package/dist/tools/bio/gene-disease-evidence.js +1 -0
- package/dist/tools/bio/gene-preclinical-profile.js +1 -0
- package/dist/tools/bio/keys.d.ts +3 -2
- package/dist/tools/bio/keys.js +3 -2
- package/dist/tools/bio/lookup-annotation.js +1 -0
- package/dist/tools/bio/opentargets.d.ts +3 -3
- package/dist/tools/bio/opentargets.js +4 -3
- package/dist/tools/bio/pubchem.js +1 -0
- package/dist/tools/bio/search-clinical-trials.js +1 -0
- package/dist/tools/bio/search-faers.js +1 -0
- package/dist/tools/bio/search-geo-datasets.js +1 -0
- package/dist/tools/bio/search-interactions.js +1 -0
- package/dist/tools/bio/target-safety.d.ts +4 -6
- package/dist/tools/bio/target-safety.js +7 -6
- package/dist/tools/define-tool.d.ts +19 -12
- package/dist/tools/define-tool.js +4 -2
- package/dist/tools/display/show-user.js +1 -0
- package/dist/tools/iterate-report.js +2 -0
- package/dist/tools/lib/chembl-client.d.ts +2 -0
- package/dist/tools/lib/chembl-client.js +1 -0
- package/dist/tools/lib/monarch-client.d.ts +42 -0
- package/dist/tools/lib/monarch-client.js +100 -0
- package/dist/tools/report/build-report.js +1 -0
- package/dist/tools/report/mint-preview-url.js +1 -0
- package/dist/tools/report/preview-snapshot.js +1 -0
- package/dist/tools/report/submit-report.js +1 -0
- package/dist/tools/report/version-fs.js +4 -0
- package/dist/tools/report-authoring/authoring-tools.d.ts +134 -0
- package/dist/tools/report-authoring/authoring-tools.js +352 -0
- package/dist/tools/research/context7-docs.js +2 -0
- package/dist/tools/research/generate-analogy-report.js +1 -0
- package/dist/tools/research/generate-plan.js +3 -0
- package/dist/tools/research/inspect-data-profile.js +4 -0
- package/dist/tools/research/literature-reviewer.js +1 -0
- package/dist/tools/research/search-arxiv.js +1 -0
- package/dist/tools/research/search-github-repos.js +1 -0
- package/dist/tools/research/search-semantic-scholar.js +1 -0
- package/dist/tools/sandbox/list-available-packages.js +23 -0
- package/dist/tools/sandbox/list-available-refs.js +36 -0
- package/dist/tools/sandbox/report-blocker.js +1 -0
- package/dist/tools/sandbox/skills.js +2 -0
- package/dist/tools/workspace/file-stat.js +1 -0
- package/dist/tools/workspace/show-file.js +2 -0
- package/dist/tools/workspace/show-plan.js +1 -0
- package/dist/workflows/execute-analysis.d.ts +5 -1
- package/dist/workflows/execute-analysis.js +5 -5
- package/dist/workflows/execute-target-assessment.d.ts +13 -2
- package/dist/workflows/execute-target-assessment.js +78 -16
- package/dist/workflows/target-assessment/assemblers/index.d.ts +1 -1
- package/dist/workflows/target-assessment/assemblers/index.js +1 -1
- package/dist/workflows/target-assessment/assemblers/literature.d.ts +9 -27
- package/dist/workflows/target-assessment/assemblers/literature.js +32 -48
- package/dist/workflows/target-assessment/assemblers/orchestrator.d.ts +17 -9
- package/dist/workflows/target-assessment/assemblers/orchestrator.js +195 -85
- package/dist/workflows/target-assessment/assemblers/safety.d.ts +70 -48
- package/dist/workflows/target-assessment/assemblers/safety.js +125 -42
- package/dist/workflows/target-assessment/collectors/index.d.ts +5 -2
- package/dist/workflows/target-assessment/collectors/index.js +48 -5
- package/dist/workflows/target-assessment/coverage.d.ts +43 -27
- package/dist/workflows/target-assessment/coverage.js +33 -29
- package/dist/workflows/target-assessment/fanout/index.js +1 -0
- package/dist/workflows/target-assessment/investigation/index.d.ts +97 -0
- package/dist/workflows/target-assessment/investigation/index.js +419 -0
- package/dist/workflows/target-assessment/lib/approval-precedents.d.ts +26 -5
- package/dist/workflows/target-assessment/lib/approval-precedents.js +95 -29
- package/dist/workflows/target-assessment/lib/citation-validator.js +1 -1
- package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.d.ts +2 -2
- package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.d.ts +2 -3
- package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.js +0 -4
- package/dist/workflows/target-assessment/lib/compute-derived.d.ts +6 -5
- package/dist/workflows/target-assessment/lib/compute-derived.js +14 -5
- package/dist/workflows/target-assessment/lib/family-complex-supplement.d.ts +5 -6
- package/dist/workflows/target-assessment/lib/family-complex-supplement.js +2 -3
- package/dist/workflows/target-assessment/lib/fda-label-safety.d.ts +72 -0
- package/dist/workflows/target-assessment/lib/fda-label-safety.js +166 -0
- package/dist/workflows/target-assessment/lib/heterodimer-filter.d.ts +0 -9
- package/dist/workflows/target-assessment/lib/heterodimer-filter.js +0 -10
- package/dist/workflows/target-assessment/lib/hpo-organ-map.d.ts +34 -0
- package/dist/workflows/target-assessment/lib/hpo-organ-map.js +63 -0
- package/dist/workflows/target-assessment/lib/impc-organ-map.d.ts +19 -0
- package/dist/workflows/target-assessment/lib/impc-organ-map.js +39 -0
- package/dist/workflows/target-assessment/lib/meddra-organ-map.d.ts +24 -14
- package/dist/workflows/target-assessment/lib/meddra-organ-map.js +59 -47
- package/dist/workflows/target-assessment/lib/recommendation-sanitizer.js +1 -1
- package/dist/workflows/target-assessment/lib/regulatory-actions.d.ts +2 -3
- package/dist/workflows/target-assessment/lib/regulatory-actions.js +33 -4
- package/dist/workflows/target-assessment/lib/safety-corroboration.d.ts +44 -0
- package/dist/workflows/target-assessment/lib/safety-corroboration.js +273 -0
- package/dist/workflows/target-assessment/lib/target-identity-filter.d.ts +5 -7
- package/dist/workflows/target-assessment/lib/target-identity-filter.js +5 -7
- package/dist/workflows/target-assessment/metrics.d.ts +1 -6
- package/dist/workflows/target-assessment/metrics.js +1 -13
- package/dist/workflows/target-assessment/phase4-assemble.d.ts +2147 -807
- package/dist/workflows/target-assessment/phase4-assemble.js +19 -19
- package/dist/workflows/target-assessment/phase5-persist.d.ts +20 -21
- package/dist/workflows/target-assessment/phase5-persist.js +56 -173
- package/dist/workflows/target-assessment/schemas.d.ts +46 -1
- package/dist/workflows/target-assessment/schemas.js +19 -0
- package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.d.ts +1 -0
- package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.js +2 -0
- package/dist/workflows/target-assessment/steps/phase2-aggregate.d.ts +26 -62
- package/dist/workflows/target-assessment/steps/phase2-aggregate.js +0 -4
- package/dist/workflows/target-assessment/steps/phase3-aggregate.d.ts +27 -154
- package/dist/workflows/target-assessment/steps/phase3-aggregate.js +0 -6
- package/dist/workflows/target-assessment/steps/synthesis/diagnostics.d.ts +0 -6
- package/dist/workflows/target-assessment/steps/synthesis/diagnostics.js +0 -18
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-polypharm.d.ts +1 -0
- package/dist/workflows/target-assessment/synthesis/index.d.ts +52 -5
- package/dist/workflows/target-assessment/synthesis/index.js +4 -1
- package/dist/workflows/target-assessment/synthesis-probes.d.ts +3 -3
- package/package.json +4 -1
|
@@ -413,6 +413,7 @@ export const planReportTool = defineTool({
|
|
|
413
413
|
"existing preview with `modifications` needs no brief — you may go " +
|
|
414
414
|
"straight to `submit_report`.)",
|
|
415
415
|
inputSchema: z.object({}),
|
|
416
|
+
describeCall: "none",
|
|
416
417
|
executionMode: "inline",
|
|
417
418
|
execute: async () => ok({
|
|
418
419
|
schema: REPORT_BRIEF_JSON_SCHEMA,
|
|
@@ -472,6 +473,7 @@ export function createReportSubmitTool(deps) {
|
|
|
472
473
|
"as an `error` string. Returns the preview id + version and emits a " +
|
|
473
474
|
"preview card.",
|
|
474
475
|
inputSchema: submitReportInputSchema,
|
|
476
|
+
describeCall: "none",
|
|
475
477
|
execute: async (input, ctx) => {
|
|
476
478
|
// The brief rides as `unknown` so its ~12k schema stays off the
|
|
477
479
|
// always-on tool surface. Validate it here and return issues as DATA
|
|
@@ -58,6 +58,8 @@ export interface ChemblPolypharmHit {
|
|
|
58
58
|
moleculeChemblId: string;
|
|
59
59
|
targetChemblId: string;
|
|
60
60
|
targetName: string | null;
|
|
61
|
+
/** The assay the reported activity was measured in, when ChEMBL names one. */
|
|
62
|
+
assayChemblId: string | null;
|
|
61
63
|
standardType: string | null;
|
|
62
64
|
standardValue: number | null;
|
|
63
65
|
standardUnits: string | null;
|
|
@@ -431,6 +431,7 @@ export async function getModulatorPolypharmacology(moleculeChemblId, options = {
|
|
|
431
431
|
moleculeChemblId,
|
|
432
432
|
targetChemblId: tid,
|
|
433
433
|
targetName: null,
|
|
434
|
+
assayChemblId: raw.assay_chembl_id ?? null,
|
|
434
435
|
standardType: raw.standard_type ?? null,
|
|
435
436
|
standardValue: parseNumeric(raw.standard_value),
|
|
436
437
|
standardUnits: raw.standard_units ?? null,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure async client functions for the Monarch Initiative association API.
|
|
3
|
+
*
|
|
4
|
+
* Monarch curates human gene→phenotype annotations (HPO, from HPOA/OMIM/
|
|
5
|
+
* Orphanet): *human* loss-of-function evidence, meaning what is observed in
|
|
6
|
+
* people carrying variation in the gene, as opposed to a mouse knockout's
|
|
7
|
+
* phenotype or an aggregate gene-disease association score.
|
|
8
|
+
*
|
|
9
|
+
* Each phenotype association carries its HPO ancestor closure, which is what
|
|
10
|
+
* lets a consumer resolve the phenotype onto an organ system by identifier
|
|
11
|
+
* rather than by matching prose.
|
|
12
|
+
*
|
|
13
|
+
* The API is keyless and public.
|
|
14
|
+
*/
|
|
15
|
+
/** A curated human phenotype attributed to variation in the gene. */
|
|
16
|
+
export interface MonarchPhenotypeAssociation {
|
|
17
|
+
/** HPO term id, e.g. `HP:0001392`. */
|
|
18
|
+
readonly hpoId: string;
|
|
19
|
+
readonly label: string;
|
|
20
|
+
/** The term's HPO ancestor closure, for identifier-based organ resolution. */
|
|
21
|
+
readonly ancestorIds: string[];
|
|
22
|
+
/** PMIDs (as `PMID:…` curies) cited by the annotation. */
|
|
23
|
+
readonly publications: string[];
|
|
24
|
+
/** The disease the phenotype was annotated under, when the annotation names one. */
|
|
25
|
+
readonly diseaseContext: string | null;
|
|
26
|
+
/** Share of affected individuals showing the phenotype, when annotated. */
|
|
27
|
+
readonly frequencyPercent: number | null;
|
|
28
|
+
readonly primaryKnowledgeSource: string | null;
|
|
29
|
+
}
|
|
30
|
+
export interface MonarchGeneProfile {
|
|
31
|
+
/** The curie the gene was queried by, e.g. `HGNC:1097`. */
|
|
32
|
+
readonly geneCurie: string;
|
|
33
|
+
readonly phenotypes: MonarchPhenotypeAssociation[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Curated human phenotype associations for one gene.
|
|
37
|
+
*
|
|
38
|
+
* `geneCurie` is a prefixed identifier Monarch resolves — an HGNC id
|
|
39
|
+
* (`HGNC:1097`) or an NCBI gene id (`NCBIGene:673`). A gene Monarch does not
|
|
40
|
+
* hold returns an empty profile rather than an error.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getGenePhenotypeProfile(geneCurie: string): Promise<MonarchGeneProfile>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure async client functions for the Monarch Initiative association API.
|
|
3
|
+
*
|
|
4
|
+
* Monarch curates human gene→phenotype annotations (HPO, from HPOA/OMIM/
|
|
5
|
+
* Orphanet): *human* loss-of-function evidence, meaning what is observed in
|
|
6
|
+
* people carrying variation in the gene, as opposed to a mouse knockout's
|
|
7
|
+
* phenotype or an aggregate gene-disease association score.
|
|
8
|
+
*
|
|
9
|
+
* Each phenotype association carries its HPO ancestor closure, which is what
|
|
10
|
+
* lets a consumer resolve the phenotype onto an organ system by identifier
|
|
11
|
+
* rather than by matching prose.
|
|
12
|
+
*
|
|
13
|
+
* The API is keyless and public.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import { apiFetchValidated, describeApiError, isUnexpectedApiError } from "./api-utils.js";
|
|
17
|
+
const MONARCH_BASE = "https://api-v3.monarchinitiative.org/v3/api";
|
|
18
|
+
/** Row cap per association category — a well-annotated gene carries a few hundred. */
|
|
19
|
+
const ASSOCIATION_ROW_CAP = 300;
|
|
20
|
+
/** The closure arrays make these responses large; the default timeout is short for them. */
|
|
21
|
+
const REQUEST_TIMEOUT_MS = 120_000;
|
|
22
|
+
const HUMAN_TAXON = "NCBITaxon:9606";
|
|
23
|
+
/** Phenotype terms live in the HPO namespace; a model-organism term would not. */
|
|
24
|
+
const HPO_NAMESPACE = "HP";
|
|
25
|
+
/**
|
|
26
|
+
* One association row. Every field is optional because Monarch returns the same
|
|
27
|
+
* envelope for every category and populates only what applies; the reader below
|
|
28
|
+
* treats a missing field as absent rather than trusting the wire.
|
|
29
|
+
*/
|
|
30
|
+
const MonarchAssociationSchema = z.object({
|
|
31
|
+
subject_taxon: z.string().nullish(),
|
|
32
|
+
object: z.string().optional(),
|
|
33
|
+
object_label: z.string().nullish(),
|
|
34
|
+
object_closure: z.array(z.string()).nullish(),
|
|
35
|
+
publications: z.array(z.string()).nullish(),
|
|
36
|
+
primary_knowledge_source: z.string().nullish(),
|
|
37
|
+
disease_context_qualifier: z.string().nullish(),
|
|
38
|
+
has_percentage: z.number().nullish(),
|
|
39
|
+
});
|
|
40
|
+
const MonarchAssociationPageSchema = z.object({
|
|
41
|
+
items: z.array(MonarchAssociationSchema).optional(),
|
|
42
|
+
});
|
|
43
|
+
async function fetchAssociations(geneCurie, category) {
|
|
44
|
+
const params = new URLSearchParams({
|
|
45
|
+
subject: geneCurie,
|
|
46
|
+
category,
|
|
47
|
+
limit: String(ASSOCIATION_ROW_CAP),
|
|
48
|
+
});
|
|
49
|
+
const res = await apiFetchValidated(`${MONARCH_BASE}/association?${params.toString()}`, MonarchAssociationPageSchema, {
|
|
50
|
+
timeoutMs: REQUEST_TIMEOUT_MS,
|
|
51
|
+
});
|
|
52
|
+
if (res.isErr()) {
|
|
53
|
+
// A 4xx means the gene curie is not one Monarch holds — an expected
|
|
54
|
+
// "not found", returned as an empty page. Anything else is a real
|
|
55
|
+
// failure and surfaces.
|
|
56
|
+
if (isUnexpectedApiError(res.error))
|
|
57
|
+
throw new Error(describeApiError(res.error));
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
return res.value.items ?? [];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Human phenotype annotations only.
|
|
64
|
+
*
|
|
65
|
+
* Monarch serves a gene's phenotype edges from several annotation sets; the
|
|
66
|
+
* filter keeps the rows whose subject is the human gene and whose object is an
|
|
67
|
+
* HPO term, so model-organism phenotypes stay with the collector that owns them.
|
|
68
|
+
*/
|
|
69
|
+
function toPhenotype(row) {
|
|
70
|
+
if (!row.object || !row.object.startsWith(`${HPO_NAMESPACE}:`))
|
|
71
|
+
return null;
|
|
72
|
+
if (row.subject_taxon != null && row.subject_taxon !== HUMAN_TAXON)
|
|
73
|
+
return null;
|
|
74
|
+
return {
|
|
75
|
+
hpoId: row.object,
|
|
76
|
+
label: row.object_label ?? "",
|
|
77
|
+
ancestorIds: row.object_closure ?? [],
|
|
78
|
+
publications: row.publications ?? [],
|
|
79
|
+
diseaseContext: row.disease_context_qualifier ?? null,
|
|
80
|
+
frequencyPercent: row.has_percentage ?? null,
|
|
81
|
+
primaryKnowledgeSource: row.primary_knowledge_source ?? null,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Curated human phenotype associations for one gene.
|
|
86
|
+
*
|
|
87
|
+
* `geneCurie` is a prefixed identifier Monarch resolves — an HGNC id
|
|
88
|
+
* (`HGNC:1097`) or an NCBI gene id (`NCBIGene:673`). A gene Monarch does not
|
|
89
|
+
* hold returns an empty profile rather than an error.
|
|
90
|
+
*/
|
|
91
|
+
export async function getGenePhenotypeProfile(geneCurie) {
|
|
92
|
+
const rows = await fetchAssociations(geneCurie, "biolink:GeneToPhenotypicFeatureAssociation");
|
|
93
|
+
const phenotypes = [];
|
|
94
|
+
for (const row of rows) {
|
|
95
|
+
const p = toPhenotype(row);
|
|
96
|
+
if (p)
|
|
97
|
+
phenotypes.push(p);
|
|
98
|
+
}
|
|
99
|
+
return { geneCurie, phenotypes };
|
|
100
|
+
}
|
|
@@ -16,6 +16,7 @@ export function createBuildReportTool(state) {
|
|
|
16
16
|
"Always use this — never invoke a build script directly. Returns " +
|
|
17
17
|
"structured errors with line numbers when the template is broken.",
|
|
18
18
|
inputSchema: z.object({}),
|
|
19
|
+
describeCall: "none",
|
|
19
20
|
execute: async () => {
|
|
20
21
|
return ok(await renderReport({
|
|
21
22
|
versionDir: state.versionDir,
|
|
@@ -24,6 +24,7 @@ export function createMintPreviewUrlTool(state) {
|
|
|
24
24
|
inputSchema: z.object({
|
|
25
25
|
version: z.number().optional().describe("Version to mint for. Defaults to the iteration's current version."),
|
|
26
26
|
}),
|
|
27
|
+
describeCall: "none",
|
|
27
28
|
execute: async (input) => {
|
|
28
29
|
const version = input.version ?? state.currentVersion;
|
|
29
30
|
const result = await state.previews.mintPreviewAccess(state.resourceId, state.previewId);
|
|
@@ -47,6 +47,7 @@ export function createPreviewSnapshotTool(state) {
|
|
|
47
47
|
.optional()
|
|
48
48
|
.describe("Optional extra wait in ms after the theme-ready event (e.g., for chart paint). Capped at 30s."),
|
|
49
49
|
}),
|
|
50
|
+
describeCall: "none",
|
|
50
51
|
execute: async (input) => {
|
|
51
52
|
let url = state.urlCell.url;
|
|
52
53
|
const expiresAt = state.urlCell.expiresAt;
|
|
@@ -42,6 +42,7 @@ export function createSubmitReportTool(state) {
|
|
|
42
42
|
"samples — the rest had no QC row'. " +
|
|
43
43
|
"Leave empty when the report shipped cleanly."),
|
|
44
44
|
}),
|
|
45
|
+
describeCall: "none",
|
|
45
46
|
execute: async (input) => {
|
|
46
47
|
const problems = [];
|
|
47
48
|
// 1. report.html.j2 exists — the report itself, as opposed to the
|
|
@@ -44,6 +44,7 @@ export function createVersionFsTools(state) {
|
|
|
44
44
|
path: z.string().min(1),
|
|
45
45
|
content: z.string(),
|
|
46
46
|
}),
|
|
47
|
+
describeCall: "none",
|
|
47
48
|
execute: async ({ path, content }) => {
|
|
48
49
|
const resolved = resolveAgentPath(path, state.versionDir);
|
|
49
50
|
if (resolved.kind === "out_of_scope") {
|
|
@@ -73,6 +74,7 @@ export function createVersionFsTools(state) {
|
|
|
73
74
|
oldText: z.string().min(1),
|
|
74
75
|
newText: z.string(),
|
|
75
76
|
}),
|
|
77
|
+
describeCall: "none",
|
|
76
78
|
execute: async ({ path, oldText, newText }) => {
|
|
77
79
|
const resolved = resolveAgentPath(path, state.versionDir);
|
|
78
80
|
if (resolved.kind === "out_of_scope") {
|
|
@@ -112,6 +114,7 @@ export function createVersionFsTools(state) {
|
|
|
112
114
|
inputSchema: z.object({
|
|
113
115
|
path: z.string().min(1),
|
|
114
116
|
}),
|
|
117
|
+
describeCall: "none",
|
|
115
118
|
execute: async ({ path }) => {
|
|
116
119
|
const resolved = resolveAgentPath(path, state.versionDir);
|
|
117
120
|
if (resolved.kind === "out_of_scope") {
|
|
@@ -148,6 +151,7 @@ export function createVersionFsTools(state) {
|
|
|
148
151
|
inputSchema: z.object({
|
|
149
152
|
path: z.string().min(1),
|
|
150
153
|
}),
|
|
154
|
+
describeCall: "none",
|
|
151
155
|
execute: async ({ path }) => {
|
|
152
156
|
const resolved = resolveAgentPath(path, state.versionDir);
|
|
153
157
|
if (resolved.kind === "out_of_scope") {
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The authoring tool surface over the draft operations.
|
|
3
|
+
*
|
|
4
|
+
* The factory closes over a private draft holder and the pinned snapshot. It gives eight tools and a
|
|
5
|
+
* read of the current draft. The tools read no ambient state, thus two factories hold two independent
|
|
6
|
+
* drafts.
|
|
7
|
+
*
|
|
8
|
+
* Each tool maps its flat input onto a core operation, and it applies the pure operation. The holder
|
|
9
|
+
* swaps only on a landed operation. A refused operation returns typed data in the ok channel, and the
|
|
10
|
+
* error channel stays for an unexpected failure.
|
|
11
|
+
*
|
|
12
|
+
* The primitive admits a flat object input only. Thus a destination is four optional fields, and not a
|
|
13
|
+
* nested union. A conflict between the flat fields refuses before the core runs.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import { type DraftRefusal } from "../../report-model/draft-operations.js";
|
|
17
|
+
import { type OutlineEntry, type ReadableBlock } from "../../report-model/draft-read.js";
|
|
18
|
+
import { type FinishResult } from "../../report-model/draft-finish.js";
|
|
19
|
+
import { type DraftDocument } from "../../report-model/draft.js";
|
|
20
|
+
import type { ReportSnapshot } from "../../report-model/reference-resolver.js";
|
|
21
|
+
import { type Tool } from "../define-tool.js";
|
|
22
|
+
/** The flat destination fields. An anchor is `before` or `after`, and a place is `start` or `end`. */
|
|
23
|
+
declare const addBlockInput: z.ZodObject<{
|
|
24
|
+
block: z.ZodUnion<readonly [z.ZodType<import("../../report-model/draft.js").DraftBlock, unknown, z.core.$ZodTypeInternals<import("../../report-model/draft.js").DraftBlock, unknown>>, z.ZodUnknown]>;
|
|
25
|
+
parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
26
|
+
place: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
27
|
+
end: "end";
|
|
28
|
+
start: "start";
|
|
29
|
+
}>>>;
|
|
30
|
+
before: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
|
+
after: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
/**
|
|
34
|
+
* The change payload is a title for a section target, or a block for an atom target, and exactly one of
|
|
35
|
+
* the two. Both fields are absentable, because a section retitle names no block. Zod 4 treats a bare
|
|
36
|
+
* `z.unknown()` as a required key, thus an optional marker is what makes the retitle call representable.
|
|
37
|
+
*/
|
|
38
|
+
declare const changeBlockInput: z.ZodObject<{
|
|
39
|
+
targetId: z.ZodString;
|
|
40
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
block: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<import("../../report-model/draft.js").DraftBlock, unknown, z.core.$ZodTypeInternals<import("../../report-model/draft.js").DraftBlock, unknown>>, z.ZodUnknown]>>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
declare const removeBlockInput: z.ZodObject<{
|
|
44
|
+
targetId: z.ZodString;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
declare const moveBlockInput: z.ZodObject<{
|
|
47
|
+
targetId: z.ZodString;
|
|
48
|
+
parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
place: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
50
|
+
end: "end";
|
|
51
|
+
start: "start";
|
|
52
|
+
}>>>;
|
|
53
|
+
before: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
|
+
after: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
declare const readOutlineInput: z.ZodObject<{}, z.core.$strip>;
|
|
57
|
+
/** The read names its target with the same field name as each mutation, thus one id key serves them all. */
|
|
58
|
+
declare const readBlockInput: z.ZodObject<{
|
|
59
|
+
targetId: z.ZodString;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
declare const setTitleInput: z.ZodObject<{
|
|
62
|
+
title: z.ZodString;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
declare const finishDraftInput: z.ZodObject<{}, z.core.$strip>;
|
|
65
|
+
export type AddBlockInput = z.infer<typeof addBlockInput>;
|
|
66
|
+
export type ChangeBlockInput = z.infer<typeof changeBlockInput>;
|
|
67
|
+
export type RemoveBlockInput = z.infer<typeof removeBlockInput>;
|
|
68
|
+
export type MoveBlockInput = z.infer<typeof moveBlockInput>;
|
|
69
|
+
export type ReadOutlineInput = z.infer<typeof readOutlineInput>;
|
|
70
|
+
export type ReadBlockInput = z.infer<typeof readBlockInput>;
|
|
71
|
+
export type SetTitleInput = z.infer<typeof setTitleInput>;
|
|
72
|
+
export type FinishDraftInput = z.infer<typeof finishDraftInput>;
|
|
73
|
+
/** One container that an operation changed, and the child order inside it after the operation. */
|
|
74
|
+
export interface ChangedContainer {
|
|
75
|
+
/** The section that holds the children. It is absent when the container is the root. */
|
|
76
|
+
parentId?: string;
|
|
77
|
+
children: OutlineEntry[];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The result of a mutation tool. A refusal carries the typed reason.
|
|
81
|
+
*
|
|
82
|
+
* A landing carries the child order of each container that it changed, and not the whole outline. A whole
|
|
83
|
+
* outline costs the size of the draft on every landing, thus composing a report of n blocks would spend
|
|
84
|
+
* n-squared outline entries of agent context to author it. Only the container that the operation touched
|
|
85
|
+
* can surprise the agent: it chose the id, and the rest of the tree did not move. `read_outline` stays
|
|
86
|
+
* the way to read the whole draft, and it costs one call when the agent wants one.
|
|
87
|
+
*
|
|
88
|
+
* A move across two containers reports both. An operation that changes no child order reports none.
|
|
89
|
+
*/
|
|
90
|
+
export type MutationResult = {
|
|
91
|
+
applied: true;
|
|
92
|
+
changed: ChangedContainer[];
|
|
93
|
+
} | {
|
|
94
|
+
applied: false;
|
|
95
|
+
refusal: DraftRefusal;
|
|
96
|
+
};
|
|
97
|
+
/** The result of `read_outline`. */
|
|
98
|
+
export interface OutlineResult {
|
|
99
|
+
outline: OutlineEntry[];
|
|
100
|
+
}
|
|
101
|
+
/** The result of `read_block`. An absent block is an expected outcome, thus it stays in the ok channel. */
|
|
102
|
+
export type ReadBlockResult = {
|
|
103
|
+
found: true;
|
|
104
|
+
block: ReadableBlock;
|
|
105
|
+
} | {
|
|
106
|
+
found: false;
|
|
107
|
+
};
|
|
108
|
+
/** The state that the factory closes over. */
|
|
109
|
+
export interface ReportAuthoringState {
|
|
110
|
+
readonly snapshot: ReportSnapshot;
|
|
111
|
+
/** The draft to start from. The default is an empty draft. */
|
|
112
|
+
readonly initialDraft?: DraftDocument;
|
|
113
|
+
}
|
|
114
|
+
/** The eight authoring tools, plus a read of the current draft. */
|
|
115
|
+
export interface ReportAuthoringTools {
|
|
116
|
+
readonly add_block: Tool<AddBlockInput, MutationResult>;
|
|
117
|
+
readonly change_block: Tool<ChangeBlockInput, MutationResult>;
|
|
118
|
+
readonly remove_block: Tool<RemoveBlockInput, MutationResult>;
|
|
119
|
+
readonly move_block: Tool<MoveBlockInput, MutationResult>;
|
|
120
|
+
readonly set_title: Tool<SetTitleInput, MutationResult>;
|
|
121
|
+
readonly read_outline: Tool<ReadOutlineInput, OutlineResult>;
|
|
122
|
+
readonly read_block: Tool<ReadBlockInput, ReadBlockResult>;
|
|
123
|
+
readonly finish_draft: Tool<FinishDraftInput, FinishResult>;
|
|
124
|
+
currentDraft(): DraftDocument;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Make the eight authoring tools over one draft.
|
|
128
|
+
*
|
|
129
|
+
* The holder is a private `let`. Each tool reads the holder at call time, thus a landing through one tool
|
|
130
|
+
* shows in the next call of every tool. The holder swaps only inside `land`, thus a refused operation
|
|
131
|
+
* leaves the draft as it was.
|
|
132
|
+
*/
|
|
133
|
+
export declare function createReportAuthoringTools(state: ReportAuthoringState): ReportAuthoringTools;
|
|
134
|
+
export {};
|