@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,406 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cortex state table initialization.
|
|
3
|
+
*
|
|
4
|
+
* Creates `cortex_*` tables on startup using `CREATE TABLE IF NOT EXISTS` +
|
|
5
|
+
* additive `ALTER TABLE ... ADD COLUMN IF NOT EXISTS`. The whole flow is
|
|
6
|
+
* serialized across concurrent replicas with a Postgres advisory lock so
|
|
7
|
+
* simultaneous startups don't race on DDL.
|
|
8
|
+
*/
|
|
9
|
+
import { backfillAiSdkMessageEnvelopes } from "../memory/message-backfill.js";
|
|
10
|
+
const DDL = `
|
|
11
|
+
-- Analysis-level state (status, context, data-profile tracking, billing identity).
|
|
12
|
+
--
|
|
13
|
+
-- User identity is derived from the ambient credential's JWT sub claim
|
|
14
|
+
-- at request time — not persisted in this table.
|
|
15
|
+
CREATE TABLE IF NOT EXISTS cortex_analysis_state (
|
|
16
|
+
analysis_id TEXT PRIMARY KEY,
|
|
17
|
+
status TEXT NOT NULL,
|
|
18
|
+
context TEXT,
|
|
19
|
+
billing_context JSONB,
|
|
20
|
+
-- Nullable: NULL is the honest "no profile" state, which loadDataProfileStatus
|
|
21
|
+
-- collapses to null so a cleared profile is indistinguishable from one that never
|
|
22
|
+
-- existed. The 'pending' default still applies to a row inserted without a status --
|
|
23
|
+
-- a freshly-seeded analysis awaiting its first profile.
|
|
24
|
+
data_profile_status TEXT DEFAULT 'pending',
|
|
25
|
+
data_profile_error TEXT,
|
|
26
|
+
data_profile_started_at TEXT,
|
|
27
|
+
data_profile_completed_at TEXT,
|
|
28
|
+
data_profile_result JSONB,
|
|
29
|
+
created_at TEXT NOT NULL,
|
|
30
|
+
updated_at TEXT NOT NULL
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
-- File registry — artifact_id (provenance) + file_id (S3), cross-run.
|
|
34
|
+
CREATE TABLE IF NOT EXISTS cortex_artifacts (
|
|
35
|
+
analysis_id TEXT NOT NULL,
|
|
36
|
+
path TEXT NOT NULL,
|
|
37
|
+
hash TEXT NOT NULL,
|
|
38
|
+
size BIGINT NOT NULL,
|
|
39
|
+
role TEXT NOT NULL,
|
|
40
|
+
source_step TEXT,
|
|
41
|
+
source_run TEXT,
|
|
42
|
+
artifact_id TEXT,
|
|
43
|
+
file_id TEXT,
|
|
44
|
+
created_at TEXT NOT NULL,
|
|
45
|
+
PRIMARY KEY (analysis_id, path)
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
CREATE INDEX IF NOT EXISTS idx_cortex_artifacts_run
|
|
49
|
+
ON cortex_artifacts(analysis_id, source_run);
|
|
50
|
+
CREATE INDEX IF NOT EXISTS idx_cortex_artifacts_artifact
|
|
51
|
+
ON cortex_artifacts(analysis_id, artifact_id);
|
|
52
|
+
|
|
53
|
+
-- Run ledger — one row per workflow execution.
|
|
54
|
+
CREATE TABLE IF NOT EXISTS cortex_runs (
|
|
55
|
+
run_id TEXT PRIMARY KEY,
|
|
56
|
+
analysis_id TEXT NOT NULL,
|
|
57
|
+
thread_id TEXT,
|
|
58
|
+
workflow_name TEXT NOT NULL,
|
|
59
|
+
status TEXT NOT NULL,
|
|
60
|
+
started_at TEXT NOT NULL,
|
|
61
|
+
completed_at TEXT,
|
|
62
|
+
error TEXT,
|
|
63
|
+
parts JSONB,
|
|
64
|
+
mandate_jti TEXT, -- oss-core-managed-ok run-mandate ledger, nullable, OSS leaves null
|
|
65
|
+
mandate_expires_at TEXT -- oss-core-managed-ok run-mandate ledger, nullable, OSS leaves null
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
CREATE INDEX IF NOT EXISTS idx_cortex_runs_analysis
|
|
69
|
+
ON cortex_runs(analysis_id);
|
|
70
|
+
CREATE INDEX IF NOT EXISTS idx_cortex_runs_thread
|
|
71
|
+
ON cortex_runs(thread_id);
|
|
72
|
+
|
|
73
|
+
-- Step execution ledger — one row per step execution.
|
|
74
|
+
CREATE TABLE IF NOT EXISTS cortex_step_executions (
|
|
75
|
+
run_id TEXT NOT NULL,
|
|
76
|
+
step_id TEXT NOT NULL,
|
|
77
|
+
analysis_id TEXT NOT NULL,
|
|
78
|
+
wave INTEGER NOT NULL,
|
|
79
|
+
agent_id TEXT NOT NULL,
|
|
80
|
+
status TEXT NOT NULL,
|
|
81
|
+
started_at TEXT,
|
|
82
|
+
completed_at TEXT,
|
|
83
|
+
duration_ms BIGINT,
|
|
84
|
+
error TEXT,
|
|
85
|
+
attempts INTEGER NOT NULL DEFAULT 1,
|
|
86
|
+
last_error_class TEXT,
|
|
87
|
+
finish_reason TEXT,
|
|
88
|
+
hit_max_steps INTEGER NOT NULL DEFAULT 0,
|
|
89
|
+
blocked_reason TEXT,
|
|
90
|
+
PRIMARY KEY (run_id, step_id)
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
CREATE INDEX IF NOT EXISTS idx_cortex_step_exec_analysis
|
|
94
|
+
ON cortex_step_executions(analysis_id);
|
|
95
|
+
|
|
96
|
+
-- Analysis plans — persisted by generatePlan, consumed by showUser and executePlan.
|
|
97
|
+
-- Immutable, append-only. Iteration produces a new row linked via parent_plan_id.
|
|
98
|
+
CREATE TABLE IF NOT EXISTS cortex_plans (
|
|
99
|
+
plan_id TEXT PRIMARY KEY,
|
|
100
|
+
analysis_id TEXT NOT NULL
|
|
101
|
+
REFERENCES cortex_analysis_state(analysis_id)
|
|
102
|
+
ON DELETE CASCADE,
|
|
103
|
+
plan JSONB NOT NULL,
|
|
104
|
+
parent_plan_id TEXT
|
|
105
|
+
REFERENCES cortex_plans(plan_id)
|
|
106
|
+
ON DELETE SET NULL,
|
|
107
|
+
created_at TEXT NOT NULL
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
CREATE INDEX IF NOT EXISTS idx_cortex_plans_analysis
|
|
111
|
+
ON cortex_plans(analysis_id, created_at DESC);
|
|
112
|
+
|
|
113
|
+
-- Target assessments — organization-scoped, snapshot-style target dossiers.
|
|
114
|
+
-- Independent of analyses, projects, runs, and chat threads. The full
|
|
115
|
+
-- dossier is persisted as JSONB on the row, no separate artifacts table.
|
|
116
|
+
CREATE TABLE IF NOT EXISTS cortex_target_assessments (
|
|
117
|
+
id UUID PRIMARY KEY,
|
|
118
|
+
organization_id TEXT NOT NULL,
|
|
119
|
+
target_id TEXT NOT NULL,
|
|
120
|
+
target_label TEXT NOT NULL,
|
|
121
|
+
goal TEXT,
|
|
122
|
+
status TEXT NOT NULL,
|
|
123
|
+
progress TEXT,
|
|
124
|
+
dossier JSONB,
|
|
125
|
+
billing_context_id TEXT NOT NULL,
|
|
126
|
+
error JSONB,
|
|
127
|
+
requested_by TEXT NOT NULL,
|
|
128
|
+
workflow_run_id TEXT,
|
|
129
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
130
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
131
|
+
completed_at TIMESTAMPTZ
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
ALTER TABLE cortex_target_assessments
|
|
135
|
+
ADD COLUMN IF NOT EXISTS workflow_run_id TEXT;
|
|
136
|
+
|
|
137
|
+
-- DBOS workflow id for the executeTargetAssessment workflow. For DBOS-shaped
|
|
138
|
+
-- rows, workflow_id = assessmentId (the workflowID passed to DBOS.startWorkflow).
|
|
139
|
+
-- Nullable so older rows tolerate NULL -- new rows always write
|
|
140
|
+
-- workflow_id alongside the row insert.
|
|
141
|
+
ALTER TABLE cortex_target_assessments
|
|
142
|
+
ADD COLUMN IF NOT EXISTS workflow_id TEXT;
|
|
143
|
+
|
|
144
|
+
CREATE INDEX IF NOT EXISTS idx_cortex_target_assessments_workflow_id
|
|
145
|
+
ON cortex_target_assessments(workflow_id);
|
|
146
|
+
|
|
147
|
+
CREATE INDEX IF NOT EXISTS idx_cortex_target_assessments_org_created
|
|
148
|
+
ON cortex_target_assessments(organization_id, created_at DESC);
|
|
149
|
+
|
|
150
|
+
CREATE INDEX IF NOT EXISTS idx_cortex_target_assessments_org_target_created
|
|
151
|
+
ON cortex_target_assessments(organization_id, target_id, created_at DESC);
|
|
152
|
+
|
|
153
|
+
-- Per-row clinical-consequence annotations for off-target hits, produced by
|
|
154
|
+
-- a focused LLM annotator. Cached by (primary_target_gene, off_target_key)
|
|
155
|
+
-- so repeat assessments of the same target reuse prior work and avoid
|
|
156
|
+
-- per-run LLM cost.
|
|
157
|
+
--
|
|
158
|
+
-- off_target_key is the ChEMBL ID when present, else the (trimmed,
|
|
159
|
+
-- lowercased) off-target name. Composite primary key prevents duplicate
|
|
160
|
+
-- annotations.
|
|
161
|
+
CREATE TABLE IF NOT EXISTS cortex_off_target_annotations (
|
|
162
|
+
primary_target_gene TEXT NOT NULL,
|
|
163
|
+
off_target_key TEXT NOT NULL,
|
|
164
|
+
off_target_name TEXT NOT NULL,
|
|
165
|
+
clinical_consequence TEXT NOT NULL,
|
|
166
|
+
provenance TEXT,
|
|
167
|
+
model TEXT NOT NULL,
|
|
168
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
169
|
+
PRIMARY KEY (primary_target_gene, off_target_key)
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
-- Regulatory guidance corpus — pre-indexed FDA CDER, FDA CBER, and ICH
|
|
173
|
+
-- guidance documents. Written/refreshed via tasks/refresh-regulatory-corpus.ts
|
|
174
|
+
-- and searched (top-K cosine) via lib/regulatory-corpus.ts. No synthesis tool
|
|
175
|
+
-- consumes it yet — a search_regulatory_guidance tool is not wired.
|
|
176
|
+
CREATE TABLE IF NOT EXISTS cortex_regulatory_chunks (
|
|
177
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
178
|
+
source TEXT NOT NULL,
|
|
179
|
+
doc_id TEXT NOT NULL,
|
|
180
|
+
doc_title TEXT NOT NULL,
|
|
181
|
+
doc_url TEXT NOT NULL,
|
|
182
|
+
section TEXT,
|
|
183
|
+
chunk_index INTEGER NOT NULL,
|
|
184
|
+
chunk_text TEXT NOT NULL,
|
|
185
|
+
embedding vector(1536),
|
|
186
|
+
metadata JSONB NOT NULL DEFAULT '{}'::jsonb,
|
|
187
|
+
indexed_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
CREATE INDEX IF NOT EXISTS idx_cortex_regulatory_chunks_source_doc
|
|
191
|
+
ON cortex_regulatory_chunks(source, doc_id);
|
|
192
|
+
|
|
193
|
+
CREATE INDEX IF NOT EXISTS idx_cortex_regulatory_chunks_metadata
|
|
194
|
+
ON cortex_regulatory_chunks USING gin (metadata);
|
|
195
|
+
|
|
196
|
+
-- Conversation message store — the harness ThreadHistory module's table.
|
|
197
|
+
-- One row per message, with seq monotonic per thread. message_envelope holds
|
|
198
|
+
-- AI SDK ModelMessage envelopes and tokens is counted at write time, so the
|
|
199
|
+
-- read path never tokenizes. Legacy role/content_jsonb columns are nullable
|
|
200
|
+
-- and write-frozen — they exist only for startup backfill/inspection and
|
|
201
|
+
-- should be dropped after the migration window. Conversation-scoped only —
|
|
202
|
+
-- workflow and sandbox agent loops use the DBOS step cache, never this
|
|
203
|
+
-- table (see the harness-thread-store spec). The (thread_id, seq) primary key already serves
|
|
204
|
+
-- (thread_id, seq DESC) reads, so no separate index is needed.
|
|
205
|
+
CREATE TABLE IF NOT EXISTS messages (
|
|
206
|
+
thread_id TEXT NOT NULL,
|
|
207
|
+
seq BIGINT NOT NULL,
|
|
208
|
+
role TEXT,
|
|
209
|
+
content_jsonb JSONB,
|
|
210
|
+
message_envelope JSONB,
|
|
211
|
+
tokens INTEGER NOT NULL,
|
|
212
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
213
|
+
PRIMARY KEY (thread_id, seq)
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
-- Conversation thread metadata — the harness ThreadStore module's table,
|
|
217
|
+
-- one row per conversation thread. Holds the analysis-scope, title, and
|
|
218
|
+
-- soft-delete tombstone the harness messages table deliberately lacks.
|
|
219
|
+
-- No free-form metadata column: working memory lives in cortex_working_memory;
|
|
220
|
+
-- nothing else reads thread metadata. A NULL deleted_at means the thread is live.
|
|
221
|
+
CREATE TABLE IF NOT EXISTS cortex_analysis_threads (
|
|
222
|
+
thread_id TEXT PRIMARY KEY,
|
|
223
|
+
analysis_id TEXT NOT NULL,
|
|
224
|
+
title TEXT,
|
|
225
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
226
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
227
|
+
deleted_at TIMESTAMPTZ
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
CREATE INDEX IF NOT EXISTS idx_cortex_analysis_threads_analysis
|
|
231
|
+
ON cortex_analysis_threads(analysis_id) WHERE deleted_at IS NULL;
|
|
232
|
+
|
|
233
|
+
-- Working memory — the harness WorkingMemory module's table, one row per
|
|
234
|
+
-- analysis. The data column holds a JSONB object with four sections (goal,
|
|
235
|
+
-- constraints, hypotheses, findings). Section updates are a read-modify-write
|
|
236
|
+
-- in harness/memory/working-memory.ts, not a whole-blob rewrite.
|
|
237
|
+
-- Analysis-scoped and agent-maintained.
|
|
238
|
+
CREATE TABLE IF NOT EXISTS cortex_working_memory (
|
|
239
|
+
analysis_id TEXT PRIMARY KEY,
|
|
240
|
+
data JSONB NOT NULL,
|
|
241
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
242
|
+
);
|
|
243
|
+
`;
|
|
244
|
+
/**
|
|
245
|
+
* Initialize Cortex state tables. Safe to call on every startup and across
|
|
246
|
+
* concurrent replicas (advisory lock serializes the init flow).
|
|
247
|
+
*/
|
|
248
|
+
export async function initCortexState(pool) {
|
|
249
|
+
const client = await pool.connect();
|
|
250
|
+
try {
|
|
251
|
+
// Serialize concurrent replica startups — cheap, no extra tooling.
|
|
252
|
+
await client.query("SELECT pg_advisory_lock(hashtext('cortex_state_init'))");
|
|
253
|
+
try {
|
|
254
|
+
// pgvector must be present for the per-analysis search indexes. We
|
|
255
|
+
// tolerate an already-present extension, but fail loudly on any other
|
|
256
|
+
// error so operators see a clear infra-pointer message.
|
|
257
|
+
try {
|
|
258
|
+
await client.query("CREATE EXTENSION IF NOT EXISTS vector");
|
|
259
|
+
}
|
|
260
|
+
catch (err) {
|
|
261
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
262
|
+
if (!/already exists/i.test(msg)) {
|
|
263
|
+
throw new Error(`Cortex requires the pgvector extension. ` +
|
|
264
|
+
`CREATE EXTENSION IF NOT EXISTS vector failed: ${msg}. ` +
|
|
265
|
+
`Ask platform-infra to enable pgvector on the RDS parameter group, ` +
|
|
266
|
+
`or grant CREATE on the database to the Cortex role.`, { cause: err });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// Base DDL — idempotent via CREATE TABLE IF NOT EXISTS / CREATE INDEX IF NOT EXISTS.
|
|
270
|
+
const statements = DDL.split(";")
|
|
271
|
+
.map((s) => s.trim())
|
|
272
|
+
.filter((s) => s.length > 0);
|
|
273
|
+
for (const sql of statements) {
|
|
274
|
+
await client.query(sql);
|
|
275
|
+
}
|
|
276
|
+
// Drop vestigial columns/tables from pre-v2 databases. Idempotent:
|
|
277
|
+
// each statement targets a specific column that may or may not exist;
|
|
278
|
+
// `DROP COLUMN IF EXISTS` is a no-op when absent.
|
|
279
|
+
const dropMigrations = [
|
|
280
|
+
"DROP TABLE IF EXISTS cortex_run_events",
|
|
281
|
+
"ALTER TABLE cortex_step_executions DROP COLUMN IF EXISTS thread_id",
|
|
282
|
+
"ALTER TABLE cortex_step_executions DROP COLUMN IF EXISTS execution_id",
|
|
283
|
+
"ALTER TABLE cortex_step_executions DROP COLUMN IF EXISTS resources",
|
|
284
|
+
"ALTER TABLE cortex_step_executions DROP COLUMN IF EXISTS summary",
|
|
285
|
+
"ALTER TABLE cortex_artifacts DROP COLUMN IF EXISTS description",
|
|
286
|
+
"ALTER TABLE cortex_artifacts DROP COLUMN IF EXISTS metadata",
|
|
287
|
+
"ALTER TABLE cortex_analysis_state DROP COLUMN IF EXISTS profile",
|
|
288
|
+
"ALTER TABLE cortex_analysis_state DROP COLUMN IF EXISTS input_files",
|
|
289
|
+
"ALTER TABLE cortex_analysis_state DROP COLUMN IF EXISTS user_id",
|
|
290
|
+
// v2 vestiges on cortex_runs.
|
|
291
|
+
"ALTER TABLE cortex_runs DROP COLUMN IF EXISTS plan",
|
|
292
|
+
"ALTER TABLE cortex_runs DROP COLUMN IF EXISTS plan_version",
|
|
293
|
+
"ALTER TABLE cortex_runs DROP COLUMN IF EXISTS current_wave",
|
|
294
|
+
"ALTER TABLE cortex_runs DROP COLUMN IF EXISTS suspension",
|
|
295
|
+
// The mandate JWT lives in DBOS workflow input (never reconstructed -- oss-core-managed-ok: run-mandate ledger (nullable; OSS leaves null)
|
|
296
|
+
// from the DB), and `run_id` is the DBOS workflowID directly — no
|
|
297
|
+
// separate `workflow_id` column.
|
|
298
|
+
"ALTER TABLE cortex_runs DROP COLUMN IF EXISTS mandate_token", // oss-core-managed-ok: drop-migration for removed branded column
|
|
299
|
+
"ALTER TABLE cortex_runs DROP COLUMN IF EXISTS workflow_id",
|
|
300
|
+
"DROP INDEX IF EXISTS idx_cortex_runs_workflow",
|
|
301
|
+
];
|
|
302
|
+
for (const sql of dropMigrations) {
|
|
303
|
+
await client.query(sql);
|
|
304
|
+
}
|
|
305
|
+
// If an older DB had `cortex_runs.thread_id NOT NULL`, relax it now.
|
|
306
|
+
// Safe no-op when already nullable.
|
|
307
|
+
await client.query("ALTER TABLE cortex_runs ALTER COLUMN thread_id DROP NOT NULL");
|
|
308
|
+
// Legacy Anthropic message columns are write-frozen: runtime writes
|
|
309
|
+
// only message_envelope, so new rows must not require them. The
|
|
310
|
+
// columns should be dropped entirely after the migration window.
|
|
311
|
+
await client.query("ALTER TABLE messages ALTER COLUMN role DROP NOT NULL");
|
|
312
|
+
await client.query("ALTER TABLE messages ALTER COLUMN content_jsonb DROP NOT NULL");
|
|
313
|
+
// Additive migrations — columns that may not exist on older DBs.
|
|
314
|
+
const addMigrations = [
|
|
315
|
+
"ALTER TABLE cortex_runs ADD COLUMN IF NOT EXISTS thread_id TEXT",
|
|
316
|
+
"ALTER TABLE cortex_runs ADD COLUMN IF NOT EXISTS parts JSONB",
|
|
317
|
+
"ALTER TABLE cortex_runs ADD COLUMN IF NOT EXISTS mandate_jti TEXT", // oss-core-managed-ok: run-mandate ledger (nullable; OSS leaves null)
|
|
318
|
+
"ALTER TABLE cortex_runs ADD COLUMN IF NOT EXISTS mandate_expires_at TEXT", // oss-core-managed-ok: run-mandate ledger (nullable; OSS leaves null)
|
|
319
|
+
"ALTER TABLE cortex_analysis_state ADD COLUMN IF NOT EXISTS data_profile_result JSONB",
|
|
320
|
+
"ALTER TABLE cortex_analysis_state ADD COLUMN IF NOT EXISTS billing_context JSONB",
|
|
321
|
+
// Sandbox reliability telemetry (from sandbox-reliability change on main).
|
|
322
|
+
"ALTER TABLE cortex_step_executions ADD COLUMN IF NOT EXISTS attempts INTEGER NOT NULL DEFAULT 1",
|
|
323
|
+
"ALTER TABLE cortex_step_executions ADD COLUMN IF NOT EXISTS last_error_class TEXT",
|
|
324
|
+
"ALTER TABLE cortex_step_executions ADD COLUMN IF NOT EXISTS finish_reason TEXT",
|
|
325
|
+
"ALTER TABLE cortex_step_executions ADD COLUMN IF NOT EXISTS hit_max_steps INTEGER NOT NULL DEFAULT 0",
|
|
326
|
+
"ALTER TABLE cortex_step_executions ADD COLUMN IF NOT EXISTS blocked_reason TEXT",
|
|
327
|
+
"ALTER TABLE cortex_runs ADD COLUMN IF NOT EXISTS plan_id TEXT REFERENCES cortex_plans(plan_id) ON DELETE SET NULL",
|
|
328
|
+
// Promote overflow-prone numeric columns from int4 to int8.
|
|
329
|
+
// File sizes >2 GB and durations >~24.8 days previously failed INSERT
|
|
330
|
+
// with "value ... is out of range of type integer".
|
|
331
|
+
"ALTER TABLE cortex_artifacts ALTER COLUMN size TYPE BIGINT",
|
|
332
|
+
"ALTER TABLE cortex_step_executions ALTER COLUMN duration_ms TYPE BIGINT",
|
|
333
|
+
"ALTER TABLE cortex_artifacts ADD COLUMN IF NOT EXISTS unrecoverable_at TEXT",
|
|
334
|
+
"ALTER TABLE cortex_artifacts ADD COLUMN IF NOT EXISTS file_type TEXT",
|
|
335
|
+
// Active-sandbox registry — sandbox_ref carries {sandboxId, host, port,
|
|
336
|
+
// backend} (no callbackSecret — that lives only in the DBOS step-output
|
|
337
|
+
// cache). exec_id carries the currently in-flight workflowId:stepId:fnId.
|
|
338
|
+
// Partial index supports the watchdog's registry query
|
|
339
|
+
// (status='running' AND sandbox_ref IS NOT NULL); kept partial so it
|
|
340
|
+
// stays compact against the much larger terminal-row mass.
|
|
341
|
+
"ALTER TABLE cortex_step_executions ADD COLUMN IF NOT EXISTS sandbox_ref JSONB",
|
|
342
|
+
"ALTER TABLE cortex_step_executions ADD COLUMN IF NOT EXISTS exec_id TEXT",
|
|
343
|
+
"CREATE INDEX IF NOT EXISTS idx_cortex_step_exec_active_sandbox " + "ON cortex_step_executions(status) WHERE sandbox_ref IS NOT NULL",
|
|
344
|
+
// DBOS workflow addressing. `cortex_runs.run_id` IS the parent DBOS
|
|
345
|
+
// workflowID — both are the same bare UUID. `child_workflow_id` maps
|
|
346
|
+
// each step-execution row to its DBOS child workflow id.
|
|
347
|
+
// Partial-unique index — at most one active run per (analysis_id, plan_id).
|
|
348
|
+
// Terminal rows are excluded so a deliberate re-run after completion
|
|
349
|
+
// succeeds; a concurrent double-trigger raises unique-violation and the
|
|
350
|
+
// caller resolves to the existing active runId via queryActiveRun.
|
|
351
|
+
"CREATE UNIQUE INDEX IF NOT EXISTS idx_cortex_runs_active_plan " +
|
|
352
|
+
"ON cortex_runs(analysis_id, plan_id) " +
|
|
353
|
+
"WHERE status IN ('running','suspended_insufficient_funds')",
|
|
354
|
+
"ALTER TABLE cortex_step_executions ADD COLUMN IF NOT EXISTS child_workflow_id TEXT",
|
|
355
|
+
"CREATE INDEX IF NOT EXISTS idx_cortex_step_exec_child_workflow " + "ON cortex_step_executions(child_workflow_id)",
|
|
356
|
+
"ALTER TABLE cortex_analysis_state ADD COLUMN IF NOT EXISTS seed_input_file_ids JSONB",
|
|
357
|
+
// Databases created before `data_profile_status` became nullable still
|
|
358
|
+
// carry the NOT NULL floor, which would reject a clear. Idempotent:
|
|
359
|
+
// dropping an absent NOT NULL no-ops, so this is a no-op on fresh DBs.
|
|
360
|
+
"ALTER TABLE cortex_analysis_state ALTER COLUMN data_profile_status DROP NOT NULL",
|
|
361
|
+
"ALTER TABLE messages ADD COLUMN IF NOT EXISTS message_envelope JSONB",
|
|
362
|
+
];
|
|
363
|
+
for (const sql of addMigrations) {
|
|
364
|
+
await client.query(sql);
|
|
365
|
+
}
|
|
366
|
+
await backfillAiSdkMessageEnvelopes(client);
|
|
367
|
+
// HNSW ANN index on cortex_regulatory_chunks.embedding. HNSW gives
|
|
368
|
+
// higher recall than ivfflat at the same latency and needs no
|
|
369
|
+
// training step — the right pick for a write-occasionally /
|
|
370
|
+
// read-many corpus (quarterly refresh, multiple search calls per
|
|
371
|
+
// synthesis step).
|
|
372
|
+
//
|
|
373
|
+
// Requires pgvector >= 0.5.0. Tolerated gracefully on older
|
|
374
|
+
// versions — the table and B-tree/GIN indexes still work; the
|
|
375
|
+
// operator can build this index manually once they upgrade pgvector.
|
|
376
|
+
// m and ef_construction are conservative defaults; tune after
|
|
377
|
+
// measuring recall vs. latency on the production corpus size.
|
|
378
|
+
try {
|
|
379
|
+
await client.query(`CREATE INDEX IF NOT EXISTS idx_cortex_regulatory_chunks_embedding
|
|
380
|
+
ON cortex_regulatory_chunks USING hnsw (embedding vector_cosine_ops)
|
|
381
|
+
WITH (m = 16, ef_construction = 64)`);
|
|
382
|
+
}
|
|
383
|
+
catch (err) {
|
|
384
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
385
|
+
console.warn(`[state-init] Could not create HNSW index on cortex_regulatory_chunks.embedding ` +
|
|
386
|
+
`(pgvector < 0.5.0 or operator class unavailable): ${msg}. ` +
|
|
387
|
+
`Cosine similarity queries will fall back to sequential scan. ` +
|
|
388
|
+
`Upgrade pgvector and re-run init to get the ANN index.`);
|
|
389
|
+
}
|
|
390
|
+
// No boot-time orphan sweep on cortex_runs / cortex_step_executions.
|
|
391
|
+
// Every running row is backed by a DBOS workflow (executeAnalysis,
|
|
392
|
+
// executeTargetAssessment, resume entry); DBOS recovery is the
|
|
393
|
+
// substitute — each pod has a stable executorID (StatefulSet pod name)
|
|
394
|
+
// and runs `recoverPendingWorkflows` for its own ID at launch (ADR
|
|
395
|
+
// 0012). The workflow body owns the terminal transition on cortex_runs;
|
|
396
|
+
// a bulk fail here would race recovery and mark healthy sibling-replica
|
|
397
|
+
// runs as failed.
|
|
398
|
+
}
|
|
399
|
+
finally {
|
|
400
|
+
await client.query("SELECT pg_advisory_unlock(hashtext('cortex_state_init'))");
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
finally {
|
|
404
|
+
client.release();
|
|
405
|
+
}
|
|
406
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cortex_plans` operations — plan insert (minted id), upsert (caller id),
|
|
3
|
+
* and analysis-scoped lookup.
|
|
4
|
+
*/
|
|
5
|
+
import type { ResultAsync } from "neverthrow";
|
|
6
|
+
import { type DbError } from "../lib/db-result.js";
|
|
7
|
+
import type { Querier } from "./db.js";
|
|
8
|
+
export interface InsertPlanInput {
|
|
9
|
+
analysisId: string;
|
|
10
|
+
plan: unknown;
|
|
11
|
+
parentPlanId?: string | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Insert a plan and return the generated planId.
|
|
15
|
+
* Validates that parentPlanId (if set) belongs to the same analysis —
|
|
16
|
+
* the FK alone only enforces existence, not tenant scope.
|
|
17
|
+
*
|
|
18
|
+
* The tenant-scope checks (parent missing / parent belongs to another
|
|
19
|
+
* analysis) are control-flow throws, NOT `DbError`: they short-circuit the
|
|
20
|
+
* chain by throwing before any driver call, so `tryQuery` never captures them
|
|
21
|
+
* as a query failure and they surface verbatim to the caller.
|
|
22
|
+
*/
|
|
23
|
+
export declare function insertPlan(pool: Querier, input: InsertPlanInput): ResultAsync<string, DbError>;
|
|
24
|
+
export interface UpsertPlanInput {
|
|
25
|
+
/** Caller-derived id — must match the `pln-<8hex>` contract. */
|
|
26
|
+
planId: string;
|
|
27
|
+
analysisId: string;
|
|
28
|
+
plan: unknown;
|
|
29
|
+
parentPlanId?: string | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Insert a plan under a caller-supplied id, or no-op if that id already exists
|
|
33
|
+
* (`ON CONFLICT (plan_id) DO NOTHING`). Unlike {@link insertPlan}, the id is
|
|
34
|
+
* given by the caller — used when the id is derived deterministically (e.g. a
|
|
35
|
+
* content hash) so that re-running the same plan is idempotent rather than
|
|
36
|
+
* minting a fresh row every time.
|
|
37
|
+
*
|
|
38
|
+
* Re-upserting an existing planId is a success no-op: exactly one row survives.
|
|
39
|
+
* The same parent-scope check as `insertPlan` applies (parent must belong to
|
|
40
|
+
* the same analysis) and is a control-flow throw, not a `DbError`.
|
|
41
|
+
*
|
|
42
|
+
* An id off the `pln-<8hex>` shape is a caller/contract error, not a storage
|
|
43
|
+
* failure: it throws synchronously before any driver call, surfacing verbatim
|
|
44
|
+
* above the Result boundary rather than riding the err channel as a `DbError`
|
|
45
|
+
* (mirroring the parent-scope violations, which throw before the INSERT).
|
|
46
|
+
*/
|
|
47
|
+
export declare function upsertPlan(pool: Querier, input: UpsertPlanInput): ResultAsync<void, DbError>;
|
|
48
|
+
/**
|
|
49
|
+
* Analysis-scoped plan lookup. Returns `ok(null)` for unknown planIds OR
|
|
50
|
+
* for planIds that belong to a different analysis — indistinguishable
|
|
51
|
+
* to the caller, which is the multi-tenancy invariant. Absence is NOT an
|
|
52
|
+
* error.
|
|
53
|
+
*/
|
|
54
|
+
export declare function loadPlan(pool: Querier, planId: string, opts: {
|
|
55
|
+
analysisId: string;
|
|
56
|
+
}): ResultAsync<unknown | null, DbError>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cortex_plans` operations — plan insert (minted id), upsert (caller id),
|
|
3
|
+
* and analysis-scoped lookup.
|
|
4
|
+
*/
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
6
|
+
import { tryMutation, tryQuery } from "../lib/db-result.js";
|
|
7
|
+
/**
|
|
8
|
+
* `cortex_plans.plan_id` shape contract — `pln-` followed by 8 lowercase hex
|
|
9
|
+
* chars. The chat trigger (`tools/execute-plan.ts`) enforces the same regex on
|
|
10
|
+
* its tool input; `upsertPlan` re-asserts it because it accepts a caller-derived
|
|
11
|
+
* id rather than minting one.
|
|
12
|
+
*/
|
|
13
|
+
const PLAN_ID_PATTERN = /^pln-[a-f0-9]{8}$/;
|
|
14
|
+
/**
|
|
15
|
+
* Enforce tenant scope for a `parentPlanId`: the parent row must exist AND belong
|
|
16
|
+
* to `analysisId`. Shared by {@link insertPlan} and {@link upsertPlan} — the
|
|
17
|
+
* `cortex_plans` FK enforces existence only, not tenant scope, so without this a
|
|
18
|
+
* plan could be parented under another analysis's plan.
|
|
19
|
+
*
|
|
20
|
+
* Both violations (parent missing / parent in another analysis) are control-flow
|
|
21
|
+
* throws, NOT `DbError`: they short-circuit before the child INSERT, so the throw
|
|
22
|
+
* surfaces verbatim above the Result boundary rather than riding the err channel
|
|
23
|
+
* as a query failure. `label` scopes the driver-call telemetry to the caller.
|
|
24
|
+
*/
|
|
25
|
+
function checkParentScope(pool, parentPlanId, analysisId, label) {
|
|
26
|
+
return tryQuery(label, () => pool.query({
|
|
27
|
+
text: "SELECT analysis_id FROM cortex_plans WHERE plan_id = $1",
|
|
28
|
+
values: [parentPlanId],
|
|
29
|
+
})).map((parent) => {
|
|
30
|
+
if ((parent.rowCount ?? 0) === 0) {
|
|
31
|
+
throw new Error(`parent plan ${parentPlanId} not found`);
|
|
32
|
+
}
|
|
33
|
+
if (parent.rows[0].analysis_id !== analysisId) {
|
|
34
|
+
throw new Error(`parent plan ${parentPlanId} belongs to a different analysis`);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Insert a plan and return the generated planId.
|
|
40
|
+
* Validates that parentPlanId (if set) belongs to the same analysis —
|
|
41
|
+
* the FK alone only enforces existence, not tenant scope.
|
|
42
|
+
*
|
|
43
|
+
* The tenant-scope checks (parent missing / parent belongs to another
|
|
44
|
+
* analysis) are control-flow throws, NOT `DbError`: they short-circuit the
|
|
45
|
+
* chain by throwing before any driver call, so `tryQuery` never captures them
|
|
46
|
+
* as a query failure and they surface verbatim to the caller.
|
|
47
|
+
*/
|
|
48
|
+
export function insertPlan(pool, input) {
|
|
49
|
+
const insert = () => {
|
|
50
|
+
const planId = `pln-${randomUUID().slice(0, 8)}`;
|
|
51
|
+
const now = new Date().toISOString();
|
|
52
|
+
return tryMutation("plans.insertPlan", async () => {
|
|
53
|
+
await pool.query({
|
|
54
|
+
text: `INSERT INTO cortex_plans
|
|
55
|
+
(plan_id, analysis_id, plan, parent_plan_id, created_at)
|
|
56
|
+
VALUES ($1, $2, $3, $4, $5)`,
|
|
57
|
+
values: [planId, input.analysisId, JSON.stringify(input.plan), input.parentPlanId ?? null, now],
|
|
58
|
+
});
|
|
59
|
+
return planId;
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
if (!input.parentPlanId)
|
|
63
|
+
return insert();
|
|
64
|
+
return checkParentScope(pool, input.parentPlanId, input.analysisId, "plans.insertPlan.parentScope").andThen(insert);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Insert a plan under a caller-supplied id, or no-op if that id already exists
|
|
68
|
+
* (`ON CONFLICT (plan_id) DO NOTHING`). Unlike {@link insertPlan}, the id is
|
|
69
|
+
* given by the caller — used when the id is derived deterministically (e.g. a
|
|
70
|
+
* content hash) so that re-running the same plan is idempotent rather than
|
|
71
|
+
* minting a fresh row every time.
|
|
72
|
+
*
|
|
73
|
+
* Re-upserting an existing planId is a success no-op: exactly one row survives.
|
|
74
|
+
* The same parent-scope check as `insertPlan` applies (parent must belong to
|
|
75
|
+
* the same analysis) and is a control-flow throw, not a `DbError`.
|
|
76
|
+
*
|
|
77
|
+
* An id off the `pln-<8hex>` shape is a caller/contract error, not a storage
|
|
78
|
+
* failure: it throws synchronously before any driver call, surfacing verbatim
|
|
79
|
+
* above the Result boundary rather than riding the err channel as a `DbError`
|
|
80
|
+
* (mirroring the parent-scope violations, which throw before the INSERT).
|
|
81
|
+
*/
|
|
82
|
+
export function upsertPlan(pool, input) {
|
|
83
|
+
if (!PLAN_ID_PATTERN.test(input.planId)) {
|
|
84
|
+
throw new Error(`upsertPlan: invalid plan id "${input.planId}" — expected the pln-<8hex> shape`);
|
|
85
|
+
}
|
|
86
|
+
const upsert = () => {
|
|
87
|
+
const now = new Date().toISOString();
|
|
88
|
+
return tryMutation("plans.upsertPlan", async () => {
|
|
89
|
+
await pool.query({
|
|
90
|
+
text: `INSERT INTO cortex_plans
|
|
91
|
+
(plan_id, analysis_id, plan, parent_plan_id, created_at)
|
|
92
|
+
VALUES ($1, $2, $3, $4, $5)
|
|
93
|
+
ON CONFLICT (plan_id) DO NOTHING`,
|
|
94
|
+
values: [input.planId, input.analysisId, JSON.stringify(input.plan), input.parentPlanId ?? null, now],
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
if (!input.parentPlanId)
|
|
99
|
+
return upsert();
|
|
100
|
+
return checkParentScope(pool, input.parentPlanId, input.analysisId, "plans.upsertPlan.parentScope").andThen(upsert);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Analysis-scoped plan lookup. Returns `ok(null)` for unknown planIds OR
|
|
104
|
+
* for planIds that belong to a different analysis — indistinguishable
|
|
105
|
+
* to the caller, which is the multi-tenancy invariant. Absence is NOT an
|
|
106
|
+
* error.
|
|
107
|
+
*/
|
|
108
|
+
export function loadPlan(pool, planId, opts) {
|
|
109
|
+
return tryQuery("plans.loadPlan", async () => {
|
|
110
|
+
const result = await pool.query({
|
|
111
|
+
text: `SELECT plan FROM cortex_plans
|
|
112
|
+
WHERE plan_id = $1 AND analysis_id = $2`,
|
|
113
|
+
values: [planId, opts.analysisId],
|
|
114
|
+
});
|
|
115
|
+
return result.rows[0]?.plan ?? null;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cortex_runs` operations — run lifecycle, dedup, run-mandate persistence. oss-core-managed-ok: run-mandate ledger (nullable; OSS leaves null)
|
|
3
|
+
*
|
|
4
|
+
* Every read/write returns `ResultAsync<T, DbError>` — a driver failure rides
|
|
5
|
+
* the err channel, absence rides ok (`ok(null)` / `ok([])`). The lone exception
|
|
6
|
+
* is `insertRun`'s dedup collision: `RunDedupCollisionError` is a control-flow
|
|
7
|
+
* signal (the caller recovers via `queryActiveRun`), not a storage failure, so
|
|
8
|
+
* it is thrown verbatim ABOVE the Result boundary rather than mapped to a
|
|
9
|
+
* `DbError`. Every other write maps SQLSTATE 23505/23503/23502/23514 to
|
|
10
|
+
* `err(constraint_violation)` via `tryMutation`.
|
|
11
|
+
*/
|
|
12
|
+
import type { ResultAsync } from "neverthrow";
|
|
13
|
+
import type { DbError } from "../lib/db-result.js";
|
|
14
|
+
import type { Querier } from "./db.js";
|
|
15
|
+
import type { CortexRunRow } from "./schema.js";
|
|
16
|
+
export interface InsertRunInput {
|
|
17
|
+
runId: string;
|
|
18
|
+
analysisId: string;
|
|
19
|
+
threadId?: string | null;
|
|
20
|
+
workflowName: string;
|
|
21
|
+
planId?: string | null;
|
|
22
|
+
mandateJti?: string | null;
|
|
23
|
+
mandateExpiresAt?: string | null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Raised when `insertRun` collides with the partial-unique index
|
|
27
|
+
* `idx_cortex_runs_active_plan` — i.e., an active run already exists for
|
|
28
|
+
* `(analysisId, planId)`. Callers SHOULD recover via `queryActiveRun` and
|
|
29
|
+
* return the existing `runId` instead of starting a fresh workflow.
|
|
30
|
+
*/
|
|
31
|
+
export declare class RunDedupCollisionError extends Error {
|
|
32
|
+
readonly analysisId: string;
|
|
33
|
+
readonly planId: string | null;
|
|
34
|
+
constructor(analysisId: string, planId: string | null);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Insert the run row. On the partial-unique index collision
|
|
38
|
+
* (`idx_cortex_runs_active_plan`) the function throws `RunDedupCollisionError`
|
|
39
|
+
* verbatim — a control-flow signal the caller recovers from via
|
|
40
|
+
* `queryActiveRun`, NOT a `DbError`. The throw rides out of the `ResultAsync`
|
|
41
|
+
* as a rejected promise (so an `await insertRun(...).match(...)`-free caller
|
|
42
|
+
* sees the same exception it always did); every other driver failure stays in
|
|
43
|
+
* the err channel as a `DbError`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function insertRun(pool: Querier, input: InsertRunInput): ResultAsync<void, DbError>;
|
|
46
|
+
/**
|
|
47
|
+
* Recover the active run row for `(analysisId, planId)` after `insertRun`
|
|
48
|
+
* raises `RunDedupCollisionError`. The partial-unique index guarantees at
|
|
49
|
+
* most one match.
|
|
50
|
+
*/
|
|
51
|
+
export declare function queryActiveRun(pool: Querier, analysisId: string, planId: string | null): ResultAsync<CortexRunRow | null, DbError>;
|
|
52
|
+
export declare function updateRunStatus(pool: Querier, runId: string, status: "running" | "completed" | "partial" | "failed" | "canceled" | "suspended_insufficient_funds", error?: string | null): ResultAsync<void, DbError>;
|
|
53
|
+
export declare function promoteFailedToPartial(pool: Querier, runId: string): ResultAsync<boolean, DbError>;
|
|
54
|
+
export declare function queryRun(pool: Querier, runId: string): ResultAsync<CortexRunRow | null, DbError>;
|
|
55
|
+
export declare function queryRunsByAnalysis(pool: Querier, analysisId: string, { limit, offset }?: {
|
|
56
|
+
limit?: number;
|
|
57
|
+
offset?: number;
|
|
58
|
+
}): ResultAsync<CortexRunRow[], DbError>;
|
|
59
|
+
export declare function queryRunsByThread(pool: Querier, analysisId: string, threadId: string, { limit, offset }?: {
|
|
60
|
+
limit?: number;
|
|
61
|
+
offset?: number;
|
|
62
|
+
}): ResultAsync<CortexRunRow[], DbError>;
|
|
63
|
+
/**
|
|
64
|
+
* Persist the run mandate jti + expiry for a run. oss-core-managed-ok: run-mandate ledger (nullable; OSS leaves null)
|
|
65
|
+
* Called by `authorizeForRun` after a successful mint so the cancel
|
|
66
|
+
* handler can revoke the mandate by `runId → jti` lookup. oss-core-managed-ok: run-mandate ledger (nullable; OSS leaves null)
|
|
67
|
+
* The JWT itself is NOT persisted — it rides in DBOS workflow input.
|
|
68
|
+
*/
|
|
69
|
+
export declare function setRunMandate(pool: Querier, runId: string, jti: string, expiresAt: string): ResultAsync<void, DbError>;
|