@firstflow/react 0.0.1 → 0.0.101

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.
@@ -0,0 +1,325 @@
1
+ interface CreateFirstflowOptions {
2
+ agentId: string;
3
+ /** Optional Clerk API key used as `Authorization: Bearer ...` for protected SDK endpoints. */
4
+ apiKey?: string;
5
+ /** Optional identified user + traits used for audience targeting and analytics identify. */
6
+ user?: UserContext | null;
7
+ /** Auto-fetch audience membership map for identified users. Defaults to true. */
8
+ autoFetchAudienceMembership?: boolean;
9
+ }
10
+ interface UserContext {
11
+ /** Stable app-specific identifier (required for identified users). */
12
+ id: string;
13
+ /** Optional top-level identity fields. */
14
+ email?: string;
15
+ name?: string;
16
+ /** Arbitrary user attributes used in audience rules (e.g. plan, role, company). */
17
+ traits?: Record<string, unknown>;
18
+ }
19
+ /**
20
+ * Segment membership lookup map keyed by segment_id.
21
+ * Missing keys always evaluate to false in runtime eligibility checks.
22
+ */
23
+ type AudienceMembershipMap = Record<string, boolean>;
24
+ /**
25
+ * Public API for the issue module only (open, submit, getConfig, destroy).
26
+ * Internal wiring (setConfig, setOpenHandler) is not exposed.
27
+ */
28
+ interface IssueModulePublic {
29
+ open(options?: OpenOptions): void;
30
+ submit(data: IssueReportData): Promise<void>;
31
+ getConfig(): NormalizedConfig;
32
+ destroy(): void;
33
+ }
34
+ /** Analytics API exposed on the platform instance. Used by all feature modules. */
35
+ interface AnalyticsModulePublic {
36
+ track(eventName: string, properties?: Record<string, unknown>): void;
37
+ identify(userId?: string, traits?: Record<string, unknown>): void;
38
+ page(name?: string, properties?: Record<string, unknown>): void;
39
+ }
40
+ /**
41
+ * Root platform instance: agent identity, analytics, and feature modules.
42
+ * Represents the runtime context for this agent at this API.
43
+ */
44
+ /** Subset of agent widget branding merged from public config (`widget_ui` / `primary_color`). */
45
+ type FirstflowWidgetUi = Readonly<{
46
+ primaryColor?: string;
47
+ }>;
48
+ interface FirstflowInstance {
49
+ readonly agentId: string;
50
+ /** Fixed public API base URL used for config, audience, and overrides (see `FIRSTFLOW_PUBLIC_API_BASE_URL`). */
51
+ readonly apiUrl: string;
52
+ /**
53
+ * Brand color hints for embedded UI (e.g. announcement primary buttons).
54
+ * Populated from agent config when the API returns `widget_ui` or `primary_color`.
55
+ */
56
+ getWidgetUi(): FirstflowWidgetUi | null;
57
+ analytics: AnalyticsModulePublic;
58
+ issue: IssueModulePublic;
59
+ feedback: FeedbackModulePublic;
60
+ survey: SurveyModulePublic;
61
+ getUser(): UserContext | null;
62
+ setUser(user: UserContext | null): void;
63
+ /**
64
+ * Merge segment membership values into runtime state.
65
+ * Only `true` grants membership; missing IDs or non-true values are treated as not a member.
66
+ */
67
+ setAudienceMembership(map: AudienceMembershipMap): void;
68
+ getAudienceMembership(): AudienceMembershipMap;
69
+ refreshConfig(): Promise<void>;
70
+ reset(): void;
71
+ }
72
+ /**
73
+ * Raw issues config as received from API (e.g. agent.issues_config).
74
+ */
75
+ interface RawIssueFieldConfig {
76
+ id?: string;
77
+ allowed?: boolean;
78
+ label?: string;
79
+ type?: "text" | "textarea" | "select";
80
+ required?: boolean;
81
+ options?: string[];
82
+ }
83
+ interface RawIssuesConfig {
84
+ enabled?: boolean;
85
+ title?: string;
86
+ triggerLabel?: string;
87
+ submitLabel?: string;
88
+ cancelLabel?: string;
89
+ cancelEnabled?: boolean;
90
+ promptText?: string;
91
+ fields?: RawIssueFieldConfig[];
92
+ }
93
+ interface RawFeedbackFormConfig {
94
+ tags?: string[];
95
+ placeholder?: string;
96
+ showTags?: boolean;
97
+ showComment?: boolean;
98
+ /** Message shown to the user after they submit feedback (or immediately when no form is shown). */
99
+ confirmationMessage?: string;
100
+ }
101
+ interface RawFeedbackConfig {
102
+ enabled?: boolean;
103
+ like?: RawFeedbackFormConfig;
104
+ dislike?: RawFeedbackFormConfig;
105
+ }
106
+ interface NormalizedFeedbackFormConfig {
107
+ tags: string[];
108
+ placeholder: string;
109
+ showTags: boolean;
110
+ showComment: boolean;
111
+ /** Message shown after feedback is given. */
112
+ confirmationMessage: string;
113
+ }
114
+ interface NormalizedFeedbackConfig {
115
+ enabled: boolean;
116
+ like: NormalizedFeedbackFormConfig;
117
+ dislike: NormalizedFeedbackFormConfig;
118
+ }
119
+ interface MessageFeedbackSubmitPayload {
120
+ conversationId: string;
121
+ messageId: string;
122
+ rating: "like" | "dislike";
123
+ /** Used by MessageFeedback UI only; not sent as analytics event fields. */
124
+ tags?: string[];
125
+ comment?: string;
126
+ /** Mirrors config: whether tags/comment were enabled for this sentiment at submit time. */
127
+ showTags?: boolean;
128
+ showComment?: boolean;
129
+ messagePreview?: string;
130
+ /**
131
+ * Arbitrary JSON-serializable key/value bag (e.g. locale, page_url, model, experiment_id).
132
+ * Sent on the analytics payload as property `metadata` after JSON round-trip (max ~32KB serialized).
133
+ */
134
+ metadata?: Record<string, unknown>;
135
+ }
136
+ interface FeedbackModulePublic {
137
+ submit(payload: MessageFeedbackSubmitPayload): Promise<void>;
138
+ getConfig(): NormalizedFeedbackConfig;
139
+ isEnabled(): boolean;
140
+ }
141
+ type SurveyQuestionType = 'nps' | 'multiple_choice' | 'slider' | 'opinion_scale' | 'open_question' | 'concept_test' | 'interview_prompt' | 'text_block' | 'thank_you';
142
+ type SurveyScaleType = 'numbers' | 'stars' | 'emojis';
143
+ type SurveyAnswerValue = string | number | string[] | null;
144
+ interface SurveyQuestion {
145
+ id: string;
146
+ nodeId: string;
147
+ type: SurveyQuestionType;
148
+ questionText: string;
149
+ required: boolean;
150
+ options?: string[];
151
+ minValue?: number;
152
+ maxValue?: number;
153
+ minLabel?: string;
154
+ maxLabel?: string;
155
+ step?: number;
156
+ scaleType?: SurveyScaleType;
157
+ placeholder?: string;
158
+ multiline?: boolean;
159
+ /** thank_you: confetti when true or unset; set false to disable. */
160
+ showConfetti?: boolean;
161
+ }
162
+ interface SurveyExperience {
163
+ experienceId: string;
164
+ name?: string | null;
165
+ status?: string | null;
166
+ settings?: ExperienceSettings | null;
167
+ questions: SurveyQuestion[];
168
+ }
169
+ type ExperienceSettings = {
170
+ trigger: {
171
+ show_on: 'chat_opens' | 'after_user_message' | 'after_idle' | 'custom_event';
172
+ custom_event_name?: string;
173
+ /** Idle delay in seconds (when show_on is "after_idle"). 0-300. */
174
+ delay_seconds?: number;
175
+ };
176
+ device: 'all' | 'desktop' | 'mobile';
177
+ audience: AudienceConfig;
178
+ schedule: {
179
+ start_type: 'now' | 'scheduled';
180
+ starts_at?: string;
181
+ timezone?: string;
182
+ expiration_type: 'none' | 'scheduled';
183
+ expires_at?: string;
184
+ };
185
+ frequency: {
186
+ type: 'once' | 'limited' | 'always';
187
+ limit?: number;
188
+ period?: 'session' | 'day' | 'week' | 'lifetime';
189
+ };
190
+ priority: number;
191
+ };
192
+ type RuleOperator = 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'in' | 'not_in' | 'gt' | 'gte' | 'lt' | 'lte' | 'exists' | 'not_exists';
193
+ interface AudienceRule {
194
+ trait: string;
195
+ operator: RuleOperator;
196
+ value?: unknown;
197
+ }
198
+ type AudienceConfig = {
199
+ type: 'all';
200
+ } | {
201
+ type: 'segment';
202
+ segment_id?: string;
203
+ } | {
204
+ type: 'rules';
205
+ operator: 'AND' | 'OR';
206
+ rules: AudienceRule[];
207
+ };
208
+ interface SurveySubmitPayload {
209
+ experienceId: string;
210
+ conversationId?: string;
211
+ answers: Record<string, SurveyAnswerValue>;
212
+ metadata?: Record<string, unknown>;
213
+ }
214
+ interface SurveyModulePublic {
215
+ getSurveys(): SurveyExperience[];
216
+ getSurvey(experienceId: string): SurveyExperience | null;
217
+ setExperiences(experiences: unknown[] | null | undefined): void;
218
+ isEnabled(experienceId?: string): boolean;
219
+ submit(payload: SurveySubmitPayload): Promise<void>;
220
+ }
221
+ /**
222
+ * Normalized field config used internally (after filtering allowed, defaulting type/label).
223
+ */
224
+ interface NormalizedFieldConfig {
225
+ id: string;
226
+ type: "text" | "textarea" | "select";
227
+ label: string;
228
+ required: boolean;
229
+ options?: string[];
230
+ }
231
+ /**
232
+ * Normalized config: single source of truth for the SDK.
233
+ */
234
+ interface NormalizedConfig {
235
+ agentId: string;
236
+ apiUrl: string;
237
+ enabled: boolean;
238
+ title: string;
239
+ triggerLabel: string;
240
+ submitLabel: string;
241
+ cancelLabel: string;
242
+ cancelEnabled: boolean;
243
+ promptText: string;
244
+ fields: NormalizedFieldConfig[];
245
+ }
246
+ /**
247
+ * Form field values only (keys = field ids). Validated before submit.
248
+ * Validation applies to this only.
249
+ */
250
+ type IssueFormValues = Record<string, string | undefined>;
251
+ /**
252
+ * Context metadata: set programmatically (e.g. open({ messageId })). Never validated.
253
+ * Merged with form values at submit time. Users can add arbitrary JSON-serializable keys/values.
254
+ */
255
+ type IssueContextMetadata = {
256
+ conversationId?: string;
257
+ messageId?: string;
258
+ sessionId?: string;
259
+ agentId?: string;
260
+ model?: string;
261
+ } & Record<string, unknown>;
262
+ /**
263
+ * Options passed to open() (e.g. "Report this response").
264
+ */
265
+ type OpenOptions = IssueContextMetadata;
266
+ /**
267
+ * Final submission payload: form values + context metadata. Sent to transport.
268
+ * Values can be primitives (form fields) or arbitrary JSON-serializable metadata.
269
+ */
270
+ type IssuePayload = Record<string, unknown>;
271
+ /**
272
+ * Options for createIssueReporter. Config is optional; when omitted, defaults are used.
273
+ * When analytics is omitted, a default analytics instance is created (same default collector settings).
274
+ */
275
+ interface CreateIssueReporterOptions {
276
+ agentId: string;
277
+ apiUrl: string;
278
+ config?: Partial<RawIssuesConfig>;
279
+ /** Platform analytics; issue module calls analytics.track('issue_submitted', payload). Defaults to createAnalytics({ agentId }) when omitted. */
280
+ analytics?: AnalyticsModulePublic;
281
+ }
282
+ /**
283
+ * Validation result.
284
+ */
285
+ interface ValidationResult {
286
+ valid: boolean;
287
+ errors?: Record<string, string>;
288
+ }
289
+ type IssueReportData = Record<string, unknown>;
290
+ /**
291
+ * Instance returned by createIssueReporter.
292
+ * setConfig is used internally when config is loaded asynchronously.
293
+ */
294
+ interface IssueReporterInstance {
295
+ getConfig(): NormalizedConfig;
296
+ setConfig(config: NormalizedConfig): void;
297
+ reportIssue(data: IssueReportData): Promise<void>;
298
+ open(options?: OpenOptions): void;
299
+ setOpenHandler(handler: ((options?: OpenOptions) => void) | undefined): void;
300
+ destroy(): void;
301
+ }
302
+
303
+ /**
304
+ * Platform event names. Feature modules use these when calling analytics.track().
305
+ * Do not rename existing events (e.g. issue_submitted) to avoid breaking pipelines.
306
+ */
307
+ /** Issue module — backward compatible */
308
+ declare const ISSUE_SUBMITTED = "issue_submitted";
309
+ /** Future modules */
310
+ declare const FEEDBACK_SUBMITTED = "feedback_submitted";
311
+ declare const SURVEY_COMPLETED = "survey_completed";
312
+ declare const EXPERIENCE_SHOWN = "experience_shown";
313
+ declare const EXPERIENCE_CLICKED = "experience_clicked";
314
+ declare const CHAT_MESSAGE_SENT = "chat_message_sent";
315
+ /**
316
+ * `experience_type` on `experience_shown` / `experience_clicked` — stable for ClickHouse / dashboards.
317
+ * Surfaces which product surface fired the event alongside `experience_id` / `node_id`.
318
+ */
319
+ declare const EXPERIENCE_ANALYTICS_TYPE: {
320
+ readonly FLOW_MESSAGE: "flow_message";
321
+ readonly FLOW_ANNOUNCEMENT: "flow_announcement";
322
+ readonly SURVEY: "survey";
323
+ };
324
+
325
+ export { type AudienceMembershipMap as A, ISSUE_SUBMITTED as B, type CreateFirstflowOptions as C, type IssueModulePublic as D, type ExperienceSettings as E, type FirstflowInstance as F, type IssueFormValues as I, type MessageFeedbackSubmitPayload as M, type NormalizedFeedbackConfig as N, type OpenOptions as O, type RawIssuesConfig as R, type SurveySubmitPayload as S, type UserContext as U, type ValidationResult as V, type RawFeedbackConfig as a, type SurveyQuestion as b, type SurveyAnswerValue as c, type SurveyModulePublic as d, type AnalyticsModulePublic as e, type AudienceConfig as f, type AudienceRule as g, CHAT_MESSAGE_SENT as h, EXPERIENCE_ANALYTICS_TYPE as i, EXPERIENCE_CLICKED as j, EXPERIENCE_SHOWN as k, type FirstflowWidgetUi as l, type RuleOperator as m, SURVEY_COMPLETED as n, type SurveyExperience as o, type NormalizedFeedbackFormConfig as p, type FeedbackModulePublic as q, type NormalizedConfig as r, type NormalizedFieldConfig as s, type IssueContextMetadata as t, type IssuePayload as u, type RawIssueFieldConfig as v, type IssueReporterInstance as w, type IssueReportData as x, type CreateIssueReporterOptions as y, FEEDBACK_SUBMITTED as z };
@@ -0,0 +1,325 @@
1
+ interface CreateFirstflowOptions {
2
+ agentId: string;
3
+ /** Optional Clerk API key used as `Authorization: Bearer ...` for protected SDK endpoints. */
4
+ apiKey?: string;
5
+ /** Optional identified user + traits used for audience targeting and analytics identify. */
6
+ user?: UserContext | null;
7
+ /** Auto-fetch audience membership map for identified users. Defaults to true. */
8
+ autoFetchAudienceMembership?: boolean;
9
+ }
10
+ interface UserContext {
11
+ /** Stable app-specific identifier (required for identified users). */
12
+ id: string;
13
+ /** Optional top-level identity fields. */
14
+ email?: string;
15
+ name?: string;
16
+ /** Arbitrary user attributes used in audience rules (e.g. plan, role, company). */
17
+ traits?: Record<string, unknown>;
18
+ }
19
+ /**
20
+ * Segment membership lookup map keyed by segment_id.
21
+ * Missing keys always evaluate to false in runtime eligibility checks.
22
+ */
23
+ type AudienceMembershipMap = Record<string, boolean>;
24
+ /**
25
+ * Public API for the issue module only (open, submit, getConfig, destroy).
26
+ * Internal wiring (setConfig, setOpenHandler) is not exposed.
27
+ */
28
+ interface IssueModulePublic {
29
+ open(options?: OpenOptions): void;
30
+ submit(data: IssueReportData): Promise<void>;
31
+ getConfig(): NormalizedConfig;
32
+ destroy(): void;
33
+ }
34
+ /** Analytics API exposed on the platform instance. Used by all feature modules. */
35
+ interface AnalyticsModulePublic {
36
+ track(eventName: string, properties?: Record<string, unknown>): void;
37
+ identify(userId?: string, traits?: Record<string, unknown>): void;
38
+ page(name?: string, properties?: Record<string, unknown>): void;
39
+ }
40
+ /**
41
+ * Root platform instance: agent identity, analytics, and feature modules.
42
+ * Represents the runtime context for this agent at this API.
43
+ */
44
+ /** Subset of agent widget branding merged from public config (`widget_ui` / `primary_color`). */
45
+ type FirstflowWidgetUi = Readonly<{
46
+ primaryColor?: string;
47
+ }>;
48
+ interface FirstflowInstance {
49
+ readonly agentId: string;
50
+ /** Fixed public API base URL used for config, audience, and overrides (see `FIRSTFLOW_PUBLIC_API_BASE_URL`). */
51
+ readonly apiUrl: string;
52
+ /**
53
+ * Brand color hints for embedded UI (e.g. announcement primary buttons).
54
+ * Populated from agent config when the API returns `widget_ui` or `primary_color`.
55
+ */
56
+ getWidgetUi(): FirstflowWidgetUi | null;
57
+ analytics: AnalyticsModulePublic;
58
+ issue: IssueModulePublic;
59
+ feedback: FeedbackModulePublic;
60
+ survey: SurveyModulePublic;
61
+ getUser(): UserContext | null;
62
+ setUser(user: UserContext | null): void;
63
+ /**
64
+ * Merge segment membership values into runtime state.
65
+ * Only `true` grants membership; missing IDs or non-true values are treated as not a member.
66
+ */
67
+ setAudienceMembership(map: AudienceMembershipMap): void;
68
+ getAudienceMembership(): AudienceMembershipMap;
69
+ refreshConfig(): Promise<void>;
70
+ reset(): void;
71
+ }
72
+ /**
73
+ * Raw issues config as received from API (e.g. agent.issues_config).
74
+ */
75
+ interface RawIssueFieldConfig {
76
+ id?: string;
77
+ allowed?: boolean;
78
+ label?: string;
79
+ type?: "text" | "textarea" | "select";
80
+ required?: boolean;
81
+ options?: string[];
82
+ }
83
+ interface RawIssuesConfig {
84
+ enabled?: boolean;
85
+ title?: string;
86
+ triggerLabel?: string;
87
+ submitLabel?: string;
88
+ cancelLabel?: string;
89
+ cancelEnabled?: boolean;
90
+ promptText?: string;
91
+ fields?: RawIssueFieldConfig[];
92
+ }
93
+ interface RawFeedbackFormConfig {
94
+ tags?: string[];
95
+ placeholder?: string;
96
+ showTags?: boolean;
97
+ showComment?: boolean;
98
+ /** Message shown to the user after they submit feedback (or immediately when no form is shown). */
99
+ confirmationMessage?: string;
100
+ }
101
+ interface RawFeedbackConfig {
102
+ enabled?: boolean;
103
+ like?: RawFeedbackFormConfig;
104
+ dislike?: RawFeedbackFormConfig;
105
+ }
106
+ interface NormalizedFeedbackFormConfig {
107
+ tags: string[];
108
+ placeholder: string;
109
+ showTags: boolean;
110
+ showComment: boolean;
111
+ /** Message shown after feedback is given. */
112
+ confirmationMessage: string;
113
+ }
114
+ interface NormalizedFeedbackConfig {
115
+ enabled: boolean;
116
+ like: NormalizedFeedbackFormConfig;
117
+ dislike: NormalizedFeedbackFormConfig;
118
+ }
119
+ interface MessageFeedbackSubmitPayload {
120
+ conversationId: string;
121
+ messageId: string;
122
+ rating: "like" | "dislike";
123
+ /** Used by MessageFeedback UI only; not sent as analytics event fields. */
124
+ tags?: string[];
125
+ comment?: string;
126
+ /** Mirrors config: whether tags/comment were enabled for this sentiment at submit time. */
127
+ showTags?: boolean;
128
+ showComment?: boolean;
129
+ messagePreview?: string;
130
+ /**
131
+ * Arbitrary JSON-serializable key/value bag (e.g. locale, page_url, model, experiment_id).
132
+ * Sent on the analytics payload as property `metadata` after JSON round-trip (max ~32KB serialized).
133
+ */
134
+ metadata?: Record<string, unknown>;
135
+ }
136
+ interface FeedbackModulePublic {
137
+ submit(payload: MessageFeedbackSubmitPayload): Promise<void>;
138
+ getConfig(): NormalizedFeedbackConfig;
139
+ isEnabled(): boolean;
140
+ }
141
+ type SurveyQuestionType = 'nps' | 'multiple_choice' | 'slider' | 'opinion_scale' | 'open_question' | 'concept_test' | 'interview_prompt' | 'text_block' | 'thank_you';
142
+ type SurveyScaleType = 'numbers' | 'stars' | 'emojis';
143
+ type SurveyAnswerValue = string | number | string[] | null;
144
+ interface SurveyQuestion {
145
+ id: string;
146
+ nodeId: string;
147
+ type: SurveyQuestionType;
148
+ questionText: string;
149
+ required: boolean;
150
+ options?: string[];
151
+ minValue?: number;
152
+ maxValue?: number;
153
+ minLabel?: string;
154
+ maxLabel?: string;
155
+ step?: number;
156
+ scaleType?: SurveyScaleType;
157
+ placeholder?: string;
158
+ multiline?: boolean;
159
+ /** thank_you: confetti when true or unset; set false to disable. */
160
+ showConfetti?: boolean;
161
+ }
162
+ interface SurveyExperience {
163
+ experienceId: string;
164
+ name?: string | null;
165
+ status?: string | null;
166
+ settings?: ExperienceSettings | null;
167
+ questions: SurveyQuestion[];
168
+ }
169
+ type ExperienceSettings = {
170
+ trigger: {
171
+ show_on: 'chat_opens' | 'after_user_message' | 'after_idle' | 'custom_event';
172
+ custom_event_name?: string;
173
+ /** Idle delay in seconds (when show_on is "after_idle"). 0-300. */
174
+ delay_seconds?: number;
175
+ };
176
+ device: 'all' | 'desktop' | 'mobile';
177
+ audience: AudienceConfig;
178
+ schedule: {
179
+ start_type: 'now' | 'scheduled';
180
+ starts_at?: string;
181
+ timezone?: string;
182
+ expiration_type: 'none' | 'scheduled';
183
+ expires_at?: string;
184
+ };
185
+ frequency: {
186
+ type: 'once' | 'limited' | 'always';
187
+ limit?: number;
188
+ period?: 'session' | 'day' | 'week' | 'lifetime';
189
+ };
190
+ priority: number;
191
+ };
192
+ type RuleOperator = 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'in' | 'not_in' | 'gt' | 'gte' | 'lt' | 'lte' | 'exists' | 'not_exists';
193
+ interface AudienceRule {
194
+ trait: string;
195
+ operator: RuleOperator;
196
+ value?: unknown;
197
+ }
198
+ type AudienceConfig = {
199
+ type: 'all';
200
+ } | {
201
+ type: 'segment';
202
+ segment_id?: string;
203
+ } | {
204
+ type: 'rules';
205
+ operator: 'AND' | 'OR';
206
+ rules: AudienceRule[];
207
+ };
208
+ interface SurveySubmitPayload {
209
+ experienceId: string;
210
+ conversationId?: string;
211
+ answers: Record<string, SurveyAnswerValue>;
212
+ metadata?: Record<string, unknown>;
213
+ }
214
+ interface SurveyModulePublic {
215
+ getSurveys(): SurveyExperience[];
216
+ getSurvey(experienceId: string): SurveyExperience | null;
217
+ setExperiences(experiences: unknown[] | null | undefined): void;
218
+ isEnabled(experienceId?: string): boolean;
219
+ submit(payload: SurveySubmitPayload): Promise<void>;
220
+ }
221
+ /**
222
+ * Normalized field config used internally (after filtering allowed, defaulting type/label).
223
+ */
224
+ interface NormalizedFieldConfig {
225
+ id: string;
226
+ type: "text" | "textarea" | "select";
227
+ label: string;
228
+ required: boolean;
229
+ options?: string[];
230
+ }
231
+ /**
232
+ * Normalized config: single source of truth for the SDK.
233
+ */
234
+ interface NormalizedConfig {
235
+ agentId: string;
236
+ apiUrl: string;
237
+ enabled: boolean;
238
+ title: string;
239
+ triggerLabel: string;
240
+ submitLabel: string;
241
+ cancelLabel: string;
242
+ cancelEnabled: boolean;
243
+ promptText: string;
244
+ fields: NormalizedFieldConfig[];
245
+ }
246
+ /**
247
+ * Form field values only (keys = field ids). Validated before submit.
248
+ * Validation applies to this only.
249
+ */
250
+ type IssueFormValues = Record<string, string | undefined>;
251
+ /**
252
+ * Context metadata: set programmatically (e.g. open({ messageId })). Never validated.
253
+ * Merged with form values at submit time. Users can add arbitrary JSON-serializable keys/values.
254
+ */
255
+ type IssueContextMetadata = {
256
+ conversationId?: string;
257
+ messageId?: string;
258
+ sessionId?: string;
259
+ agentId?: string;
260
+ model?: string;
261
+ } & Record<string, unknown>;
262
+ /**
263
+ * Options passed to open() (e.g. "Report this response").
264
+ */
265
+ type OpenOptions = IssueContextMetadata;
266
+ /**
267
+ * Final submission payload: form values + context metadata. Sent to transport.
268
+ * Values can be primitives (form fields) or arbitrary JSON-serializable metadata.
269
+ */
270
+ type IssuePayload = Record<string, unknown>;
271
+ /**
272
+ * Options for createIssueReporter. Config is optional; when omitted, defaults are used.
273
+ * When analytics is omitted, a default analytics instance is created (same default collector settings).
274
+ */
275
+ interface CreateIssueReporterOptions {
276
+ agentId: string;
277
+ apiUrl: string;
278
+ config?: Partial<RawIssuesConfig>;
279
+ /** Platform analytics; issue module calls analytics.track('issue_submitted', payload). Defaults to createAnalytics({ agentId }) when omitted. */
280
+ analytics?: AnalyticsModulePublic;
281
+ }
282
+ /**
283
+ * Validation result.
284
+ */
285
+ interface ValidationResult {
286
+ valid: boolean;
287
+ errors?: Record<string, string>;
288
+ }
289
+ type IssueReportData = Record<string, unknown>;
290
+ /**
291
+ * Instance returned by createIssueReporter.
292
+ * setConfig is used internally when config is loaded asynchronously.
293
+ */
294
+ interface IssueReporterInstance {
295
+ getConfig(): NormalizedConfig;
296
+ setConfig(config: NormalizedConfig): void;
297
+ reportIssue(data: IssueReportData): Promise<void>;
298
+ open(options?: OpenOptions): void;
299
+ setOpenHandler(handler: ((options?: OpenOptions) => void) | undefined): void;
300
+ destroy(): void;
301
+ }
302
+
303
+ /**
304
+ * Platform event names. Feature modules use these when calling analytics.track().
305
+ * Do not rename existing events (e.g. issue_submitted) to avoid breaking pipelines.
306
+ */
307
+ /** Issue module — backward compatible */
308
+ declare const ISSUE_SUBMITTED = "issue_submitted";
309
+ /** Future modules */
310
+ declare const FEEDBACK_SUBMITTED = "feedback_submitted";
311
+ declare const SURVEY_COMPLETED = "survey_completed";
312
+ declare const EXPERIENCE_SHOWN = "experience_shown";
313
+ declare const EXPERIENCE_CLICKED = "experience_clicked";
314
+ declare const CHAT_MESSAGE_SENT = "chat_message_sent";
315
+ /**
316
+ * `experience_type` on `experience_shown` / `experience_clicked` — stable for ClickHouse / dashboards.
317
+ * Surfaces which product surface fired the event alongside `experience_id` / `node_id`.
318
+ */
319
+ declare const EXPERIENCE_ANALYTICS_TYPE: {
320
+ readonly FLOW_MESSAGE: "flow_message";
321
+ readonly FLOW_ANNOUNCEMENT: "flow_announcement";
322
+ readonly SURVEY: "survey";
323
+ };
324
+
325
+ export { type AudienceMembershipMap as A, ISSUE_SUBMITTED as B, type CreateFirstflowOptions as C, type IssueModulePublic as D, type ExperienceSettings as E, type FirstflowInstance as F, type IssueFormValues as I, type MessageFeedbackSubmitPayload as M, type NormalizedFeedbackConfig as N, type OpenOptions as O, type RawIssuesConfig as R, type SurveySubmitPayload as S, type UserContext as U, type ValidationResult as V, type RawFeedbackConfig as a, type SurveyQuestion as b, type SurveyAnswerValue as c, type SurveyModulePublic as d, type AnalyticsModulePublic as e, type AudienceConfig as f, type AudienceRule as g, CHAT_MESSAGE_SENT as h, EXPERIENCE_ANALYTICS_TYPE as i, EXPERIENCE_CLICKED as j, EXPERIENCE_SHOWN as k, type FirstflowWidgetUi as l, type RuleOperator as m, SURVEY_COMPLETED as n, type SurveyExperience as o, type NormalizedFeedbackFormConfig as p, type FeedbackModulePublic as q, type NormalizedConfig as r, type NormalizedFieldConfig as s, type IssueContextMetadata as t, type IssuePayload as u, type RawIssueFieldConfig as v, type IssueReporterInstance as w, type IssueReportData as x, type CreateIssueReporterOptions as y, FEEDBACK_SUBMITTED as z };