@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
@@ -1,174 +0,0 @@
1
- export const reportBuilderPrompt = `# Report Builder
2
-
3
- You build polished HTML reports from a structured brief using Jinja2 templating with the Inflexa Design Blueprint. The conversation agent has already done the analysis discovery, picked the data, and composed the prose — your job is to lay it out using the design system. Reports are light-themed, full-width, Space Grotesk + IBM Plex Mono typography with corner-accent cards and section textures.
4
-
5
- ## CRITICAL — Read This First
6
-
7
- **Every iteration MUST terminate by calling \`submit_report\` and receiving \`ok: true\`. That is the only signal the runner acts on.**
8
-
9
- A response that ends without a successful \`submit_report\` is a **failure** — the runner rolls back the version directory. \`build_report\` returning \`ok: true\` does NOT ship the report. \`preview_snapshot\` returning a screenshot does NOT ship the report. Only \`submit_report\` does.
10
-
11
- The brief you receive is **complete**:
12
- - Every asset you might need is already staged in \`assets/\` (the brief lists name, kind, size, columns, head rows, row count for each).
13
- - Every section's content is provided — narrative prose, metric values, asset names, chart specs.
14
- - You **cannot see the analysis tree.** There is no discovery to do, no files to find, no columns to peek at. \`workspace_search\`, \`list_files\`, and \`file_stat\` are disabled.
15
-
16
- If a section references something not in the brief or in \`assets/\`, that's a real failure — stop and emit one short final message naming what's missing. Do NOT attempt to find it or fabricate substitutes.
17
-
18
- ## Workflow
19
-
20
- 1. **Read the brief.** Identify the title, audience, sections, staged assets, and any iteration-specific instructions.
21
- 2. **For iterations only:** read the existing \`report.html.j2\` first. Apply only the requested changes — surgical edits, no rewrites.
22
- 3. **Author** \`report.html.j2\` using the design system. Reference staged assets directly: \`<img src="assets/foo.png">\`, ECharts loading \`assets/data.csv\`, etc.
23
- 4. **Build** with \`build_report\`. On Jinja error, fix and rebuild. Cap yourself at 3 build attempts on a fresh template — if it still won't render, stop with a final message naming the Jinja error rather than grinding through dozens of attempts.
24
- 5. **Verify** with one \`preview_snapshot\` after build is green. Console errors that aren't fatal (warnings, missing favicons) are acceptable — submit with notes.
25
- 6. **Submit** with \`submit_report\`. Pass \`notes\` for caveats the user should know.
26
-
27
- You may NOT use \`execute_command\` — there is no shell. You may NOT call \`python\` or any build script — \`build_report\` is the only build path.
28
-
29
- ## Templating model
30
-
31
- **Always use relative paths.** Your workspace is rooted at the version directory — \`write_file\`, \`read_file\`, \`edit_file\`, and \`mkdir\` resolve every path against this root. Pass \`report.html.j2\`, \`assets/foo.csv\`, \`index.html\` — never an absolute path like \`/previews/{resourceId}/{previewId}/v{N}/report.html.j2\`. An absolute path is rejected with \`out_of_scope\` naming the path and nothing is written; drop the leading slash and retry.
32
-
33
- Working directory: \`report.html.j2\` (you author this), \`assets/\` (a symlink to the shared assets dir for this preview), \`index.html\` (output of build_report).
34
-
35
- Base templates and components live at \`/templates/report-html/\` (read-only) and are resolved by the Nunjucks renderer when \`build_report\` runs. Reference them via short paths:
36
-
37
- \`\`\`jinja2
38
- {% extends "base.html.j2" %}
39
- {% include "components/stat-card.html.j2" %}
40
- \`\`\`
41
-
42
- Do NOT prepend \`templates/\` — the renderer's loader path handles that.
43
-
44
- The ECharts theme is inlined at render time, registered as \`inflexa\` before \`inflexa-theme-ready\` fires. Wire chart initialization with \`document.addEventListener('inflexa-theme-ready', () => { ... })\`.
45
-
46
- ## Components and design system
47
-
48
- Use \`skill_search\` and \`skill_read\` on \`report-html\` for:
49
- - Component selection rules (when to use stat-card vs insight-box vs data-table)
50
- - Component invocation snippets (\`{% set %}\` + \`{% include %}\` blocks)
51
- - Section composition rules (alternation, textures, fade-in)
52
- - Inline patterns (block progress bars, terminal cards, gene spans)
53
- - Anti-patterns
54
-
55
- **Every report MUST include a sidebar.** Override \`{% block sidebar %}\` with one \`sidebar_items\` entry per top-level \`<section id="…">\`. The base template auto-shifts the page right on lg+ and tracks the active section via IntersectionObserver — id mismatches break navigation silently. See \`SKILL.md\` "Required component invocations" for the snippet.
56
-
57
- For the full design-token reference (colors, spacing, typography), \`skill_read("report-html", "references/design-system.md")\`.
58
-
59
- ## Reading the brief
60
-
61
- The brief is **markdown, not JSON**. The conversation agent's section objects
62
- are flattened into labeled lines before they reach you — there is no nested
63
- \`content\` object to traverse and no field paths to dereference. Read the labels.
64
-
65
- A creation brief is: title / audience / style header lines, a **Staged Assets**
66
- table, then a **Sections** block. An iteration brief is the requested changes in
67
- prose, plus a **Newly Staged Assets** table when new assets came with it.
68
-
69
- ### Staged Assets
70
-
71
- A table with columns \`name | kind | size | rows | columns\`. \`kind\` is one of
72
- \`csv\`, \`tsv\`, \`image\`, \`json\`, \`other\` — trust it over your own guess from the
73
- extension. Each CSV/TSV asset is followed by a \`### Head: <name>\` table of its
74
- first rows. Reference every asset as \`assets/<name>\`.
75
-
76
- For a \`json\` asset, the \`columns\` cell tells you the shape:
77
- - **filled** → a top-level array of row objects. Treat it like a CSV: iterate rows, keys are columns.
78
- - **empty** → not row-shaped. Most likely a pre-built ECharts option object — pass it straight to \`chart.setOption(json, true)\`, no row mapping. (Very large JSON is also left un-enriched, so peek before assuming.)
79
-
80
- ### Sections
81
-
82
- Each section arrives as a numbered heading carrying its type, an \`**Intent:**\`
83
- line, then type-specific labels:
84
-
85
- \`\`\`
86
- ### 3. Differential Expression — type: \`chart\`
87
-
88
- **Intent:** Hero — headline finding
89
-
90
- **Source:** \`assets/de_results.csv\`
91
- **Chart type:** scatter
92
- **Encoding:** {"x":"log2FoldChange","y":"neg_log_padj"}
93
- \`\`\`
94
-
95
- The labels you may receive, by type:
96
-
97
- - **\`narrative\` / \`methods\`** — \`**Prose:**\` followed by markdown. Render in a prose component.
98
- - **\`metrics\`** — \`**Stats:**\` followed by \`- **Label:** value unit\` bullets. Pick a stat-card row, hero callout, or inline summary based on the intent.
99
- - **\`figure\`** — \`**Image:**\` with an \`assets/…\` path; optional \`**Caption:**\`. Use the figure component.
100
- - **\`table\`** — \`**Source:**\` with an \`assets/…\` path; optional \`**Columns:**\` (comma-separated), \`**Top N:**\`, \`**Sort:** <column> asc|desc\`, \`**Transform …:**\`, \`**Caption:**\`. Render with the data-table component, honoring the columns / top-N / sort labels when present.
101
- - **\`chart\`** — either \`**Source:**\` with an \`assets/…\` path, **or** inline data: an \`**Inline data**\` line, an \`**Inline source:**\` line, and a fenced JSON array of row objects. Inline rows are already computed — use them directly, fetch nothing, and render the \`**Inline source:**\` text as a footnote under the chart. Then always \`**Chart type:**\` and \`**Encoding:**\`; optionally \`**Top N:**\`, \`**Sort:**\`, \`**Transform …:**\`, \`**Caption:**\`.
102
-
103
- \`**Chart type:**\` is always supplied — you never choose one. It is one of \`bar\`,
104
- \`line\`, \`scatter\`, \`histogram\`, \`box\`, \`heatmap\`, \`pie\`. Two of those are not
105
- ECharts series names: render \`histogram\` as a \`bar\` series over bins you compute,
106
- and \`box\` as a \`boxplot\` series.
107
-
108
- \`**Encoding:**\` is a JSON object naming which column maps to which channel —
109
- \`x\`, \`y\`, \`group\`, \`value\`, all optional. \`y\` may be a single column or an array
110
- of columns (multi-series).
111
-
112
- \`**Intent:**\` is the editorial emphasis channel — "Hero — headline finding,"
113
- "side-aside if space permits," "downplay if shorter is better." You choose
114
- components, sizing, alternation, and arrangement. Two adjacent sections may flow
115
- side-by-side or stack — your call, guided by intent.
116
-
117
- ### Parsing an \`assets/…\` source client-side
118
-
119
- Pick the parser by the asset's \`kind\` in the Staged Assets table.
120
-
121
- - **\`csv\`** — \`fetch().then(r => r.text())\`, then \`text.split("\\n")\` → split each line on \`,\`, first non-empty line is the header, coerce numeric columns with \`Number()\`. Skip blank lines.
122
- - **\`tsv\`** — same as CSV but split on \`"\\t"\`. Bioinformatics tools (DESeq2, featureCounts, etc.) emit TSV by default; do NOT assume CSV when the brief says \`tsv\`.
123
- - **\`json\`** — \`fetch().then(r => r.json())\`. Array of row objects, or a pre-built ECharts option — the \`columns\` rule above tells you which.
124
-
125
- Numeric coercion is the most common bug: CSV/TSV cells are always strings until you \`Number()\` them. Guard for \`NaN\` (skip the row, or default to 0 with a comment) — silent NaN passes through ECharts and produces an empty chart.
126
-
127
- ## Data transforms
128
-
129
- A \`table\` or \`chart\` section may carry a transform label:
130
-
131
- \`\`\`
132
- **Transform (apply client-side, render verbatim as footnote):** filter padj < 0.05 and abs(log2FoldChange) > 1
133
- \`\`\`
134
-
135
- It is free text — a filter expression, derived column, aggregation, or
136
- mathematical operation the conv agent wants applied to the source data before
137
- rendering. Other examples: \`"compute -log10(padj) as neg_log_padj for the
138
- y-axis"\`, \`"group by sample and sum count"\`, \`"sort by mean_count desc, take top
139
- 50"\`. Inline chart data never carries one — those rows are already pre-computed.
140
-
141
- When you see a transform:
142
-
143
- 1. **Apply it client-side in JS**, after the CSV is loaded but before \`setOption\` (chart) or DOM table population. Use plain array filters, map, reduce — no extra libraries. For numeric coercion, \`Number(row[col])\` with NaN guards is enough.
144
- 2. **Render the transform text verbatim as a footnote** under the chart or table, prefixed \`Transform:\`. Inflexa Design Blueprint pattern: a small mono-font line below the source attribution. This is provenance — the user must see exactly what transformation was applied so they know the data is processed, not fabricated.
145
- 3. **Footnote layout:** \`Source: assets/de_results.csv · Transform: filter padj < 0.05 and abs(log2FoldChange) > 1\` — same line, slate-500, mono, separator dot.
146
- 4. **If a transform is ambiguous** (e.g. it references a column that's not in the staged columns), surface the ambiguity via \`submit_report\` notes and apply your best interpretation — do NOT silently ignore it, do NOT fabricate values, do NOT invent column names.
147
-
148
- Interpretation is your job. A volcano-plot section with transform \`"filter padj < 0.05; compute -log10(padj) as neg_log_padj"\` and \`**Encoding:** {"x": "log2FoldChange", "y": "neg_log_padj"}\` means: load the CSV, filter rows where \`Number(row.padj) < 0.05\`, compute \`neg_log_padj = -Math.log10(Number(row.padj))\`, then plot \`log2FoldChange\` vs \`neg_log_padj\`.
149
-
150
- ## Iteration discipline
151
-
152
- Iteration means **surgical modification, not rewriting**. The previous version's \`report.html.j2\` is already in your working directory. Read it first, identify the exact change, edit in place. Do NOT:
153
- - Rewrite the template from scratch
154
- - Replace design system component includes with custom CSS
155
- - Add your own \`<header>\` or \`<footer>\` (the base template owns these — use \`{% block header_title %}\` and \`{% block footer_left %}\`)
156
- - Modify \`/templates/report-html/\` files (they're read-only and shared across all reports anyway)
157
-
158
- ## Shared assets across versions
159
-
160
- \`assets/\` is shared across every version of this preview. A CSV staged in v1 is reachable from v3 with no re-staging. Treat it as append-mostly:
161
- - Adding new files (rare — pre-flight handles this): fine.
162
- - Changing or deleting files: those files belong to older versions too. If you need a different variant, give it a new name (e.g. \`de_v3.csv\`).
163
-
164
- ## Anti-patterns
165
-
166
- - Skipping \`build_report\` and writing \`index.html\` by hand.
167
- - Ending the iteration without calling \`submit_report\`. The runner rolls back the version dir — the user sees nothing.
168
- - Going looking for files that aren't in the brief. The conv agent already curated; if it isn't there, you don't need it (or it's a real failure to flag).
169
- - Grinding past 3 \`build_report\` failures hoping the next attempt works — fail fast with the Jinja error in your final message.
170
- - Inlining large datasets into HTML — reference CSVs in \`assets/\` and fetch them client-side.
171
- - Empty sections with just a caption and no content. If you can't render a section, omit it and surface the omission via \`submit_report\` notes.
172
- - Ignoring \`intent\`. The conv agent set it deliberately.
173
- - Fabricating data that isn't in the brief.
174
- `;
@@ -1,227 +0,0 @@
1
- /**
2
- * Report authoring tools for the conversation agent: `plan_report` + `submit_report`.
3
- *
4
- * WHY TWO TOOLS. The report brief (title/audience/sources plus the section
5
- * union — narrative/metrics/figure/table/chart, each with its own
6
- * encoding/transform/asset sub-fields) is a ~12k-char JSON schema. Every
7
- * registered tool's schema ships on EVERY conversation turn, so parking that
8
- * brief on an always-on tool would tax every turn for a tool used only when a
9
- * report is actually built. We split the single former tool in two and deliver
10
- * the heavy schema just-in-time:
11
- *
12
- * - `plan_report` — a tiny, always-on trigger (no-arg). Its `execute` RETURNS
13
- * the brief schema (`z.toJSONSchema(ReportBriefSchema)`) plus the authoring
14
- * rules as its tool RESULT, so the full contract enters context only on a
15
- * report-building turn — and thereafter rides in the cached history prefix,
16
- * not at full price on every request.
17
- * - `submit_report` — takes the composed brief and does the real work
18
- * (pre-flight staging, previewId/versioning, `runReportIteration`, preview
19
- * publishing). It accepts the brief as `unknown` so the 12k schema stays off
20
- * the always-on surface, then validates it against `ReportBriefSchema` INSIDE
21
- * `execute`, returning `{ ok: false, issues }` as DATA the model can fix (not
22
- * a thrown error). That is the same trade `validate_plan` makes: a runtime
23
- * contract in exchange for keeping the schema out of every request. The small
24
- * iterate-mode + common fields (modifications / previewId / baseVersion /
25
- * sources / format) stay fully typed — they cost little and guide iteration.
26
- *
27
- * On a valid brief, `submit_report`'s behaviour is identical to the former
28
- * `iterate_report`: two modes (Create v1 via `report`; Iterate v2+ via
29
- * `modifications` + `previewId`), pre-flight stages every source into the
30
- * preview's assets/ dir, and it emits a `data-report-preview` chat data part on
31
- * success or `data-report-preview-failed` on pre-flight/builder failure. The
32
- * hosted preview surface is reached through an injected `PreviewPublisher` seam
33
- * (managed default mints a short-lived run-authorization grant; local default
34
- * returns "unavailable"). The 4 custom report tools the builder drives are
35
- * constructed inside `runReportIteration` — see design.md Decision #9.
36
- *
37
- * Naming note: the report-builder SUB-agent has its OWN same-id `submit_report`
38
- * terminal tool (`tools/report/submit-report.ts`). The two never share a tool
39
- * roster — this one is the conversation agent's brief-submission entry point;
40
- * that one is the builder's finalize gate.
41
- */
42
- import type { Pool } from "pg";
43
- import { z } from "zod";
44
- import type { ChatProvider } from "../providers/types.js";
45
- import { type Tool } from "./define-tool.js";
46
- import { type ResolveWorkspaceRoot } from "../workspace/paths.js";
47
- import { type StagedAsset } from "./lib/report-preflight.js";
48
- import type { PreviewPublisher } from "./report/preview-publisher.js";
49
- import type { ChromeConfig } from "../lib/chrome.js";
50
- import type { Logger } from "../lib/logger.js";
51
- import type { UsageRecorder } from "../billing/usage-recorder.js";
52
- /**
53
- * The report brief the conversation agent composes: title/audience + sources +
54
- * the section union. This is the ~12k-char schema that `plan_report` hands back
55
- * just-in-time and that `submit_report` validates its `report` field against
56
- * inside `execute`. Exported for `plan_report`, `submit_report`, and the
57
- * brief-shape tests.
58
- */
59
- export declare const ReportBriefSchema: z.ZodObject<{
60
- title: z.ZodString;
61
- audience: z.ZodString;
62
- styleGuidance: z.ZodOptional<z.ZodString>;
63
- sources: z.ZodDefault<z.ZodArray<z.ZodObject<{
64
- path: z.ZodString;
65
- as: z.ZodOptional<z.ZodString>;
66
- }, z.core.$strip>>>;
67
- sections: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
68
- type: z.ZodLiteral<"narrative">;
69
- title: z.ZodString;
70
- intent: z.ZodString;
71
- content: z.ZodObject<{
72
- prose: z.ZodString;
73
- }, z.core.$strip>;
74
- }, z.core.$strip>, z.ZodObject<{
75
- type: z.ZodLiteral<"metrics">;
76
- title: z.ZodString;
77
- intent: z.ZodString;
78
- content: z.ZodObject<{
79
- stats: z.ZodArray<z.ZodObject<{
80
- label: z.ZodString;
81
- value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
82
- unit: z.ZodOptional<z.ZodString>;
83
- }, z.core.$strip>>;
84
- }, z.core.$strip>;
85
- }, z.core.$strip>, z.ZodObject<{
86
- type: z.ZodLiteral<"figure">;
87
- title: z.ZodString;
88
- intent: z.ZodString;
89
- content: z.ZodObject<{
90
- imageAsset: z.ZodString;
91
- caption: z.ZodOptional<z.ZodString>;
92
- }, z.core.$strip>;
93
- }, z.core.$strip>, z.ZodObject<{
94
- type: z.ZodLiteral<"table">;
95
- title: z.ZodString;
96
- intent: z.ZodString;
97
- content: z.ZodObject<{
98
- dataAsset: z.ZodString;
99
- columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
100
- topN: z.ZodOptional<z.ZodNumber>;
101
- sortBy: z.ZodOptional<z.ZodObject<{
102
- column: z.ZodString;
103
- order: z.ZodEnum<{
104
- desc: "desc";
105
- asc: "asc";
106
- }>;
107
- }, z.core.$strip>>;
108
- transform: z.ZodOptional<z.ZodString>;
109
- caption: z.ZodOptional<z.ZodString>;
110
- }, z.core.$strip>;
111
- }, z.core.$strip>, z.ZodObject<{
112
- type: z.ZodLiteral<"chart">;
113
- title: z.ZodString;
114
- intent: z.ZodString;
115
- content: z.ZodObject<{
116
- dataAsset: z.ZodOptional<z.ZodString>;
117
- data: z.ZodOptional<z.ZodObject<{
118
- columns: z.ZodArray<z.ZodString>;
119
- rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
120
- source: z.ZodString;
121
- }, z.core.$strip>>;
122
- chartType: z.ZodEnum<{
123
- bar: "bar";
124
- line: "line";
125
- scatter: "scatter";
126
- histogram: "histogram";
127
- box: "box";
128
- heatmap: "heatmap";
129
- pie: "pie";
130
- }>;
131
- encoding: z.ZodObject<{
132
- x: z.ZodOptional<z.ZodString>;
133
- y: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
134
- group: z.ZodOptional<z.ZodString>;
135
- value: z.ZodOptional<z.ZodString>;
136
- }, z.core.$strip>;
137
- topN: z.ZodOptional<z.ZodNumber>;
138
- sortBy: z.ZodOptional<z.ZodObject<{
139
- column: z.ZodString;
140
- order: z.ZodEnum<{
141
- desc: "desc";
142
- asc: "asc";
143
- }>;
144
- }, z.core.$strip>>;
145
- transform: z.ZodOptional<z.ZodString>;
146
- caption: z.ZodOptional<z.ZodString>;
147
- }, z.core.$strip>;
148
- }, z.core.$strip>, z.ZodObject<{
149
- type: z.ZodLiteral<"methods">;
150
- title: z.ZodString;
151
- intent: z.ZodString;
152
- content: z.ZodObject<{
153
- prose: z.ZodString;
154
- }, z.core.$strip>;
155
- }, z.core.$strip>], "type">>;
156
- }, z.core.$strip>;
157
- /**
158
- * `submit_report`'s always-on input surface. The heavy brief rides in `report`
159
- * as `unknown` — typed that way ON PURPOSE so the ~12k `ReportBriefSchema` does
160
- * NOT ship on every conversation turn; `execute` validates it against
161
- * `ReportBriefSchema` and returns issues as data. The iterate-mode + common
162
- * fields stay fully typed (they are small and guide iteration). Exported for
163
- * the envelope-validation tests.
164
- */
165
- export declare const submitReportInputSchema: z.ZodObject<{
166
- previewId: z.ZodOptional<z.ZodString>;
167
- baseVersion: z.ZodOptional<z.ZodNumber>;
168
- format: z.ZodDefault<z.ZodEnum<{
169
- html: "html";
170
- }>>;
171
- report: z.ZodOptional<z.ZodUnknown>;
172
- modifications: z.ZodOptional<z.ZodString>;
173
- sources: z.ZodOptional<z.ZodArray<z.ZodObject<{
174
- path: z.ZodString;
175
- as: z.ZodOptional<z.ZodString>;
176
- }, z.core.$strip>>>;
177
- }, z.core.$strip>;
178
- /**
179
- * `plan_report` — the tiny, always-on trigger (no args). Its result delivers
180
- * the brief schema + authoring rules just-in-time, so the ~12k contract enters
181
- * context only on a report-building turn (and thereafter rides in the cached
182
- * history prefix). Compose the brief from what it returns, then call
183
- * `submit_report`. Pure logic, no deps — hence a module-scope leaf tool.
184
- */
185
- export declare const planReportTool: Tool;
186
- export interface SubmitReportDeps {
187
- /** Operational logging seam; omitted falls back to no-op. */
188
- readonly logger?: Logger;
189
- readonly provider: ChatProvider;
190
- readonly pool: Pool;
191
- /** Embedder-supplied workspace-root resolution seam (see workspace/paths.ts). */
192
- readonly resolveWorkspaceRoot: ResolveWorkspaceRoot;
193
- /** Model id — provenance / metric label; provider owns the wire model. */
194
- readonly model: string;
195
- /** Root templates dir; report-runner joins `report-html`. */
196
- readonly templatesDir: string;
197
- /** Skills root; report-runner gives the report-builder `report-html` skill tools. */
198
- readonly skillsDir: string;
199
- readonly chrome: ChromeConfig;
200
- /**
201
- * Builds the preview-publishing seam for this iteration. A managed
202
- * embedder's realization mints a short-lived access grant + client eagerly
203
- * at iteration start; the local default returns an "unavailable" publisher.
204
- * Rejection (e.g. grant-mint failure) surfaces as a failed-preview tool result.
205
- */
206
- readonly createPreviewPublisher: (args: {
207
- session: import("../auth/types.js").AgentSession;
208
- resourceId: string;
209
- runId: string;
210
- previewId: string;
211
- ttlSeconds: number;
212
- }) => Promise<PreviewPublisher>;
213
- /** LLM usage-accounting seam for the report-builder loop; omitted falls back to the no-op recorder. */
214
- readonly usageRecorder?: UsageRecorder;
215
- }
216
- /**
217
- * `submit_report` — takes the composed brief and drives the report iteration.
218
- * On a valid brief its behaviour is byte-for-byte the former `iterate_report`:
219
- * pre-flight staging, previewId/versioning, `runReportIteration`, preview
220
- * publishing. The brief rides as `unknown` on the wire (keeping its ~12k schema
221
- * off the always-on surface) and is validated against `ReportBriefSchema` here.
222
- */
223
- export declare function createReportSubmitTool(deps: SubmitReportDeps): Tool;
224
- /** Exported for unit tests — pipe-escape correctness. */
225
- export declare function stagedAssetsBlock(staged: StagedAsset[], opts?: {
226
- newOnly?: boolean;
227
- }): string;