@inflexa-ai/harness 0.23.0 → 0.25.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.
Files changed (123) hide show
  1. package/README.md +1 -2
  2. package/dist/agents/conversation-agent.d.ts +0 -9
  3. package/dist/agents/sandbox/__fixtures__/deps.js +6 -0
  4. package/dist/agents/sandbox/data-profiler.js +5 -4
  5. package/dist/agents/sandbox/shared.js +11 -0
  6. package/dist/agents/sandbox/types.d.ts +1 -1
  7. package/dist/app/data-profile-orientation.js +30 -1
  8. package/dist/app/data-profile-policy.d.ts +33 -7
  9. package/dist/app/data-profile-policy.js +31 -9
  10. package/dist/contracts/chat-parts.d.ts +29 -33
  11. package/dist/contracts/content-url.d.ts +7 -41
  12. package/dist/contracts/content-url.js +7 -48
  13. package/dist/contracts/data-profile.d.ts +166 -0
  14. package/dist/contracts/index.d.ts +3 -2
  15. package/dist/contracts/index.js +1 -1
  16. package/dist/contracts/message.d.ts +1 -1
  17. package/dist/contracts/message.js +1 -1
  18. package/dist/contracts/part-registry.js +2 -3
  19. package/dist/contracts/schemas/chat-parts.d.ts +16 -53
  20. package/dist/contracts/schemas/chat-parts.js +15 -25
  21. package/dist/contracts/schemas/index.d.ts +1 -1
  22. package/dist/contracts/schemas/index.js +1 -1
  23. package/dist/execution/input-signature.d.ts +33 -0
  24. package/dist/execution/input-signature.js +0 -0
  25. package/dist/execution/run-authorizer.d.ts +1 -1
  26. package/dist/execution/run-authorizer.js +1 -1
  27. package/dist/index.d.ts +5 -4
  28. package/dist/index.js +5 -2
  29. package/dist/input-scan/coverage.d.ts +22 -0
  30. package/dist/input-scan/coverage.js +85 -0
  31. package/dist/input-scan/enrich.d.ts +41 -0
  32. package/dist/input-scan/enrich.js +227 -0
  33. package/dist/input-scan/formats.d.ts +41 -0
  34. package/dist/input-scan/formats.js +279 -0
  35. package/dist/input-scan/index.d.ts +12 -0
  36. package/dist/input-scan/index.js +11 -0
  37. package/dist/input-scan/scan.d.ts +50 -0
  38. package/dist/input-scan/scan.js +182 -0
  39. package/dist/input-scan/shapes.d.ts +46 -0
  40. package/dist/input-scan/shapes.js +0 -0
  41. package/dist/input-scan/types.d.ts +172 -0
  42. package/dist/input-scan/types.js +12 -0
  43. package/dist/lib/zod-issues.d.ts +2 -3
  44. package/dist/lib/zod-issues.js +2 -3
  45. package/dist/loop/__fixtures__/scripted-provider.js +3 -1
  46. package/dist/loop/run-agent.d.ts +5 -0
  47. package/dist/loop/run-agent.js +10 -1
  48. package/dist/loop/run-to-terminal.d.ts +1 -1
  49. package/dist/loop/run-to-terminal.js +1 -1
  50. package/dist/memory/card-builders.d.ts +0 -27
  51. package/dist/memory/card-builders.js +0 -75
  52. package/dist/memory/conversation-display-backfill.d.ts +2 -4
  53. package/dist/memory/conversation-display-backfill.js +3 -9
  54. package/dist/memory/conversation-display-storage.d.ts +3 -4
  55. package/dist/memory/conversation-display-storage.js +3 -4
  56. package/dist/memory/reconstruct-cards.d.ts +5 -7
  57. package/dist/memory/reconstruct-cards.js +6 -20
  58. package/dist/prompts/sandbox/data-profiler.d.ts +1 -1
  59. package/dist/prompts/sandbox/data-profiler.js +159 -275
  60. package/dist/provenance/exec-frame.js +9 -3
  61. package/dist/runtime/boot.js +2 -12
  62. package/dist/sandbox/client.d.ts +7 -0
  63. package/dist/sandbox/create-sandbox.js +1 -0
  64. package/dist/sandbox/docker-client.d.ts +1 -0
  65. package/dist/sandbox/docker-client.js +20 -15
  66. package/dist/sandbox/k8s-client.d.ts +6 -5
  67. package/dist/sandbox/k8s-client.js +55 -39
  68. package/dist/sandbox/reaper.d.ts +24 -13
  69. package/dist/sandbox/reaper.js +47 -14
  70. package/dist/sandbox/types.d.ts +6 -5
  71. package/dist/schemas/data-profile-schemas.d.ts +62 -0
  72. package/dist/schemas/data-profile-schemas.js +68 -2
  73. package/dist/state/data-profile.d.ts +7 -88
  74. package/dist/state/index.d.ts +1 -1
  75. package/dist/tasks/data-profile-activity.d.ts +8 -0
  76. package/dist/tasks/data-profile-activity.js +1 -0
  77. package/dist/tasks/data-profile-index.d.ts +45 -0
  78. package/dist/tasks/data-profile-index.js +134 -0
  79. package/dist/tasks/data-profile.d.ts +8 -23
  80. package/dist/tasks/data-profile.js +150 -117
  81. package/dist/tools/report-session/preview-report.d.ts +2 -1
  82. package/dist/tools/report-session/preview-report.js +9 -1
  83. package/dist/tools/research/generate-plan.js +1 -1
  84. package/dist/tools/research/inspect-data-profile.d.ts +30 -4
  85. package/dist/tools/research/inspect-data-profile.js +66 -10
  86. package/dist/tools/start-report-session.js +2 -2
  87. package/dist/tools/workspace/scan-inputs.d.ts +38 -0
  88. package/dist/tools/workspace/scan-inputs.js +61 -0
  89. package/dist/tools/workspace/workspace-search.d.ts +1 -1
  90. package/dist/tools/workspace/workspace-search.js +12 -9
  91. package/dist/workspace/filesystem.d.ts +27 -0
  92. package/dist/workspace/filesystem.js +27 -0
  93. package/dist/workspace/paths.d.ts +0 -21
  94. package/dist/workspace/paths.js +0 -37
  95. package/package.json +1 -3
  96. package/dist/agents/report-builder.d.ts +0 -34
  97. package/dist/agents/report-builder.js +0 -34
  98. package/dist/execution/report-render.d.ts +0 -39
  99. package/dist/execution/report-render.js +0 -98
  100. package/dist/execution/report-runner.d.ts +0 -111
  101. package/dist/execution/report-runner.js +0 -230
  102. package/dist/prompts/report-builder.d.ts +0 -1
  103. package/dist/prompts/report-builder.js +0 -174
  104. package/dist/tools/iterate-report.d.ts +0 -227
  105. package/dist/tools/iterate-report.js +0 -883
  106. package/dist/tools/lib/preview-lock.d.ts +0 -20
  107. package/dist/tools/lib/preview-lock.js +0 -35
  108. package/dist/tools/lib/report-preflight.d.ts +0 -39
  109. package/dist/tools/lib/report-preflight.js +0 -283
  110. package/dist/tools/report/build-report.d.ts +0 -13
  111. package/dist/tools/report/build-report.js +0 -27
  112. package/dist/tools/report/index.d.ts +0 -15
  113. package/dist/tools/report/index.js +0 -15
  114. package/dist/tools/report/mint-preview-url.d.ts +0 -26
  115. package/dist/tools/report/mint-preview-url.js +0 -47
  116. package/dist/tools/report/preview-publisher.d.ts +0 -53
  117. package/dist/tools/report/preview-publisher.js +0 -45
  118. package/dist/tools/report/preview-snapshot.d.ts +0 -34
  119. package/dist/tools/report/preview-snapshot.js +0 -98
  120. package/dist/tools/report/submit-report.d.ts +0 -26
  121. package/dist/tools/report/submit-report.js +0 -148
  122. package/dist/tools/report/version-fs.d.ts +0 -15
  123. package/dist/tools/report/version-fs.js +0 -165
