@h-ai/feedback 0.1.0-alpha.73 → 0.1.0-alpha.75

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/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import * as _h_ai_core from '@h-ai/core';
3
3
  import { HaiResult, PaginatedResult } from '@h-ai/core';
4
- import { FeedbackBudget, FeedbackSubmitInput, FeedbackReport, FeedbackListInput, FeedbackDetail, FeedbackEvidenceQuery, FeedbackEvidence, FeedbackSetStatusInput, FeedbackAppendEvidenceInput, FeedbackCompleteInput, FeedbackUploadInput, FeedbackAttachment, FeedbackAttachmentData, FeedbackRetryInput, FeedbackExportInput, FeedbackJob } from '@h-ai/api-contract/feedback';
4
+ import { FeedbackEvidenceInput, FeedbackReport, FeedbackBudget, FeedbackSubmitInput, FeedbackListInput, FeedbackDetail, FeedbackEvidenceQuery, FeedbackEvidence, FeedbackSetStatusInput, FeedbackAppendEvidenceInput, FeedbackCompleteInput, FeedbackUploadInput, FeedbackAttachment, FeedbackAttachmentData, FeedbackRetryInput, FeedbackExportInput, FeedbackJob } from '@h-ai/api-contract/feedback';
5
5
  export { FeedbackAppendEvidenceInput, FeedbackAttachment, FeedbackAttachmentData, FeedbackCompleteInput, FeedbackDetail, FeedbackEvidence, FeedbackEvidenceQuery, FeedbackExportInput, FeedbackJob, FeedbackListInput, FeedbackReport, FeedbackRetryInput, FeedbackSetStatusInput, FeedbackSubmitInput, FeedbackUploadInput } from '@h-ai/api-contract/feedback';
6
6
 
