@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.
Files changed (330) hide show
  1. package/README.md +48 -0
  2. package/dist/agents/conversation-agent.d.ts +15 -11
  3. package/dist/agents/conversation-agent.js +31 -34
  4. package/dist/agents/report-builder.js +2 -1
  5. package/dist/agents/sandbox/bulk-transcriptomics-agent.js +1 -1
  6. package/dist/agents/sandbox/cheminformatics-agent.js +1 -19
  7. package/dist/agents/sandbox/chromatin-agent.js +1 -10
  8. package/dist/agents/sandbox/dna-methylation-agent.js +1 -10
  9. package/dist/agents/sandbox/drug-repurposing-agent.js +4 -14
  10. package/dist/agents/sandbox/enrichment-agent.js +1 -10
  11. package/dist/agents/sandbox/ephemeral-executor.js +1 -10
  12. package/dist/agents/sandbox/genomic-variant-agent.js +1 -3
  13. package/dist/agents/sandbox/immune-profiling-agent.js +1 -13
  14. package/dist/agents/sandbox/metabolomics-agent.js +1 -1
  15. package/dist/agents/sandbox/microbiome-agent.js +1 -1
  16. package/dist/agents/sandbox/multi-omics-integration-agent.js +1 -12
  17. package/dist/agents/sandbox/multimodal-sc-agent.js +1 -1
  18. package/dist/agents/sandbox/network-agent.js +1 -10
  19. package/dist/agents/sandbox/pkpd-clinical-response-agent.js +2 -8
  20. package/dist/agents/sandbox/proteomics-agent.js +1 -1
  21. package/dist/agents/sandbox/scientific-executor.js +1 -10
  22. package/dist/agents/sandbox/shared.d.ts +20 -6
  23. package/dist/agents/sandbox/shared.js +50 -39
  24. package/dist/agents/sandbox/single-cell-agent.js +1 -1
  25. package/dist/agents/sandbox/spatial-omics-agent.js +1 -1
  26. package/dist/agents/sandbox/statistical-modeling-agent.js +1 -1
  27. package/dist/agents/sandbox/translational-safety-agent.js +3 -9
  28. package/dist/agents/sandbox/types.d.ts +1 -1
  29. package/dist/agents/system-prompt.d.ts +37 -11
  30. package/dist/agents/system-prompt.js +35 -12
  31. package/dist/app/chat-turn.d.ts +3 -0
  32. package/dist/app/chat-turn.js +3 -1
  33. package/dist/app/data-profile-orientation.d.ts +34 -0
  34. package/dist/app/data-profile-orientation.js +117 -0
  35. package/dist/app/synthesize-run.d.ts +3 -0
  36. package/dist/app/synthesize-run.js +3 -1
  37. package/dist/contracts/schemas/chat-parts.d.ts +9 -9
  38. package/dist/execution/artifact-metadata.d.ts +3 -0
  39. package/dist/execution/artifact-metadata.js +10 -3
  40. package/dist/execution/artifact-registration.d.ts +2 -1
  41. package/dist/execution/artifact-registration.js +8 -2
  42. package/dist/execution/ephemeral-runner.d.ts +16 -0
  43. package/dist/execution/ephemeral-runner.js +31 -5
  44. package/dist/execution/post-step-pipeline.d.ts +3 -0
  45. package/dist/execution/post-step-pipeline.js +24 -4
  46. package/dist/execution/reconcile-manifest.d.ts +7 -0
  47. package/dist/execution/reconcile-manifest.js +19 -5
  48. package/dist/execution/report-runner.d.ts +3 -0
  49. package/dist/execution/report-runner.js +4 -4
  50. package/dist/execution/run-synthesis.js +20 -19
  51. package/dist/execution/step-summary.d.ts +3 -0
  52. package/dist/execution/step-summary.js +6 -3
  53. package/dist/index.d.ts +9 -2
  54. package/dist/index.js +24 -5
  55. package/dist/lib/chrome.d.ts +4 -1
  56. package/dist/lib/chrome.js +10 -7
  57. package/dist/lib/console-logger.d.ts +19 -0
  58. package/dist/lib/console-logger.js +62 -0
  59. package/dist/lib/logger.d.ts +88 -0
  60. package/dist/lib/logger.js +37 -0
  61. package/dist/lib/otel.d.ts +2 -1
  62. package/dist/lib/otel.js +8 -3
  63. package/dist/loop/__fixtures__/scripted-provider.d.ts +2 -2
  64. package/dist/loop/__fixtures__/scripted-provider.js +2 -1
  65. package/dist/loop/metrics.d.ts +33 -1
  66. package/dist/loop/metrics.js +56 -2
  67. package/dist/loop/run-agent.d.ts +13 -1
  68. package/dist/loop/run-agent.js +19 -4
  69. package/dist/memory/card-builders.d.ts +8 -1
  70. package/dist/memory/card-builders.js +20 -3
  71. package/dist/memory/reconstruct-cards.js +4 -3
  72. package/dist/memory/thread-history.d.ts +27 -2
  73. package/dist/memory/thread-history.js +45 -5
  74. package/dist/memory/working-memory.d.ts +93 -10
  75. package/dist/memory/working-memory.js +220 -84
  76. package/dist/prompts/SOUL.d.ts +22 -9
  77. package/dist/prompts/SOUL.js +56 -37
  78. package/dist/prompts/analogical-reasoner.d.ts +1 -1
  79. package/dist/prompts/analogical-reasoner.js +2 -2
  80. package/dist/prompts/briefing.d.ts +100 -0
  81. package/dist/prompts/briefing.js +166 -0
  82. package/dist/prompts/conversation.d.ts +1 -1
  83. package/dist/prompts/conversation.js +94 -440
  84. package/dist/prompts/literature-reviewer.d.ts +1 -1
  85. package/dist/prompts/literature-reviewer.js +10 -10
  86. package/dist/prompts/planner.js +28 -59
  87. package/dist/prompts/report-builder.d.ts +1 -1
  88. package/dist/prompts/report-builder.js +71 -24
  89. package/dist/prompts/sandbox/bulk-transcriptomics-agent.d.ts +1 -1
  90. package/dist/prompts/sandbox/bulk-transcriptomics-agent.js +2 -7
  91. package/dist/prompts/sandbox/cheminformatics-agent.d.ts +1 -1
  92. package/dist/prompts/sandbox/cheminformatics-agent.js +11 -15
  93. package/dist/prompts/sandbox/chromatin-agent.d.ts +1 -1
  94. package/dist/prompts/sandbox/chromatin-agent.js +3 -7
  95. package/dist/prompts/sandbox/data-profiler.d.ts +1 -1
  96. package/dist/prompts/sandbox/data-profiler.js +13 -8
  97. package/dist/prompts/sandbox/dna-methylation-agent.d.ts +1 -1
  98. package/dist/prompts/sandbox/dna-methylation-agent.js +2 -7
  99. package/dist/prompts/sandbox/drug-repurposing-agent.d.ts +1 -1
  100. package/dist/prompts/sandbox/drug-repurposing-agent.js +15 -16
  101. package/dist/prompts/sandbox/enrichment-agent.d.ts +1 -1
  102. package/dist/prompts/sandbox/enrichment-agent.js +2 -9
  103. package/dist/prompts/sandbox/genomic-variant-agent.d.ts +1 -1
  104. package/dist/prompts/sandbox/genomic-variant-agent.js +2 -6
  105. package/dist/prompts/sandbox/immune-profiling-agent.d.ts +1 -1
  106. package/dist/prompts/sandbox/immune-profiling-agent.js +3 -8
  107. package/dist/prompts/sandbox/metabolomics-agent.d.ts +1 -1
  108. package/dist/prompts/sandbox/metabolomics-agent.js +1 -7
  109. package/dist/prompts/sandbox/microbiome-agent.d.ts +1 -1
  110. package/dist/prompts/sandbox/microbiome-agent.js +2 -7
  111. package/dist/prompts/sandbox/multi-omics-integration-agent.d.ts +1 -1
  112. package/dist/prompts/sandbox/multi-omics-integration-agent.js +2 -8
  113. package/dist/prompts/sandbox/multimodal-sc-agent.d.ts +1 -1
  114. package/dist/prompts/sandbox/multimodal-sc-agent.js +2 -7
  115. package/dist/prompts/sandbox/network-agent.d.ts +1 -1
  116. package/dist/prompts/sandbox/network-agent.js +2 -7
  117. package/dist/prompts/sandbox/proteomics-agent.d.ts +1 -1
  118. package/dist/prompts/sandbox/proteomics-agent.js +2 -9
  119. package/dist/prompts/sandbox/single-cell-agent.d.ts +1 -1
  120. package/dist/prompts/sandbox/single-cell-agent.js +2 -9
  121. package/dist/prompts/sandbox/spatial-omics-agent.d.ts +1 -1
  122. package/dist/prompts/sandbox/spatial-omics-agent.js +3 -6
  123. package/dist/prompts/sandbox/statistical-modeling-agent.d.ts +1 -1
  124. package/dist/prompts/sandbox/statistical-modeling-agent.js +2 -7
  125. package/dist/prompts/sandbox/translational-safety-agent.d.ts +1 -1
  126. package/dist/prompts/sandbox/translational-safety-agent.js +13 -14
  127. package/dist/prompts/sandbox-standards.d.ts +22 -14
  128. package/dist/prompts/sandbox-standards.js +91 -71
  129. package/dist/prompts/synthesis-agent.d.ts +1 -1
  130. package/dist/prompts/synthesis-agent.js +33 -131
  131. package/dist/provenance/collector.js +1 -1
  132. package/dist/providers/ai-sdk.js +31 -4
  133. package/dist/providers/prompt-cache.d.ts +74 -0
  134. package/dist/providers/prompt-cache.js +77 -0
  135. package/dist/providers/types.d.ts +33 -0
  136. package/dist/reference-data/catalog.d.ts +131 -0
  137. package/dist/reference-data/catalog.js +348 -0
  138. package/dist/reference-data/receipt.d.ts +41 -0
  139. package/dist/reference-data/receipt.js +40 -0
  140. package/dist/runtime/boot.d.ts +2 -2
  141. package/dist/runtime/boot.js +1 -1
  142. package/dist/runtime/connection-budget.d.ts +2 -2
  143. package/dist/runtime/connection-budget.js +5 -3
  144. package/dist/runtime/dbos.d.ts +7 -7
  145. package/dist/runtime/dbos.js +14 -11
  146. package/dist/runtime/shutdown.d.ts +2 -2
  147. package/dist/runtime/shutdown.js +4 -3
  148. package/dist/sandbox/create-sandbox.d.ts +2 -2
  149. package/dist/sandbox/docker-client.d.ts +2 -2
  150. package/dist/sandbox/docker-client.js +4 -1
  151. package/dist/sandbox/k8s-client.d.ts +3 -0
  152. package/dist/sandbox/k8s-client.js +5 -4
  153. package/dist/sandbox/notification-sweep.d.ts +3 -3
  154. package/dist/sandbox/notification-sweep.js +4 -2
  155. package/dist/sandbox/reaper.d.ts +3 -3
  156. package/dist/sandbox/reaper.js +7 -4
  157. package/dist/sandbox/watchdog.d.ts +3 -3
  158. package/dist/sandbox/watchdog.js +8 -2
  159. package/dist/schemas/data-profile-schemas.js +5 -3
  160. package/dist/schemas/plan-schemas.d.ts +21 -21
  161. package/dist/schemas/plan-schemas.js +9 -3
  162. package/dist/schemas/run-synthesis.d.ts +8 -4
  163. package/dist/schemas/run-synthesis.js +92 -56
  164. package/dist/schemas/validate-plan.js +1 -1
  165. package/dist/schemas/workflow-state.d.ts +7 -1
  166. package/dist/schemas/workflow-state.js +33 -19
  167. package/dist/state/artifacts.d.ts +13 -0
  168. package/dist/state/artifacts.js +27 -0
  169. package/dist/state/data-profile.d.ts +64 -5
  170. package/dist/state/index.d.ts +3 -3
  171. package/dist/state/index.js +1 -1
  172. package/dist/state/init.d.ts +2 -1
  173. package/dist/state/init.js +5 -6
  174. package/dist/tasks/data-profile.d.ts +25 -2
  175. package/dist/tasks/data-profile.js +95 -39
  176. package/dist/tools/bio/chembl.d.ts +38 -0
  177. package/dist/tools/bio/chembl.js +138 -0
  178. package/dist/tools/bio/comptox.d.ts +50 -0
  179. package/dist/tools/bio/comptox.js +149 -0
  180. package/dist/tools/bio/get-impc-ko-profile.js +9 -6
  181. package/dist/tools/bio/index.d.ts +5 -17
  182. package/dist/tools/bio/index.js +5 -17
  183. package/dist/tools/bio/keys.d.ts +14 -9
  184. package/dist/tools/bio/keys.js +16 -16
  185. package/dist/tools/bio/opentargets.d.ts +38 -0
  186. package/dist/tools/bio/opentargets.js +89 -0
  187. package/dist/tools/bio/pubchem.d.ts +29 -0
  188. package/dist/tools/bio/pubchem.js +92 -0
  189. package/dist/tools/bio/pubmed.d.ts +51 -0
  190. package/dist/tools/bio/pubmed.js +100 -0
  191. package/dist/tools/bio/search-bgee-expression.js +12 -6
  192. package/dist/tools/bio/search-clinical-trials.js +16 -5
  193. package/dist/tools/bio/search-dgidb.d.ts +11 -1
  194. package/dist/tools/bio/search-dgidb.js +92 -78
  195. package/dist/tools/bio/search-faers.js +8 -4
  196. package/dist/tools/bio/search-geo-datasets.js +20 -6
  197. package/dist/tools/bio/search-gwas-catalog.d.ts +1 -1
  198. package/dist/tools/bio/search-pharmgkb.js +10 -4
  199. package/dist/tools/display/index.d.ts +1 -0
  200. package/dist/tools/display/index.js +1 -0
  201. package/dist/tools/display/normalize-echart-spec.d.ts +61 -0
  202. package/dist/tools/display/normalize-echart-spec.js +211 -0
  203. package/dist/tools/display/show-user.d.ts +6 -1
  204. package/dist/tools/display/show-user.js +25 -12
  205. package/dist/tools/execute-plan.js +5 -2
  206. package/dist/tools/iterate-report.d.ts +171 -118
  207. package/dist/tools/iterate-report.js +336 -96
  208. package/dist/tools/lib/chembl-client.d.ts +12 -0
  209. package/dist/tools/lib/chembl-client.js +127 -0
  210. package/dist/tools/lib/ctx-ops.d.ts +224 -0
  211. package/dist/tools/lib/ctx-ops.js +450 -0
  212. package/dist/tools/lib/iuphar-client.js +10 -1
  213. package/dist/tools/lib/openfda-client.js +11 -3
  214. package/dist/tools/lib/pathway-client.js +10 -4
  215. package/dist/tools/lib/pubchem-ops.d.ts +74 -0
  216. package/dist/tools/lib/pubchem-ops.js +224 -0
  217. package/dist/tools/memory/update-working-memory.d.ts +45 -7
  218. package/dist/tools/memory/update-working-memory.js +111 -41
  219. package/dist/tools/report/index.d.ts +3 -2
  220. package/dist/tools/report/index.js +3 -2
  221. package/dist/tools/research/generate-analogy-report.js +25 -12
  222. package/dist/tools/research/generate-plan.d.ts +12 -5
  223. package/dist/tools/research/generate-plan.js +168 -37
  224. package/dist/tools/research/index.d.ts +1 -0
  225. package/dist/tools/research/index.js +1 -0
  226. package/dist/tools/research/inspect-data-profile.d.ts +85 -0
  227. package/dist/tools/research/inspect-data-profile.js +161 -0
  228. package/dist/tools/research/literature-reviewer.d.ts +3 -0
  229. package/dist/tools/research/literature-reviewer.js +5 -6
  230. package/dist/tools/sandbox/list-available-packages.d.ts +79 -5
  231. package/dist/tools/sandbox/list-available-packages.js +152 -10
  232. package/dist/tools/sandbox/list-available-refs.d.ts +141 -5
  233. package/dist/tools/sandbox/list-available-refs.js +647 -134
  234. package/dist/tools/sandbox/report-blocker.d.ts +39 -9
  235. package/dist/tools/sandbox/report-blocker.js +43 -20
  236. package/dist/tools/workspace/execute-command.d.ts +3 -0
  237. package/dist/tools/workspace/execute-command.js +3 -1
  238. package/dist/tools/workspace/read-file.js +4 -5
  239. package/dist/tools/workspace/run-exec.d.ts +4 -4
  240. package/dist/tools/workspace/run-exec.js +4 -4
  241. package/dist/tools/workspace/show-file.js +10 -6
  242. package/dist/tools/workspace/show-plan.js +12 -6
  243. package/dist/tools/workspace/workspace-search.d.ts +1 -1
  244. package/dist/tools/workspace/workspace-search.js +11 -5
  245. package/dist/workflows/execute-analysis.d.ts +46 -4
  246. package/dist/workflows/execute-analysis.js +118 -13
  247. package/dist/workflows/execute-target-assessment.d.ts +3 -0
  248. package/dist/workflows/execute-target-assessment.js +19 -15
  249. package/dist/workflows/sandbox-step.d.ts +9 -0
  250. package/dist/workflows/sandbox-step.js +39 -17
  251. package/dist/workflows/target-assessment/lib/citation-validator.js +2 -2
  252. package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.js +2 -1
  253. package/dist/workflows/target-assessment/lib/llm-step.d.ts +3 -0
  254. package/dist/workflows/target-assessment/lib/llm-step.js +3 -1
  255. package/dist/workflows/target-assessment/lib/structured-llm.d.ts +3 -0
  256. package/dist/workflows/target-assessment/lib/structured-llm.js +1 -0
  257. package/dist/workflows/target-assessment/phase5-persist.d.ts +3 -0
  258. package/dist/workflows/target-assessment/phase5-persist.js +8 -3
  259. package/dist/workflows/target-assessment/progress.d.ts +2 -1
  260. package/dist/workflows/target-assessment/progress.js +4 -3
  261. package/dist/workspace/filesystem.js +163 -74
  262. package/dist/workspace/paths.d.ts +2 -2
  263. package/dist/workspace/paths.js +2 -2
  264. package/package.json +95 -96
  265. package/dist/execution/filesystem-artifact-registry.d.ts +0 -57
  266. package/dist/execution/filesystem-artifact-registry.js +0 -92
  267. package/dist/lib/identifiers.d.ts +0 -8
  268. package/dist/lib/identifiers.js +0 -10
  269. package/dist/lib/mime-detect.d.ts +0 -17
  270. package/dist/lib/mime-detect.js +0 -29
  271. package/dist/lib/streamed-download.d.ts +0 -28
  272. package/dist/lib/streamed-download.js +0 -111
  273. package/dist/lib/trace-context.d.ts +0 -11
  274. package/dist/lib/trace-context.js +0 -49
  275. package/dist/providers/llm-capabilities.d.ts +0 -33
  276. package/dist/providers/llm-capabilities.js +0 -58
  277. package/dist/schemas/render-step-prompt.d.ts +0 -32
  278. package/dist/schemas/render-step-prompt.js +0 -76
  279. package/dist/tools/bio/find-approval-precedent.d.ts +0 -32
  280. package/dist/tools/bio/find-approval-precedent.js +0 -72
  281. package/dist/tools/bio/get-article-details.d.ts +0 -11
  282. package/dist/tools/bio/get-article-details.js +0 -20
  283. package/dist/tools/bio/get-article-full-text.d.ts +0 -19
  284. package/dist/tools/bio/get-article-full-text.js +0 -32
  285. package/dist/tools/bio/get-bioactivity.d.ts +0 -11
  286. package/dist/tools/bio/get-bioactivity.js +0 -23
  287. package/dist/tools/bio/get-drug-info.d.ts +0 -9
  288. package/dist/tools/bio/get-drug-info.js +0 -22
  289. package/dist/tools/bio/get-mechanism.d.ts +0 -8
  290. package/dist/tools/bio/get-mechanism.js +0 -18
  291. package/dist/tools/bio/get-pubchem-assays.d.ts +0 -22
  292. package/dist/tools/bio/get-pubchem-assays.js +0 -107
  293. package/dist/tools/bio/get-pubchem-cross-refs.d.ts +0 -15
  294. package/dist/tools/bio/get-pubchem-cross-refs.js +0 -68
  295. package/dist/tools/bio/get-target-safety.d.ts +0 -18
  296. package/dist/tools/bio/get-target-safety.js +0 -26
  297. package/dist/tools/bio/search-compounds.d.ts +0 -22
  298. package/dist/tools/bio/search-compounds.js +0 -160
  299. package/dist/tools/bio/search-ctx-chemical.d.ts +0 -50
  300. package/dist/tools/bio/search-ctx-chemical.js +0 -130
  301. package/dist/tools/bio/search-ctx-exposure.d.ts +0 -55
  302. package/dist/tools/bio/search-ctx-exposure.js +0 -176
  303. package/dist/tools/bio/search-ctx-hazard.d.ts +0 -111
  304. package/dist/tools/bio/search-ctx-hazard.js +0 -178
  305. package/dist/tools/bio/search-opentargets.d.ts +0 -11
  306. package/dist/tools/bio/search-opentargets.js +0 -25
  307. package/dist/tools/bio/search-pubchem-compound.d.ts +0 -26
  308. package/dist/tools/bio/search-pubchem-compound.js +0 -110
  309. package/dist/tools/bio/search-pubmed.d.ts +0 -17
  310. package/dist/tools/bio/search-pubmed.js +0 -31
  311. package/dist/tools/bio/search-targets.d.ts +0 -9
  312. package/dist/tools/bio/search-targets.js +0 -20
  313. package/dist/tools/bio/search-toxcast.d.ts +0 -36
  314. package/dist/tools/bio/search-toxcast.js +0 -141
  315. package/dist/workflows/register-workflows.d.ts +0 -51
  316. package/dist/workflows/register-workflows.js +0 -48
  317. package/dist/workflows/resume-execute-analysis.d.ts +0 -70
  318. package/dist/workflows/resume-execute-analysis.js +0 -80
  319. package/dist/workflows/target-assessment/correction-loop.d.ts +0 -45
  320. package/dist/workflows/target-assessment/correction-loop.js +0 -62
  321. package/dist/workflows/target-assessment/steps/phase0-resolve.d.ts +0 -71
  322. package/dist/workflows/target-assessment/steps/phase0-resolve.js +0 -21
  323. package/dist/workflows/target-assessment/steps/phase1-aggregate.d.ts +0 -1018
  324. package/dist/workflows/target-assessment/steps/phase1-aggregate.js +0 -25
  325. package/dist/workspace/mount-strategy.d.ts +0 -50
  326. package/dist/workspace/mount-strategy.js +0 -67
  327. package/dist/workspace/provenance-collector.d.ts +0 -34
  328. package/dist/workspace/provenance-collector.js +0 -16
  329. package/dist/workspace/workspace-paths.d.ts +0 -26
  330. package/dist/workspace/workspace-paths.js +0 -31
