@kontourai/survey 0.4.23 → 0.5.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 (39) hide show
  1. package/README.md +86 -872
  2. package/dist/example-data/corrected-document-candidates.d.ts +2 -0
  3. package/dist/{fixtures → example-data}/corrected-document-candidates.js +3 -3
  4. package/dist/{fixtures → example-data}/downstream-public-directory-proposal.d.ts +1 -1
  5. package/dist/{fixtures → example-data}/downstream-public-directory-proposal.js +1 -1
  6. package/dist/{fixtures → example-data}/public-directory-review-resource.d.ts +2 -2
  7. package/dist/{fixtures → example-data}/public-directory-review-resource.js +2 -2
  8. package/dist/example-data/public-field-review.d.ts +2 -0
  9. package/dist/{fixtures → example-data}/public-field-review.js +2 -2
  10. package/dist/{fixtures → example-data}/regulated-document-review-resource.d.ts +1 -1
  11. package/dist/{fixtures → example-data}/regulated-document-review-resource.js +3 -3
  12. package/dist/examples/public-field-observation.js +4 -4
  13. package/dist/examples/review-workbench/downstream-public-directory-adapter.d.ts +1 -1
  14. package/dist/examples/review-workbench/facility-credential-consumer.d.ts +2 -2
  15. package/dist/examples/review-workbench/facility-credential-consumer.js +8 -8
  16. package/dist/examples/review-workbench/server-apply-consumer.d.ts +1 -1
  17. package/dist/examples/review-workbench/server-apply-consumer.js +3 -3
  18. package/dist/src/agent-utterance.d.ts +166 -0
  19. package/dist/src/agent-utterance.js +373 -0
  20. package/dist/src/anthropic.d.ts +104 -0
  21. package/dist/src/anthropic.js +383 -0
  22. package/dist/src/index.d.ts +10 -2
  23. package/dist/src/index.js +5 -1
  24. package/dist/src/inquiry-mapping.d.ts +256 -0
  25. package/dist/src/inquiry-mapping.js +385 -0
  26. package/dist/src/review-workbench/review-queue-session.js +3 -3
  27. package/dist/src/review-workbench/review-surface-preview.js +1 -1
  28. package/dist/src/review-workbench/review-workbench-data.d.ts +4 -4
  29. package/dist/src/review-workbench/review-workbench-data.js +14 -14
  30. package/dist/src/schema-mapping.d.ts +196 -0
  31. package/dist/src/schema-mapping.js +486 -0
  32. package/dist/src/to-flow-artifact.d.ts +41 -0
  33. package/dist/src/to-flow-artifact.js +31 -0
  34. package/dist/src/to-surface.d.ts +3 -3
  35. package/dist/src/to-surface.js +1 -1
  36. package/dist/src/types.d.ts +2 -2
  37. package/package.json +25 -9
  38. package/dist/fixtures/corrected-document-candidates.d.ts +0 -2
  39. package/dist/fixtures/public-field-review.d.ts +0 -2
