semiotic 3.5.4 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +196 -175
- package/README.md +52 -15
- package/ai/cli.js +41 -0
- package/ai/componentMetadata.cjs +11 -2
- package/ai/dist/mcp-server.js +454 -4
- package/ai/examples.md +98 -0
- package/ai/schema.json +614 -9
- package/ai/system-prompt.md +5 -2
- package/dist/components/AccessibleNavTree.d.ts +25 -0
- package/dist/components/Annotation.d.ts +40 -14
- package/dist/components/ChartContainer.d.ts +32 -2
- package/dist/components/ai/annotationProvenance.d.ts +349 -0
- package/dist/components/ai/audienceProfile.d.ts +147 -0
- package/dist/components/ai/audiences.d.ts +31 -0
- package/dist/components/ai/chartCapabilities.d.ts +55 -0
- package/dist/components/ai/chartCapabilityTypes.d.ts +254 -0
- package/dist/components/ai/chartRoles.d.ts +27 -0
- package/dist/components/ai/conversationArc.d.ts +379 -0
- package/dist/components/ai/dataScaleProfile.d.ts +320 -0
- package/dist/components/ai/describeChart.d.ts +114 -0
- package/dist/components/ai/diffProfile.d.ts +51 -0
- package/dist/components/ai/inferIntent.d.ts +24 -0
- package/dist/components/ai/intents.d.ts +34 -0
- package/dist/components/ai/navigationTree.d.ts +45 -0
- package/dist/components/ai/profileData.d.ts +16 -0
- package/dist/components/ai/qualityFixtures.d.ts +2 -0
- package/dist/components/ai/qualityScorecard.d.ts +82 -0
- package/dist/components/ai/readerGrounding.d.ts +70 -0
- package/dist/components/ai/repairChartConfig.d.ts +73 -0
- package/dist/components/ai/streamingTypes.d.ts +64 -0
- package/dist/components/ai/suggestCharts.d.ts +109 -0
- package/dist/components/ai/suggestDashboard.d.ts +92 -0
- package/dist/components/ai/suggestStreamCharts.d.ts +34 -0
- package/dist/components/ai/suggestStretchCharts.d.ts +60 -0
- package/dist/components/ai/useChartSuggestions.d.ts +22 -0
- package/dist/components/ai/useConversationArc.d.ts +89 -0
- package/dist/components/ai/useNavigationSync.d.ts +61 -0
- package/dist/components/ai/variantDiscovery.d.ts +168 -0
- package/dist/components/charts/geo/ChoroplethMap.capability.d.ts +2 -0
- package/dist/components/charts/geo/DistanceCartogram.capability.d.ts +2 -0
- package/dist/components/charts/geo/FlowMap.capability.d.ts +2 -0
- package/dist/components/charts/geo/ProportionalSymbolMap.capability.d.ts +2 -0
- package/dist/components/charts/index.d.ts +1 -1
- package/dist/components/charts/network/ChordDiagram.capability.d.ts +2 -0
- package/dist/components/charts/network/CirclePack.capability.d.ts +2 -0
- package/dist/components/charts/network/ForceDirectedGraph.capability.d.ts +2 -0
- package/dist/components/charts/network/OrbitDiagram.capability.d.ts +2 -0
- package/dist/components/charts/network/ProcessSankey.capability.d.ts +2 -0
- package/dist/components/charts/network/SankeyDiagram.capability.d.ts +2 -0
- package/dist/components/charts/network/TreeDiagram.capability.d.ts +2 -0
- package/dist/components/charts/network/Treemap.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/BarChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/BoxPlot.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/DonutChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/DotPlot.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/FunnelChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/GaugeChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/GroupedBarChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/Histogram.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/Histogram.d.ts +4 -2
- package/dist/components/charts/ordinal/LikertChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/LikertChart.d.ts +1 -1
- package/dist/components/charts/ordinal/LikertChart.defaults.d.ts +1 -0
- package/dist/components/charts/ordinal/PieChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/RidgelinePlot.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/StackedBarChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/SwarmPlot.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/SwimlaneChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/ViolinPlot.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHeatmap.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +3 -0
- package/dist/components/charts/realtime/RealtimeHistogram.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +3 -0
- package/dist/components/charts/realtime/RealtimeLineChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +3 -0
- package/dist/components/charts/realtime/RealtimeSwarmChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +3 -0
- package/dist/components/charts/realtime/RealtimeWaterfallChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +3 -0
- package/dist/components/charts/realtime/TemporalHistogram.capability.d.ts +7 -0
- package/dist/components/charts/shared/annotationHierarchy.d.ts +42 -0
- package/dist/components/charts/shared/annotationResolvers.d.ts +3 -2
- package/dist/components/charts/shared/annotationRules.d.ts +16 -0
- package/dist/components/charts/shared/annotationTypes.d.ts +14 -0
- package/dist/components/charts/shared/auditAccessibility.d.ts +90 -0
- package/dist/components/charts/shared/chartSpecs.d.ts +2 -37
- package/dist/components/charts/shared/diagnoseConfig.d.ts +4 -6
- package/dist/components/charts/shared/selectionUtils.d.ts +5 -2
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +2 -0
- package/dist/components/charts/shared/types.d.ts +5 -1
- package/dist/components/charts/value/BigNumber.capability.d.ts +13 -0
- package/dist/components/charts/value/BigNumber.d.ts +14 -0
- package/dist/components/charts/value/formatting.d.ts +40 -0
- package/dist/components/charts/value/thresholdSparkline.d.ts +40 -0
- package/dist/components/charts/value/types.d.ts +292 -0
- package/dist/components/charts/xy/AreaChart.capability.d.ts +10 -0
- package/dist/components/charts/xy/BubbleChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/CandlestickChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/ConnectedScatterplot.capability.d.ts +2 -0
- package/dist/components/charts/xy/DifferenceChart.capability.d.ts +8 -0
- package/dist/components/charts/xy/Heatmap.capability.d.ts +9 -0
- package/dist/components/charts/xy/LineChart.capability.d.ts +9 -0
- package/dist/components/charts/xy/MinimapChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/MultiAxisLineChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/QuadrantChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/QuadrantChart.d.ts +5 -2
- package/dist/components/charts/xy/QuadrantChart.defaults.d.ts +2 -0
- package/dist/components/charts/xy/Scatterplot.capability.d.ts +2 -0
- package/dist/components/charts/xy/StackedAreaChart.capability.d.ts +2 -0
- package/dist/components/data/DataSummarizer.d.ts +45 -0
- package/dist/components/realtime/lifecycleBands.d.ts +44 -0
- package/dist/components/realtime/types.d.ts +23 -8
- package/dist/components/recipes/annotationDensity.d.ts +69 -0
- package/dist/components/recipes/annotationLayout.d.ts +93 -0
- package/dist/components/semiotic-ai.d.ts +58 -0
- package/dist/components/semiotic-realtime.d.ts +2 -0
- package/dist/components/semiotic-recipes.d.ts +4 -0
- package/dist/components/semiotic-utils.d.ts +8 -0
- package/dist/components/semiotic-value.d.ts +55 -0
- package/dist/components/semiotic-xy.d.ts +1 -1
- package/dist/components/semiotic.d.ts +8 -1
- package/dist/components/server/staticAnnotations.d.ts +2 -0
- package/dist/components/store/useChartFocus.d.ts +43 -0
- package/dist/components/store/useChartInterrogation.d.ts +141 -0
- package/dist/components/stream/AccessibleDataTable.d.ts +10 -1
- package/dist/components/stream/NetworkSVGOverlay.d.ts +11 -5
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +2 -0
- package/dist/components/stream/SVGOverlay.d.ts +2 -0
- package/dist/components/stream/geoTypes.d.ts +3 -0
- package/dist/components/stream/networkTypes.d.ts +2 -0
- package/dist/components/stream/ordinalTypes.d.ts +2 -0
- package/dist/components/stream/types.d.ts +2 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +58 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-realtime.d.ts +2 -0
- package/dist/semiotic-recipes.d.ts +4 -0
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils.d.ts +8 -0
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-value.d.ts +55 -0
- package/dist/semiotic-value.min.js +2 -0
- package/dist/semiotic-value.module.min.js +2 -0
- package/dist/semiotic-xy.d.ts +1 -1
- package/dist/semiotic.d.ts +8 -1
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +28 -5
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import type { AnnotationStatus } from "./annotationProvenance";
|
|
2
|
+
export type ConversationArcEventType = "suggestion-shown" | "suggestion-chosen" | "audience-set" | "chart-rendered" | "chart-edited" | "chart-replaced" | "chart-exported" | "chart-abandoned" | "interrogation-asked" | "interrogation-answered" | "nav-node-focused" | "nav-branch-expanded" | "annotation-status-changed";
|
|
3
|
+
interface ConversationArcEventBase {
|
|
4
|
+
/** Discriminator for the event variant. */
|
|
5
|
+
type: ConversationArcEventType;
|
|
6
|
+
/** `Date.now()` at the moment the event was recorded. Stamped by the store. */
|
|
7
|
+
timestamp: number;
|
|
8
|
+
/** Stable ID for the enabled session — survives until `disableConversationArc()` or `reset()`. */
|
|
9
|
+
sessionId: string;
|
|
10
|
+
/** Optional opaque correlation key that threads a single arc together. */
|
|
11
|
+
arcId?: string;
|
|
12
|
+
/** Free-form bag for context the talk-track doesn't need a typed slot for. */
|
|
13
|
+
meta?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface SuggestionShownEvent extends ConversationArcEventBase {
|
|
16
|
+
type: "suggestion-shown";
|
|
17
|
+
/**
|
|
18
|
+
* Intent label fed into `suggestCharts` (e.g. "trend", "distribution").
|
|
19
|
+
* Accepts a single intent or an array — mirrors `SuggestChartsOptions.intent`.
|
|
20
|
+
*/
|
|
21
|
+
intent?: string | ReadonlyArray<string>;
|
|
22
|
+
/** Ranked component names in the order the suggester returned them. */
|
|
23
|
+
components: string[];
|
|
24
|
+
/** Top suggestion's composite score, if known. */
|
|
25
|
+
topScore?: number;
|
|
26
|
+
/** Audience target active when the suggestion ran. */
|
|
27
|
+
audience?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface SuggestionChosenEvent extends ConversationArcEventBase {
|
|
30
|
+
type: "suggestion-chosen";
|
|
31
|
+
component: string;
|
|
32
|
+
/** 1-based rank in the matching `suggestion-shown` event, if known. */
|
|
33
|
+
rank?: number;
|
|
34
|
+
/** Who picked the suggestion: a human, an agent loop, or a default-fall-through. */
|
|
35
|
+
source?: "user" | "agent" | "auto";
|
|
36
|
+
}
|
|
37
|
+
export interface AudienceSetEvent extends ConversationArcEventBase {
|
|
38
|
+
type: "audience-set";
|
|
39
|
+
audience: string;
|
|
40
|
+
previous?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ChartRenderedEvent extends ConversationArcEventBase {
|
|
43
|
+
type: "chart-rendered";
|
|
44
|
+
component: string;
|
|
45
|
+
chartId?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface ChartEditedEvent extends ConversationArcEventBase {
|
|
48
|
+
type: "chart-edited";
|
|
49
|
+
component: string;
|
|
50
|
+
chartId?: string;
|
|
51
|
+
/** Names of props that changed in this edit. */
|
|
52
|
+
changedProps?: string[];
|
|
53
|
+
}
|
|
54
|
+
export interface ChartReplacedEvent extends ConversationArcEventBase {
|
|
55
|
+
type: "chart-replaced";
|
|
56
|
+
from: string;
|
|
57
|
+
to: string;
|
|
58
|
+
/** Why the swap happened — `"repair"`, `"variant"`, `"user-rejected"`, etc. */
|
|
59
|
+
reason?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface ChartExportedEvent extends ConversationArcEventBase {
|
|
62
|
+
type: "chart-exported";
|
|
63
|
+
component: string;
|
|
64
|
+
/** What was exported: `"jsx"`, `"svg"`, `"png"`, `"json"`, `"url"`, etc. */
|
|
65
|
+
format: string;
|
|
66
|
+
}
|
|
67
|
+
export interface ChartAbandonedEvent extends ConversationArcEventBase {
|
|
68
|
+
type: "chart-abandoned";
|
|
69
|
+
component?: string;
|
|
70
|
+
reason?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface InterrogationAskedEvent extends ConversationArcEventBase {
|
|
73
|
+
type: "interrogation-asked";
|
|
74
|
+
/** Chart the question was directed at, if known. */
|
|
75
|
+
component?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Question text. The `useChartInterrogation` instrumentation
|
|
78
|
+
* truncates to ~500 chars before recording so the ring buffer
|
|
79
|
+
* stays bounded; callers stamping their own events should do the
|
|
80
|
+
* same.
|
|
81
|
+
*/
|
|
82
|
+
query: string;
|
|
83
|
+
/** Optional payload size hint (e.g. summary token count) for diagnostics. */
|
|
84
|
+
contextSize?: number;
|
|
85
|
+
}
|
|
86
|
+
export interface InterrogationAnsweredEvent extends ConversationArcEventBase {
|
|
87
|
+
type: "interrogation-answered";
|
|
88
|
+
/** Chart the answer was directed at, if known. */
|
|
89
|
+
component?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Answer text. The `useChartInterrogation` instrumentation
|
|
92
|
+
* truncates to ~2000 chars before recording so multi-kilobyte LLM
|
|
93
|
+
* responses don't bloat the ring buffer. Callers stamping their
|
|
94
|
+
* own events should follow the same convention.
|
|
95
|
+
*/
|
|
96
|
+
answer?: string;
|
|
97
|
+
/** Number of annotations the response attached, if known. */
|
|
98
|
+
annotationCount?: number;
|
|
99
|
+
/**
|
|
100
|
+
* Round-trip latency in ms from ask to answer, clamped to ≥ 0.
|
|
101
|
+
* The instrumentation measures via `performance.now()` when
|
|
102
|
+
* available; the `Date.now()` fallback can produce negative
|
|
103
|
+
* deltas under clock changes, hence the clamp.
|
|
104
|
+
*/
|
|
105
|
+
latencyMs?: number;
|
|
106
|
+
/** Set when the response was an error rather than a successful answer. */
|
|
107
|
+
error?: boolean;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* A reader focused a node in an `AccessibleNavTree` (keyboard or click). The
|
|
111
|
+
* first *reception*-side behavioral signal in the arc — which structural nodes
|
|
112
|
+
* a non-visual (or AI) reader actually visits, the dependent measure visualization-
|
|
113
|
+
* literacy studies usually lack. Emitted only on genuine tree interaction, not
|
|
114
|
+
* when the active node is driven externally (canvas → tree sync).
|
|
115
|
+
*/
|
|
116
|
+
export interface NavNodeFocusedEvent extends ConversationArcEventBase {
|
|
117
|
+
type: "nav-node-focused";
|
|
118
|
+
/** `chartId` of the chart the tree describes, when correlated. */
|
|
119
|
+
chartId?: string;
|
|
120
|
+
/** Tree node id that gained focus. */
|
|
121
|
+
nodeId: string;
|
|
122
|
+
/** Node role: `"chart" | "axis" | "series" | "datum"`. */
|
|
123
|
+
role: string;
|
|
124
|
+
/** 1-based depth (aria-level). */
|
|
125
|
+
level: number;
|
|
126
|
+
/** The node's announced label (the emitter truncates to ~200 chars). */
|
|
127
|
+
label?: string;
|
|
128
|
+
}
|
|
129
|
+
/** A reader expanded or collapsed a branch in an `AccessibleNavTree`. */
|
|
130
|
+
export interface NavBranchExpandedEvent extends ConversationArcEventBase {
|
|
131
|
+
type: "nav-branch-expanded";
|
|
132
|
+
/** `chartId` of the chart the tree describes, when correlated. */
|
|
133
|
+
chartId?: string;
|
|
134
|
+
/** Tree node id that was toggled. */
|
|
135
|
+
nodeId: string;
|
|
136
|
+
/** Node role of the toggled branch. */
|
|
137
|
+
role: string;
|
|
138
|
+
/** 1-based depth (aria-level). */
|
|
139
|
+
level: number;
|
|
140
|
+
/** `true` on expand, `false` on collapse. */
|
|
141
|
+
expanded: boolean;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* An annotation's editorial status transitioned (M7). The accept / dispute /
|
|
145
|
+
* retract / propose flow is what turns an annotation into the durable,
|
|
146
|
+
* observable node of the conversation arc (IDID §13.4): the note is the unit
|
|
147
|
+
* the arc is *about*, not chart chrome.
|
|
148
|
+
*
|
|
149
|
+
* `fromStatus`/`toStatus` are deliberately not named `from`/`to` — `summarizeArc`
|
|
150
|
+
* reads `from`/`to` as chart-component names (the `chart-replaced` shape), so a
|
|
151
|
+
* status value there would pollute `componentsSeen`.
|
|
152
|
+
*/
|
|
153
|
+
export interface AnnotationStatusChangedEvent extends ConversationArcEventBase {
|
|
154
|
+
type: "annotation-status-changed";
|
|
155
|
+
/** `provenance.stableId` of the annotation whose status changed, when known. */
|
|
156
|
+
annotationId?: string;
|
|
157
|
+
/** Previous editorial status, if known. */
|
|
158
|
+
fromStatus?: AnnotationStatus;
|
|
159
|
+
/** New editorial status. */
|
|
160
|
+
toStatus: AnnotationStatus;
|
|
161
|
+
/** `chartId` of the chart carrying the annotation, when correlated. */
|
|
162
|
+
chartId?: string;
|
|
163
|
+
}
|
|
164
|
+
export type ConversationArcEvent = SuggestionShownEvent | SuggestionChosenEvent | AudienceSetEvent | ChartRenderedEvent | ChartEditedEvent | ChartReplacedEvent | ChartExportedEvent | ChartAbandonedEvent | InterrogationAskedEvent | InterrogationAnsweredEvent | NavNodeFocusedEvent | NavBranchExpandedEvent | AnnotationStatusChangedEvent;
|
|
165
|
+
/**
|
|
166
|
+
* Input shape accepted by `record()`: the event variant without the
|
|
167
|
+
* stamped fields (`timestamp` and `sessionId`). Callers may still
|
|
168
|
+
* provide them to backfill historical events.
|
|
169
|
+
*
|
|
170
|
+
* Implemented as a distributive conditional so each member of the
|
|
171
|
+
* discriminated union keeps its variant-specific payload (e.g.
|
|
172
|
+
* `SuggestionShownEvent.components`). A non-distributive
|
|
173
|
+
* `Omit<ConversationArcEvent, ...>` collapses to the union's common
|
|
174
|
+
* fields and rejects every variant-specific key.
|
|
175
|
+
*/
|
|
176
|
+
export type ConversationArcEventInput = ConversationArcEvent extends infer E ? E extends ConversationArcEvent ? Omit<E, "timestamp" | "sessionId"> & Partial<Pick<E, "timestamp" | "sessionId">> : never : never;
|
|
177
|
+
export type ConversationArcListener = (event: ConversationArcEvent) => void;
|
|
178
|
+
export interface ConversationArcSink {
|
|
179
|
+
/**
|
|
180
|
+
* Persist a newly-recorded event. Called only after the store is enabled and
|
|
181
|
+
* the event is accepted into the ring buffer.
|
|
182
|
+
*/
|
|
183
|
+
record?(event: ConversationArcEvent): void | Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Optional hook for consumers that treat `flush()` as an export boundary.
|
|
186
|
+
* The in-memory buffer is still cleared by the store after this call.
|
|
187
|
+
*/
|
|
188
|
+
flush?(events: ReadonlyArray<ConversationArcEvent>): void | Promise<void>;
|
|
189
|
+
/** Clear durable state owned by this sink. */
|
|
190
|
+
clear?(): void | Promise<void>;
|
|
191
|
+
/** Load previously persisted events for replay / hydration. */
|
|
192
|
+
load?(): ReadonlyArray<ConversationArcEvent> | Promise<ReadonlyArray<ConversationArcEvent>>;
|
|
193
|
+
}
|
|
194
|
+
export interface ConversationArcStorageLike {
|
|
195
|
+
getItem(key: string): string | null;
|
|
196
|
+
setItem(key: string, value: string): void;
|
|
197
|
+
removeItem(key: string): void;
|
|
198
|
+
}
|
|
199
|
+
export interface LocalStorageConversationArcSinkOptions {
|
|
200
|
+
/** Storage key. Defaults to `semiotic:conversation-arc`. */
|
|
201
|
+
key?: string;
|
|
202
|
+
/** Test hook or alternate Storage implementation. Defaults to `window.localStorage`. */
|
|
203
|
+
storage?: ConversationArcStorageLike;
|
|
204
|
+
/** Maximum events retained in storage. Defaults to 1000. */
|
|
205
|
+
maxEvents?: number;
|
|
206
|
+
}
|
|
207
|
+
export interface IndexedDBConversationArcSinkOptions {
|
|
208
|
+
/** Database name. Defaults to `semiotic-conversation-arc`. */
|
|
209
|
+
dbName?: string;
|
|
210
|
+
/** Object store name. Defaults to `events`. */
|
|
211
|
+
storeName?: string;
|
|
212
|
+
/** Test hook or alternate IndexedDB factory. Defaults to `globalThis.indexedDB`. */
|
|
213
|
+
indexedDB?: IDBFactory;
|
|
214
|
+
/** Maximum events retained in the object store. Defaults to 1000. */
|
|
215
|
+
maxEvents?: number;
|
|
216
|
+
}
|
|
217
|
+
export type ConversationArcWebhookFetch = (input: string, init?: RequestInit) => Promise<unknown>;
|
|
218
|
+
export interface WebhookConversationArcSinkOptions {
|
|
219
|
+
url: string;
|
|
220
|
+
method?: "POST" | "PUT";
|
|
221
|
+
headers?: Record<string, string>;
|
|
222
|
+
fetch?: ConversationArcWebhookFetch;
|
|
223
|
+
mapEvent?: (event: ConversationArcEvent) => unknown;
|
|
224
|
+
}
|
|
225
|
+
export interface LoadConversationArcOptions {
|
|
226
|
+
/** Capacity of the hydrated ring buffer. Defaults to max(existing, events.length, 1000). */
|
|
227
|
+
capacity?: number;
|
|
228
|
+
/** Active session id for future recordings. Replayed event session ids are preserved. */
|
|
229
|
+
sessionId?: string;
|
|
230
|
+
/**
|
|
231
|
+
* Whether the store should accept new events after hydration. Defaults to false
|
|
232
|
+
* so replaying an artifact cannot accidentally start telemetry.
|
|
233
|
+
*/
|
|
234
|
+
enabled?: boolean;
|
|
235
|
+
/** Append to the current buffer instead of replacing it. Defaults to false. */
|
|
236
|
+
append?: boolean;
|
|
237
|
+
}
|
|
238
|
+
export interface ConversationArcStore {
|
|
239
|
+
readonly enabled: boolean;
|
|
240
|
+
readonly sessionId: string | null;
|
|
241
|
+
readonly capacity: number;
|
|
242
|
+
/**
|
|
243
|
+
* Records an event. Returns the stamped event on success, or `null`
|
|
244
|
+
* if the store is disabled. Stamps `timestamp` and `sessionId` if
|
|
245
|
+
* the caller didn't.
|
|
246
|
+
*/
|
|
247
|
+
record(input: ConversationArcEventInput): ConversationArcEvent | null;
|
|
248
|
+
/** Returns the current buffer (newest last) and clears it. */
|
|
249
|
+
flush(): ConversationArcEvent[];
|
|
250
|
+
/**
|
|
251
|
+
* Returns a frozen, referentially-stable snapshot of the current
|
|
252
|
+
* buffer. Stable across consecutive calls until the next mutation,
|
|
253
|
+
* so it can drive `useSyncExternalStore`. Read-only — callers that
|
|
254
|
+
* need a mutable copy should `.slice()` the result.
|
|
255
|
+
*/
|
|
256
|
+
getEvents(): ReadonlyArray<ConversationArcEvent>;
|
|
257
|
+
/**
|
|
258
|
+
* Subscribe to new events. Returns an unsubscribe function.
|
|
259
|
+
*
|
|
260
|
+
* Subscriptions persist across enable/disable transitions — a
|
|
261
|
+
* subscriber registered before `enableConversationArc()` still
|
|
262
|
+
* receives events once recording starts. Cleared by `reset()`.
|
|
263
|
+
*/
|
|
264
|
+
subscribe(listener: ConversationArcListener): () => void;
|
|
265
|
+
/** Empties the buffer without disabling the store. */
|
|
266
|
+
clear(): void;
|
|
267
|
+
/** Disables the store and drops the buffer + subscribers. */
|
|
268
|
+
reset(): void;
|
|
269
|
+
}
|
|
270
|
+
export interface EnableConversationArcOptions {
|
|
271
|
+
/** Maximum events retained in the ring buffer. Defaults to 1000. */
|
|
272
|
+
capacity?: number;
|
|
273
|
+
/** Override the generated session ID. Useful for cross-tab correlation. */
|
|
274
|
+
sessionId?: string;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Subscribe to *any* state mutation in the conversation-arc store —
|
|
278
|
+
* including `clear`, `flush`, `reset`, and `enable`, in addition to
|
|
279
|
+
* recorded events. Intended for React hooks that need to re-render
|
|
280
|
+
* on snapshot changes; event sinks should use `subscribe()` instead.
|
|
281
|
+
*
|
|
282
|
+
* Returns an unsubscribe callback.
|
|
283
|
+
*/
|
|
284
|
+
export declare function subscribeToConversationArcChange(listener: () => void): () => void;
|
|
285
|
+
/**
|
|
286
|
+
* Register an opt-in persistence sink. Sinks receive only accepted events:
|
|
287
|
+
* disabled telemetry remains a no-op and replay hydration does not re-emit
|
|
288
|
+
* historical events into durable stores.
|
|
289
|
+
*/
|
|
290
|
+
export declare function registerConversationArcSink(sink: ConversationArcSink): () => void;
|
|
291
|
+
/**
|
|
292
|
+
* Browser-local durable sink backed by `localStorage`. It appends each accepted
|
|
293
|
+
* event to a JSON array and exposes `load()` so a session can be replayed later.
|
|
294
|
+
* When `localStorage` is unavailable (SSR, private browser failures), operations
|
|
295
|
+
* degrade to no-ops and `load()` returns `[]`.
|
|
296
|
+
*/
|
|
297
|
+
export declare function createLocalStorageConversationArcSink(options?: LocalStorageConversationArcSinkOptions): ConversationArcSink & {
|
|
298
|
+
load(): ConversationArcEvent[];
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Browser durable sink backed by IndexedDB. Writes are asynchronous and
|
|
302
|
+
* fire-and-forget from the recorder; callers that need replay can await
|
|
303
|
+
* `sink.load()`.
|
|
304
|
+
*/
|
|
305
|
+
export declare function createIndexedDBConversationArcSink(options?: IndexedDBConversationArcSinkOptions): ConversationArcSink & {
|
|
306
|
+
load(): Promise<ConversationArcEvent[]>;
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Minimal webhook sink for app-owned analytics ingestion. The sink posts one
|
|
310
|
+
* JSON payload per accepted event; retry, batching, authentication refresh, and
|
|
311
|
+
* sampling policy remain application concerns.
|
|
312
|
+
*/
|
|
313
|
+
export declare function createWebhookConversationArcSink(options: WebhookConversationArcSinkOptions): ConversationArcSink;
|
|
314
|
+
/**
|
|
315
|
+
* Hydrate the in-memory store from a saved arc without replaying side effects.
|
|
316
|
+
* The loaded events become visible through `getEvents()` / `useConversationArc`,
|
|
317
|
+
* but listeners and sinks are not called. Pass `{ enabled: true }` when you want
|
|
318
|
+
* to resume recording after loading; the default is replay-only.
|
|
319
|
+
*/
|
|
320
|
+
export declare function loadConversationArc(events: ReadonlyArray<ConversationArcEvent>, options?: LoadConversationArcOptions): ReadonlyArray<ConversationArcEvent>;
|
|
321
|
+
/** Alias with the word replay for fixture-driven callers. */
|
|
322
|
+
export declare function replayConversationArc(events: ReadonlyArray<ConversationArcEvent>, options?: LoadConversationArcOptions): ReadonlyArray<ConversationArcEvent>;
|
|
323
|
+
/**
|
|
324
|
+
* Record an audience-set event. Convenience wrapper around `record`
|
|
325
|
+
* for the common pattern: "the user picked a new audience profile
|
|
326
|
+
* and I want to put that in the arc."
|
|
327
|
+
*
|
|
328
|
+
* `previous` is optional but recommended — it lets downstream
|
|
329
|
+
* analytics see the transition rather than just the new state. Pass
|
|
330
|
+
* `null` when there was no prior audience.
|
|
331
|
+
*
|
|
332
|
+
* Returns the stamped event, or `null` if recording is disabled.
|
|
333
|
+
*
|
|
334
|
+
* ```ts
|
|
335
|
+
* import { recordAudienceChange } from "semiotic/ai"
|
|
336
|
+
*
|
|
337
|
+
* function AudiencePicker({ value, onChange }) {
|
|
338
|
+
* return (
|
|
339
|
+
* <select value={value} onChange={(e) => {
|
|
340
|
+
* const next = e.target.value
|
|
341
|
+
* recordAudienceChange(next, value)
|
|
342
|
+
* onChange(next)
|
|
343
|
+
* }} />
|
|
344
|
+
* )
|
|
345
|
+
* }
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
export declare function recordAudienceChange(audience: string, previous?: string | null, extra?: {
|
|
349
|
+
arcId?: string;
|
|
350
|
+
meta?: Record<string, unknown>;
|
|
351
|
+
}): ConversationArcEvent | null;
|
|
352
|
+
/**
|
|
353
|
+
* Sugar for an `annotation-status-changed` event (M7). Call it from the
|
|
354
|
+
* accept / dispute / retract / propose UI so the arc records how an
|
|
355
|
+
* annotation's editorial standing moved — the durable, observable node of the
|
|
356
|
+
* conversation. No-op (returns null) until `enableConversationArc()`.
|
|
357
|
+
*/
|
|
358
|
+
export declare function recordAnnotationStatusChange(toStatus: AnnotationStatus, opts?: {
|
|
359
|
+
annotationId?: string;
|
|
360
|
+
fromStatus?: AnnotationStatus;
|
|
361
|
+
chartId?: string;
|
|
362
|
+
arcId?: string;
|
|
363
|
+
meta?: Record<string, unknown>;
|
|
364
|
+
}): ConversationArcEvent | null;
|
|
365
|
+
/**
|
|
366
|
+
* Opt in to conversation-arc telemetry. Safe to call multiple times —
|
|
367
|
+
* subsequent calls reuse the existing session unless `sessionId` is
|
|
368
|
+
* explicitly provided.
|
|
369
|
+
*/
|
|
370
|
+
export declare function enableConversationArc(options?: EnableConversationArcOptions): ConversationArcStore;
|
|
371
|
+
/** Turn the store off without dropping the buffered events. */
|
|
372
|
+
export declare function disableConversationArc(): void;
|
|
373
|
+
/**
|
|
374
|
+
* Always returns a store façade. Methods are safe to call when
|
|
375
|
+
* disabled — `record()` returns null, `getEvents()`/`flush()` return
|
|
376
|
+
* empty arrays, `subscribe()` returns a no-op unsubscriber.
|
|
377
|
+
*/
|
|
378
|
+
export declare function getConversationArcStore(): ConversationArcStore;
|
|
379
|
+
export {};
|