7
7
  /**
@@ -23,14 +23,27 @@ declare const FeedbackConfigSchema: z.ZodObject<{
23
23
  console: "console";
24
24
  reach: "reach";
25
25
  }>>;
26
+ consoleContent: z.ZodDefault<z.ZodEnum<{
27
+ metadata: "metadata";
28
+ summary: "summary";
29
+ }>>;
26
30
  recipients: z.ZodDefault<z.ZodArray<z.ZodString>>;
27
31
  notificationProvider: z.ZodDefault<z.ZodString>;
28
32
  adminUrl: z.ZodOptional<z.ZodURL>;
29
33
  collectionTimeoutMs: z.ZodDefault<z.ZodNumber>;
34
+ businessCollectionTimeoutMs: z.ZodDefault<z.ZodNumber>;
35
+ webhookUrl: z.ZodDefault<z.ZodString>;
36
+ webhookSecret: z.ZodDefault<z.ZodString>;
37
+ webhookTimeoutMs: z.ZodDefault<z.ZodNumber>;
30
38
  workerIntervalMs: z.ZodDefault<z.ZodNumber>;
31
39
  leaseMs: z.ZodDefault<z.ZodNumber>;
32
40
  maxAttempts: z.ZodDefault<z.ZodNumber>;
33
41
  retentionDays: z.ZodDefault<z.ZodNumber>;
42
+ maxReportsPerUserDay: z.ZodDefault<z.ZodNumber>;
43
+ maxBytesPerUserDay: z.ZodDefault<z.ZodNumber>;
44
+ maxStoredBytesPerScope: z.ZodDefault<z.ZodNumber>;
45
+ maxExportsPerReport: z.ZodDefault<z.ZodNumber>;
46
+ exportRetentionHours: z.ZodDefault<z.ZodNumber>;
34
47
  envAllowlist: z.ZodDefault<z.ZodArray<z.ZodString>>;
35
48
  maxTotalBytes: z.ZodDefault<z.ZodNumber>;
36
49
  maxAttachmentBytes: z.ZodDefault<z.ZodNumber>;
@@ -78,6 +91,7 @@ declare const HaiFeedbackError: {
78
91
  LIMIT_EXCEEDED: _h_ai_core.HaiErrorDef;
79
92
  INVALID_INPUT: _h_ai_core.HaiErrorDef;
80
93
  CHECKSUM_MISMATCH: _h_ai_core.HaiErrorDef;
94
+ QUOTA_EXCEEDED: _h_ai_core.HaiErrorDef;
81
95
  };
82
96
  /**
83
97
  * 由可信服务端认证与授权策略生成的范围;HTTP 输入不能指定此对象。
@@ -93,6 +107,71 @@ interface FeedbackContext {
93
107
  userId: string;
94
108
  permissions?: readonly string[];
95
109
  }
110
+ /**
111
+ * 业务采集附件;ID 在同一反馈内稳定,正文由框架计算校验和并写入私有存储。
112
+ * @example
113
+ * ```ts
114
+ * import type { FeedbackCollectedAttachment } from '@h-ai/feedback'
115
+ * const file: FeedbackCollectedAttachment = { id: 'logs', name: 'logs.txt', contentType: 'text/plain', bytes: new TextEncoder().encode('diagnostics') }
116
+ * void file
117
+ * ```
118
+ */
119
+ interface FeedbackCollectedAttachment {
120
+ id: string;
121
+ name: string;
122
+ contentType: string;
123
+ bytes: Uint8Array;
124
+ }
125
+ /**
126
+ * 业务补充材料;短文本/结构化信息出现在 business 证据,完整日志使用附件。
127
+ * @example
128
+ * ```ts
129
+ * import type { FeedbackCollectedEvidence } from '@h-ai/feedback'
130
+ * const evidence: FeedbackCollectedEvidence = { text: 'Order diagnostics', data: { orderId: 'order-1' } }
131
+ * void evidence
132
+ * ```
133
+ */
134
+ interface FeedbackCollectedEvidence {
135
+ text?: string;
136
+ data?: FeedbackEvidenceInput['data'];
137
+ attachments?: FeedbackCollectedAttachment[];
138
+ }
139
+ /**
140
+ * 采集扩展在持久任务中执行并等待异步结果;可能重试,宿主应按 report.id 幂等并响应 signal。
141
+ * @example
142
+ * ```ts
143
+ * import type { FeedbackInitOptions } from '@h-ai/feedback'
144
+ * const options: FeedbackInitOptions = { collectEvidence: async ({ report, signal }) => { signal.throwIfAborted(); return { text: report.number } } }
145
+ * void options
146
+ * ```
147
+ */
148
+ interface FeedbackInitOptions {
149
+ collectEvidence?: (context: {
150
+ report: Readonly<FeedbackReport>;
151
+ signal: AbortSignal;
152
+ }) => FeedbackCollectedEvidence | Promise<FeedbackCollectedEvidence>;
153
+ }
154
+ /**
155
+ * 采集结束后发送的 feedback.created 事件;eventId 跨重试稳定,附件正文通过受权 API 读取。
156
+ * @example
157
+ * ```ts
158
+ * import type { FeedbackWebhookEvent } from '@h-ai/feedback'
159
+ * function eventKey(event: FeedbackWebhookEvent) { return event.eventId }
160
+ * void eventKey
161
+ * ```
162
+ */
163
+ interface FeedbackWebhookEvent {
164
+ event: 'feedback.created';
165
+ eventId: string;
166
+ createdAt: number;
167
+ report: FeedbackReport;
168
+ evidence: {
169
+ revision: number;
170
+ business: boolean;
171
+ attachments: FeedbackAttachment[];
172
+ };
173
+ detailUrl?: string;
174
+ }
96
175
  /**
97
176
  * 反馈服务对象;领域操作返回 HaiResult,close 不释放宿主依赖连接。
98
177
  * @example
@@ -106,7 +185,7 @@ interface FeedbackContext {
106
185
  * ```
107
186
  */
108
187
  interface FeedbackFunctions {
109
- init: (config: FeedbackConfigInput) => Promise<HaiResult<void>>;
188
+ init: (config: FeedbackConfigInput, options?: FeedbackInitOptions) => Promise<HaiResult<void>>;
110
189
  close: () => Promise<HaiResult<void>>;
111
190
  readonly isInitialized: boolean;
112
191
  readonly config: FeedbackConfig | null;
@@ -158,4 +237,4 @@ interface FeedbackFunctions {
158
237
  */
159
238
  declare const feedback: FeedbackFunctions;
160
239
 
161
- export { type FeedbackConfig, type FeedbackConfigInput, FeedbackConfigSchema, type FeedbackContext, type FeedbackFunctions, HaiFeedbackError, feedback };
240
+ export { type FeedbackCollectedAttachment, type FeedbackCollectedEvidence, type FeedbackConfig, type FeedbackConfigInput, FeedbackConfigSchema, type FeedbackContext, type FeedbackFunctions, type FeedbackInitOptions, type FeedbackWebhookEvent, HaiFeedbackError, feedback };