@@ -1,31 +0,0 @@
1
- /**
2
- * searchPubMed — search PubMed via NCBI E-utilities.
3
- */
4
- import { ok } from "neverthrow";
5
- import { z } from "zod";
6
- import { defineTool } from "../define-tool.js";
7
- import { searchPubmed } from "../lib/pubmed-client.js";
8
- export function createSearchPubMedTool(deps) {
9
- return defineTool({
10
- id: "search_pubmed",
11
- description: "Search PubMed for scientific articles using NCBI E-utilities. " +
12
- "The query uses PubMed search syntax — use MeSH terms (e.g., " +
13
- '"breast neoplasms"[MeSH]), field tags ([Title/Abstract], [Author], [Gene]), ' +
14
- "and Boolean operators (AND, OR, NOT). " +
15
- 'Example: "BRCA1"[Gene] AND "breast neoplasms"[MeSH] AND "drug resistance"[Title/Abstract]. ' +
16
- "Returns PMIDs, titles, journal names, publication years, and author summaries.",
17
- inputSchema: z.object({
18
- query: z.string().describe("PubMed search query. Supports MeSH terms, field tags, and Boolean operators."),
19
- maxResults: z.number().int().min(1).max(50).default(10).describe("Maximum number of results to return (1–50, default 10)"),
20
- sort: z.enum(["relevance", "date"]).default("relevance").describe('Sort order: "relevance" or "date" (default "relevance")'),
21
- dateRange: z
22
- .object({
23
- from: z.string().describe("Start date in YYYY/MM/DD format"),
24
- to: z.string().describe("End date in YYYY/MM/DD format"),
25
- })
26
- .optional()
27
- .describe("Optional date range filter"),
28
- }),
29
- execute: async ({ query, maxResults, sort, dateRange }) => ok(await searchPubmed(deps.ncbiApiKey, query, { maxResults, sort, dateRange })),
30
- });
31
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * searchTargets tool — search ChEMBL for biological targets.
3
- */
4
- export declare const searchTargetsTool: import("../define-tool.js").Tool<{
5
- query: string;
6
- limit: number;
7
- }, {
8
- targets: import("../lib/chembl-client.js").ChemblTarget[];
9
- }>;
@@ -1,20 +0,0 @@
1
- /**
2
- * searchTargets tool — search ChEMBL for biological targets.
3
- */
4
- import { ok } from "neverthrow";
5
- import { z } from "zod";
6
- import { defineTool } from "../define-tool.js";
7
- import { searchTargets } from "../lib/chembl-client.js";
8
- export const searchTargetsTool = defineTool({
9
- id: "search_targets",
10
- description: "Search ChEMBL for biological targets by gene symbol, protein name, or ChEMBL ID. " +
11
- "Returns target metadata including ChEMBL IDs, target type, organism, and gene names.",
12
- inputSchema: z.object({
13
- query: z.string().min(1).describe("Search term: gene symbol (e.g. 'EGFR'), protein name, or ChEMBL target ID"),
14
- limit: z.number().int().min(1).max(25).default(25).describe("Maximum number of targets to return"),
15
- }),
16
- execute: async ({ query, limit }) => {
17
- const targets = await searchTargets(query, limit);
18
- return ok({ targets });
19
- },
20
- });
@@ -1,36 +0,0 @@
1
- /**
2
- * searchToxcast — search EPA ToxCast/Tox21 high-throughput screening data
3
- * for a chemical via the CTX Bioactivity API.
4
- */
5
- interface ToxcastAssayResult {
6
- aeid: number;
7
- assayEndpoint: string;
8
- ac50: number | null;
9
- hitCall: number;
10
- maxMean: number | null;
11
- model: string;
12
- flags: string[];
13
- }
14
- type ToxcastOutput = {
15
- found: false;
16
- query: string;
17
- } | {
18
- found: true;
19
- chemical: {
20
- dtxsid: string;
21
- preferredName: string;
22
- casrn: string | null;
23
- totalAssays: number;
24
- activeAssays: number;
25
- activeHitRate: number;
26
- results: ToxcastAssayResult[];
27
- };
28
- };
29
- export declare function createSearchToxcastTool(deps: {
30
- apiKey: string;
31
- }): import("../define-tool.js").Tool<{
32
- query: string;
33
- activeOnly: boolean;
34
- limit: number;
35
- }, ToxcastOutput>;
36
- export {};
@@ -1,141 +0,0 @@
1
- /**
2
- * searchToxcast — search EPA ToxCast/Tox21 high-throughput screening data
3
- * for a chemical via the CTX Bioactivity 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
- // Raw CTX Bioactivity API wire shapes, validated at the fetch boundary. Fields
11
- // are optional because the API omits absent values; `dtxsid` stays required
12
- // because `resolveDtxsid` reads it without a guard, so a row missing it is a
13
- // contract break surfaced as `invalid_response` rather than a runtime error.
14
- // The row-shaping/filtering logic in `execute` stays put — it depends on the
15
- // resolved chemical, the assay-name map, and the `activeOnly`/`limit` inputs.
16
- const CtxChemicalSearchRowSchema = z.object({
17
- dtxsid: z.string(),
18
- preferredName: z.string().optional(),
19
- casrn: z.string().nullable().optional(),
20
- });
21
- const ToxcastMc5ParamSchema = z.object({
22
- ac50: z.number().optional(),
23
- acc: z.number().optional(),
24
- });
25
- const ToxcastMc6ParamSchema = z.object({
26
- flag: z.unknown().optional(),
27
- });
28
- const ToxcastBioactivityRowSchema = z.object({
29
- aeid: z.number().optional(),
30
- hitc: z.number().optional(),
31
- maxMean: z.number().nullable().optional(),
32
- modl: z.string().optional(),
33
- mc5Param: ToxcastMc5ParamSchema.nullable().optional(),
34
- mc6Param: ToxcastMc6ParamSchema.nullable().optional(),
35
- });
36
- const ToxcastAssaySummaryRowSchema = z.object({
37
- aeid: z.number().optional(),
38
- aenm: z.string().optional(),
39
- });
40
- export function createSearchToxcastTool(deps) {
41
- return defineTool({
42
- id: "search_toxcast",
43
- description: "Search EPA ToxCast/Tox21 high-throughput screening data for a chemical via the CTX Bioactivity API. " +
44
- "Returns in-vitro bioactivity results across hundreds of assay endpoints " +
45
- "(nuclear receptors, stress response, mitochondrial toxicity, etc.). " +
46
- "Use to assess toxicological liability of compounds or drug targets. " +
47
- "Requires EPA_CCTE_API_KEY environment variable.",
48
- inputSchema: z.object({
49
- query: z.string().describe("Chemical identifier: DTXSID (e.g. DTXSID7020182), CASRN (e.g. 80-05-7), " + "or chemical name (e.g. bisphenol A)"),
50
- activeOnly: z.boolean().default(true).describe("Return only active (hit) assays. Set false for all tested assays."),
51
- limit: z.number().int().min(1).max(200).default(50).describe("Max assay results to return (sorted by AC50 ascending for actives)"),
52
- }),
53
- execute: async ({ query, activeOnly = true, limit = 50 }) => {
54
- const headers = getEpaCcteHeaders(deps.apiKey);
55
- const resolved = await resolveDtxsid(query, headers);
56
- // "No chemical found" is an expected outcome — a data variant, not an error.
57
- if (!resolved)
58
- return ok({ found: false, query });
59
- const { dtxsid, preferredName, casrn } = resolved;
60
- const aeidMap = await fetchAssayNames(dtxsid, headers);
61
- const bioUrl = `${EPA_CCTE_BASE}/bioactivity/data/search/by-dtxsid/${dtxsid}`;
62
- const bioRes = await apiFetchValidated(bioUrl, z.array(ToxcastBioactivityRowSchema), { headers });
63
- if (bioRes.isErr())
64
- throw new Error(describeApiError(bioRes.error));
65
- const allResults = bioRes.value ?? [];
66
- const totalAssays = allResults.length;
67
- const activeAssays = allResults.filter((r) => r.hitc === 1).length;
68
- const filtered = activeOnly ? allResults.filter((r) => r.hitc === 1) : allResults;
69
- filtered.sort((a, b) => extractAc50(a) - extractAc50(b));
70
- const results = filtered.slice(0, limit).map((r) => {
71
- const aeid = r.aeid ?? 0;
72
- const mc6 = r.mc6Param ?? {};
73
- const flags = Array.isArray(mc6.flag) ? mc6.flag : [];
74
- return {
75
- aeid,
76
- assayEndpoint: aeidMap.get(aeid) ?? `aeid:${aeid}`,
77
- ac50: extractAc50Raw(r),
78
- hitCall: r.hitc ?? 0,
79
- maxMean: r.maxMean ?? null,
80
- model: r.modl ?? "",
81
- flags,
82
- };
83
- });
84
- return ok({
85
- found: true,
86
- chemical: {
87
- dtxsid,
88
- preferredName,
89
- casrn,
90
- totalAssays,
91
- activeAssays,
92
- activeHitRate: totalAssays > 0 ? Math.round((activeAssays / totalAssays) * 1000) / 1000 : 0,
93
- results,
94
- },
95
- });
96
- },
97
- });
98
- }
99
- function extractAc50(r) {
100
- return extractAc50Raw(r) ?? Infinity;
101
- }
102
- function extractAc50Raw(r) {
103
- const mc5 = r.mc5Param;
104
- if (mc5 && typeof mc5 === "object") {
105
- if (typeof mc5.ac50 === "number")
106
- return mc5.ac50;
107
- if (typeof mc5.acc === "number")
108
- return mc5.acc;
109
- }
110
- return null;
111
- }
112
- async function resolveDtxsid(query, headers) {
113
- if (query.startsWith("DTXSID")) {
114
- return { dtxsid: query, preferredName: query, casrn: null };
115
- }
116
- const searchUrl = `${EPA_CCTE_BASE}/chemical/search/equal/${encodeURIComponent(query)}`;
117
- const searchRes = await apiFetchValidated(searchUrl, z.array(CtxChemicalSearchRowSchema), { headers });
118
- if (searchRes.isErr())
119
- throw new Error(describeApiError(searchRes.error));
120
- if (!searchRes.value?.length)
121
- return null;
122
- const chem = searchRes.value[0];
123
- return {
124
- dtxsid: chem.dtxsid,
125
- preferredName: chem.preferredName ?? query,
126
- casrn: chem.casrn ?? null,
127
- };
128
- }
129
- async function fetchAssayNames(dtxsid, headers) {
130
- const map = new Map();
131
- const url = `${EPA_CCTE_BASE}/bioactivity/data/summary/search/by-dtxsid/${dtxsid}`;
132
- const res = await apiFetchValidated(url, z.array(ToxcastAssaySummaryRowSchema), { headers });
133
- if (res.isOk() && Array.isArray(res.value)) {
134
- for (const s of res.value) {
135
- if (s.aeid != null && s.aenm) {
136
- map.set(s.aeid, s.aenm);
137
- }
138
- }
139
- }
140
- return map;
141
- }
@@ -1,51 +0,0 @@
1
- /**
2
- * Single registration call site for the analysis-side DBOS workflows.
3
- *
4
- * This module is the **one place** that calls `registerExecuteAnalysis` and
5
- * `registerSandboxStep`, binding the parent + child workflow bodies to the
6
- * running DBOS engine. Keeping both registrations in one file holds a single
7
- * invariant: both workflows land under the same `applicationVersion` stamp
8
- * that `launchDbos` writes onto the engine (`harness/runtime/dbos.ts`).
9
- * Blue/green drains gate on `dbos.application_versions`, so registering the
10
- * parent and child together under one stamp guarantees a drain treats them
11
- * as one cohort.
12
- *
13
- * Deps are supplied by the composition root: `registerAnalysisWorkflows`
14
- * takes a fully-formed deps bundle and passes each half straight through to
15
- * the per-workflow register functions. This module constructs nothing —
16
- * it only wires.
17
- */
18
- import { type ExecuteAnalysisDeps, type ExecuteAnalysisInput, type ExecuteAnalysisResult } from "./execute-analysis.js";
19
- import { type SandboxStepDeps, type SandboxStepInput, type SandboxStepResult } from "./sandbox-step.js";
20
- export interface AnalysisWorkflowDeps {
21
- readonly executeAnalysis: ExecuteAnalysisDeps;
22
- readonly sandboxStep: SandboxStepDeps;
23
- }
24
- export interface RegisteredAnalysisWorkflows {
25
- readonly executeAnalysis: (input: ExecuteAnalysisInput) => Promise<ExecuteAnalysisResult>;
26
- readonly sandboxStep: (input: SandboxStepInput) => Promise<SandboxStepResult>;
27
- }
28
- /**
29
- * Register the parent + child workflows with the running DBOS engine.
30
- *
31
- * Call this BEFORE `launchDbos`: `DBOS.launch()` runs recovery synchronously and
32
- * resolves in-flight workflows by their registered name, so a workflow that is
33
- * not registered at launch cannot be reclaimed. `runtime/assemble.ts` — the
34
- * declared source of truth for wiring order — registers every workflow before
35
- * launch for exactly this reason, and the embedded runtime does the same.
36
- * Idempotency is owned by the SDK — calling twice with the same name is a
37
- * `DBOS.registerWorkflow` invariant violation, not something this module
38
- * guards against.
39
- *
40
- * Scope: this helper takes a fully-formed `AnalysisWorkflowDeps`, so it fits
41
- * only a caller that already holds a registered sandbox-step callable —
42
- * `ExecuteAnalysisDeps.sandboxStepCallable` (inside `deps.executeAnalysis`)
43
- * exists only after `registerSandboxStep` has run. A caller that still needs
44
- * that child callable must instead register the two workflows directly in
45
- * assemble-order — register the child first, then feed its callable into the
46
- * parent's deps — the way `runtime/assemble.ts` does; registering the child
47
- * here as well would make its `registerSandboxStep` a second registration under
48
- * the same name, which the SDK rejects. No in-tree caller holds a
49
- * pre-registered child callable, so this helper is currently uncalled.
50
- */
51
- export declare function registerAnalysisWorkflows(deps: AnalysisWorkflowDeps): RegisteredAnalysisWorkflows;
@@ -1,48 +0,0 @@
1
- /**
2
- * Single registration call site for the analysis-side DBOS workflows.
3
- *
4
- * This module is the **one place** that calls `registerExecuteAnalysis` and
5
- * `registerSandboxStep`, binding the parent + child workflow bodies to the
6
- * running DBOS engine. Keeping both registrations in one file holds a single
7
- * invariant: both workflows land under the same `applicationVersion` stamp
8
- * that `launchDbos` writes onto the engine (`harness/runtime/dbos.ts`).
9
- * Blue/green drains gate on `dbos.application_versions`, so registering the
10
- * parent and child together under one stamp guarantees a drain treats them
11
- * as one cohort.
12
- *
13
- * Deps are supplied by the composition root: `registerAnalysisWorkflows`
14
- * takes a fully-formed deps bundle and passes each half straight through to
15
- * the per-workflow register functions. This module constructs nothing —
16
- * it only wires.
17
- */
18
- import { registerExecuteAnalysis } from "./execute-analysis.js";
19
- import { registerSandboxStep } from "./sandbox-step.js";
20
- /**
21
- * Register the parent + child workflows with the running DBOS engine.
22
- *
23
- * Call this BEFORE `launchDbos`: `DBOS.launch()` runs recovery synchronously and
24
- * resolves in-flight workflows by their registered name, so a workflow that is
25
- * not registered at launch cannot be reclaimed. `runtime/assemble.ts` — the
26
- * declared source of truth for wiring order — registers every workflow before
27
- * launch for exactly this reason, and the embedded runtime does the same.
28
- * Idempotency is owned by the SDK — calling twice with the same name is a
29
- * `DBOS.registerWorkflow` invariant violation, not something this module
30
- * guards against.
31
- *
32
- * Scope: this helper takes a fully-formed `AnalysisWorkflowDeps`, so it fits
33
- * only a caller that already holds a registered sandbox-step callable —
34
- * `ExecuteAnalysisDeps.sandboxStepCallable` (inside `deps.executeAnalysis`)
35
- * exists only after `registerSandboxStep` has run. A caller that still needs
36
- * that child callable must instead register the two workflows directly in
37
- * assemble-order — register the child first, then feed its callable into the
38
- * parent's deps — the way `runtime/assemble.ts` does; registering the child
39
- * here as well would make its `registerSandboxStep` a second registration under
40
- * the same name, which the SDK rejects. No in-tree caller holds a
41
- * pre-registered child callable, so this helper is currently uncalled.
42
- */
43
- export function registerAnalysisWorkflows(deps) {
44
- return {
45
- executeAnalysis: registerExecuteAnalysis(deps.executeAnalysis),
46
- sandboxStep: registerSandboxStep(deps.sandboxStep),
47
- };
48
- }
@@ -1,70 +0,0 @@
1
- /**
2
- * Resume helper for the `executeAnalysis` parent workflow.
3
- *
4
- * The actual resume *entry-point* (the HTTP route, the operator CLI hook,
5
- * the analytics-tier replay) is owned by change 9 — that change exposes
6
- * resume to the world. This module owns the **internal contract** every
7
- * resume call site MUST satisfy so the parent body re-opens the running
8
- * charge correctly after a 402 pause.
9
- *
10
- * Contract:
11
- *
12
- * 1. Call `prepareExecuteAnalysisResume(pool, parentWorkflowId)` BEFORE
13
- * `DBOS.resumeWorkflow(parentWorkflowId)`.
14
- * 2. The helper finds the cortex_runs row by `workflow_id`, atomically
15
- * bumps `attempt_count`, and returns the new attempt + the runId.
16
- * Children that are still CANCELLED need an explicit
17
- * `DBOS.resumeWorkflow(childWorkflowId)` from the caller; completed
18
- * children's `getResult` returns from the DBOS cache.
19
- * 3. On resume the parent body reads the bumped attempt_count and uses
20
- * it in `open-running-charge:${attempt}` / `close-running-charge:${attempt}`
21
- * / `revoke-run-auth:${attempt}` so each step name has never been
22
- * cached. A fresh managed-root charge is opened to replace the one that
23
- * closed with `budget_exceeded` on the pause.
24
- * 4. The same attempt is passed through to children via
25
- * `SandboxStepInput.attempt`, where it drives
26
- * `attemptStepNameFormatter` and so the resumed LLM calls miss the
27
- * prior cached 402 and fire fresh (NOTES #3).
28
- * 5. The workflow id and run id MUST NOT change across resume:
29
- * `cortex_runs.workflow_id` is rewritten by nothing in this code
30
- * path. The whole point of the bumped attempt counter is that the
31
- * same workflow id can survive multiple resumes without cache
32
- * collisions.
33
- *
34
- * Failure modes:
35
- *
36
- * - The row does not exist → `MissingRunError`. Caller MUST surface a 404
37
- * to the originating operator; do NOT call `DBOS.resumeWorkflow` on a
38
- * missing run.
39
- * - The row's status is terminal (`completed`/`partial`/`failed`/`canceled`
40
- * without `suspended_insufficient_funds` on the analysis): the helper
41
- * still bumps the counter so a defensive retry is harmless, but the
42
- * caller SHOULD skip the resume — the workflow already ran to
43
- * completion. Change 9's entry point owns this guard.
44
- */
45
- import type { Pool } from "pg";
46
- import type { CortexRunRow } from "../state/schema.js";
47
- export declare class MissingRunError extends Error {
48
- readonly workflowId: string;
49
- constructor(workflowId: string);
50
- }
51
- export interface PrepareResumeResult {
52
- readonly runId: string;
53
- readonly workflowId: string;
54
- readonly attempt: number;
55
- readonly previousStatus: CortexRunRow["status"];
56
- }
57
- /**
58
- * Bump the parent-workflow resume attempt counter and return the new
59
- * value. The caller invokes `DBOS.resumeWorkflow(workflowId)` immediately
60
- * after; the resumed parent body reads the bumped counter and re-opens
61
- * the running charge with a step name that has never been cached.
62
- *
63
- * `workflowId` and `runId` are the same bare UUID — `cortex_runs.run_id`
64
- * IS the DBOS workflowID.
65
- *
66
- * Idempotency: each call bumps once. A double-call before
67
- * `DBOS.resumeWorkflow` is harmless — both step names are misses and the
68
- * close on the just-opened charge will still cleanly land.
69
- */
70
- export declare function prepareExecuteAnalysisResume(pool: Pool, workflowId: string): Promise<PrepareResumeResult>;
@@ -1,80 +0,0 @@
1
- /**
2
- * Resume helper for the `executeAnalysis` parent workflow.
3
- *
4
- * The actual resume *entry-point* (the HTTP route, the operator CLI hook,
5
- * the analytics-tier replay) is owned by change 9 — that change exposes
6
- * resume to the world. This module owns the **internal contract** every
7
- * resume call site MUST satisfy so the parent body re-opens the running
8
- * charge correctly after a 402 pause.
9
- *
10
- * Contract:
11
- *
12
- * 1. Call `prepareExecuteAnalysisResume(pool, parentWorkflowId)` BEFORE
13
- * `DBOS.resumeWorkflow(parentWorkflowId)`.
14
- * 2. The helper finds the cortex_runs row by `workflow_id`, atomically
15
- * bumps `attempt_count`, and returns the new attempt + the runId.
16
- * Children that are still CANCELLED need an explicit
17
- * `DBOS.resumeWorkflow(childWorkflowId)` from the caller; completed
18
- * children's `getResult` returns from the DBOS cache.
19
- * 3. On resume the parent body reads the bumped attempt_count and uses
20
- * it in `open-running-charge:${attempt}` / `close-running-charge:${attempt}`
21
- * / `revoke-run-auth:${attempt}` so each step name has never been
22
- * cached. A fresh managed-root charge is opened to replace the one that
23
- * closed with `budget_exceeded` on the pause.
24
- * 4. The same attempt is passed through to children via
25
- * `SandboxStepInput.attempt`, where it drives
26
- * `attemptStepNameFormatter` and so the resumed LLM calls miss the
27
- * prior cached 402 and fire fresh (NOTES #3).
28
- * 5. The workflow id and run id MUST NOT change across resume:
29
- * `cortex_runs.workflow_id` is rewritten by nothing in this code
30
- * path. The whole point of the bumped attempt counter is that the
31
- * same workflow id can survive multiple resumes without cache
32
- * collisions.
33
- *
34
- * Failure modes:
35
- *
36
- * - The row does not exist → `MissingRunError`. Caller MUST surface a 404
37
- * to the originating operator; do NOT call `DBOS.resumeWorkflow` on a
38
- * missing run.
39
- * - The row's status is terminal (`completed`/`partial`/`failed`/`canceled`
40
- * without `suspended_insufficient_funds` on the analysis): the helper
41
- * still bumps the counter so a defensive retry is harmless, but the
42
- * caller SHOULD skip the resume — the workflow already ran to
43
- * completion. Change 9's entry point owns this guard.
44
- */
45
- import { unwrapOrThrow } from "../lib/result.js";
46
- import { bumpRunAttemptCount, queryRun } from "../state/index.js";
47
- export class MissingRunError extends Error {
48
- workflowId;
49
- constructor(workflowId) {
50
- super(`No cortex_runs row found for run_id=${workflowId}`);
51
- this.workflowId = workflowId;
52
- this.name = "MissingRunError";
53
- }
54
- }
55
- /**
56
- * Bump the parent-workflow resume attempt counter and return the new
57
- * value. The caller invokes `DBOS.resumeWorkflow(workflowId)` immediately
58
- * after; the resumed parent body reads the bumped counter and re-opens
59
- * the running charge with a step name that has never been cached.
60
- *
61
- * `workflowId` and `runId` are the same bare UUID — `cortex_runs.run_id`
62
- * IS the DBOS workflowID.
63
- *
64
- * Idempotency: each call bumps once. A double-call before
65
- * `DBOS.resumeWorkflow` is harmless — both step names are misses and the
66
- * close on the just-opened charge will still cleanly land.
67
- */
68
- export async function prepareExecuteAnalysisResume(pool, workflowId) {
69
- const row = unwrapOrThrow(await queryRun(pool, workflowId));
70
- if (!row) {
71
- throw new MissingRunError(workflowId);
72
- }
73
- const attempt = unwrapOrThrow(await bumpRunAttemptCount(pool, row.runId));
74
- return {
75
- runId: row.runId,
76
- workflowId,
77
- attempt,
78
- previousStatus: row.status,
79
- };
80
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * Correction loop for Phase-3 fan-out branches that returned empty
3
- * without an error.
4
- *
5
- * Contract:
6
- * 1. If `coverage` is `available` (non-empty data), pass through.
7
- * 2. If `coverage` is `queried_no_data` and we have a deterministic
8
- * alt-name retry available, run ONE retry. If it succeeds, return
9
- * the new payload tagged `available`.
10
- * 3. If still empty after the alt-name retry, escalate ONCE to the
11
- * responsible Phase-2 agent (via the supplied `escalate` callback)
12
- * with the failure bundle. If the agent returns a usable payload,
13
- * return it. Otherwise return `coverage: "queried_no_data"`.
14
- *
15
- * The escalation callback is optional — callers without an agent fall
16
- * back to a final coverage tag without escalation.
17
- */
18
- import type { Coverage, SerializedError } from "./coverage.js";
19
- type CoverageEnvelope<T> = {
20
- coverage: "available";
21
- data: T;
22
- } | {
23
- coverage: "queried_no_data";
24
- error?: SerializedError;
25
- } | {
26
- coverage: "not_loaded";
27
- reason?: string;
28
- };
29
- export interface CorrectionInput<T> {
30
- initial: CoverageEnvelope<T>;
31
- altRetry?: () => Promise<CoverageEnvelope<T>>;
32
- escalate?: () => Promise<CoverageEnvelope<T>>;
33
- }
34
- export interface CorrectionTrace {
35
- altRetryAttempted: boolean;
36
- altRetrySucceeded: boolean;
37
- escalationAttempted: boolean;
38
- escalationSucceeded: boolean;
39
- finalCoverage: Coverage;
40
- }
41
- export declare function runCorrectionLoop<T>(input: CorrectionInput<T>): Promise<{
42
- result: CoverageEnvelope<T>;
43
- trace: CorrectionTrace;
44
- }>;
45
- export {};
@@ -1,62 +0,0 @@
1
- /**
2
- * Correction loop for Phase-3 fan-out branches that returned empty
3
- * without an error.
4
- *
5
- * Contract:
6
- * 1. If `coverage` is `available` (non-empty data), pass through.
7
- * 2. If `coverage` is `queried_no_data` and we have a deterministic
8
- * alt-name retry available, run ONE retry. If it succeeds, return
9
- * the new payload tagged `available`.
10
- * 3. If still empty after the alt-name retry, escalate ONCE to the
11
- * responsible Phase-2 agent (via the supplied `escalate` callback)
12
- * with the failure bundle. If the agent returns a usable payload,
13
- * return it. Otherwise return `coverage: "queried_no_data"`.
14
- *
15
- * The escalation callback is optional — callers without an agent fall
16
- * back to a final coverage tag without escalation.
17
- */
18
- export async function runCorrectionLoop(input) {
19
- const trace = {
20
- altRetryAttempted: false,
21
- altRetrySucceeded: false,
22
- escalationAttempted: false,
23
- escalationSucceeded: false,
24
- finalCoverage: input.initial.coverage,
25
- };
26
- if (input.initial.coverage === "available") {
27
- return { result: input.initial, trace };
28
- }
29
- if (input.initial.coverage === "not_loaded") {
30
- return { result: input.initial, trace };
31
- }
32
- if (input.altRetry) {
33
- trace.altRetryAttempted = true;
34
- try {
35
- const retried = await input.altRetry();
36
- if (retried.coverage === "available") {
37
- trace.altRetrySucceeded = true;
38
- trace.finalCoverage = "available";
39
- return { result: retried, trace };
40
- }
41
- }
42
- catch {
43
- // alt retry failed; proceed to escalation
44
- }
45
- }
46
- if (input.escalate) {
47
- trace.escalationAttempted = true;
48
- try {
49
- const esc = await input.escalate();
50
- if (esc.coverage === "available") {
51
- trace.escalationSucceeded = true;
52
- trace.finalCoverage = "available";
53
- return { result: esc, trace };
54
- }
55
- }
56
- catch {
57
- // escalation failed; fall through
58
- }
59
- }
60
- trace.finalCoverage = "queried_no_data";
61
- return { result: input.initial, trace };
62
- }
@@ -1,71 +0,0 @@
1
- /**
2
- * Phase 0 — target resolution.
3
- *
4
- * The single step in the workflow allowed to throw. A hard resolution
5
- * failure aborts the assessment with `error.kind: "target-unresolved"`.
6
- *
7
- * The DBOS workflow body re-implements Phase 0 inline; this module is kept
8
- * for its schemas (input/output) so dependent modules continue to compile.
9
- */
10
- export declare const phase0InputSchema: import("zod").ZodObject<{
11
- assessmentId: import("zod").ZodString;
12
- target: import("zod").ZodString;
13
- goal: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
14
- organizationId: import("zod").ZodString;
15
- requestedBy: import("zod").ZodString;
16
- }, import("zod/v4/core").$strip>;
17
- export declare const phase0OutputSchema: import("zod").ZodObject<{
18
- assessmentId: import("zod").ZodString;
19
- goal: import("zod").ZodNullable<import("zod").ZodString>;
20
- canonicalId: import("zod").ZodString;
21
- canonicalOntology: import("zod").ZodEnum<{
22
- ensembl: "ensembl";
23
- hgnc: "hgnc";
24
- }>;
25
- geneSymbol: import("zod").ZodString;
26
- approvedName: import("zod").ZodString;
27
- ids: import("zod").ZodObject<{
28
- hgnc: import("zod").ZodNullable<import("zod").ZodString>;
29
- ensembl: import("zod").ZodNullable<import("zod").ZodString>;
30
- uniprot: import("zod").ZodNullable<import("zod").ZodString>;
31
- chembl: import("zod").ZodNullable<import("zod").ZodString>;
32
- entrez: import("zod").ZodNullable<import("zod").ZodString>;
33
- }, import("zod/v4/core").$strip>;
34
- synonyms: import("zod").ZodArray<import("zod").ZodString>;
35
- proteinSynonyms: import("zod").ZodArray<import("zod").ZodString>;
36
- proteinFamily: import("zod").ZodNullable<import("zod").ZodString>;
37
- resolutionCoverage: import("zod").ZodObject<{
38
- hgnc: import("zod").ZodBoolean;
39
- uniprot: import("zod").ZodBoolean;
40
- ensembl: import("zod").ZodBoolean;
41
- chembl: import("zod").ZodBoolean;
42
- }, import("zod/v4/core").$strip>;
43
- }, import("zod/v4/core").$strip>;
44
- export declare function phase0Execute(inputData: {
45
- assessmentId: string;
46
- goal?: string | null;
47
- target: string;
48
- }): Promise<{
49
- canonicalId: string;
50
- canonicalOntology: "hgnc" | "ensembl";
51
- geneSymbol: string;
52
- approvedName: string;
53
- ids: {
54
- hgnc: string | null;
55
- ensembl: string | null;
56
- uniprot: string | null;
57
- chembl: string | null;
58
- entrez: string | null;
59
- };
60
- synonyms: string[];
61
- proteinSynonyms: string[];
62
- proteinFamily: string | null;
63
- resolutionCoverage: {
64
- hgnc: boolean;
65
- uniprot: boolean;
66
- ensembl: boolean;
67
- chembl: boolean;
68
- };
69
- assessmentId: string;
70
- goal: string | null;
71
- }>;