@kontourai/survey 6.1.0 → 8.0.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 (45) hide show
  1. package/dist/src/calibration.d.ts +15 -0
  2. package/dist/src/calibration.js +11 -0
  3. package/dist/src/canonical-reviewed-trust-input.d.ts +10 -0
  4. package/dist/src/canonical-reviewed-trust-input.js +45 -1
  5. package/dist/src/console/review-console-server.js +22 -4
  6. package/dist/src/decision-carry-forward.d.ts +157 -0
  7. package/dist/src/decision-carry-forward.js +295 -0
  8. package/dist/src/extraction-envelope.d.ts +4 -3
  9. package/dist/src/extraction-envelope.js +3 -3
  10. package/dist/src/field-states.d.ts +100 -0
  11. package/dist/src/field-states.js +169 -0
  12. package/dist/src/index.d.ts +6 -4
  13. package/dist/src/index.js +3 -1
  14. package/dist/src/mcp/review-mcp.js +173 -45
  15. package/dist/src/review-resource.d.ts +36 -0
  16. package/dist/src/review-session-file.d.ts +7 -0
  17. package/dist/src/review-workbench/audit-rows.d.ts +1 -1
  18. package/dist/src/review-workbench/audit-rows.js +1 -0
  19. package/dist/src/review-workbench/audit-sample.d.ts +32 -0
  20. package/dist/src/review-workbench/audit-sample.js +53 -0
  21. package/dist/src/review-workbench/extraction-inspector.d.ts +1 -1
  22. package/dist/src/review-workbench/extraction-inspector.js +1 -1
  23. package/dist/src/review-workbench/field-state-view.d.ts +15 -0
  24. package/dist/src/review-workbench/field-state-view.js +84 -0
  25. package/dist/src/review-workbench/queue-binding.d.ts +45 -2
  26. package/dist/src/review-workbench/queue-binding.js +45 -0
  27. package/dist/src/review-workbench/review-presentation.d.ts +23 -0
  28. package/dist/src/review-workbench/review-presentation.js +51 -10
  29. package/dist/src/review-workbench/review-queue-session.d.ts +93 -5
  30. package/dist/src/review-workbench/review-queue-session.js +147 -11
  31. package/dist/src/review-workbench/review-session-replay.d.ts +11 -1
  32. package/dist/src/review-workbench/review-session-replay.js +49 -1
  33. package/dist/src/review-workbench/review-workbench-css.generated.js +126 -0
  34. package/dist/src/review-workbench/review-workbench-element.d.ts +10 -0
  35. package/dist/src/review-workbench/review-workbench-element.js +21 -3
  36. package/dist/src/review-workbench/review-workbench.css +126 -0
  37. package/dist/src/review-workbench/review-workbench.d.ts +40 -8
  38. package/dist/src/review-workbench/review-workbench.js +192 -71
  39. package/dist/src/review-workbench/review-workbench.standalone.css +126 -0
  40. package/dist/src/review-workbench/server-review-session.d.ts +18 -0
  41. package/dist/src/review-workbench/server-review-session.js +20 -2
  42. package/dist/src/surface-reviewed-extraction.d.ts +23 -0
  43. package/dist/src/surface-reviewed-extraction.js +64 -1
  44. package/dist/src/to-surface.js +32 -3
  45. package/package.json +1 -1
@@ -614,6 +614,30 @@
614
614
  .survey-workbench-embed .chip.rejected{ color: var(--k-negative); background: var(--k-negative-wash); }
615
615
  .survey-workbench-embed .chip.could-not-confirm{ color: var(--k-caution); background: var(--k-caution-wash); }
616
616
 
