@inflexa-ai/harness 0.35.7 → 0.36.0
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/dist/auth/types.d.ts +5 -14
- package/dist/auth/types.js +3 -10
- package/dist/billing/usage-recorder.d.ts +1 -1
- package/dist/contracts/analogy-report.d.ts +1 -1
- package/dist/contracts/analogy-report.js +1 -1
- package/dist/contracts/chat-parts.d.ts +2 -3
- package/dist/contracts/index.d.ts +0 -4
- package/dist/contracts/index.js +0 -2
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -21
- package/dist/lib/metrics.d.ts +1 -1
- package/dist/lib/otel-spans.d.ts +0 -2
- package/dist/lib/otel-spans.js +0 -2
- package/dist/loop/genai-spans.d.ts +20 -0
- package/dist/loop/genai-spans.js +53 -0
- package/dist/loop/run-agent.d.ts +1 -1
- package/dist/loop/run-agent.js +9 -4
- package/dist/providers/ai-sdk.js +8 -0
- package/dist/runtime/assemble.d.ts +0 -3
- package/dist/runtime/assemble.js +0 -3
- package/dist/state/index.d.ts +0 -2
- package/dist/state/index.js +0 -1
- package/dist/state/init.js +1 -60
- package/dist/state/purge-analysis.d.ts +1 -2
- package/dist/state/purge-analysis.js +1 -2
- package/dist/tasks/regulatory-corpus-boot-refresh.js +1 -1
- package/dist/tools/bio/gene-preclinical-profile.d.ts +1 -3
- package/dist/tools/bio/gene-preclinical-profile.js +1 -3
- package/dist/tools/lib/chembl-client.d.ts +1 -4
- package/dist/tools/lib/chembl-client.js +1 -4
- package/dist/tools/lib/clinical-benchmarks-client.d.ts +1 -1
- package/dist/tools/lib/clinical-benchmarks-client.js +1 -1
- package/dist/tools/lib/clinical-trials-client.d.ts +0 -3
- package/dist/tools/lib/clinical-trials-client.js +0 -3
- package/dist/tools/lib/identifier-resolver.d.ts +5 -7
- package/dist/tools/lib/identifier-resolver.js +5 -7
- package/dist/tools/lib/iuphar-client.d.ts +1 -3
- package/dist/tools/lib/iuphar-client.js +1 -3
- package/dist/tools/lib/opentargets-client.d.ts +1 -1
- package/dist/tools/lib/opentargets-client.js +1 -1
- package/dist/tools/lib/protein-family-normalize.d.ts +5 -7
- package/dist/tools/lib/protein-family-normalize.js +5 -7
- package/dist/tools/lib/uniprot-client.d.ts +0 -7
- package/dist/tools/lib/uniprot-client.js +2 -9
- package/package.json +9 -8
- package/dist/contracts/target-assessment-row.d.ts +0 -85
- package/dist/contracts/target-assessment-row.js +0 -37
- package/dist/contracts/target-dossier.d.ts +0 -12423
- package/dist/contracts/target-dossier.js +0 -1282
- package/dist/prompts/target-assessment/briefs/executive-recommendation.d.ts +0 -1
- package/dist/prompts/target-assessment/briefs/executive-recommendation.js +0 -85
- package/dist/prompts/target-assessment/briefs/index.d.ts +0 -4
- package/dist/prompts/target-assessment/briefs/index.js +0 -4
- package/dist/prompts/target-assessment/briefs/liability-bullets.d.ts +0 -1
- package/dist/prompts/target-assessment/briefs/liability-bullets.js +0 -114
- package/dist/prompts/target-assessment/briefs/target-organ-liabilities.d.ts +0 -1
- package/dist/prompts/target-assessment/briefs/target-organ-liabilities.js +0 -37
- package/dist/prompts/target-assessment/briefs/translational-commentary.d.ts +0 -1
- package/dist/prompts/target-assessment/briefs/translational-commentary.js +0 -23
- package/dist/prompts/target-assessment/drugs-in-class.d.ts +0 -1
- package/dist/prompts/target-assessment/drugs-in-class.js +0 -29
- package/dist/prompts/target-assessment/investigation/adversarial-critique.d.ts +0 -1
- package/dist/prompts/target-assessment/investigation/adversarial-critique.js +0 -67
- package/dist/prompts/target-assessment/investigation/claim-reverification.d.ts +0 -1
- package/dist/prompts/target-assessment/investigation/claim-reverification.js +0 -49
- package/dist/prompts/target-assessment/investigation/index.d.ts +0 -3
- package/dist/prompts/target-assessment/investigation/index.js +0 -3
- package/dist/prompts/target-assessment/investigation/mechanism-proposal.d.ts +0 -1
- package/dist/prompts/target-assessment/investigation/mechanism-proposal.js +0 -49
- package/dist/prompts/target-assessment/modulator-triage.d.ts +0 -1
- package/dist/prompts/target-assessment/modulator-triage.js +0 -31
- package/dist/prompts/target-assessment/off-target-annotator.d.ts +0 -1
- package/dist/prompts/target-assessment/off-target-annotator.js +0 -28
- package/dist/prompts/target-assessment/tox-voice/core.d.ts +0 -1
- package/dist/prompts/target-assessment/tox-voice/core.js +0 -74
- package/dist/prompts/target-assessment/tox-voice/critique.d.ts +0 -7
- package/dist/prompts/target-assessment/tox-voice/critique.js +0 -109
- package/dist/prompts/target-assessment/tox-voice/exemplars.d.ts +0 -8
- package/dist/prompts/target-assessment/tox-voice/exemplars.js +0 -24
- package/dist/prompts/target-assessment/tox-voice/index.d.ts +0 -4
- package/dist/prompts/target-assessment/tox-voice/index.js +0 -4
- package/dist/prompts/target-assessment/tox-voice/vocabulary.d.ts +0 -18
- package/dist/prompts/target-assessment/tox-voice/vocabulary.js +0 -61
- package/dist/state/target-assessments.d.ts +0 -68
- package/dist/state/target-assessments.js +0 -222
- package/dist/workflows/execute-target-assessment.d.ts +0 -118
- package/dist/workflows/execute-target-assessment.js +0 -631
- package/dist/workflows/target-assessment/assemblers/index.d.ts +0 -5
- package/dist/workflows/target-assessment/assemblers/index.js +0 -4
- package/dist/workflows/target-assessment/assemblers/literature.d.ts +0 -281
- package/dist/workflows/target-assessment/assemblers/literature.js +0 -971
- package/dist/workflows/target-assessment/assemblers/orchestrator.d.ts +0 -118
- package/dist/workflows/target-assessment/assemblers/orchestrator.js +0 -945
- package/dist/workflows/target-assessment/assemblers/safety.d.ts +0 -374
- package/dist/workflows/target-assessment/assemblers/safety.js +0 -1068
- package/dist/workflows/target-assessment/assemblers/trials.d.ts +0 -30
- package/dist/workflows/target-assessment/assemblers/trials.js +0 -75
- package/dist/workflows/target-assessment/collectors/index.d.ts +0 -114
- package/dist/workflows/target-assessment/collectors/index.js +0 -538
- package/dist/workflows/target-assessment/coverage.d.ts +0 -97
- package/dist/workflows/target-assessment/coverage.js +0 -86
- package/dist/workflows/target-assessment/decisions/index.d.ts +0 -86
- package/dist/workflows/target-assessment/decisions/index.js +0 -127
- package/dist/workflows/target-assessment/fanout/index.d.ts +0 -32
- package/dist/workflows/target-assessment/fanout/index.js +0 -156
- package/dist/workflows/target-assessment/investigation/index.d.ts +0 -97
- package/dist/workflows/target-assessment/investigation/index.js +0 -419
- package/dist/workflows/target-assessment/lib/approval-precedents.d.ts +0 -73
- package/dist/workflows/target-assessment/lib/approval-precedents.js +0 -185
- package/dist/workflows/target-assessment/lib/citation-validator.d.ts +0 -46
- package/dist/workflows/target-assessment/lib/citation-validator.js +0 -316
- package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.d.ts +0 -65
- package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.js +0 -174
- package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.d.ts +0 -44
- package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.js +0 -152
- package/dist/workflows/target-assessment/lib/compute-derived.d.ts +0 -20
- package/dist/workflows/target-assessment/lib/compute-derived.js +0 -261
- package/dist/workflows/target-assessment/lib/compute-selectivity.d.ts +0 -15
- package/dist/workflows/target-assessment/lib/compute-selectivity.js +0 -18
- package/dist/workflows/target-assessment/lib/dedup-modulators.d.ts +0 -37
- package/dist/workflows/target-assessment/lib/dedup-modulators.js +0 -157
- package/dist/workflows/target-assessment/lib/evidence-conflict-detector.d.ts +0 -17
- package/dist/workflows/target-assessment/lib/evidence-conflict-detector.js +0 -100
- package/dist/workflows/target-assessment/lib/expression-constants.d.ts +0 -21
- package/dist/workflows/target-assessment/lib/expression-constants.js +0 -21
- package/dist/workflows/target-assessment/lib/family-complex-supplement.d.ts +0 -20
- package/dist/workflows/target-assessment/lib/family-complex-supplement.js +0 -36
- package/dist/workflows/target-assessment/lib/fda-label-safety.d.ts +0 -72
- package/dist/workflows/target-assessment/lib/fda-label-safety.js +0 -166
- package/dist/workflows/target-assessment/lib/heterodimer-filter.d.ts +0 -30
- package/dist/workflows/target-assessment/lib/heterodimer-filter.js +0 -44
- package/dist/workflows/target-assessment/lib/hpo-organ-map.d.ts +0 -34
- package/dist/workflows/target-assessment/lib/hpo-organ-map.js +0 -63
- package/dist/workflows/target-assessment/lib/impc-organ-map.d.ts +0 -19
- package/dist/workflows/target-assessment/lib/impc-organ-map.js +0 -39
- package/dist/workflows/target-assessment/lib/intended-polypharm-filter.d.ts +0 -4
- package/dist/workflows/target-assessment/lib/intended-polypharm-filter.js +0 -24
- package/dist/workflows/target-assessment/lib/llm-step.d.ts +0 -80
- package/dist/workflows/target-assessment/lib/llm-step.js +0 -101
- package/dist/workflows/target-assessment/lib/meddra-organ-map.d.ts +0 -40
- package/dist/workflows/target-assessment/lib/meddra-organ-map.js +0 -138
- package/dist/workflows/target-assessment/lib/recommendation-quality-gates.d.ts +0 -17
- package/dist/workflows/target-assessment/lib/recommendation-quality-gates.js +0 -99
- package/dist/workflows/target-assessment/lib/recommendation-sanitizer.d.ts +0 -2
- package/dist/workflows/target-assessment/lib/recommendation-sanitizer.js +0 -51
- package/dist/workflows/target-assessment/lib/regulatory-actions.d.ts +0 -25
- package/dist/workflows/target-assessment/lib/regulatory-actions.js +0 -176
- package/dist/workflows/target-assessment/lib/safety-corroboration.d.ts +0 -44
- package/dist/workflows/target-assessment/lib/safety-corroboration.js +0 -273
- package/dist/workflows/target-assessment/lib/structured-llm.d.ts +0 -61
- package/dist/workflows/target-assessment/lib/structured-llm.js +0 -102
- package/dist/workflows/target-assessment/lib/target-identity-filter.d.ts +0 -59
- package/dist/workflows/target-assessment/lib/target-identity-filter.js +0 -95
- package/dist/workflows/target-assessment/lib/therapeutic-programs.d.ts +0 -20
- package/dist/workflows/target-assessment/lib/therapeutic-programs.js +0 -68
- package/dist/workflows/target-assessment/metrics.d.ts +0 -16
- package/dist/workflows/target-assessment/metrics.js +0 -30
- package/dist/workflows/target-assessment/phase4-assemble.d.ts +0 -3182
- package/dist/workflows/target-assessment/phase4-assemble.js +0 -39
- package/dist/workflows/target-assessment/phase5-persist.d.ts +0 -59
- package/dist/workflows/target-assessment/phase5-persist.js +0 -349
- package/dist/workflows/target-assessment/progress-stream.d.ts +0 -75
- package/dist/workflows/target-assessment/progress-stream.js +0 -110
- package/dist/workflows/target-assessment/progress.d.ts +0 -39
- package/dist/workflows/target-assessment/progress.js +0 -77
- package/dist/workflows/target-assessment/schemas.d.ts +0 -970
- package/dist/workflows/target-assessment/schemas.js +0 -318
- package/dist/workflows/target-assessment/steps/collectors/pathways.d.ts +0 -15
- package/dist/workflows/target-assessment/steps/collectors/pathways.js +0 -58
- package/dist/workflows/target-assessment/steps/fanout/aes-for-one-class-drug-step.d.ts +0 -34
- package/dist/workflows/target-assessment/steps/fanout/aes-for-one-class-drug-step.js +0 -31
- package/dist/workflows/target-assessment/steps/fanout/aes-for-one-trial-step.d.ts +0 -57
- package/dist/workflows/target-assessment/steps/fanout/aes-for-one-trial-step.js +0 -54
- package/dist/workflows/target-assessment/steps/fanout/faers-for-one-modulator-step.d.ts +0 -35
- package/dist/workflows/target-assessment/steps/fanout/faers-for-one-modulator-step.js +0 -32
- package/dist/workflows/target-assessment/steps/fanout/index.d.ts +0 -14
- package/dist/workflows/target-assessment/steps/fanout/index.js +0 -10
- package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.d.ts +0 -29
- package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.js +0 -29
- package/dist/workflows/target-assessment/steps/phase2-aggregate.d.ts +0 -657
- package/dist/workflows/target-assessment/steps/phase2-aggregate.js +0 -34
- package/dist/workflows/target-assessment/steps/phase3-aggregate.d.ts +0 -806
- package/dist/workflows/target-assessment/steps/phase3-aggregate.js +0 -16
- package/dist/workflows/target-assessment/steps/synthesis/diagnostics.d.ts +0 -28
- package/dist/workflows/target-assessment/steps/synthesis/diagnostics.js +0 -27
- package/dist/workflows/target-assessment/sub-workflows/index.d.ts +0 -15
- package/dist/workflows/target-assessment/sub-workflows/index.js +0 -11
- package/dist/workflows/target-assessment/sub-workflows/per-class-drug-aes.d.ts +0 -41
- package/dist/workflows/target-assessment/sub-workflows/per-class-drug-aes.js +0 -12
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-faers.d.ts +0 -41
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-faers.js +0 -12
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-polypharm.d.ts +0 -37
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-polypharm.js +0 -12
- package/dist/workflows/target-assessment/sub-workflows/per-trial-aes.d.ts +0 -66
- package/dist/workflows/target-assessment/sub-workflows/per-trial-aes.js +0 -12
- package/dist/workflows/target-assessment/synthesis/index.d.ts +0 -607
- package/dist/workflows/target-assessment/synthesis/index.js +0 -354
- package/dist/workflows/target-assessment/synthesis-probes.d.ts +0 -56
- package/dist/workflows/target-assessment/synthesis-probes.js +0 -320
package/dist/auth/types.d.ts
CHANGED
|
@@ -24,18 +24,14 @@ export interface Identity {
|
|
|
24
24
|
readonly user: string;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* What the request operates on
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* What the request operates on. It owns its resource coordinates
|
|
28
|
+
* (`scopeResource`) and the workload id (`scopeWorkloadId`) used for
|
|
29
|
+
* attribution.
|
|
30
30
|
*/
|
|
31
31
|
export type Scope = {
|
|
32
32
|
readonly kind: "analysis";
|
|
33
33
|
readonly analysisId: string;
|
|
34
34
|
readonly threadId?: string;
|
|
35
|
-
} | {
|
|
36
|
-
readonly kind: "target-assessment";
|
|
37
|
-
readonly targetAssessmentId: string;
|
|
38
|
-
readonly billingContextId: string;
|
|
39
35
|
};
|
|
40
36
|
declare const CRED_BRAND: unique symbol;
|
|
41
37
|
/**
|
|
@@ -64,15 +60,10 @@ export interface RunFrame {
|
|
|
64
60
|
}
|
|
65
61
|
/** Canonical resource coordinates a `Scope` resolves to. */
|
|
66
62
|
export interface ResourceCoordinates {
|
|
67
|
-
readonly resourceType: "analysis"
|
|
63
|
+
readonly resourceType: "analysis";
|
|
68
64
|
readonly resourceId: string;
|
|
69
65
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Derive the `{ resourceType, resourceId }` a scope resolves through.
|
|
72
|
-
* Analysis → `{ "analysis", analysisId }`; target-assessment →
|
|
73
|
-
* `{ "billing_context", billingContextId }` (TA resolves billing via the
|
|
74
|
-
* billing-context discriminator until it is a first-class resource).
|
|
75
|
-
*/
|
|
66
|
+
/** Derive the `{ resourceType, resourceId }` a scope resolves through: `{ "analysis", analysisId }`. */
|
|
76
67
|
export declare function scopeResource(scope: Scope): ResourceCoordinates;
|
|
77
68
|
/** The value stamped into the workload tag — the workload id for this scope. */
|
|
78
69
|
export declare function scopeWorkloadId(scope: Scope): string;
|
package/dist/auth/types.js
CHANGED
|
@@ -19,20 +19,13 @@
|
|
|
19
19
|
* Neither bundle carries resolved billing headers — billing is resolved
|
|
20
20
|
* lazily at the LLM call site (see `harness/billing/resolver.ts`).
|
|
21
21
|
*/
|
|
22
|
-
/**
|
|
23
|
-
* Derive the `{ resourceType, resourceId }` a scope resolves through.
|
|
24
|
-
* Analysis → `{ "analysis", analysisId }`; target-assessment →
|
|
25
|
-
* `{ "billing_context", billingContextId }` (TA resolves billing via the
|
|
26
|
-
* billing-context discriminator until it is a first-class resource).
|
|
27
|
-
*/
|
|
22
|
+
/** Derive the `{ resourceType, resourceId }` a scope resolves through: `{ "analysis", analysisId }`. */
|
|
28
23
|
export function scopeResource(scope) {
|
|
29
|
-
return
|
|
30
|
-
? { resourceType: "analysis", resourceId: scope.analysisId }
|
|
31
|
-
: { resourceType: "billing_context", resourceId: scope.billingContextId };
|
|
24
|
+
return { resourceType: "analysis", resourceId: scope.analysisId };
|
|
32
25
|
}
|
|
33
26
|
/** The value stamped into the workload tag — the workload id for this scope. */
|
|
34
27
|
export function scopeWorkloadId(scope) {
|
|
35
|
-
return scope.
|
|
28
|
+
return scope.analysisId;
|
|
36
29
|
}
|
|
37
30
|
/**
|
|
38
31
|
* Derive a child session for a sub-agent call — provenance only. Sets the
|
|
@@ -36,7 +36,7 @@ export interface LlmUsageRecord {
|
|
|
36
36
|
readonly agentId: string;
|
|
37
37
|
/** Provenance path from the root agent down to `agentId`. */
|
|
38
38
|
readonly callPath: readonly string[];
|
|
39
|
-
/** Scope ids as attribution: `analysisId
|
|
39
|
+
/** Scope ids as attribution: `analysisId`. */
|
|
40
40
|
readonly scope: Scope;
|
|
41
41
|
/** Present only for calls made inside a run (the session carries a `RunFrame`). */
|
|
42
42
|
readonly runId?: string;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* source of truth for the JSON envelope returned to the conversation
|
|
4
4
|
* agent. Both Cortex and the frontend import from this module.
|
|
5
5
|
*
|
|
6
|
-
* Coverage discipline
|
|
6
|
+
* Coverage discipline: every analogy carries a
|
|
7
7
|
* `coverage` discriminator. Only the extraction phase is allowed to throw;
|
|
8
8
|
* search-phase failures surface via `coverage: "search_failed" |
|
|
9
9
|
* "queried_no_data" | "not_loaded"`.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* source of truth for the JSON envelope returned to the conversation
|
|
4
4
|
* agent. Both Cortex and the frontend import from this module.
|
|
5
5
|
*
|
|
6
|
-
* Coverage discipline
|
|
6
|
+
* Coverage discipline: every analogy carries a
|
|
7
7
|
* `coverage` discriminator. Only the extraction phase is allowed to throw;
|
|
8
8
|
* search-phase failures surface via `coverage: "search_failed" |
|
|
9
9
|
* "queried_no_data" | "not_loaded"`.
|
|
@@ -211,9 +211,8 @@ export interface StepSummaryPart {
|
|
|
211
211
|
* absent or zeroed figure. Per-call granularity is the usage-record ledger's
|
|
212
212
|
* job, never this part's.
|
|
213
213
|
*
|
|
214
|
-
* Scoped to analysis runs. Workflows without step parts (
|
|
215
|
-
*
|
|
216
|
-
* carry no usage part.
|
|
214
|
+
* Scoped to analysis runs. Workflows without step parts (ephemeral runs, data
|
|
215
|
+
* profiling) reach the ledger through the recorder seam and carry no usage part.
|
|
217
216
|
*/
|
|
218
217
|
export interface StepUsagePart {
|
|
219
218
|
type: "data-step-usage";
|
|
@@ -14,8 +14,4 @@ export { PART_REGISTRY, isTransient, isReconciling, isSidebarPart } from "./part
|
|
|
14
14
|
export type { CortexChatPartType, PartDescriptor, PartEmitter, PartConsumer } from "./part-registry.js";
|
|
15
15
|
export { AnalogyCoverageSchema, AnalogyReportSchema, AnalogyReportErrorSchema, AnalogicalReasonerOutputSchema } from "./analogy-report.js";
|
|
16
16
|
export type { AnalogyCoverage, AnalogyReport, AnalogyReportError, AnalogicalReasonerOutput } from "./analogy-report.js";
|
|
17
|
-
export { CoverageSchema, RowCoverageSchema, EntitySchema, ClaimSupportSchema, ClaimEvidenceSchema, LiabilityBulletSchema, LiabilitySummarySchema, TractabilitySchema, IndicationsSchema, DrugInteractionsSchema, ClinicalTrialAttributionSchema, ClinicalDevelopmentSchema, OrganRiskRowSchema, OffTargetRowSchema, OffTargetPanelSchema, RegulatoryActionRowSchema, SafetyFlagSchema, SafetyProfileSchema, OffTissueRowSchema, OffTissueRiskSchema, ReferenceBiologyShape, EvidenceConflictsSchema, EvidenceTimelineSchema, TranslationalChainSchema, AdditionalEvidenceSchema, DiscoveryTrialsSchema, QualityGateStatusSchema, QualityGatesSchema, DerivedSchema, DossierSchema, DossierBodySchema, isDossier, dossierJsonSchema, SECTION_BLURBS, TargetAssessmentPhaseSchema, TargetAssessmentProgressEventSchema, } from "./target-dossier.js";
|
|
18
|
-
export type { Coverage, RowCoverage, Entity, EvidenceItem, ClaimSupport, ClaimEvidence, LiabilityBullet, LiabilitySummary, TractabilitySection, ClinicalTrialAttribution, ClinicalTrialRow, ClinicalDevelopment, FailedTrialRow, TrialOutcomeRow, OrganRiskRow, OffTargetRow, RegulatoryActionRow, SafetyFlag, SafetyProfile, OffTissueRow, QualityGateStatus, QualityGates, Derived, Dossier, DossierBody, SectionBlurbKey, TargetAssessmentPhase, TargetAssessmentProgressEvent, } from "./target-dossier.js";
|
|
19
|
-
export { TargetAssessmentStatusSchema, TargetAssessmentErrorSchema, TargetAssessmentListRowSchema, TargetAssessmentRowSchema, } from "./target-assessment-row.js";
|
|
20
|
-
export type { TargetAssessmentStatus, TargetAssessmentError, TargetAssessmentListRow, TargetAssessmentRow } from "./target-assessment-row.js";
|
|
21
17
|
export { buildReportSessionUrl, reportSessionResourceId } from "./content-url.js";
|
package/dist/contracts/index.js
CHANGED
|
@@ -4,6 +4,4 @@ export { DATA_PROFILE_RUN_LITERAL } from "./data-profile.js";
|
|
|
4
4
|
export { DIMENSION_CATEGORIES, DIMENSION_CATEGORY_IDS, DIMENSION_PROBE_IDS, DIMENSION_PROBES, GROUP_CATEGORIES, GROUP_CATEGORY_IDS, GROUP_ROLE_IDS, GROUP_ROLES, PROBE_OUTCOME_IDS, dimensionCategoryEntry, dimensionScope, groupCategoryEntry, } from "./profile-vocabulary.js";
|
|
5
5
|
export { PART_REGISTRY, isTransient, isReconciling, isSidebarPart } from "./part-registry.js";
|
|
6
6
|
export { AnalogyCoverageSchema, AnalogyReportSchema, AnalogyReportErrorSchema, AnalogicalReasonerOutputSchema } from "./analogy-report.js";
|
|
7
|
-
export { CoverageSchema, RowCoverageSchema, EntitySchema, ClaimSupportSchema, ClaimEvidenceSchema, LiabilityBulletSchema, LiabilitySummarySchema, TractabilitySchema, IndicationsSchema, DrugInteractionsSchema, ClinicalTrialAttributionSchema, ClinicalDevelopmentSchema, OrganRiskRowSchema, OffTargetRowSchema, OffTargetPanelSchema, RegulatoryActionRowSchema, SafetyFlagSchema, SafetyProfileSchema, OffTissueRowSchema, OffTissueRiskSchema, ReferenceBiologyShape, EvidenceConflictsSchema, EvidenceTimelineSchema, TranslationalChainSchema, AdditionalEvidenceSchema, DiscoveryTrialsSchema, QualityGateStatusSchema, QualityGatesSchema, DerivedSchema, DossierSchema, DossierBodySchema, isDossier, dossierJsonSchema, SECTION_BLURBS, TargetAssessmentPhaseSchema, TargetAssessmentProgressEventSchema, } from "./target-dossier.js";
|
|
8
|
-
export { TargetAssessmentStatusSchema, TargetAssessmentErrorSchema, TargetAssessmentListRowSchema, TargetAssessmentRowSchema, } from "./target-assessment-row.js";
|
|
9
7
|
export { buildReportSessionUrl, reportSessionResourceId } from "./content-url.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -156,13 +156,6 @@ export { registerExecuteAnalysis } from "./workflows/execute-analysis.js";
|
|
|
156
156
|
export type { ExecuteAnalysisDeps, ExecuteAnalysisInput, ExecuteAnalysisResult, RunObservation, RunStepObservation, StepRuntimeStatus, } from "./workflows/execute-analysis.js";
|
|
157
157
|
export { registerSandboxStep } from "./workflows/sandbox-step.js";
|
|
158
158
|
export type { SandboxStepDeps, SandboxStepInput, SandboxStepResult, SandboxAgentBuildContext } from "./workflows/sandbox-step.js";
|
|
159
|
-
export { DEFAULT_CLAIM_INVESTIGATION_CONFIG } from "./workflows/target-assessment/investigation/index.js";
|
|
160
|
-
export type { ClaimInvestigationConfig } from "./workflows/target-assessment/investigation/index.js";
|
|
161
|
-
export { insertAssessment, getAssessment, updateProgress, listAssessmentsByOrg } from "./state/target-assessments.js";
|
|
162
|
-
export type { InsertAssessmentInput, ListAssessmentsOptions } from "./state/target-assessments.js";
|
|
163
|
-
export type { TargetAssessmentRow, TargetAssessmentListRow, TargetAssessmentStatus, TargetAssessmentError } from "./state/target-assessments.js";
|
|
164
|
-
export { createTargetAssessmentProgressStream } from "./workflows/target-assessment/progress-stream.js";
|
|
165
|
-
export type { TargetAssessmentProgressStream, TargetAssessmentProgressStreamDeps, TargetAssessmentProgressHandler, TargetAssessmentProgressSubscribeOptions, } from "./workflows/target-assessment/progress-stream.js";
|
|
166
159
|
export { createRunEventStream } from "./execution/run-event-stream.js";
|
|
167
160
|
export type { RunEventStream, RunEventStreamDeps, RunEventSubscribeOptions, RunEventPartHandler } from "./execution/run-event-stream.js";
|
|
168
161
|
export { createSandboxAgents, SANDBOX_AGENT_META } from "./agents/sandbox/index.js";
|
package/dist/index.js
CHANGED
|
@@ -271,27 +271,6 @@ export { ExecEventMessageSchema } from "./sandbox/types.js";
|
|
|
271
271
|
// these, but an embedder running only the run engine registers them directly.
|
|
272
272
|
export { registerExecuteAnalysis } from "./workflows/execute-analysis.js";
|
|
273
273
|
export { registerSandboxStep } from "./workflows/sandbox-step.js";
|
|
274
|
-
// Target assessment — the bounds its claim-investigation phase runs under. An
|
|
275
|
-
// embedder wiring `executeTargetAssessment` sets these at its composition root;
|
|
276
|
-
// the dossier reports whichever values were in force.
|
|
277
|
-
export { DEFAULT_CLAIM_INVESTIGATION_CONFIG } from "./workflows/target-assessment/investigation/index.js";
|
|
278
|
-
// The row surface of `cortex_target_assessments`: the intake write an embedder's
|
|
279
|
-
// trigger route makes, the two reads its detail and list routes make, and the
|
|
280
|
-
// progress write. The row types ride with them — `getAssessment` and
|
|
281
|
-
// `listAssessmentsByOrg` hand back values an embedder cannot hold without naming,
|
|
282
|
-
// and `TargetAssessmentStatus` is what a host switches on to render one. The
|
|
283
|
-
// terminal writers (`setDossier`, `markFailed`, `markAssessmentSuspended`,
|
|
284
|
-
// `markAssessmentRunning`, `softDeleteAssessment`) stay off the front door: the
|
|
285
|
-
// workflow's own terminal path owns them, and an embedder calling one races the
|
|
286
|
-
// state the workflow is about to write.
|
|
287
|
-
export { insertAssessment, getAssessment, updateProgress, listAssessmentsByOrg } from "./state/target-assessments.js";
|
|
288
|
-
// The read side of a target assessment's progress stream. `emitProgress` writes
|
|
289
|
-
// one part per phase and the workflow owns that write; this is the only way to
|
|
290
|
-
// read it back without reaching for the durability engine, which is exactly what
|
|
291
|
-
// an embedder rendering a progress bar would otherwise have to do. One stream per
|
|
292
|
-
// assessment (`workflowID === assessmentId`), so it needs no pool — unlike the
|
|
293
|
-
// run-event seam below, which fans in a parent and its children.
|
|
294
|
-
export { createTargetAssessmentProgressStream } from "./workflows/target-assessment/progress-stream.js";
|
|
295
274
|
// Run-event read seam — the fine-grained durable channel beside `observeRun`.
|
|
296
275
|
// The two are a deliberate pair, not a duplication: `observeRun` is the coarse,
|
|
297
276
|
// in-process run/step snapshot a workflow hands its host synchronously, and it
|
package/dist/lib/metrics.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ import type { StepExecutionStatus } from "../state/schema.js";
|
|
|
35
35
|
/** Terminal status of a run. A budget pause records as `canceled`, the same as the run ledger. */
|
|
36
36
|
export type RunOutcome = "completed" | "partial" | "failed" | "canceled";
|
|
37
37
|
/** The workflow family a run belongs to. */
|
|
38
|
-
export type RunWorkflow = "analysis" | "
|
|
38
|
+
export type RunWorkflow = "analysis" | "data_profile";
|
|
39
39
|
/** Terminal status of an executed step. A blocker is a failure to deliver, so `blocked` maps here to `failed`. */
|
|
40
40
|
export type StepOutcome = "completed" | "failed" | "canceled";
|
|
41
41
|
/**
|
package/dist/lib/otel-spans.d.ts
CHANGED
|
@@ -48,8 +48,6 @@ export declare const ATTR_INFLEXA_TOOL_USE_ID = "inflexa.tool_use_id";
|
|
|
48
48
|
export declare const ATTR_INFLEXA_EXEC_ID = "inflexa.exec_id";
|
|
49
49
|
/** The 1-based attempt counter of a sandbox poll, pull, or liveness-probe step. */
|
|
50
50
|
export declare const ATTR_INFLEXA_ATTEMPT = "inflexa.attempt";
|
|
51
|
-
/** The per-item key (a ChEMBL or NCT id) of a target-assessment fan-out step. */
|
|
52
|
-
export declare const ATTR_INFLEXA_FANOUT_KEY = "inflexa.fanout_key";
|
|
53
51
|
/**
|
|
54
52
|
* Rename the DBOS span of the step that is running to `name` and put its id
|
|
55
53
|
* in `attributes`. Call it as the first statement of a step body whose DBOS
|
package/dist/lib/otel-spans.js
CHANGED
|
@@ -71,8 +71,6 @@ export const ATTR_INFLEXA_TOOL_USE_ID = "inflexa.tool_use_id";
|
|
|
71
71
|
export const ATTR_INFLEXA_EXEC_ID = "inflexa.exec_id";
|
|
72
72
|
/** The 1-based attempt counter of a sandbox poll, pull, or liveness-probe step. */
|
|
73
73
|
export const ATTR_INFLEXA_ATTEMPT = "inflexa.attempt";
|
|
74
|
-
/** The per-item key (a ChEMBL or NCT id) of a target-assessment fan-out step. */
|
|
75
|
-
export const ATTR_INFLEXA_FANOUT_KEY = "inflexa.fanout_key";
|
|
76
74
|
/**
|
|
77
75
|
* Rename the DBOS span of the step that is running to `name` and put its id
|
|
78
76
|
* in `attributes`. Call it as the first statement of a step body whose DBOS
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenTelemetry GenAI spans for the agent loop: `invoke_agent` around a run of
|
|
3
|
+
* `runAgent`, and `execute_tool` around each tool call that it dispatches. The AI
|
|
4
|
+
* SDK traces the model calls (`providers/ai-sdk.ts`). It never sees the loop or
|
|
5
|
+
* the tools, because the harness runs both itself.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolCallPart } from "ai";
|
|
8
|
+
import type { AgentSession } from "../auth/types.js";
|
|
9
|
+
import type { ToolOutcome } from "./tool-outcome.js";
|
|
10
|
+
interface AgentRun {
|
|
11
|
+
readonly finish: {
|
|
12
|
+
readonly reason: string;
|
|
13
|
+
readonly cappedOut: boolean;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Run one agent loop under an `invoke_agent` span. */
|
|
17
|
+
export declare function traceAgentRun<T extends AgentRun>(agentName: string, session: AgentSession, run: () => Promise<T>): Promise<T>;
|
|
18
|
+
/** Run one tool call under an `execute_tool` span that records how the call ended. */
|
|
19
|
+
export declare function traceToolCall<T>(call: Pick<ToolCallPart, "toolName" | "toolCallId">, run: () => Promise<T>, outcomeOf: (value: T) => ToolOutcome): Promise<T>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenTelemetry GenAI spans for the agent loop: `invoke_agent` around a run of
|
|
3
|
+
* `runAgent`, and `execute_tool` around each tool call that it dispatches. The AI
|
|
4
|
+
* SDK traces the model calls (`providers/ai-sdk.ts`). It never sees the loop or
|
|
5
|
+
* the tools, because the harness runs both itself.
|
|
6
|
+
*/
|
|
7
|
+
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
|
+
/** Run one agent loop under an `invoke_agent` span. */
|
|
9
|
+
export function traceAgentRun(agentName, session, run) {
|
|
10
|
+
const attributes = { "gen_ai.operation.name": "invoke_agent", "gen_ai.agent.name": agentName, ...runFrameAttributes(session) };
|
|
11
|
+
return withSpan(`invoke_agent ${agentName}`, attributes, async (span) => {
|
|
12
|
+
const result = await run();
|
|
13
|
+
span.setAttributes({ "gen_ai.response.finish_reasons": [result.finish.reason], "inflexa.agent.capped_out": result.finish.cappedOut });
|
|
14
|
+
return result;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/** Run one tool call under an `execute_tool` span that records how the call ended. */
|
|
18
|
+
export function traceToolCall(call, run, outcomeOf) {
|
|
19
|
+
const attributes = { "gen_ai.operation.name": "execute_tool", "gen_ai.tool.name": call.toolName, "gen_ai.tool.call.id": call.toolCallId };
|
|
20
|
+
return withSpan(`execute_tool ${call.toolName}`, attributes, async (span) => {
|
|
21
|
+
const value = await run();
|
|
22
|
+
const outcome = outcomeOf(value);
|
|
23
|
+
span.setAttribute("inflexa.tool.outcome", outcome);
|
|
24
|
+
if (outcome === "error")
|
|
25
|
+
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
26
|
+
return value;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function withSpan(name, attributes, run) {
|
|
30
|
+
return trace.getTracer("@inflexa-ai/harness").startActiveSpan(name, { attributes }, async (span) => {
|
|
31
|
+
try {
|
|
32
|
+
return await run(span);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
// A cancellation is the caller's decision, not a failure.
|
|
36
|
+
const cancelled = err instanceof Error && err.name === "AbortError";
|
|
37
|
+
if (!cancelled) {
|
|
38
|
+
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
39
|
+
if (err instanceof Error)
|
|
40
|
+
span.recordException(err);
|
|
41
|
+
}
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
span.end();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function runFrameAttributes({ runFrame }) {
|
|
50
|
+
if (runFrame === undefined)
|
|
51
|
+
return {};
|
|
52
|
+
return { "inflexa.run_id": runFrame.runId, ...(runFrame.stepId === undefined ? {} : { "inflexa.step_id": runFrame.stepId }) };
|
|
53
|
+
}
|
package/dist/loop/run-agent.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export interface RunAgentOptions {
|
|
|
70
70
|
*
|
|
71
71
|
* The policy lives here, on the run, rather than on the provider, precisely
|
|
72
72
|
* so it applies to loops and *not* to the one-shot LLM calls made elsewhere
|
|
73
|
-
* (report generation
|
|
73
|
+
* (report generation): those would pay the
|
|
74
74
|
* cache-write premium for a cache nothing ever reads back.
|
|
75
75
|
*/
|
|
76
76
|
readonly promptCache?: PromptCachePolicy;
|
package/dist/loop/run-agent.js
CHANGED
|
@@ -13,6 +13,7 @@ import { DEFAULT_REASONING } from "../providers/reasoning.js";
|
|
|
13
13
|
import { resultStep } from "./run-step.js";
|
|
14
14
|
import { AskRejectedError, UnavailableAsk } from "../tools/approval/contract.js";
|
|
15
15
|
import { isToolError, readToolResultImages } from "../tools/define-tool.js";
|
|
16
|
+
import { traceAgentRun, traceToolCall } from "./genai-spans.js";
|
|
16
17
|
import { addChatUsage, hasReportedUsage, recordAgentRun } from "./metrics.js";
|
|
17
18
|
import { computeDetail, computeResultDetail } from "./tool-detail.js";
|
|
18
19
|
import { toolOutcomeForOutputType } from "./tool-outcome.js";
|
|
@@ -22,7 +23,10 @@ export const DEFAULT_STEP_NAME_FORMATTER = {
|
|
|
22
23
|
llm: (i) => `llm-${i}`,
|
|
23
24
|
tool: (name, id) => `tool-${name}-${id}`,
|
|
24
25
|
};
|
|
25
|
-
export
|
|
26
|
+
export function runAgent(agent, initial, session, opts) {
|
|
27
|
+
return traceAgentRun(agent.id, session, () => runAgentLoop(agent, initial, session, opts));
|
|
28
|
+
}
|
|
29
|
+
async function runAgentLoop(agent, initial, session, opts) {
|
|
26
30
|
const { provider, signal, emit, runStep } = opts;
|
|
27
31
|
const formatStepName = opts.formatStepName ?? DEFAULT_STEP_NAME_FORMATTER;
|
|
28
32
|
const configuredFatalLoopError = opts.isFatalLoopError ?? (() => false);
|
|
@@ -524,6 +528,7 @@ function appendDeferredImages(messages, results, deferredImages) {
|
|
|
524
528
|
* is genuinely fast. A bracket inside the step would report a body that did not run.
|
|
525
529
|
*/
|
|
526
530
|
async function dispatchTools(toolUses, toolsById, toolCtx, isFatalLoopError, runStep, toolStepName, encoding) {
|
|
531
|
+
const dispatch = (tu) => traceToolCall(tu, () => dispatchTool(tu, toolsById, toolCtx(tu), isFatalLoopError, encoding), (dispatched) => outcomeOf(dispatched.result));
|
|
527
532
|
const results = new Array(toolUses.length);
|
|
528
533
|
// The array starts with holes, which read as `undefined`. The element type
|
|
529
534
|
// says so, thus it agrees with what `settleRound` accepts. Every index is in
|
|
@@ -550,7 +555,7 @@ async function dispatchTools(toolUses, toolsById, toolCtx, isFatalLoopError, run
|
|
|
550
555
|
const stepName = toolStepName(tu.toolName, tu.toolCallId);
|
|
551
556
|
return runStep(stepName, () => {
|
|
552
557
|
stableSpan(stepName, `tool:${tu.toolName}`, { [ATTR_INFLEXA_TOOL_USE_ID]: tu.toolCallId });
|
|
553
|
-
return
|
|
558
|
+
return dispatch(tu);
|
|
554
559
|
}).then((settled) => {
|
|
555
560
|
durations[idx] = elapsedMs(startedAt);
|
|
556
561
|
const dispatched = readDispatchedStep(settled);
|
|
@@ -561,7 +566,7 @@ async function dispatchTools(toolUses, toolsById, toolCtx, isFatalLoopError, run
|
|
|
561
566
|
}));
|
|
562
567
|
for (const { tu, idx } of workflowTools) {
|
|
563
568
|
const startedAt = performance.now();
|
|
564
|
-
const dispatched = await
|
|
569
|
+
const dispatched = await dispatch(tu);
|
|
565
570
|
results[idx] = dispatched.result;
|
|
566
571
|
if (dispatched.detail !== undefined)
|
|
567
572
|
resultDetails[idx] = dispatched.detail;
|
|
@@ -569,7 +574,7 @@ async function dispatchTools(toolUses, toolsById, toolCtx, isFatalLoopError, run
|
|
|
569
574
|
}
|
|
570
575
|
for (const { tu, idx } of inlineTools) {
|
|
571
576
|
const startedAt = performance.now();
|
|
572
|
-
const dispatched = await
|
|
577
|
+
const dispatched = await dispatch(tu);
|
|
573
578
|
results[idx] = dispatched.result;
|
|
574
579
|
if (dispatched.detail !== undefined)
|
|
575
580
|
resultDetails[idx] = dispatched.detail;
|
package/dist/providers/ai-sdk.js
CHANGED
|
@@ -2,6 +2,7 @@ import { streamText, wrapLanguageModel, } from "ai";
|
|
|
2
2
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
3
3
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
4
4
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
5
|
+
import { OpenTelemetry } from "@ai-sdk/otel";
|
|
5
6
|
import { APICallError } from "@ai-sdk/provider";
|
|
6
7
|
import { retryWithExponentialBackoff } from "@ai-sdk/provider-utils";
|
|
7
8
|
import { ResultAsync, err, ok } from "neverthrow";
|
|
@@ -431,6 +432,11 @@ export function createAiSdkProvider(deps) {
|
|
|
431
432
|
const maxRetries = deps.maxRetries ?? RETRY_MAX_RETRIES;
|
|
432
433
|
const requestTimeoutMs = deps.requestTimeoutMs;
|
|
433
434
|
const requestedModelId = requestedModelIdOf(deps.model);
|
|
435
|
+
// Each model call emits OpenTelemetry GenAI spans through the AI SDK, with no
|
|
436
|
+
// prompt or completion text on them. The integration rides on each call
|
|
437
|
+
// instead of the global registry, so the harness never traces the embedder's
|
|
438
|
+
// own AI SDK calls.
|
|
439
|
+
const telemetry = { integrations: new OpenTelemetry(), recordInputs: false, recordOutputs: false };
|
|
434
440
|
routeSdkWarningsTo(logger);
|
|
435
441
|
/**
|
|
436
442
|
* Record a call that the envelope gave up on.
|
|
@@ -484,6 +490,7 @@ export function createAiSdkProvider(deps) {
|
|
|
484
490
|
maxRetries: 0,
|
|
485
491
|
headers,
|
|
486
492
|
abortSignal: signal,
|
|
493
|
+
telemetry,
|
|
487
494
|
// `firstChunkMs` bounds the wait for the first content chunk,
|
|
488
495
|
// and `chunkMs` bounds each later gap. Thus each silent interval
|
|
489
496
|
// carries the one configured bound, and a turn that writes
|
|
@@ -560,6 +567,7 @@ export function createAiSdkProvider(deps) {
|
|
|
560
567
|
maxRetries: 0,
|
|
561
568
|
headers,
|
|
562
569
|
abortSignal: signal,
|
|
570
|
+
telemetry,
|
|
563
571
|
// The fetch guard bounds the wait until the headers. Past the
|
|
564
572
|
// headers the SDK owns two bounds: `firstChunkMs` covers the wait
|
|
565
573
|
// for the first content chunk, and `chunkMs` covers each later
|
|
@@ -25,7 +25,6 @@ import { type AcquireEyes } from "../lib/eyes.js";
|
|
|
25
25
|
import type { ThreadType } from "../memory/thread-store.js";
|
|
26
26
|
import { type ExecuteAnalysisDeps, type ExecuteAnalysisInput, type ExecuteAnalysisResult } from "../workflows/execute-analysis.js";
|
|
27
27
|
import { type SandboxStepDeps, type SandboxStepInput, type SandboxStepResult } from "../workflows/sandbox-step.js";
|
|
28
|
-
import { type ExecuteTargetAssessmentDeps, type ExecuteTargetAssessmentInput, type ExecuteTargetAssessmentResult } from "../workflows/execute-target-assessment.js";
|
|
29
28
|
import { type DataProfileDeps, type DataProfileWorkflowInput } from "../tasks/data-profile.js";
|
|
30
29
|
import { type ExtractValuesResult, type ExtractValuesWorkflowInput } from "../tasks/extract-values.js";
|
|
31
30
|
import type { DeriveTableExecInput } from "../tools/report-session/derive-table.js";
|
|
@@ -54,14 +53,12 @@ export type SandboxStepCallable = (input: SandboxStepInput) => Promise<SandboxSt
|
|
|
54
53
|
export interface CoreWorkflowDeps {
|
|
55
54
|
readonly sandboxStep: Omit<SandboxStepDeps, "usageRecorder" | "citationResolver">;
|
|
56
55
|
readonly buildExecuteAnalysis: (sandboxStep: SandboxStepCallable) => Omit<ExecuteAnalysisDeps, "usageRecorder" | "citationResolver">;
|
|
57
|
-
readonly executeTargetAssessment: Omit<ExecuteTargetAssessmentDeps, "usageRecorder">;
|
|
58
56
|
readonly dataProfile: Omit<DataProfileDeps, "usageRecorder">;
|
|
59
57
|
}
|
|
60
58
|
/** The registered, callable workflow handles. */
|
|
61
59
|
export interface RegisteredWorkflows {
|
|
62
60
|
readonly executeAnalysis: (input: ExecuteAnalysisInput) => Promise<ExecuteAnalysisResult>;
|
|
63
61
|
readonly sandboxStep: SandboxStepCallable;
|
|
64
|
-
readonly executeTargetAssessment: (input: ExecuteTargetAssessmentInput) => Promise<ExecuteTargetAssessmentResult>;
|
|
65
62
|
readonly dataProfile: (input: DataProfileWorkflowInput) => Promise<void>;
|
|
66
63
|
readonly extractValues: (input: ExtractValuesWorkflowInput) => Promise<ExtractValuesResult>;
|
|
67
64
|
readonly deriveTableExec: (input: DeriveTableExecInput) => Promise<ExecResult>;
|
package/dist/runtime/assemble.js
CHANGED
|
@@ -23,7 +23,6 @@ import { hasBrowserUrl } from "../lib/chrome.js";
|
|
|
23
23
|
import { createStaticEyes } from "../lib/eyes.js";
|
|
24
24
|
import { registerExecuteAnalysis } from "../workflows/execute-analysis.js";
|
|
25
25
|
import { registerSandboxStep } from "../workflows/sandbox-step.js";
|
|
26
|
-
import { registerExecuteTargetAssessment, } from "../workflows/execute-target-assessment.js";
|
|
27
26
|
import { registerDataProfileWorkflow } from "../tasks/data-profile.js";
|
|
28
27
|
import { bindExtractionTrigger, createExtractionArm, registerExtractValuesWorkflow, } from "../tasks/extract-values.js";
|
|
29
28
|
import { registerDeriveTableExecWorkflow, triggerDeriveTableExec } from "../tasks/derive-table-exec.js";
|
|
@@ -86,7 +85,6 @@ export function assembleCoreRuntime(deps) {
|
|
|
86
85
|
});
|
|
87
86
|
const sandboxStep = registerSandboxStep({ ...wf.sandboxStep, citationResolver, usageRecorder });
|
|
88
87
|
const executeAnalysis = registerExecuteAnalysis({ ...wf.buildExecuteAnalysis(sandboxStep), citationResolver, usageRecorder });
|
|
89
|
-
const executeTargetAssessment = registerExecuteTargetAssessment({ ...wf.executeTargetAssessment, usageRecorder });
|
|
90
88
|
const dataProfile = registerDataProfileWorkflow({ ...wf.dataProfile, usageRecorder });
|
|
91
89
|
// The extraction workflow shares the profile's sandbox and authorization rails, thus it draws the same
|
|
92
90
|
// three seams from the profile deps. The report resolver factory binds the extraction arm over this
|
|
@@ -196,7 +194,6 @@ export function assembleCoreRuntime(deps) {
|
|
|
196
194
|
workflows: {
|
|
197
195
|
executeAnalysis,
|
|
198
196
|
sandboxStep,
|
|
199
|
-
executeTargetAssessment,
|
|
200
197
|
dataProfile,
|
|
201
198
|
extractValues,
|
|
202
199
|
deriveTableExec,
|
package/dist/state/index.d.ts
CHANGED
|
@@ -27,5 +27,3 @@ export { createAnalysisPurge } from "./purge-analysis.js";
|
|
|
27
27
|
export type { AnalysisPurge, AnalysisPurgeDeps, AnalysisPurgeOutcome } from "./purge-analysis.js";
|
|
28
28
|
export { AnalysisStateRowSchema, ArtifactRole, ArtifactRowSchema, RunStatus, StepExecutionStatus, SynthesisStatus, CortexRunRowSchema, StepExecutionRowSchema, CortexPlanRowSchema, } from "./schema.js";
|
|
29
29
|
export type { AnalysisStateRow, ArtifactRow, CortexRunRow, StepExecutionRow, CortexPlanRow } from "./schema.js";
|
|
30
|
-
export { insertAssessment, updateProgress, setDossier, markFailed, getAssessment, listAssessmentsByOrg, softDeleteAssessment, TargetAssessmentStatusSchema, TargetAssessmentErrorSchema, TargetAssessmentRowSchema, } from "./target-assessments.js";
|
|
31
|
-
export type { TargetAssessmentStatus, TargetAssessmentRow, TargetAssessmentError, InsertAssessmentInput, ListAssessmentsOptions, } from "./target-assessments.js";
|
package/dist/state/index.js
CHANGED
|
@@ -20,4 +20,3 @@ export { queryRunCountsByAnalyses, queryThreadCountsByAnalyses, queryDataProfile
|
|
|
20
20
|
// alone, with the workflow ledger behind an injected seam.
|
|
21
21
|
export { createAnalysisPurge } from "./purge-analysis.js";
|
|
22
22
|
export { AnalysisStateRowSchema, ArtifactRole, ArtifactRowSchema, RunStatus, StepExecutionStatus, SynthesisStatus, CortexRunRowSchema, StepExecutionRowSchema, CortexPlanRowSchema, } from "./schema.js";
|
|
23
|
-
export { insertAssessment, updateProgress, setDossier, markFailed, getAssessment, listAssessmentsByOrg, softDeleteAssessment, TargetAssessmentStatusSchema, TargetAssessmentErrorSchema, TargetAssessmentRowSchema, } from "./target-assessments.js";
|
package/dist/state/init.js
CHANGED
|
@@ -199,65 +199,6 @@ CREATE TABLE IF NOT EXISTS cortex_report_session_state (
|
|
|
199
199
|
CREATE INDEX IF NOT EXISTS idx_cortex_report_session_state_analysis
|
|
200
200
|
ON cortex_report_session_state(analysis_id);
|
|
201
201
|
|
|
202
|
-
-- Target assessments — organization-scoped, snapshot-style target dossiers.
|
|
203
|
-
-- Independent of analyses, projects, runs, and chat threads. The full
|
|
204
|
-
-- dossier is persisted as JSONB on the row, no separate artifacts table.
|
|
205
|
-
CREATE TABLE IF NOT EXISTS cortex_target_assessments (
|
|
206
|
-
id UUID PRIMARY KEY,
|
|
207
|
-
organization_id TEXT NOT NULL,
|
|
208
|
-
target_id TEXT NOT NULL,
|
|
209
|
-
target_label TEXT NOT NULL,
|
|
210
|
-
goal TEXT,
|
|
211
|
-
status TEXT NOT NULL,
|
|
212
|
-
progress TEXT,
|
|
213
|
-
dossier JSONB,
|
|
214
|
-
billing_context_id TEXT NOT NULL,
|
|
215
|
-
error JSONB,
|
|
216
|
-
requested_by TEXT NOT NULL,
|
|
217
|
-
workflow_run_id TEXT,
|
|
218
|
-
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
219
|
-
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
220
|
-
completed_at TIMESTAMPTZ
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
ALTER TABLE cortex_target_assessments
|
|
224
|
-
ADD COLUMN IF NOT EXISTS workflow_run_id TEXT;
|
|
225
|
-
|
|
226
|
-
-- DBOS workflow id for the executeTargetAssessment workflow. For DBOS-shaped
|
|
227
|
-
-- rows, workflow_id = assessmentId (the workflowID passed to DBOS.startWorkflow).
|
|
228
|
-
-- Nullable so older rows tolerate NULL -- new rows always write
|
|
229
|
-
-- workflow_id alongside the row insert.
|
|
230
|
-
ALTER TABLE cortex_target_assessments
|
|
231
|
-
ADD COLUMN IF NOT EXISTS workflow_id TEXT;
|
|
232
|
-
|
|
233
|
-
CREATE INDEX IF NOT EXISTS idx_cortex_target_assessments_workflow_id
|
|
234
|
-
ON cortex_target_assessments(workflow_id);
|
|
235
|
-
|
|
236
|
-
CREATE INDEX IF NOT EXISTS idx_cortex_target_assessments_org_created
|
|
237
|
-
ON cortex_target_assessments(organization_id, created_at DESC);
|
|
238
|
-
|
|
239
|
-
CREATE INDEX IF NOT EXISTS idx_cortex_target_assessments_org_target_created
|
|
240
|
-
ON cortex_target_assessments(organization_id, target_id, created_at DESC);
|
|
241
|
-
|
|
242
|
-
-- Per-row clinical-consequence annotations for off-target hits, produced by
|
|
243
|
-
-- a focused LLM annotator. Cached by (primary_target_gene, off_target_key)
|
|
244
|
-
-- so repeat assessments of the same target reuse prior work and avoid
|
|
245
|
-
-- per-run LLM cost.
|
|
246
|
-
--
|
|
247
|
-
-- off_target_key is the ChEMBL ID when present, else the (trimmed,
|
|
248
|
-
-- lowercased) off-target name. Composite primary key prevents duplicate
|
|
249
|
-
-- annotations.
|
|
250
|
-
CREATE TABLE IF NOT EXISTS cortex_off_target_annotations (
|
|
251
|
-
primary_target_gene TEXT NOT NULL,
|
|
252
|
-
off_target_key TEXT NOT NULL,
|
|
253
|
-
off_target_name TEXT NOT NULL,
|
|
254
|
-
clinical_consequence TEXT NOT NULL,
|
|
255
|
-
provenance TEXT,
|
|
256
|
-
model TEXT NOT NULL,
|
|
257
|
-
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
258
|
-
PRIMARY KEY (primary_target_gene, off_target_key)
|
|
259
|
-
);
|
|
260
|
-
|
|
261
202
|
-- Regulatory guidance corpus — pre-indexed FDA CDER, FDA CBER, and ICH
|
|
262
203
|
-- guidance documents. Written/refreshed via tasks/refresh-regulatory-corpus.ts
|
|
263
204
|
-- and searched (top-K cosine) via lib/regulatory-corpus.ts. No synthesis tool
|
|
@@ -684,7 +625,7 @@ export async function initCortexState(pool, injected) {
|
|
|
684
625
|
}
|
|
685
626
|
// No boot-time orphan sweep on cortex_runs / cortex_step_executions.
|
|
686
627
|
// Every running row is backed by a DBOS workflow (executeAnalysis,
|
|
687
|
-
//
|
|
628
|
+
// resume entry); DBOS recovery is the
|
|
688
629
|
// substitute — each pod has a stable executorID (StatefulSet pod name)
|
|
689
630
|
// and runs `recoverPendingWorkflows` for its own ID at launch (ADR
|
|
690
631
|
// 0012). The workflow body owns the terminal transition on cortex_runs;
|
|
@@ -28,8 +28,7 @@
|
|
|
28
28
|
*
|
|
29
29
|
* What it does not reach, so that absent coverage is never read as delivered:
|
|
30
30
|
* scheduled operational workflows (they belong to no analysis and accumulate
|
|
31
|
-
* independently of any purge),
|
|
32
|
-
* separate top-level entity), the shared regulatory corpus, `messages` rows whose
|
|
31
|
+
* independently of any purge), the shared regulatory corpus, `messages` rows whose
|
|
33
32
|
* thread row is already gone (nothing attributes them to an analysis), and
|
|
34
33
|
* workspace files on disk (the embedder owns their disposal).
|
|
35
34
|
*/
|
|
@@ -28,8 +28,7 @@
|
|
|
28
28
|
*
|
|
29
29
|
* What it does not reach, so that absent coverage is never read as delivered:
|
|
30
30
|
* scheduled operational workflows (they belong to no analysis and accumulate
|
|
31
|
-
* independently of any purge),
|
|
32
|
-
* separate top-level entity), the shared regulatory corpus, `messages` rows whose
|
|
31
|
+
* independently of any purge), the shared regulatory corpus, `messages` rows whose
|
|
33
32
|
* thread row is already gone (nothing attributes them to an analysis), and
|
|
34
33
|
* workspace files on disk (the embedder owns their disposal).
|
|
35
34
|
*/
|
|
@@ -79,7 +79,7 @@ export async function maybeKickOffRegulatoryCorpusRefresh(deps) {
|
|
|
79
79
|
return "skipped-fresh";
|
|
80
80
|
}
|
|
81
81
|
// Corpus is stale — resolve the maintenance embedder. System-scoped
|
|
82
|
-
// maintenance work has no analysis
|
|
82
|
+
// maintenance work has no analysis to bill against, so
|
|
83
83
|
// we route directly to api.openai.com on a dedicated key. Never the
|
|
84
84
|
// billing-gateway-routed workspace embedder, which would emit unattributed calls
|
|
85
85
|
// and flood the boot log via `billing-fetch-patch`.
|
|
@@ -12,9 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* No source caps its own output: Bgee returns every annotated tissue per
|
|
14
14
|
* species, IMPC every significant phenotype term, and Monarch every curated
|
|
15
|
-
* HPO annotation, so each half is trimmed here rather than in the clients
|
|
16
|
-
* target-assessment collectors read the same clients and legitimately want full
|
|
17
|
-
* fidelity for the dossier.
|
|
15
|
+
* HPO annotation, so each half is trimmed here rather than in the clients.
|
|
18
16
|
*/
|
|
19
17
|
import { type SupportedSpecies, type TissueRow } from "../lib/bgee-client.js";
|
|
20
18
|
import { type MpTerm, type ViabilityCall, type ViabilityCategory } from "../lib/impc-client.js";
|
|
@@ -12,9 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* No source caps its own output: Bgee returns every annotated tissue per
|
|
14
14
|
* species, IMPC every significant phenotype term, and Monarch every curated
|
|
15
|
-
* HPO annotation, so each half is trimmed here rather than in the clients
|
|
16
|
-
* target-assessment collectors read the same clients and legitimately want full
|
|
17
|
-
* fidelity for the dossier.
|
|
15
|
+
* HPO annotation, so each half is trimmed here rather than in the clients.
|
|
18
16
|
*/
|
|
19
17
|
import { ok } from "neverthrow";
|
|
20
18
|
import { z } from "zod";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pure async client functions for the ChEMBL REST API.
|
|
3
3
|
*
|
|
4
|
-
* Used
|
|
4
|
+
* Used by tool wrappers.
|
|
5
5
|
*
|
|
6
6
|
* Absence policy: ChEMBL sends an explicit `null` for an absent value, and it
|
|
7
7
|
* never omits the key. Thus a maybe-absent field carries `.nullable()`, not
|
|
@@ -234,8 +234,5 @@ export declare function getMoleculeInChIKey(moleculeChemblId: string): Promise<s
|
|
|
234
234
|
* Resolve a drug's mechanism-of-action targets to UniProt accessions.
|
|
235
235
|
* Returns deduplicated accessions across all mechanism rows.
|
|
236
236
|
* Empty array on no mechanism, missing target, or non-protein target.
|
|
237
|
-
*
|
|
238
|
-
* Used by target-identity-filter to detect off-target trials (e.g., a
|
|
239
|
-
* trial of a CALCRL drug being surfaced under a CALCR assessment).
|
|
240
237
|
*/
|
|
241
238
|
export declare function getDrugPrimaryTargetUniprots(moleculeChemblId: string): Promise<string[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pure async client functions for the ChEMBL REST API.
|
|
3
3
|
*
|
|
4
|
-
* Used
|
|
4
|
+
* Used by tool wrappers.
|
|
5
5
|
*
|
|
6
6
|
* Absence policy: ChEMBL sends an explicit `null` for an absent value, and it
|
|
7
7
|
* never omits the key. Thus a maybe-absent field carries `.nullable()`, not
|
|
@@ -673,9 +673,6 @@ export async function getMoleculeInChIKey(moleculeChemblId) {
|
|
|
673
673
|
* Resolve a drug's mechanism-of-action targets to UniProt accessions.
|
|
674
674
|
* Returns deduplicated accessions across all mechanism rows.
|
|
675
675
|
* Empty array on no mechanism, missing target, or non-protein target.
|
|
676
|
-
*
|
|
677
|
-
* Used by target-identity-filter to detect off-target trials (e.g., a
|
|
678
|
-
* trial of a CALCRL drug being surfaced under a CALCR assessment).
|
|
679
676
|
*/
|
|
680
677
|
export async function getDrugPrimaryTargetUniprots(moleculeChemblId) {
|
|
681
678
|
const mechRes = await apiFetchValidated(`${CHEMBL_BASE}/mechanism.json?molecule_chembl_id=${encodeURIComponent(moleculeChemblId)}&limit=20`, MechanismsResponseSchema, { headers: HEADERS });
|
|
@@ -29,7 +29,7 @@ export declare function inferTherapeuticArea(indicationLabels: string[]): string
|
|
|
29
29
|
* `source` field discloses whether the fallback was used.
|
|
30
30
|
*/
|
|
31
31
|
export declare function getBenchmarks(therapeuticArea: string | null): BenchmarkResult;
|
|
32
|
-
/** Return the dataset's metadata for transparency
|
|
32
|
+
/** Return the dataset's metadata for transparency. */
|
|
33
33
|
export declare function getDatasetAttribution(): {
|
|
34
34
|
data_version: string;
|
|
35
35
|
data_window: string;
|