@rhei-team/rhei 1.0.0-beta.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 (30) hide show
  1. package/README.md +1048 -0
  2. package/bin/rhei-mcp.js +3 -0
  3. package/dist/index.d.ts +12 -0
  4. package/dist/index.js +86366 -0
  5. package/dist/premium/contracts.d.ts +445 -0
  6. package/dist/premium/contracts.js +97 -0
  7. package/dist/vendor/rhei-core/briefs.js +1276 -0
  8. package/dist/vendor/rhei-core/codeAgent.js +615 -0
  9. package/dist/vendor/rhei-core/codeEditSession.js +293 -0
  10. package/dist/vendor/rhei-core/codeIntelligence.js +4287 -0
  11. package/dist/vendor/rhei-core/codeMarket.js +8946 -0
  12. package/dist/vendor/rhei-core/codeReviewIntelligence.js +5918 -0
  13. package/dist/vendor/rhei-core/codeSemantics.js +172427 -0
  14. package/dist/vendor/rhei-core/codeStory.js +667 -0
  15. package/dist/vendor/rhei-core/codeStrategyPlan.js +663 -0
  16. package/dist/vendor/rhei-core/codeTrail.js +2781 -0
  17. package/dist/vendor/rhei-core/codeWorkHandoff.js +281 -0
  18. package/dist/vendor/rhei-core/contextQuery.js +1119 -0
  19. package/dist/vendor/rhei-core/contextRouting.js +2052 -0
  20. package/dist/vendor/rhei-core/evidenceLedger.js +5336 -0
  21. package/dist/vendor/rhei-core/executionSafety.js +0 -0
  22. package/dist/vendor/rhei-core/goalIntelligence.js +2218 -0
  23. package/dist/vendor/rhei-core/model-lanes.js +75 -0
  24. package/dist/vendor/rhei-core/now.js +127 -0
  25. package/dist/vendor/rhei-core/package.json +29 -0
  26. package/dist/vendor/rhei-core/programPlan.js +3153 -0
  27. package/dist/vendor/rhei-core/search.js +196 -0
  28. package/dist/vendor/rhei-core/serviceIntelligence.js +1734 -0
  29. package/dist/vendor/rhei-core/workflowPlan.js +1660 -0
  30. package/package.json +41 -0
