@cstar.help/js 0.14.0 → 0.15.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.
@@ -20,8 +20,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/quickhelp/index.ts
21
21
  var quickhelp_exports = {};
22
22
  __export(quickhelp_exports, {
23
+ CStarAuthenticationError: () => CStarAuthenticationError,
24
+ CStarConflictError: () => CStarConflictError,
25
+ CStarError: () => CStarError,
26
+ CStarFeatureDisabledError: () => CStarFeatureDisabledError,
27
+ CStarNotFoundError: () => CStarNotFoundError,
28
+ CStarPermissionError: () => CStarPermissionError,
29
+ CStarRateLimitError: () => CStarRateLimitError,
30
+ CStarRealtimeUnavailableError: () => CStarRealtimeUnavailableError,
31
+ CStarServerError: () => CStarServerError,
32
+ CStarValidationError: () => CStarValidationError,
33
+ ErrorType: () => ErrorType,
23
34
  QuickHelpClient: () => QuickHelpClient,
24
- QuickHelpError: () => QuickHelpError
35
+ QuickHelpError: () => QuickHelpError,
36
+ parseError: () => parseError,
37
+ parsePublicError: () => parsePublicError
25
38
  });
26
39
  module.exports = __toCommonJS(quickhelp_exports);
27
40
 
@@ -62,7 +75,7 @@ function normalizeArgs(messageOrStatus, maybeBody, defaults) {
62
75
  }
63
76
  };
64
77
  }