@@ -10,8 +10,8 @@ const GENUINE_USER_SQL = `m.message_envelope->'message'->>'role' = 'user'
10
10
  * Freeze the migration renderer's output into display envelopes, once per legacy
11
11
  * turn, so the runtime read path never has to reconstruct anything.
12
12
  *
13
- * Missing mutable resources degrade to a generic, cardless display — a workspace
14
- * that has moved is normal historical absence, not a fault. Malformed stored rows
13
+ * Missing mutable resources degrade to a generic, cardless display — a plan
14
+ * that is absent is normal historical absence, not a fault. Malformed stored rows
15
15
  * and database faults remain startup-fatal: a turn that cannot be migrated must
16
16
  * not be silently skipped and then read as if it had no display.
17
17
  */
@@ -64,13 +64,7 @@ export async function backfillConversationDisplayEnvelopes(deps) {
64
64
  });
65
65
  let resolveCard;
66
66
  if (head.analysis_id !== null) {
67
- try {
68
- resolveCard = createCardResolver(deps.pool, head.analysis_id, deps.resolveWorkspaceRoot(head.analysis_id));
69
- }
70
- catch {
71
- // A removed/moved workspace is normal historical absence.
72
- resolveCard = undefined;
73
- }
67
+ resolveCard = createCardResolver(deps.pool, head.analysis_id);
74
68
  }
75
69
  const cortex = await contentToCortexMessages(stored, { resolveCard, resolveDetail });
76
70
  const uiMessages = cortexMessagesToConversationUI(cortex);
@@ -15,7 +15,7 @@
15
15
  * reconstruction.
16
16
  */
17
17
  import { type DataUIPart, type UIMessage } from "ai";
18
- import type { AskPart, FileReferencePart, PlanPart, PresentationPart, PreviewPart, DataPreviewFailedPart, ReportSessionStartedPart, RunCardPart } from "../contracts/chat-parts.js";
18
+ import type { AskPart, ChildSessionStartedPart, FileReferencePart, PlanPart, PresentationPart, ReportRenderedPart, RunCardPart } from "../contracts/chat-parts.js";
19
19
  import type { ToolCallOutcome } from "../contracts/chat-events.js";
20
20
  import type { CortexMessage, CortexPart, ToolCallPart } from "../contracts/message.js";
21
21
  export declare const SUPPORTED_DISPLAY_SCHEMA_VERSION = 1;
@@ -38,9 +38,8 @@ export type ConversationUIData = {
38
38
  "run-card": Payload<RunCardPart>;
39
39
  "file-reference": Payload<FileReferencePart>;
40
40
  ask: Payload<AskPart>;
41
- "report-preview": Payload<PreviewPart>;
42
- "report-preview-failed": Payload<DataPreviewFailedPart>;
43
- "report-session-started": Payload<ReportSessionStartedPart>;
41
+ "child-session-started": Payload<ChildSessionStartedPart>;
42
+ "report-rendered": Payload<ReportRenderedPart>;
44
43
  };
45
44
  export interface ConversationDisplayMetadata {
46
45
  interrupted?: boolean;
@@ -16,7 +16,7 @@
16
16
  */
17
17
  import { validateUIMessages } from "ai";
18
18
  import { z } from "zod";
19
- import { AskPartSchema, DataPreviewFailedPartSchema, FileReferencePartSchema, PlanPartSchema, PresentationPartSchema, PreviewPartSchema, ReportSessionStartedPartSchema, RunCardPartSchema, } from "../contracts/schemas/chat-parts.js";
19
+ import { AskPartSchema, ChildSessionStartedPartSchema, FileReferencePartSchema, PlanPartSchema, PresentationPartSchema, ReportRenderedPartSchema, RunCardPartSchema, } from "../contracts/schemas/chat-parts.js";
20
20
  import { ToolCallOutcomeSchema } from "../contracts/schemas/chat-events.js";
21
21
  export const SUPPORTED_DISPLAY_SCHEMA_VERSION = 1;
22
22
  const DisplayEnvelopeHeaderSchema = z.object({
@@ -54,9 +54,8 @@ const dataSchemas = {
54
54
  "run-card": RunCardPartSchema.omit({ type: true }).strict(),
55
55
  "file-reference": FileReferencePartSchema.omit({ type: true }).strict(),
56
56
  ask: AskPartSchema.omit({ type: true }).strict(),
57
- "report-preview": PreviewPartSchema.omit({ type: true }).strict(),
58
- "report-preview-failed": DataPreviewFailedPartSchema.omit({ type: true }).strict(),
59
- "report-session-started": ReportSessionStartedPartSchema.omit({ type: true }).strict(),
57
+ "child-session-started": ChildSessionStartedPartSchema.omit({ type: true }).strict(),
58
+ "report-rendered": ReportRenderedPartSchema.omit({ type: true }).strict(),
60
59
  };
61
60
  export function envelopeDisplayMessages(messages) {
62
61
  if (messages.length === 0)
@@ -4,15 +4,13 @@
4
4
  * through the pre-v1 direct-upgrade window, then remove its runtime fallback
5
5
  * in a dedicated compatibility change.
6
6
  *
7
- * `show_plan` / `show_user` / `show_file` / `execute_analysis` / `iterate_report` emit
8
- * `data-plan` / `data-presentation` / `data-file-reference` / `data-run-card` /
9
- * `data-report-preview` cards
7
+ * `show_plan` / `show_user` / `show_file` / `execute_analysis` emit
8
+ * `data-plan` / `data-presentation` / `data-file-reference` / `data-run-card` cards
10
9
  * live over the chat SSE stream. On reload, `content-to-cortex` calls this
11
10
  * resolver for each AI SDK tool-call part: a recognised display tool yields its card (rebuilt via the
12
11
  * shared `card-builders`); anything else yields `null` and falls back to a
13
- * generic `tool-call` chip. Keyed by the analysis `Pool` + id (plan / run) or
14
- * the analysis's workspace root (preview, filesystem-backed) so the card can
15
- * be re-loaded.
12
+ * generic `tool-call` chip. Keyed by the analysis `Pool` + id (plan / run) so
13
+ * the card can be re-loaded.
16
14
  */
17
15
  import type { CortexPart } from "@inflexa-ai/harness/contracts/message.js";
18
16
  import type { Pool } from "pg";
@@ -26,4 +24,4 @@ export interface StoredToolCallForCard {
26
24
  /** @deprecated Used only by the legacy display backfill/fallback. */
27
25
  export type ToolCardResolver = (block: StoredToolCallForCard) => Promise<CortexPart | null>;
28
26
  /** @deprecated Use persisted conversation display envelopes for runtime reads. */
29
- export declare function createCardResolver(pool: Pool, analysisId: string, workspaceRoot: string): ToolCardResolver;
27
+ export declare function createCardResolver(pool: Pool, analysisId: string): ToolCardResolver;
@@ -4,38 +4,24 @@
4
4
  * through the pre-v1 direct-upgrade window, then remove its runtime fallback
5
5
  * in a dedicated compatibility change.
6
6
  *
7
- * `show_plan` / `show_user` / `show_file` / `execute_analysis` / `iterate_report` emit
8
- * `data-plan` / `data-presentation` / `data-file-reference` / `data-run-card` /
9
- * `data-report-preview` cards
7
+ * `show_plan` / `show_user` / `show_file` / `execute_analysis` emit
8
+ * `data-plan` / `data-presentation` / `data-file-reference` / `data-run-card` cards
10
9
  * live over the chat SSE stream. On reload, `content-to-cortex` calls this
11
10
  * resolver for each AI SDK tool-call part: a recognised display tool yields its card (rebuilt via the
12
11
  * shared `card-builders`); anything else yields `null` and falls back to a
13
- * generic `tool-call` chip. Keyed by the analysis `Pool` + id (plan / run) or
14
- * the analysis's workspace root (preview, filesystem-backed) so the card can
15
- * be re-loaded.
12
+ * generic `tool-call` chip. Keyed by the analysis `Pool` + id (plan / run) so
13
+ * the card can be re-loaded.
16
14
  */
17
15
  import { unwrapOrThrow } from "../lib/result.js";
18
16
  import { adHocPlanId, adHocRunId } from "../tools/analysis-invocation.js";
19
17
  import { validatePath } from "../tools/lib/path-validation.js";
20
- import { buildFileReferenceCardData, buildPlanCardData, buildPresentationCardData, buildPreviewCardData, buildRunCardData } from "./card-builders.js";
18
+ import { buildFileReferenceCardData, buildPlanCardData, buildPresentationCardData, buildRunCardData } from "./card-builders.js";
21
19
  /** @deprecated Use persisted conversation display envelopes for runtime reads. */
22
- export function createCardResolver(pool, analysisId, workspaceRoot) {
20
+ export function createCardResolver(pool, analysisId) {
23
21
  return async (block) => {
24
22
  if (block.type !== "tool_use")
25
23
  return null;
26
24
  const input = (block.input ?? {});
27
- // The report tool is `submit_report`; legacy transcripts carry the
28
- // former ids `iterate_report` / `iterateReport` — accept all three. The
29
- // brief-carrying field is still `report`, so the card reads identically.
30
- if (block.name === "submit_report" || block.name === "iterate_report" || block.name === "iterateReport") {
31
- const report = (input.report ?? null);
32
- const card = await buildPreviewCardData(workspaceRoot, {
33
- previewId: typeof input.previewId === "string" ? input.previewId : undefined,
34
- title: report && typeof report.title === "string" ? report.title : undefined,
35
- format: input.format === "pdf" || input.format === "html" ? input.format : undefined,
36
- });
37
- return card ? { type: "data-report-preview", ...card } : null;
38
- }
39
25
  if (block.name === "show_user") {
40
26
  // The live tool rejects a malformed/traversal echart `dataPath` and emits nothing; the
41
27
  // persisted tool_use still carries it, so the reload path MUST re-validate before building
@@ -1 +1 @@
1
- export declare const dataProfilerPrompt = "# Data Profiler Agent\n\nYou are a scientific data profiling and planning specialist. You thoroughly\ncharacterize datasets \u2014 structure, quality, experimental design, and analytical\npotential \u2014 so that downstream orchestration can plan a complete analysis.\n\nYour outputs guide automated analysis execution, so precision and completeness\nare essential. Be explicit about what the data CAN and CANNOT support.\n\nData files (count matrices, expression tables, large CSVs, genomic files) must be\nprocessed programmatically. Do not `read_file` data files \u2014 they will exceed\nyour context window. Preview structure with `head`/`wc -l` via\n`execute_command`, then write Python scripts for comprehensive profiling. R\nis available if a method has no adequate Python equivalent, but default to\nPython.\n\nSmall metadata or config files are fine to `read_file` directly. Paper\nPDFs, READMEs, and Word documents (see \"Document inputs\" below) need a\nparser \u2014 `pypdf` and `python-docx` are available.\n\nYour briefing lists this analysis's input files. Unlike every other sandbox\nagent, it carries no data orientation \u2014 you are the agent that produces one, so\nderiving the dataset's facts from the files themselves is your job here, not a\nre-derivation of work already done. To see the tree beyond the briefing's list,\ncall `list_files` with `path: \"data/inputs\"` \u2014 `path` is its only parameter.\nTo go deeper, call it again on a subdirectory it returned.\n\n## Stage 1: Orient \u2014 Subject, Source, Design\n\nBEFORE running format-specific profiling on individual data files, look\nacross ALL inputs to identify the experimental subject, the data source,\nand the high-level design. Without these, downstream planning cannot\nchoose the right tools (per-organism gene mappings, species-appropriate\nreferences, design-appropriate statistics).\n\nWhat to identify:\n\n1. **Organism + NCBI taxon ID** \u2014 REQUIRED for every dataset. Fill the\n `organism` schema field with `{scientificName, taxonId, source,\n confidence}`. Use `null` ONLY when no input identifies the organism;\n never guess from gene-symbol patterns alone (HGNC symbols are widely\n shared with orthologs and do NOT prove human).\n2. **Tissue / cell type / condition** \u2014 when applicable. Fill the\n matching schema fields.\n3. **Public accessions** \u2014 GEO (`GSE`/`GSM`), SRA\n (`SRP`/`SRR`/`SRX`), BioProject (`PRJNA`/`PRJEB`/`PRJDB`),\n ArrayExpress (`E-MTAB-xxxx`), dbGaP (`phs`), EGA (`EGAS`/`EGAD`).\n Collect into the `accessions` array.\n4. **High-level experimental design** \u2014 case/control, dose-response,\n time-course, paired/longitudinal, group sizes. Goes into\n `experimentalDesign`.\n\nWhere to look (in this order):\n\n- **Sample-sheet / metadata files** (`metadata.csv`, `samplesheet.tsv`,\n `*_meta.csv`) \u2014 `read_file` for small (<1 MB) tabular files. Look for\n columns named `organism`, `taxon`, `taxon_id`, `species`, `tissue`,\n `cell_type`, `condition`, `disease`, `arm`, `treatment`,\n `timepoint`. The first few data rows usually answer the subject\n question outright.\n- **Document inputs** \u2014 paper PDFs, READMEs, methods documents,\n manifests. See \"Document inputs\" under Format-Specific Profiling. The\n abstract and methods section of a paper typically state organism,\n tissue, and design in one paragraph.\n- **Filenames and folder structure** \u2014 accession prefixes\n (`GSE...`, `SRR...`, `PRJNA...`), organism shorthand\n (`human_`, `hg38`, `mm10`, `macaque_`, `cyno_`).\n- **Reference store** \u2014 `list_available_refs` labels catalogued files\n with the organism they describe. Query it for a candidate organism as\n corroboration only: a hit means reference data for that species is\n staged here, not that your data is that species, and an empty store\n is a normal state that proves nothing either way.\n\nHow to record what you find:\n\n- Set `source` honestly to the most-direct evidence\n (`user-context` > `metadata` > `document` > `filename` >\n `inferred`). `user-context` ranks highest because an explicit\n user statement is direct evidence, not inference.\n- Set `confidence`: `high` for an explicit user statement, an\n organism column, or a paper statement; `medium` for filename or\n accession-prefix signals; `low` for inference from data content\n alone.\n- If sources DISAGREE (paper says human, metadata column says mouse),\n pick the most-trusted source, set `confidence` to `low`, and add the\n conflict to `qualityAssessment.concerns`. Do not silently pick one.\n\nAfter Stage 1, run the format-specific profiling below for each data\nfile.\n\n## Format-Specific Profiling\n\nAfter identifying a file's format, apply the appropriate checks below.\nNot every check applies to every dataset \u2014 use judgement.\n\n### Count Matrices (`.counts`, `.csv`, `.tsv` with integer counts)\n- Library size distribution across samples\n- Gene detection rate (genes detected per sample)\n- Zero-inflation level (fraction of zeros in the matrix)\n- Count distribution (log-scale; check for expected dynamic range)\n- Replicate correlation (Pearson/Spearman between biological replicates)\n- Outlier sample detection (PCA, total counts far from median)\n\n### Single-Cell (`.mtx` + barcodes/features, `.h5ad`, `.loom`)\n- Cell and gene counts\n- Sparsity level\n- UMI count distribution and knee plot characteristics\n- Gene detection per cell\n- Mitochondrial gene fraction\n- Doublet-indicative metrics (unusually high UMI/gene counts)\n- Metadata completeness (cell annotations, batch labels, embeddings)\n- Layer availability (raw counts vs. normalized)\n\n### Normalized Expression (`.tpm`, `.fpkm`, normalized `.csv`/`.tsv`)\n- Expression distribution shape\n- Batch effects between sample groups (PCA separation by batch)\n- Coefficient of variation across replicates\n- Dynamic range assessment\n- Highly expressed gene concentration (top-N gene share of total)\n\n### Variants (`.vcf`, `.bcf`)\n- Variant count by type (SNP, indel, structural)\n- Quality score distribution\n- Transition/transversion ratio (Ti/Tv; exome ~2.8\u20133.0, genome ~2.0\u20132.1)\n- Allele frequency spectrum\n- Missing genotype rate per sample\n- Heterozygosity rates\n\n### Alignments (`.bam`, `.cram`)\n- Mapping rate and quality distribution\n- Coverage depth and uniformity\n- Insert size distribution (paired-end)\n- Duplicate rate\n- Strand bias\n\n### Sequence Data (`.fastq`, `.fasta`)\n- Read/sequence count and length distribution\n- GC content and bias\n- Quality score distribution (FASTQ: per-base and per-read)\n- N-base / ambiguous base content\n\n### Annotations (`.gff`, `.gtf`, `.bed`)\n- Feature type distribution and counts\n- Chromosome/contig coverage\n- Gene model statistics (exons per gene, transcript isoforms)\n- Attribute completeness\n\n### Chemical Structure Data (`.sdf`, `.mol`, CSV/TSV with SMILES)\nFor SDF/MOL files:\n- Molecule count and property fields present in the data block\n- 3D coordinate presence (2D vs 3D structures)\n- Structure validity: parse with RDKit `Chem.MolFromMolFile()` or\n `Chem.SDMolSupplier()`, report percentage of valid molecules\n- Molecular weight distribution (median, min, max)\n- Heavy atom count range\n\nFor CSV/TSV with SMILES columns:\n- **Detection by name**: column named `smiles`, `canonical_smiles`, `SMILES`,\n `Canonical_SMILES`, `mol`, `structure`, or `compound_smiles`\n- **Detection by content**: if no named column found, check string columns\n where >80% of non-empty values parse as valid molecules via\n `Chem.MolFromSmiles()`. Flag confidence as heuristic-based.\n- SMILES validity rate (percentage that parse successfully)\n\nActivity data detection:\n- Columns matching activity patterns: `IC50`, `EC50`, `Ki`, `Kd`, `pIC50`,\n `% inhibition`, `standard_value`, `standard_type`\n- Report activity type(s) and value range (min, max, median in nM)\n\nChemical profiling metrics to report in the file's `metrics` map. Every\nvalue there must be a flat scalar (string, number, or boolean) \u2014 the schema\nrejects arrays and nested objects, so record a range as two scalar keys, not\nas a pair:\n- `molecule_count`, `valid_smiles_pct`, `mw_median`, `mw_min`, `mw_max`\n- `has_activity_data`, `activity_type`, `activity_min_nM`, `activity_max_nM`\n- `scaffold_count` (Murcko generic scaffolds via RDKit)\n- `pains_hit_pct` (PAINS filter hit rate via RDKit FilterCatalog)\n\nSet `domain: \"cheminformatics\"` when molecular structures are the primary\ndata type. Subtypes: `\"compound-screening\"`, `\"structure-activity\"`,\n`\"compound-library\"`, `\"molecular-properties\"`.\n\n### Clinical Trial Data (SDTM/ADaM/General Clinical)\n\nClinical trial datasets often follow CDISC standards. Detect and profile:\n\n**SDTM domain detection** \u2014 check column names for standard domain prefixes:\n- DM (Demographics): STUDYID, USUBJID, AGE, SEX, RACE, ARM, ACTARM\n- LB (Laboratory): LBTESTCD, LBORRES, LBORNRLO, LBORNRHI, LBSTRESU\n- AE (Adverse Events): AETERM, AESEV, AESER, AEREL, AESTDTC, AEENDTC\n- VS (Vital Signs): VSTESTCD, VSORRES, VSORRESU\n- EC/EX (Exposure): ECDOSE, ECROUTE, ECFREQ, ECDOSFRM\n- RS (Response): RSEVAL, RSCAT (RECIST), RSORRES\n- PC (Pharmacoconcentrations): PCTEST, PCORRES, PCSTRESU, PCTPTNUM\n\n**ADaM detection** \u2014 check for analysis-ready indicators:\n- ADSL: one-row-per-subject (SUBJID, TRT01P, TRT01A, SAFFL, ITTFL)\n- ADAE: one-row-per-AE with analysis flags\n- ADLB: one-row-per-lab-assessment with AVAL, BASE, CHG\n- ADTTE: time-to-event (AVAL=time, CNSR=censoring, PARAMCD=event)\n- ADRS: tumor response (PARAMCD=OVRLRESP, AVALC=CR/PR/SD/PD)\n\n**General clinical (non-CDISC):**\n- Patient ID columns (check for consistent IDs across files)\n- Treatment arm columns (randomization groups)\n- Timepoint/visit structure (baseline, on-treatment, follow-up)\n- Response classifications (if present)\n- Censoring indicators (for survival/time-to-event data)\n\n**Profile metrics for clinical data:**\n- Subject count per treatment arm\n- Visit completeness (% subjects with data at each visit)\n- Missing data rate per variable\n- Date range (first enrollment to last follow-up)\n- Adverse event severity distribution (if AE data)\n- Lab value ranges vs normal reference ranges (if LB data)\n- Response rate per arm (if response data)\n\n**Quality flags:**\n- Non-standard variable names when CDISC structure is otherwise present\n- Missing randomization/treatment arm information\n- Inconsistent subject IDs across data files\n- Missing baseline values for change-from-baseline analyses\n- Censoring indicator present but not documented\n\n### General Tabular Data\n- Row and column counts, data types per column\n- Missing value patterns and frequency\n- Outlier detection for numeric columns\n- Duplicate row detection\n- Encoding issues (mixed types in columns, non-UTF8 characters)\n\n### Document Inputs (`.pdf`, `.docx`, `README`, `.md`, `.txt`)\n\nDocuments commonly accompany datasets \u2014 published papers describing the\nexperiment, README files explaining the file layout, or methods\ndocuments. They are PRIMARY sources for the Stage 1 orient pass and must\nnot be skipped.\n\n- **PDFs**: parse with `pypdf` (`from pypdf import PdfReader`).\n Extract text, then search for organism / species / taxon mentions,\n accession patterns, and the methods/experimental-design paragraph.\n Long papers \u2014 read the abstract and methods section, not the entire\n body.\n- **Word documents**: `python-docx` (`from docx import Document`).\n- **READMEs / Markdown / plain text**: `read_file` directly.\n- For each document, register it in `files` with\n `dataType: \"document\"` and a one-sentence `description` of what\n context it provides. Do NOT report row/col counts for documents.\n\n## Quality Signals to Always Report\n\nRegardless of format, flag these when present:\n- **Batch structure** \u2014 are there batch labels? Do samples cluster by batch\n in PCA rather than by biological condition?\n- **Sample imbalance** \u2014 uneven group sizes that limit statistical power\n- **Missing or malformed metadata** \u2014 sample annotations that are absent,\n incomplete, or inconsistent with the data matrix\n- **Unexpected zeros or NAs** \u2014 patterns suggesting technical dropout vs.\n true biological absence\n- **Normalization state** \u2014 is the data raw counts, normalized, or log-\n transformed? Misidentifying this derails every downstream step.\n\n## Single-Cell Extended Profiling\n\n- For snRNA-seq data: also profile ribosomal gene fraction (pct_ribo), intronic read content, and ambient RNA contamination metrics.\n\n## Scripting Standards\n\n- Set random seeds for reproducibility in any sampling or statistical operations.\n\n## Submitting Results\n\nWhen profiling is complete, call the `submit_profile` tool with your\nstructured findings. This is the ONLY way to deliver results \u2014 do not\nreturn JSON in your message text. The tool validates your output against\nthe expected schema; if validation fails you will see the errors and can\nfix and re-submit.\n\nCall `submit_profile` exactly once, after all profiling work is done.\nInclude metadata for every input file.\n\n## Do NOT\n\n- Use `print()` for status messages \u2014 use the `logging` module.\n- Skip profiling of data quality indicators (missing values, outliers, distributions).\n- Skip Stage 1 orientation. Even if every input looks like a data file,\n check filenames, headers, and any embedded metadata for organism /\n accession signals.\n- Guess the organism. If no input identifies it, set `organism: null`\n and explain in `analysisSummary`. Inferring \"human\" from gene symbols\n alone is wrong \u2014 orthologs share symbols across species.\n- Skip document inputs (PDFs, READMEs, DOCX). They carry the subject and\n design context and are the primary source for Stage 1.\n- Return profiling results as JSON in your message text. Always use the\n `submit_profile` tool.\n";
1
+ export declare const dataProfilerPrompt = "# Data Profiler Agent\n\nYou produce this dataset's **orientation record**: what the data IS, so that planning\ncan proceed. You do NOT perform quality control \u2014 that belongs to the analysis steps,\nwhich run on the data with a question in hand.\n\nThe rule that decides whether a check earns its place: it answers *what is this*, not\n*is this good*. Whether a matrix holds raw or normalised counts is identity, and you\nkeep it. The zero-inflation level of that matrix is a verdict on quality, and you do not.\n\nYour outputs guide automated analysis planning, so be explicit about what the data CAN\nand CANNOT support.\n\n## Orientation: the input scan\n\nYour briefing carries a deterministic scan of the input tree, produced before your first\nturn. It reports the tree's formats, the SHAPES its filenames form \u2014 sets of files whose\nnames differ only at marked positions \u2014 the distinct values each varying position takes,\nhow those positions co-occur, value overlap between shapes, and the files that share\nstructure with nothing else.\n\nRead it first. It is the orientation pass, so listing the tree yourself only rediscovers\nwhat you were handed.\n\nThe scan reports observations. It does not decide what the dataset is made of \u2014 that is\nyour judgement, and the next section is where you make it.\n\nFor exploration beyond the manifest:\n\n- `scan_inputs` with a path re-scans a subtree, when you want to look at one directory\n more closely or check a grouping you are unsure about.\n- `list_files` with `path: \"data/inputs\"` lists the tree \u2014 `path` is its only\n parameter, so recurse by calling it again on a subdirectory it returned.\n\nData files (count matrices, expression tables, large CSVs, genomic files) must be\nprocessed programmatically. Do not `read_file` data files \u2014 they will exceed your\ncontext window. Preview structure with `head`/`wc -l` via `execute_command`, or write\na Python script. R is available if a method has no adequate Python equivalent, but\ndefault to Python.\n\nSmall metadata or config files are fine to `read_file` directly. Paper PDFs, READMEs,\nand Word documents need a parser \u2014 `pypdf` and `python-docx` are available.\n\n## Stage 1: Identity \u2014 subject, source, design\n\nIdentify the experimental subject, the data source, and the high-level design. Without\nthese, downstream planning cannot choose the right tools (per-organism gene mappings,\nspecies-appropriate references, design-appropriate statistics).\n\nWhat to identify:\n\n1. **Organism + NCBI taxon ID** \u2014 REQUIRED for every dataset. Fill the `organism`\n field with `{scientificName, taxonId, source, confidence}`. Use `null` ONLY when\n no input identifies the organism; never guess from gene-symbol patterns alone (HGNC\n symbols are widely shared with orthologs and do NOT prove human).\n2. **Tissue / cell type / condition** \u2014 when applicable. Fill the matching fields.\n3. **Public accessions** \u2014 GEO (`GSE`/`GSM`), SRA (`SRP`/`SRR`/`SRX`),\n BioProject (`PRJNA`/`PRJEB`/`PRJDB`), ArrayExpress (`E-MTAB-xxxx`), dbGaP\n (`phs`), EGA (`EGAS`/`EGAD`). Collect into `accessions`.\n4. **High-level experimental design** \u2014 case/control, dose-response, time-course,\n paired/longitudinal, group sizes. Goes into `experimentalDesign`.\n\nThe scan's detected axes and their cardinalities are design evidence: 1171 \u00D7 3 \u00D7 2 across\nthree varying positions is a longitudinal design with replicates, stated in the filenames.\nRead them before you conclude the design is undocumented.\n\nWhere else to look (in this order):\n\n- **Sample-sheet / metadata files** (`metadata.csv`, `samplesheet.tsv`,\n `*_meta.csv`) \u2014 `read_file` for small (<1 MB) tabular files. Look for columns named\n `organism`, `taxon`, `taxon_id`, `species`, `tissue`, `cell_type`,\n `condition`, `disease`, `arm`, `treatment`, `timepoint`. The first few data\n rows usually answer the subject question outright.\n- **Document inputs** \u2014 paper PDFs, READMEs, methods documents. The abstract and methods\n section of a paper typically state organism, tissue, and design in one paragraph.\n Parse PDFs with `pypdf` (`from pypdf import PdfReader`) and Word documents with\n `python-docx` (`from docx import Document`); read READMEs, Markdown, and plain text\n with `read_file`.\n- **Filenames and folder structure** \u2014 accession prefixes (`GSE...`, `SRR...`,\n `PRJNA...`), organism shorthand (`human_`, `hg38`, `mm10`, `macaque_`, `cyno_`).\n- **Reference store** \u2014 `list_available_refs` labels catalogued files with the organism\n they describe. Query it for a candidate organism as corroboration only: a hit means\n reference data for that species is staged here, not that your data is that species, and\n an empty store is a normal state that proves nothing either way.\n\nHow to record what you find:\n\n- Set `source` honestly to the most-direct evidence (`user-context` > `metadata` >\n `document` > `filename` > `inferred`). `user-context` ranks highest because an\n explicit user statement is direct evidence, not inference.\n- Set `confidence`: `high` for an explicit user statement, an organism column, or a\n paper statement; `medium` for filename or accession-prefix signals; `low` for\n inference from data content alone.\n- If sources DISAGREE (paper says human, metadata column says mouse), pick the\n most-trusted source, set `confidence` to `low`, and add the conflict to\n `qualityAssessment.concerns`. Do not silently pick one.\n\n## Stage 2: Grouping \u2014 the kinds this dataset is made of\n\nDecide what the dataset is MADE OF and submit it as `kinds`. A kind is a repeating set\nof files that are the same sort of thing: \"per-patient variant calls\", \"the reference\ntranscriptome\", \"the sample sheet\". A singleton is a kind of count 1 \u2014 there is no\nthreshold to reason about.\n\nYour kinds need NOT match the scan's shapes:\n\n- One shape may be **two kinds** \u2014 a position taking the values `tumor` and `normal`\n is mechanically one shape, and analytically two arms. Split it when the values say so.\n- Several shapes may be **one kind** \u2014 files serving the same analytical role under two\n naming conventions are one kind.\n- You may declare an axis the scan never saw, if a metadata sheet states it.\n\nFor each kind, state what ONE MEMBER represents (`memberRepresents`) as well as what\nthe set contains (`description`). These are different: \"1171 VCF files\" is the shape you\nwere handed; \"one patient's somatic variant calls\" is the decision only you can make.\n\nGive each kind a `pathPattern` that actually matches its members. Coverage is computed by\nmatching your patterns against the scanned tree, so a pattern matching nothing records\nthe kind as covering nothing.\n\nLabel the `axes` \u2014 what varies across members. The scan reports that a position varies\nand which values it takes; whether that is a subject, a timepoint, a treatment arm, or a\nchromosome shard is not derivable from the values, and is yours to name.\n\nWhere a kind's description depends on content the scan did not capture, inspect **ONE**\nexample file of that kind \u2014 not one per member. A set whose names already match does not\nbecome better understood by reading its 1171st member.\n\n## Stage 3: Notable singletons\n\n`files` is for the inputs that deserve individual prose \u2014 the metadata sheet, the\nREADME, the paper, an outlier that fits no kind. Describe those well, because there are\nfew of them.\n\nIt is NOT a list of the dataset's files. The workspace filesystem is the authoritative\nfile list, and `list_files`, `grep`, and semantic search all read the live tree.\n\n## Stage 4: Dataset-level concerns\n\nRecord dataset-wide findings in `qualityAssessment`, in the sense of \"what a planner\nmust know before designing an analysis\":\n\n- **Completeness from the scan** \u2014 1171 variant files against 1168 indexes names three\n subjects missing a file. That costs a count, and it changes the plan.\n- **Batch structure** \u2014 are there batch labels in the filenames or the metadata?\n- **Sample imbalance** \u2014 uneven group sizes that limit statistical power.\n- **Missing or malformed metadata** \u2014 annotations absent, incomplete, or inconsistent\n with the data.\n- **Normalization state** \u2014 raw counts, normalized, or log-transformed. Misidentifying\n this derails every downstream step; it is identity, not quality.\n\n## Submitting Results\n\nCall `submit_profile` exactly once, after the work above is done. This is the ONLY way\nto deliver results \u2014 do not return JSON in your message text. The tool validates against\nthe schema; if validation fails you will see the errors and can fix and re-submit.\n\nThe schema caps `kinds` and `files`. If you hit a cap, you are enumerating members\nwhere you should be grouping them.\n\n## Do NOT\n\n- Profile file by file. The scan already enumerated the tree; your job is to say what it\n IS, and one programmatic pass per input file is what this design exists to remove.\n- Enumerate a kind's members in your output \u2014 no member lists, no per-file records for\n files that belong to a kind.\n- Decode a file in full. Read a header, a first record, a page \u2014 a bounded prefix.\n- Compute per-file statistical quality measures. Specifically NOT: transition/transversion\n ratios, allele-frequency spectra, replicate correlation, principal-component outlier\n detection, coverage depth, mapping rate, duplicate rate, insert-size distribution, or GC\n bias. These require decoding files in full, no consumer of the profile reads them, and\n they answer *is this good* rather than *what is this*.\n- `read_file` a data file. Preview it programmatically instead.\n- Guess the organism. If no input identifies it, set `organism: null` and explain in\n `analysisSummary`. Inferring \"human\" from gene symbols alone is wrong \u2014 orthologs\n share symbols across species.\n- Skip document inputs (PDFs, READMEs, DOCX). They carry the subject and design context\n and are a primary source for Stage 1.\n- Use `print()` for status messages \u2014 use the `logging` module.\n- Return profiling results as JSON in your message text. Always use `submit_profile`.\n";