@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,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input sanitization — two pure, always-on functions applied once to the
|
|
3
|
+
* incoming user message by the chat route (change 6). Never applied to
|
|
4
|
+
* assistant messages or tool results.
|
|
5
|
+
*
|
|
6
|
+
* Two pure functions, not a plug-in pipeline. What runs is exactly these two.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* C0/C1 control characters and DEL, excluding `\t` (U+0009) and `\n`
|
|
10
|
+
* (U+000A) which are legitimate whitespace in user prose.
|
|
11
|
+
*/
|
|
12
|
+
// eslint-disable-next-line no-control-regex -- matching control characters is the intent: this pattern strips invisible C0/C1 bytes and DEL from untrusted user input (see `normalizeUnicode` below).
|
|
13
|
+
const CONTROL_CHARS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/g;
|
|
14
|
+
/**
|
|
15
|
+
* NFC-normalize and strip control characters.
|
|
16
|
+
*
|
|
17
|
+
* Unicode normalization collapses visually-identical decomposed sequences
|
|
18
|
+
* to a canonical form; control-char stripping removes invisible C0/C1 bytes
|
|
19
|
+
* that could smuggle formatting or terminal escapes.
|
|
20
|
+
*/
|
|
21
|
+
export function normalizeUnicode(text) {
|
|
22
|
+
return text.normalize("NFC").replace(CONTROL_CHARS, "");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Each entry redacts one structured, prefixed secret format. Every pattern
|
|
26
|
+
* has a prefix (`AKIA`, `sk-`, `gh*_`, `eyJ`, `Bearer`, a DB scheme) that
|
|
27
|
+
* cannot collide with a nucleotide or protein sequence — so none of these
|
|
28
|
+
* false-positive on biological data.
|
|
29
|
+
*
|
|
30
|
+
* The 40-char generic AWS secret pattern and the loose `key:value` "Generic
|
|
31
|
+
* Secret Assignment" pattern are intentionally absent — both are domain-blind
|
|
32
|
+
* and false-positive on nucleotide / protein sequences.
|
|
33
|
+
*
|
|
34
|
+
* Order matters: `sk-ant-` is redacted before the generic `sk-` so the
|
|
35
|
+
* Anthropic label wins; `sk-(?!ant-)` additionally excludes it by lookahead.
|
|
36
|
+
*/
|
|
37
|
+
const SECRET_PATTERNS = [
|
|
38
|
+
{ name: "AWS Access Key", pattern: /\bAKIA[0-9A-Z]{16}\b/g },
|
|
39
|
+
{ name: "Anthropic API Key", pattern: /\bsk-ant-[A-Za-z0-9_-]{20,}\b/g },
|
|
40
|
+
{ name: "OpenAI API Key", pattern: /\bsk-(?!ant-)[A-Za-z0-9_-]{20,}\b/g },
|
|
41
|
+
{ name: "GitHub Token", pattern: /\bgh[psoru]_[A-Za-z0-9_]{36,}\b/g },
|
|
42
|
+
{
|
|
43
|
+
name: "JWT Token",
|
|
44
|
+
pattern: /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,
|
|
45
|
+
},
|
|
46
|
+
{ name: "Bearer Token", pattern: /\bBearer\s+[A-Za-z0-9_\-.~+/]+=*/gi },
|
|
47
|
+
{
|
|
48
|
+
name: "Connection String",
|
|
49
|
+
pattern: /\b(?:postgres|postgresql|mysql|mongodb|redis|amqp|mssql):\/\/[^\s"'`]+/gi,
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
/**
|
|
53
|
+
* Replace structured secret formats with `[REDACTED: <name>]`.
|
|
54
|
+
*
|
|
55
|
+
* Only prefixed formats are matched — a 40-nucleotide `ACGT…` string or a
|
|
56
|
+
* 40-residue protein sequence passes through unchanged.
|
|
57
|
+
*/
|
|
58
|
+
export function redactSecrets(text) {
|
|
59
|
+
let out = text;
|
|
60
|
+
for (const { name, pattern } of SECRET_PATTERNS) {
|
|
61
|
+
out = out.replace(pattern, `[REDACTED: ${name}]`);
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared async utilities — sleep and bounded-concurrency map.
|
|
3
|
+
*/
|
|
4
|
+
/** Promise-based delay. */
|
|
5
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Map over items with bounded concurrency.
|
|
8
|
+
* At most `concurrency` items are processed simultaneously.
|
|
9
|
+
*/
|
|
10
|
+
export declare function mapConcurrent<T, R>(items: T[], concurrency: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared async utilities — sleep and bounded-concurrency map.
|
|
3
|
+
*/
|
|
4
|
+
/** Promise-based delay. */
|
|
5
|
+
export function sleep(ms) {
|
|
6
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Map over items with bounded concurrency.
|
|
10
|
+
* At most `concurrency` items are processed simultaneously.
|
|
11
|
+
*/
|
|
12
|
+
export async function mapConcurrent(items, concurrency, fn) {
|
|
13
|
+
const results = new Array(items.length);
|
|
14
|
+
let nextIndex = 0;
|
|
15
|
+
async function worker() {
|
|
16
|
+
while (nextIndex < items.length) {
|
|
17
|
+
const i = nextIndex++;
|
|
18
|
+
results[i] = await fn(items[i], i);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const workers = Array.from({ length: Math.min(concurrency, items.length) }, () => worker());
|
|
22
|
+
await Promise.all(workers);
|
|
23
|
+
return results;
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless Chrome connection — process-lifetime singleton connected to the
|
|
3
|
+
* Chrome sidecar reachable at `CHROME_BROWSER_URL`. Used by the iterate-report
|
|
4
|
+
* preview-snapshot tool for visual validation.
|
|
5
|
+
*
|
|
6
|
+
* Connection is lazy and reconnect-on-disconnect; pages are gated through a
|
|
7
|
+
* semaphore so the sidecar isn't overwhelmed by concurrent reports.
|
|
8
|
+
*/
|
|
9
|
+
import type { Browser, BrowserContext, Page } from "puppeteer-core";
|
|
10
|
+
export interface ChromeConfig {
|
|
11
|
+
readonly browserUrl?: string;
|
|
12
|
+
readonly maxPages?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function getBrowser(browserUrl?: string): Promise<Browser>;
|
|
15
|
+
export declare function withPage<T>(cfg: ChromeConfig, fn: (page: Page, context: BrowserContext) => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless Chrome connection — process-lifetime singleton connected to the
|
|
3
|
+
* Chrome sidecar reachable at `CHROME_BROWSER_URL`. Used by the iterate-report
|
|
4
|
+
* preview-snapshot tool for visual validation.
|
|
5
|
+
*
|
|
6
|
+
* Connection is lazy and reconnect-on-disconnect; pages are gated through a
|
|
7
|
+
* semaphore so the sidecar isn't overwhelmed by concurrent reports.
|
|
8
|
+
*/
|
|
9
|
+
import puppeteer from "puppeteer-core";
|
|
10
|
+
let browser;
|
|
11
|
+
let connecting;
|
|
12
|
+
let semaphore;
|
|
13
|
+
function createSemaphore(max) {
|
|
14
|
+
let active = 0;
|
|
15
|
+
const queue = [];
|
|
16
|
+
const release = () => {
|
|
17
|
+
active--;
|
|
18
|
+
const next = queue.shift();
|
|
19
|
+
if (next)
|
|
20
|
+
next();
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
acquire() {
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
const grant = () => {
|
|
26
|
+
active++;
|
|
27
|
+
resolve(release);
|
|
28
|
+
};
|
|
29
|
+
if (active < max)
|
|
30
|
+
grant();
|
|
31
|
+
else
|
|
32
|
+
queue.push(grant);
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function getSemaphore(maxPages) {
|
|
38
|
+
if (!semaphore) {
|
|
39
|
+
const max = maxPages && maxPages > 0 ? maxPages : 4;
|
|
40
|
+
semaphore = createSemaphore(max);
|
|
41
|
+
}
|
|
42
|
+
return semaphore;
|
|
43
|
+
}
|
|
44
|
+
export async function getBrowser(browserUrl) {
|
|
45
|
+
if (browser && browser.connected)
|
|
46
|
+
return browser;
|
|
47
|
+
if (connecting)
|
|
48
|
+
return connecting;
|
|
49
|
+
const browserURL = browserUrl;
|
|
50
|
+
if (!browserURL) {
|
|
51
|
+
throw new Error("CHROME_BROWSER_URL is not set — Cortex requires the chrome sidecar to be reachable");
|
|
52
|
+
}
|
|
53
|
+
console.log(`[chrome] connecting to browser at ${browserURL}`);
|
|
54
|
+
connecting = puppeteer
|
|
55
|
+
.connect({ browserURL })
|
|
56
|
+
.then((b) => {
|
|
57
|
+
browser = b;
|
|
58
|
+
b.on("disconnected", () => {
|
|
59
|
+
console.log("[chrome] browser disconnected; will reconnect on next request");
|
|
60
|
+
if (browser === b)
|
|
61
|
+
browser = undefined;
|
|
62
|
+
});
|
|
63
|
+
console.log(`[chrome] connected (wsEndpoint=${b.wsEndpoint()})`);
|
|
64
|
+
return b;
|
|
65
|
+
})
|
|
66
|
+
.catch((err) => {
|
|
67
|
+
console.error("[chrome] failed to connect to browser:", err);
|
|
68
|
+
throw err;
|
|
69
|
+
})
|
|
70
|
+
.finally(() => {
|
|
71
|
+
connecting = undefined;
|
|
72
|
+
});
|
|
73
|
+
return connecting;
|
|
74
|
+
}
|
|
75
|
+
export async function withPage(cfg, fn) {
|
|
76
|
+
const release = await getSemaphore(cfg.maxPages).acquire();
|
|
77
|
+
let context;
|
|
78
|
+
try {
|
|
79
|
+
const b = await getBrowser(cfg.browserUrl);
|
|
80
|
+
context = await b.createBrowserContext();
|
|
81
|
+
const page = await context.newPage();
|
|
82
|
+
return await fn(page, context);
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
if (context) {
|
|
86
|
+
try {
|
|
87
|
+
await context.close();
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
console.error("[chrome] error closing browser context:", err);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
release();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Postgres data-access Result glue for cortex.
|
|
3
|
+
*
|
|
4
|
+
* The data-access layer (`state/`, `memory/`, vector-store, regulatory-corpus)
|
|
5
|
+
* models failure as values: every function returns `ResultAsync<T, DbError>`.
|
|
6
|
+
* The ONLY `try/catch` lives here, at the `pg` driver call — these three
|
|
7
|
+
* wrappers turn a driver throw into an `err(DbError)`; everything above them
|
|
8
|
+
* flows `ResultAsync`.
|
|
9
|
+
*
|
|
10
|
+
* House rules realized here (see `lib/result.ts`):
|
|
11
|
+
* - Absence is NOT an error. A missing row stays in the ok channel as a data
|
|
12
|
+
* variant (`ok(null)` / `ok([])`), never an `err`. `DbError` is reserved for
|
|
13
|
+
* a genuine driver/connection/constraint failure.
|
|
14
|
+
* - Control-flow exceptions (DBOS cancellation, `AbortError`) are NOT failures
|
|
15
|
+
* and are never captured as a `DbError`: the single-statement wrappers below
|
|
16
|
+
* only ever see driver throws, and `withTransaction` never catches a throw
|
|
17
|
+
* that escapes `fn` — a control-flow exception propagates untouched to the
|
|
18
|
+
* workflow-call seam (its `finally` only rolls back and releases).
|
|
19
|
+
*
|
|
20
|
+
* Consumers unwrap per their edge: HTTP routes `.match(...)`; DBOS step bodies
|
|
21
|
+
* `resultStep(runStep)` / `unwrapOrThrow`; tool `execute` bodies `unwrapOrThrow`
|
|
22
|
+
* (a throw becomes an `is_error` tool_result via dispatch).
|
|
23
|
+
*/
|
|
24
|
+
import { ResultAsync } from "neverthrow";
|
|
25
|
+
import type { Pool, PoolClient } from "pg";
|
|
26
|
+
/** A query/mutation/connection accepted by the data-access layer. */
|
|
27
|
+
type Querier = Pool | PoolClient;
|
|
28
|
+
/**
|
|
29
|
+
* A storage-layer failure. Absence is deliberately NOT modelled: single-row
|
|
30
|
+
* reads return `ok(T | null)` and mutations against a missing row return
|
|
31
|
+
* `ok(0 rows)`, so "not found" rides the ok channel. `DbError` is reserved for
|
|
32
|
+
* driver-level failures — a failed read, a failed write, a constraint trip, or
|
|
33
|
+
* a lost connection. `op` is a stable, human-readable label (e.g.
|
|
34
|
+
* `"runs.insertRun"`) used by `describeDbError` and in logs.
|
|
35
|
+
*/
|
|
36
|
+
export type DbError = {
|
|
37
|
+
readonly type: "query_failed";
|
|
38
|
+
readonly op: string;
|
|
39
|
+
readonly cause: unknown;
|
|
40
|
+
} | {
|
|
41
|
+
readonly type: "mutation_failed";
|
|
42
|
+
readonly op: string;
|
|
43
|
+
readonly cause: unknown;
|
|
44
|
+
} | {
|
|
45
|
+
readonly type: "connection_failed";
|
|
46
|
+
readonly op: string;
|
|
47
|
+
readonly cause: unknown;
|
|
48
|
+
} | {
|
|
49
|
+
readonly type: "constraint_violation";
|
|
50
|
+
readonly op: string;
|
|
51
|
+
readonly constraint: string;
|
|
52
|
+
readonly cause: unknown;
|
|
53
|
+
};
|
|
54
|
+
/** A one-line, user-facing description of a `DbError` for logs and error bodies. */
|
|
55
|
+
export declare function describeDbError(e: DbError): string;
|
|
56
|
+
/**
|
|
57
|
+
* Wrap a read. A `pg` throw becomes `err(query_failed)` — or
|
|
58
|
+
* `err(connection_failed)` for a connection SQLSTATE. Absence is the body's
|
|
59
|
+
* concern: return `ok(null)` / `ok([])` from `fn` for a missing row.
|
|
60
|
+
*
|
|
61
|
+
* `fn` runs the driver call and returns the already-mapped value (`T`). Keep
|
|
62
|
+
* `fn` to the single `await querier.query(...)` plus its row-mapping; do not
|
|
63
|
+
* embed control-flow that could throw a non-driver error.
|
|
64
|
+
*/
|
|
65
|
+
export declare function tryQuery<T>(op: string, fn: () => Promise<T>): ResultAsync<T, DbError>;
|
|
66
|
+
/**
|
|
67
|
+
* Wrap a write. A `pg` throw becomes `err(mutation_failed)`, mapped to
|
|
68
|
+
* `err(constraint_violation{constraint})` for SQLSTATE 23505/23503/23502/23514
|
|
69
|
+
* and `err(connection_failed)` for a connection SQLSTATE.
|
|
70
|
+
*/
|
|
71
|
+
export declare function tryMutation<T>(op: string, fn: () => Promise<T>): ResultAsync<T, DbError>;
|
|
72
|
+
/**
|
|
73
|
+
* Run `fn`'s statements in one transaction against a dedicated `PoolClient`:
|
|
74
|
+
* `BEGIN`, run `fn(client)`, `COMMIT` on `ok`, `ROLLBACK` on `err`. `fn`
|
|
75
|
+
* receives the transaction's `client` — every statement inside MUST use it,
|
|
76
|
+
* not the pool.
|
|
77
|
+
*
|
|
78
|
+
* CRITICAL FOOTGUN: the `pg` driver rolls back a transaction only when its
|
|
79
|
+
* callback throws, but our mutations report failure by returning `err`. So
|
|
80
|
+
* `withTransaction` rolls back itself whenever `fn` does not reach `COMMIT`.
|
|
81
|
+
* Build the transaction body as a single `ResultAsync` chain whose first `err`
|
|
82
|
+
* short-circuits to `fn`'s result — do NOT `.match`/swallow a mid-transaction
|
|
83
|
+
* `err` inside `fn`, or that statement commits with the rest.
|
|
84
|
+
*
|
|
85
|
+
* `connect` / `BEGIN` / `COMMIT` driver errors become `err`. A throw that
|
|
86
|
+
* escapes `fn` itself is NEVER caught here — a control-flow exception (DBOS
|
|
87
|
+
* cancellation, `AbortError`) is DBOS's own signalling and must reach the
|
|
88
|
+
* workflow-call seam untouched; the `finally` only rolls back the open
|
|
89
|
+
* transaction and releases the connection so a cancelled tx never poisons the
|
|
90
|
+
* pool.
|
|
91
|
+
*/
|
|
92
|
+
export declare function withTransaction<T>(pool: Pool, op: string, fn: (client: PoolClient) => ResultAsync<T, DbError>): ResultAsync<T, DbError>;
|
|
93
|
+
export type { Querier };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Postgres data-access Result glue for cortex.
|
|
3
|
+
*
|
|
4
|
+
* The data-access layer (`state/`, `memory/`, vector-store, regulatory-corpus)
|
|
5
|
+
* models failure as values: every function returns `ResultAsync<T, DbError>`.
|
|
6
|
+
* The ONLY `try/catch` lives here, at the `pg` driver call — these three
|
|
7
|
+
* wrappers turn a driver throw into an `err(DbError)`; everything above them
|
|
8
|
+
* flows `ResultAsync`.
|
|
9
|
+
*
|
|
10
|
+
* House rules realized here (see `lib/result.ts`):
|
|
11
|
+
* - Absence is NOT an error. A missing row stays in the ok channel as a data
|
|
12
|
+
* variant (`ok(null)` / `ok([])`), never an `err`. `DbError` is reserved for
|
|
13
|
+
* a genuine driver/connection/constraint failure.
|
|
14
|
+
* - Control-flow exceptions (DBOS cancellation, `AbortError`) are NOT failures
|
|
15
|
+
* and are never captured as a `DbError`: the single-statement wrappers below
|
|
16
|
+
* only ever see driver throws, and `withTransaction` never catches a throw
|
|
17
|
+
* that escapes `fn` — a control-flow exception propagates untouched to the
|
|
18
|
+
* workflow-call seam (its `finally` only rolls back and releases).
|
|
19
|
+
*
|
|
20
|
+
* Consumers unwrap per their edge: HTTP routes `.match(...)`; DBOS step bodies
|
|
21
|
+
* `resultStep(runStep)` / `unwrapOrThrow`; tool `execute` bodies `unwrapOrThrow`
|
|
22
|
+
* (a throw becomes an `is_error` tool_result via dispatch).
|
|
23
|
+
*/
|
|
24
|
+
import { ResultAsync, err, ok } from "neverthrow";
|
|
25
|
+
const _assertDomainError = true;
|
|
26
|
+
/** pg SQLSTATE classes that mean "connection is gone", mapped to `connection_failed`. */
|
|
27
|
+
const CONNECTION_SQLSTATE = new Set([
|
|
28
|
+
"08000", // connection_exception
|
|
29
|
+
"08003", // connection_does_not_exist
|
|
30
|
+
"08006", // connection_failure
|
|
31
|
+
"08001", // sqlclient_unable_to_establish_sqlconnection
|
|
32
|
+
"08004", // sqlserver_rejected_establishment_of_sqlconnection
|
|
33
|
+
"57P01", // admin_shutdown
|
|
34
|
+
"57P02", // crash_shutdown
|
|
35
|
+
"57P03", // cannot_connect_now
|
|
36
|
+
]);
|
|
37
|
+
/** pg SQLSTATE → the violated constraint kind, for `constraint_violation`. */
|
|
38
|
+
const CONSTRAINT_SQLSTATE = {
|
|
39
|
+
"23505": "unique",
|
|
40
|
+
"23503": "foreign_key",
|
|
41
|
+
"23502": "not_null",
|
|
42
|
+
"23514": "check",
|
|
43
|
+
};
|
|
44
|
+
function sqlstate(cause) {
|
|
45
|
+
if (cause && typeof cause === "object" && "code" in cause) {
|
|
46
|
+
const code = cause.code;
|
|
47
|
+
return typeof code === "string" ? code : undefined;
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
/** pg surfaces the tripped constraint's name on `.constraint`. */
|
|
52
|
+
function constraintName(cause) {
|
|
53
|
+
if (cause && typeof cause === "object" && "constraint" in cause) {
|
|
54
|
+
const name = cause.constraint;
|
|
55
|
+
if (typeof name === "string" && name.length > 0)
|
|
56
|
+
return name;
|
|
57
|
+
}
|
|
58
|
+
return "unknown";
|
|
59
|
+
}
|
|
60
|
+
/** A read throw → `connection_failed` for a connection SQLSTATE, else `query_failed`. */
|
|
61
|
+
function readError(op, cause) {
|
|
62
|
+
const code = sqlstate(cause);
|
|
63
|
+
if (code && CONNECTION_SQLSTATE.has(code)) {
|
|
64
|
+
return { type: "connection_failed", op, cause };
|
|
65
|
+
}
|
|
66
|
+
return { type: "query_failed", op, cause };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A write throw → `constraint_violation` for a constraint SQLSTATE (carrying
|
|
70
|
+
* the constraint name), `connection_failed` for a connection SQLSTATE, else
|
|
71
|
+
* `mutation_failed`.
|
|
72
|
+
*/
|
|
73
|
+
function writeError(op, cause) {
|
|
74
|
+
const code = sqlstate(cause);
|
|
75
|
+
if (code && code in CONSTRAINT_SQLSTATE) {
|
|
76
|
+
return {
|
|
77
|
+
type: "constraint_violation",
|
|
78
|
+
op,
|
|
79
|
+
constraint: constraintName(cause),
|
|
80
|
+
cause,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (code && CONNECTION_SQLSTATE.has(code)) {
|
|
84
|
+
return { type: "connection_failed", op, cause };
|
|
85
|
+
}
|
|
86
|
+
return { type: "mutation_failed", op, cause };
|
|
87
|
+
}
|
|
88
|
+
/** A one-line, user-facing description of a `DbError` for logs and error bodies. */
|
|
89
|
+
export function describeDbError(e) {
|
|
90
|
+
switch (e.type) {
|
|
91
|
+
case "query_failed":
|
|
92
|
+
return `database read failed (${e.op})`;
|
|
93
|
+
case "mutation_failed":
|
|
94
|
+
return `database write failed (${e.op})`;
|
|
95
|
+
case "connection_failed":
|
|
96
|
+
return `database connection failed (${e.op})`;
|
|
97
|
+
case "constraint_violation":
|
|
98
|
+
return `database constraint "${e.constraint}" violated (${e.op})`;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Wrap a read. A `pg` throw becomes `err(query_failed)` — or
|
|
103
|
+
* `err(connection_failed)` for a connection SQLSTATE. Absence is the body's
|
|
104
|
+
* concern: return `ok(null)` / `ok([])` from `fn` for a missing row.
|
|
105
|
+
*
|
|
106
|
+
* `fn` runs the driver call and returns the already-mapped value (`T`). Keep
|
|
107
|
+
* `fn` to the single `await querier.query(...)` plus its row-mapping; do not
|
|
108
|
+
* embed control-flow that could throw a non-driver error.
|
|
109
|
+
*/
|
|
110
|
+
export function tryQuery(op, fn) {
|
|
111
|
+
return new ResultAsync((async () => {
|
|
112
|
+
try {
|
|
113
|
+
return ok(await fn());
|
|
114
|
+
}
|
|
115
|
+
catch (cause) {
|
|
116
|
+
return err(readError(op, cause));
|
|
117
|
+
}
|
|
118
|
+
})());
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Wrap a write. A `pg` throw becomes `err(mutation_failed)`, mapped to
|
|
122
|
+
* `err(constraint_violation{constraint})` for SQLSTATE 23505/23503/23502/23514
|
|
123
|
+
* and `err(connection_failed)` for a connection SQLSTATE.
|
|
124
|
+
*/
|
|
125
|
+
export function tryMutation(op, fn) {
|
|
126
|
+
return new ResultAsync((async () => {
|
|
127
|
+
try {
|
|
128
|
+
return ok(await fn());
|
|
129
|
+
}
|
|
130
|
+
catch (cause) {
|
|
131
|
+
return err(writeError(op, cause));
|
|
132
|
+
}
|
|
133
|
+
})());
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Best-effort `ROLLBACK`: on a poisoned/closed connection it may itself throw;
|
|
137
|
+
* the original failure is what matters (an aborted transaction never
|
|
138
|
+
* committed), and `release()` reclaims the connection regardless.
|
|
139
|
+
*/
|
|
140
|
+
async function rollbackQuietly(client) {
|
|
141
|
+
try {
|
|
142
|
+
await client.query("ROLLBACK");
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
/* connection already gone — release covers it */
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Run `fn`'s statements in one transaction against a dedicated `PoolClient`:
|
|
150
|
+
* `BEGIN`, run `fn(client)`, `COMMIT` on `ok`, `ROLLBACK` on `err`. `fn`
|
|
151
|
+
* receives the transaction's `client` — every statement inside MUST use it,
|
|
152
|
+
* not the pool.
|
|
153
|
+
*
|
|
154
|
+
* CRITICAL FOOTGUN: the `pg` driver rolls back a transaction only when its
|
|
155
|
+
* callback throws, but our mutations report failure by returning `err`. So
|
|
156
|
+
* `withTransaction` rolls back itself whenever `fn` does not reach `COMMIT`.
|
|
157
|
+
* Build the transaction body as a single `ResultAsync` chain whose first `err`
|
|
158
|
+
* short-circuits to `fn`'s result — do NOT `.match`/swallow a mid-transaction
|
|
159
|
+
* `err` inside `fn`, or that statement commits with the rest.
|
|
160
|
+
*
|
|
161
|
+
* `connect` / `BEGIN` / `COMMIT` driver errors become `err`. A throw that
|
|
162
|
+
* escapes `fn` itself is NEVER caught here — a control-flow exception (DBOS
|
|
163
|
+
* cancellation, `AbortError`) is DBOS's own signalling and must reach the
|
|
164
|
+
* workflow-call seam untouched; the `finally` only rolls back the open
|
|
165
|
+
* transaction and releases the connection so a cancelled tx never poisons the
|
|
166
|
+
* pool.
|
|
167
|
+
*/
|
|
168
|
+
export function withTransaction(pool, op, fn) {
|
|
169
|
+
return new ResultAsync((async () => {
|
|
170
|
+
let client;
|
|
171
|
+
try {
|
|
172
|
+
client = await pool.connect();
|
|
173
|
+
}
|
|
174
|
+
catch (cause) {
|
|
175
|
+
return err(writeError(op, cause));
|
|
176
|
+
}
|
|
177
|
+
let committed = false;
|
|
178
|
+
try {
|
|
179
|
+
const begun = await tryMutation(`${op}:begin`, () => client.query("BEGIN"));
|
|
180
|
+
if (begun.isErr())
|
|
181
|
+
return err(begun.error);
|
|
182
|
+
const inner = await fn(client);
|
|
183
|
+
if (inner.isErr())
|
|
184
|
+
return err(inner.error);
|
|
185
|
+
const done = await tryMutation(`${op}:commit`, () => client.query("COMMIT"));
|
|
186
|
+
if (done.isErr())
|
|
187
|
+
return err(done.error);
|
|
188
|
+
committed = true;
|
|
189
|
+
return ok(inner.value);
|
|
190
|
+
}
|
|
191
|
+
finally {
|
|
192
|
+
if (!committed)
|
|
193
|
+
await rollbackQuietly(client);
|
|
194
|
+
client.release();
|
|
195
|
+
}
|
|
196
|
+
})());
|
|
197
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared filesystem helpers — deduplicated SHA-256 hashing and file existence checks.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Compute SHA-256 hash of in-memory content.
|
|
6
|
+
* Returns `sha256:<hex>` format.
|
|
7
|
+
*/
|
|
8
|
+
export declare function computeSha256(content: Buffer | Uint8Array): string;
|
|
9
|
+
/**
|
|
10
|
+
* Compute SHA-256 hash of a file on disk.
|
|
11
|
+
* Returns `sha256:<hex>` format.
|
|
12
|
+
*/
|
|
13
|
+
export declare function computeSha256File(filePath: string): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* True when `hash` is a well-formed `algorithm:hex` content hash. The storage backend
|
|
16
|
+
* (`ValidateContentHash`) rejects any file row without one — and rolls back the
|
|
17
|
+
* whole activity transaction on the first bad row — so this gates what reaches
|
|
18
|
+
* registration. Inputs arrive hashless from the path-only provenance frame and
|
|
19
|
+
* are filled by `reconcileManifestWithDisk`; an empty hash past that point is
|
|
20
|
+
* an attestation invariant violation, not something to paper over.
|
|
21
|
+
*/
|
|
22
|
+
export declare function hasValidContentHash(hash: string | undefined): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Check whether a file exists (access-based, no stat overhead).
|
|
25
|
+
*/
|
|
26
|
+
export declare function fileExists(filePath: string): Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* Write a file that MUST land physically inside the analysis workspace tree,
|
|
29
|
+
* refusing every symlink escape a sandbox step could have planted.
|
|
30
|
+
*
|
|
31
|
+
* The harness runs some post-step writes (a step's `output/summary.md`, a run's
|
|
32
|
+
* `synthesis.json`) in the HOST process, into the same `runs/{runId}/{stepId}`
|
|
33
|
+
* subtree the sandbox agent held read-write. A plain `fs.writeFile` follows
|
|
34
|
+
* symlinks, so a compromised agent that replaced the leaf — or an intermediate
|
|
35
|
+
* directory — with a symlink to `~/.ssh/authorized_keys` (or any host path)
|
|
36
|
+
* would have the harness write model-authored bytes straight through it. This
|
|
37
|
+
* relocation made that worse: the tree now lives in the user's own project
|
|
38
|
+
* folder, so a short relative symlink reaches their source.
|
|
39
|
+
*
|
|
40
|
+
* Two independent checks, because an escape can hide in either place:
|
|
41
|
+
* 1. `realpath` the materialized parent directory and require it to stay under
|
|
42
|
+
* `realpath(workspaceRoot)` — catches a symlinked intermediate dir
|
|
43
|
+
* (`output -> /elsewhere`).
|
|
44
|
+
* 2. Open the leaf with `O_NOFOLLOW` — a symlinked final component fails with
|
|
45
|
+
* `ELOOP` instead of being followed. This is atomic, so it is not
|
|
46
|
+
* TOCTOU-racy the way an `lstat`-then-open would be.
|
|
47
|
+
*
|
|
48
|
+
* Throws on any escape (a security-invariant violation, like `assertSafeId`) and
|
|
49
|
+
* on genuine I/O failure; the caller decides whether that is fatal or best-effort.
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* How `absPath` — already lexically inside `confinementRoot` — relates to it
|
|
53
|
+
* once symlinks are followed:
|
|
54
|
+
* - `in` — resolves inside the root (a real file, or a symlink/hard link
|
|
55
|
+
* whose real location stays in-tree).
|
|
56
|
+
* - `escaped` — resolves OUTSIDE the root via a symlink; the caller must refuse.
|
|
57
|
+
* - `absent` — does not fully exist (missing file, or a symlink to a missing
|
|
58
|
+
* target); nothing to leak, so the caller proceeds with its own
|
|
59
|
+
* not-found / fallback handling.
|
|
60
|
+
*/
|
|
61
|
+
export type WithinRootVerdict = "in" | "escaped" | "absent";
|
|
62
|
+
/**
|
|
63
|
+
* Classify a path against a confinement root, following symlinks — the read-side
|
|
64
|
+
* companion to {@link writeFileWithinRoot}. The workspace read seam resolves
|
|
65
|
+
* agent-supplied paths lexically only; without this, a symlink an agent planted
|
|
66
|
+
* in its writable step dir (`ln -s ~/.ssh/id_rsa leak.txt`) would be read through
|
|
67
|
+
* by the host process, leaking arbitrary host-file content into the model context.
|
|
68
|
+
*
|
|
69
|
+
* Hard links classify as `in`: a hard link has no symlink target for `realpath`
|
|
70
|
+
* to follow, so it resolves to its own in-tree path — which is exactly why this
|
|
71
|
+
* blocks the symlink escape without breaking hard-linked staged inputs.
|
|
72
|
+
*/
|
|
73
|
+
export declare function classifyWithinRoot(confinementRoot: string, absPath: string): Promise<WithinRootVerdict>;
|
|
74
|
+
export declare function writeFileWithinRoot(workspaceRoot: string, absPath: string, data: string | Uint8Array): Promise<void>;
|