@@ -0,0 +1,41 @@
1
+ import type { ReviewOutcome, ReviewStatus } from "./types.js";
2
+ /**
3
+ * The neutral trust-artifact shape Kontour Flow consumes through
4
+ * `flow attach-evidence --trust-artifact`. Flow evaluates only these fields
5
+ * plus its own definition and project config; Survey stays the producer-side
6
+ * authority for what the review actually decided.
7
+ */
8
+ export interface FlowTrustArtifact {
9
+ schema_version: "0.1";
10
+ artifact_type: "trust-report";
11
+ subject: string;
12
+ producer: string;
13
+ status: string;
14
+ issued_at: string;
15
+ authority_traces: string[];
16
+ claims: Array<{
17
+ type: string;
18
+ subject: string;
19
+ status: string;
20
+ }>;
21
+ }
22
+ export interface FlowTrustArtifactOptions {
23
+ /** Flow claim type the gate expects, e.g. "adversarial.review". */
24
+ claimType: string;
25
+ /** Flow claim subject the gate expects, e.g. "adversarial-pass.review". */
26
+ subject: string;
27
+ /** Producer identity recorded on the artifact, e.g. "survey/adversarial-workbench". */
28
+ producer: string;
29
+ /** Defaults to the review outcome's reviewedAt, then the current time. */
30
+ issuedAt?: string;
31
+ /** Defaults to ["survey:review-outcome/<outcome id>"]. */
32
+ authorityTraces?: string[];
33
+ /** Override the ReviewStatus -> artifact status projection per entry. */
34
+ statusMap?: Partial<Record<ReviewStatus, string>>;
35
+ }
36
+ /**
37
+ * Projects a Survey ReviewOutcome into the neutral trust artifact Flow
38
+ * consumes, so a per-round review (including an adversarial pass) can satisfy
39
+ * or fail a Flow gate without Flow learning Survey vocabulary.
40
+ */
41
+ export declare function flowTrustArtifactFromReviewOutcome(outcome: ReviewOutcome, options: FlowTrustArtifactOptions): FlowTrustArtifact;
@@ -0,0 +1,31 @@
1
+ const defaultStatusMap = {
2
+ verified: "trusted",
3
+ assumed: "assumed",
4
+ proposed: "proposed",
5
+ rejected: "rejected",
6
+ };
7
+ /**
8
+ * Projects a Survey ReviewOutcome into the neutral trust artifact Flow
9
+ * consumes, so a per-round review (including an adversarial pass) can satisfy
10
+ * or fail a Flow gate without Flow learning Survey vocabulary.
11
+ */
12
+ export function flowTrustArtifactFromReviewOutcome(outcome, options) {
13
+ if (!outcome.id) {
14
+ throw new Error("flowTrustArtifactFromReviewOutcome requires a review outcome id");
15
+ }
16
+ const statusMap = { ...defaultStatusMap, ...options.statusMap };
17
+ const status = statusMap[outcome.status];
18
+ if (!status) {
19
+ throw new Error(`flowTrustArtifactFromReviewOutcome: unmapped review status '${outcome.status}'`);
20
+ }
21
+ return {
22
+ schema_version: "0.1",
23
+ artifact_type: "trust-report",
24
+ subject: options.subject,
25
+ producer: options.producer,
26
+ status,
27
+ issued_at: options.issuedAt ?? outcome.reviewedAt ?? new Date().toISOString(),
28
+ authority_traces: options.authorityTraces ?? [`survey:review-outcome/${outcome.id}`],
29
+ claims: [{ type: options.claimType, subject: options.subject, status }],
30
+ };
31
+ }
@@ -1,6 +1,6 @@
1
- import type { TrustInput } from "@kontourai/surface";
1
+ import type { TrustBundle } from "@kontourai/surface";
2
2
  import type { SurveyInput } from "./types.js";