617
+ /* Field-state panel: one row per field, content and lifecycle derived from
618
+ the records, never stored labels. A field that was not read is listed. */
619
+ .survey-workbench-embed .field-states{ padding: var(--k-space-3, 12px) 1rem; border-bottom: 1px solid var(--k-line); background: var(--k-panel); }
620
+ .survey-workbench-embed .field-states h2{ margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--k-text); }
621
+ .survey-workbench-embed .field-states ul{ list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
622
+ .survey-workbench-embed .field-states-lead{ margin: 0 0 8px; font-size: 13px; line-height: 1.45; color: var(--k-caution); }
623
+ .survey-workbench-embed .field-state-row{ display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 6px 0; border-top: 1px solid var(--k-line); }
624
+ .survey-workbench-embed .field-state-row:first-child{ border-top: 0; }
625
+ .survey-workbench-embed .field-state-name{ font-family: var(--k-font-mono, ui-monospace, monospace); font-size: 12px; color: var(--k-text); overflow-wrap: anywhere; }
626
+ .survey-workbench-embed .field-state-chips{ display: inline-flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
627
+ .survey-workbench-embed .field-state-note{ grid-column: 1 / -1; font-size: 12px; color: var(--k-muted); }
628
+ .survey-workbench-embed .field-state-note.signal{ color: var(--k-caution); }
629
+ .survey-workbench-embed .chip.state-content.value{ color: var(--k-positive); background: var(--k-positive-wash); }
630
+ .survey-workbench-embed .chip.state-content.conflicting,
631
+ .survey-workbench-embed .chip.state-content.excluded,
632
+ .survey-workbench-embed .chip.state-content.not_covered{ color: var(--k-caution); background: var(--k-caution-wash); }
633
+ .survey-workbench-embed .chip.state-content.unsupported{ color: var(--k-negative); background: var(--k-negative-wash); }
634
+ .survey-workbench-embed .chip.state-content.none,
635
+ .survey-workbench-embed .chip.state-lifecycle.superseded{ color: var(--k-muted); background: var(--k-sunken); }
636
+ .survey-workbench-embed .chip.state-lifecycle.pending{ color: var(--k-brand); background: var(--k-brand-wash); }
637
+ .survey-workbench-embed .chip.state-lifecycle.accepted{ color: var(--k-positive); background: var(--k-positive-wash); }
638
+ .survey-workbench-embed .chip.state-lifecycle.rejected{ color: var(--k-negative); background: var(--k-negative-wash); }
639
+ .survey-workbench-embed .chip.state-lifecycle.could_not_confirm{ color: var(--k-caution); background: var(--k-caution-wash); }
640
+
617
641
  .survey-workbench-embed .frow1 .push{
618
642
  margin-left: auto;
619
643
  }
@@ -832,6 +856,106 @@
832
856
  font-size: 12px;
833
857
  }
834
858
 
859
+ /* A queue that came from an extraction import but was not checked against
860
+ it (unverified), or that does not match it (diverges, shown instead of the
861
+ queue). */
862
+ .survey-workbench-embed .queue-attestation{
863
+ display: flex;
864
+ align-items: flex-start;
865
+ gap: var(--k-space-2);
866
+ margin: 0 0 var(--k-space-3);
867
+ padding: var(--k-space-2) var(--k-space-3);
868
+ border-radius: 9px;
869
+ font-size: 13px;
870
+ line-height: 1.45;
871
+ color: var(--k-caution);
872
+ background: var(--k-caution-wash);
873
+ }
874
+
875
+ .survey-workbench-embed .queue-attestation svg{
876
+ flex: none;
877
+ margin-top: 2px;
878
+ }
879
+
880
+ .survey-workbench-embed .queue-attestation.diverges{
881
+ color: var(--k-negative);
882
+ background: var(--k-negative-wash);
883
+ }
884
+
885
+ /* A score-blind session: an informational note, not a warning. */
886
+ .survey-workbench-embed .queue-attestation.score-blind{
887
+ color: var(--k-active);
888
+ background: var(--k-active-soft);
889
+ }
890
+
891
+ /* Conflicting proposed values: each value is listed with its own choice
892
+ control until the field is decided, then marked chosen or not chosen. */
893
+ .survey-workbench-embed .conflict-values ul{
894
+ list-style: none;
895
+ margin: var(--k-space-2) 0 0;
896
+ padding: 0;
897
+ display: grid;
898
+ gap: var(--k-space-2);
899
+ }
900
+
901
+ .survey-workbench-embed .conflict-values li{
902
+ display: flex;
903
+ align-items: center;
904
+ justify-content: space-between;
905
+ gap: var(--k-space-3);
906
+ flex-wrap: wrap;
907
+ padding: var(--k-space-2) var(--k-space-3);
908
+ border: 1px solid var(--k-line);
909
+ border-radius: 9px;
910
+ }
911
+
912
+ .survey-workbench-embed .conflict-values li[data-chosen="true"]{
913
+ border-color: var(--k-positive);
914
+ background: var(--k-positive-wash);
915
+ }
916
+
917
+ .survey-workbench-embed .conflict-values .conflict-text{
918
+ display: inline-flex;
919
+ align-items: baseline;
920
+ gap: var(--k-space-2);
921
+ flex-wrap: wrap;
922
+ min-width: 0;
923
+ }
924
+
925
+ .survey-workbench-embed .conflict-values .vtext{
926
+ font-weight: 600;
927
+ overflow-wrap: anywhere;
928
+ }
929
+
930
+ .survey-workbench-embed .conflict-values q{
931
+ color: var(--k-muted);
932
+ font-size: 12.5px;
933
+ overflow-wrap: anywhere;
934
+ }
935
+
936
+ .survey-workbench-embed .conflict-values .btn.choose{
937
+ min-height: 36px;
938
+ padding: 0 14px;
939
+ font-size: 13px;
940
+ }
941
+
942
+ .survey-workbench-embed .choice-tag{
943
+ font-size: 12px;
944
+ font-weight: 600;
945
+ padding: 2px 8px;
946
+ border-radius: 999px;
947
+ }
948
+
949
+ .survey-workbench-embed .choice-tag.chosen{
950
+ color: var(--k-positive);
951
+ background: var(--k-positive-wash);
952
+ }
953
+
954
+ .survey-workbench-embed .choice-tag.not-chosen{
955
+ color: var(--k-muted);
956
+ background: var(--k-sunken);
957
+ }
958
+
835
959
  .survey-workbench-embed .excerpt-verification,
836
960
  .survey-workbench-embed .support-verification{
837
961
  margin: 0;
@@ -1324,6 +1448,8 @@
1324
1448
  /* The diff-collapse must also hold in host contexts without a query container
1325
1449
  (e.g. an embed that doesn't establish `container-type`): fall back to viewport. */
1326
1450
  @media (max-width: 620px) {
1451
+ .survey-workbench-embed .field-state-row{ grid-template-columns: minmax(0, 1fr); }
1452
+ .survey-workbench-embed .field-state-chips{ justify-content: flex-start; }
1327
1453
  .survey-workbench-embed .diff{
1328
1454
  grid-template-columns: 1fr;
1329
1455
  }
@@ -2,16 +2,28 @@ import { type ReviewQueueSessionState, type ReviewWorkbenchDecision, type Review
2
2
  import { type ReviewSessionReplayIssue, type ReviewSessionReplayWarning } from "./review-session-replay.js";
3
3
  import { type ReviewPresentationAdapter } from "./review-presentation.js";
4
4
  import { type ReviewCandidate, type ReviewDecision, type ReviewItem, type ReviewSession, type ReviewSessionEvent, type ReviewValueDescriptor } from "../review-resource.js";
5
+ import type { ExtractionEnvelopeImport, ExtractionEnvelopeImportResult } from "../extraction-envelope.js";
6
+ import type { FieldState } from "../field-states.js";
5
7
  export { reviewAuditRowKeys, type ReviewAuditRowKey } from "./audit-rows.js";
6
- export { assertReviewQueueAgainstExtractionImport, assertReviewQueueBinding, bindReviewQueue, hashReviewQueueSnapshot, UnattestedExtractionQueueError, UnattestedReviewQueueError, validateReviewQueueAgainstExtractionImport, validateReviewQueueBinding, type BindReviewQueueOptions, type ReviewQueueBinding, type ReviewQueueBindingIssue, type ReviewQueueBindingIssueCode, type ReviewQueueExtractionIssue, type ReviewQueueExtractionIssueCode, type ValidateReviewQueueBindingOptions, } from "./queue-binding.js";
8
+ export { assertReviewQueueAgainstExtractionImport, assertReviewQueueBinding, attestReviewQueueExtraction, bindReviewQueue, reviewItemCarriesExtractionBinding, unverifiedExtractionQueueSentence, hashReviewQueueSnapshot, UnattestedExtractionQueueError, UnattestedReviewQueueError, validateReviewQueueAgainstExtractionImport, validateReviewQueueBinding, type BindReviewQueueOptions, type ReviewQueueBinding, type ReviewQueueBindingIssue, type ReviewQueueBindingIssueCode, type ReviewQueueExtractionAttestation, type ReviewQueueExtractionIssue, type ReviewQueueExtractionIssueCode, type ValidateReviewQueueBindingOptions, } from "./queue-binding.js";
7
9
  export { buildExtractionInspectorModel, exportExtractionInspector, filterExtractionInspectorCandidates, mountExtractionInspector, type ExtractionAlignmentState, type ArtifactUnavailableCode, type BuiltExtractionInspectorCandidate, type BuiltExtractionInspectorModel, type ExtractionInspectorCandidate, type ExtractionInspectorEntry, type ExtractionInspectorExportOptions, type ExtractionInspectorFilters, type ExtractionInspectorInput, type ExtractionInspectorMountOptions, type ExtractionInspectorModel, type ExtractionInspectorSource, type ResolvedExtractionArtifact, } from "./extraction-inspector.js";
8
- export { buildReviewSessionEvents, buildReviewSessionEvent, buildReviewSessionResource, candidateForDecision, decisionCandidateId, decisionSelectsNoCandidate, keepActionDecision, currentReviewItem, currentReviewWorkbenchState, defaultReviewSessionName, deriveQueueRowStatus, initialReviewQueueSessionState, initialReviewWorkbenchState, nextUnresolvedItemName, replayReviewSessionEvents, reviewSessionSummary, reviewWorkbenchSessionStorageKey, selectedCandidateRole, workbenchDecisionDefinitions, type ReviewQueueRowStatus, type ReviewQueueSessionState, type ReviewSessionSummary, type ReviewWorkbenchDecision, type ReviewWorkbenchState, } from "./review-queue-session.js";
9
- export { buildReviewCandidatePresentation, buildReviewItemPresentation, buildReviewResultPresentation, humanizeIdentifier, type ReviewCandidatePresentation, type ReviewCandidatePresentationContext, type ReviewItemPresentation, type ReviewItemPresentationContext, type ReviewPresentationAdapter, type ReviewPresentationLink, type ReviewResultPresentation, type ReviewTracePresentationContext, type ReviewTraceRef, type ReviewValuePresentationContext, } from "./review-presentation.js";
10
+ export { renderFieldStatesHtml } from "./field-state-view.js";
11
+ export { drawRandomAuditSample, openRandomAuditSession, type RandomAuditSampleOptions, } from "./audit-sample.js";
12
+ export { buildReviewSessionEvents, buildReviewSessionEvent, buildReviewSessionResource, candidateForDecision, conflictSelectionIssue, unchosenProposedCandidates, decisionCandidateId, decisionSelectsNoCandidate, keepActionDecision, currentReviewItem, currentReviewWorkbenchState, defaultReviewSessionName, deriveQueueRowStatus, initialReviewQueueSessionState, initialReviewWorkbenchState, isScoreBlind, assertReviewSessionConditions, nextUnresolvedItemName, replayReviewSessionEvents, reviewSessionSummary, reviewWorkbenchSessionStorageKey, selectedCandidateRole, workbenchDecisionDefinitions, type ReviewSessionPresentation, type ReviewSessionSampling, type ReviewQueueRowStatus, type ReviewQueueSessionState, type ReviewSessionSummary, type ReviewWorkbenchDecision, type ReviewWorkbenchState, } from "./review-queue-session.js";
13
+ export { buildReviewCandidatePresentation, buildReviewItemPresentation, buildReviewResultPresentation, humanizeIdentifier, type ExcludedProposalPresentation, type ExcludedProposalsUnreadable, type ReviewCandidatePresentation, type ReviewCandidatePresentationContext, type ReviewItemPresentation, type ReviewItemPresentationContext, type ReviewPresentationAdapter, type ReviewPresentationLink, type ReviewResultPresentation, type ReviewTracePresentationContext, type ReviewTraceRef, type ReviewValuePresentationContext, } from "./review-presentation.js";
10
14
  export { buildSurfaceProjectionPreview, type PreviewAuthorityTrace, type PreviewCandidateHistory, type PreviewClaim, type PreviewIntegrityPosture, type PreviewReviewEvent, type PreviewSourceAuthority, type PreviewSourceEvidence, type SurfaceProjectionPreview, } from "./review-surface-preview.js";
11
15
  export { reviewSessionReplayWarningsForSnapshot, validateReviewSessionEventsForSnapshot, type ReviewSessionReplayIssue, type ReviewSessionReplayIssueCode, type ReviewSessionReplayWarning, } from "./review-session-replay.js";
12
16
  export { checkEditedValueForItem, editedValueFromEditorText, type EditedValueCheck, } from "./edited-value.js";
13
17
  export { assertReviewDecisionModeAllows, DecisionModeViolationError, validateReviewDecisionMode, type ReviewDecisionModeIssue, type ReviewDecisionModeIssueCode, type ReviewDecisionModeResult, } from "./producer-decision-mode.js";
14
- export declare function buildReviewDecision(state: ReviewWorkbenchState): ReviewDecision | undefined;
18
+ /**
19
+ * Options for building review decisions. The decision prompt is rendered from
20
+ * the item when the decision is built, so pass the same presentation adapter
21
+ * the card used, or the recorded prompt renders values its own way.
22
+ */
23
+ export interface ReviewDecisionBuildOptions {
24
+ readonly presentationAdapter?: ReviewPresentationAdapter;
25
+ }
26
+ export declare function buildReviewDecision(state: ReviewWorkbenchState, options?: ReviewDecisionBuildOptions): ReviewDecision | undefined;
15
27
  export interface ReviewWorkbenchSessionExport {
16
28
  readonly session: ReviewSession;
17
29
  readonly events: readonly ReviewSessionEvent[];
@@ -31,6 +43,8 @@ export interface DeriveReviewSessionApplyResultForSnapshotOptions {
31
43
  readonly snapshot: ReviewQueueSessionState;
32
44
  readonly events: readonly ReviewSessionEvent[];
33
45
  readonly requiredResolvedItems?: ReviewSessionApplyResolutionRequirement;
46
+ /** The adapter the reviewer's card used; the recorded decision prompts render values with it. */
47
+ readonly presentationAdapter?: ReviewPresentationAdapter;
34
48
  }
35
49
  export type DeriveReviewSessionApplyResultForSnapshotResult = {
36
50
  readonly ok: true;
@@ -89,8 +103,22 @@ export interface PersistentReviewSessionEventStoreOptions {
89
103
  export interface MountReviewWorkbenchOptions {
90
104
  readonly eventStore?: ReviewSessionEventStore;
91
105
  readonly presentationAdapter?: ReviewPresentationAdapter;
106
+ /**
107
+ * The extraction import record the queue was built from, as stored beside
108
+ * it. When supplied, the workbench checks the queue against it and refuses to
109
+ * present a queue that diverges. When absent and the queue's items came from
110
+ * an extraction import, the workbench shows an "Unverified queue" notice.
111
+ */
112
+ readonly extractionImport?: ExtractionEnvelopeImport | ExtractionEnvelopeImportResult;
92
113
  /** Maximum review cards mounted at once. Defaults to 50 and is capped at 250. */
93
114
  readonly pageSize?: number;
115
+ /**
116
+ * The queue's derived field states (`deriveFieldStates`). When supplied, a
117
+ * field-state panel lists every field with its content state, lifecycle and
118
+ * signals, including fields that have no review card because they were not
119
+ * read. Lifecycles of queued fields follow the live session.
120
+ */
121
+ readonly fieldStates?: readonly FieldState[];
94
122
  }
95
123
  export type ReviewQueueDisposition = "all" | "unresolved" | "accepted" | "kept" | "rejected" | "could-not-confirm";
96
124
  export interface ReviewQueueView {
@@ -189,15 +217,15 @@ export interface MapReviewWorkbenchResultsToApplyActionsOptions<TAction> {
189
217
  readonly skip?: (context: ReviewApplyActionContext) => boolean;
190
218
  readonly map: (context: ReviewApplyActionContext) => TAction | readonly TAction[] | undefined;
191
219
  }
192
- export declare function buildReviewDecisionsFromSession(session: ReviewQueueSessionState): ReviewDecision[];
220
+ export declare function buildReviewDecisionsFromSession(session: ReviewQueueSessionState, options?: ReviewDecisionBuildOptions): ReviewDecision[];
193
221
  export declare function requireReviewResultForItem(item: ReviewItem, results: readonly ReviewWorkbenchResult[]): ReviewWorkbenchResult;
194
222
  export declare function assertReviewResultMatches(result: ReviewWorkbenchResult, expectation: ReviewApplyResultExpectation): void;
195
223
  export declare function mapReviewWorkbenchResultsToApplyActions<TAction>(options: MapReviewWorkbenchResultsToApplyActionsOptions<TAction>): ReviewApplyActionMapping<TAction>[];
196
224
  export declare const mapReviewApplyActions: typeof mapReviewWorkbenchResultsToApplyActions;
197
- export declare function buildReviewWorkbenchResultsFromSession(session: ReviewQueueSessionState): ReviewWorkbenchResult[];
198
- export declare function buildReviewWorkbenchSessionExport(session: ReviewQueueSessionState, events?: readonly ReviewSessionEvent[]): ReviewWorkbenchSessionExport;
225
+ export declare function buildReviewWorkbenchResultsFromSession(session: ReviewQueueSessionState, options?: ReviewDecisionBuildOptions): ReviewWorkbenchResult[];
226
+ export declare function buildReviewWorkbenchSessionExport(session: ReviewQueueSessionState, events?: readonly ReviewSessionEvent[], options?: ReviewDecisionBuildOptions): ReviewWorkbenchSessionExport;
199
227
  export declare function replayReviewSessionEventsForSnapshot(snapshot: ReviewQueueSessionState, events: readonly ReviewSessionEvent[]): ReviewQueueSessionState;
200
- export declare function buildReviewWorkbenchSessionExportForSnapshot(snapshot: ReviewQueueSessionState, events: readonly ReviewSessionEvent[]): ReviewWorkbenchSessionExport;
228
+ export declare function buildReviewWorkbenchSessionExportForSnapshot(snapshot: ReviewQueueSessionState, events: readonly ReviewSessionEvent[], options?: ReviewDecisionBuildOptions): ReviewWorkbenchSessionExport;
201
229
  export declare function deriveReviewSessionApplyResultForSnapshot(options: DeriveReviewSessionApplyResultForSnapshotOptions): DeriveReviewSessionApplyResultForSnapshotResult;
202
230
  export declare function createInMemoryReviewSessionEventStore(initialEvents?: readonly ReviewSessionEvent[]): ReviewSessionEventStore & {
203
231
  events(): readonly ReviewSessionEvent[];
@@ -210,6 +238,10 @@ export declare function createPersistentReviewSessionEventStore(options: Persist
210
238
  export declare function renderReviewWorkbenchHtml(state: ReviewWorkbenchState | ReviewQueueSessionState, _events?: readonly ReviewSessionEvent[], options?: {
211
239
  readonly presentationAdapter?: ReviewPresentationAdapter;
212
240
  readonly queueView?: Partial<ReviewQueueView>;
241
+ /** See {@link MountReviewWorkbenchOptions.extractionImport}. */
242
+ readonly extractionImport?: ExtractionEnvelopeImport | ExtractionEnvelopeImportResult;
243
+ /** See {@link MountReviewWorkbenchOptions.fieldStates}. */
244
+ readonly fieldStates?: readonly FieldState[];
213
245
  }): string;
214
246
  export declare function buildReviewQueueWindow(session: ReviewQueueSessionState, view?: Partial<ReviewQueueView>): ReviewQueueWindow;
215
247
  /**