@@ -0,0 +1,445 @@
1
+ import { z } from "zod/v3";
2
+ export declare const RHEI_PREMIUM_FEATURES: readonly ["premium_context_rerank", "premium_graph_expand", "premium_service_enrichment", "premium_drift_signals"];
3
+ export type RheiPremiumFeatureV1 = typeof RHEI_PREMIUM_FEATURES[number];
4
+ export type RheiPremiumModeV1 = "off" | "auto" | "required";
5
+ export type RheiSourceUploadModeV1 = "never" | "metadata_only" | "selected_slices";
6
+ export declare const RHEI_PREMIUM_MODE_VALUES: readonly ["off", "auto", "required"];
7
+ export declare const RHEI_SOURCE_UPLOAD_MODE_VALUES: readonly ["never", "metadata_only", "selected_slices"];
8
+ export declare const RheiPremiumFeatureV1Schema: z.ZodEnum<["premium_context_rerank", "premium_graph_expand", "premium_service_enrichment", "premium_drift_signals"]>;
9
+ export declare const RheiPremiumModeV1Schema: z.ZodEnum<["off", "auto", "required"]>;
10
+ export declare const RheiSourceUploadModeV1Schema: z.ZodEnum<["never", "metadata_only", "selected_slices"]>;
11
+ export declare const RheiLicenseStatusV1Schema: z.ZodObject<{
12
+ kind: z.ZodLiteral<"RheiLicenseStatusV1">;
13
+ schemaVersion: z.ZodLiteral<1>;
14
+ status: z.ZodEnum<["anonymous", "authenticated_free", "entitled", "not_entitled", "expired", "rate_limited", "unreachable"]>;
15
+ tenantId: z.ZodOptional<z.ZodString>;
16
+ accountId: z.ZodOptional<z.ZodString>;
17
+ enabledFeatures: z.ZodArray<z.ZodEnum<["premium_context_rerank", "premium_graph_expand", "premium_service_enrichment", "premium_drift_signals"]>, "many">;
18
+ expiresAt: z.ZodOptional<z.ZodString>;
19
+ checkedAt: z.ZodString;
20
+ serverTraceId: z.ZodOptional<z.ZodString>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ kind: "RheiLicenseStatusV1";
23
+ schemaVersion: 1;
24
+ status: "expired" | "anonymous" | "authenticated_free" | "entitled" | "not_entitled" | "rate_limited" | "unreachable";
25
+ checkedAt: string;
26
+ enabledFeatures: ("premium_context_rerank" | "premium_graph_expand" | "premium_service_enrichment" | "premium_drift_signals")[];
27
+ expiresAt?: string | undefined;
28
+ tenantId?: string | undefined;
29
+ accountId?: string | undefined;
30
+ serverTraceId?: string | undefined;
31
+ }, {
32
+ kind: "RheiLicenseStatusV1";
33
+ schemaVersion: 1;
34
+ status: "expired" | "anonymous" | "authenticated_free" | "entitled" | "not_entitled" | "rate_limited" | "unreachable";
35
+ checkedAt: string;
36
+ enabledFeatures: ("premium_context_rerank" | "premium_graph_expand" | "premium_service_enrichment" | "premium_drift_signals")[];
37
+ expiresAt?: string | undefined;
38
+ tenantId?: string | undefined;
39
+ accountId?: string | undefined;
40
+ serverTraceId?: string | undefined;
41
+ }>;
42
+ export type RheiLicenseStatusV1 = z.infer<typeof RheiLicenseStatusV1Schema>;
43
+ export declare const RheiPremiumTrialStartResponseV1Schema: z.ZodObject<{
44
+ kind: z.ZodLiteral<"RheiPremiumTrialStartResponseV1">;
45
+ schemaVersion: z.ZodLiteral<1>;
46
+ status: z.ZodEnum<["ok", "not_authenticated", "unavailable"]>;
47
+ created: z.ZodOptional<z.ZodBoolean>;
48
+ expiresAt: z.ZodOptional<z.ZodString>;
49
+ license: z.ZodOptional<z.ZodObject<{
50
+ kind: z.ZodLiteral<"RheiLicenseStatusV1">;
51
+ schemaVersion: z.ZodLiteral<1>;
52
+ status: z.ZodEnum<["anonymous", "authenticated_free", "entitled", "not_entitled", "expired", "rate_limited", "unreachable"]>;
53
+ tenantId: z.ZodOptional<z.ZodString>;
54
+ accountId: z.ZodOptional<z.ZodString>;
55
+ enabledFeatures: z.ZodArray<z.ZodEnum<["premium_context_rerank", "premium_graph_expand", "premium_service_enrichment", "premium_drift_signals"]>, "many">;
56
+ expiresAt: z.ZodOptional<z.ZodString>;
57
+ checkedAt: z.ZodString;
58
+ serverTraceId: z.ZodOptional<z.ZodString>;
59
+ }, "strip", z.ZodTypeAny, {
60
+ kind: "RheiLicenseStatusV1";
61
+ schemaVersion: 1;
62
+ status: "expired" | "anonymous" | "authenticated_free" | "entitled" | "not_entitled" | "rate_limited" | "unreachable";
63
+ checkedAt: string;
64
+ enabledFeatures: ("premium_context_rerank" | "premium_graph_expand" | "premium_service_enrichment" | "premium_drift_signals")[];
65
+ expiresAt?: string | undefined;
66
+ tenantId?: string | undefined;
67
+ accountId?: string | undefined;
68
+ serverTraceId?: string | undefined;
69
+ }, {
70
+ kind: "RheiLicenseStatusV1";
71
+ schemaVersion: 1;
72
+ status: "expired" | "anonymous" | "authenticated_free" | "entitled" | "not_entitled" | "rate_limited" | "unreachable";
73
+ checkedAt: string;
74
+ enabledFeatures: ("premium_context_rerank" | "premium_graph_expand" | "premium_service_enrichment" | "premium_drift_signals")[];
75
+ expiresAt?: string | undefined;
76
+ tenantId?: string | undefined;
77
+ accountId?: string | undefined;
78
+ serverTraceId?: string | undefined;
79
+ }>>;
80
+ serverTraceId: z.ZodOptional<z.ZodString>;
81
+ advisoryOnly: z.ZodOptional<z.ZodLiteral<true>>;
82
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
83
+ }, "strip", z.ZodTypeAny, {
84
+ kind: "RheiPremiumTrialStartResponseV1";
85
+ schemaVersion: 1;
86
+ status: "unavailable" | "ok" | "not_authenticated";
87
+ advisoryOnly?: true | undefined;
88
+ warnings?: string[] | undefined;
89
+ created?: boolean | undefined;
90
+ expiresAt?: string | undefined;
91
+ serverTraceId?: string | undefined;
92
+ license?: {
93
+ kind: "RheiLicenseStatusV1";
94
+ schemaVersion: 1;
95
+ status: "expired" | "anonymous" | "authenticated_free" | "entitled" | "not_entitled" | "rate_limited" | "unreachable";
96
+ checkedAt: string;
97
+ enabledFeatures: ("premium_context_rerank" | "premium_graph_expand" | "premium_service_enrichment" | "premium_drift_signals")[];
98
+ expiresAt?: string | undefined;
99
+ tenantId?: string | undefined;
100
+ accountId?: string | undefined;
101
+ serverTraceId?: string | undefined;
102
+ } | undefined;
103
+ }, {
104
+ kind: "RheiPremiumTrialStartResponseV1";
105
+ schemaVersion: 1;
106
+ status: "unavailable" | "ok" | "not_authenticated";
107
+ advisoryOnly?: true | undefined;
108
+ warnings?: string[] | undefined;
109
+ created?: boolean | undefined;
110
+ expiresAt?: string | undefined;
111
+ serverTraceId?: string | undefined;
112
+ license?: {
113
+ kind: "RheiLicenseStatusV1";
114
+ schemaVersion: 1;
115
+ status: "expired" | "anonymous" | "authenticated_free" | "entitled" | "not_entitled" | "rate_limited" | "unreachable";
116
+ checkedAt: string;
117
+ enabledFeatures: ("premium_context_rerank" | "premium_graph_expand" | "premium_service_enrichment" | "premium_drift_signals")[];
118
+ expiresAt?: string | undefined;
119
+ tenantId?: string | undefined;
120
+ accountId?: string | undefined;
121
+ serverTraceId?: string | undefined;
122
+ } | undefined;
123
+ }>;
124
+ export type RheiPremiumTrialStartResponseV1 = z.infer<typeof RheiPremiumTrialStartResponseV1Schema>;
125
+ export declare const RheiPremiumContextPlanRequestV1Schema: z.ZodObject<{
126
+ kind: z.ZodLiteral<"RheiPremiumContextPlanRequestV1">;
127
+ schemaVersion: z.ZodLiteral<1>;
128
+ feature: z.ZodEnum<["premium_context_rerank", "premium_graph_expand", "premium_service_enrichment", "premium_drift_signals"]>;
129
+ client: z.ZodObject<{
130
+ packageName: z.ZodEnum<["@rhei-team/mcp-server", "@rhei/mcp-server"]>;
131
+ packageVersion: z.ZodString;
132
+ commandRunner: z.ZodOptional<z.ZodEnum<["npm", "npx", "bunx", "pnpm", "pnpm_dlx", "local", "unknown"]>>;
133
+ capabilities: z.ZodArray<z.ZodString, "many">;
134
+ }, "strip", z.ZodTypeAny, {
135
+ capabilities: string[];
136
+ packageName: "@rhei-team/mcp-server" | "@rhei/mcp-server";
137
+ packageVersion: string;
138
+ commandRunner?: "unknown" | "local" | "npm" | "npx" | "bunx" | "pnpm" | "pnpm_dlx" | undefined;
139
+ }, {
140
+ capabilities: string[];
141
+ packageName: "@rhei-team/mcp-server" | "@rhei/mcp-server";
142
+ packageVersion: string;
143
+ commandRunner?: "unknown" | "local" | "npm" | "npx" | "bunx" | "pnpm" | "pnpm_dlx" | undefined;
144
+ }>;
145
+ repo: z.ZodObject<{
146
+ repoFingerprint: z.ZodString;
147
+ sourceEpochHash: z.ZodOptional<z.ZodString>;
148
+ indexFreshness: z.ZodOptional<z.ZodString>;
149
+ localSqlSchemaVersion: z.ZodOptional<z.ZodNumber>;
150
+ }, "strip", z.ZodTypeAny, {
151
+ repoFingerprint: string;
152
+ indexFreshness?: string | undefined;
153
+ sourceEpochHash?: string | undefined;
154
+ localSqlSchemaVersion?: number | undefined;
155
+ }, {
156
+ repoFingerprint: string;
157
+ indexFreshness?: string | undefined;
158
+ sourceEpochHash?: string | undefined;
159
+ localSqlSchemaVersion?: number | undefined;
160
+ }>;
161
+ privacy: z.ZodObject<{
162
+ sourceUpload: z.ZodEnum<["never", "metadata_only", "selected_slices"]>;
163
+ redactionPolicy: z.ZodEnum<["default_local", "none", "custom"]>;
164
+ maxBytes: z.ZodNumber;
165
+ }, "strip", z.ZodTypeAny, {
166
+ sourceUpload: "metadata_only" | "never" | "selected_slices";
167
+ redactionPolicy: "none" | "custom" | "default_local";
168
+ maxBytes: number;
169
+ }, {
170
+ sourceUpload: "metadata_only" | "never" | "selected_slices";
171
+ redactionPolicy: "none" | "custom" | "default_local";
172
+ maxBytes: number;
173
+ }>;
174
+ goal: z.ZodObject<{
175
+ text: z.ZodOptional<z.ZodString>;
176
+ responseType: z.ZodOptional<z.ZodString>;
177
+ targetAgent: z.ZodOptional<z.ZodString>;
178
+ tokenBudget: z.ZodOptional<z.ZodNumber>;
179
+ }, "strip", z.ZodTypeAny, {
180
+ tokenBudget?: number | undefined;
181
+ text?: string | undefined;
182
+ responseType?: string | undefined;
183
+ targetAgent?: string | undefined;
184
+ }, {
185
+ tokenBudget?: number | undefined;
186
+ text?: string | undefined;
187
+ responseType?: string | undefined;
188
+ targetAgent?: string | undefined;
189
+ }>;
190
+ localCandidates: z.ZodArray<z.ZodObject<{
191
+ path: z.ZodString;
192
+ contentHash: z.ZodOptional<z.ZodString>;
193
+ language: z.ZodOptional<z.ZodString>;
194
+ spans: z.ZodOptional<z.ZodArray<z.ZodObject<{
195
+ startLine: z.ZodNumber;
196
+ endLine: z.ZodNumber;
197
+ text: z.ZodOptional<z.ZodString>;
198
+ }, "strip", z.ZodTypeAny, {
199
+ startLine: number;
200
+ endLine: number;
201
+ text?: string | undefined;
202
+ }, {
203
+ startLine: number;
204
+ endLine: number;
205
+ text?: string | undefined;
206
+ }>, "many">>;
207
+ localReasonCodes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
208
+ }, "strip", z.ZodTypeAny, {
209
+ path: string;
210
+ language?: string | undefined;
211
+ contentHash?: string | undefined;
212
+ spans?: {
213
+ startLine: number;
214
+ endLine: number;
215
+ text?: string | undefined;
216
+ }[] | undefined;
217
+ localReasonCodes?: string[] | undefined;
218
+ }, {
219
+ path: string;
220
+ language?: string | undefined;
221
+ contentHash?: string | undefined;
222
+ spans?: {
223
+ startLine: number;
224
+ endLine: number;
225
+ text?: string | undefined;
226
+ }[] | undefined;
227
+ localReasonCodes?: string[] | undefined;
228
+ }>, "many">;
229
+ }, "strip", z.ZodTypeAny, {
230
+ kind: "RheiPremiumContextPlanRequestV1";
231
+ schemaVersion: 1;
232
+ goal: {
233
+ tokenBudget?: number | undefined;
234
+ text?: string | undefined;
235
+ responseType?: string | undefined;
236
+ targetAgent?: string | undefined;
237
+ };
238
+ privacy: {
239
+ sourceUpload: "metadata_only" | "never" | "selected_slices";
240
+ redactionPolicy: "none" | "custom" | "default_local";
241
+ maxBytes: number;
242
+ };
243
+ repo: {
244
+ repoFingerprint: string;
245
+ indexFreshness?: string | undefined;
246
+ sourceEpochHash?: string | undefined;
247
+ localSqlSchemaVersion?: number | undefined;
248
+ };
249
+ feature: "premium_context_rerank" | "premium_graph_expand" | "premium_service_enrichment" | "premium_drift_signals";
250
+ client: {
251
+ capabilities: string[];
252
+ packageName: "@rhei-team/mcp-server" | "@rhei/mcp-server";
253
+ packageVersion: string;
254
+ commandRunner?: "unknown" | "local" | "npm" | "npx" | "bunx" | "pnpm" | "pnpm_dlx" | undefined;
255
+ };
256
+ localCandidates: {
257
+ path: string;
258
+ language?: string | undefined;
259
+ contentHash?: string | undefined;
260
+ spans?: {
261
+ startLine: number;
262
+ endLine: number;
263
+ text?: string | undefined;
264
+ }[] | undefined;
265
+ localReasonCodes?: string[] | undefined;
266
+ }[];
267
+ }, {
268
+ kind: "RheiPremiumContextPlanRequestV1";
269
+ schemaVersion: 1;
270
+ goal: {
271
+ tokenBudget?: number | undefined;
272
+ text?: string | undefined;
273
+ responseType?: string | undefined;
274
+ targetAgent?: string | undefined;
275
+ };
276
+ privacy: {
277
+ sourceUpload: "metadata_only" | "never" | "selected_slices";
278
+ redactionPolicy: "none" | "custom" | "default_local";
279
+ maxBytes: number;
280
+ };
281
+ repo: {
282
+ repoFingerprint: string;
283
+ indexFreshness?: string | undefined;
284
+ sourceEpochHash?: string | undefined;
285
+ localSqlSchemaVersion?: number | undefined;
286
+ };
287
+ feature: "premium_context_rerank" | "premium_graph_expand" | "premium_service_enrichment" | "premium_drift_signals";
288
+ client: {
289
+ capabilities: string[];
290
+ packageName: "@rhei-team/mcp-server" | "@rhei/mcp-server";
291
+ packageVersion: string;
292
+ commandRunner?: "unknown" | "local" | "npm" | "npx" | "bunx" | "pnpm" | "pnpm_dlx" | undefined;
293
+ };
294
+ localCandidates: {
295
+ path: string;
296
+ language?: string | undefined;
297
+ contentHash?: string | undefined;
298
+ spans?: {
299
+ startLine: number;
300
+ endLine: number;
301
+ text?: string | undefined;
302
+ }[] | undefined;
303
+ localReasonCodes?: string[] | undefined;
304
+ }[];
305
+ }>;
306
+ export type RheiPremiumContextPlanRequestV1 = z.infer<typeof RheiPremiumContextPlanRequestV1Schema>;
307
+ export declare const RheiPremiumContextPlanResponseV1Schema: z.ZodObject<{
308
+ kind: z.ZodLiteral<"RheiPremiumContextPlanResponseV1">;
309
+ schemaVersion: z.ZodLiteral<1>;
310
+ status: z.ZodEnum<["ok", "degraded", "not_authenticated", "not_entitled", "rate_limited", "unavailable"]>;
311
+ license: z.ZodObject<{
312
+ kind: z.ZodLiteral<"RheiLicenseStatusV1">;
313
+ schemaVersion: z.ZodLiteral<1>;
314
+ status: z.ZodEnum<["anonymous", "authenticated_free", "entitled", "not_entitled", "expired", "rate_limited", "unreachable"]>;
315
+ tenantId: z.ZodOptional<z.ZodString>;
316
+ accountId: z.ZodOptional<z.ZodString>;
317
+ enabledFeatures: z.ZodArray<z.ZodEnum<["premium_context_rerank", "premium_graph_expand", "premium_service_enrichment", "premium_drift_signals"]>, "many">;
318
+ expiresAt: z.ZodOptional<z.ZodString>;
319
+ checkedAt: z.ZodString;
320
+ serverTraceId: z.ZodOptional<z.ZodString>;
321
+ }, "strip", z.ZodTypeAny, {
322
+ kind: "RheiLicenseStatusV1";
323
+ schemaVersion: 1;
324
+ status: "expired" | "anonymous" | "authenticated_free" | "entitled" | "not_entitled" | "rate_limited" | "unreachable";
325
+ checkedAt: string;
326
+ enabledFeatures: ("premium_context_rerank" | "premium_graph_expand" | "premium_service_enrichment" | "premium_drift_signals")[];
327
+ expiresAt?: string | undefined;
328
+ tenantId?: string | undefined;
329
+ accountId?: string | undefined;
330
+ serverTraceId?: string | undefined;
331
+ }, {
332
+ kind: "RheiLicenseStatusV1";
333
+ schemaVersion: 1;
334
+ status: "expired" | "anonymous" | "authenticated_free" | "entitled" | "not_entitled" | "rate_limited" | "unreachable";
335
+ checkedAt: string;
336
+ enabledFeatures: ("premium_context_rerank" | "premium_graph_expand" | "premium_service_enrichment" | "premium_drift_signals")[];
337
+ expiresAt?: string | undefined;
338
+ tenantId?: string | undefined;
339
+ accountId?: string | undefined;
340
+ serverTraceId?: string | undefined;
341
+ }>;
342
+ serverTraceId: z.ZodString;
343
+ advisoryOnly: z.ZodLiteral<true>;
344
+ rankedRefs: z.ZodOptional<z.ZodArray<z.ZodObject<{
345
+ path: z.ZodString;
346
+ rank: z.ZodNumber;
347
+ reasonCodes: z.ZodArray<z.ZodString, "many">;
348
+ evidenceRefs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
349
+ }, "strip", z.ZodTypeAny, {
350
+ path: string;
351
+ reasonCodes: string[];
352
+ rank: number;
353
+ evidenceRefs?: string[] | undefined;
354
+ }, {
355
+ path: string;
356
+ reasonCodes: string[];
357
+ rank: number;
358
+ evidenceRefs?: string[] | undefined;
359
+ }>, "many">>;
360
+ graphEvidence: z.ZodOptional<z.ZodUnknown>;
361
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
362
+ }, "strip", z.ZodTypeAny, {
363
+ kind: "RheiPremiumContextPlanResponseV1";
364
+ schemaVersion: 1;
365
+ advisoryOnly: true;
366
+ status: "unavailable" | "degraded" | "ok" | "not_entitled" | "rate_limited" | "not_authenticated";
367
+ serverTraceId: string;
368
+ license: {
369
+ kind: "RheiLicenseStatusV1";
370
+ schemaVersion: 1;
371
+ status: "expired" | "anonymous" | "authenticated_free" | "entitled" | "not_entitled" | "rate_limited" | "unreachable";
372
+ checkedAt: string;
373
+ enabledFeatures: ("premium_context_rerank" | "premium_graph_expand" | "premium_service_enrichment" | "premium_drift_signals")[];
374
+ expiresAt?: string | undefined;
375
+ tenantId?: string | undefined;
376
+ accountId?: string | undefined;
377
+ serverTraceId?: string | undefined;
378
+ };
379
+ warnings?: string[] | undefined;
380
+ graphEvidence?: unknown;
381
+ rankedRefs?: {
382
+ path: string;
383
+ reasonCodes: string[];
384
+ rank: number;
385
+ evidenceRefs?: string[] | undefined;
386
+ }[] | undefined;
387
+ }, {
388
+ kind: "RheiPremiumContextPlanResponseV1";
389
+ schemaVersion: 1;
390
+ advisoryOnly: true;
391
+ status: "unavailable" | "degraded" | "ok" | "not_entitled" | "rate_limited" | "not_authenticated";
392
+ serverTraceId: string;
393
+ license: {
394
+ kind: "RheiLicenseStatusV1";
395
+ schemaVersion: 1;
396
+ status: "expired" | "anonymous" | "authenticated_free" | "entitled" | "not_entitled" | "rate_limited" | "unreachable";
397
+ checkedAt: string;
398
+ enabledFeatures: ("premium_context_rerank" | "premium_graph_expand" | "premium_service_enrichment" | "premium_drift_signals")[];
399
+ expiresAt?: string | undefined;
400
+ tenantId?: string | undefined;
401
+ accountId?: string | undefined;
402
+ serverTraceId?: string | undefined;
403
+ };
404
+ warnings?: string[] | undefined;
405
+ graphEvidence?: unknown;
406
+ rankedRefs?: {
407
+ path: string;
408
+ reasonCodes: string[];
409
+ rank: number;
410
+ evidenceRefs?: string[] | undefined;
411
+ }[] | undefined;
412
+ }>;
413
+ export type RheiPremiumContextPlanResponseV1 = z.infer<typeof RheiPremiumContextPlanResponseV1Schema>;
414
+ export type RheiAuthStateV1 = {
415
+ kind: "RheiAuthStateV1";
416
+ schemaVersion: 1;
417
+ status: "signed_out" | "signed_in";
418
+ source: "env" | "local_store" | "none";
419
+ tokenPreview?: string;
420
+ };
421
+ export type RheiPremiumBoundaryV1 = {
422
+ kind: "RheiPremiumBoundaryV1";
423
+ schemaVersion: 1;
424
+ mode: RheiPremiumModeV1;
425
+ decision: "local_only" | "remote_allowed" | "blocked";
426
+ reason: "premium_off" | "missing_auth" | "not_entitled" | "source_upload_disabled" | "server_unreachable" | "rate_limited" | "allowed";
427
+ requestedFeature: RheiPremiumFeatureV1;
428
+ licenseStatus?: RheiLicenseStatusV1["status"];
429
+ serverTraceId?: string;
430
+ checkedAt?: string;
431
+ userMessage: string;
432
+ advisoryOnly: true;
433
+ };
434
+ export type RheiPremiumContextPlanProjectionV1 = {
435
+ kind: "RheiPremiumContextPlanProjectionV1";
436
+ schemaVersion: 1;
437
+ status: RheiPremiumContextPlanResponseV1["status"] | "skipped";
438
+ decision: RheiPremiumBoundaryV1["decision"];
439
+ reason: RheiPremiumBoundaryV1["reason"] | "premium_boundary_absent";
440
+ requestedFeature?: RheiPremiumFeatureV1;
441
+ serverTraceId?: string;
442
+ rankedRefs?: RheiPremiumContextPlanResponseV1["rankedRefs"];
443
+ warnings?: string[];
444
+ advisoryOnly: true;
445
+ };
@@ -0,0 +1,97 @@
1
+ import { z } from "zod/v3";
2
+ export const RHEI_PREMIUM_FEATURES = [
3
+ "premium_context_rerank",
4
+ "premium_graph_expand",
5
+ "premium_service_enrichment",
6
+ "premium_drift_signals",
7
+ ];
8
+ export const RHEI_PREMIUM_MODE_VALUES = ["off", "auto", "required"];
9
+ export const RHEI_SOURCE_UPLOAD_MODE_VALUES = ["never", "metadata_only", "selected_slices"];
10
+ export const RheiPremiumFeatureV1Schema = z.enum(RHEI_PREMIUM_FEATURES);
11
+ export const RheiPremiumModeV1Schema = z.enum(RHEI_PREMIUM_MODE_VALUES);
12
+ export const RheiSourceUploadModeV1Schema = z.enum(RHEI_SOURCE_UPLOAD_MODE_VALUES);
13
+ export const RheiLicenseStatusV1Schema = z.object({
14
+ kind: z.literal("RheiLicenseStatusV1"),
15
+ schemaVersion: z.literal(1),
16
+ status: z.enum([
17
+ "anonymous",
18
+ "authenticated_free",
19
+ "entitled",
20
+ "not_entitled",
21
+ "expired",
22
+ "rate_limited",
23
+ "unreachable",
24
+ ]),
25
+ tenantId: z.string().optional(),
26
+ accountId: z.string().optional(),
27
+ enabledFeatures: z.array(RheiPremiumFeatureV1Schema),
28
+ expiresAt: z.string().optional(),
29
+ checkedAt: z.string(),
30
+ serverTraceId: z.string().optional(),
31
+ });
32
+ export const RheiPremiumTrialStartResponseV1Schema = z.object({
33
+ kind: z.literal("RheiPremiumTrialStartResponseV1"),
34
+ schemaVersion: z.literal(1),
35
+ status: z.enum(["ok", "not_authenticated", "unavailable"]),
36
+ created: z.boolean().optional(),
37
+ expiresAt: z.string().optional(),
38
+ license: RheiLicenseStatusV1Schema.optional(),
39
+ serverTraceId: z.string().optional(),
40
+ advisoryOnly: z.literal(true).optional(),
41
+ warnings: z.array(z.string()).optional(),
42
+ });
43
+ export const RheiPremiumContextPlanRequestV1Schema = z.object({
44
+ kind: z.literal("RheiPremiumContextPlanRequestV1"),
45
+ schemaVersion: z.literal(1),
46
+ feature: RheiPremiumFeatureV1Schema,
47
+ client: z.object({
48
+ packageName: z.enum(["@rhei-team/mcp-server", "@rhei/mcp-server"]),
49
+ packageVersion: z.string(),
50
+ commandRunner: z.enum(["npm", "npx", "bunx", "pnpm", "pnpm_dlx", "local", "unknown"]).optional(),
51
+ capabilities: z.array(z.string()),
52
+ }),
53
+ repo: z.object({
54
+ repoFingerprint: z.string(),
55
+ sourceEpochHash: z.string().optional(),
56
+ indexFreshness: z.string().optional(),
57
+ localSqlSchemaVersion: z.number().optional(),
58
+ }),
59
+ privacy: z.object({
60
+ sourceUpload: RheiSourceUploadModeV1Schema,
61
+ redactionPolicy: z.enum(["default_local", "none", "custom"]),
62
+ maxBytes: z.number().nonnegative(),
63
+ }),
64
+ goal: z.object({
65
+ text: z.string().optional(),
66
+ responseType: z.string().optional(),
67
+ targetAgent: z.string().optional(),
68
+ tokenBudget: z.number().positive().optional(),
69
+ }),
70
+ localCandidates: z.array(z.object({
71
+ path: z.string(),
72
+ contentHash: z.string().optional(),
73
+ language: z.string().optional(),
74
+ spans: z.array(z.object({
75
+ startLine: z.number().int().positive(),
76
+ endLine: z.number().int().positive(),
77
+ text: z.string().optional(),
78
+ })).optional(),
79
+ localReasonCodes: z.array(z.string()).optional(),
80
+ })),
81
+ });
82
+ export const RheiPremiumContextPlanResponseV1Schema = z.object({
83
+ kind: z.literal("RheiPremiumContextPlanResponseV1"),
84
+ schemaVersion: z.literal(1),
85
+ status: z.enum(["ok", "degraded", "not_authenticated", "not_entitled", "rate_limited", "unavailable"]),
86
+ license: RheiLicenseStatusV1Schema,
87
+ serverTraceId: z.string(),
88
+ advisoryOnly: z.literal(true),
89
+ rankedRefs: z.array(z.object({
90
+ path: z.string(),
91
+ rank: z.number(),
92
+ reasonCodes: z.array(z.string()),
93
+ evidenceRefs: z.array(z.string()).optional(),
94
+ })).optional(),
95
+ graphEvidence: z.unknown().optional(),
96
+ warnings: z.array(z.string()).optional(),
97
+ });