65
- var CStarError = class extends Error {
78
+ var CStarErrorImpl = class extends Error {
66
79
  constructor(messageOrStatus, body) {
67
80
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body);
68
81
  super(resolved.message);
@@ -75,7 +88,7 @@ var CStarError = class extends Error {
75
88
  this.statusCode = statusCode;
76
89
  }
77
90
  };
78
- var CStarAuthenticationError = class extends CStarError {
91
+ var CStarAuthenticationErrorImpl = class extends CStarErrorImpl {
79
92
  constructor(messageOrStatus, body) {
80
93
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
81
94
  type: ErrorType.AUTHENTICATION_ERROR,
@@ -86,7 +99,7 @@ var CStarAuthenticationError = class extends CStarError {
86
99
  this.name = "CStarAuthenticationError";
87
100
  }
88
101
  };
89
- var CStarRateLimitError = class extends CStarError {
102
+ var CStarRateLimitErrorImpl = class extends CStarErrorImpl {
90
103
  constructor(messageOrStatus, body, retryAfter) {
91
104
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
92
105
  type: ErrorType.RATE_LIMIT_ERROR,
@@ -98,7 +111,7 @@ var CStarRateLimitError = class extends CStarError {
98
111
  this.retryAfter = retryAfter ?? 60;
99
112
  }
100
113
  };
101
- var CStarNotFoundError = class extends CStarError {
114
+ var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
102
115
  constructor(messageOrStatus, body) {
103
116
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
104
117
  type: ErrorType.NOT_FOUND_ERROR,
@@ -109,7 +122,7 @@ var CStarNotFoundError = class extends CStarError {
109
122
  this.name = "CStarNotFoundError";
110
123
  }
111
124
  };
112
- var CStarValidationError = class extends CStarError {
125
+ var CStarValidationErrorImpl = class extends CStarErrorImpl {
113
126
  constructor(messageOrStatus, body) {
114
127
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
115
128
  type: ErrorType.INVALID_REQUEST_ERROR,
@@ -120,7 +133,7 @@ var CStarValidationError = class extends CStarError {
120
133
  this.name = "CStarValidationError";
121
134
  }
122
135
  };
123
- var CStarPermissionError = class extends CStarError {
136
+ var CStarPermissionErrorImpl = class extends CStarErrorImpl {
124
137
  constructor(messageOrStatus, body) {
125
138
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
126
139
  type: ErrorType.PERMISSION_ERROR,
@@ -131,7 +144,7 @@ var CStarPermissionError = class extends CStarError {
131
144
  this.name = "CStarPermissionError";
132
145
  }
133
146
  };
134
- var CStarConflictError = class extends CStarError {
147
+ var CStarConflictErrorImpl = class extends CStarErrorImpl {
135
148
  constructor(messageOrStatus, body) {
136
149
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
137
150
  type: ErrorType.CONFLICT_ERROR,
@@ -142,7 +155,7 @@ var CStarConflictError = class extends CStarError {
142
155
  this.name = "CStarConflictError";
143
156
  }
144
157
  };
145
- var CStarServerError = class extends CStarError {
158
+ var CStarServerErrorImpl = class extends CStarErrorImpl {
146
159
  constructor(messageOrStatus, body) {
147
160
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
148
161
  type: ErrorType.SERVER_ERROR,
@@ -153,7 +166,7 @@ var CStarServerError = class extends CStarError {
153
166
  this.name = "CStarServerError";
154
167
  }
155
168
  };
156
- var CStarFeatureDisabledError = class extends CStarError {
169
+ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
157
170
  constructor(messageOrStatus, body) {
158
171
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
159
172
  type: ErrorType.FEATURE_NOT_CONFIGURED,
@@ -166,6 +179,82 @@ var CStarFeatureDisabledError = class extends CStarError {
166
179
  this.enableUrl = resolved.enable_url ?? "";
167
180
  }
168
181
  };
182
+ var CStarRealtimeUnavailableErrorImpl = class extends CStarErrorImpl {
183
+ constructor(message) {
184
+ const resolved = message ?? "EventSource is not available in this environment. Real-time subscriptions only work in the browser. Move the call to a client-only path (`useEffect` / `onMount`), or pass an `eventSource` polyfill via the realtime options. See https://cstar.help/developers/sdk/realtime#ssr";
185
+ super(0, {
186
+ type: ErrorType.API_ERROR,
187
+ code: "realtime_unavailable",
188
+ message: resolved,
189
+ doc_url: "https://cstar.help/developers/sdk/realtime#ssr"
190
+ });
191
+ this.name = "CStarRealtimeUnavailableError";
192
+ }
193
+ };
194
+ var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@cstar.help/js/errors/v1");
195
+ var globalSlot = globalThis;
196
+ var registry = globalSlot[REGISTRY_KEY] ?? (globalSlot[REGISTRY_KEY] = {
197
+ CStarError: CStarErrorImpl,
198
+ CStarAuthenticationError: CStarAuthenticationErrorImpl,
199
+ CStarRateLimitError: CStarRateLimitErrorImpl,
200
+ CStarNotFoundError: CStarNotFoundErrorImpl,
201
+ CStarValidationError: CStarValidationErrorImpl,
202
+ CStarPermissionError: CStarPermissionErrorImpl,
203
+ CStarConflictError: CStarConflictErrorImpl,
204
+ CStarServerError: CStarServerErrorImpl,
205
+ CStarFeatureDisabledError: CStarFeatureDisabledErrorImpl,
206
+ CStarRealtimeUnavailableError: CStarRealtimeUnavailableErrorImpl
207
+ });
208
+ var CStarError = registry.CStarError;
209
+ var CStarAuthenticationError = registry.CStarAuthenticationError;
210
+ var CStarRateLimitError = registry.CStarRateLimitError;
211
+ var CStarNotFoundError = registry.CStarNotFoundError;
212
+ var CStarValidationError = registry.CStarValidationError;
213
+ var CStarPermissionError = registry.CStarPermissionError;
214
+ var CStarConflictError = registry.CStarConflictError;
215
+ var CStarServerError = registry.CStarServerError;
216
+ var CStarFeatureDisabledError = registry.CStarFeatureDisabledError;
217
+ var CStarRealtimeUnavailableError = registry.CStarRealtimeUnavailableError;
218
+ function parsePublicError(status, body, fallbackMessage) {
219
+ const obj = body && typeof body === "object" ? body : null;
220
+ const errVal = obj?.error;
221
+ let message = fallbackMessage;
222
+ let structured = null;
223
+ if (typeof errVal === "string") {
224
+ message = errVal;
225
+ } else if (errVal && typeof errVal === "object") {
226
+ const e = errVal;
227
+ if (typeof e.message === "string") message = e.message;
228
+ structured = {
229
+ type: typeof e.type === "string" ? e.type : ErrorType.API_ERROR,
230
+ code: typeof e.code === "string" ? e.code : "api_error",
231
+ message,
232
+ param: typeof e.param === "string" ? e.param : void 0,
233
+ doc_url: typeof e.doc_url === "string" ? e.doc_url : DEFAULT_DOC_URL,
234
+ request_id: typeof e.request_id === "string" ? e.request_id : void 0,
235
+ feature: typeof e.feature === "string" ? e.feature : void 0,
236
+ enable_url: typeof e.enable_url === "string" ? e.enable_url : void 0
237
+ };
238
+ } else if (typeof obj?.message === "string") {
239
+ message = obj.message;
240
+ }
241
+ const errorBody = structured ?? {
242
+ type: ErrorType.API_ERROR,
243
+ code: status >= 500 ? "server_error" : "request_failed",
244
+ message,
245
+ doc_url: DEFAULT_DOC_URL
246
+ };
247
+ return parseError(status, { error: errorBody });
248
+ }
249
+ var STATUS_TO_CLASS = {
250
+ 400: CStarValidationError,
251
+ 401: CStarAuthenticationError,
252
+ 403: CStarPermissionError,
253
+ 404: CStarNotFoundError,
254
+ 409: CStarConflictError,
255
+ 422: CStarValidationError,
256
+ 429: CStarRateLimitError
257
+ };
169
258
  var TYPE_TO_CLASS = {
170
259
  [ErrorType.AUTHENTICATION_ERROR]: CStarAuthenticationError,
171
260
  [ErrorType.PERMISSION_ERROR]: CStarPermissionError,
@@ -176,6 +265,27 @@ var TYPE_TO_CLASS = {
176
265
  [ErrorType.SERVER_ERROR]: CStarServerError,
177
266
  [ErrorType.FEATURE_NOT_CONFIGURED]: CStarFeatureDisabledError
178
267
  };
268
+ function parseError(statusCode, body, retryAfter) {
269
+ const errorBody = body?.error ?? {
270
+ type: ErrorType.API_ERROR,
271
+ code: "unknown_error",
272
+ message: `Request failed with status ${statusCode}`,
273
+ doc_url: DEFAULT_DOC_URL
274
+ };
275
+ if (statusCode === 429) {
276
+ return new CStarRateLimitError(statusCode, errorBody, retryAfter ?? 60);
277
+ }
278
+ const StatusCls = STATUS_TO_CLASS[statusCode];
279
+ if (StatusCls) {
280
+ return new StatusCls(statusCode, errorBody);
281
+ }
282
+ const TypeCls = TYPE_TO_CLASS[errorBody.type];
283
+ if (TypeCls) {
284
+ return new TypeCls(statusCode, errorBody);
285
+ }
286
+ if (statusCode >= 500) return new CStarServerError(statusCode, errorBody);
287
+ return new CStarError(statusCode, errorBody);
288
+ }
179
289
 
180
290
  // src/quickhelp/index.ts
181
291
  var DEFAULT_BASE_URL = "https://www.cstar.help";
@@ -310,6 +420,19 @@ function parseRetryAfter(header) {
310
420
  }
311
421
  // Annotate the CommonJS export names for ESM import in node:
312
422
  0 && (module.exports = {
423
+ CStarAuthenticationError,
424
+ CStarConflictError,
425
+ CStarError,
426
+ CStarFeatureDisabledError,
427
+ CStarNotFoundError,
428
+ CStarPermissionError,
429
+ CStarRateLimitError,
430
+ CStarRealtimeUnavailableError,
431
+ CStarServerError,
432
+ CStarValidationError,
433
+ ErrorType,
313
434
  QuickHelpClient,
314
- QuickHelpError
435
+ QuickHelpError,
436
+ parseError,
437
+ parsePublicError
315
438
  });
@@ -55,6 +55,126 @@ interface QuickHelpAskResult {
55
55
  turnNumber: number;
56
56
  }
57
57
 
58
+ /**
59
+ * Error classes for the cStar SDK.
60
+ *
61
+ * NEW-v3-01 — Cross-subpath instanceof identity.
62
+ *
63
+ * Each public subpath (`/library`, `/auth`, `/community`, `/quickhelp`, ...)
64
+ * is bundled as a separate tsup entry with `splitting: false`, so each one
65
+ * carries its own copy of this module. Without deduplication, errors thrown
66
+ * by `LibraryClient` carry the LibraryClient-bundled `CStarError` class —
67
+ * not the one a consumer imports from `@cstar.help/js`. That makes
68
+ * `instanceof CStarError` checks fail silently, invalidating every "did the
69
+ * SDK throw a typed cStar error?" branch in user code.
70
+ *
71
+ * Fix: register each class on a `Symbol.for(...)` slot of `globalThis`. The
72
+ * symbol is realm-shared, so every bundled copy of this module resolves to
73
+ * the SAME class identity at runtime — the first copy to load wins, and all
74
+ * subsequent copies surface the canonical class via the same slot. The
75
+ * inline `Impl` definitions are only used as the seed for the very first
76
+ * copy to register. Internal `parseError` / `parsePublicError` reference the
77
+ * EXPORTED canonical names so instances they construct also land on the
78
+ * canonical class.
79
+ */
80
+ /** Error type constants matching the cStar API. */
81
+ declare const ErrorType: {
82
+ readonly AUTHENTICATION_ERROR: "authentication_error";
83
+ readonly PERMISSION_ERROR: "permission_error";
84
+ readonly INVALID_REQUEST_ERROR: "invalid_request_error";
85
+ readonly NOT_FOUND_ERROR: "not_found_error";
86
+ readonly CONFLICT_ERROR: "conflict_error";
87
+ readonly RATE_LIMIT_ERROR: "rate_limit_error";
88
+ readonly FEATURE_NOT_CONFIGURED: "feature_not_configured";
89
+ readonly API_ERROR: "api_error";
90
+ readonly SERVER_ERROR: "server_error";
91
+ };
92
+ /** Shape of the error object returned by the cStar API. */
93
+ interface ApiErrorBody {
94
+ type: string;
95
+ code: string;
96
+ message: string;
97
+ param?: string;
98
+ doc_url: string;
99
+ request_id?: string;
100
+ feature?: string;
101
+ enable_url?: string;
102
+ }
103
+ /** Base error class for all cStar API errors. */
104
+ declare class CStarErrorImpl extends Error {
105
+ readonly type: string;
106
+ readonly code: string;
107
+ readonly param?: string;
108
+ readonly docUrl: string;
109
+ readonly requestId?: string;
110
+ readonly statusCode: number;
111
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
112
+ }
113
+ declare class CStarAuthenticationErrorImpl extends CStarErrorImpl {
114
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
115
+ }
116
+ declare class CStarRateLimitErrorImpl extends CStarErrorImpl {
117
+ readonly retryAfter: number;
118
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number);
119
+ }
120
+ declare class CStarNotFoundErrorImpl extends CStarErrorImpl {
121
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
122
+ }
123
+ declare class CStarValidationErrorImpl extends CStarErrorImpl {
124
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
125
+ }
126
+ declare class CStarPermissionErrorImpl extends CStarErrorImpl {
127
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
128
+ }
129
+ declare class CStarConflictErrorImpl extends CStarErrorImpl {
130
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
131
+ }
132
+ declare class CStarServerErrorImpl extends CStarErrorImpl {
133
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
134
+ }
135
+ declare class CStarFeatureDisabledErrorImpl extends CStarErrorImpl {
136
+ readonly feature: string;
137
+ readonly enableUrl: string;
138
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
139
+ }
140
+ declare class CStarRealtimeUnavailableErrorImpl extends CStarErrorImpl {
141
+ constructor(message?: string);
142
+ }
143
+ declare const CStarError: typeof CStarErrorImpl;
144
+ type CStarError = InstanceType<typeof CStarErrorImpl>;
145
+ declare const CStarAuthenticationError: typeof CStarAuthenticationErrorImpl;
146
+ type CStarAuthenticationError = InstanceType<typeof CStarAuthenticationErrorImpl>;
147
+ declare const CStarRateLimitError: typeof CStarRateLimitErrorImpl;
148
+ type CStarRateLimitError = InstanceType<typeof CStarRateLimitErrorImpl>;
149
+ declare const CStarNotFoundError: typeof CStarNotFoundErrorImpl;
150
+ type CStarNotFoundError = InstanceType<typeof CStarNotFoundErrorImpl>;
151
+ declare const CStarValidationError: typeof CStarValidationErrorImpl;
152
+ type CStarValidationError = InstanceType<typeof CStarValidationErrorImpl>;
153
+ declare const CStarPermissionError: typeof CStarPermissionErrorImpl;
154
+ type CStarPermissionError = InstanceType<typeof CStarPermissionErrorImpl>;
155
+ declare const CStarConflictError: typeof CStarConflictErrorImpl;
156
+ type CStarConflictError = InstanceType<typeof CStarConflictErrorImpl>;
157
+ declare const CStarServerError: typeof CStarServerErrorImpl;
158
+ type CStarServerError = InstanceType<typeof CStarServerErrorImpl>;
159
+ declare const CStarFeatureDisabledError: typeof CStarFeatureDisabledErrorImpl;
160
+ type CStarFeatureDisabledError = InstanceType<typeof CStarFeatureDisabledErrorImpl>;
161
+ declare const CStarRealtimeUnavailableError: typeof CStarRealtimeUnavailableErrorImpl;
162
+ type CStarRealtimeUnavailableError = InstanceType<typeof CStarRealtimeUnavailableErrorImpl>;
163
+ /**
164
+ * Parse a public-route response (anonymous LibraryClient, CommunityClient,
165
+ * QuickHelpClient, AuthClient) into a typed `CStarError`.
166
+ *
167
+ * Public routes don't always emit the structured `{error: {type, code,
168
+ * doc_url, ...}}` envelope — many emit `{error: 'message string'}` or
169
+ * `{message: '...'}`. This helper normalizes both shapes and dispatches
170
+ * on HTTP status (closes F-026 and F-034 — Library/Auth used to throw
171
+ * plain `Error`).
172
+ */
173
+ declare function parsePublicError(status: number, body: unknown, fallbackMessage: string): CStarError;
174
+ declare function parseError(statusCode: number, body: {
175
+ error?: ApiErrorBody;
176
+ } | null, retryAfter?: number): CStarError;
177
+
58
178
  /**
59
179
  * Quick Help — anonymous AI Q&A client.
60
180
  *
@@ -127,4 +247,4 @@ declare class QuickHelpError extends Error {
127
247
  });
128
248
  }
129
249
 
130
- export { type QuickHelpAskParams, type QuickHelpAskResult, QuickHelpClient, type QuickHelpConfig, QuickHelpError, type QuickHelpPublicConfig, type QuickHelpTurnOutcome };
250
+ export { type ApiErrorBody, CStarAuthenticationError, CStarConflictError, CStarError, CStarFeatureDisabledError, CStarNotFoundError, CStarPermissionError, CStarRateLimitError, CStarRealtimeUnavailableError, CStarServerError, CStarValidationError, ErrorType, type QuickHelpAskParams, type QuickHelpAskResult, QuickHelpClient, type QuickHelpConfig, QuickHelpError, type QuickHelpPublicConfig, type QuickHelpTurnOutcome, parseError, parsePublicError };
@@ -55,6 +55,126 @@ interface QuickHelpAskResult {
55
55
  turnNumber: number;
56
56
  }
57
57
 
58
+ /**
59
+ * Error classes for the cStar SDK.
60
+ *
61
+ * NEW-v3-01 — Cross-subpath instanceof identity.
62
+ *
63
+ * Each public subpath (`/library`, `/auth`, `/community`, `/quickhelp`, ...)
64
+ * is bundled as a separate tsup entry with `splitting: false`, so each one
65
+ * carries its own copy of this module. Without deduplication, errors thrown
66
+ * by `LibraryClient` carry the LibraryClient-bundled `CStarError` class —
67
+ * not the one a consumer imports from `@cstar.help/js`. That makes
68
+ * `instanceof CStarError` checks fail silently, invalidating every "did the
69
+ * SDK throw a typed cStar error?" branch in user code.
70
+ *
71
+ * Fix: register each class on a `Symbol.for(...)` slot of `globalThis`. The
72
+ * symbol is realm-shared, so every bundled copy of this module resolves to
73
+ * the SAME class identity at runtime — the first copy to load wins, and all
74
+ * subsequent copies surface the canonical class via the same slot. The
75
+ * inline `Impl` definitions are only used as the seed for the very first
76
+ * copy to register. Internal `parseError` / `parsePublicError` reference the
77
+ * EXPORTED canonical names so instances they construct also land on the
78
+ * canonical class.
79
+ */
80
+ /** Error type constants matching the cStar API. */
81
+ declare const ErrorType: {
82
+ readonly AUTHENTICATION_ERROR: "authentication_error";
83
+ readonly PERMISSION_ERROR: "permission_error";
84
+ readonly INVALID_REQUEST_ERROR: "invalid_request_error";
85
+ readonly NOT_FOUND_ERROR: "not_found_error";
86
+ readonly CONFLICT_ERROR: "conflict_error";
87
+ readonly RATE_LIMIT_ERROR: "rate_limit_error";
88
+ readonly FEATURE_NOT_CONFIGURED: "feature_not_configured";
89
+ readonly API_ERROR: "api_error";
90
+ readonly SERVER_ERROR: "server_error";
91
+ };
92
+ /** Shape of the error object returned by the cStar API. */
93
+ interface ApiErrorBody {
94
+ type: string;
95
+ code: string;
96
+ message: string;
97
+ param?: string;
98
+ doc_url: string;
99
+ request_id?: string;
100
+ feature?: string;
101
+ enable_url?: string;
102
+ }
103
+ /** Base error class for all cStar API errors. */
104
+ declare class CStarErrorImpl extends Error {
105
+ readonly type: string;
106
+ readonly code: string;
107
+ readonly param?: string;
108
+ readonly docUrl: string;
109
+ readonly requestId?: string;
110
+ readonly statusCode: number;
111
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
112
+ }
113
+ declare class CStarAuthenticationErrorImpl extends CStarErrorImpl {
114
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
115
+ }
116
+ declare class CStarRateLimitErrorImpl extends CStarErrorImpl {
117
+ readonly retryAfter: number;
118
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number);
119
+ }
120
+ declare class CStarNotFoundErrorImpl extends CStarErrorImpl {
121
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
122
+ }
123
+ declare class CStarValidationErrorImpl extends CStarErrorImpl {
124
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
125
+ }
126
+ declare class CStarPermissionErrorImpl extends CStarErrorImpl {
127
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
128
+ }
129
+ declare class CStarConflictErrorImpl extends CStarErrorImpl {
130
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
131
+ }
132
+ declare class CStarServerErrorImpl extends CStarErrorImpl {
133
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
134
+ }
135
+ declare class CStarFeatureDisabledErrorImpl extends CStarErrorImpl {
136
+ readonly feature: string;
137
+ readonly enableUrl: string;
138
+ constructor(messageOrStatus: string | number, body?: ApiErrorBody);
139
+ }
140
+ declare class CStarRealtimeUnavailableErrorImpl extends CStarErrorImpl {
141
+ constructor(message?: string);
142
+ }
143
+ declare const CStarError: typeof CStarErrorImpl;
144
+ type CStarError = InstanceType<typeof CStarErrorImpl>;
145
+ declare const CStarAuthenticationError: typeof CStarAuthenticationErrorImpl;
146
+ type CStarAuthenticationError = InstanceType<typeof CStarAuthenticationErrorImpl>;
147
+ declare const CStarRateLimitError: typeof CStarRateLimitErrorImpl;
148
+ type CStarRateLimitError = InstanceType<typeof CStarRateLimitErrorImpl>;
149
+ declare const CStarNotFoundError: typeof CStarNotFoundErrorImpl;
150
+ type CStarNotFoundError = InstanceType<typeof CStarNotFoundErrorImpl>;
151
+ declare const CStarValidationError: typeof CStarValidationErrorImpl;
152
+ type CStarValidationError = InstanceType<typeof CStarValidationErrorImpl>;
153
+ declare const CStarPermissionError: typeof CStarPermissionErrorImpl;
154
+ type CStarPermissionError = InstanceType<typeof CStarPermissionErrorImpl>;
155
+ declare const CStarConflictError: typeof CStarConflictErrorImpl;
156
+ type CStarConflictError = InstanceType<typeof CStarConflictErrorImpl>;
157
+ declare const CStarServerError: typeof CStarServerErrorImpl;
158
+ type CStarServerError = InstanceType<typeof CStarServerErrorImpl>;
159
+ declare const CStarFeatureDisabledError: typeof CStarFeatureDisabledErrorImpl;
160
+ type CStarFeatureDisabledError = InstanceType<typeof CStarFeatureDisabledErrorImpl>;
161
+ declare const CStarRealtimeUnavailableError: typeof CStarRealtimeUnavailableErrorImpl;
162
+ type CStarRealtimeUnavailableError = InstanceType<typeof CStarRealtimeUnavailableErrorImpl>;
163
+ /**
164
+ * Parse a public-route response (anonymous LibraryClient, CommunityClient,
165
+ * QuickHelpClient, AuthClient) into a typed `CStarError`.
166
+ *
167
+ * Public routes don't always emit the structured `{error: {type, code,
168
+ * doc_url, ...}}` envelope — many emit `{error: 'message string'}` or
169
+ * `{message: '...'}`. This helper normalizes both shapes and dispatches
170
+ * on HTTP status (closes F-026 and F-034 — Library/Auth used to throw
171
+ * plain `Error`).
172
+ */
173
+ declare function parsePublicError(status: number, body: unknown, fallbackMessage: string): CStarError;
174
+ declare function parseError(statusCode: number, body: {
175
+ error?: ApiErrorBody;
176
+ } | null, retryAfter?: number): CStarError;
177
+
58
178
  /**
59
179
  * Quick Help — anonymous AI Q&A client.
60
180
  *
@@ -127,4 +247,4 @@ declare class QuickHelpError extends Error {
127
247
  });
128
248
  }
129
249
 
130
- export { type QuickHelpAskParams, type QuickHelpAskResult, QuickHelpClient, type QuickHelpConfig, QuickHelpError, type QuickHelpPublicConfig, type QuickHelpTurnOutcome };
250
+ export { type ApiErrorBody, CStarAuthenticationError, CStarConflictError, CStarError, CStarFeatureDisabledError, CStarNotFoundError, CStarPermissionError, CStarRateLimitError, CStarRealtimeUnavailableError, CStarServerError, CStarValidationError, ErrorType, type QuickHelpAskParams, type QuickHelpAskResult, QuickHelpClient, type QuickHelpConfig, QuickHelpError, type QuickHelpPublicConfig, type QuickHelpTurnOutcome, parseError, parsePublicError };