@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,204 @@
|
|
|
1
|
+
import { jsonSchema, tool as aiTool } from "ai";
|
|
2
|
+
import { classifyProviderError } from "../providers/errors.js";
|
|
3
|
+
import { resultStep } from "./run-step.js";
|
|
4
|
+
import { isToolError } from "../tools/define-tool.js";
|
|
5
|
+
import { recordAgentRun } from "./metrics.js";
|
|
6
|
+
const TRUNCATED_PROSE_STEER = "Your previous reply was cut off at the output-token limit; continue concisely, or finish via your terminal tool.";
|
|
7
|
+
const TRUNCATED_TOOL_USE_ERROR = "Your previous tool call was cut off at the output-token limit and was not executed. Retry with a smaller payload, writing in incremental pieces.";
|
|
8
|
+
export const DEFAULT_STEP_NAME_FORMATTER = {
|
|
9
|
+
llm: (i) => `llm-${i}`,
|
|
10
|
+
tool: (name, id) => `tool-${name}-${id}`,
|
|
11
|
+
};
|
|
12
|
+
export async function runAgent(agent, initial, session, opts) {
|
|
13
|
+
const { provider, signal, emit, runStep } = opts;
|
|
14
|
+
const formatStepName = opts.formatStepName ?? DEFAULT_STEP_NAME_FORMATTER;
|
|
15
|
+
const isFatalLoopError = opts.isFatalLoopError ?? (() => false);
|
|
16
|
+
if (agent.tools.length > 0 && !provider.capabilities.toolCalling) {
|
|
17
|
+
throw new Error(`Provider/model cannot run tool-required agent "${agent.id}"`);
|
|
18
|
+
}
|
|
19
|
+
const messages = [...initial];
|
|
20
|
+
const source = {
|
|
21
|
+
agentId: session.provenance.agentId ?? agent.id,
|
|
22
|
+
callPath: session.provenance.callPath,
|
|
23
|
+
};
|
|
24
|
+
const toolsById = new Map(agent.tools.map((t) => [t.id, t]));
|
|
25
|
+
const toolDefs = Object.fromEntries(agent.tools.map((t) => [
|
|
26
|
+
t.id,
|
|
27
|
+
aiTool({
|
|
28
|
+
description: t.description,
|
|
29
|
+
inputSchema: jsonSchema(t.jsonSchema),
|
|
30
|
+
}),
|
|
31
|
+
]));
|
|
32
|
+
const toolCtx = (tu) => ({
|
|
33
|
+
session,
|
|
34
|
+
signal,
|
|
35
|
+
emit,
|
|
36
|
+
runStep: (name, fn) => runStep(`${formatStepName.tool(tu.toolName, tu.toolCallId)}:${name}`, fn),
|
|
37
|
+
});
|
|
38
|
+
let iterations = 0;
|
|
39
|
+
let truncationRecoveries = 0;
|
|
40
|
+
for (let i = 0; i < agent.maxIterations; i++) {
|
|
41
|
+
iterations = i + 1;
|
|
42
|
+
const request = {
|
|
43
|
+
system: agent.systemPrompt,
|
|
44
|
+
messages,
|
|
45
|
+
tools: toolDefs,
|
|
46
|
+
};
|
|
47
|
+
const reply = await resultStep(runStep)(formatStepName.llm(i), () => provider.chat(request, session, signal));
|
|
48
|
+
messages.push(reply.message);
|
|
49
|
+
const toolCalls = toolCallParts(reply.message);
|
|
50
|
+
if (reply.finishReason === "length") {
|
|
51
|
+
truncationRecoveries++;
|
|
52
|
+
await emit({ type: "iteration", source, index: i, final: false });
|
|
53
|
+
if (toolCalls.length === 0) {
|
|
54
|
+
messages.push({ role: "user", content: TRUNCATED_PROSE_STEER });
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const trailing = toolCalls[toolCalls.length - 1];
|
|
58
|
+
const earlier = toolCalls.slice(0, -1);
|
|
59
|
+
for (const tu of earlier) {
|
|
60
|
+
await emit({ type: "tool-started", source, toolUseId: tu.toolCallId, name: tu.toolName, input: tu.input });
|
|
61
|
+
}
|
|
62
|
+
const results = await dispatchTools(earlier, toolsById, toolCtx, isFatalLoopError, runStep, formatStepName.tool);
|
|
63
|
+
for (let idx = 0; idx < earlier.length; idx++) {
|
|
64
|
+
const tu = earlier[idx];
|
|
65
|
+
await emit({
|
|
66
|
+
type: "tool-finished",
|
|
67
|
+
source,
|
|
68
|
+
toolUseId: tu.toolCallId,
|
|
69
|
+
name: tu.toolName,
|
|
70
|
+
isError: isErrorOutput(results[idx]),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
results.push(errorResult(trailing, TRUNCATED_TOOL_USE_ERROR));
|
|
74
|
+
messages.push({ role: "tool", content: results });
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (reply.finishReason !== "tool-calls") {
|
|
78
|
+
await emit({ type: "iteration", source, index: i, final: true });
|
|
79
|
+
recordAgentRun({ agentId: agent.id, iterations, cappedOut: false });
|
|
80
|
+
return { messages, finish: { reason: reply.finishReason, cappedOut: false, truncationRecoveries } };
|
|
81
|
+
}
|
|
82
|
+
await emit({ type: "iteration", source, index: i, final: false });
|
|
83
|
+
for (const tu of toolCalls) {
|
|
84
|
+
await emit({ type: "tool-started", source, toolUseId: tu.toolCallId, name: tu.toolName, input: tu.input });
|
|
85
|
+
}
|
|
86
|
+
const results = await dispatchTools(toolCalls, toolsById, toolCtx, isFatalLoopError, runStep, formatStepName.tool);
|
|
87
|
+
for (let idx = 0; idx < toolCalls.length; idx++) {
|
|
88
|
+
const tu = toolCalls[idx];
|
|
89
|
+
await emit({
|
|
90
|
+
type: "tool-finished",
|
|
91
|
+
source,
|
|
92
|
+
toolUseId: tu.toolCallId,
|
|
93
|
+
name: tu.toolName,
|
|
94
|
+
isError: isErrorOutput(results[idx]),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
messages.push({ role: "tool", content: results });
|
|
98
|
+
}
|
|
99
|
+
const wrapUp = await resultStep(runStep)(formatStepName.llm(agent.maxIterations), () => provider.chat({ system: agent.systemPrompt, messages, tools: {}, toolChoice: "none" }, session, signal));
|
|
100
|
+
messages.push(wrapUp.message);
|
|
101
|
+
await emit({ type: "iteration", source, index: agent.maxIterations, final: true });
|
|
102
|
+
recordAgentRun({ agentId: agent.id, iterations, cappedOut: true });
|
|
103
|
+
return { messages, finish: { reason: "max_iterations", cappedOut: true, truncationRecoveries } };
|
|
104
|
+
}
|
|
105
|
+
function toolCallParts(message) {
|
|
106
|
+
if (typeof message.content === "string")
|
|
107
|
+
return [];
|
|
108
|
+
return message.content.filter((part) => part.type === "tool-call");
|
|
109
|
+
}
|
|
110
|
+
async function dispatchTools(toolUses, toolsById, toolCtx, isFatalLoopError, runStep, toolStepName) {
|
|
111
|
+
const results = new Array(toolUses.length);
|
|
112
|
+
const stepTools = [];
|
|
113
|
+
const workflowTools = [];
|
|
114
|
+
const inlineTools = [];
|
|
115
|
+
for (const [idx, tu] of toolUses.entries()) {
|
|
116
|
+
const mode = toolsById.get(tu.toolName)?.executionMode ?? "step";
|
|
117
|
+
if (mode === "workflow")
|
|
118
|
+
workflowTools.push({ tu, idx });
|
|
119
|
+
else if (mode === "inline")
|
|
120
|
+
inlineTools.push({ tu, idx });
|
|
121
|
+
else
|
|
122
|
+
stepTools.push({ tu, idx });
|
|
123
|
+
}
|
|
124
|
+
await Promise.all(stepTools.map(({ tu, idx }) => runStep(toolStepName(tu.toolName, tu.toolCallId), () => dispatchTool(tu, toolsById, toolCtx(tu), isFatalLoopError)).then((r) => {
|
|
125
|
+
results[idx] = r;
|
|
126
|
+
})));
|
|
127
|
+
for (const { tu, idx } of workflowTools) {
|
|
128
|
+
results[idx] = await dispatchTool(tu, toolsById, toolCtx(tu), isFatalLoopError);
|
|
129
|
+
}
|
|
130
|
+
for (const { tu, idx } of inlineTools) {
|
|
131
|
+
results[idx] = await dispatchTool(tu, toolsById, toolCtx(tu), isFatalLoopError);
|
|
132
|
+
}
|
|
133
|
+
return results;
|
|
134
|
+
}
|
|
135
|
+
async function dispatchTool(tu, toolsById, ctx, isFatalLoopError) {
|
|
136
|
+
const tool = toolsById.get(tu.toolName);
|
|
137
|
+
if (tool === undefined) {
|
|
138
|
+
return errorResult(tu, `unknown tool: ${tu.toolName}`);
|
|
139
|
+
}
|
|
140
|
+
const parsed = tool.inputSchema.safeParse(tu.input);
|
|
141
|
+
if (!parsed.success) {
|
|
142
|
+
return errorResult(tu, `input validation failed: ${formatZodIssues(parsed.error)}`);
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const output = await tool.execute(parsed.data, ctx);
|
|
146
|
+
if (output.isErr())
|
|
147
|
+
return errorResult(tu, toolErrorContent(output.error));
|
|
148
|
+
return successResult(tu, output.value);
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
if (isFatalLoopError(err))
|
|
152
|
+
throw err;
|
|
153
|
+
return errorResult(tu, toolErrorContent(err));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function jsonValue(value) {
|
|
157
|
+
return JSON.parse(JSON.stringify(value ?? null));
|
|
158
|
+
}
|
|
159
|
+
function successResult(toolCall, value) {
|
|
160
|
+
return {
|
|
161
|
+
type: "tool-result",
|
|
162
|
+
toolCallId: toolCall.toolCallId,
|
|
163
|
+
toolName: toolCall.toolName,
|
|
164
|
+
output: { type: "json", value: jsonValue(value) },
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function toolErrorContent(value) {
|
|
168
|
+
if (isToolError(value)) {
|
|
169
|
+
return JSON.stringify({ error: value.error, retryable: value.retryable });
|
|
170
|
+
}
|
|
171
|
+
const { retryable } = classifyProviderError(value);
|
|
172
|
+
const error = value instanceof Error ? value.message : String(value);
|
|
173
|
+
return JSON.stringify({ error, retryable });
|
|
174
|
+
}
|
|
175
|
+
function errorResult(toolCall, content) {
|
|
176
|
+
return {
|
|
177
|
+
type: "tool-result",
|
|
178
|
+
toolCallId: toolCall.toolCallId,
|
|
179
|
+
toolName: toolCall.toolName,
|
|
180
|
+
output: { type: "error-text", value: content },
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function isErrorOutput(result) {
|
|
184
|
+
return result.output.type === "error-text" || result.output.type === "error-json" || result.output.type === "execution-denied";
|
|
185
|
+
}
|
|
186
|
+
export function finalText(messages) {
|
|
187
|
+
const last = messages.at(-1);
|
|
188
|
+
if (last === undefined || last.role !== "assistant")
|
|
189
|
+
return "";
|
|
190
|
+
if (typeof last.content === "string")
|
|
191
|
+
return last.content;
|
|
192
|
+
return last.content
|
|
193
|
+
.filter((block) => block.type === "text")
|
|
194
|
+
.map((block) => block.text)
|
|
195
|
+
.join("");
|
|
196
|
+
}
|
|
197
|
+
function formatZodIssues(error) {
|
|
198
|
+
return error.issues
|
|
199
|
+
.map((issue) => {
|
|
200
|
+
const path = issue.path.length > 0 ? issue.path.join(".") : "(root)";
|
|
201
|
+
return `${path}: ${issue.message}`;
|
|
202
|
+
})
|
|
203
|
+
.join("; ");
|
|
204
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `RunStep` adapters.
|
|
3
|
+
*
|
|
4
|
+
* `runAgent` wraps every LLM and tool call in an injected `RunStep`. Two
|
|
5
|
+
* adapters cover the two execution modes:
|
|
6
|
+
*
|
|
7
|
+
* - `passthroughStep` — the chat route. In-process, single-replica, no
|
|
8
|
+
* durability. Just runs the function.
|
|
9
|
+
* - `durableStep` — workflow contexts. Wraps the call as a `DBOS.runStep`
|
|
10
|
+
* so a crashed workflow replays without re-issuing completed LLM/tool
|
|
11
|
+
* calls. The step name (`llm-${i}`, `tool-${name}-${toolUseId}`) is the
|
|
12
|
+
* cache key on replay (see the harness-thread-store spec) and must not be reformatted.
|
|
13
|
+
*
|
|
14
|
+
* The loop body never imports DBOS — it depends only on the `RunStep`
|
|
15
|
+
* shape, which is what lets the same `runAgent` serve chat and (in change
|
|
16
|
+
* 8) durable workflows.
|
|
17
|
+
*/
|
|
18
|
+
import type { Result } from "neverthrow";
|
|
19
|
+
import type { RunStep } from "./types.js";
|
|
20
|
+
export declare const passthroughStep: RunStep;
|
|
21
|
+
export declare const durableStep: RunStep;
|
|
22
|
+
/**
|
|
23
|
+
* Adapt a `RunStep` to a `Result`-returning body. This is THE seam where
|
|
24
|
+
* `Result` meets durability: a step is recorded as failed — and retried /
|
|
25
|
+
* fails fast — only when its body throws, so an `err` MUST become a throw at
|
|
26
|
+
* the step boundary. The body stays Result-shaped; `unwrapOrThrow` isolates
|
|
27
|
+
* the throw. Pass `durableStep` in workflows, `passthroughStep` in chat.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resultStep(runStep: RunStep): <T, E>(name: string, fn: () => PromiseLike<Result<T, E>>) => Promise<T>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `RunStep` adapters.
|
|
3
|
+
*
|
|
4
|
+
* `runAgent` wraps every LLM and tool call in an injected `RunStep`. Two
|
|
5
|
+
* adapters cover the two execution modes:
|
|
6
|
+
*
|
|
7
|
+
* - `passthroughStep` — the chat route. In-process, single-replica, no
|
|
8
|
+
* durability. Just runs the function.
|
|
9
|
+
* - `durableStep` — workflow contexts. Wraps the call as a `DBOS.runStep`
|
|
10
|
+
* so a crashed workflow replays without re-issuing completed LLM/tool
|
|
11
|
+
* calls. The step name (`llm-${i}`, `tool-${name}-${toolUseId}`) is the
|
|
12
|
+
* cache key on replay (see the harness-thread-store spec) and must not be reformatted.
|
|
13
|
+
*
|
|
14
|
+
* The loop body never imports DBOS — it depends only on the `RunStep`
|
|
15
|
+
* shape, which is what lets the same `runAgent` serve chat and (in change
|
|
16
|
+
* 8) durable workflows.
|
|
17
|
+
*/
|
|
18
|
+
import { DBOS } from "@dbos-inc/dbos-sdk";
|
|
19
|
+
import { unwrapOrThrow } from "../lib/result.js";
|
|
20
|
+
export const passthroughStep = (_name, fn) => fn();
|
|
21
|
+
export const durableStep = (name, fn) => DBOS.runStep(fn, { name });
|
|
22
|
+
/**
|
|
23
|
+
* Adapt a `RunStep` to a `Result`-returning body. This is THE seam where
|
|
24
|
+
* `Result` meets durability: a step is recorded as failed — and retried /
|
|
25
|
+
* fails fast — only when its body throws, so an `err` MUST become a throw at
|
|
26
|
+
* the step boundary. The body stays Result-shaped; `unwrapOrThrow` isolates
|
|
27
|
+
* the throw. Pass `durableStep` in workflows, `passthroughStep` in chat.
|
|
28
|
+
*/
|
|
29
|
+
export function resultStep(runStep) {
|
|
30
|
+
return (name,
|
|
31
|
+
// `PromiseLike`, not `Promise` — a `ResultAsync` (what `provider.chat`
|
|
32
|
+
// returns) is a `PromiseLike<Result>`, awaited to its inner `Result`.
|
|
33
|
+
fn) => runStep(name, async () => unwrapOrThrow(await fn()));
|
|
34
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `runToTerminal` — terminal-salvage wrapper around `runAgent`.
|
|
3
|
+
*
|
|
4
|
+
* Some agents communicate their result EXCLUSIVELY through a terminal tool
|
|
5
|
+
* (`submit_plan`, `submit_report`, `submit_profile`, `submit_synthesis`, …):
|
|
6
|
+
* the loop's text reply is discarded and the outcome is read from a closure
|
|
7
|
+
* cell the terminal tool writes. Plain `runAgent` ends a capped run on a
|
|
8
|
+
* tool-LESS wrap-up turn, so an agent that burns its whole iteration budget —
|
|
9
|
+
* or simply stops on prose — without ever submitting leaves that cell empty
|
|
10
|
+
* and forces the caller to hard-fail.
|
|
11
|
+
*
|
|
12
|
+
* `runToTerminal` runs the agent, then — if the outcome cell is still empty
|
|
13
|
+
* and the run was not aborted — grants ONE focused salvage continuation whose
|
|
14
|
+
* only tools are the terminal tools, opened by a corrective nudge. Restricting
|
|
15
|
+
* the surface to the terminal tools removes every distraction; a small
|
|
16
|
+
* `maxIterations` lets the model fix a single validation rejection and
|
|
17
|
+
* resubmit.
|
|
18
|
+
*
|
|
19
|
+
* Salvage steps are namespaced (`salvage:…`) so a durable (DBOS) caller does
|
|
20
|
+
* not collide the continuation's `llm-*` / `tool-*` cache keys with the first
|
|
21
|
+
* run's — replaying them would silently return the first run's cached results.
|
|
22
|
+
*/
|
|
23
|
+
import type { AgentSession } from "../auth/types.js";
|
|
24
|
+
import type { Tool } from "../tools/define-tool.js";
|
|
25
|
+
import { type RunAgentOptions, type RunAgentResult } from "./run-agent.js";
|
|
26
|
+
import type { AgentDefinition, LoopMessage } from "./types.js";
|
|
27
|
+
/** Default salvage budget: one submit plus a validation-fix retry or two. */
|
|
28
|
+
export declare const DEFAULT_SALVAGE_ITERATIONS = 3;
|
|
29
|
+
/** Describes how to salvage a run that never reached its terminal tool. */
|
|
30
|
+
export interface TerminalSalvage {
|
|
31
|
+
/** True once the agent recorded its terminal outcome (reads the closure cell). */
|
|
32
|
+
readonly resolved: () => boolean;
|
|
33
|
+
/** Terminal tools offered on the salvage turn (submit / blocker / …). Must be
|
|
34
|
+
* the same instances the first run used — they close over the outcome cell. */
|
|
35
|
+
readonly tools: readonly Tool[];
|
|
36
|
+
/** Corrective user message that opens the salvage continuation. */
|
|
37
|
+
readonly nudge: string;
|
|
38
|
+
/** Salvage iteration budget. Defaults to {@link DEFAULT_SALVAGE_ITERATIONS}. */
|
|
39
|
+
readonly maxIterations?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Drive `agent` to its terminal tool, salvaging once if it doesn't get there.
|
|
43
|
+
* Returns the salvage run's result when a salvage occurred (its message array
|
|
44
|
+
* already includes the first run's), otherwise the first run's result.
|
|
45
|
+
*/
|
|
46
|
+
export declare function runToTerminal(agent: AgentDefinition, initial: readonly LoopMessage[], session: AgentSession, opts: RunAgentOptions, salvage: TerminalSalvage): Promise<RunAgentResult>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `runToTerminal` — terminal-salvage wrapper around `runAgent`.
|
|
3
|
+
*
|
|
4
|
+
* Some agents communicate their result EXCLUSIVELY through a terminal tool
|
|
5
|
+
* (`submit_plan`, `submit_report`, `submit_profile`, `submit_synthesis`, …):
|
|
6
|
+
* the loop's text reply is discarded and the outcome is read from a closure
|
|
7
|
+
* cell the terminal tool writes. Plain `runAgent` ends a capped run on a
|
|
8
|
+
* tool-LESS wrap-up turn, so an agent that burns its whole iteration budget —
|
|
9
|
+
* or simply stops on prose — without ever submitting leaves that cell empty
|
|
10
|
+
* and forces the caller to hard-fail.
|
|
11
|
+
*
|
|
12
|
+
* `runToTerminal` runs the agent, then — if the outcome cell is still empty
|
|
13
|
+
* and the run was not aborted — grants ONE focused salvage continuation whose
|
|
14
|
+
* only tools are the terminal tools, opened by a corrective nudge. Restricting
|
|
15
|
+
* the surface to the terminal tools removes every distraction; a small
|
|
16
|
+
* `maxIterations` lets the model fix a single validation rejection and
|
|
17
|
+
* resubmit.
|
|
18
|
+
*
|
|
19
|
+
* Salvage steps are namespaced (`salvage:…`) so a durable (DBOS) caller does
|
|
20
|
+
* not collide the continuation's `llm-*` / `tool-*` cache keys with the first
|
|
21
|
+
* run's — replaying them would silently return the first run's cached results.
|
|
22
|
+
*/
|
|
23
|
+
import { DEFAULT_STEP_NAME_FORMATTER, runAgent } from "./run-agent.js";
|
|
24
|
+
/** Default salvage budget: one submit plus a validation-fix retry or two. */
|
|
25
|
+
export const DEFAULT_SALVAGE_ITERATIONS = 3;
|
|
26
|
+
function salvageStepNames(base) {
|
|
27
|
+
return {
|
|
28
|
+
llm: (i) => `salvage:${base.llm(i)}`,
|
|
29
|
+
tool: (name, id) => `salvage:${base.tool(name, id)}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Drive `agent` to its terminal tool, salvaging once if it doesn't get there.
|
|
34
|
+
* Returns the salvage run's result when a salvage occurred (its message array
|
|
35
|
+
* already includes the first run's), otherwise the first run's result.
|
|
36
|
+
*/
|
|
37
|
+
export async function runToTerminal(agent, initial, session, opts, salvage) {
|
|
38
|
+
const first = await runAgent(agent, initial, session, opts);
|
|
39
|
+
if (salvage.resolved() || opts.signal.aborted)
|
|
40
|
+
return first;
|
|
41
|
+
const salvageAgent = {
|
|
42
|
+
...agent,
|
|
43
|
+
tools: [...salvage.tools],
|
|
44
|
+
maxIterations: salvage.maxIterations ?? DEFAULT_SALVAGE_ITERATIONS,
|
|
45
|
+
};
|
|
46
|
+
const salvageOpts = {
|
|
47
|
+
...opts,
|
|
48
|
+
formatStepName: salvageStepNames(opts.formatStepName ?? DEFAULT_STEP_NAME_FORMATTER),
|
|
49
|
+
};
|
|
50
|
+
return runAgent(salvageAgent, [...first.messages, { role: "user", content: salvage.nudge }], session, salvageOpts);
|
|
51
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent-loop seam — shared types.
|
|
3
|
+
*
|
|
4
|
+
* `runAgent` (run-agent.ts) is a pure-async function: it owns the message
|
|
5
|
+
* loop and nothing else. Durability and streaming are *injected* — a
|
|
6
|
+
* `RunStep` wraps each LLM/tool call (`passthroughStep` for chat, a
|
|
7
|
+
* `DBOS.runStep` wrapper in PR #3) and an `EmitFn` is the flat event sink.
|
|
8
|
+
* The loop body itself knows nothing about DBOS, HTTP, or memory.
|
|
9
|
+
*/
|
|
10
|
+
import type { ModelMessage } from "ai";
|
|
11
|
+
import type { ChatStreamEvent } from "../providers/types.js";
|
|
12
|
+
import type { Tool } from "../tools/define-tool.js";
|
|
13
|
+
/**
|
|
14
|
+
* A loop message. The harness's working message array is AI SDK-shaped
|
|
15
|
+
* `ModelMessage`.
|
|
16
|
+
*/
|
|
17
|
+
export type LoopMessage = ModelMessage;
|
|
18
|
+
/**
|
|
19
|
+
* Everything `runAgent` needs to drive one agent: identity, the system
|
|
20
|
+
* prompt, the model id (provenance / metric label — the `ChatProvider`
|
|
21
|
+
* owns the wire model), the tool surface, and the runaway-guard cap.
|
|
22
|
+
*/
|
|
23
|
+
export interface AgentDefinition {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly systemPrompt: string;
|
|
26
|
+
readonly model: string;
|
|
27
|
+
readonly tools: readonly Tool[];
|
|
28
|
+
/** Runaway guard — at the cap the loop forces a tool-less wrap-up call. */
|
|
29
|
+
readonly maxIterations: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The durability seam. `passthroughStep` (`(_, fn) => fn()`) in the chat
|
|
33
|
+
* route; a `DBOS.runStep` wrapper in PR #3. The loop is agnostic — it only
|
|
34
|
+
* promises a deterministic `name` per call (the step-naming contract).
|
|
35
|
+
*/
|
|
36
|
+
export type RunStep = <T>(name: string, fn: () => Promise<T>) => Promise<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Provenance stamped onto every orchestration event — the agent call
|
|
39
|
+
* chain at the point of emission, derived from the `Session` (see the harness-durable-runtime spec).
|
|
40
|
+
* `callPath` is provenance only; nothing branches on it.
|
|
41
|
+
*/
|
|
42
|
+
export interface EventSource {
|
|
43
|
+
readonly agentId: string;
|
|
44
|
+
readonly callPath: readonly string[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Orchestration events the loop emits: iteration boundaries and tool-call
|
|
48
|
+
* lifecycle. Distinct from `ChatStreamEvent` (model-output text deltas) —
|
|
49
|
+
* the chat route folds both into one `EmitFn` sink.
|
|
50
|
+
*/
|
|
51
|
+
export type EmitEvent = {
|
|
52
|
+
readonly type: "iteration";
|
|
53
|
+
readonly source: EventSource;
|
|
54
|
+
/** Zero-based iteration index; equals `maxIterations` for the wrap-up. */
|
|
55
|
+
readonly index: number;
|
|
56
|
+
/** True when this iteration produced the loop's terminal reply. */
|
|
57
|
+
readonly final: boolean;
|
|
58
|
+
} | {
|
|
59
|
+
readonly type: "tool-started";
|
|
60
|
+
readonly source: EventSource;
|
|
61
|
+
readonly toolUseId: string;
|
|
62
|
+
readonly name: string;
|
|
63
|
+
readonly input: unknown;
|
|
64
|
+
} | {
|
|
65
|
+
readonly type: "tool-finished";
|
|
66
|
+
readonly source: EventSource;
|
|
67
|
+
readonly toolUseId: string;
|
|
68
|
+
readonly name: string;
|
|
69
|
+
readonly isError: boolean;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* A UI presentation event a tool streams to chat — an AI-SDK `data-*`
|
|
73
|
+
* part whose payload the frontend renders (file references, plan cards,
|
|
74
|
+
* synthesized content). The loop and `emit` are agnostic to the payload
|
|
75
|
+
* shape; the typed contract lives in `harness/contracts`.
|
|
76
|
+
*/
|
|
77
|
+
export interface ChatDataPart {
|
|
78
|
+
readonly type: `data-${string}`;
|
|
79
|
+
readonly data: unknown;
|
|
80
|
+
/**
|
|
81
|
+
* Emitting-agent provenance, for the SSE route's depth filter (it drops
|
|
82
|
+
* sub-agent display parts the same way it drops sub-agent tool events).
|
|
83
|
+
* Omitted by emitters outside the chat loop (workflow parts carry their own
|
|
84
|
+
* routing envelopes).
|
|
85
|
+
*/
|
|
86
|
+
readonly source?: EventSource;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The flat event sink. One function reference flows unchanged through
|
|
90
|
+
* every nesting level. It carries three event categories: orchestration
|
|
91
|
+
* events (`EmitEvent`, from the loop), model-output deltas
|
|
92
|
+
* (`ChatStreamEvent`, from the provider), and UI presentation parts
|
|
93
|
+
* (`ChatDataPart`, from tools). A tool that does not stream never calls it.
|
|
94
|
+
*/
|
|
95
|
+
export type EmitFn = (event: EmitEvent | ChatStreamEvent | ChatDataPart) => void | Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent-loop seam — shared types.
|
|
3
|
+
*
|
|
4
|
+
* `runAgent` (run-agent.ts) is a pure-async function: it owns the message
|
|
5
|
+
* loop and nothing else. Durability and streaming are *injected* — a
|
|
6
|
+
* `RunStep` wraps each LLM/tool call (`passthroughStep` for chat, a
|
|
7
|
+
* `DBOS.runStep` wrapper in PR #3) and an `EmitFn` is the flat event sink.
|
|
8
|
+
* The loop body itself knows nothing about DBOS, HTTP, or memory.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ModelMessage } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const SUPPORTED_AI_SDK_MAJOR = 7;
|
|
4
|
+
export declare const StoredMessageEnvelopeSchema: z.ZodObject<{
|
|
5
|
+
kind: z.ZodLiteral<"ai-sdk-model-message">;
|
|
6
|
+
aiSdkMajor: z.ZodLiteral<7>;
|
|
7
|
+
message: z.ZodType<ModelMessage, unknown, z.core.$ZodTypeInternals<ModelMessage, unknown>>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export type StoredMessageEnvelope = z.infer<typeof StoredMessageEnvelopeSchema>;
|
|
10
|
+
export declare function envelopeMessage(message: ModelMessage): StoredMessageEnvelope;
|
|
11
|
+
export declare function parseStoredMessageEnvelope(value: unknown, identity: string): StoredMessageEnvelope;
|
|
12
|
+
type LegacyContent = string | Array<Record<string, unknown>>;
|
|
13
|
+
export interface LegacyMessageRow {
|
|
14
|
+
readonly threadId: string;
|
|
15
|
+
readonly seq: number;
|
|
16
|
+
readonly role: string;
|
|
17
|
+
readonly content: LegacyContent;
|
|
18
|
+
}
|
|
19
|
+
export declare function legacyAnthropicToModelMessage(row: LegacyMessageRow): ModelMessage;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { modelMessageSchema } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const SUPPORTED_AI_SDK_MAJOR = 7;
|
|
4
|
+
export const StoredMessageEnvelopeSchema = z.object({
|
|
5
|
+
kind: z.literal("ai-sdk-model-message"),
|
|
6
|
+
aiSdkMajor: z.literal(SUPPORTED_AI_SDK_MAJOR),
|
|
7
|
+
message: modelMessageSchema,
|
|
8
|
+
});
|
|
9
|
+
export function envelopeMessage(message) {
|
|
10
|
+
return {
|
|
11
|
+
kind: "ai-sdk-model-message",
|
|
12
|
+
aiSdkMajor: SUPPORTED_AI_SDK_MAJOR,
|
|
13
|
+
message,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function parseStoredMessageEnvelope(value, identity) {
|
|
17
|
+
const parsed = StoredMessageEnvelopeSchema.safeParse(value);
|
|
18
|
+
if (!parsed.success) {
|
|
19
|
+
throw new Error(`Invalid stored AI SDK message envelope at ${identity}: ${parsed.error.message}`);
|
|
20
|
+
}
|
|
21
|
+
return parsed.data;
|
|
22
|
+
}
|
|
23
|
+
function providerOptionsFromLegacy(block) {
|
|
24
|
+
// A block may carry both a signed thinking signature and cache_control;
|
|
25
|
+
// both are required for valid continuation, so both must survive.
|
|
26
|
+
const anthropic = {};
|
|
27
|
+
if (typeof block.signature === "string")
|
|
28
|
+
anthropic.signature = block.signature;
|
|
29
|
+
if (typeof block.cache_control === "object" && block.cache_control !== null) {
|
|
30
|
+
anthropic.cacheControl = block.cache_control;
|
|
31
|
+
}
|
|
32
|
+
return Object.keys(anthropic).length > 0 ? { anthropic } : undefined;
|
|
33
|
+
}
|
|
34
|
+
export function legacyAnthropicToModelMessage(row) {
|
|
35
|
+
const content = row.content;
|
|
36
|
+
if (row.role === "user") {
|
|
37
|
+
if (typeof content === "string")
|
|
38
|
+
return { role: "user", content };
|
|
39
|
+
const toolResults = content.filter((block) => block.type === "tool_result");
|
|
40
|
+
if (toolResults.length > 0) {
|
|
41
|
+
// An AI SDK tool message carries only tool-result parts; a legacy row
|
|
42
|
+
// mixing tool_result with other blocks cannot become one message and
|
|
43
|
+
// must fail the row rather than drop the extra blocks.
|
|
44
|
+
if (toolResults.length !== content.length) {
|
|
45
|
+
throw new Error(`Legacy user row ${row.threadId}/${row.seq} mixes tool_result with other content blocks and cannot be represented losslessly`);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
role: "tool",
|
|
49
|
+
content: toolResults.map((block) => {
|
|
50
|
+
const toolCallId = block.tool_use_id;
|
|
51
|
+
if (typeof toolCallId !== "string")
|
|
52
|
+
throw new Error(`Legacy tool_result row ${row.threadId}/${row.seq} is missing tool_use_id`);
|
|
53
|
+
const raw = typeof block.content === "string" ? block.content : JSON.stringify(block.content ?? null);
|
|
54
|
+
return {
|
|
55
|
+
type: "tool-result",
|
|
56
|
+
toolCallId,
|
|
57
|
+
toolName: typeof block.name === "string" ? block.name : "legacy_tool",
|
|
58
|
+
output: block.is_error === true ? { type: "error-text", value: raw } : { type: "text", value: raw },
|
|
59
|
+
};
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const unrepresentable = content.find((block) => !(block.type === "text" && typeof block.text === "string"));
|
|
64
|
+
if (unrepresentable !== undefined) {
|
|
65
|
+
throw new Error(`Legacy user row ${row.threadId}/${row.seq} contains unrepresentable block type "${String(unrepresentable.type)}"; failing rather than writing a lossy envelope`);
|
|
66
|
+
}
|
|
67
|
+
const userContent = content.map((block) => ({ type: "text", text: String(block.text), providerOptions: providerOptionsFromLegacy(block) }));
|
|
68
|
+
return {
|
|
69
|
+
role: "user",
|
|
70
|
+
content: userContent,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (row.role === "assistant") {
|
|
74
|
+
if (typeof content === "string")
|
|
75
|
+
return { role: "assistant", content };
|
|
76
|
+
const assistantContent = [];
|
|
77
|
+
for (const block of content) {
|
|
78
|
+
if (block.type === "text" && typeof block.text === "string") {
|
|
79
|
+
assistantContent.push({ type: "text", text: block.text, providerOptions: providerOptionsFromLegacy(block) });
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (block.type === "thinking" && typeof block.thinking === "string") {
|
|
83
|
+
assistantContent.push({ type: "reasoning", text: block.thinking, providerOptions: providerOptionsFromLegacy(block) });
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (block.type === "tool_use") {
|
|
87
|
+
if (typeof block.id !== "string" || typeof block.name !== "string") {
|
|
88
|
+
throw new Error(`Legacy tool_use row ${row.threadId}/${row.seq} is missing id/name`);
|
|
89
|
+
}
|
|
90
|
+
assistantContent.push({
|
|
91
|
+
type: "tool-call",
|
|
92
|
+
toolCallId: block.id,
|
|
93
|
+
toolName: block.name,
|
|
94
|
+
input: block.input ?? {},
|
|
95
|
+
providerOptions: providerOptionsFromLegacy(block),
|
|
96
|
+
});
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
// Any other block (e.g. redacted_thinking) may carry signed provider
|
|
100
|
+
// data required for continuation; fail the row instead of dropping it.
|
|
101
|
+
throw new Error(`Legacy assistant row ${row.threadId}/${row.seq} contains unrepresentable block type "${String(block.type)}"; failing rather than writing a lossy envelope`);
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
role: "assistant",
|
|
105
|
+
content: assistantContent,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (row.role === "system") {
|
|
109
|
+
if (typeof content !== "string")
|
|
110
|
+
throw new Error(`Legacy system row ${row.threadId}/${row.seq} must contain string content`);
|
|
111
|
+
return { role: "system", content };
|
|
112
|
+
}
|
|
113
|
+
throw new Error(`Unsupported legacy message role at ${row.threadId}/${row.seq}: ${row.role}`);
|
|
114
|
+
}
|