@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,746 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `executeAnalysis` — the parent DBOS workflow.
|
|
3
|
+
*
|
|
4
|
+
* Shape (every external interaction is a `DBOS.runStep` so a crashed parent
|
|
5
|
+
* replays from the cache instead of repeating side effects):
|
|
6
|
+
*
|
|
7
|
+
* 1. `validateAndInit`
|
|
8
|
+
* - validate the plan DAG (cycle / missing-dep / dup-id)
|
|
9
|
+
* - create the run dir
|
|
10
|
+
* - open the running charge
|
|
11
|
+
* - emit `data-run-started`
|
|
12
|
+
* Inputs are NOT materialized here: the workspace tree's `data/` inputs must
|
|
13
|
+
* already be populated by the embedder before the run is triggered — the
|
|
14
|
+
* workflow neither downloads nor stages input data.
|
|
15
|
+
* The run authorization is minted at the async edge (`executePlan` / TA
|
|
16
|
+
* trigger / `runDataProfile`) and rides in `input.runSession` — the
|
|
17
|
+
* workflow body never mints, never reads the JWT back from `cortex_runs`.
|
|
18
|
+
* 2. Scheduler loop
|
|
19
|
+
* - maintain `completedSet` + `inFlightHandles`
|
|
20
|
+
* - dispatch every `scheduleReady(plan, completedSet, startedSet)` via
|
|
21
|
+
* `DBOS.startWorkflow` with deterministic child id
|
|
22
|
+
* `"${parent.workflowID}-${N}"` (N is the step's stable index)
|
|
23
|
+
* - each child input is `forStep(input.runSession, stepId)` for the
|
|
24
|
+
* session field
|
|
25
|
+
* - emit `data-dag-state` (reconciling by id) on every dispatch +
|
|
26
|
+
* completion
|
|
27
|
+
* - await child results via `getResult` (these are themselves cached
|
|
28
|
+
* in DBOS, so parent recovery does NOT re-run completed children)
|
|
29
|
+
* 3. Fail-fast cascade
|
|
30
|
+
* - on the first non-resumable child failure (or on external parent
|
|
31
|
+
* cancel): stop scheduling, then
|
|
32
|
+
* `Promise.allSettled(handles.map(h => DBOS.cancelWorkflow(h.workflowID)))`
|
|
33
|
+
* - each cancelled child tears down its sandbox in its own terminal path
|
|
34
|
+
* 4. Pause cascade (402)
|
|
35
|
+
* - on a child cancelling itself with `budget_exceeded`: cancel siblings
|
|
36
|
+
* then self-cancel the parent to `CANCELLED` (NOT `ERROR` — ERROR
|
|
37
|
+
* isn't resumable; NOTES #3)
|
|
38
|
+
* - the analysis flips to `suspended_insufficient_funds` in
|
|
39
|
+
* `collectAndComplete`. The paused parent lands in `CANCELLED`, a
|
|
40
|
+
* durably reschedulable state; re-driving it after a top-up is a
|
|
41
|
+
* future enhancement, not yet wired here.
|
|
42
|
+
* 5. `synthesizeFindings` (single sequential block, no sandbox)
|
|
43
|
+
* 6. `collectAndComplete` (terminal — runs on ALL paths)
|
|
44
|
+
* - determine final status from completed/cancelled/failed counts
|
|
45
|
+
* - update `cortex_runs.status` + `error`
|
|
46
|
+
* - close running charge with matching reason
|
|
47
|
+
* - revoke run authorization via the injected `runAuthorizer` seam
|
|
48
|
+
* - emit terminal stream part
|
|
49
|
+
* - WRITES NOTHING to the conversation thread (results are pull-only
|
|
50
|
+
* via `inspectRun`)
|
|
51
|
+
*/
|
|
52
|
+
import { DBOS } from "@dbos-inc/dbos-sdk";
|
|
53
|
+
import { mkdir } from "node:fs/promises";
|
|
54
|
+
import { join } from "node:path";
|
|
55
|
+
import { forStep } from "../auth/types.js";
|
|
56
|
+
import { unwrapOrThrow } from "../lib/result.js";
|
|
57
|
+
import { RunDedupCollisionError, countArtifactsForRun, queryActiveRun, seedStepExecutions, suspendAnalysis as suspendAnalysisQuery, sweepPendingStepExecutions, updateRunStatus, } from "../state/index.js";
|
|
58
|
+
import { isBudgetExceeded } from "../loop/budget-exceeded.js";
|
|
59
|
+
import { runDir } from "../workspace/paths.js";
|
|
60
|
+
import { isChatDataPart } from "../sandbox/sandbox-step-translate.js";
|
|
61
|
+
import { synthesizeRun } from "../app/synthesize-run.js";
|
|
62
|
+
import { computeTopologicalLevels, scheduleReady, validatePlanDag } from "./execute-analysis-scheduler.js";
|
|
63
|
+
import { recordCancelledChild } from "./metrics.js";
|
|
64
|
+
import { BUDGET_EXCEEDED_TOPIC } from "./sandbox-step.js";
|
|
65
|
+
// ── In-body orchestration helpers ────────────────────────────────────
|
|
66
|
+
/** Emit a chat data part on the parent's DBOS stream. */
|
|
67
|
+
function emitStreamPart(part) {
|
|
68
|
+
return DBOS.writeStream("events", part);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Fire the optional run-lifecycle provenance observer, isolating a throwing
|
|
72
|
+
* host observer from the workflow. The harness is host-agnostic and cannot
|
|
73
|
+
* assume the callback is total; a defect in it must log loudly and be
|
|
74
|
+
* swallowed, never corrupt run state — integrity enforcement lives at the
|
|
75
|
+
* host's own ledger, not here.
|
|
76
|
+
*/
|
|
77
|
+
function emitProvenanceGuarded(deps, event) {
|
|
78
|
+
if (!deps.emitProvenance)
|
|
79
|
+
return;
|
|
80
|
+
try {
|
|
81
|
+
deps.emitProvenance(event);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
console.error(`[executeAnalysis] emitProvenance threw for run ${event.runId} (event=${event.type}):`, err);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Project the sandbox-step input handed to each child. The parent owns the
|
|
89
|
+
* level computation; the rest comes from `ExecuteAnalysisInput`. The body
|
|
90
|
+
* fills in `runSession` via `forStep` after this returns. Exported for the
|
|
91
|
+
* projection/timeout-propagation tests.
|
|
92
|
+
*/
|
|
93
|
+
export function buildChildInput(args) {
|
|
94
|
+
const { input, stepId, level, runId, workflowId } = args;
|
|
95
|
+
const resources = input.resourcesByStepId[stepId];
|
|
96
|
+
if (!resources) {
|
|
97
|
+
throw new Error(`executeAnalysis: step "${stepId}" missing from resourcesByStepId — every step must declare resources`);
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
analysisId: input.analysisId,
|
|
101
|
+
runId,
|
|
102
|
+
stepId,
|
|
103
|
+
agentId: input.agentByStepId[stepId] ?? "scientific-executor",
|
|
104
|
+
level,
|
|
105
|
+
prompt: input.promptByStepId[stepId] ?? "",
|
|
106
|
+
parentWorkflowId: workflowId,
|
|
107
|
+
resources,
|
|
108
|
+
timeoutSeconds: input.timeoutByStepId?.[stepId],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Run-level literature-grounded synthesis (no sandbox). Returns the
|
|
113
|
+
* quick-display findings for the run-completed card; empty when synthesis is
|
|
114
|
+
* skipped or produced no synthesizable content. A genuine failure re-throws
|
|
115
|
+
* inside the caller's `DBOS.runStep`, failing the run (D10). Exported so
|
|
116
|
+
* integration tests can drive the wired synthesis without a full parent body.
|
|
117
|
+
*/
|
|
118
|
+
export function synthesizeFindings(args) {
|
|
119
|
+
const { analysisId, runId, completedSteps, session, deps } = args;
|
|
120
|
+
const emit = (event) => {
|
|
121
|
+
const part = isChatDataPart(event)
|
|
122
|
+
? event
|
|
123
|
+
: {
|
|
124
|
+
type: "data-loop-event",
|
|
125
|
+
data: { stepId: "synthesis", event },
|
|
126
|
+
};
|
|
127
|
+
return DBOS.writeStream("events", part);
|
|
128
|
+
};
|
|
129
|
+
return synthesizeRun({
|
|
130
|
+
pool: deps.pool,
|
|
131
|
+
provider: deps.provider,
|
|
132
|
+
embedding: deps.embedding,
|
|
133
|
+
resolveWorkspaceRoot: deps.resolveWorkspaceRoot,
|
|
134
|
+
synthesisModel: deps.synthesisModel,
|
|
135
|
+
bioKeys: deps.bioKeys,
|
|
136
|
+
}, {
|
|
137
|
+
analysisId,
|
|
138
|
+
runId,
|
|
139
|
+
completedSteps,
|
|
140
|
+
session,
|
|
141
|
+
emit,
|
|
142
|
+
onProgress: (phase, activity, extra = {}) => DBOS.writeStream("events", {
|
|
143
|
+
type: "data-synthesis-progress",
|
|
144
|
+
id: `synthesis-progress-${runId}`,
|
|
145
|
+
runId,
|
|
146
|
+
phase,
|
|
147
|
+
activity,
|
|
148
|
+
...extra,
|
|
149
|
+
}),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
// ── Workflow registration ────────────────────────────────────────────
|
|
153
|
+
/**
|
|
154
|
+
* Register the executeAnalysis parent workflow with DBOS. Caller is
|
|
155
|
+
* responsible for setting `workflowID = runId` via
|
|
156
|
+
* `DBOS.startWorkflow(_, { workflowID })` — the body assumes that contract
|
|
157
|
+
* and uses `DBOS.workflowID` as the source of truth.
|
|
158
|
+
*/
|
|
159
|
+
export function registerExecuteAnalysis(deps) {
|
|
160
|
+
return DBOS.registerWorkflow(async (input) => {
|
|
161
|
+
return runExecuteAnalysisBody(input, deps);
|
|
162
|
+
}, { name: "executeAnalysis" });
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Body extracted so tests can drive it without registering a workflow
|
|
166
|
+
* (the DBOS calls inside still rely on a workflow context being present).
|
|
167
|
+
*/
|
|
168
|
+
export async function runExecuteAnalysisBody(input, deps) {
|
|
169
|
+
// (0) Validate up-front — no side effects yet, so a malformed plan does
|
|
170
|
+
// NOT leak a runId, run authorization, or running charge.
|
|
171
|
+
validatePlanDag(input.steps);
|
|
172
|
+
const levels = computeTopologicalLevels(input.steps);
|
|
173
|
+
// (1) validateAndInit — create the run dir + open the charge. Inputs are
|
|
174
|
+
// NOT materialized here: the embedder must have populated the workspace tree's
|
|
175
|
+
// `data/` before triggering (the workflow neither downloads nor stages). The
|
|
176
|
+
// `cortex_runs` row was inserted by `executePlan` at the async edge;
|
|
177
|
+
// the run authorization is already minted and rides in `input.runSession`.
|
|
178
|
+
const runId = input.runSession.runFrame.runId;
|
|
179
|
+
const workflowId = runId;
|
|
180
|
+
const init = await validateAndInit(input, runId, deps);
|
|
181
|
+
if (init.kind === "joined-existing") {
|
|
182
|
+
return {
|
|
183
|
+
runId: init.runId,
|
|
184
|
+
workflowId: init.runId,
|
|
185
|
+
status: "running",
|
|
186
|
+
completedSteps: [],
|
|
187
|
+
failedSteps: [],
|
|
188
|
+
canceledSteps: [],
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
// Seed the full DAG as `pending` rows so ledger readers see every step from
|
|
192
|
+
// run start (honest done/total), not just the ones that began executing.
|
|
193
|
+
// The seed's DO NOTHING conflict action makes this replay-safe; the agent
|
|
194
|
+
// fallback mirrors `buildChildInput` so seed and mark-running agree on the
|
|
195
|
+
// row a step's child later upserts.
|
|
196
|
+
await DBOS.runStep(async () => {
|
|
197
|
+
unwrapOrThrow(await seedStepExecutions(deps.pool, input.steps.map((step) => ({
|
|
198
|
+
runId,
|
|
199
|
+
stepId: step.id,
|
|
200
|
+
analysisId: input.analysisId,
|
|
201
|
+
wave: levels.get(step.id) ?? 0,
|
|
202
|
+
agentId: input.agentByStepId[step.id] ?? "scientific-executor",
|
|
203
|
+
}))));
|
|
204
|
+
}, { name: "seed-step-executions" });
|
|
205
|
+
// One checkpointed clock read stamps the run's start; the terminal read in
|
|
206
|
+
// `collectAndComplete` subtracts it for the true run span. Checkpointed →
|
|
207
|
+
// replay-stable (see `RunProvenanceEvent`).
|
|
208
|
+
const startedAtMs = await DBOS.now();
|
|
209
|
+
await emitStreamPart({
|
|
210
|
+
type: "data-run-started",
|
|
211
|
+
runId,
|
|
212
|
+
planSummary: input.planSummary,
|
|
213
|
+
stepCount: input.steps.length,
|
|
214
|
+
});
|
|
215
|
+
emitProvenanceGuarded(deps, {
|
|
216
|
+
type: "run_started",
|
|
217
|
+
analysisId: input.analysisId,
|
|
218
|
+
runId,
|
|
219
|
+
planSummary: input.planSummary,
|
|
220
|
+
stepCount: input.steps.length,
|
|
221
|
+
atMs: startedAtMs,
|
|
222
|
+
});
|
|
223
|
+
// (2-4) Scheduler loop + fail-fast + pause cascade.
|
|
224
|
+
const final = await runSchedulerLoop({
|
|
225
|
+
input,
|
|
226
|
+
runId,
|
|
227
|
+
workflowId,
|
|
228
|
+
levels,
|
|
229
|
+
deps,
|
|
230
|
+
});
|
|
231
|
+
// (5) Run-level synthesis — a genuine failure must fail the run (D10). The
|
|
232
|
+
// honest non-fatal outcomes (report_blocker / no-summaries) resolve normally
|
|
233
|
+
// inside the dep; only real exceptions reach here. We capture the error,
|
|
234
|
+
// still run the terminal block (close charge + revoke run authorization), and re-throw
|
|
235
|
+
// after so the workflow record goes to ERROR.
|
|
236
|
+
let synthesisError = null;
|
|
237
|
+
let synthesisFindings = [];
|
|
238
|
+
const synthesisEnabled = deps.synthesisEnabled ?? true;
|
|
239
|
+
if (synthesisEnabled && final.completed.size > 0) {
|
|
240
|
+
try {
|
|
241
|
+
const synthOut = await DBOS.runStep(() => synthesizeFindings({
|
|
242
|
+
analysisId: input.analysisId,
|
|
243
|
+
runId,
|
|
244
|
+
completedSteps: [...final.completed],
|
|
245
|
+
session: input.runSession,
|
|
246
|
+
deps,
|
|
247
|
+
}), { name: "synthesize-findings" });
|
|
248
|
+
synthesisFindings = synthOut.findings;
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
synthesisError = err;
|
|
252
|
+
console.error(`[executeAnalysis] synthesizeFindings failed for run ${runId} — failing the run:`, err instanceof Error ? err.message : err);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// (6) collectAndComplete — terminal block. Runs on EVERY path. When synthesis
|
|
256
|
+
// failed, force a failed terminal status so the charge/run-authorization close correctly
|
|
257
|
+
// and the run row + stream report the failure before we re-throw.
|
|
258
|
+
const result = await collectAndComplete({
|
|
259
|
+
input,
|
|
260
|
+
runId,
|
|
261
|
+
workflowId,
|
|
262
|
+
startedAtMs,
|
|
263
|
+
completed: final.completed,
|
|
264
|
+
failed: final.failed,
|
|
265
|
+
canceled: final.canceled,
|
|
266
|
+
budgetExceeded: final.budgetExceeded,
|
|
267
|
+
failureReason: synthesisError
|
|
268
|
+
? synthesisError instanceof Error
|
|
269
|
+
? `synthesis-failed: ${synthesisError.message}`
|
|
270
|
+
: "synthesis-failed"
|
|
271
|
+
: final.failureReason,
|
|
272
|
+
forceFailed: synthesisError !== null,
|
|
273
|
+
findings: synthesisFindings,
|
|
274
|
+
deps,
|
|
275
|
+
});
|
|
276
|
+
// Synthesis failure takes priority over the budget-exceeded cascade: a run
|
|
277
|
+
// whose synthesis threw is definitively failed (ERROR), not a resumable
|
|
278
|
+
// budget pause. Only self-cancel when synthesis succeeded.
|
|
279
|
+
if (final.budgetExceeded && synthesisError === null) {
|
|
280
|
+
await DBOS.cancelWorkflow(DBOS.workflowID);
|
|
281
|
+
await DBOS.runStep(async () => undefined, {
|
|
282
|
+
name: "self-cancel-budget-exceeded",
|
|
283
|
+
});
|
|
284
|
+
// Unreachable — the runStep above raises DBOSWorkflowCancelledError.
|
|
285
|
+
}
|
|
286
|
+
// Re-throw after the terminal block so the workflow record goes to ERROR.
|
|
287
|
+
if (synthesisError !== null)
|
|
288
|
+
throw synthesisError;
|
|
289
|
+
return result;
|
|
290
|
+
}
|
|
291
|
+
async function validateAndInit(input, runId, deps) {
|
|
292
|
+
// The cortex_runs row already exists (inserted by `executePlan`). Sanity-
|
|
293
|
+
// check that no other active run for the same plan won the race — the
|
|
294
|
+
// partial-unique index would have rejected the insert if so, so this is
|
|
295
|
+
// defense-in-depth only.
|
|
296
|
+
try {
|
|
297
|
+
const existing = unwrapOrThrow(await queryActiveRun(deps.pool, input.analysisId, input.planId));
|
|
298
|
+
if (existing && existing.runId !== runId) {
|
|
299
|
+
return { kind: "joined-existing", runId: existing.runId };
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch (err) {
|
|
303
|
+
if (err instanceof RunDedupCollisionError) {
|
|
304
|
+
const existing = unwrapOrThrow(await queryActiveRun(deps.pool, input.analysisId, input.planId));
|
|
305
|
+
if (existing)
|
|
306
|
+
return { kind: "joined-existing", runId: existing.runId };
|
|
307
|
+
}
|
|
308
|
+
throw err;
|
|
309
|
+
}
|
|
310
|
+
await DBOS.runStep(async () => {
|
|
311
|
+
// A resolver throw here (unknown analysis, unresolvable root) fails the
|
|
312
|
+
// step durably — exactly the contract the workspace-root-resolution spec
|
|
313
|
+
// requires of failures inside DBOS bodies.
|
|
314
|
+
await mkdir(join(deps.resolveWorkspaceRoot(input.analysisId), runDir(runId)), {
|
|
315
|
+
recursive: true,
|
|
316
|
+
});
|
|
317
|
+
}, { name: "init-run-filesystem" });
|
|
318
|
+
await DBOS.runStep(() => deps.runCharge.open({
|
|
319
|
+
analysisId: input.analysisId,
|
|
320
|
+
runId,
|
|
321
|
+
session: input.runSession,
|
|
322
|
+
}), { name: "open-running-charge" });
|
|
323
|
+
return { kind: "fresh" };
|
|
324
|
+
}
|
|
325
|
+
async function runSchedulerLoop(args) {
|
|
326
|
+
const { input, runId, workflowId, levels, deps } = args;
|
|
327
|
+
const completed = new Set();
|
|
328
|
+
const failed = new Set();
|
|
329
|
+
const canceled = new Set();
|
|
330
|
+
const inFlight = new Map();
|
|
331
|
+
const budgetExceededChildIds = new Set();
|
|
332
|
+
// Child workflow ids the parent itself cancelled (fail-fast / budget cascade). Their `getResult`
|
|
333
|
+
// rejects with a DBOS cancellation error and lands in the settlement error branch — but the step was
|
|
334
|
+
// CANCELED by us, not failed on its own merits. Keyed here (deterministic: `cancelInFlight` runs the
|
|
335
|
+
// same way on a replay) so that branch records it as canceled everywhere, matching how a child that
|
|
336
|
+
// returns a graceful `{status:"canceled"}` is already handled.
|
|
337
|
+
const canceledByParent = new Set();
|
|
338
|
+
const stepRuntime = new Map();
|
|
339
|
+
for (const step of input.steps) {
|
|
340
|
+
stepRuntime.set(step.id, { status: "pending" });
|
|
341
|
+
}
|
|
342
|
+
let failFast = false;
|
|
343
|
+
let budgetExceeded = false;
|
|
344
|
+
let failureReason = null;
|
|
345
|
+
const stepIndexById = new Map(input.steps.map((s, i) => [s.id, i]));
|
|
346
|
+
const emitDagSnapshot = async () => {
|
|
347
|
+
await emitStreamPart({
|
|
348
|
+
type: "data-dag-state",
|
|
349
|
+
id: `dag-${runId}`,
|
|
350
|
+
runId,
|
|
351
|
+
steps: input.steps.map((s) => {
|
|
352
|
+
const rt = stepRuntime.get(s.id);
|
|
353
|
+
const entry = {
|
|
354
|
+
id: s.id,
|
|
355
|
+
name: s.id,
|
|
356
|
+
agent: input.agentByStepId[s.id] ?? "unknown",
|
|
357
|
+
status: rt.status,
|
|
358
|
+
level: levels.get(s.id) ?? 0,
|
|
359
|
+
dependsOn: [...s.depends_on],
|
|
360
|
+
};
|
|
361
|
+
if (rt.durationMs !== undefined)
|
|
362
|
+
entry.durationMs = rt.durationMs;
|
|
363
|
+
if (rt.error !== undefined)
|
|
364
|
+
entry.error = rt.error;
|
|
365
|
+
return entry;
|
|
366
|
+
}),
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
const dbosParentId = DBOS.workflowID ?? workflowId;
|
|
370
|
+
const dispatchReady = async () => {
|
|
371
|
+
if (failFast)
|
|
372
|
+
return;
|
|
373
|
+
const inFlightStepIds = new Set([...inFlight.values()].map((h) => h.stepId));
|
|
374
|
+
let admit;
|
|
375
|
+
let queuedChanged = false;
|
|
376
|
+
if (input.budget) {
|
|
377
|
+
const scheduled = scheduleReady(input.steps, completed, inFlightStepIds, {
|
|
378
|
+
budget: input.budget,
|
|
379
|
+
resourcesByStepId: input.resourcesByStepId,
|
|
380
|
+
});
|
|
381
|
+
if (scheduled.neverFits.length > 0) {
|
|
382
|
+
// An over-budget step can never be admitted — plan-time validation
|
|
383
|
+
// makes this unreachable for new plans; stored plans fail loudly
|
|
384
|
+
// instead of waiting forever. Standard fail-fast follows.
|
|
385
|
+
for (const stepId of scheduled.neverFits) {
|
|
386
|
+
const r = input.resourcesByStepId[stepId];
|
|
387
|
+
const declared = r ? `${r.cpu} CPU / ${r.memoryGb} GB` : "undeclared";
|
|
388
|
+
failed.add(stepId);
|
|
389
|
+
stepRuntime.set(stepId, {
|
|
390
|
+
status: "failed",
|
|
391
|
+
error: `step resources (${declared}) exceed the machine budget (${input.budget.cpu} CPU / ${input.budget.memoryGb} GB)`,
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
failFast = true;
|
|
395
|
+
failureReason = `step "${scheduled.neverFits[0]}" exceeds the machine resource budget`;
|
|
396
|
+
await cancelInFlight(inFlight, "fail_fast", canceledByParent);
|
|
397
|
+
await emitDagSnapshot();
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
for (const stepId of scheduled.heldForCapacity) {
|
|
401
|
+
if (stepRuntime.get(stepId).status !== "queued") {
|
|
402
|
+
stepRuntime.set(stepId, { status: "queued" });
|
|
403
|
+
queuedChanged = true;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
admit = scheduled.admit;
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
admit = scheduleReady(input.steps, completed, inFlightStepIds);
|
|
410
|
+
}
|
|
411
|
+
if (admit.length === 0) {
|
|
412
|
+
if (queuedChanged)
|
|
413
|
+
await emitDagSnapshot();
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
for (const stepId of admit) {
|
|
417
|
+
const idx = stepIndexById.get(stepId);
|
|
418
|
+
const childWorkflowId = `${workflowId}-${idx}`;
|
|
419
|
+
const baseChildInput = buildChildInput({
|
|
420
|
+
input,
|
|
421
|
+
stepId,
|
|
422
|
+
level: levels.get(stepId) ?? 0,
|
|
423
|
+
runId,
|
|
424
|
+
workflowId,
|
|
425
|
+
});
|
|
426
|
+
const childInput = {
|
|
427
|
+
...baseChildInput,
|
|
428
|
+
parentWorkflowId: dbosParentId,
|
|
429
|
+
runSession: forStep(input.runSession, stepId),
|
|
430
|
+
};
|
|
431
|
+
const handle = (await DBOS.startWorkflow(deps.sandboxStepCallable, {
|
|
432
|
+
workflowID: childWorkflowId,
|
|
433
|
+
})(childInput));
|
|
434
|
+
inFlight.set(childWorkflowId, { stepId, handle });
|
|
435
|
+
stepRuntime.set(stepId, { status: "running" });
|
|
436
|
+
}
|
|
437
|
+
await emitDagSnapshot();
|
|
438
|
+
};
|
|
439
|
+
await dispatchReady();
|
|
440
|
+
while (inFlight.size > 0) {
|
|
441
|
+
// `waitFirst` checkpoints the "who finished first" decision (see the harness-durable-runtime spec), so
|
|
442
|
+
// the winning workflow id replays identically — unlike `Promise.race` over
|
|
443
|
+
// `getResult`, whose uncheckpointed winner would reorder the downstream
|
|
444
|
+
// function-ID-consuming ops and diverge the counter on replay.
|
|
445
|
+
const winner = await DBOS.waitFirst([...inFlight.values()].map((e) => e.handle));
|
|
446
|
+
const childId = winner.workflowID;
|
|
447
|
+
const entry = inFlight.get(childId);
|
|
448
|
+
inFlight.delete(childId);
|
|
449
|
+
let settled;
|
|
450
|
+
try {
|
|
451
|
+
const result = await entry.handle.getResult();
|
|
452
|
+
settled = { childId, stepId: entry.stepId, kind: "result", result };
|
|
453
|
+
}
|
|
454
|
+
catch (err) {
|
|
455
|
+
settled = { childId, stepId: entry.stepId, kind: "error", err };
|
|
456
|
+
}
|
|
457
|
+
await drainBudgetExceededNotifications(budgetExceededChildIds);
|
|
458
|
+
const childWasBudgetExceeded = budgetExceededChildIds.has(settled.childId);
|
|
459
|
+
// Terminal step status + duration for the provenance emission below. Every
|
|
460
|
+
// settlement branch assigns both, so the emission fires exactly once per
|
|
461
|
+
// settled child with the mapped status.
|
|
462
|
+
let stepStatus;
|
|
463
|
+
let stepDurationMs;
|
|
464
|
+
if (settled.kind === "result") {
|
|
465
|
+
const r = settled.result;
|
|
466
|
+
if (r.status === "complete") {
|
|
467
|
+
completed.add(settled.stepId);
|
|
468
|
+
stepRuntime.set(settled.stepId, {
|
|
469
|
+
status: "completed",
|
|
470
|
+
durationMs: r.durationMs ?? undefined,
|
|
471
|
+
});
|
|
472
|
+
stepStatus = "completed";
|
|
473
|
+
stepDurationMs = r.durationMs ?? undefined;
|
|
474
|
+
await emitDagSnapshot();
|
|
475
|
+
await dispatchReady();
|
|
476
|
+
}
|
|
477
|
+
else if (r.status === "canceled") {
|
|
478
|
+
canceled.add(settled.stepId);
|
|
479
|
+
const isBudgetCancel = childWasBudgetExceeded || r.error === "budget_exceeded";
|
|
480
|
+
if (isBudgetCancel && !budgetExceeded) {
|
|
481
|
+
budgetExceeded = true;
|
|
482
|
+
failFast = true;
|
|
483
|
+
failureReason = "budget_exceeded";
|
|
484
|
+
await cancelInFlight(inFlight, "budget_exceeded", canceledByParent);
|
|
485
|
+
}
|
|
486
|
+
stepRuntime.set(settled.stepId, {
|
|
487
|
+
status: "failed",
|
|
488
|
+
durationMs: r.durationMs ?? undefined,
|
|
489
|
+
error: r.error ?? "canceled",
|
|
490
|
+
});
|
|
491
|
+
stepStatus = "canceled";
|
|
492
|
+
stepDurationMs = r.durationMs ?? undefined;
|
|
493
|
+
await emitDagSnapshot();
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
// failed or blocked — a blocker (see the harness-sandbox-agents spec) fails fast exactly like a
|
|
497
|
+
// failure: the step declared it cannot deliver, so its dependents can
|
|
498
|
+
// never run. Same cancel-siblings + stop-scheduling path.
|
|
499
|
+
failed.add(settled.stepId);
|
|
500
|
+
if (!failFast) {
|
|
501
|
+
failFast = true;
|
|
502
|
+
failureReason = r.error ?? (r.status === "blocked" ? "step_blocked" : "step_failed");
|
|
503
|
+
await cancelInFlight(inFlight, "fail_fast", canceledByParent);
|
|
504
|
+
}
|
|
505
|
+
stepRuntime.set(settled.stepId, {
|
|
506
|
+
status: "failed",
|
|
507
|
+
durationMs: r.durationMs ?? undefined,
|
|
508
|
+
error: r.error ?? (r.status === "blocked" ? "step_blocked" : "step_failed"),
|
|
509
|
+
});
|
|
510
|
+
stepStatus = "failed";
|
|
511
|
+
stepDurationMs = r.durationMs ?? undefined;
|
|
512
|
+
await emitDagSnapshot();
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
else if (canceledByParent.has(settled.childId)) {
|
|
516
|
+
// The child threw because the PARENT cancelled it (fail-fast / budget cascade), not because
|
|
517
|
+
// it failed on its own — its `getResult` rejects with a DBOS cancellation error. Record it as
|
|
518
|
+
// canceled, mirroring the graceful `{status:"canceled"}` branch above so the `canceled` set,
|
|
519
|
+
// the terminal result, and the `step_completed` provenance all agree. No failFast / cancel
|
|
520
|
+
// cascade here: the run is already failing fast (that is why this child was cancelled).
|
|
521
|
+
canceled.add(settled.stepId);
|
|
522
|
+
stepRuntime.set(settled.stepId, {
|
|
523
|
+
// `stepRuntime` (the DAG snapshot) has no canceled tier; the graceful-cancel branch above
|
|
524
|
+
// likewise renders canceled steps as "failed", so this stays consistent with it.
|
|
525
|
+
status: "failed",
|
|
526
|
+
error: settled.err instanceof Error ? settled.err.message : String(settled.err),
|
|
527
|
+
});
|
|
528
|
+
stepStatus = "canceled";
|
|
529
|
+
stepDurationMs = undefined;
|
|
530
|
+
await emitDagSnapshot();
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
failed.add(settled.stepId);
|
|
534
|
+
const cause = childWasBudgetExceeded || isBudgetExceeded(settled.err) ? "budget_exceeded" : "fail_fast";
|
|
535
|
+
if (cause === "budget_exceeded" && !budgetExceeded) {
|
|
536
|
+
budgetExceeded = true;
|
|
537
|
+
failFast = true;
|
|
538
|
+
failureReason = "budget_exceeded";
|
|
539
|
+
}
|
|
540
|
+
else if (!failFast) {
|
|
541
|
+
failFast = true;
|
|
542
|
+
failureReason = settled.err instanceof Error ? settled.err.message : String(settled.err);
|
|
543
|
+
}
|
|
544
|
+
await cancelInFlight(inFlight, cause, canceledByParent);
|
|
545
|
+
stepRuntime.set(settled.stepId, {
|
|
546
|
+
status: "failed",
|
|
547
|
+
error: settled.err instanceof Error ? settled.err.message : String(settled.err),
|
|
548
|
+
});
|
|
549
|
+
stepStatus = "failed";
|
|
550
|
+
// A child that settled by throwing carries no durable duration.
|
|
551
|
+
stepDurationMs = undefined;
|
|
552
|
+
await emitDagSnapshot();
|
|
553
|
+
}
|
|
554
|
+
// One `step_completed` provenance emission per settled child — this
|
|
555
|
+
// settlement loop is the only site that observes every executed step.
|
|
556
|
+
// Plain guarded call (NOT `DBOS.runStep`): body re-execution on recovery
|
|
557
|
+
// must re-fire it, and the checkpointed `DBOS.now()` read keeps the
|
|
558
|
+
// timestamp replay-stable. Never-dispatched steps reach no settlement, so
|
|
559
|
+
// they emit nothing by design.
|
|
560
|
+
const settledAtMs = await DBOS.now();
|
|
561
|
+
emitProvenanceGuarded(deps, {
|
|
562
|
+
type: "step_completed",
|
|
563
|
+
analysisId: input.analysisId,
|
|
564
|
+
runId,
|
|
565
|
+
stepId: settled.stepId,
|
|
566
|
+
status: stepStatus,
|
|
567
|
+
...(stepDurationMs !== undefined ? { durationMs: stepDurationMs } : {}),
|
|
568
|
+
atMs: settledAtMs,
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
await drainBudgetExceededNotifications(budgetExceededChildIds);
|
|
572
|
+
return { completed, failed, canceled, budgetExceeded, failureReason };
|
|
573
|
+
}
|
|
574
|
+
async function drainBudgetExceededNotifications(childIds) {
|
|
575
|
+
while (true) {
|
|
576
|
+
const msg = await DBOS.recv(BUDGET_EXCEEDED_TOPIC, 0);
|
|
577
|
+
if (!msg)
|
|
578
|
+
return;
|
|
579
|
+
childIds.add(msg.childWorkflowId);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
async function cancelInFlight(inFlight, cause, canceledByParent) {
|
|
583
|
+
const ids = [...inFlight.keys()];
|
|
584
|
+
// Record every id BEFORE the cancel so the settlement loop classifies the resulting
|
|
585
|
+
// DBOS-cancellation rejection as canceled rather than failed (see `canceledByParent`).
|
|
586
|
+
for (const childId of ids)
|
|
587
|
+
canceledByParent.add(childId);
|
|
588
|
+
await Promise.allSettled(ids.map((childId) => DBOS.cancelWorkflow(childId)));
|
|
589
|
+
for (let i = 0; i < ids.length; i++) {
|
|
590
|
+
recordCancelledChild({ cause });
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
async function collectAndComplete(args) {
|
|
594
|
+
const { input, runId, workflowId, startedAtMs, completed, failed, canceled, budgetExceeded, failureReason, forceFailed, deps } = args;
|
|
595
|
+
const status = forceFailed
|
|
596
|
+
? "failed"
|
|
597
|
+
: deriveFinalStatus({
|
|
598
|
+
totalSteps: input.steps.length,
|
|
599
|
+
completed,
|
|
600
|
+
failed,
|
|
601
|
+
canceled,
|
|
602
|
+
budgetExceeded,
|
|
603
|
+
});
|
|
604
|
+
const chargeReason = status === "completed" || status === "partial" ? "ok" : status === "failed" ? "error" : budgetExceeded ? "budget_exceeded" : "canceled";
|
|
605
|
+
const revokeReason = status === "completed" || status === "partial"
|
|
606
|
+
? "workflow-completed"
|
|
607
|
+
: status === "failed"
|
|
608
|
+
? "workflow-failed"
|
|
609
|
+
: budgetExceeded
|
|
610
|
+
? "workflow-suspended"
|
|
611
|
+
: "workflow-canceled";
|
|
612
|
+
// Terminal clock read + run-completion provenance, emitted BEFORE the `cortex_runs`
|
|
613
|
+
// status write below — and thus before any of the terminal cleanup steps. The CLI
|
|
614
|
+
// watches the run by POLLING that row (`run.ts` `waitForRunTerminal`) and shuts down
|
|
615
|
+
// the instant it leaves `running`, flushing provenance and then `process.exit()`ing;
|
|
616
|
+
// emitting the record only after the status write races that shutdown and can drop
|
|
617
|
+
// the run's terminal provenance entirely. Emitting first makes the record dirty
|
|
618
|
+
// (synchronously, via the bus) before the row can be observed terminal, so the CLI's
|
|
619
|
+
// flush always captures it. Not step-wrapped — a DBOS recovery replay must re-fire it;
|
|
620
|
+
// `DBOS.now()` is checkpointed, so the span stays replay-stable (see `RunProvenanceEvent`).
|
|
621
|
+
// The duration measures from the `run_started` read threaded in as `startedAtMs`.
|
|
622
|
+
const terminalAtMs = await DBOS.now();
|
|
623
|
+
emitProvenanceGuarded(deps, {
|
|
624
|
+
type: "run_completed",
|
|
625
|
+
analysisId: input.analysisId,
|
|
626
|
+
runId,
|
|
627
|
+
status,
|
|
628
|
+
atMs: terminalAtMs,
|
|
629
|
+
durationMs: terminalAtMs - startedAtMs,
|
|
630
|
+
});
|
|
631
|
+
try {
|
|
632
|
+
await DBOS.runStep(async () => {
|
|
633
|
+
unwrapOrThrow(await updateRunStatus(deps.pool, runId, status, failureReason ?? (status === "canceled" && !budgetExceeded ? "external_cancel" : null)));
|
|
634
|
+
}, { name: "persist-final-status" });
|
|
635
|
+
}
|
|
636
|
+
catch (err) {
|
|
637
|
+
console.error(`[executeAnalysis] persist-final-status failed for run ${runId} (status=${status}):`, err);
|
|
638
|
+
}
|
|
639
|
+
// Sweep never-started steps to `skipped` — but ONLY on genuinely-terminal
|
|
640
|
+
// paths. The gate is the BRANCH, not the written run status: the resumable
|
|
641
|
+
// 402 pause below also writes "canceled", yet its pending rows must survive
|
|
642
|
+
// for the resumed workflow to execute. Log-don't-rollback, like every other
|
|
643
|
+
// finalisation step here.
|
|
644
|
+
if (!(budgetExceeded && !forceFailed)) {
|
|
645
|
+
try {
|
|
646
|
+
await DBOS.runStep(async () => {
|
|
647
|
+
unwrapOrThrow(await sweepPendingStepExecutions(deps.pool, runId));
|
|
648
|
+
}, { name: "sweep-pending-steps" });
|
|
649
|
+
}
|
|
650
|
+
catch (err) {
|
|
651
|
+
console.error(`[executeAnalysis] sweep-pending-steps failed for run ${runId}:`, err);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
// A forced failure (synthesis threw) is terminal, not a resumable budget
|
|
655
|
+
// pause — never suspend it, even when the budget was also exceeded.
|
|
656
|
+
if (budgetExceeded && !forceFailed) {
|
|
657
|
+
try {
|
|
658
|
+
await DBOS.runStep(async () => {
|
|
659
|
+
unwrapOrThrow(await suspendAnalysisQuery(deps.pool, input.analysisId));
|
|
660
|
+
}, { name: "suspend-analysis" });
|
|
661
|
+
}
|
|
662
|
+
catch (err) {
|
|
663
|
+
console.error(`[executeAnalysis] suspend-analysis failed for run ${runId}:`, err);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
try {
|
|
667
|
+
await DBOS.runStep(() => deps.runCharge.close({
|
|
668
|
+
analysisId: input.analysisId,
|
|
669
|
+
runId,
|
|
670
|
+
reason: chargeReason,
|
|
671
|
+
session: input.runSession,
|
|
672
|
+
}), { name: "close-running-charge" });
|
|
673
|
+
}
|
|
674
|
+
catch (err) {
|
|
675
|
+
console.error(`[executeAnalysis] closeRunningCharge failed for run ${runId} (reason=${chargeReason}):`, err);
|
|
676
|
+
}
|
|
677
|
+
// Revoke the run authorization for the terminal run state. Ownership
|
|
678
|
+
// defaults to true for inputs persisted before the field existed (a
|
|
679
|
+
// workflow recovered across this deploy) — those were always Cortex-owned.
|
|
680
|
+
const authorization = {
|
|
681
|
+
runSession: input.runSession,
|
|
682
|
+
ownsMandate: input.ownsMandate ?? true, // oss-core-managed-ok
|
|
683
|
+
};
|
|
684
|
+
try {
|
|
685
|
+
await DBOS.runStep(() => deps.runAuthorizer.revoke(authorization, revokeReason), { name: "revoke-run-auth" });
|
|
686
|
+
}
|
|
687
|
+
catch (err) {
|
|
688
|
+
console.error(`[executeAnalysis] revokeRunAuthorization failed for run ${runId} (reason=${revokeReason}):`, err);
|
|
689
|
+
}
|
|
690
|
+
// The `run_completed` provenance was already emitted above (before the status write, to
|
|
691
|
+
// beat the CLI's poll-and-shutdown). These branches only fan out the UI stream part, whose
|
|
692
|
+
// completed/failed shapes genuinely differ — the provenance record does not.
|
|
693
|
+
if (status === "completed" || status === "partial") {
|
|
694
|
+
const artifactCount = await DBOS.runStep(() => countArtifactsForRun(deps.pool, input.analysisId, runId), { name: "count-run-artifacts" }).catch(() => 0);
|
|
695
|
+
await emitStreamPart({
|
|
696
|
+
type: "data-run-completed",
|
|
697
|
+
runId,
|
|
698
|
+
status,
|
|
699
|
+
completedSteps: completed.size,
|
|
700
|
+
totalSteps: input.steps.length,
|
|
701
|
+
artifactCount,
|
|
702
|
+
findings: args.findings.map((f) => ({
|
|
703
|
+
title: f.title,
|
|
704
|
+
confidence: f.confidence,
|
|
705
|
+
})),
|
|
706
|
+
...(status === "partial"
|
|
707
|
+
? {
|
|
708
|
+
note: `${completed.size} of ${input.steps.length} steps completed; results are partial.`,
|
|
709
|
+
}
|
|
710
|
+
: {}),
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
else {
|
|
714
|
+
await emitStreamPart({
|
|
715
|
+
type: "data-run-failed",
|
|
716
|
+
runId,
|
|
717
|
+
error: failureReason ?? (budgetExceeded ? "Run paused: insufficient budget" : "Run canceled before completion"),
|
|
718
|
+
...(budgetExceeded ? { reason: "budget_exceeded" } : {}),
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
return {
|
|
722
|
+
runId,
|
|
723
|
+
workflowId,
|
|
724
|
+
status,
|
|
725
|
+
completedSteps: [...completed],
|
|
726
|
+
failedSteps: [...failed],
|
|
727
|
+
canceledSteps: [...canceled],
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* `"running"` is excluded from the return: it is only the joined-existing
|
|
732
|
+
* trigger outcome, never a settled terminal status. Narrowing it away here lets
|
|
733
|
+
* the terminal `run_completed` provenance emission carry the terminal-only
|
|
734
|
+
* status vocabulary without a cast.
|
|
735
|
+
*/
|
|
736
|
+
function deriveFinalStatus(args) {
|
|
737
|
+
const { totalSteps, completed, failed, canceled, budgetExceeded } = args;
|
|
738
|
+
if (budgetExceeded)
|
|
739
|
+
return "canceled";
|
|
740
|
+
if (failed.size > 0) {
|
|
741
|
+
return completed.size > 0 ? "partial" : "failed";
|
|
742
|
+
}
|
|
743
|
+
if (canceled.size > 0)
|
|
744
|
+
return "canceled";
|
|
745
|
+
return completed.size === totalSteps ? "completed" : "partial";
|
|
746
|
+
}
|