3
- export interface BuildSurveyTrustInputOptions {
3
+ export interface BuildSurveyTrustBundleOptions {
4
4
  reviewProofs?: boolean;
5
5
  }
6
- export declare function buildSurveyTrustInput(input: SurveyInput, options?: BuildSurveyTrustInputOptions): TrustInput;
6
+ export declare function buildSurveyTrustBundle(input: SurveyInput, options?: BuildSurveyTrustBundleOptions): TrustBundle;
@@ -1,5 +1,5 @@
1
1
  import { buildReviewProofAnchor } from "./review-proof.js";
2
- export function buildSurveyTrustInput(input, options = {}) {
2
+ export function buildSurveyTrustBundle(input, options = {}) {
3
3
  const rawSources = indexById(input.rawSources, "raw source");
4
4
  const extractions = indexById(input.extractions, "extraction");
5
5
  const candidateSets = indexById(input.candidateSets, "candidate set");
@@ -1,6 +1,6 @@
1
1
  import type { ConfidenceBasis, DerivationEdge, EvidenceMethod, EvidenceType, ImpactLevel, TrustStatus } from "@kontourai/surface";
2
- export type RawSourceKind = "uploaded-document" | "web-page" | "api-record" | "manual-entry" | "policy-standard";
3
- export type LocatorScheme = "pdf" | "text" | "html" | "structured-field";
2
+ export type RawSourceKind = "uploaded-document" | "web-page" | "api-record" | "manual-entry" | "policy-standard" | "inquiry-question" | "agent-utterance" | "system-schema";
3
+ export type LocatorScheme = "pdf" | "text" | "html" | "structured-field" | "text-span";
4
4
  export interface RawSource {
5
5
  id: string;
6
6
  kind: RawSourceKind;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontourai/survey",
3
- "version": "0.4.23",
3
+ "version": "0.5.0",
4
4
  "description": "Producer-side source, extraction, candidate, and review contracts for projecting verified claims into Surface.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -9,7 +9,7 @@
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/kontourai/survey.git"
11
11
  },
12
- "homepage": "https://kontourai.io/survey",
12
+ "homepage": "https://kontourai.github.io/survey/",
13
13
  "bugs": {
14
14
  "url": "https://github.com/kontourai/survey/issues"
15
15
  },
@@ -18,6 +18,10 @@
18
18
  },
19
19
  "exports": {
20
20
  ".": "./dist/src/index.js",
21
+ "./anthropic": {
22
+ "types": "./dist/src/anthropic.d.ts",
23
+ "default": "./dist/src/anthropic.js"
24
+ },
21
25
  "./review-workbench": {
22
26
  "types": "./dist/src/review-workbench/review-workbench.d.ts",
23
27
  "default": "./dist/src/review-workbench/review-workbench.js"
@@ -28,14 +32,14 @@
28
32
  },
29
33
  "./review-workbench.css": "./dist/src/review-workbench/review-workbench.css",
30
34
  "./review-workbench/standalone.css": "./dist/src/review-workbench/review-workbench.standalone.css",
31
- "./fixtures/public-field-review": "./dist/fixtures/public-field-review.js",
32
- "./fixtures/corrected-document-candidates": "./dist/fixtures/corrected-document-candidates.js",
33
- "./fixtures/public-directory-review-resource": "./dist/fixtures/public-directory-review-resource.js",
34
- "./fixtures/regulated-document-review-resource": "./dist/fixtures/regulated-document-review-resource.js"
35
+ "./example-data/public-field-review": "./dist/example-data/public-field-review.js",
36
+ "./example-data/corrected-document-candidates": "./dist/example-data/corrected-document-candidates.js",
37
+ "./example-data/public-directory-review-resource": "./dist/example-data/public-directory-review-resource.js",
38
+ "./example-data/regulated-document-review-resource": "./dist/example-data/regulated-document-review-resource.js"
35
39
  },
36
40
  "files": [
37
41
  "dist/examples/",
38
- "dist/fixtures/",
42
+ "dist/example-data/",
39
43
  "dist/src/",
40
44
  "README.md"
41
45
  ],
@@ -52,15 +56,27 @@
52
56
  "check:review-workbench": "npm run check:review-workbench:static",
53
57
  "check:review-workbench:static": "npm run build && node scripts/check-review-workbench.cjs",
54
58
  "setup:repo-hooks": "node scripts/setup-repo-hooks.cjs",
55
- "validate:repo-hooks": "node scripts/validate-repo-hooks.cjs"
59
+ "validate:repo-hooks": "node scripts/validate-repo-hooks.cjs",
60
+ "docs:build": "npm run build --silent && node scripts/docs-site/build.ts",
61
+ "docs:check": "npm run docs:build && node scripts/docs-site/check-links.ts"
56
62
  },
57
63
  "dependencies": {
58
- "@kontourai/surface": "^0.5.1"
64
+ "@kontourai/surface": "^0.9.0"
65
+ },
66
+ "peerDependencies": {
67
+ "@anthropic-ai/sdk": ">=0.20.0"
68
+ },
69
+ "peerDependenciesMeta": {
70
+ "@anthropic-ai/sdk": {
71
+ "optional": true
72
+ }
59
73
  },
60
74
  "devDependencies": {
75
+ "@anthropic-ai/sdk": "^0.54.0",
61
76
  "@kontourai/console-kit": "^0.1.0",
62
77
  "@playwright/test": "^1.60.0",
63
78
  "@types/node": "^25.6.0",
79
+ "marked": "^16.4.2",
64
80
  "typescript": "^5.8.0"
65
81
  },
66
82
  "engines": {
@@ -1,2 +0,0 @@
1
- import type { SurveyInput } from "../src/index.js";
2
- export declare const correctedDocumentCandidatesFixture: SurveyInput;
@@ -1,2 +0,0 @@
1
- import type { SurveyInput } from "../src/index.js";
2
- export declare const publicFieldReviewFixture: SurveyInput;