@inflexa-ai/harness 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +58 -0
- package/dist/agents/conversation-agent.d.ts +105 -0
- package/dist/agents/conversation-agent.js +140 -0
- package/dist/agents/report-builder.d.ts +32 -0
- package/dist/agents/report-builder.js +31 -0
- package/dist/agents/sandbox/__fixtures__/deps.d.ts +23 -0
- package/dist/agents/sandbox/__fixtures__/deps.js +96 -0
- package/dist/agents/sandbox/bulk-transcriptomics-agent.d.ts +8 -0
- package/dist/agents/sandbox/bulk-transcriptomics-agent.js +22 -0
- package/dist/agents/sandbox/cheminformatics-agent.d.ts +9 -0
- package/dist/agents/sandbox/cheminformatics-agent.js +62 -0
- package/dist/agents/sandbox/chromatin-agent.d.ts +8 -0
- package/dist/agents/sandbox/chromatin-agent.js +24 -0
- package/dist/agents/sandbox/data-profiler.d.ts +10 -0
- package/dist/agents/sandbox/data-profiler.js +24 -0
- package/dist/agents/sandbox/dna-methylation-agent.d.ts +8 -0
- package/dist/agents/sandbox/dna-methylation-agent.js +24 -0
- package/dist/agents/sandbox/drug-repurposing-agent.d.ts +8 -0
- package/dist/agents/sandbox/drug-repurposing-agent.js +54 -0
- package/dist/agents/sandbox/enrichment-agent.d.ts +8 -0
- package/dist/agents/sandbox/enrichment-agent.js +24 -0
- package/dist/agents/sandbox/ephemeral-executor.d.ts +9 -0
- package/dist/agents/sandbox/ephemeral-executor.js +29 -0
- package/dist/agents/sandbox/genomic-variant-agent.d.ts +8 -0
- package/dist/agents/sandbox/genomic-variant-agent.js +27 -0
- package/dist/agents/sandbox/immune-profiling-agent.d.ts +8 -0
- package/dist/agents/sandbox/immune-profiling-agent.js +43 -0
- package/dist/agents/sandbox/index.d.ts +31 -0
- package/dist/agents/sandbox/index.js +96 -0
- package/dist/agents/sandbox/metabolomics-agent.d.ts +8 -0
- package/dist/agents/sandbox/metabolomics-agent.js +15 -0
- package/dist/agents/sandbox/microbiome-agent.d.ts +8 -0
- package/dist/agents/sandbox/microbiome-agent.js +15 -0
- package/dist/agents/sandbox/multi-omics-integration-agent.d.ts +8 -0
- package/dist/agents/sandbox/multi-omics-integration-agent.js +33 -0
- package/dist/agents/sandbox/multimodal-sc-agent.d.ts +8 -0
- package/dist/agents/sandbox/multimodal-sc-agent.js +15 -0
- package/dist/agents/sandbox/network-agent.d.ts +8 -0
- package/dist/agents/sandbox/network-agent.js +25 -0
- package/dist/agents/sandbox/pkpd-clinical-response-agent.d.ts +8 -0
- package/dist/agents/sandbox/pkpd-clinical-response-agent.js +59 -0
- package/dist/agents/sandbox/proteomics-agent.d.ts +8 -0
- package/dist/agents/sandbox/proteomics-agent.js +15 -0
- package/dist/agents/sandbox/scientific-executor.d.ts +9 -0
- package/dist/agents/sandbox/scientific-executor.js +56 -0
- package/dist/agents/sandbox/shared.d.ts +100 -0
- package/dist/agents/sandbox/shared.js +195 -0
- package/dist/agents/sandbox/single-cell-agent.d.ts +8 -0
- package/dist/agents/sandbox/single-cell-agent.js +25 -0
- package/dist/agents/sandbox/spatial-omics-agent.d.ts +8 -0
- package/dist/agents/sandbox/spatial-omics-agent.js +15 -0
- package/dist/agents/sandbox/statistical-modeling-agent.d.ts +8 -0
- package/dist/agents/sandbox/statistical-modeling-agent.js +37 -0
- package/dist/agents/sandbox/translational-safety-agent.d.ts +8 -0
- package/dist/agents/sandbox/translational-safety-agent.js +59 -0
- package/dist/agents/sandbox/types.d.ts +34 -0
- package/dist/agents/sandbox/types.js +15 -0
- package/dist/agents/sandbox/validate-skills.d.ts +18 -0
- package/dist/agents/sandbox/validate-skills.js +40 -0
- package/dist/agents/sandbox-catalog.d.ts +33 -0
- package/dist/agents/sandbox-catalog.js +44 -0
- package/dist/agents/system-prompt.d.ts +25 -0
- package/dist/agents/system-prompt.js +23 -0
- package/dist/app/chat-turn.d.ts +35 -0
- package/dist/app/chat-turn.js +64 -0
- package/dist/app/data-profile-policy.d.ts +36 -0
- package/dist/app/data-profile-policy.js +37 -0
- package/dist/app/message-assembly.d.ts +65 -0
- package/dist/app/message-assembly.js +61 -0
- package/dist/app/synthesize-run.d.ts +57 -0
- package/dist/app/synthesize-run.js +103 -0
- package/dist/auth/local-auth-context.d.ts +19 -0
- package/dist/auth/local-auth-context.js +20 -0
- package/dist/auth/local-run-authorizer.d.ts +10 -0
- package/dist/auth/local-run-authorizer.js +23 -0
- package/dist/auth/types.d.ts +166 -0
- package/dist/auth/types.js +61 -0
- package/dist/billing/cached-resolver.d.ts +23 -0
- package/dist/billing/cached-resolver.js +61 -0
- package/dist/billing/noop-resolver.d.ts +6 -0
- package/dist/billing/noop-resolver.js +7 -0
- package/dist/billing/noop-run-charge.d.ts +6 -0
- package/dist/billing/noop-run-charge.js +10 -0
- package/dist/billing/resolver.d.ts +64 -0
- package/dist/billing/resolver.js +24 -0
- package/dist/billing/run-charge.d.ts +24 -0
- package/dist/billing/run-charge.js +9 -0
- package/dist/config/resource-limits.d.ts +76 -0
- package/dist/config/resource-limits.js +116 -0
- package/dist/contracts/analogy-report.d.ts +120 -0
- package/dist/contracts/analogy-report.js +50 -0
- package/dist/contracts/chat-events.d.ts +61 -0
- package/dist/contracts/chat-events.js +13 -0
- package/dist/contracts/chat-parts.d.ts +308 -0
- package/dist/contracts/chat-parts.js +13 -0
- package/dist/contracts/content-url.d.ts +49 -0
- package/dist/contracts/content-url.js +56 -0
- package/dist/contracts/index.d.ts +12 -0
- package/dist/contracts/index.js +5 -0
- package/dist/contracts/message.d.ts +36 -0
- package/dist/contracts/message.js +9 -0
- package/dist/contracts/part-registry.d.ts +18 -0
- package/dist/contracts/part-registry.js +28 -0
- package/dist/contracts/schemas/chat-events.d.ts +90 -0
- package/dist/contracts/schemas/chat-events.js +43 -0
- package/dist/contracts/schemas/chat-parts.d.ts +683 -0
- package/dist/contracts/schemas/chat-parts.js +295 -0
- package/dist/contracts/schemas/index.d.ts +2 -0
- package/dist/contracts/schemas/index.js +2 -0
- package/dist/contracts/target-assessment-row.d.ts +85 -0
- package/dist/contracts/target-assessment-row.js +37 -0
- package/dist/contracts/target-dossier.d.ts +16720 -0
- package/dist/contracts/target-dossier.js +1339 -0
- package/dist/data/clinical-benchmarks.json +108 -0
- package/dist/data/protein-family-modality.json +101 -0
- package/dist/data/safety-panel-schema.d.ts +64 -0
- package/dist/data/safety-panel-schema.js +34 -0
- package/dist/data/safety-panel.json +436 -0
- package/dist/execution/artifact-metadata.d.ts +74 -0
- package/dist/execution/artifact-metadata.js +203 -0
- package/dist/execution/artifact-record.d.ts +19 -0
- package/dist/execution/artifact-record.js +7 -0
- package/dist/execution/artifact-registration.d.ts +36 -0
- package/dist/execution/artifact-registration.js +61 -0
- package/dist/execution/artifact-registry.d.ts +82 -0
- package/dist/execution/artifact-registry.js +17 -0
- package/dist/execution/dbos-run-launcher.d.ts +7 -0
- package/dist/execution/dbos-run-launcher.js +38 -0
- package/dist/execution/ephemeral-runner.d.ts +81 -0
- package/dist/execution/ephemeral-runner.js +161 -0
- package/dist/execution/filesystem-artifact-registry.d.ts +57 -0
- package/dist/execution/filesystem-artifact-registry.js +92 -0
- package/dist/execution/noop-artifact-registry.d.ts +11 -0
- package/dist/execution/noop-artifact-registry.js +17 -0
- package/dist/execution/post-step-pipeline.d.ts +70 -0
- package/dist/execution/post-step-pipeline.js +207 -0
- package/dist/execution/post-step.d.ts +20 -0
- package/dist/execution/post-step.js +65 -0
- package/dist/execution/reconcile-manifest.d.ts +25 -0
- package/dist/execution/reconcile-manifest.js +132 -0
- package/dist/execution/report-render.d.ts +39 -0
- package/dist/execution/report-render.js +98 -0
- package/dist/execution/report-runner.d.ts +87 -0
- package/dist/execution/report-runner.js +227 -0
- package/dist/execution/run-authorizer.d.ts +43 -0
- package/dist/execution/run-authorizer.js +17 -0
- package/dist/execution/run-launcher.d.ts +36 -0
- package/dist/execution/run-launcher.js +15 -0
- package/dist/execution/run-synthesis.d.ts +107 -0
- package/dist/execution/run-synthesis.js +329 -0
- package/dist/execution/staged-input.d.ts +41 -0
- package/dist/execution/staged-input.js +15 -0
- package/dist/execution/step-summary-metrics.d.ts +10 -0
- package/dist/execution/step-summary-metrics.js +22 -0
- package/dist/execution/step-summary.d.ts +55 -0
- package/dist/execution/step-summary.js +106 -0
- package/dist/execution/topo-sort.d.ts +33 -0
- package/dist/execution/topo-sort.js +99 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +157 -0
- package/dist/input-sanitization.d.ts +22 -0
- package/dist/input-sanitization.js +64 -0
- package/dist/lib/async-utils.d.ts +10 -0
- package/dist/lib/async-utils.js +24 -0
- package/dist/lib/chrome.d.ts +15 -0
- package/dist/lib/chrome.js +95 -0
- package/dist/lib/db-result.d.ts +93 -0
- package/dist/lib/db-result.js +197 -0
- package/dist/lib/fs-helpers.d.ts +74 -0
- package/dist/lib/fs-helpers.js +119 -0
- package/dist/lib/fs-result.d.ts +98 -0
- package/dist/lib/fs-result.js +137 -0
- package/dist/lib/host-concurrency.d.ts +16 -0
- package/dist/lib/host-concurrency.js +60 -0
- package/dist/lib/identifiers.d.ts +8 -0
- package/dist/lib/identifiers.js +10 -0
- package/dist/lib/metrics.d.ts +7 -0
- package/dist/lib/metrics.js +12 -0
- package/dist/lib/mime-detect.d.ts +17 -0
- package/dist/lib/mime-detect.js +29 -0
- package/dist/lib/otel.d.ts +30 -0
- package/dist/lib/otel.js +102 -0
- package/dist/lib/regulatory-corpus/fetch-fda-guidance.d.ts +35 -0
- package/dist/lib/regulatory-corpus/fetch-fda-guidance.js +107 -0
- package/dist/lib/regulatory-corpus/fetch-ich.d.ts +46 -0
- package/dist/lib/regulatory-corpus/fetch-ich.js +173 -0
- package/dist/lib/regulatory-corpus.d.ts +88 -0
- package/dist/lib/regulatory-corpus.js +141 -0
- package/dist/lib/result.d.ts +87 -0
- package/dist/lib/result.js +103 -0
- package/dist/lib/storage.d.ts +29 -0
- package/dist/lib/storage.js +37 -0
- package/dist/lib/streamed-download.d.ts +28 -0
- package/dist/lib/streamed-download.js +111 -0
- package/dist/lib/trace-context.d.ts +11 -0
- package/dist/lib/trace-context.js +49 -0
- package/dist/loop/__fixtures__/scripted-provider.d.ts +31 -0
- package/dist/loop/__fixtures__/scripted-provider.js +57 -0
- package/dist/loop/budget-exceeded.d.ts +22 -0
- package/dist/loop/budget-exceeded.js +41 -0
- package/dist/loop/metrics.d.ts +25 -0
- package/dist/loop/metrics.js +46 -0
- package/dist/loop/run-agent.d.ts +28 -0
- package/dist/loop/run-agent.js +204 -0
- package/dist/loop/run-step.d.ts +29 -0
- package/dist/loop/run-step.js +34 -0
- package/dist/loop/run-to-terminal.d.ts +46 -0
- package/dist/loop/run-to-terminal.js +51 -0
- package/dist/loop/types.d.ts +95 -0
- package/dist/loop/types.js +10 -0
- package/dist/memory/ai-sdk-message-storage.d.ts +20 -0
- package/dist/memory/ai-sdk-message-storage.js +114 -0
- package/dist/memory/card-builders.d.ts +114 -0
- package/dist/memory/card-builders.js +231 -0
- package/dist/memory/content-to-cortex.d.ts +42 -0
- package/dist/memory/content-to-cortex.js +85 -0
- package/dist/memory/count-tokens.d.ts +18 -0
- package/dist/memory/count-tokens.js +64 -0
- package/dist/memory/derive-thread-title.d.ts +14 -0
- package/dist/memory/derive-thread-title.js +26 -0
- package/dist/memory/message-backfill.d.ts +2 -0
- package/dist/memory/message-backfill.js +38 -0
- package/dist/memory/reconstruct-cards.d.ts +23 -0
- package/dist/memory/reconstruct-cards.js +64 -0
- package/dist/memory/thread-history.d.ts +80 -0
- package/dist/memory/thread-history.js +187 -0
- package/dist/memory/thread-store.d.ts +66 -0
- package/dist/memory/thread-store.js +88 -0
- package/dist/memory/working-memory.d.ts +135 -0
- package/dist/memory/working-memory.js +185 -0
- package/dist/prompts/SOUL.d.ts +17 -0
- package/dist/prompts/SOUL.js +173 -0
- package/dist/prompts/analogical-reasoner.d.ts +1 -0
- package/dist/prompts/analogical-reasoner.js +170 -0
- package/dist/prompts/conversation.d.ts +1 -0
- package/dist/prompts/conversation.js +697 -0
- package/dist/prompts/execute-analysis/step-summary.d.ts +1 -0
- package/dist/prompts/execute-analysis/step-summary.js +38 -0
- package/dist/prompts/literature-reviewer.d.ts +1 -0
- package/dist/prompts/literature-reviewer.js +107 -0
- package/dist/prompts/planner.d.ts +2 -0
- package/dist/prompts/planner.js +259 -0
- package/dist/prompts/report-builder.d.ts +1 -0
- package/dist/prompts/report-builder.js +127 -0
- package/dist/prompts/sandbox/bulk-transcriptomics-agent.d.ts +1 -0
- package/dist/prompts/sandbox/bulk-transcriptomics-agent.js +78 -0
- package/dist/prompts/sandbox/cheminformatics-agent.d.ts +1 -0
- package/dist/prompts/sandbox/cheminformatics-agent.js +224 -0
- package/dist/prompts/sandbox/chromatin-agent.d.ts +1 -0
- package/dist/prompts/sandbox/chromatin-agent.js +100 -0
- package/dist/prompts/sandbox/data-profiler.d.ts +1 -0
- package/dist/prompts/sandbox/data-profiler.js +291 -0
- package/dist/prompts/sandbox/dna-methylation-agent.d.ts +1 -0
- package/dist/prompts/sandbox/dna-methylation-agent.js +96 -0
- package/dist/prompts/sandbox/drug-repurposing-agent.d.ts +1 -0
- package/dist/prompts/sandbox/drug-repurposing-agent.js +144 -0
- package/dist/prompts/sandbox/enrichment-agent.d.ts +1 -0
- package/dist/prompts/sandbox/enrichment-agent.js +89 -0
- package/dist/prompts/sandbox/ephemeral-executor.d.ts +1 -0
- package/dist/prompts/sandbox/ephemeral-executor.js +66 -0
- package/dist/prompts/sandbox/genomic-variant-agent.d.ts +1 -0
- package/dist/prompts/sandbox/genomic-variant-agent.js +83 -0
- package/dist/prompts/sandbox/immune-profiling-agent.d.ts +1 -0
- package/dist/prompts/sandbox/immune-profiling-agent.js +101 -0
- package/dist/prompts/sandbox/metabolomics-agent.d.ts +1 -0
- package/dist/prompts/sandbox/metabolomics-agent.js +89 -0
- package/dist/prompts/sandbox/microbiome-agent.d.ts +1 -0
- package/dist/prompts/sandbox/microbiome-agent.js +109 -0
- package/dist/prompts/sandbox/multi-omics-integration-agent.d.ts +1 -0
- package/dist/prompts/sandbox/multi-omics-integration-agent.js +122 -0
- package/dist/prompts/sandbox/multimodal-sc-agent.d.ts +1 -0
- package/dist/prompts/sandbox/multimodal-sc-agent.js +90 -0
- package/dist/prompts/sandbox/network-agent.d.ts +1 -0
- package/dist/prompts/sandbox/network-agent.js +95 -0
- package/dist/prompts/sandbox/pkpd-clinical-response-agent.d.ts +1 -0
- package/dist/prompts/sandbox/pkpd-clinical-response-agent.js +71 -0
- package/dist/prompts/sandbox/proteomics-agent.d.ts +1 -0
- package/dist/prompts/sandbox/proteomics-agent.js +93 -0
- package/dist/prompts/sandbox/scientific-executor.d.ts +1 -0
- package/dist/prompts/sandbox/scientific-executor.js +68 -0
- package/dist/prompts/sandbox/single-cell-agent.d.ts +1 -0
- package/dist/prompts/sandbox/single-cell-agent.js +129 -0
- package/dist/prompts/sandbox/spatial-omics-agent.d.ts +1 -0
- package/dist/prompts/sandbox/spatial-omics-agent.js +94 -0
- package/dist/prompts/sandbox/statistical-modeling-agent.d.ts +1 -0
- package/dist/prompts/sandbox/statistical-modeling-agent.js +112 -0
- package/dist/prompts/sandbox/translational-safety-agent.d.ts +1 -0
- package/dist/prompts/sandbox/translational-safety-agent.js +105 -0
- package/dist/prompts/sandbox-standards.d.ts +18 -0
- package/dist/prompts/sandbox-standards.js +358 -0
- package/dist/prompts/synthesis-agent.d.ts +1 -0
- package/dist/prompts/synthesis-agent.js +289 -0
- package/dist/prompts/target-assessment/briefs/executive-recommendation.d.ts +1 -0
- package/dist/prompts/target-assessment/briefs/executive-recommendation.js +85 -0
- package/dist/prompts/target-assessment/briefs/index.d.ts +4 -0
- package/dist/prompts/target-assessment/briefs/index.js +4 -0
- package/dist/prompts/target-assessment/briefs/liability-bullets.d.ts +1 -0
- package/dist/prompts/target-assessment/briefs/liability-bullets.js +114 -0
- package/dist/prompts/target-assessment/briefs/target-organ-liabilities.d.ts +1 -0
- package/dist/prompts/target-assessment/briefs/target-organ-liabilities.js +29 -0
- package/dist/prompts/target-assessment/briefs/translational-commentary.d.ts +1 -0
- package/dist/prompts/target-assessment/briefs/translational-commentary.js +23 -0
- package/dist/prompts/target-assessment/drugs-in-class.d.ts +1 -0
- package/dist/prompts/target-assessment/drugs-in-class.js +29 -0
- package/dist/prompts/target-assessment/modulator-triage.d.ts +1 -0
- package/dist/prompts/target-assessment/modulator-triage.js +31 -0
- package/dist/prompts/target-assessment/off-target-annotator.d.ts +1 -0
- package/dist/prompts/target-assessment/off-target-annotator.js +28 -0
- package/dist/prompts/target-assessment/tox-voice/core.d.ts +1 -0
- package/dist/prompts/target-assessment/tox-voice/core.js +74 -0
- package/dist/prompts/target-assessment/tox-voice/critique.d.ts +7 -0
- package/dist/prompts/target-assessment/tox-voice/critique.js +109 -0
- package/dist/prompts/target-assessment/tox-voice/exemplars.d.ts +8 -0
- package/dist/prompts/target-assessment/tox-voice/exemplars.js +24 -0
- package/dist/prompts/target-assessment/tox-voice/index.d.ts +4 -0
- package/dist/prompts/target-assessment/tox-voice/index.js +4 -0
- package/dist/prompts/target-assessment/tox-voice/vocabulary.d.ts +15 -0
- package/dist/prompts/target-assessment/tox-voice/vocabulary.js +72 -0
- package/dist/provenance/collector.d.ts +148 -0
- package/dist/provenance/collector.js +296 -0
- package/dist/provenance/exec-frame.d.ts +36 -0
- package/dist/provenance/exec-frame.js +49 -0
- package/dist/provenance/types.d.ts +95 -0
- package/dist/provenance/types.js +64 -0
- package/dist/providers/__fixtures__/session.d.ts +16 -0
- package/dist/providers/__fixtures__/session.js +20 -0
- package/dist/providers/ai-sdk.d.ts +47 -0
- package/dist/providers/ai-sdk.js +142 -0
- package/dist/providers/anthropic.d.ts +22 -0
- package/dist/providers/anthropic.js +26 -0
- package/dist/providers/embedding.d.ts +32 -0
- package/dist/providers/embedding.js +42 -0
- package/dist/providers/errors.d.ts +80 -0
- package/dist/providers/errors.js +137 -0
- package/dist/providers/llm-capabilities.d.ts +33 -0
- package/dist/providers/llm-capabilities.js +58 -0
- package/dist/providers/streaming-chat.d.ts +23 -0
- package/dist/providers/streaming-chat.js +61 -0
- package/dist/providers/types.d.ts +59 -0
- package/dist/providers/types.js +8 -0
- package/dist/runtime/assemble.d.ts +68 -0
- package/dist/runtime/assemble.js +46 -0
- package/dist/runtime/boot.d.ts +73 -0
- package/dist/runtime/boot.js +65 -0
- package/dist/runtime/connection-budget.d.ts +48 -0
- package/dist/runtime/connection-budget.js +57 -0
- package/dist/runtime/dbos.d.ts +94 -0
- package/dist/runtime/dbos.js +160 -0
- package/dist/runtime/lifecycle.d.ts +12 -0
- package/dist/runtime/lifecycle.js +19 -0
- package/dist/runtime/pools.d.ts +25 -0
- package/dist/runtime/pools.js +30 -0
- package/dist/runtime/shutdown.d.ts +33 -0
- package/dist/runtime/shutdown.js +39 -0
- package/dist/sandbox/await-exec.d.ts +143 -0
- package/dist/sandbox/await-exec.js +406 -0
- package/dist/sandbox/client.d.ts +82 -0
- package/dist/sandbox/client.js +23 -0
- package/dist/sandbox/create-sandbox.d.ts +105 -0
- package/dist/sandbox/create-sandbox.js +132 -0
- package/dist/sandbox/deliver-exec-event.d.ts +25 -0
- package/dist/sandbox/deliver-exec-event.js +29 -0
- package/dist/sandbox/docker-client.d.ts +75 -0
- package/dist/sandbox/docker-client.js +315 -0
- package/dist/sandbox/estimate-data-profile-resources.d.ts +5 -0
- package/dist/sandbox/estimate-data-profile-resources.js +73 -0
- package/dist/sandbox/exec-id.d.ts +12 -0
- package/dist/sandbox/exec-id.js +20 -0
- package/dist/sandbox/execution-id.d.ts +30 -0
- package/dist/sandbox/execution-id.js +47 -0
- package/dist/sandbox/hmac.d.ts +54 -0
- package/dist/sandbox/hmac.js +67 -0
- package/dist/sandbox/identity.d.ts +15 -0
- package/dist/sandbox/identity.js +22 -0
- package/dist/sandbox/ignored-dirs.d.ts +7 -0
- package/dist/sandbox/ignored-dirs.js +7 -0
- package/dist/sandbox/k8s-client.d.ts +71 -0
- package/dist/sandbox/k8s-client.js +488 -0
- package/dist/sandbox/liveness.d.ts +60 -0
- package/dist/sandbox/liveness.js +82 -0
- package/dist/sandbox/mount-plan.d.ts +77 -0
- package/dist/sandbox/mount-plan.js +84 -0
- package/dist/sandbox/notification-sweep.d.ts +42 -0
- package/dist/sandbox/notification-sweep.js +74 -0
- package/dist/sandbox/reaper.d.ts +70 -0
- package/dist/sandbox/reaper.js +124 -0
- package/dist/sandbox/sandbox-error.d.ts +105 -0
- package/dist/sandbox/sandbox-error.js +92 -0
- package/dist/sandbox/sandbox-step-translate.d.ts +35 -0
- package/dist/sandbox/sandbox-step-translate.js +76 -0
- package/dist/sandbox/submit-exec.d.ts +33 -0
- package/dist/sandbox/submit-exec.js +68 -0
- package/dist/sandbox/types.d.ts +277 -0
- package/dist/sandbox/types.js +147 -0
- package/dist/sandbox/watchdog.d.ts +71 -0
- package/dist/sandbox/watchdog.js +150 -0
- package/dist/schemas/artifact-manifest.d.ts +34 -0
- package/dist/schemas/artifact-manifest.js +36 -0
- package/dist/schemas/data-profile-schemas.d.ts +92 -0
- package/dist/schemas/data-profile-schemas.js +89 -0
- package/dist/schemas/file-metadata.d.ts +51 -0
- package/dist/schemas/file-metadata.js +39 -0
- package/dist/schemas/plan-schemas.d.ts +110 -0
- package/dist/schemas/plan-schemas.js +50 -0
- package/dist/schemas/render-step-prompt.d.ts +32 -0
- package/dist/schemas/render-step-prompt.js +76 -0
- package/dist/schemas/run-synthesis.d.ts +148 -0
- package/dist/schemas/run-synthesis.js +87 -0
- package/dist/schemas/step-summary.d.ts +18 -0
- package/dist/schemas/step-summary.js +20 -0
- package/dist/schemas/validate-plan.d.ts +39 -0
- package/dist/schemas/validate-plan.js +120 -0
- package/dist/schemas/workflow-state.d.ts +314 -0
- package/dist/schemas/workflow-state.js +139 -0
- package/dist/state/active-sandboxes.d.ts +58 -0
- package/dist/state/active-sandboxes.js +100 -0
- package/dist/state/analyses-metrics.d.ts +21 -0
- package/dist/state/analyses-metrics.js +59 -0
- package/dist/state/analyses.d.ts +58 -0
- package/dist/state/analyses.js +132 -0
- package/dist/state/artifacts.d.ts +53 -0
- package/dist/state/artifacts.js +175 -0
- package/dist/state/data-profile.d.ts +176 -0
- package/dist/state/data-profile.js +284 -0
- package/dist/state/db.d.ts +10 -0
- package/dist/state/db.js +9 -0
- package/dist/state/index.d.ts +29 -0
- package/dist/state/index.js +20 -0
- package/dist/state/init.d.ts +14 -0
- package/dist/state/init.js +406 -0
- package/dist/state/plans.d.ts +56 -0
- package/dist/state/plans.js +117 -0
- package/dist/state/runs.d.ts +69 -0
- package/dist/state/runs.js +206 -0
- package/dist/state/schema.d.ts +150 -0
- package/dist/state/schema.js +100 -0
- package/dist/state/step-executions.d.ts +77 -0
- package/dist/state/step-executions.js +175 -0
- package/dist/state/target-assessments.d.ts +68 -0
- package/dist/state/target-assessments.js +222 -0
- package/dist/state/vector-store.d.ts +53 -0
- package/dist/state/vector-store.js +89 -0
- package/dist/tasks/data-profile.d.ts +171 -0
- package/dist/tasks/data-profile.js +461 -0
- package/dist/tasks/refresh-regulatory-corpus.d.ts +59 -0
- package/dist/tasks/refresh-regulatory-corpus.js +146 -0
- package/dist/tasks/regulatory-corpus-boot-refresh.d.ts +55 -0
- package/dist/tasks/regulatory-corpus-boot-refresh.js +149 -0
- package/dist/tools/__fixtures__/tool-context.d.ts +13 -0
- package/dist/tools/__fixtures__/tool-context.js +18 -0
- package/dist/tools/bio/check-safety-panel.d.ts +35 -0
- package/dist/tools/bio/check-safety-panel.js +76 -0
- package/dist/tools/bio/find-approval-precedent.d.ts +32 -0
- package/dist/tools/bio/find-approval-precedent.js +72 -0
- package/dist/tools/bio/get-article-details.d.ts +11 -0
- package/dist/tools/bio/get-article-details.js +20 -0
- package/dist/tools/bio/get-article-full-text.d.ts +19 -0
- package/dist/tools/bio/get-article-full-text.js +32 -0
- package/dist/tools/bio/get-bioactivity.d.ts +11 -0
- package/dist/tools/bio/get-bioactivity.js +23 -0
- package/dist/tools/bio/get-drug-info.d.ts +9 -0
- package/dist/tools/bio/get-drug-info.js +22 -0
- package/dist/tools/bio/get-impc-ko-profile.d.ts +9 -0
- package/dist/tools/bio/get-impc-ko-profile.js +20 -0
- package/dist/tools/bio/get-mechanism.d.ts +8 -0
- package/dist/tools/bio/get-mechanism.js +18 -0
- package/dist/tools/bio/get-pubchem-assays.d.ts +22 -0
- package/dist/tools/bio/get-pubchem-assays.js +107 -0
- package/dist/tools/bio/get-pubchem-cross-refs.d.ts +15 -0
- package/dist/tools/bio/get-pubchem-cross-refs.js +68 -0
- package/dist/tools/bio/get-target-safety.d.ts +18 -0
- package/dist/tools/bio/get-target-safety.js +26 -0
- package/dist/tools/bio/index.d.ts +41 -0
- package/dist/tools/bio/index.js +48 -0
- package/dist/tools/bio/keys.d.ts +31 -0
- package/dist/tools/bio/keys.js +30 -0
- package/dist/tools/bio/lookup-go-term.d.ts +31 -0
- package/dist/tools/bio/lookup-go-term.js +116 -0
- package/dist/tools/bio/search-bgee-expression.d.ts +10 -0
- package/dist/tools/bio/search-bgee-expression.js +24 -0
- package/dist/tools/bio/search-clinical-trials.d.ts +12 -0
- package/dist/tools/bio/search-clinical-trials.js +21 -0
- package/dist/tools/bio/search-clinvar.d.ts +13 -0
- package/dist/tools/bio/search-clinvar.js +28 -0
- package/dist/tools/bio/search-compounds.d.ts +22 -0
- package/dist/tools/bio/search-compounds.js +160 -0
- package/dist/tools/bio/search-ctx-chemical.d.ts +50 -0
- package/dist/tools/bio/search-ctx-chemical.js +130 -0
- package/dist/tools/bio/search-ctx-exposure.d.ts +55 -0
- package/dist/tools/bio/search-ctx-exposure.js +176 -0
- package/dist/tools/bio/search-ctx-hazard.d.ts +111 -0
- package/dist/tools/bio/search-ctx-hazard.js +178 -0
- package/dist/tools/bio/search-dgidb.d.ts +43 -0
- package/dist/tools/bio/search-dgidb.js +199 -0
- package/dist/tools/bio/search-disgenet.d.ts +30 -0
- package/dist/tools/bio/search-disgenet.js +84 -0
- package/dist/tools/bio/search-drugbank.d.ts +38 -0
- package/dist/tools/bio/search-drugbank.js +109 -0
- package/dist/tools/bio/search-faers.d.ts +11 -0
- package/dist/tools/bio/search-faers.js +23 -0
- package/dist/tools/bio/search-gene.d.ts +11 -0
- package/dist/tools/bio/search-gene.js +19 -0
- package/dist/tools/bio/search-geo-datasets.d.ts +20 -0
- package/dist/tools/bio/search-geo-datasets.js +86 -0
- package/dist/tools/bio/search-gwas-catalog.d.ts +33 -0
- package/dist/tools/bio/search-gwas-catalog.js +172 -0
- package/dist/tools/bio/search-interactions.d.ts +17 -0
- package/dist/tools/bio/search-interactions.js +31 -0
- package/dist/tools/bio/search-opentargets.d.ts +11 -0
- package/dist/tools/bio/search-opentargets.js +25 -0
- package/dist/tools/bio/search-pathway.d.ts +12 -0
- package/dist/tools/bio/search-pathway.js +32 -0
- package/dist/tools/bio/search-pharmgkb.d.ts +17 -0
- package/dist/tools/bio/search-pharmgkb.js +46 -0
- package/dist/tools/bio/search-pubchem-compound.d.ts +26 -0
- package/dist/tools/bio/search-pubchem-compound.js +110 -0
- package/dist/tools/bio/search-pubmed.d.ts +17 -0
- package/dist/tools/bio/search-pubmed.js +31 -0
- package/dist/tools/bio/search-targets.d.ts +9 -0
- package/dist/tools/bio/search-targets.js +20 -0
- package/dist/tools/bio/search-toxcast.d.ts +36 -0
- package/dist/tools/bio/search-toxcast.js +141 -0
- package/dist/tools/define-tool.d.ts +80 -0
- package/dist/tools/define-tool.js +48 -0
- package/dist/tools/display/index.d.ts +4 -0
- package/dist/tools/display/index.js +4 -0
- package/dist/tools/display/show-user.d.ts +33 -0
- package/dist/tools/display/show-user.js +67 -0
- package/dist/tools/execute-plan.d.ts +64 -0
- package/dist/tools/execute-plan.js +208 -0
- package/dist/tools/iterate-report.d.ts +172 -0
- package/dist/tools/iterate-report.js +521 -0
- package/dist/tools/lib/api-utils.d.ts +80 -0
- package/dist/tools/lib/api-utils.js +128 -0
- package/dist/tools/lib/bgee-client.d.ts +36 -0
- package/dist/tools/lib/bgee-client.js +150 -0
- package/dist/tools/lib/cbioportal-client.d.ts +34 -0
- package/dist/tools/lib/cbioportal-client.js +159 -0
- package/dist/tools/lib/chembl-client.d.ts +123 -0
- package/dist/tools/lib/chembl-client.js +458 -0
- package/dist/tools/lib/chembl-config.d.ts +5 -0
- package/dist/tools/lib/chembl-config.js +3 -0
- package/dist/tools/lib/clinical-benchmarks-client.d.ts +33 -0
- package/dist/tools/lib/clinical-benchmarks-client.js +54 -0
- package/dist/tools/lib/clinical-trials-client.d.ts +216 -0
- package/dist/tools/lib/clinical-trials-client.js +339 -0
- package/dist/tools/lib/clinicaltrials-config.d.ts +4 -0
- package/dist/tools/lib/clinicaltrials-config.js +2 -0
- package/dist/tools/lib/clinvar-client.d.ts +25 -0
- package/dist/tools/lib/clinvar-client.js +126 -0
- package/dist/tools/lib/disgenet-config.d.ts +2 -0
- package/dist/tools/lib/disgenet-config.js +11 -0
- package/dist/tools/lib/drugbank-config.d.ts +2 -0
- package/dist/tools/lib/drugbank-config.js +12 -0
- package/dist/tools/lib/ema-client.d.ts +45 -0
- package/dist/tools/lib/ema-client.js +127 -0
- package/dist/tools/lib/ema-config.d.ts +7 -0
- package/dist/tools/lib/ema-config.js +7 -0
- package/dist/tools/lib/ensembl-client.d.ts +27 -0
- package/dist/tools/lib/ensembl-client.js +82 -0
- package/dist/tools/lib/gwas-catalog-config.d.ts +4 -0
- package/dist/tools/lib/gwas-catalog-config.js +2 -0
- package/dist/tools/lib/identifier-resolver.d.ts +85 -0
- package/dist/tools/lib/identifier-resolver.js +333 -0
- package/dist/tools/lib/impc-client.d.ts +44 -0
- package/dist/tools/lib/impc-client.js +239 -0
- package/dist/tools/lib/iuphar-client.d.ts +75 -0
- package/dist/tools/lib/iuphar-client.js +230 -0
- package/dist/tools/lib/iuphar-config.d.ts +5 -0
- package/dist/tools/lib/iuphar-config.js +3 -0
- package/dist/tools/lib/ncbi-utils.d.ts +58 -0
- package/dist/tools/lib/ncbi-utils.js +286 -0
- package/dist/tools/lib/openfda-client.d.ts +53 -0
- package/dist/tools/lib/openfda-client.js +192 -0
- package/dist/tools/lib/openfda-config.d.ts +2 -0
- package/dist/tools/lib/openfda-config.js +2 -0
- package/dist/tools/lib/opentargets-client.d.ts +64 -0
- package/dist/tools/lib/opentargets-client.js +290 -0
- package/dist/tools/lib/opentargets-config.d.ts +5 -0
- package/dist/tools/lib/opentargets-config.js +5 -0
- package/dist/tools/lib/path-validation.d.ts +14 -0
- package/dist/tools/lib/path-validation.js +26 -0
- package/dist/tools/lib/pathway-client.d.ts +27 -0
- package/dist/tools/lib/pathway-client.js +149 -0
- package/dist/tools/lib/pharmgkb-config.d.ts +4 -0
- package/dist/tools/lib/pharmgkb-config.js +2 -0
- package/dist/tools/lib/preview-lock.d.ts +20 -0
- package/dist/tools/lib/preview-lock.js +35 -0
- package/dist/tools/lib/protein-family-modality.d.ts +16 -0
- package/dist/tools/lib/protein-family-modality.js +42 -0
- package/dist/tools/lib/protein-family-normalize.d.ts +12 -0
- package/dist/tools/lib/protein-family-normalize.js +46 -0
- package/dist/tools/lib/pubchem-client.d.ts +40 -0
- package/dist/tools/lib/pubchem-client.js +128 -0
- package/dist/tools/lib/pubchem-config.d.ts +5 -0
- package/dist/tools/lib/pubchem-config.js +3 -0
- package/dist/tools/lib/pubmed-client.d.ts +28 -0
- package/dist/tools/lib/pubmed-client.js +91 -0
- package/dist/tools/lib/report-preflight.d.ts +39 -0
- package/dist/tools/lib/report-preflight.js +283 -0
- package/dist/tools/lib/string-client.d.ts +33 -0
- package/dist/tools/lib/string-client.js +93 -0
- package/dist/tools/lib/toxcast-config.d.ts +2 -0
- package/dist/tools/lib/toxcast-config.js +11 -0
- package/dist/tools/lib/uniprot-client.d.ts +28 -0
- package/dist/tools/lib/uniprot-client.js +103 -0
- package/dist/tools/lib/uniprot-config.d.ts +5 -0
- package/dist/tools/lib/uniprot-config.js +3 -0
- package/dist/tools/memory/index.d.ts +4 -0
- package/dist/tools/memory/index.js +4 -0
- package/dist/tools/memory/update-working-memory.d.ts +25 -0
- package/dist/tools/memory/update-working-memory.js +112 -0
- package/dist/tools/registry.d.ts +15 -0
- package/dist/tools/registry.js +26 -0
- package/dist/tools/report/build-report.d.ts +13 -0
- package/dist/tools/report/build-report.js +26 -0
- package/dist/tools/report/index.d.ts +14 -0
- package/dist/tools/report/index.js +14 -0
- package/dist/tools/report/mint-preview-url.d.ts +26 -0
- package/dist/tools/report/mint-preview-url.js +44 -0
- package/dist/tools/report/preview-publisher.d.ts +37 -0
- package/dist/tools/report/preview-publisher.js +25 -0
- package/dist/tools/report/preview-snapshot.d.ts +26 -0
- package/dist/tools/report/preview-snapshot.js +121 -0
- package/dist/tools/report/submit-report.d.ts +25 -0
- package/dist/tools/report/submit-report.js +126 -0
- package/dist/tools/report/version-fs.d.ts +15 -0
- package/dist/tools/report/version-fs.js +154 -0
- package/dist/tools/research/context7-docs.d.ts +31 -0
- package/dist/tools/research/context7-docs.js +61 -0
- package/dist/tools/research/generate-analogy-report.d.ts +60 -0
- package/dist/tools/research/generate-analogy-report.js +288 -0
- package/dist/tools/research/generate-plan.d.ts +39 -0
- package/dist/tools/research/generate-plan.js +393 -0
- package/dist/tools/research/index.d.ts +15 -0
- package/dist/tools/research/index.js +15 -0
- package/dist/tools/research/inspect-run.d.ts +54 -0
- package/dist/tools/research/inspect-run.js +85 -0
- package/dist/tools/research/literature-reviewer.d.ts +29 -0
- package/dist/tools/research/literature-reviewer.js +84 -0
- package/dist/tools/research/search-arxiv.d.ts +32 -0
- package/dist/tools/research/search-arxiv.js +123 -0
- package/dist/tools/research/search-github-repos.d.ts +32 -0
- package/dist/tools/research/search-github-repos.js +86 -0
- package/dist/tools/research/search-semantic-scholar.d.ts +33 -0
- package/dist/tools/research/search-semantic-scholar.js +93 -0
- package/dist/tools/run-ephemeral.d.ts +33 -0
- package/dist/tools/run-ephemeral.js +65 -0
- package/dist/tools/sandbox/index.d.ts +7 -0
- package/dist/tools/sandbox/index.js +7 -0
- package/dist/tools/sandbox/list-available-packages.d.ts +7 -0
- package/dist/tools/sandbox/list-available-packages.js +27 -0
- package/dist/tools/sandbox/list-available-refs.d.ts +7 -0
- package/dist/tools/sandbox/list-available-refs.js +147 -0
- package/dist/tools/sandbox/report-blocker.d.ts +23 -0
- package/dist/tools/sandbox/report-blocker.js +39 -0
- package/dist/tools/sandbox/skills.d.ts +72 -0
- package/dist/tools/sandbox/skills.js +144 -0
- package/dist/tools/workspace/edit-file.d.ts +46 -0
- package/dist/tools/workspace/edit-file.js +100 -0
- package/dist/tools/workspace/execute-command.d.ts +80 -0
- package/dist/tools/workspace/execute-command.js +95 -0
- package/dist/tools/workspace/file-stat.d.ts +24 -0
- package/dist/tools/workspace/file-stat.js +37 -0
- package/dist/tools/workspace/grep.d.ts +57 -0
- package/dist/tools/workspace/grep.js +154 -0
- package/dist/tools/workspace/index.d.ts +26 -0
- package/dist/tools/workspace/index.js +27 -0
- package/dist/tools/workspace/list-files.d.ts +24 -0
- package/dist/tools/workspace/list-files.js +38 -0
- package/dist/tools/workspace/mutator.d.ts +83 -0
- package/dist/tools/workspace/mutator.js +81 -0
- package/dist/tools/workspace/read-file.d.ts +39 -0
- package/dist/tools/workspace/read-file.js +93 -0
- package/dist/tools/workspace/result-bounds.d.ts +42 -0
- package/dist/tools/workspace/result-bounds.js +50 -0
- package/dist/tools/workspace/run-exec.d.ts +32 -0
- package/dist/tools/workspace/run-exec.js +34 -0
- package/dist/tools/workspace/show-file.d.ts +37 -0
- package/dist/tools/workspace/show-file.js +54 -0
- package/dist/tools/workspace/show-plan.d.ts +23 -0
- package/dist/tools/workspace/show-plan.js +44 -0
- package/dist/tools/workspace/workspace-search.d.ts +25 -0
- package/dist/tools/workspace/workspace-search.js +78 -0
- package/dist/tools/workspace/write-file.d.ts +16 -0
- package/dist/tools/workspace/write-file.js +33 -0
- package/dist/workflows/execute-analysis-scheduler.d.ts +94 -0
- package/dist/workflows/execute-analysis-scheduler.js +186 -0
- package/dist/workflows/execute-analysis.d.ts +271 -0
- package/dist/workflows/execute-analysis.js +746 -0
- package/dist/workflows/execute-target-assessment.d.ts +101 -0
- package/dist/workflows/execute-target-assessment.js +528 -0
- package/dist/workflows/metrics.d.ts +37 -0
- package/dist/workflows/metrics.js +55 -0
- package/dist/workflows/plan/level.d.ts +12 -0
- package/dist/workflows/plan/level.js +12 -0
- package/dist/workflows/register-workflows.d.ts +51 -0
- package/dist/workflows/register-workflows.js +48 -0
- package/dist/workflows/resume-execute-analysis.d.ts +70 -0
- package/dist/workflows/resume-execute-analysis.js +80 -0
- package/dist/workflows/sandbox-step.d.ts +243 -0
- package/dist/workflows/sandbox-step.js +573 -0
- package/dist/workflows/target-assessment/assemblers/index.d.ts +5 -0
- package/dist/workflows/target-assessment/assemblers/index.js +4 -0
- package/dist/workflows/target-assessment/assemblers/literature.d.ts +299 -0
- package/dist/workflows/target-assessment/assemblers/literature.js +987 -0
- package/dist/workflows/target-assessment/assemblers/orchestrator.d.ts +109 -0
- package/dist/workflows/target-assessment/assemblers/orchestrator.js +835 -0
- package/dist/workflows/target-assessment/assemblers/safety.d.ts +352 -0
- package/dist/workflows/target-assessment/assemblers/safety.js +985 -0
- package/dist/workflows/target-assessment/assemblers/trials.d.ts +30 -0
- package/dist/workflows/target-assessment/assemblers/trials.js +75 -0
- package/dist/workflows/target-assessment/collectors/index.d.ts +105 -0
- package/dist/workflows/target-assessment/collectors/index.js +468 -0
- package/dist/workflows/target-assessment/correction-loop.d.ts +45 -0
- package/dist/workflows/target-assessment/correction-loop.js +62 -0
- package/dist/workflows/target-assessment/coverage.d.ts +81 -0
- package/dist/workflows/target-assessment/coverage.js +82 -0
- package/dist/workflows/target-assessment/decisions/index.d.ts +86 -0
- package/dist/workflows/target-assessment/decisions/index.js +127 -0
- package/dist/workflows/target-assessment/fanout/index.d.ts +31 -0
- package/dist/workflows/target-assessment/fanout/index.js +155 -0
- package/dist/workflows/target-assessment/lib/approval-precedents.d.ts +52 -0
- package/dist/workflows/target-assessment/lib/approval-precedents.js +119 -0
- package/dist/workflows/target-assessment/lib/citation-validator.d.ts +46 -0
- package/dist/workflows/target-assessment/lib/citation-validator.js +316 -0
- package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.d.ts +62 -0
- package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.js +172 -0
- package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.d.ts +45 -0
- package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.js +156 -0
- package/dist/workflows/target-assessment/lib/compute-derived.d.ts +19 -0
- package/dist/workflows/target-assessment/lib/compute-derived.js +252 -0
- package/dist/workflows/target-assessment/lib/compute-selectivity.d.ts +15 -0
- package/dist/workflows/target-assessment/lib/compute-selectivity.js +18 -0
- package/dist/workflows/target-assessment/lib/dedup-modulators.d.ts +37 -0
- package/dist/workflows/target-assessment/lib/dedup-modulators.js +157 -0
- package/dist/workflows/target-assessment/lib/evidence-conflict-detector.d.ts +17 -0
- package/dist/workflows/target-assessment/lib/evidence-conflict-detector.js +100 -0
- package/dist/workflows/target-assessment/lib/expression-constants.d.ts +21 -0
- package/dist/workflows/target-assessment/lib/expression-constants.js +21 -0
- package/dist/workflows/target-assessment/lib/family-complex-supplement.d.ts +21 -0
- package/dist/workflows/target-assessment/lib/family-complex-supplement.js +37 -0
- package/dist/workflows/target-assessment/lib/heterodimer-filter.d.ts +39 -0
- package/dist/workflows/target-assessment/lib/heterodimer-filter.js +54 -0
- package/dist/workflows/target-assessment/lib/intended-polypharm-filter.d.ts +4 -0
- package/dist/workflows/target-assessment/lib/intended-polypharm-filter.js +24 -0
- package/dist/workflows/target-assessment/lib/llm-step.d.ts +77 -0
- package/dist/workflows/target-assessment/lib/llm-step.js +99 -0
- package/dist/workflows/target-assessment/lib/meddra-organ-map.d.ts +30 -0
- package/dist/workflows/target-assessment/lib/meddra-organ-map.js +126 -0
- package/dist/workflows/target-assessment/lib/recommendation-quality-gates.d.ts +17 -0
- package/dist/workflows/target-assessment/lib/recommendation-quality-gates.js +99 -0
- package/dist/workflows/target-assessment/lib/recommendation-sanitizer.d.ts +2 -0
- package/dist/workflows/target-assessment/lib/recommendation-sanitizer.js +51 -0
- package/dist/workflows/target-assessment/lib/regulatory-actions.d.ts +26 -0
- package/dist/workflows/target-assessment/lib/regulatory-actions.js +147 -0
- package/dist/workflows/target-assessment/lib/structured-llm.d.ts +58 -0
- package/dist/workflows/target-assessment/lib/structured-llm.js +101 -0
- package/dist/workflows/target-assessment/lib/target-identity-filter.d.ts +60 -0
- package/dist/workflows/target-assessment/lib/target-identity-filter.js +86 -0
- package/dist/workflows/target-assessment/lib/therapeutic-programs.d.ts +20 -0
- package/dist/workflows/target-assessment/lib/therapeutic-programs.js +68 -0
- package/dist/workflows/target-assessment/metrics.d.ts +21 -0
- package/dist/workflows/target-assessment/metrics.js +42 -0
- package/dist/workflows/target-assessment/phase4-assemble.d.ts +1841 -0
- package/dist/workflows/target-assessment/phase4-assemble.js +39 -0
- package/dist/workflows/target-assessment/phase5-persist.d.ts +57 -0
- package/dist/workflows/target-assessment/phase5-persist.js +461 -0
- package/dist/workflows/target-assessment/progress.d.ts +38 -0
- package/dist/workflows/target-assessment/progress.js +76 -0
- package/dist/workflows/target-assessment/schemas.d.ts +931 -0
- package/dist/workflows/target-assessment/schemas.js +293 -0
- package/dist/workflows/target-assessment/steps/collectors/pathways.d.ts +15 -0
- package/dist/workflows/target-assessment/steps/collectors/pathways.js +58 -0
- package/dist/workflows/target-assessment/steps/fanout/aes-for-one-class-drug-step.d.ts +34 -0
- package/dist/workflows/target-assessment/steps/fanout/aes-for-one-class-drug-step.js +31 -0
- package/dist/workflows/target-assessment/steps/fanout/aes-for-one-trial-step.d.ts +57 -0
- package/dist/workflows/target-assessment/steps/fanout/aes-for-one-trial-step.js +54 -0
- package/dist/workflows/target-assessment/steps/fanout/faers-for-one-modulator-step.d.ts +35 -0
- package/dist/workflows/target-assessment/steps/fanout/faers-for-one-modulator-step.js +32 -0
- package/dist/workflows/target-assessment/steps/fanout/index.d.ts +14 -0
- package/dist/workflows/target-assessment/steps/fanout/index.js +10 -0
- package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.d.ts +28 -0
- package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.js +27 -0
- package/dist/workflows/target-assessment/steps/phase0-resolve.d.ts +71 -0
- package/dist/workflows/target-assessment/steps/phase0-resolve.js +21 -0
- package/dist/workflows/target-assessment/steps/phase1-aggregate.d.ts +1018 -0
- package/dist/workflows/target-assessment/steps/phase1-aggregate.js +25 -0
- package/dist/workflows/target-assessment/steps/phase2-aggregate.d.ts +696 -0
- package/dist/workflows/target-assessment/steps/phase2-aggregate.js +38 -0
- package/dist/workflows/target-assessment/steps/phase3-aggregate.d.ts +936 -0
- package/dist/workflows/target-assessment/steps/phase3-aggregate.js +22 -0
- package/dist/workflows/target-assessment/steps/synthesis/diagnostics.d.ts +34 -0
- package/dist/workflows/target-assessment/steps/synthesis/diagnostics.js +45 -0
- package/dist/workflows/target-assessment/sub-workflows/index.d.ts +15 -0
- package/dist/workflows/target-assessment/sub-workflows/index.js +11 -0
- package/dist/workflows/target-assessment/sub-workflows/per-class-drug-aes.d.ts +41 -0
- package/dist/workflows/target-assessment/sub-workflows/per-class-drug-aes.js +12 -0
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-faers.d.ts +41 -0
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-faers.js +12 -0
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-polypharm.d.ts +36 -0
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-polypharm.js +12 -0
- package/dist/workflows/target-assessment/sub-workflows/per-trial-aes.d.ts +66 -0
- package/dist/workflows/target-assessment/sub-workflows/per-trial-aes.js +12 -0
- package/dist/workflows/target-assessment/synthesis/index.d.ts +560 -0
- package/dist/workflows/target-assessment/synthesis/index.js +351 -0
- package/dist/workflows/target-assessment/synthesis-probes.d.ts +56 -0
- package/dist/workflows/target-assessment/synthesis-probes.js +320 -0
- package/dist/workspace/filesystem.d.ts +117 -0
- package/dist/workspace/filesystem.js +304 -0
- package/dist/workspace/mount-strategy.d.ts +50 -0
- package/dist/workspace/mount-strategy.js +67 -0
- package/dist/workspace/paths.d.ts +185 -0
- package/dist/workspace/paths.js +219 -0
- package/dist/workspace/provenance-collector.d.ts +34 -0
- package/dist/workspace/provenance-collector.js +16 -0
- package/dist/workspace/search-config.d.ts +23 -0
- package/dist/workspace/search-config.js +43 -0
- package/dist/workspace/workspace-paths.d.ts +26 -0
- package/dist/workspace/workspace-paths.js +31 -0
- package/package.json +101 -0
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The harness tool primitive.
|
|
3
|
+
*
|
|
4
|
+
* `defineTool` packages a `Tool` and emits its AI SDK input schema
|
|
5
|
+
* from the Zod `inputSchema` via Zod 4's native `z.toJSONSchema()`. It is
|
|
6
|
+
* dependency-agnostic (see the harness-durable-runtime spec): a pure tool is a module-scope
|
|
7
|
+
* `defineTool(...)`; a dependency-bearing tool is a factory closure that
|
|
8
|
+
* captures its deps and calls `defineTool`.
|
|
9
|
+
*
|
|
10
|
+
* `ToolContext` carries exactly the four request-scoped values every tool
|
|
11
|
+
* may need — no pool, no sandbox, no logger. The error contract: an expected
|
|
12
|
+
* outcome ("not found", "no results") stays in the ok channel as a data
|
|
13
|
+
* variant (`ok({ found: false })`); an unexpected failure is an `err(ToolError)`
|
|
14
|
+
* or a throw. The loop (`dispatchTool`) owns the `is_error` envelope — it maps
|
|
15
|
+
* both `err` and a thrown error to one `tool_result { is_error: true }`.
|
|
16
|
+
*/
|
|
17
|
+
import type { Result } from "neverthrow";
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
import type { AgentSession } from "../auth/types.js";
|
|
20
|
+
import type { EmitFn, RunStep } from "../loop/types.js";
|
|
21
|
+
export type { EmitFn };
|
|
22
|
+
/**
|
|
23
|
+
* The error channel of a tool's `Result`. `error` is the message surfaced to
|
|
24
|
+
* the model in the `is_error` `tool_result`; `retryable` tells it whether
|
|
25
|
+
* re-issuing the call could plausibly succeed; `cause` keeps the underlying
|
|
26
|
+
* value for classification if the error is later rethrown. A tool rarely
|
|
27
|
+
* builds one by hand — most failures stay thrown and the loop's backstop
|
|
28
|
+
* derives the same shape via `classifyProviderError`.
|
|
29
|
+
*/
|
|
30
|
+
export interface ToolError {
|
|
31
|
+
readonly error: string;
|
|
32
|
+
readonly retryable: boolean;
|
|
33
|
+
readonly cause?: unknown;
|
|
34
|
+
}
|
|
35
|
+
export type ToolExecutionMode = "step" | "workflow" | "inline";
|
|
36
|
+
/** Runtime guard — does a `Result`'s error value carry the `ToolError` shape? */
|
|
37
|
+
export declare function isToolError(value: unknown): value is ToolError;
|
|
38
|
+
/**
|
|
39
|
+
* The request-scoped values passed to every tool's `execute`. No injected
|
|
40
|
+
* dependencies (see the harness-durable-runtime spec) — `session`, `signal`, `emit`, plus the `runStep`
|
|
41
|
+
* durability seam (`passthroughStep` in chat, `DBOS.runStep` in workflows)
|
|
42
|
+
* a tool uses to wrap its own durable work.
|
|
43
|
+
*/
|
|
44
|
+
export interface ToolContext {
|
|
45
|
+
readonly session: AgentSession;
|
|
46
|
+
readonly signal: AbortSignal;
|
|
47
|
+
readonly emit: EmitFn;
|
|
48
|
+
/**
|
|
49
|
+
* Wrap durable work in a replay-cached step. The loop namespaces the name
|
|
50
|
+
* under the tool's own step name, so a tool just passes a short local label.
|
|
51
|
+
*/
|
|
52
|
+
readonly runStep: RunStep;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A packaged tool: identity, the Zod input contract, the emitted AI SDK input
|
|
56
|
+
* schema, execution mode, and the executor.
|
|
57
|
+
*/
|
|
58
|
+
export interface Tool<Input = unknown, Output = unknown> {
|
|
59
|
+
readonly id: string;
|
|
60
|
+
readonly description: string;
|
|
61
|
+
readonly inputSchema: z.ZodType;
|
|
62
|
+
readonly jsonSchema: Record<string, unknown>;
|
|
63
|
+
readonly executionMode: ToolExecutionMode;
|
|
64
|
+
execute(input: Input, ctx: ToolContext): Promise<Result<Output, ToolError>>;
|
|
65
|
+
}
|
|
66
|
+
export interface ToolDefinition<Schema extends z.ZodType, Output> {
|
|
67
|
+
readonly id: string;
|
|
68
|
+
readonly description: string;
|
|
69
|
+
readonly inputSchema: Schema;
|
|
70
|
+
readonly executionMode?: ToolExecutionMode;
|
|
71
|
+
execute(input: z.infer<Schema>, ctx: ToolContext): Promise<Result<Output, ToolError>>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Package a `Tool`. The emitted JSON Schema must have a top-level
|
|
75
|
+
* `"type": "object"` — model tool calling rejects anything else. A `z.discriminatedUnion`
|
|
76
|
+
* emits a top-level `oneOf`; this throws at construction (fail fast — not at
|
|
77
|
+
* the first LLM call). Union-shaped inputs must be modelled as a flat object
|
|
78
|
+
* with a discriminator field.
|
|
79
|
+
*/
|
|
80
|
+
export declare function defineTool<Schema extends z.ZodType, Output>(def: ToolDefinition<Schema, Output>): Tool<z.infer<Schema>, Output>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The harness tool primitive.
|
|
3
|
+
*
|
|
4
|
+
* `defineTool` packages a `Tool` and emits its AI SDK input schema
|
|
5
|
+
* from the Zod `inputSchema` via Zod 4's native `z.toJSONSchema()`. It is
|
|
6
|
+
* dependency-agnostic (see the harness-durable-runtime spec): a pure tool is a module-scope
|
|
7
|
+
* `defineTool(...)`; a dependency-bearing tool is a factory closure that
|
|
8
|
+
* captures its deps and calls `defineTool`.
|
|
9
|
+
*
|
|
10
|
+
* `ToolContext` carries exactly the four request-scoped values every tool
|
|
11
|
+
* may need — no pool, no sandbox, no logger. The error contract: an expected
|
|
12
|
+
* outcome ("not found", "no results") stays in the ok channel as a data
|
|
13
|
+
* variant (`ok({ found: false })`); an unexpected failure is an `err(ToolError)`
|
|
14
|
+
* or a throw. The loop (`dispatchTool`) owns the `is_error` envelope — it maps
|
|
15
|
+
* both `err` and a thrown error to one `tool_result { is_error: true }`.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from "zod";
|
|
18
|
+
/** Runtime guard — does a `Result`'s error value carry the `ToolError` shape? */
|
|
19
|
+
export function isToolError(value) {
|
|
20
|
+
return typeof value === "object" && value !== null && typeof value.error === "string" && typeof value.retryable === "boolean";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Package a `Tool`. The emitted JSON Schema must have a top-level
|
|
24
|
+
* `"type": "object"` — model tool calling rejects anything else. A `z.discriminatedUnion`
|
|
25
|
+
* emits a top-level `oneOf`; this throws at construction (fail fast — not at
|
|
26
|
+
* the first LLM call). Union-shaped inputs must be modelled as a flat object
|
|
27
|
+
* with a discriminator field.
|
|
28
|
+
*/
|
|
29
|
+
export function defineTool(def) {
|
|
30
|
+
const jsonSchema = z.toJSONSchema(def.inputSchema);
|
|
31
|
+
delete jsonSchema.$schema;
|
|
32
|
+
if (jsonSchema.type !== "object") {
|
|
33
|
+
throw new Error(`defineTool("${def.id}"): inputSchema must emit a top-level JSON Schema ` +
|
|
34
|
+
`'"type":"object"', got ${JSON.stringify(jsonSchema.type)}. ` +
|
|
35
|
+
`Union-shaped inputs (z.discriminatedUnion) emit "oneOf" with no ` +
|
|
36
|
+
`top-level "type" — model the input as a flat object with a ` +
|
|
37
|
+
`discriminator field instead.`);
|
|
38
|
+
}
|
|
39
|
+
const executionMode = def.executionMode ?? "step";
|
|
40
|
+
return {
|
|
41
|
+
id: def.id,
|
|
42
|
+
description: def.description,
|
|
43
|
+
inputSchema: def.inputSchema,
|
|
44
|
+
jsonSchema,
|
|
45
|
+
executionMode,
|
|
46
|
+
execute: def.execute,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* showUser tool — emits agent-synthesized content as a UI stream event.
|
|
3
|
+
*
|
|
4
|
+
* For content the agent is INVENTING — charts, markdown, code snippets,
|
|
5
|
+
* SVG diagrams, tables. Content is serialized inline (bytes on the wire).
|
|
6
|
+
*
|
|
7
|
+
* The presentation `id` is derived deterministically from the content, so
|
|
8
|
+
* an identical re-emission carries the same id — duplicate suppression is a
|
|
9
|
+
* downstream reconciliation concern of the emit pipeline (change 3), not a
|
|
10
|
+
* per-request `Set` smuggled through an ambient context bag.
|
|
11
|
+
*
|
|
12
|
+
* For stored plans, use `show_plan`. For existing files, use `show_file`.
|
|
13
|
+
*/
|
|
14
|
+
type ShowUserOutput = {
|
|
15
|
+
shown: false;
|
|
16
|
+
reason: "invalid_path";
|
|
17
|
+
} | {
|
|
18
|
+
id: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const showUserTool: import("../define-tool.js").Tool<{
|
|
21
|
+
kind: "code" | "echart" | "markdown" | "svg" | "table";
|
|
22
|
+
title?: string | undefined;
|
|
23
|
+
spec?: Record<string, unknown> | undefined;
|
|
24
|
+
dataPath?: string | undefined;
|
|
25
|
+
body?: string | undefined;
|
|
26
|
+
code?: string | undefined;
|
|
27
|
+
language?: string | undefined;
|
|
28
|
+
markup?: string | undefined;
|
|
29
|
+
headers?: string[] | undefined;
|
|
30
|
+
rows?: string[][] | undefined;
|
|
31
|
+
caption?: string | undefined;
|
|
32
|
+
}, ShowUserOutput>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* showUser tool — emits agent-synthesized content as a UI stream event.
|
|
3
|
+
*
|
|
4
|
+
* For content the agent is INVENTING — charts, markdown, code snippets,
|
|
5
|
+
* SVG diagrams, tables. Content is serialized inline (bytes on the wire).
|
|
6
|
+
*
|
|
7
|
+
* The presentation `id` is derived deterministically from the content, so
|
|
8
|
+
* an identical re-emission carries the same id — duplicate suppression is a
|
|
9
|
+
* downstream reconciliation concern of the emit pipeline (change 3), not a
|
|
10
|
+
* per-request `Set` smuggled through an ambient context bag.
|
|
11
|
+
*
|
|
12
|
+
* For stored plans, use `show_plan`. For existing files, use `show_file`.
|
|
13
|
+
*/
|
|
14
|
+
import { ok } from "neverthrow";
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import { buildPresentationCardData } from "../../memory/card-builders.js";
|
|
17
|
+
import { defineTool } from "../define-tool.js";
|
|
18
|
+
import { validatePath } from "../lib/path-validation.js";
|
|
19
|
+
// Flat object schema — Anthropic requires top-level "type": "object" in tool
|
|
20
|
+
// input_schema. A z.discriminatedUnion produces a top-level "oneOf" without
|
|
21
|
+
// "type", which the API rejects. Variant-specific fields are optional; the
|
|
22
|
+
// LLM picks the right ones based on `kind`.
|
|
23
|
+
const ShowUserInputSchema = z.object({
|
|
24
|
+
kind: z.enum(["echart", "markdown", "code", "svg", "table"]).describe("The type of agent-synthesized content to display"),
|
|
25
|
+
title: z.string().optional().describe("Title shown above the content"),
|
|
26
|
+
spec: z.record(z.string(), z.unknown()).optional().describe("Full ECharts option spec as JSON (kind=echart)"),
|
|
27
|
+
dataPath: z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("echart only: analysis-rooted CSV artifact path (e.g. 'runs/run-abc/step-2/output/de-summary.csv') the host loads as the ECharts `dataset.source` at render time. Author `encode`/dimensions against the CSV's column names and omit `dataset.source` from the spec — the data is never pulled through the context window."),
|
|
31
|
+
body: z.string().optional().describe("Markdown content to render (kind=markdown)"),
|
|
32
|
+
code: z.string().optional().describe("Code content (kind=code)"),
|
|
33
|
+
language: z.string().optional().describe("Language identifier, e.g. r, python, bash (kind=code)"),
|
|
34
|
+
markup: z.string().optional().describe("SVG markup string (kind=svg)"),
|
|
35
|
+
headers: z.array(z.string()).optional().describe("Column headers (kind=table)"),
|
|
36
|
+
rows: z.array(z.array(z.string())).optional().describe("Row data as array of string arrays (kind=table)"),
|
|
37
|
+
caption: z.string().optional().describe("Caption (kind=table)"),
|
|
38
|
+
});
|
|
39
|
+
export const showUserTool = defineTool({
|
|
40
|
+
id: "show_user",
|
|
41
|
+
description: "Display agent-synthesized content to the user: ECharts visualizations, " +
|
|
42
|
+
"markdown, code blocks, SVG diagrams, or tables. " +
|
|
43
|
+
"Use for content you are INVENTING (a chart you just built, a code snippet you are proposing, " +
|
|
44
|
+
"a markdown synthesis, a table you constructed). " +
|
|
45
|
+
"For an echart backed by a chart-ready CSV artifact a step already wrote, pass `dataPath` (analysis-rooted) " +
|
|
46
|
+
"and author `encode`/dimensions by column name with no `dataset.source` — the host loads the CSV as the " +
|
|
47
|
+
"dataset at render time, so you never inline the rows. " +
|
|
48
|
+
"For stored plans, use `show_plan`. For existing analysis files (images, CSVs, etc.), use `show_file`. " +
|
|
49
|
+
"Call once per distinct content item; an identical repeat call resolves to the same card.",
|
|
50
|
+
inputSchema: ShowUserInputSchema,
|
|
51
|
+
execute: async (input, ctx) => {
|
|
52
|
+
// `dataPath` is a reference the host resolves at render time; validate its
|
|
53
|
+
// shape only (existence is a render-time host concern), and treat a
|
|
54
|
+
// malformed path as an expected outcome the model can self-correct.
|
|
55
|
+
if (typeof input.dataPath === "string" && validatePath(input.dataPath) !== null) {
|
|
56
|
+
return ok({ shown: false, reason: "invalid_path" });
|
|
57
|
+
}
|
|
58
|
+
// Non-null: the input passed Zod validation, so `kind` is present.
|
|
59
|
+
const card = buildPresentationCardData(input);
|
|
60
|
+
await ctx.emit({
|
|
61
|
+
type: "data-presentation",
|
|
62
|
+
source: ctx.session.provenance,
|
|
63
|
+
data: card,
|
|
64
|
+
});
|
|
65
|
+
return ok({ id: card.id });
|
|
66
|
+
},
|
|
67
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* executePlan — launch the DBOS `executeAnalysis` parent workflow for an
|
|
3
|
+
* approved plan.
|
|
4
|
+
*
|
|
5
|
+
* Results are pull-only: the tool does NOT register a `.then(saveRunResult)`
|
|
6
|
+
* or any completion callback that writes to the conversation thread. The
|
|
7
|
+
* conversation agent retrieves run results via `inspectRun` on a later turn.
|
|
8
|
+
*
|
|
9
|
+
* Authorization contract: the tool runs in the chat HTTP route, so its session
|
|
10
|
+
* carries the live auth. It authorizes through the injected `RunAuthorizer`
|
|
11
|
+
* seam and never reads a credential. The flow is dedup → reserve → authorize
|
|
12
|
+
* → startWorkflow:
|
|
13
|
+
*
|
|
14
|
+
* 1. Dedup pre-check via `queryActiveRun`. On hit, return the existing
|
|
15
|
+
* `runId` with no authorization and no `startWorkflow`.
|
|
16
|
+
* 2. Reserve the slot: `insertRun` the `cortex_runs` row (`runId =
|
|
17
|
+
* randomUUID()`, the bare UUID that IS the DBOS workflowID) BEFORE
|
|
18
|
+
* authorizing. The partial-unique index is the race backstop; the loser
|
|
19
|
+
* returns the winner's `runId` without authorizing — nothing to revoke.
|
|
20
|
+
* 3. `runAuthorizer.authorize({ ..., frame: { runId } })` — authorizes the
|
|
21
|
+
* run; the authorizer's persisted handle now lands because the row
|
|
22
|
+
* exists. On failure, mark the reserved row `failed` (releasing the dedup
|
|
23
|
+
* slot for a retry) and rethrow.
|
|
24
|
+
* 4. `runLauncher.launch(executeAnalysis, { workflowId: runId }, ...)`,
|
|
25
|
+
* passing the `RunSession` in the workflow input. On failure, revoke + mark
|
|
26
|
+
* failed.
|
|
27
|
+
*/
|
|
28
|
+
import type { Pool } from "pg";
|
|
29
|
+
import type { ResourcePolicy } from "../config/resource-limits.js";
|
|
30
|
+
import type { RunAuthorizer } from "../execution/run-authorizer.js";
|
|
31
|
+
import type { RunLauncher } from "../execution/run-launcher.js";
|
|
32
|
+
import type { ExecuteAnalysisInput, ExecuteAnalysisResult } from "../workflows/execute-analysis.js";
|
|
33
|
+
type ExecuteAnalysisWorkflow = (input: ExecuteAnalysisInput) => Promise<ExecuteAnalysisResult>;
|
|
34
|
+
export interface ExecutePlanToolDeps {
|
|
35
|
+
readonly pool: Pool;
|
|
36
|
+
/** Registered `executeAnalysis` workflow callable — produced by `registerExecuteAnalysis` (wired by `assembleCoreRuntime`). */
|
|
37
|
+
readonly executeAnalysisWorkflow: ExecuteAnalysisWorkflow;
|
|
38
|
+
/** Authorizes the run at the async edge and revokes on the abort paths. */
|
|
39
|
+
readonly runAuthorizer: RunAuthorizer;
|
|
40
|
+
/** Starts the durable run — the durability engine stays behind this seam. */
|
|
41
|
+
readonly runLauncher: RunLauncher;
|
|
42
|
+
/**
|
|
43
|
+
* Host resource policy. The machine budget is snapshotted into the workflow
|
|
44
|
+
* input here at the async edge — the workflow body never reads live config,
|
|
45
|
+
* so a mid-run config edit cannot change a running run's admission decisions.
|
|
46
|
+
*/
|
|
47
|
+
readonly resourcePolicy?: ResourcePolicy;
|
|
48
|
+
}
|
|
49
|
+
export declare class PlanNotFoundError extends Error {
|
|
50
|
+
constructor(planId: string);
|
|
51
|
+
}
|
|
52
|
+
export declare class PlanMalformedError extends Error {
|
|
53
|
+
constructor(planId: string);
|
|
54
|
+
}
|
|
55
|
+
export declare class PlanValidationError extends Error {
|
|
56
|
+
readonly errors: string[];
|
|
57
|
+
constructor(planId: string, errors: string[]);
|
|
58
|
+
}
|
|
59
|
+
export declare function createExecutePlanTool(deps: ExecutePlanToolDeps): import("./define-tool.js").Tool<{
|
|
60
|
+
planId: string;
|
|
61
|
+
}, {
|
|
62
|
+
runId: string;
|
|
63
|
+
}>;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* executePlan — launch the DBOS `executeAnalysis` parent workflow for an
|
|
3
|
+
* approved plan.
|
|
4
|
+
*
|
|
5
|
+
* Results are pull-only: the tool does NOT register a `.then(saveRunResult)`
|
|
6
|
+
* or any completion callback that writes to the conversation thread. The
|
|
7
|
+
* conversation agent retrieves run results via `inspectRun` on a later turn.
|
|
8
|
+
*
|
|
9
|
+
* Authorization contract: the tool runs in the chat HTTP route, so its session
|
|
10
|
+
* carries the live auth. It authorizes through the injected `RunAuthorizer`
|
|
11
|
+
* seam and never reads a credential. The flow is dedup → reserve → authorize
|
|
12
|
+
* → startWorkflow:
|
|
13
|
+
*
|
|
14
|
+
* 1. Dedup pre-check via `queryActiveRun`. On hit, return the existing
|
|
15
|
+
* `runId` with no authorization and no `startWorkflow`.
|
|
16
|
+
* 2. Reserve the slot: `insertRun` the `cortex_runs` row (`runId =
|
|
17
|
+
* randomUUID()`, the bare UUID that IS the DBOS workflowID) BEFORE
|
|
18
|
+
* authorizing. The partial-unique index is the race backstop; the loser
|
|
19
|
+
* returns the winner's `runId` without authorizing — nothing to revoke.
|
|
20
|
+
* 3. `runAuthorizer.authorize({ ..., frame: { runId } })` — authorizes the
|
|
21
|
+
* run; the authorizer's persisted handle now lands because the row
|
|
22
|
+
* exists. On failure, mark the reserved row `failed` (releasing the dedup
|
|
23
|
+
* slot for a retry) and rethrow.
|
|
24
|
+
* 4. `runLauncher.launch(executeAnalysis, { workflowId: runId }, ...)`,
|
|
25
|
+
* passing the `RunSession` in the workflow input. On failure, revoke + mark
|
|
26
|
+
* failed.
|
|
27
|
+
*/
|
|
28
|
+
import { randomUUID } from "node:crypto";
|
|
29
|
+
import { ok } from "neverthrow";
|
|
30
|
+
import { z } from "zod";
|
|
31
|
+
import { buildRunCardData } from "../memory/card-builders.js";
|
|
32
|
+
import { unwrapOrThrow } from "../lib/result.js";
|
|
33
|
+
import { validatePlan } from "../schemas/validate-plan.js";
|
|
34
|
+
import { AnalysisPlanSchema } from "../schemas/workflow-state.js";
|
|
35
|
+
import { renderStepPrompt } from "../schemas/render-step-prompt.js";
|
|
36
|
+
import { RunDedupCollisionError, insertRun, loadPlan, queryActiveRun, updateRunStatus } from "../state/index.js";
|
|
37
|
+
import { defineTool } from "./define-tool.js";
|
|
38
|
+
const planIdSchema = z.string().regex(/^pln-[a-f0-9]{8}$/, "planId must be a pln-<8hex> value");
|
|
39
|
+
const inputSchema = z.object({
|
|
40
|
+
planId: planIdSchema,
|
|
41
|
+
});
|
|
42
|
+
export class PlanNotFoundError extends Error {
|
|
43
|
+
constructor(planId) {
|
|
44
|
+
super(`Plan ${planId} not found for this analysis`);
|
|
45
|
+
this.name = "PlanNotFoundError";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class PlanMalformedError extends Error {
|
|
49
|
+
constructor(planId) {
|
|
50
|
+
super(`Plan ${planId} is malformed`);
|
|
51
|
+
this.name = "PlanMalformedError";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export class PlanValidationError extends Error {
|
|
55
|
+
errors;
|
|
56
|
+
constructor(planId, errors) {
|
|
57
|
+
super(`Plan ${planId} failed validation: ${errors.length} error(s)`);
|
|
58
|
+
this.errors = errors;
|
|
59
|
+
this.name = "PlanValidationError";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function isDedupCollision(err) {
|
|
63
|
+
return err instanceof RunDedupCollisionError || (err instanceof Error && err.name === "RunDedupCollisionError");
|
|
64
|
+
}
|
|
65
|
+
export function createExecutePlanTool(deps) {
|
|
66
|
+
const { pool, executeAnalysisWorkflow, runAuthorizer, runLauncher, resourcePolicy } = deps;
|
|
67
|
+
return defineTool({
|
|
68
|
+
id: "execute_plan",
|
|
69
|
+
description: "Execute an approved analysis plan by its planId. " +
|
|
70
|
+
"Pass the planId returned from generatePlan — the tool resolves the plan " +
|
|
71
|
+
"server-side, validates the DAG, and starts the executeAnalysis workflow " +
|
|
72
|
+
"asynchronously. Returns the runId on success. " +
|
|
73
|
+
"The user sees a run card in chat (also tracked in the Runs panel); " +
|
|
74
|
+
"run results become available for inspection on a later turn. " +
|
|
75
|
+
"Do not instruct the user to invoke any tool.",
|
|
76
|
+
inputSchema,
|
|
77
|
+
execute: async (input, ctx) => {
|
|
78
|
+
const { planId } = input;
|
|
79
|
+
// Mirror show_plan: emit a live display card so chat renders a run card
|
|
80
|
+
// rather than a generic "used 1 tool" chip. Null (plan/run unresolvable)
|
|
81
|
+
// simply skips the card — the run still starts.
|
|
82
|
+
const emitRunCard = async (analysisId, runId) => {
|
|
83
|
+
const card = await buildRunCardData(pool, {
|
|
84
|
+
planId,
|
|
85
|
+
analysisId,
|
|
86
|
+
runId,
|
|
87
|
+
}).unwrapOr(null);
|
|
88
|
+
if (card) {
|
|
89
|
+
await ctx.emit({
|
|
90
|
+
type: "data-run-card",
|
|
91
|
+
source: ctx.session.provenance,
|
|
92
|
+
data: card,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const { session } = ctx;
|
|
97
|
+
if (session.scope.kind !== "analysis") {
|
|
98
|
+
throw new Error("executePlan can only be invoked on an analysis-scoped session");
|
|
99
|
+
}
|
|
100
|
+
if (!session.auth) {
|
|
101
|
+
throw new Error("executePlan: session is missing its auth capability");
|
|
102
|
+
}
|
|
103
|
+
const analysisId = session.scope.analysisId;
|
|
104
|
+
const threadId = session.scope.threadId ?? null;
|
|
105
|
+
const raw = unwrapOrThrow(await loadPlan(pool, planId, { analysisId }));
|
|
106
|
+
if (!raw)
|
|
107
|
+
throw new PlanNotFoundError(planId);
|
|
108
|
+
const parsed = AnalysisPlanSchema.safeParse(raw);
|
|
109
|
+
if (!parsed.success)
|
|
110
|
+
throw new PlanMalformedError(planId);
|
|
111
|
+
const plan = parsed.data;
|
|
112
|
+
const result = validatePlan(plan);
|
|
113
|
+
if (!result.valid) {
|
|
114
|
+
throw new PlanValidationError(planId, result.errors);
|
|
115
|
+
}
|
|
116
|
+
// (1) Dedup pre-check — common case is the user re-clicked Execute on
|
|
117
|
+
// an in-flight plan. A hit avoids both the authorization and the DBOS
|
|
118
|
+
// startWorkflow.
|
|
119
|
+
const existingPre = unwrapOrThrow(await queryActiveRun(pool, analysisId, planId));
|
|
120
|
+
if (existingPre) {
|
|
121
|
+
await emitRunCard(analysisId, existingPre.runId);
|
|
122
|
+
return ok({ runId: existingPre.runId });
|
|
123
|
+
}
|
|
124
|
+
// (2) Reserve the dedup slot by inserting the run row BEFORE authorizing.
|
|
125
|
+
// The partial-unique index is the race backstop for two callers that both
|
|
126
|
+
// passed the pre-check; the loser returns the winner's runId without
|
|
127
|
+
// having authorized — there is nothing to revoke. The authorization handle is left
|
|
128
|
+
// null here and populated by the authorizer, whose UPDATE lands
|
|
129
|
+
// because the row now exists.
|
|
130
|
+
const runId = randomUUID();
|
|
131
|
+
try {
|
|
132
|
+
// On the dedup collision `insertRun` throws `RunDedupCollisionError`
|
|
133
|
+
// (a control-flow signal that rides out of the ResultAsync as a
|
|
134
|
+
// rejection) — `unwrapOrThrow` never sees it; the catch below does.
|
|
135
|
+
unwrapOrThrow(await insertRun(pool, {
|
|
136
|
+
runId,
|
|
137
|
+
analysisId,
|
|
138
|
+
threadId,
|
|
139
|
+
workflowName: "executeAnalysis",
|
|
140
|
+
planId,
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
if (isDedupCollision(err)) {
|
|
145
|
+
const existing = unwrapOrThrow(await queryActiveRun(pool, analysisId, planId));
|
|
146
|
+
if (existing) {
|
|
147
|
+
await emitRunCard(analysisId, existing.runId);
|
|
148
|
+
return ok({ runId: existing.runId });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
throw err;
|
|
152
|
+
}
|
|
153
|
+
// (3) Authorize the run. The row exists, so the authorizer's persisted handle
|
|
154
|
+
// persists. On failure, mark the reserved row failed — releasing the
|
|
155
|
+
// partial-unique slot so a retry can re-run — and rethrow.
|
|
156
|
+
let authorization;
|
|
157
|
+
try {
|
|
158
|
+
authorization = await runAuthorizer.authorize({
|
|
159
|
+
auth: session.auth,
|
|
160
|
+
scope: session.scope,
|
|
161
|
+
provenance: session.provenance,
|
|
162
|
+
frame: { runId },
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
await updateRunStatus(pool, runId, "failed", "run authorization failed").match(() => { }, () => { });
|
|
167
|
+
throw err;
|
|
168
|
+
}
|
|
169
|
+
const { runSession } = authorization;
|
|
170
|
+
const planSummary = plan.title?.trim() || plan.analytical_narrative.trim().slice(0, 280);
|
|
171
|
+
const workflowInput = {
|
|
172
|
+
analysisId,
|
|
173
|
+
planId,
|
|
174
|
+
planSummary,
|
|
175
|
+
threadId,
|
|
176
|
+
steps: plan.steps.map((s) => ({
|
|
177
|
+
id: s.id,
|
|
178
|
+
depends_on: s.depends_on ?? [],
|
|
179
|
+
})),
|
|
180
|
+
promptByStepId: Object.fromEntries(plan.steps.map((s) => [s.id, renderStepPrompt(s)])),
|
|
181
|
+
agentByStepId: Object.fromEntries(plan.steps.map((s) => [s.id, s.agent ?? "unknown"])),
|
|
182
|
+
resourcesByStepId: Object.fromEntries(plan.steps.map((s) => {
|
|
183
|
+
if (!s.resources) {
|
|
184
|
+
throw new Error(`Step "${s.id}" has no resources — validatePlan should have rejected this plan`);
|
|
185
|
+
}
|
|
186
|
+
return [s.id, s.resources];
|
|
187
|
+
})),
|
|
188
|
+
timeoutByStepId: Object.fromEntries(plan.steps.filter((s) => s.timeout !== undefined).map((s) => [s.id, s.timeout])),
|
|
189
|
+
budget: resourcePolicy?.budget,
|
|
190
|
+
runSession,
|
|
191
|
+
ownsMandate: authorization.ownsMandate, // oss-core-managed-ok
|
|
192
|
+
};
|
|
193
|
+
// (4) Dispatch the workflow. `workflowId = runId` — both are the same
|
|
194
|
+
// bare UUID. On failure after insert + authorize, revoke the authorization and
|
|
195
|
+
// mark the row failed.
|
|
196
|
+
try {
|
|
197
|
+
await runLauncher.launch(executeAnalysisWorkflow, { workflowId: runId }, workflowInput);
|
|
198
|
+
}
|
|
199
|
+
catch (err) {
|
|
200
|
+
await runAuthorizer.revoke(authorization, "workflow-start-failed").catch(() => { });
|
|
201
|
+
await updateRunStatus(pool, runId, "failed", "workflow start failed").match(() => { }, () => { });
|
|
202
|
+
throw err;
|
|
203
|
+
}
|
|
204
|
+
await emitRunCard(analysisId, runId);
|
|
205
|
+
return ok({ runId });
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
}
|