@inflexa-ai/harness 0.17.0 → 0.18.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/agents/report-builder.d.ts +2 -0
- package/dist/agents/report-builder.js +2 -0
- package/dist/app/spawn-report-session.d.ts +85 -0
- package/dist/app/spawn-report-session.js +83 -0
- package/dist/contracts/chat-events.d.ts +9 -0
- package/dist/contracts/index.d.ts +6 -2
- package/dist/contracts/index.js +3 -1
- package/dist/contracts/organ-system.d.ts +49 -0
- package/dist/contracts/organ-system.js +67 -0
- package/dist/contracts/report-blocks.d.ts +564 -0
- package/dist/contracts/report-blocks.js +117 -0
- package/dist/contracts/report-reference.d.ts +459 -0
- package/dist/contracts/report-reference.js +256 -0
- package/dist/contracts/schemas/chat-events.d.ts +2 -0
- package/dist/contracts/schemas/chat-events.js +2 -0
- package/dist/contracts/severity.d.ts +15 -0
- package/dist/contracts/severity.js +10 -0
- package/dist/contracts/target-dossier.d.ts +8675 -12972
- package/dist/contracts/target-dossier.js +534 -591
- package/dist/data/safety-panel-schema.d.ts +18 -5
- package/dist/data/safety-panel-schema.js +4 -4
- package/dist/execution/artifact-metadata.js +1 -0
- package/dist/execution/report-runner.js +1 -3
- package/dist/execution/run-synthesis.js +2 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +19 -0
- package/dist/lib/async-utils.d.ts +16 -4
- package/dist/lib/async-utils.js +20 -15
- package/dist/lib/host-concurrency.js +1 -0
- package/dist/loop/__fixtures__/scripted-provider.js +23 -2
- package/dist/loop/run-agent.js +58 -10
- package/dist/loop/tool-detail.d.ts +40 -0
- package/dist/loop/tool-detail.js +35 -3
- package/dist/loop/types.d.ts +13 -0
- package/dist/memory/thread-history.d.ts +10 -0
- package/dist/memory/thread-history.js +12 -1
- package/dist/prompts/target-assessment/briefs/executive-recommendation.d.ts +1 -1
- package/dist/prompts/target-assessment/briefs/executive-recommendation.js +5 -5
- package/dist/prompts/target-assessment/briefs/liability-bullets.d.ts +1 -1
- package/dist/prompts/target-assessment/briefs/liability-bullets.js +1 -1
- package/dist/prompts/target-assessment/briefs/target-organ-liabilities.d.ts +1 -1
- package/dist/prompts/target-assessment/briefs/target-organ-liabilities.js +11 -3
- package/dist/prompts/target-assessment/investigation/adversarial-critique.d.ts +1 -0
- package/dist/prompts/target-assessment/investigation/adversarial-critique.js +67 -0
- package/dist/prompts/target-assessment/investigation/claim-reverification.d.ts +1 -0
- package/dist/prompts/target-assessment/investigation/claim-reverification.js +49 -0
- package/dist/prompts/target-assessment/investigation/index.d.ts +3 -0
- package/dist/prompts/target-assessment/investigation/index.js +3 -0
- package/dist/prompts/target-assessment/investigation/mechanism-proposal.d.ts +1 -0
- package/dist/prompts/target-assessment/investigation/mechanism-proposal.js +49 -0
- package/dist/prompts/target-assessment/tox-voice/index.d.ts +1 -1
- package/dist/prompts/target-assessment/tox-voice/vocabulary.d.ts +8 -5
- package/dist/prompts/target-assessment/tox-voice/vocabulary.js +9 -20
- package/dist/providers/__fixtures__/session.d.ts +5 -4
- package/dist/providers/__fixtures__/session.js +4 -4
- package/dist/report-model/block-walk.d.ts +56 -0
- package/dist/report-model/block-walk.js +89 -0
- package/dist/report-model/draft-finish.d.ts +60 -0
- package/dist/report-model/draft-finish.js +56 -0
- package/dist/report-model/draft-operations.d.ts +125 -0
- package/dist/report-model/draft-operations.js +341 -0
- package/dist/report-model/draft-read.d.ts +59 -0
- package/dist/report-model/draft-read.js +109 -0
- package/dist/report-model/draft.d.ts +51 -0
- package/dist/report-model/draft.js +32 -0
- package/dist/report-model/fixture-resolver.d.ts +8 -0
- package/dist/report-model/fixture-resolver.js +252 -0
- package/dist/report-model/mint-snapshot.d.ts +30 -0
- package/dist/report-model/mint-snapshot.js +40 -0
- package/dist/report-model/reference-resolver.d.ts +113 -0
- package/dist/report-model/reference-resolver.js +60 -0
- package/dist/report-model/structural-validation.d.ts +22 -0
- package/dist/report-model/structural-validation.js +68 -0
- package/dist/report-model/validate.d.ts +40 -0
- package/dist/report-model/validate.js +80 -0
- package/dist/report-render/chart.d.ts +33 -0
- package/dist/report-render/chart.js +538 -0
- package/dist/report-render/page.d.ts +127 -0
- package/dist/report-render/page.js +307 -0
- package/dist/report-render/references.d.ts +32 -0
- package/dist/report-render/references.js +44 -0
- package/dist/report-render/render.d.ts +25 -0
- package/dist/report-render/render.js +125 -0
- package/dist/report-render/script-json.d.ts +13 -0
- package/dist/report-render/script-json.js +15 -0
- package/dist/report-render/types.d.ts +39 -0
- package/dist/report-render/types.js +10 -0
- package/dist/report-render/views/chart-view.d.ts +11 -0
- package/dist/report-render/views/chart-view.js +23 -0
- package/dist/report-render/views/page-view.d.ts +20 -0
- package/dist/report-render/views/page-view.js +49 -0
- package/dist/report-render/views/prose.d.ts +28 -0
- package/dist/report-render/views/prose.js +75 -0
- package/dist/report-render/views/references-view.d.ts +20 -0
- package/dist/report-render/views/references-view.js +64 -0
- package/dist/report-render/views/values.d.ts +42 -0
- package/dist/report-render/views/values.js +43 -0
- package/dist/runtime/boot.d.ts +3 -3
- package/dist/runtime/boot.js +15 -4
- package/dist/runtime/dbos.d.ts +4 -4
- package/dist/state/artifacts.d.ts +16 -0
- package/dist/state/artifacts.js +18 -0
- package/dist/state/init.js +31 -0
- package/dist/state/purge-analysis.js +1 -0
- package/dist/state/report-versions.d.ts +132 -0
- package/dist/state/report-versions.js +194 -0
- package/dist/tasks/data-profile.js +1 -0
- package/dist/tools/bio/chembl.js +1 -0
- package/dist/tools/bio/comptox.js +1 -0
- package/dist/tools/bio/drug-gene-interactions.js +1 -0
- package/dist/tools/bio/gene-disease-evidence.js +1 -0
- package/dist/tools/bio/gene-preclinical-profile.js +1 -0
- package/dist/tools/bio/keys.d.ts +3 -2
- package/dist/tools/bio/keys.js +3 -2
- package/dist/tools/bio/lookup-annotation.js +1 -0
- package/dist/tools/bio/opentargets.d.ts +3 -3
- package/dist/tools/bio/opentargets.js +4 -3
- package/dist/tools/bio/pubchem.js +1 -0
- package/dist/tools/bio/search-clinical-trials.js +1 -0
- package/dist/tools/bio/search-faers.js +1 -0
- package/dist/tools/bio/search-geo-datasets.js +1 -0
- package/dist/tools/bio/search-interactions.js +1 -0
- package/dist/tools/bio/target-safety.d.ts +4 -6
- package/dist/tools/bio/target-safety.js +7 -6
- package/dist/tools/define-tool.d.ts +19 -12
- package/dist/tools/define-tool.js +4 -2
- package/dist/tools/display/show-user.js +1 -0
- package/dist/tools/iterate-report.js +2 -0
- package/dist/tools/lib/chembl-client.d.ts +2 -0
- package/dist/tools/lib/chembl-client.js +1 -0
- package/dist/tools/lib/monarch-client.d.ts +42 -0
- package/dist/tools/lib/monarch-client.js +100 -0
- package/dist/tools/report/build-report.js +1 -0
- package/dist/tools/report/mint-preview-url.js +1 -0
- package/dist/tools/report/preview-snapshot.js +1 -0
- package/dist/tools/report/submit-report.js +1 -0
- package/dist/tools/report/version-fs.js +4 -0
- package/dist/tools/report-authoring/authoring-tools.d.ts +134 -0
- package/dist/tools/report-authoring/authoring-tools.js +352 -0
- package/dist/tools/research/context7-docs.js +2 -0
- package/dist/tools/research/generate-analogy-report.js +1 -0
- package/dist/tools/research/generate-plan.js +3 -0
- package/dist/tools/research/inspect-data-profile.js +4 -0
- package/dist/tools/research/literature-reviewer.js +1 -0
- package/dist/tools/research/search-arxiv.js +1 -0
- package/dist/tools/research/search-github-repos.js +1 -0
- package/dist/tools/research/search-semantic-scholar.js +1 -0
- package/dist/tools/sandbox/list-available-packages.js +23 -0
- package/dist/tools/sandbox/list-available-refs.js +36 -0
- package/dist/tools/sandbox/report-blocker.js +1 -0
- package/dist/tools/sandbox/skills.js +2 -0
- package/dist/tools/workspace/file-stat.js +1 -0
- package/dist/tools/workspace/show-file.js +2 -0
- package/dist/tools/workspace/show-plan.js +1 -0
- package/dist/workflows/execute-analysis.d.ts +5 -1
- package/dist/workflows/execute-analysis.js +5 -5
- package/dist/workflows/execute-target-assessment.d.ts +13 -2
- package/dist/workflows/execute-target-assessment.js +78 -16
- package/dist/workflows/target-assessment/assemblers/index.d.ts +1 -1
- package/dist/workflows/target-assessment/assemblers/index.js +1 -1
- package/dist/workflows/target-assessment/assemblers/literature.d.ts +9 -27
- package/dist/workflows/target-assessment/assemblers/literature.js +32 -48
- package/dist/workflows/target-assessment/assemblers/orchestrator.d.ts +17 -9
- package/dist/workflows/target-assessment/assemblers/orchestrator.js +195 -85
- package/dist/workflows/target-assessment/assemblers/safety.d.ts +70 -48
- package/dist/workflows/target-assessment/assemblers/safety.js +125 -42
- package/dist/workflows/target-assessment/collectors/index.d.ts +5 -2
- package/dist/workflows/target-assessment/collectors/index.js +48 -5
- package/dist/workflows/target-assessment/coverage.d.ts +43 -27
- package/dist/workflows/target-assessment/coverage.js +33 -29
- package/dist/workflows/target-assessment/fanout/index.js +1 -0
- package/dist/workflows/target-assessment/investigation/index.d.ts +97 -0
- package/dist/workflows/target-assessment/investigation/index.js +419 -0
- package/dist/workflows/target-assessment/lib/approval-precedents.d.ts +26 -5
- package/dist/workflows/target-assessment/lib/approval-precedents.js +95 -29
- package/dist/workflows/target-assessment/lib/citation-validator.js +1 -1
- package/dist/workflows/target-assessment/lib/clinical-consequence-annotator.d.ts +2 -2
- package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.d.ts +2 -3
- package/dist/workflows/target-assessment/lib/clinical-evidence-attribution.js +0 -4
- package/dist/workflows/target-assessment/lib/compute-derived.d.ts +6 -5
- package/dist/workflows/target-assessment/lib/compute-derived.js +14 -5
- package/dist/workflows/target-assessment/lib/family-complex-supplement.d.ts +5 -6
- package/dist/workflows/target-assessment/lib/family-complex-supplement.js +2 -3
- package/dist/workflows/target-assessment/lib/fda-label-safety.d.ts +72 -0
- package/dist/workflows/target-assessment/lib/fda-label-safety.js +166 -0
- package/dist/workflows/target-assessment/lib/heterodimer-filter.d.ts +0 -9
- package/dist/workflows/target-assessment/lib/heterodimer-filter.js +0 -10
- package/dist/workflows/target-assessment/lib/hpo-organ-map.d.ts +34 -0
- package/dist/workflows/target-assessment/lib/hpo-organ-map.js +63 -0
- package/dist/workflows/target-assessment/lib/impc-organ-map.d.ts +19 -0
- package/dist/workflows/target-assessment/lib/impc-organ-map.js +39 -0
- package/dist/workflows/target-assessment/lib/meddra-organ-map.d.ts +24 -14
- package/dist/workflows/target-assessment/lib/meddra-organ-map.js +59 -47
- package/dist/workflows/target-assessment/lib/recommendation-sanitizer.js +1 -1
- package/dist/workflows/target-assessment/lib/regulatory-actions.d.ts +2 -3
- package/dist/workflows/target-assessment/lib/regulatory-actions.js +33 -4
- package/dist/workflows/target-assessment/lib/safety-corroboration.d.ts +44 -0
- package/dist/workflows/target-assessment/lib/safety-corroboration.js +273 -0
- package/dist/workflows/target-assessment/lib/target-identity-filter.d.ts +5 -7
- package/dist/workflows/target-assessment/lib/target-identity-filter.js +5 -7
- package/dist/workflows/target-assessment/metrics.d.ts +1 -6
- package/dist/workflows/target-assessment/metrics.js +1 -13
- package/dist/workflows/target-assessment/phase4-assemble.d.ts +2147 -807
- package/dist/workflows/target-assessment/phase4-assemble.js +19 -19
- package/dist/workflows/target-assessment/phase5-persist.d.ts +20 -21
- package/dist/workflows/target-assessment/phase5-persist.js +56 -173
- package/dist/workflows/target-assessment/schemas.d.ts +46 -1
- package/dist/workflows/target-assessment/schemas.js +19 -0
- package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.d.ts +1 -0
- package/dist/workflows/target-assessment/steps/fanout/polypharm-for-one-modulator-step.js +2 -0
- package/dist/workflows/target-assessment/steps/phase2-aggregate.d.ts +26 -62
- package/dist/workflows/target-assessment/steps/phase2-aggregate.js +0 -4
- package/dist/workflows/target-assessment/steps/phase3-aggregate.d.ts +27 -154
- package/dist/workflows/target-assessment/steps/phase3-aggregate.js +0 -6
- package/dist/workflows/target-assessment/steps/synthesis/diagnostics.d.ts +0 -6
- package/dist/workflows/target-assessment/steps/synthesis/diagnostics.js +0 -18
- package/dist/workflows/target-assessment/sub-workflows/per-modulator-polypharm.d.ts +1 -0
- package/dist/workflows/target-assessment/synthesis/index.d.ts +52 -5
- package/dist/workflows/target-assessment/synthesis/index.js +4 -1
- package/dist/workflows/target-assessment/synthesis-probes.d.ts +3 -3
- package/package.json +4 -1
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
import type { AgentDefinition } from "../loop/types.js";
|
|
20
20
|
import type { Tool } from "../tools/define-tool.js";
|
|
21
21
|
export declare const REPORT_BUILDER_AGENT_ID = "report-builder";
|
|
22
|
+
/** Skill pack the report-builder prompt directs the model to read (design-system reference). */
|
|
23
|
+
export declare const REPORT_BUILDER_SKILLS: readonly ["report-html"];
|
|
22
24
|
export interface CreateReportBuilderAgentDeps {
|
|
23
25
|
/** Model id — provenance / metric label; the provider owns the wire model. */
|
|
24
26
|
readonly model: string;
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
import { reportBuilderPrompt } from "../prompts/report-builder.js";
|
|
20
20
|
import { composeSystemPrompt } from "./system-prompt.js";
|
|
21
21
|
export const REPORT_BUILDER_AGENT_ID = "report-builder";
|
|
22
|
+
/** Skill pack the report-builder prompt directs the model to read (design-system reference). */
|
|
23
|
+
export const REPORT_BUILDER_SKILLS = ["report-html"];
|
|
22
24
|
/** Runaway guard — Jinja recovery may take several build/edit cycles. */
|
|
23
25
|
const REPORT_BUILDER_MAX_ITERATIONS = 75;
|
|
24
26
|
export function createReportBuilderAgent(deps) {
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report-session spawn — the host-agnostic operation that makes a `report`
|
|
3
|
+
* child thread from a conversation.
|
|
4
|
+
*
|
|
5
|
+
* The operation owns no table. It composes four reads and writes the store and
|
|
6
|
+
* the thread history already give: `getThread` for the parent, `latestSeq` for
|
|
7
|
+
* the anchor, `listThreads` for the count of report children, and
|
|
8
|
+
* `createThread` for the insert. The one storage read this capability adds,
|
|
9
|
+
* `latestSeq`, lives on the thread history, because that module owns the
|
|
10
|
+
* `messages` table.
|
|
11
|
+
*
|
|
12
|
+
* The reads and the insert take no lock and no transaction. A concurrent turn
|
|
13
|
+
* can append between the anchor read and the insert, and a retract can cut the
|
|
14
|
+
* parent's tail. A transaction cannot keep the parent still one turn later, so
|
|
15
|
+
* a lock buys no real guarantee. The anchor records the spawn point, and skew
|
|
16
|
+
* past the parent's current end is a normal state a reader expects.
|
|
17
|
+
*
|
|
18
|
+
* A conversation thread id comes from the host UI. But the spawn is a harness
|
|
19
|
+
* operation with no UI in front of it. Thus it mints a `randomUUID` and returns
|
|
20
|
+
* the full row. A managed deployment gets the same behavior with no host code.
|
|
21
|
+
*/
|
|
22
|
+
import { type ResultAsync } from "neverthrow";
|
|
23
|
+
import type { Pool } from "pg";
|
|
24
|
+
import type { DbError } from "../lib/db-result.js";
|
|
25
|
+
import { type Thread, type ThreadInputError, type ThreadPage, type ThreadType } from "../memory/thread-store.js";
|
|
26
|
+
/**
|
|
27
|
+
* A spawn the operation refuses before it writes a row. Distinct from
|
|
28
|
+
* `DbError`: nothing failed at the driver — the parent names a session the
|
|
29
|
+
* spawn refuses, and each variant carries the identifiers that say which values
|
|
30
|
+
* disagreed.
|
|
31
|
+
*
|
|
32
|
+
* The set is closed. `parent_not_found` covers an absent parent and an archived
|
|
33
|
+
* one alike, because `getThread` filters the tombstone and a spawn into hidden
|
|
34
|
+
* state is not permitted. `parent_not_a_conversation` keeps the tree flat: a
|
|
35
|
+
* report session cannot spawn another. `empty_parent_transcript` refuses a
|
|
36
|
+
* report on a parent that holds no messages, because such a report reports
|
|
37
|
+
* nothing.
|
|
38
|
+
*/
|
|
39
|
+
export type SpawnRefusal = {
|
|
40
|
+
readonly type: "parent_not_found";
|
|
41
|
+
readonly op: string;
|
|
42
|
+
readonly parentThreadId: string;
|
|
43
|
+
} | {
|
|
44
|
+
readonly type: "parent_not_a_conversation";
|
|
45
|
+
readonly op: string;
|
|
46
|
+
readonly parentThreadId: string;
|
|
47
|
+
readonly threadType: ThreadType;
|
|
48
|
+
} | {
|
|
49
|
+
readonly type: "empty_parent_transcript";
|
|
50
|
+
readonly op: string;
|
|
51
|
+
readonly parentThreadId: string;
|
|
52
|
+
};
|
|
53
|
+
/** The paging inputs `listReportSessions` forwards to the thread listing. */
|
|
54
|
+
export interface ReportSessionPaging {
|
|
55
|
+
readonly page?: number;
|
|
56
|
+
readonly perPage?: number;
|
|
57
|
+
}
|
|
58
|
+
export interface ReportSessionSpawnDeps {
|
|
59
|
+
readonly pool: Pool;
|
|
60
|
+
}
|
|
61
|
+
export interface ReportSessionSpawn {
|
|
62
|
+
/**
|
|
63
|
+
* Make a `report` child of the parent conversation and return the full row.
|
|
64
|
+
* The child takes the analysis of the parent, the parent thread id, and the
|
|
65
|
+
* anchor — the parent's latest `messages.seq` at this moment.
|
|
66
|
+
*
|
|
67
|
+
* Refused with a `SpawnRefusal`, no row written: an absent or archived
|
|
68
|
+
* parent, a parent that is not a conversation, and a parent with no
|
|
69
|
+
* messages. A store refusal (`DbError`, `ThreadInputError`) passes through
|
|
70
|
+
* unchanged.
|
|
71
|
+
*/
|
|
72
|
+
spawnReportSession(parentThreadId: string): ResultAsync<Thread, SpawnRefusal | DbError | ThreadInputError>;
|
|
73
|
+
/**
|
|
74
|
+
* The report sessions of one analysis, through the thread listing narrowed
|
|
75
|
+
* to the type `report`. It adds no predicate of its own, so its answer and
|
|
76
|
+
* the thread listing cannot disagree.
|
|
77
|
+
*/
|
|
78
|
+
listReportSessions(analysisId: string, paging?: ReportSessionPaging): ResultAsync<ThreadPage, DbError>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Build the report-session operations bound to a Postgres pool. The factory
|
|
82
|
+
* closure captures `pool` and constructs the store and the thread history from
|
|
83
|
+
* it, the same way the chat-turn preparation does.
|
|
84
|
+
*/
|
|
85
|
+
export declare function createReportSessionSpawn(deps: ReportSessionSpawnDeps): ReportSessionSpawn;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report-session spawn — the host-agnostic operation that makes a `report`
|
|
3
|
+
* child thread from a conversation.
|
|
4
|
+
*
|
|
5
|
+
* The operation owns no table. It composes four reads and writes the store and
|
|
6
|
+
* the thread history already give: `getThread` for the parent, `latestSeq` for
|
|
7
|
+
* the anchor, `listThreads` for the count of report children, and
|
|
8
|
+
* `createThread` for the insert. The one storage read this capability adds,
|
|
9
|
+
* `latestSeq`, lives on the thread history, because that module owns the
|
|
10
|
+
* `messages` table.
|
|
11
|
+
*
|
|
12
|
+
* The reads and the insert take no lock and no transaction. A concurrent turn
|
|
13
|
+
* can append between the anchor read and the insert, and a retract can cut the
|
|
14
|
+
* parent's tail. A transaction cannot keep the parent still one turn later, so
|
|
15
|
+
* a lock buys no real guarantee. The anchor records the spawn point, and skew
|
|
16
|
+
* past the parent's current end is a normal state a reader expects.
|
|
17
|
+
*
|
|
18
|
+
* A conversation thread id comes from the host UI. But the spawn is a harness
|
|
19
|
+
* operation with no UI in front of it. Thus it mints a `randomUUID` and returns
|
|
20
|
+
* the full row. A managed deployment gets the same behavior with no host code.
|
|
21
|
+
*/
|
|
22
|
+
import { randomUUID } from "node:crypto";
|
|
23
|
+
import { errAsync } from "neverthrow";
|
|
24
|
+
import { createThreadHistory } from "../memory/thread-history.js";
|
|
25
|
+
import { createThreadStore } from "../memory/thread-store.js";
|
|
26
|
+
const _assertDomainError = true;
|
|
27
|
+
const OP = "spawn-report-session";
|
|
28
|
+
/**
|
|
29
|
+
* Compose the child title. N counts the existing report children of the parent
|
|
30
|
+
* plus one. A parent with no title yields `Report N` alone, because the seed of
|
|
31
|
+
* the parent title is best-effort and can be absent.
|
|
32
|
+
*/
|
|
33
|
+
function composeTitle(parentTitle, n) {
|
|
34
|
+
const suffix = `Report ${n}`;
|
|
35
|
+
return parentTitle && parentTitle.length > 0 ? `${parentTitle} — ${suffix}` : suffix;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build the report-session operations bound to a Postgres pool. The factory
|
|
39
|
+
* closure captures `pool` and constructs the store and the thread history from
|
|
40
|
+
* it, the same way the chat-turn preparation does.
|
|
41
|
+
*/
|
|
42
|
+
export function createReportSessionSpawn(deps) {
|
|
43
|
+
const { pool } = deps;
|
|
44
|
+
const store = createThreadStore(pool);
|
|
45
|
+
const history = createThreadHistory(pool);
|
|
46
|
+
function spawnReportSession(parentThreadId) {
|
|
47
|
+
return store.getThread(parentThreadId).andThen((parent) => {
|
|
48
|
+
// An absent parent and an archived one arrive the same way — `getThread`
|
|
49
|
+
// filters the tombstone — and both refuse as `parent_not_found`.
|
|
50
|
+
if (parent === null) {
|
|
51
|
+
return errAsync({ type: "parent_not_found", op: OP, parentThreadId });
|
|
52
|
+
}
|
|
53
|
+
// The tree stays flat: only a conversation spawns a report.
|
|
54
|
+
if (parent.threadType !== "conversation") {
|
|
55
|
+
return errAsync({ type: "parent_not_a_conversation", op: OP, parentThreadId, threadType: parent.threadType });
|
|
56
|
+
}
|
|
57
|
+
return history.latestSeq(parentThreadId).andThen((anchor) => {
|
|
58
|
+
// `null` is a parent with no messages. A report on an empty transcript
|
|
59
|
+
// reports nothing, so the refusal is the correct answer.
|
|
60
|
+
if (anchor === null) {
|
|
61
|
+
return errAsync({ type: "empty_parent_transcript", op: OP, parentThreadId });
|
|
62
|
+
}
|
|
63
|
+
// `total`, not the page length: N counts every existing report child,
|
|
64
|
+
// not the count on one page. Two concurrent spawns can compose one N.
|
|
65
|
+
// The result is two titles a user renames, and no identifier collides.
|
|
66
|
+
return store
|
|
67
|
+
.listThreads({ analysisId: parent.analysisId, type: "report", parentThreadId })
|
|
68
|
+
.andThen((children) => store.createThread({
|
|
69
|
+
threadId: randomUUID(),
|
|
70
|
+
analysisId: parent.analysisId,
|
|
71
|
+
title: composeTitle(parent.title, children.total + 1),
|
|
72
|
+
type: "report",
|
|
73
|
+
parentThreadId,
|
|
74
|
+
parentSeq: anchor,
|
|
75
|
+
}));
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function listReportSessions(analysisId, paging = {}) {
|
|
80
|
+
return store.listThreads({ analysisId, type: "report", ...paging });
|
|
81
|
+
}
|
|
82
|
+
return { spawnReportSession, listReportSessions };
|
|
83
|
+
}
|
|
@@ -84,6 +84,15 @@ export interface ToolFinishedEvent {
|
|
|
84
84
|
outcome: ToolOutcome;
|
|
85
85
|
/** The same detail the matching `tool-started` carried. */
|
|
86
86
|
detail?: ToolCallDetail;
|
|
87
|
+
/**
|
|
88
|
+
* The time in milliseconds around this call's own dispatch. Absent — never
|
|
89
|
+
* zero — when the harness took no measurement.
|
|
90
|
+
*
|
|
91
|
+
* A host must read it as `event.durationMs ?? (its own bracket)`. The bracket
|
|
92
|
+
* of a host spans the whole round, because the loop emits every start before
|
|
93
|
+
* it dispatches anything. Thus the fallback is correct only for one call.
|
|
94
|
+
*/
|
|
95
|
+
durationMs?: number;
|
|
87
96
|
source: EventSource;
|
|
88
97
|
}
|
|
89
98
|
/**
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export { ORGAN_SYSTEMS, OrganSystemSchema, ORGAN_SYSTEM_LABELS, organSystemLabel } from "./organ-system.js";
|
|
2
|
+
export type { OrganSystem } from "./organ-system.js";
|
|
3
|
+
export { SEVERITIES, SeveritySchema } from "./severity.js";
|
|
4
|
+
export type { Severity } from "./severity.js";
|
|
1
5
|
export type { PlanStep, PresentationContent, PresentationPart, PlanPart, RunCardPart, FileReferenceEntry, FileReferencePart, AskPart, RunStartedPart, StepStatus, DagStepState, DagStatePart, StepPhase, StepActivityPart, FileTreeEntry, StepFileTreePart, StepOutputFile, StepOutputPart, StepSummaryPart, StepUsagePart, StepBlockedPart, SynthesizedFinding, BiologicalTheme, RunSynthesisPart, SynthesisPhase, SynthesisProgressPart, RunCompletedFinding, RunCompletedPart, RunFailedPart, PreviewPart, DataPreviewFailedPart, CortexChatPart, } from "./chat-parts.js";
|
|
2
6
|
export type { EventSource, TextDeltaEvent, ToolStartedEvent, ToolFinishedEvent, FinishEvent, ChatErrorEvent, CortexChatEvent } from "./chat-events.js";
|
|
3
7
|
export type { TokenUsageRollup } from "./usage.js";
|
|
@@ -7,8 +11,8 @@ export { PART_REGISTRY, isTransient, isReconciling, isSidebarPart } from "./part
|
|
|
7
11
|
export type { CortexChatPartType, PartDescriptor, PartEmitter, PartConsumer } from "./part-registry.js";
|
|
8
12
|
export { AnalogyCoverageSchema, AnalogyReportSchema, AnalogyReportErrorSchema, AnalogicalReasonerOutputSchema } from "./analogy-report.js";
|
|
9
13
|
export type { AnalogyCoverage, AnalogyReport, AnalogyReportError, AnalogicalReasonerOutput } from "./analogy-report.js";
|
|
10
|
-
export { CoverageSchema, EntitySchema,
|
|
11
|
-
export type { Coverage, Entity,
|
|
14
|
+
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";
|
|
15
|
+
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";
|
|
12
16
|
export { TargetAssessmentStatusSchema, TargetAssessmentErrorSchema, TargetAssessmentListRowSchema, TargetAssessmentRowSchema, } from "./target-assessment-row.js";
|
|
13
17
|
export type { TargetAssessmentStatus, TargetAssessmentError, TargetAssessmentListRow, TargetAssessmentRow } from "./target-assessment-row.js";
|
|
14
18
|
export { buildPreviewUrl, previewResourceId } from "./content-url.js";
|
package/dist/contracts/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export { ORGAN_SYSTEMS, OrganSystemSchema, ORGAN_SYSTEM_LABELS, organSystemLabel } from "./organ-system.js";
|
|
2
|
+
export { SEVERITIES, SeveritySchema } from "./severity.js";
|
|
1
3
|
export { DATA_PROFILE_RUN_LITERAL } from "./data-profile.js";
|
|
2
4
|
export { PART_REGISTRY, isTransient, isReconciling, isSidebarPart } from "./part-registry.js";
|
|
3
5
|
export { AnalogyCoverageSchema, AnalogyReportSchema, AnalogyReportErrorSchema, AnalogicalReasonerOutputSchema } from "./analogy-report.js";
|
|
4
|
-
export { CoverageSchema, EntitySchema,
|
|
6
|
+
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";
|
|
5
7
|
export { TargetAssessmentStatusSchema, TargetAssessmentErrorSchema, TargetAssessmentListRowSchema, TargetAssessmentRowSchema, } from "./target-assessment-row.js";
|
|
6
8
|
export { buildPreviewUrl, previewResourceId } from "./content-url.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical organ-system vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* This is the ONLY organ vocabulary in the package. Per-organ evidence is
|
|
5
|
+
* joined by equality on these tokens, so a second enumeration — even a
|
|
6
|
+
* "temporary" or deprecated one — reintroduces the string matching this
|
|
7
|
+
* exists to remove. Producers resolve external and model-supplied organ
|
|
8
|
+
* names onto these tokens at their own boundary.
|
|
9
|
+
*
|
|
10
|
+
* Membership is anatomical, with one deliberate exception: `oncology` is a
|
|
11
|
+
* therapeutic area rather than an organ system, so grouping by it does not
|
|
12
|
+
* denote a site. It is retained because malignancy signals — MedDRA neoplasm
|
|
13
|
+
* SOC terms, and regulatory findings matched on malignancy keywords — have
|
|
14
|
+
* no other channel to arrive on, and dropping the member would discard them.
|
|
15
|
+
* Known debt: the honest fix is a separate non-organ signal channel.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from "zod";
|
|
18
|
+
export declare const ORGAN_SYSTEMS: readonly ["cardiac", "vascular", "hepatic", "renal", "cns", "pns", "gi", "pancreas", "endocrine_thyroid", "metabolic", "hematologic", "immune", "respiratory", "reproductive", "musculoskeletal", "dermatologic", "ocular", "oncology"];
|
|
19
|
+
export declare const OrganSystemSchema: z.ZodEnum<{
|
|
20
|
+
hematologic: "hematologic";
|
|
21
|
+
metabolic: "metabolic";
|
|
22
|
+
immune: "immune";
|
|
23
|
+
hepatic: "hepatic";
|
|
24
|
+
musculoskeletal: "musculoskeletal";
|
|
25
|
+
cns: "cns";
|
|
26
|
+
renal: "renal";
|
|
27
|
+
reproductive: "reproductive";
|
|
28
|
+
respiratory: "respiratory";
|
|
29
|
+
cardiac: "cardiac";
|
|
30
|
+
vascular: "vascular";
|
|
31
|
+
pns: "pns";
|
|
32
|
+
gi: "gi";
|
|
33
|
+
pancreas: "pancreas";
|
|
34
|
+
endocrine_thyroid: "endocrine_thyroid";
|
|
35
|
+
dermatologic: "dermatologic";
|
|
36
|
+
ocular: "ocular";
|
|
37
|
+
oncology: "oncology";
|
|
38
|
+
}>;
|
|
39
|
+
export type OrganSystem = (typeof ORGAN_SYSTEMS)[number];
|
|
40
|
+
/**
|
|
41
|
+
* Reader-facing prose for each canonical token.
|
|
42
|
+
*
|
|
43
|
+
* Narrative surfaces (agent voice, rendered dossiers) read these; structured
|
|
44
|
+
* fields always carry the token. Keeping the prose a projection of the token
|
|
45
|
+
* — rather than its own list — is what stops the two drifting into the
|
|
46
|
+
* separate vocabularies this module replaces.
|
|
47
|
+
*/
|
|
48
|
+
export declare const ORGAN_SYSTEM_LABELS: Record<OrganSystem, string>;
|
|
49
|
+
export declare const organSystemLabel: (organ: OrganSystem) => string;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical organ-system vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* This is the ONLY organ vocabulary in the package. Per-organ evidence is
|
|
5
|
+
* joined by equality on these tokens, so a second enumeration — even a
|
|
6
|
+
* "temporary" or deprecated one — reintroduces the string matching this
|
|
7
|
+
* exists to remove. Producers resolve external and model-supplied organ
|
|
8
|
+
* names onto these tokens at their own boundary.
|
|
9
|
+
*
|
|
10
|
+
* Membership is anatomical, with one deliberate exception: `oncology` is a
|
|
11
|
+
* therapeutic area rather than an organ system, so grouping by it does not
|
|
12
|
+
* denote a site. It is retained because malignancy signals — MedDRA neoplasm
|
|
13
|
+
* SOC terms, and regulatory findings matched on malignancy keywords — have
|
|
14
|
+
* no other channel to arrive on, and dropping the member would discard them.
|
|
15
|
+
* Known debt: the honest fix is a separate non-organ signal channel.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from "zod";
|
|
18
|
+
export const ORGAN_SYSTEMS = [
|
|
19
|
+
"cardiac",
|
|
20
|
+
"vascular",
|
|
21
|
+
"hepatic",
|
|
22
|
+
"renal",
|
|
23
|
+
"cns",
|
|
24
|
+
"pns",
|
|
25
|
+
"gi",
|
|
26
|
+
"pancreas",
|
|
27
|
+
"endocrine_thyroid",
|
|
28
|
+
"metabolic",
|
|
29
|
+
"hematologic",
|
|
30
|
+
"immune",
|
|
31
|
+
"respiratory",
|
|
32
|
+
"reproductive",
|
|
33
|
+
"musculoskeletal",
|
|
34
|
+
"dermatologic",
|
|
35
|
+
"ocular",
|
|
36
|
+
"oncology",
|
|
37
|
+
];
|
|
38
|
+
export const OrganSystemSchema = z.enum(ORGAN_SYSTEMS);
|
|
39
|
+
/**
|
|
40
|
+
* Reader-facing prose for each canonical token.
|
|
41
|
+
*
|
|
42
|
+
* Narrative surfaces (agent voice, rendered dossiers) read these; structured
|
|
43
|
+
* fields always carry the token. Keeping the prose a projection of the token
|
|
44
|
+
* — rather than its own list — is what stops the two drifting into the
|
|
45
|
+
* separate vocabularies this module replaces.
|
|
46
|
+
*/
|
|
47
|
+
export const ORGAN_SYSTEM_LABELS = {
|
|
48
|
+
cardiac: "cardiac",
|
|
49
|
+
vascular: "vascular",
|
|
50
|
+
hepatic: "hepatobiliary",
|
|
51
|
+
renal: "renal",
|
|
52
|
+
cns: "central nervous system",
|
|
53
|
+
pns: "peripheral nervous system",
|
|
54
|
+
gi: "gastrointestinal",
|
|
55
|
+
pancreas: "pancreatic",
|
|
56
|
+
endocrine_thyroid: "endocrine (thyroid)",
|
|
57
|
+
metabolic: "metabolic",
|
|
58
|
+
hematologic: "haematologic",
|
|
59
|
+
immune: "immunologic",
|
|
60
|
+
respiratory: "respiratory",
|
|
61
|
+
reproductive: "reproductive",
|
|
62
|
+
musculoskeletal: "musculoskeletal",
|
|
63
|
+
dermatologic: "dermatologic",
|
|
64
|
+
ocular: "ocular",
|
|
65
|
+
oncology: "oncology",
|
|
66
|
+
};
|
|
67
|
+
export const organSystemLabel = (organ) => ORGAN_SYSTEM_LABELS[organ];
|