@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,142 @@
|
|
|
1
|
+
import { generateText, streamText } from "ai";
|
|
2
|
+
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
3
|
+
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
4
|
+
import { ResultAsync, err, ok } from "neverthrow";
|
|
5
|
+
import { scopeWorkloadId } from "../auth/types.js";
|
|
6
|
+
import { toProviderError } from "./errors.js";
|
|
7
|
+
const DEFAULT_MAX_RETRIES = 2;
|
|
8
|
+
function workloadOf(session) {
|
|
9
|
+
return `${session.scope.kind}:${scopeWorkloadId(session.scope)}`;
|
|
10
|
+
}
|
|
11
|
+
function isAbortError(value) {
|
|
12
|
+
if (value instanceof DOMException && value.name === "AbortError")
|
|
13
|
+
return true;
|
|
14
|
+
if (value instanceof Error && value.name === "AbortError")
|
|
15
|
+
return true;
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
function responseFromMessages(messages, fallbackText, finishReason, rawFinishReason) {
|
|
19
|
+
const message = [...messages].reverse().find((m) => m.role === "assistant");
|
|
20
|
+
if (message === undefined) {
|
|
21
|
+
return {
|
|
22
|
+
message: { role: "assistant", content: fallbackText },
|
|
23
|
+
finishReason,
|
|
24
|
+
rawFinishReason,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return { message, finishReason, rawFinishReason };
|
|
28
|
+
}
|
|
29
|
+
function responseFromGenerate(result) {
|
|
30
|
+
return responseFromMessages(result.responseMessages, result.text, result.finishReason, result.rawFinishReason);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Drop empty text parts — and messages left with no content at all — before
|
|
34
|
+
* the wire call. The Anthropic Messages API rejects any request containing an
|
|
35
|
+
* empty text block, and the SDK's own response assembly legitimately produces
|
|
36
|
+
* them: a turn that goes straight to tool calls yields an assistant message
|
|
37
|
+
* carrying a ""-text part, which the agent loop then echoes back as history
|
|
38
|
+
* on its next request. Filtering once at the outbound boundary covers every
|
|
39
|
+
* source at once — loop echo, stored thread history, legacy backfill, and the
|
|
40
|
+
* empty-string fallback in `responseFromMessages`.
|
|
41
|
+
*/
|
|
42
|
+
function sanitizeMessages(messages) {
|
|
43
|
+
const out = [];
|
|
44
|
+
for (const m of messages) {
|
|
45
|
+
if (typeof m.content === "string") {
|
|
46
|
+
if (m.content !== "")
|
|
47
|
+
out.push(m);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const parts = m.content.filter((p) => p.type !== "text" || p.text !== "");
|
|
51
|
+
// The filtered parts are a subset of this message's own content, so the
|
|
52
|
+
// message remains valid for its role — the cast only re-associates the
|
|
53
|
+
// narrowed array with the union member TS can no longer correlate.
|
|
54
|
+
if (parts.length > 0)
|
|
55
|
+
out.push({ ...m, content: parts });
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
export function createAiSdkProvider(deps) {
|
|
60
|
+
const capabilities = { toolCalling: deps.capabilities?.toolCalling ?? true };
|
|
61
|
+
function chat(req, session, signal) {
|
|
62
|
+
const run = async () => {
|
|
63
|
+
try {
|
|
64
|
+
const headers = await deps.resolveBilling(session);
|
|
65
|
+
const result = await generateText({
|
|
66
|
+
model: deps.model,
|
|
67
|
+
system: req.system,
|
|
68
|
+
messages: sanitizeMessages(req.messages),
|
|
69
|
+
tools: req.tools,
|
|
70
|
+
toolChoice: req.toolChoice ?? "auto",
|
|
71
|
+
stopWhen: [],
|
|
72
|
+
maxRetries: DEFAULT_MAX_RETRIES,
|
|
73
|
+
headers,
|
|
74
|
+
abortSignal: signal,
|
|
75
|
+
providerOptions: req.providerOptions,
|
|
76
|
+
});
|
|
77
|
+
return ok(responseFromGenerate(result));
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
if (isAbortError(e) || signal?.aborted)
|
|
81
|
+
throw e;
|
|
82
|
+
return err(toProviderError(e, workloadOf(session)));
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return new ResultAsync(run());
|
|
86
|
+
}
|
|
87
|
+
async function* chatStream(req, session, signal) {
|
|
88
|
+
try {
|
|
89
|
+
const headers = await deps.resolveBilling(session);
|
|
90
|
+
const result = streamText({
|
|
91
|
+
model: deps.model,
|
|
92
|
+
system: req.system,
|
|
93
|
+
messages: sanitizeMessages(req.messages),
|
|
94
|
+
tools: req.tools,
|
|
95
|
+
toolChoice: req.toolChoice ?? "auto",
|
|
96
|
+
stopWhen: [],
|
|
97
|
+
maxRetries: DEFAULT_MAX_RETRIES,
|
|
98
|
+
headers,
|
|
99
|
+
abortSignal: signal,
|
|
100
|
+
providerOptions: req.providerOptions,
|
|
101
|
+
});
|
|
102
|
+
let text = "";
|
|
103
|
+
for await (const delta of result.textStream) {
|
|
104
|
+
text += delta;
|
|
105
|
+
yield { type: "text-delta", text: delta };
|
|
106
|
+
}
|
|
107
|
+
const response = responseFromMessages(await result.responseMessages, text, await result.finishReason, await result.rawFinishReason);
|
|
108
|
+
yield { type: "done", response };
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
if (isAbortError(e) || signal?.aborted)
|
|
112
|
+
throw e;
|
|
113
|
+
throw toProviderError(e, workloadOf(session));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { capabilities, chat, chatStream };
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Realize an `AiSdkProviderConfig` into a `ChatProvider` bound to that config's
|
|
120
|
+
* connection and model. The model is closed into the returned provider here (it
|
|
121
|
+
* is never passed per `ChatRequest`), so N models require N provider
|
|
122
|
+
* instances over one shared connection configuration — one instance serves the
|
|
123
|
+
* single model it was built with.
|
|
124
|
+
*/
|
|
125
|
+
export function createConfiguredAiSdkProvider(deps) {
|
|
126
|
+
const config = deps.config;
|
|
127
|
+
if (config.kind === "anthropic") {
|
|
128
|
+
const provider = createAnthropic({
|
|
129
|
+
baseURL: config.baseURL,
|
|
130
|
+
apiKey: config.apiKey,
|
|
131
|
+
fetch: config.fetch,
|
|
132
|
+
});
|
|
133
|
+
return createAiSdkProvider({ model: provider.chat(config.model), resolveBilling: deps.resolveBilling, capabilities: config.capabilities });
|
|
134
|
+
}
|
|
135
|
+
const provider = createOpenAICompatible({
|
|
136
|
+
name: config.name,
|
|
137
|
+
baseURL: config.baseURL,
|
|
138
|
+
apiKey: config.apiKey,
|
|
139
|
+
fetch: config.fetch,
|
|
140
|
+
});
|
|
141
|
+
return createAiSdkProvider({ model: provider.chatModel(config.model), resolveBilling: deps.resolveBilling, capabilities: config.capabilities });
|
|
142
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility entry point for Anthropic-backed chat.
|
|
3
|
+
*
|
|
4
|
+
* The production provider path is AI SDK-backed; this wrapper preserves the
|
|
5
|
+
* old factory name for embedders while returning the new `ChatProvider` seam.
|
|
6
|
+
*/
|
|
7
|
+
import type { ResolveBilling } from "../billing/resolver.js";
|
|
8
|
+
import type { ChatProvider, FetchLike } from "./types.js";
|
|
9
|
+
export interface AnthropicProviderDeps {
|
|
10
|
+
readonly baseURL?: string;
|
|
11
|
+
readonly token: string;
|
|
12
|
+
readonly model: string;
|
|
13
|
+
readonly resolveBilling: ResolveBilling;
|
|
14
|
+
readonly fetch?: FetchLike;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Convenience over the `anthropic` arm of the public `AiSdkProviderConfig`
|
|
18
|
+
* union: it takes the Anthropic connection fields directly (`token` as the api
|
|
19
|
+
* key) and delegates to `createConfiguredAiSdkProvider`. The same construction
|
|
20
|
+
* contract holds — the `model` is bound into the returned provider.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createAnthropicProvider(deps: AnthropicProviderDeps): ChatProvider;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility entry point for Anthropic-backed chat.
|
|
3
|
+
*
|
|
4
|
+
* The production provider path is AI SDK-backed; this wrapper preserves the
|
|
5
|
+
* old factory name for embedders while returning the new `ChatProvider` seam.
|
|
6
|
+
*/
|
|
7
|
+
import { createConfiguredAiSdkProvider } from "./ai-sdk.js";
|
|
8
|
+
/**
|
|
9
|
+
* Convenience over the `anthropic` arm of the public `AiSdkProviderConfig`
|
|
10
|
+
* union: it takes the Anthropic connection fields directly (`token` as the api
|
|
11
|
+
* key) and delegates to `createConfiguredAiSdkProvider`. The same construction
|
|
12
|
+
* contract holds — the `model` is bound into the returned provider.
|
|
13
|
+
*/
|
|
14
|
+
export function createAnthropicProvider(deps) {
|
|
15
|
+
return createConfiguredAiSdkProvider({
|
|
16
|
+
resolveBilling: deps.resolveBilling,
|
|
17
|
+
config: {
|
|
18
|
+
kind: "anthropic",
|
|
19
|
+
baseURL: deps.baseURL,
|
|
20
|
+
apiKey: deps.token,
|
|
21
|
+
model: deps.model,
|
|
22
|
+
fetch: deps.fetch,
|
|
23
|
+
capabilities: { toolCalling: true },
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedding provider.
|
|
3
|
+
*
|
|
4
|
+
* The ONLY file in the harness that imports `openai`. The SDK client is
|
|
5
|
+
* pointed at the billing-gateway base URL; per-call billing headers are assembled
|
|
6
|
+
* from the `Session`. Embeds with OpenAI `text-embedding-3-small`.
|
|
7
|
+
*/
|
|
8
|
+
import type { ResolveBilling } from "../billing/resolver.js";
|
|
9
|
+
import type { EmbeddingProvider, FetchLike } from "./types.js";
|
|
10
|
+
export interface EmbeddingProviderDeps {
|
|
11
|
+
/** Billing-gateway base URL — all embedding traffic is routed through it. */
|
|
12
|
+
readonly baseURL: string;
|
|
13
|
+
/** API token presented to the billing gateway. */
|
|
14
|
+
readonly token: string;
|
|
15
|
+
/** Embedding model id. Defaults to `text-embedding-3-small`. */
|
|
16
|
+
readonly model?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Vector width the configured model emits, advertised on the returned
|
|
19
|
+
* provider (see {@link EmbeddingProvider.dimensions}). Defaults to the
|
|
20
|
+
* default model's 1536 — a host wiring a non-default `model` must supply
|
|
21
|
+
* the matching width or the per-analysis index is created at the wrong size.
|
|
22
|
+
*/
|
|
23
|
+
readonly dimensions?: number;
|
|
24
|
+
/** Resolves the billing attribution map at the call site. */
|
|
25
|
+
readonly resolveBilling: ResolveBilling;
|
|
26
|
+
/**
|
|
27
|
+
* `fetch` override. Production omits it (the SDK's default is used);
|
|
28
|
+
* tests inject a fake to feed a recorded response.
|
|
29
|
+
*/
|
|
30
|
+
readonly fetch?: FetchLike;
|
|
31
|
+
}
|
|
32
|
+
export declare function createEmbeddingProvider(deps: EmbeddingProviderDeps): EmbeddingProvider;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedding provider.
|
|
3
|
+
*
|
|
4
|
+
* The ONLY file in the harness that imports `openai`. The SDK client is
|
|
5
|
+
* pointed at the billing-gateway base URL; per-call billing headers are assembled
|
|
6
|
+
* from the `Session`. Embeds with OpenAI `text-embedding-3-small`.
|
|
7
|
+
*/
|
|
8
|
+
import OpenAI from "openai";
|
|
9
|
+
import { ResultAsync, err, ok, okAsync } from "neverthrow";
|
|
10
|
+
import { scopeWorkloadId } from "../auth/types.js";
|
|
11
|
+
import { toProviderError } from "./errors.js";
|
|
12
|
+
const DEFAULT_EMBEDDING_MODEL = "text-embedding-3-small";
|
|
13
|
+
/** Vector width of the default model — `text-embedding-3-small` emits 1536-dim vectors. */
|
|
14
|
+
const DEFAULT_EMBEDDING_DIMENSIONS = 1536;
|
|
15
|
+
export function createEmbeddingProvider(deps) {
|
|
16
|
+
const client = new OpenAI({
|
|
17
|
+
baseURL: deps.baseURL,
|
|
18
|
+
apiKey: deps.token,
|
|
19
|
+
...(deps.fetch ? { fetch: deps.fetch } : {}),
|
|
20
|
+
});
|
|
21
|
+
const model = deps.model ?? DEFAULT_EMBEDDING_MODEL;
|
|
22
|
+
const dimensions = deps.dimensions ?? DEFAULT_EMBEDDING_DIMENSIONS;
|
|
23
|
+
function embed(texts, session) {
|
|
24
|
+
if (texts.length === 0)
|
|
25
|
+
return okAsync([]);
|
|
26
|
+
const workload = `${session.scope.kind}:${scopeWorkloadId(session.scope)}`;
|
|
27
|
+
const run = async () => {
|
|
28
|
+
try {
|
|
29
|
+
const headers = await deps.resolveBilling(session);
|
|
30
|
+
const response = await client.embeddings.create({ model, input: [...texts], encoding_format: "float" }, { headers });
|
|
31
|
+
// The API does not guarantee response order; re-key by `index`.
|
|
32
|
+
const rows = [...response.data].sort((a, b) => a.index - b.index).map((d) => d.embedding);
|
|
33
|
+
return ok(rows);
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
return err(toProviderError(e, workload));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
return new ResultAsync(run());
|
|
40
|
+
}
|
|
41
|
+
return { embed, dimensions };
|
|
42
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider error taxonomy.
|
|
3
|
+
*
|
|
4
|
+
* Callers (the agent loop, the chat route, DBOS steps) branch on error
|
|
5
|
+
* origin: a billing-gateway governance rejection is permanent and user-facing; a
|
|
6
|
+
* transient upstream hiccup is retryable. This module owns the
|
|
7
|
+
* classification so callers do not re-derive it.
|
|
8
|
+
*
|
|
9
|
+
* The billing-gateway convention is status-code driven (no dedicated error header
|
|
10
|
+
* is required to disambiguate): the gateway emits `402` exclusively for
|
|
11
|
+
* `budget_exceeded` and `403` for a blocked tenant. Provider-originated
|
|
12
|
+
* failures (429, 5xx, connection) surface with their own status or as a
|
|
13
|
+
* network error with no status at all.
|
|
14
|
+
*/
|
|
15
|
+
export type ProviderErrorKind = "budget" | "tenant-blocked" | "provider";
|
|
16
|
+
/**
|
|
17
|
+
* The provider error value channel — a `DomainError`-conforming
|
|
18
|
+
* discriminated union mirroring `ProviderErrorKind`. `chat` / `embed` return
|
|
19
|
+
* `err(ProviderError)` instead of throwing a typed Error; `toProviderError`
|
|
20
|
+
* is the sole constructor. `cause` carries the original SDK throwable so the
|
|
21
|
+
* cause-walking classifiers (`isBudgetExceeded`, `classifyProviderError`)
|
|
22
|
+
* still reach the `status` / `code` signals after `toThrowable` rethrows at a
|
|
23
|
+
* step boundary.
|
|
24
|
+
*/
|
|
25
|
+
export type ProviderError = {
|
|
26
|
+
readonly type: "budget";
|
|
27
|
+
readonly retryable: false;
|
|
28
|
+
readonly message: string;
|
|
29
|
+
readonly cause?: unknown;
|
|
30
|
+
} | {
|
|
31
|
+
readonly type: "tenant-blocked";
|
|
32
|
+
readonly retryable: false;
|
|
33
|
+
readonly message: string;
|
|
34
|
+
readonly cause?: unknown;
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "provider";
|
|
37
|
+
readonly retryable: boolean;
|
|
38
|
+
readonly message: string;
|
|
39
|
+
readonly cause?: unknown;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Structural guard for an already-constructed `ProviderError` value. A
|
|
43
|
+
* `ProviderError` is a plain object, not an `Error`, so it cannot be
|
|
44
|
+
* recognized by `instanceof`; this checks the discriminant plus the two
|
|
45
|
+
* always-present fields. Used by `toProviderError` to stay idempotent.
|
|
46
|
+
*/
|
|
47
|
+
export declare function isProviderError(value: unknown): value is ProviderError;
|
|
48
|
+
/**
|
|
49
|
+
* Turn a caught SDK throwable into a `ProviderError` value. Routes through
|
|
50
|
+
* `classifyProviderError` so the `provider` variant's `retryable` keeps the
|
|
51
|
+
* transient (429 / 5xx / connection) classification. `cause` is the original
|
|
52
|
+
* throwable verbatim — for the budget variant it MUST be the SDK error
|
|
53
|
+
* carrying status 402, which is what `isBudgetExceeded` walks.
|
|
54
|
+
*
|
|
55
|
+
* Idempotent: `chatStream` throws a `ProviderError` value, which
|
|
56
|
+
* `streaming-chat`'s `catch` re-wraps by calling this again. Returning an
|
|
57
|
+
* already-constructed `ProviderError` unchanged stops that second pass from
|
|
58
|
+
* `String()`-ing the object (a `ProviderError` is not an `Error`) into a
|
|
59
|
+
* `"[object Object]"` message that would bury the real inner one.
|
|
60
|
+
*/
|
|
61
|
+
export declare function toProviderError(e: unknown, workload: string): ProviderError;
|
|
62
|
+
export interface ProviderErrorClassification {
|
|
63
|
+
readonly kind: ProviderErrorKind;
|
|
64
|
+
/**
|
|
65
|
+
* Whether re-issuing the same call could plausibly succeed. The Anthropic
|
|
66
|
+
* SDK already retries transient failures internally; a `retryable: true`
|
|
67
|
+
* classification on an error that still reached here tells the caller the
|
|
68
|
+
* failure is transient in nature, not that a retry is mandatory.
|
|
69
|
+
*/
|
|
70
|
+
readonly retryable: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Classify a provider failure by origin.
|
|
74
|
+
*
|
|
75
|
+
* - Billing-gateway `402` → `budget`, not retryable.
|
|
76
|
+
* - Billing-gateway `403` → `tenant-blocked`, not retryable.
|
|
77
|
+
* - Provider `429` / `5xx` / connection errors → `provider`, retryable.
|
|
78
|
+
* - Other `4xx` and parse / unknown errors → `provider`, not retryable.
|
|
79
|
+
*/
|
|
80
|
+
export declare function classifyProviderError(e: unknown): ProviderErrorClassification;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider error taxonomy.
|
|
3
|
+
*
|
|
4
|
+
* Callers (the agent loop, the chat route, DBOS steps) branch on error
|
|
5
|
+
* origin: a billing-gateway governance rejection is permanent and user-facing; a
|
|
6
|
+
* transient upstream hiccup is retryable. This module owns the
|
|
7
|
+
* classification so callers do not re-derive it.
|
|
8
|
+
*
|
|
9
|
+
* The billing-gateway convention is status-code driven (no dedicated error header
|
|
10
|
+
* is required to disambiguate): the gateway emits `402` exclusively for
|
|
11
|
+
* `budget_exceeded` and `403` for a blocked tenant. Provider-originated
|
|
12
|
+
* failures (429, 5xx, connection) surface with their own status or as a
|
|
13
|
+
* network error with no status at all.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Structural guard for an already-constructed `ProviderError` value. A
|
|
17
|
+
* `ProviderError` is a plain object, not an `Error`, so it cannot be
|
|
18
|
+
* recognized by `instanceof`; this checks the discriminant plus the two
|
|
19
|
+
* always-present fields. Used by `toProviderError` to stay idempotent.
|
|
20
|
+
*/
|
|
21
|
+
export function isProviderError(value) {
|
|
22
|
+
if (typeof value !== "object" || value === null)
|
|
23
|
+
return false;
|
|
24
|
+
const v = value;
|
|
25
|
+
return (v.type === "budget" || v.type === "tenant-blocked" || v.type === "provider") && typeof v.retryable === "boolean" && typeof v.message === "string";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Turn a caught SDK throwable into a `ProviderError` value. Routes through
|
|
29
|
+
* `classifyProviderError` so the `provider` variant's `retryable` keeps the
|
|
30
|
+
* transient (429 / 5xx / connection) classification. `cause` is the original
|
|
31
|
+
* throwable verbatim — for the budget variant it MUST be the SDK error
|
|
32
|
+
* carrying status 402, which is what `isBudgetExceeded` walks.
|
|
33
|
+
*
|
|
34
|
+
* Idempotent: `chatStream` throws a `ProviderError` value, which
|
|
35
|
+
* `streaming-chat`'s `catch` re-wraps by calling this again. Returning an
|
|
36
|
+
* already-constructed `ProviderError` unchanged stops that second pass from
|
|
37
|
+
* `String()`-ing the object (a `ProviderError` is not an `Error`) into a
|
|
38
|
+
* `"[object Object]"` message that would bury the real inner one.
|
|
39
|
+
*/
|
|
40
|
+
export function toProviderError(e, workload) {
|
|
41
|
+
if (isProviderError(e))
|
|
42
|
+
return e;
|
|
43
|
+
const { kind, retryable } = classifyProviderError(e);
|
|
44
|
+
const detail = e instanceof Error ? e.message : String(e);
|
|
45
|
+
if (kind === "budget") {
|
|
46
|
+
return {
|
|
47
|
+
type: "budget",
|
|
48
|
+
retryable: false,
|
|
49
|
+
message: `Billing budget exceeded for ${workload}: ${detail}`,
|
|
50
|
+
cause: e,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (kind === "tenant-blocked") {
|
|
54
|
+
return {
|
|
55
|
+
type: "tenant-blocked",
|
|
56
|
+
retryable: false,
|
|
57
|
+
message: `Billing gateway blocked tenant for ${workload}: ${detail}`,
|
|
58
|
+
cause: e,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return { type: "provider", retryable, message: detail, cause: e };
|
|
62
|
+
}
|
|
63
|
+
/** Max links walked on the `cause` chain looking for a structured status. */
|
|
64
|
+
const MAX_CAUSE_HOPS = 5;
|
|
65
|
+
/** Node/undici error codes that mean "the connection itself failed". */
|
|
66
|
+
const CONNECTION_ERROR_CODES = new Set([
|
|
67
|
+
"ECONNREFUSED",
|
|
68
|
+
"ECONNRESET",
|
|
69
|
+
"ENOTFOUND",
|
|
70
|
+
"ETIMEDOUT",
|
|
71
|
+
"EPIPE",
|
|
72
|
+
"EAI_AGAIN",
|
|
73
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
74
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
75
|
+
"UND_ERR_SOCKET",
|
|
76
|
+
]);
|
|
77
|
+
const CONNECTION_ERROR_PATTERN = /fetch failed|socket hang up|network error|connection (?:refused|reset|error|closed)|econnrefused|enotfound|etimedout|terminated/i;
|
|
78
|
+
/** Walk the `cause` chain for the first numeric HTTP status. */
|
|
79
|
+
function extractStatus(err) {
|
|
80
|
+
let cursor = err;
|
|
81
|
+
for (let i = 0; i < MAX_CAUSE_HOPS && cursor; i++) {
|
|
82
|
+
const e = cursor;
|
|
83
|
+
if (typeof e.status === "number")
|
|
84
|
+
return e.status;
|
|
85
|
+
if (typeof e.statusCode === "number")
|
|
86
|
+
return e.statusCode;
|
|
87
|
+
cursor = e.cause;
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
/** Does any link of the `cause` chain look like a transport-level failure? */
|
|
92
|
+
function looksLikeConnectionError(err) {
|
|
93
|
+
let cursor = err;
|
|
94
|
+
for (let i = 0; i < MAX_CAUSE_HOPS && cursor; i++) {
|
|
95
|
+
const e = cursor;
|
|
96
|
+
if (typeof e.code === "string" && CONNECTION_ERROR_CODES.has(e.code)) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
if (typeof e.name === "string" && /^APIConnection/.test(e.name)) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
if (typeof e.message === "string" && CONNECTION_ERROR_PATTERN.test(e.message)) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
cursor = e.cause;
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Classify a provider failure by origin.
|
|
111
|
+
*
|
|
112
|
+
* - Billing-gateway `402` → `budget`, not retryable.
|
|
113
|
+
* - Billing-gateway `403` → `tenant-blocked`, not retryable.
|
|
114
|
+
* - Provider `429` / `5xx` / connection errors → `provider`, retryable.
|
|
115
|
+
* - Other `4xx` and parse / unknown errors → `provider`, not retryable.
|
|
116
|
+
*/
|
|
117
|
+
export function classifyProviderError(e) {
|
|
118
|
+
const status = extractStatus(e);
|
|
119
|
+
if (status === 402)
|
|
120
|
+
return { kind: "budget", retryable: false };
|
|
121
|
+
if (status === 403)
|
|
122
|
+
return { kind: "tenant-blocked", retryable: false };
|
|
123
|
+
if (status === 429 || (status !== undefined && status >= 500)) {
|
|
124
|
+
return { kind: "provider", retryable: true };
|
|
125
|
+
}
|
|
126
|
+
if (status !== undefined) {
|
|
127
|
+
// A concrete 4xx (other than 402/403) — the request is wrong; retrying
|
|
128
|
+
// it unchanged will fail again.
|
|
129
|
+
return { kind: "provider", retryable: false };
|
|
130
|
+
}
|
|
131
|
+
// No status: a transport failure is retryable; anything else (parse
|
|
132
|
+
// errors, unexpected throws) is not.
|
|
133
|
+
return {
|
|
134
|
+
kind: "provider",
|
|
135
|
+
retryable: looksLikeConnectionError(e),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-model capability gates for harness provider calls.
|
|
3
|
+
*
|
|
4
|
+
* The harness `ChatRequest` is a passthrough of `MessageCreateParamsBase`,
|
|
5
|
+
* so callers already pass per-call overrides (`temperature`, `thinking`,
|
|
6
|
+
* tool config, …) as native fields. This module is the silent drop-on-reject
|
|
7
|
+
* gate at the provider edge: model-rejected fields are stripped before they
|
|
8
|
+
* hit the wire so the call still succeeds (e.g. `acceptsTemperature`).
|
|
9
|
+
*
|
|
10
|
+
* Classification is pattern-based on the bare model name (no provider
|
|
11
|
+
* prefix — the harness `createAnthropicProvider` already knows it is
|
|
12
|
+
* Anthropic). No network calls, no runtime probing.
|
|
13
|
+
*/
|
|
14
|
+
import type { Message } from "./types.js";
|
|
15
|
+
/**
|
|
16
|
+
* Anthropic Opus/Sonnet/Haiku 4.7+ reject `temperature` with HTTP 400.
|
|
17
|
+
* 4.6 and earlier accept it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function anthropicAcceptsTemperature(modelName: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The model's true maximum output-token ceiling — the `max_tokens` the
|
|
22
|
+
* Anthropic provider sets per call (the API requires the field). Pattern-
|
|
23
|
+
* matched on the bare model name (no provider prefix). Ceilings per the
|
|
24
|
+
* current Anthropic model reference: Opus 4.x → 128K, Sonnet 4.6 → 64K,
|
|
25
|
+
* Haiku 4.5 → 64K.
|
|
26
|
+
*/
|
|
27
|
+
export declare function maxOutputTokens(modelName: string): number;
|
|
28
|
+
/**
|
|
29
|
+
* Map an OpenAI `finish_reason` into the Anthropic `stop_reason` the harness
|
|
30
|
+
* loop branches on (see the harness-providers spec — every provider adapts into Anthropic shape).
|
|
31
|
+
* The imminent `openai.ts` adapter is the first caller.
|
|
32
|
+
*/
|
|
33
|
+
export declare function mapOpenAiFinishReason(finishReason: string | null): Message["stop_reason"];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-model capability gates for harness provider calls.
|
|
3
|
+
*
|
|
4
|
+
* The harness `ChatRequest` is a passthrough of `MessageCreateParamsBase`,
|
|
5
|
+
* so callers already pass per-call overrides (`temperature`, `thinking`,
|
|
6
|
+
* tool config, …) as native fields. This module is the silent drop-on-reject
|
|
7
|
+
* gate at the provider edge: model-rejected fields are stripped before they
|
|
8
|
+
* hit the wire so the call still succeeds (e.g. `acceptsTemperature`).
|
|
9
|
+
*
|
|
10
|
+
* Classification is pattern-based on the bare model name (no provider
|
|
11
|
+
* prefix — the harness `createAnthropicProvider` already knows it is
|
|
12
|
+
* Anthropic). No network calls, no runtime probing.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Anthropic Opus/Sonnet/Haiku 4.7+ reject `temperature` with HTTP 400.
|
|
16
|
+
* 4.6 and earlier accept it.
|
|
17
|
+
*/
|
|
18
|
+
export function anthropicAcceptsTemperature(modelName) {
|
|
19
|
+
return !/^claude-(opus|sonnet|haiku)-4-([7-9]|\d{2,})\b/.test(modelName.toLowerCase());
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The model's true maximum output-token ceiling — the `max_tokens` the
|
|
23
|
+
* Anthropic provider sets per call (the API requires the field). Pattern-
|
|
24
|
+
* matched on the bare model name (no provider prefix). Ceilings per the
|
|
25
|
+
* current Anthropic model reference: Opus 4.x → 128K, Sonnet 4.6 → 64K,
|
|
26
|
+
* Haiku 4.5 → 64K.
|
|
27
|
+
*/
|
|
28
|
+
export function maxOutputTokens(modelName) {
|
|
29
|
+
const name = modelName.toLowerCase();
|
|
30
|
+
if (/^claude-opus-4-/.test(name))
|
|
31
|
+
return 128_000;
|
|
32
|
+
if (/^claude-sonnet-4-/.test(name))
|
|
33
|
+
return 64_000;
|
|
34
|
+
if (/^claude-haiku-4-/.test(name))
|
|
35
|
+
return 64_000;
|
|
36
|
+
// Unknown model — a generous default broadly accepted by current models;
|
|
37
|
+
// the loop recovers from truncation, so erring high is cheap.
|
|
38
|
+
return 32_768;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Map an OpenAI `finish_reason` into the Anthropic `stop_reason` the harness
|
|
42
|
+
* loop branches on (see the harness-providers spec — every provider adapts into Anthropic shape).
|
|
43
|
+
* The imminent `openai.ts` adapter is the first caller.
|
|
44
|
+
*/
|
|
45
|
+
export function mapOpenAiFinishReason(finishReason) {
|
|
46
|
+
switch (finishReason) {
|
|
47
|
+
case "length":
|
|
48
|
+
return "max_tokens";
|
|
49
|
+
case "tool_calls":
|
|
50
|
+
return "tool_use";
|
|
51
|
+
case "stop":
|
|
52
|
+
return "end_turn";
|
|
53
|
+
case "content_filter":
|
|
54
|
+
return "refusal";
|
|
55
|
+
default:
|
|
56
|
+
return "end_turn";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createStreamingChat` — a streaming `AgentChat`.
|
|
3
|
+
*
|
|
4
|
+
* The agent loop depends on `AgentChat`: one request in, one collapsed
|
|
5
|
+
* `ChatResponse` out. A `ChatProvider` satisfies that directly — its `chat`
|
|
6
|
+
* collapses the stream silently. This builds a SECOND `AgentChat` from the
|
|
7
|
+
* same provider's `chatStream` primitive: its `chat` drives the stream,
|
|
8
|
+
* forwards every text delta to `onText`, and returns the same collapsed
|
|
9
|
+
* `ChatResponse`. `runAgent` calls `chat` and never knows it streamed.
|
|
10
|
+
*
|
|
11
|
+
* The chat route is the one caller — it is the single place token streaming
|
|
12
|
+
* is wired. Sub-agent loops (planner, literature-reviewer) and workflow
|
|
13
|
+
* loops run on the plain `ChatProvider`, so they never stream.
|
|
14
|
+
*/
|
|
15
|
+
import type { AgentChat, ChatProvider } from "./types.js";
|
|
16
|
+
/**
|
|
17
|
+
* Wrap a `ChatProvider` as a streaming `AgentChat`. `onText` is called once
|
|
18
|
+
* per text delta, in arrival order, as a side effect of `chat`. `chat` is
|
|
19
|
+
* Result-returning: it consumes the throwing `chatStream` and maps a thrown
|
|
20
|
+
* SDK failure to `err(ProviderError)`; a client abort is re-thrown verbatim
|
|
21
|
+
* (control-flow, never the error channel).
|
|
22
|
+
*/
|
|
23
|
+
export declare function createStreamingChat(provider: ChatProvider, onText: (text: string) => void): AgentChat;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createStreamingChat` — a streaming `AgentChat`.
|
|
3
|
+
*
|
|
4
|
+
* The agent loop depends on `AgentChat`: one request in, one collapsed
|
|
5
|
+
* `ChatResponse` out. A `ChatProvider` satisfies that directly — its `chat`
|
|
6
|
+
* collapses the stream silently. This builds a SECOND `AgentChat` from the
|
|
7
|
+
* same provider's `chatStream` primitive: its `chat` drives the stream,
|
|
8
|
+
* forwards every text delta to `onText`, and returns the same collapsed
|
|
9
|
+
* `ChatResponse`. `runAgent` calls `chat` and never knows it streamed.
|
|
10
|
+
*
|
|
11
|
+
* The chat route is the one caller — it is the single place token streaming
|
|
12
|
+
* is wired. Sub-agent loops (planner, literature-reviewer) and workflow
|
|
13
|
+
* loops run on the plain `ChatProvider`, so they never stream.
|
|
14
|
+
*/
|
|
15
|
+
import { ResultAsync, err, ok } from "neverthrow";
|
|
16
|
+
import { scopeWorkloadId } from "../auth/types.js";
|
|
17
|
+
import { toProviderError } from "./errors.js";
|
|
18
|
+
/**
|
|
19
|
+
* Wrap a `ChatProvider` as a streaming `AgentChat`. `onText` is called once
|
|
20
|
+
* per text delta, in arrival order, as a side effect of `chat`. `chat` is
|
|
21
|
+
* Result-returning: it consumes the throwing `chatStream` and maps a thrown
|
|
22
|
+
* SDK failure to `err(ProviderError)`; a client abort is re-thrown verbatim
|
|
23
|
+
* (control-flow, never the error channel).
|
|
24
|
+
*/
|
|
25
|
+
export function createStreamingChat(provider, onText) {
|
|
26
|
+
return {
|
|
27
|
+
capabilities: provider.capabilities,
|
|
28
|
+
chat(req, session, signal) {
|
|
29
|
+
const workload = `${session.scope.kind}:${scopeWorkloadId(session.scope)}`;
|
|
30
|
+
const run = async () => {
|
|
31
|
+
let final;
|
|
32
|
+
try {
|
|
33
|
+
for await (const event of provider.chatStream(req, session, signal)) {
|
|
34
|
+
if (event.type === "text-delta") {
|
|
35
|
+
onText(event.text);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
final = event.response;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
if (e instanceof DOMException && e.name === "AbortError")
|
|
44
|
+
throw e;
|
|
45
|
+
if (e instanceof Error && e.name === "AbortError")
|
|
46
|
+
throw e;
|
|
47
|
+
return err(toProviderError(e, workload));
|
|
48
|
+
}
|
|
49
|
+
if (final === undefined) {
|
|
50
|
+
return err({
|
|
51
|
+
type: "provider",
|
|
52
|
+
retryable: false,
|
|
53
|
+
message: "createStreamingChat: chatStream ended without a final message",
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return ok(final);
|
|
57
|
+
};
|
|
58
|
+
return new ResultAsync(run());
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|