@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.
@@ -35,7 +35,7 @@ function normalizeArgs(messageOrStatus, maybeBody, defaults) {
35
35
  }
36
36
  };
37
37
  }
38
- var CStarError = class extends Error {
38
+ var CStarErrorImpl = class extends Error {
39
39
  constructor(messageOrStatus, body) {
40
40
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body);
41
41
  super(resolved.message);
@@ -48,7 +48,7 @@ var CStarError = class extends Error {
48
48
  this.statusCode = statusCode;
49
49
  }
50
50
  };
51
- var CStarAuthenticationError = class extends CStarError {
51
+ var CStarAuthenticationErrorImpl = class extends CStarErrorImpl {
52
52
  constructor(messageOrStatus, body) {
53
53
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
54
54
  type: ErrorType.AUTHENTICATION_ERROR,
@@ -59,7 +59,7 @@ var CStarAuthenticationError = class extends CStarError {
59
59
  this.name = "CStarAuthenticationError";
60
60
  }
61
61
  };
62
- var CStarRateLimitError = class extends CStarError {
62
+ var CStarRateLimitErrorImpl = class extends CStarErrorImpl {
63
63
  constructor(messageOrStatus, body, retryAfter) {
64
64
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
65
65
  type: ErrorType.RATE_LIMIT_ERROR,
@@ -71,7 +71,7 @@ var CStarRateLimitError = class extends CStarError {
71
71
  this.retryAfter = retryAfter ?? 60;
72
72
  }
73
73
  };
74
- var CStarNotFoundError = class extends CStarError {
74
+ var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
75
75
  constructor(messageOrStatus, body) {
76
76
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
77
77
  type: ErrorType.NOT_FOUND_ERROR,
@@ -82,7 +82,7 @@ var CStarNotFoundError = class extends CStarError {
82
82
  this.name = "CStarNotFoundError";
83
83
  }
84
84
  };
85
- var CStarValidationError = class extends CStarError {
85
+ var CStarValidationErrorImpl = class extends CStarErrorImpl {
86
86
  constructor(messageOrStatus, body) {
87
87
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
88
88
  type: ErrorType.INVALID_REQUEST_ERROR,
@@ -93,7 +93,7 @@ var CStarValidationError = class extends CStarError {
93
93
  this.name = "CStarValidationError";
94
94
  }
95
95
  };
96
- var CStarPermissionError = class extends CStarError {
96
+ var CStarPermissionErrorImpl = class extends CStarErrorImpl {
97
97
  constructor(messageOrStatus, body) {
98
98
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
99
99
  type: ErrorType.PERMISSION_ERROR,
@@ -104,7 +104,7 @@ var CStarPermissionError = class extends CStarError {
104
104
  this.name = "CStarPermissionError";
105
105
  }
106
106
  };
107
- var CStarConflictError = class extends CStarError {
107
+ var CStarConflictErrorImpl = class extends CStarErrorImpl {
108
108
  constructor(messageOrStatus, body) {
109
109
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
110
110
  type: ErrorType.CONFLICT_ERROR,
@@ -115,7 +115,7 @@ var CStarConflictError = class extends CStarError {
115
115
  this.name = "CStarConflictError";
116
116
  }
117
117
  };
118
- var CStarServerError = class extends CStarError {
118
+ var CStarServerErrorImpl = class extends CStarErrorImpl {
119
119
  constructor(messageOrStatus, body) {
120
120
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
121
121
  type: ErrorType.SERVER_ERROR,
@@ -126,7 +126,7 @@ var CStarServerError = class extends CStarError {
126
126
  this.name = "CStarServerError";
127
127
  }
128
128
  };
129
- var CStarFeatureDisabledError = class extends CStarError {
129
+ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
130
130
  constructor(messageOrStatus, body) {
131
131
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
132
132
  type: ErrorType.FEATURE_NOT_CONFIGURED,
@@ -139,6 +139,42 @@ var CStarFeatureDisabledError = class extends CStarError {
139
139
  this.enableUrl = resolved.enable_url ?? "";
140
140
  }
141
141
  };
142
+ var CStarRealtimeUnavailableErrorImpl = class extends CStarErrorImpl {
143
+ constructor(message) {
144
+ 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";
145
+ super(0, {
146
+ type: ErrorType.API_ERROR,
147
+ code: "realtime_unavailable",
148
+ message: resolved,
149
+ doc_url: "https://cstar.help/developers/sdk/realtime#ssr"
150
+ });
151
+ this.name = "CStarRealtimeUnavailableError";
152
+ }
153
+ };
154
+ var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@cstar.help/js/errors/v1");
155
+ var globalSlot = globalThis;
156
+ var registry = globalSlot[REGISTRY_KEY] ?? (globalSlot[REGISTRY_KEY] = {
157
+ CStarError: CStarErrorImpl,
158
+ CStarAuthenticationError: CStarAuthenticationErrorImpl,
159
+ CStarRateLimitError: CStarRateLimitErrorImpl,
160
+ CStarNotFoundError: CStarNotFoundErrorImpl,
161
+ CStarValidationError: CStarValidationErrorImpl,
162
+ CStarPermissionError: CStarPermissionErrorImpl,
163
+ CStarConflictError: CStarConflictErrorImpl,
164
+ CStarServerError: CStarServerErrorImpl,
165
+ CStarFeatureDisabledError: CStarFeatureDisabledErrorImpl,
166
+ CStarRealtimeUnavailableError: CStarRealtimeUnavailableErrorImpl
167
+ });
168
+ var CStarError = registry.CStarError;
169
+ var CStarAuthenticationError = registry.CStarAuthenticationError;
170
+ var CStarRateLimitError = registry.CStarRateLimitError;
171
+ var CStarNotFoundError = registry.CStarNotFoundError;
172
+ var CStarValidationError = registry.CStarValidationError;
173
+ var CStarPermissionError = registry.CStarPermissionError;
174
+ var CStarConflictError = registry.CStarConflictError;
175
+ var CStarServerError = registry.CStarServerError;
176
+ var CStarFeatureDisabledError = registry.CStarFeatureDisabledError;
177
+ var CStarRealtimeUnavailableError = registry.CStarRealtimeUnavailableError;
142
178
  function parsePublicError(status, body, fallbackMessage) {
143
179
  const obj = body && typeof body === "object" ? body : null;
144
180
  const errVal = obj?.error;
@@ -502,5 +538,18 @@ var CommunityClient = class {
502
538
  }
503
539
  };
504
540
  export {
505
- CommunityClient
541
+ CStarAuthenticationError,
542
+ CStarConflictError,
543
+ CStarError,
544
+ CStarFeatureDisabledError,
545
+ CStarNotFoundError,
546
+ CStarPermissionError,
547
+ CStarRateLimitError,
548
+ CStarRealtimeUnavailableError,
549
+ CStarServerError,
550
+ CStarValidationError,
551
+ CommunityClient,
552
+ ErrorType,
553
+ parseError,
554
+ parsePublicError
506
555
  };
package/dist/index.cjs CHANGED
@@ -74,7 +74,7 @@ function normalizeArgs(messageOrStatus, maybeBody, defaults) {
74
74
  }
75
75
  };
76
76
  }
77
- var CStarError = class extends Error {
77
+ var CStarErrorImpl = class extends Error {
78
78
  constructor(messageOrStatus, body) {
79
79
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body);
80
80
  super(resolved.message);
@@ -87,7 +87,7 @@ var CStarError = class extends Error {
87
87
  this.statusCode = statusCode;
88
88
  }
89
89
  };
90
- var CStarAuthenticationError = class extends CStarError {
90
+ var CStarAuthenticationErrorImpl = class extends CStarErrorImpl {
91
91
  constructor(messageOrStatus, body) {
92
92
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
93
93
  type: ErrorType.AUTHENTICATION_ERROR,
@@ -98,7 +98,7 @@ var CStarAuthenticationError = class extends CStarError {
98
98
  this.name = "CStarAuthenticationError";
99
99
  }
100
100
  };
101
- var CStarRateLimitError = class extends CStarError {
101
+ var CStarRateLimitErrorImpl = class extends CStarErrorImpl {
102
102
  constructor(messageOrStatus, body, retryAfter) {
103
103
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
104
104
  type: ErrorType.RATE_LIMIT_ERROR,
@@ -110,7 +110,7 @@ var CStarRateLimitError = class extends CStarError {
110
110
  this.retryAfter = retryAfter ?? 60;
111
111
  }
112
112
  };
113
- var CStarNotFoundError = class extends CStarError {
113
+ var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
114
114
  constructor(messageOrStatus, body) {
115
115
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
116
116
  type: ErrorType.NOT_FOUND_ERROR,
@@ -121,7 +121,7 @@ var CStarNotFoundError = class extends CStarError {
121
121
  this.name = "CStarNotFoundError";
122
122
  }
123
123
  };
124
- var CStarValidationError = class extends CStarError {
124
+ var CStarValidationErrorImpl = class extends CStarErrorImpl {
125
125
  constructor(messageOrStatus, body) {
126
126
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
127
127
  type: ErrorType.INVALID_REQUEST_ERROR,
@@ -132,7 +132,7 @@ var CStarValidationError = class extends CStarError {
132
132
  this.name = "CStarValidationError";
133
133
  }
134
134
  };
135
- var CStarPermissionError = class extends CStarError {
135
+ var CStarPermissionErrorImpl = class extends CStarErrorImpl {
136
136
  constructor(messageOrStatus, body) {
137
137
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
138
138
  type: ErrorType.PERMISSION_ERROR,
@@ -143,7 +143,7 @@ var CStarPermissionError = class extends CStarError {
143
143
  this.name = "CStarPermissionError";
144
144
  }
145
145
  };
146
- var CStarConflictError = class extends CStarError {
146
+ var CStarConflictErrorImpl = class extends CStarErrorImpl {
147
147
  constructor(messageOrStatus, body) {
148
148
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
149
149
  type: ErrorType.CONFLICT_ERROR,
@@ -154,7 +154,7 @@ var CStarConflictError = class extends CStarError {
154
154
  this.name = "CStarConflictError";
155
155
  }
156
156
  };
157
- var CStarServerError = class extends CStarError {
157
+ var CStarServerErrorImpl = class extends CStarErrorImpl {
158
158
  constructor(messageOrStatus, body) {
159
159
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
160
160
  type: ErrorType.SERVER_ERROR,
@@ -165,7 +165,7 @@ var CStarServerError = class extends CStarError {
165
165
  this.name = "CStarServerError";
166
166
  }
167
167
  };
168
- var CStarFeatureDisabledError = class extends CStarError {
168
+ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
169
169
  constructor(messageOrStatus, body) {
170
170
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
171
171
  type: ErrorType.FEATURE_NOT_CONFIGURED,
@@ -178,7 +178,7 @@ var CStarFeatureDisabledError = class extends CStarError {
178
178
  this.enableUrl = resolved.enable_url ?? "";
179
179
  }
180
180
  };
181
- var CStarRealtimeUnavailableError = class extends CStarError {
181
+ var CStarRealtimeUnavailableErrorImpl = class extends CStarErrorImpl {
182
182
  constructor(message) {
183
183
  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";
184
184
  super(0, {
@@ -190,6 +190,30 @@ var CStarRealtimeUnavailableError = class extends CStarError {
190
190
  this.name = "CStarRealtimeUnavailableError";
191
191
  }
192
192
  };
193
+ var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@cstar.help/js/errors/v1");
194
+ var globalSlot = globalThis;
195
+ var registry = globalSlot[REGISTRY_KEY] ?? (globalSlot[REGISTRY_KEY] = {
196
+ CStarError: CStarErrorImpl,
197
+ CStarAuthenticationError: CStarAuthenticationErrorImpl,
198
+ CStarRateLimitError: CStarRateLimitErrorImpl,
199
+ CStarNotFoundError: CStarNotFoundErrorImpl,
200
+ CStarValidationError: CStarValidationErrorImpl,
201
+ CStarPermissionError: CStarPermissionErrorImpl,
202
+ CStarConflictError: CStarConflictErrorImpl,
203
+ CStarServerError: CStarServerErrorImpl,
204
+ CStarFeatureDisabledError: CStarFeatureDisabledErrorImpl,
205
+ CStarRealtimeUnavailableError: CStarRealtimeUnavailableErrorImpl
206
+ });
207
+ var CStarError = registry.CStarError;
208
+ var CStarAuthenticationError = registry.CStarAuthenticationError;
209
+ var CStarRateLimitError = registry.CStarRateLimitError;
210
+ var CStarNotFoundError = registry.CStarNotFoundError;
211
+ var CStarValidationError = registry.CStarValidationError;
212
+ var CStarPermissionError = registry.CStarPermissionError;
213
+ var CStarConflictError = registry.CStarConflictError;
214
+ var CStarServerError = registry.CStarServerError;
215
+ var CStarFeatureDisabledError = registry.CStarFeatureDisabledError;
216
+ var CStarRealtimeUnavailableError = registry.CStarRealtimeUnavailableError;
193
217
  var STATUS_TO_CLASS = {
194
218
  400: CStarValidationError,
195
219
  401: CStarAuthenticationError,
@@ -232,7 +256,7 @@ function parseError(statusCode, body, retryAfter) {
232
256
  }
233
257
 
234
258
  // src/client.ts
235
- var SDK_VERSION = "0.14.0";
259
+ var SDK_VERSION = "0.15.0";
236
260
  var DEFAULT_BASE_URL = "https://www.cstar.help";
237
261
  var DEFAULT_API_VERSION = "2026-03-01";
238
262
  var DEFAULT_MAX_RETRIES = 3;
package/dist/index.d.cts CHANGED
@@ -1017,7 +1017,15 @@ interface Webhook {
1017
1017
  metadata: Metadata;
1018
1018
  createdAt: string;
1019
1019
  updatedAt: string;
1020
- /** Only returned on creation (POST). */
1020
+ /**
1021
+ * Signing secret for HMAC verification (`whsec_*`). Only returned on
1022
+ * creation (POST `/webhooks`). Save it immediately — subsequent reads
1023
+ * will not include it. Use it as the `secret` argument to
1024
+ * `constructEvent` / `verifySignature` from `@cstar.help/js/webhook`.
1025
+ */
1026
+ signingSecret?: string;
1027
+ /** @deprecated since 0.15.0 — use {@link signingSecret} instead. Kept
1028
+ * during the deprecation window so 0.14.x consumers keep working. */
1021
1029
  secret?: string;
1022
1030
  }
1023
1031
  /** Parameters for listing webhooks. */
@@ -3056,6 +3064,28 @@ declare class OfflineQueue {
3056
3064
  private loadFromStorage;
3057
3065
  }
3058
3066
 
3067
+ /**
3068
+ * Error classes for the cStar SDK.
3069
+ *
3070
+ * NEW-v3-01 — Cross-subpath instanceof identity.
3071
+ *
3072
+ * Each public subpath (`/library`, `/auth`, `/community`, `/quickhelp`, ...)
3073
+ * is bundled as a separate tsup entry with `splitting: false`, so each one
3074
+ * carries its own copy of this module. Without deduplication, errors thrown
3075
+ * by `LibraryClient` carry the LibraryClient-bundled `CStarError` class —
3076
+ * not the one a consumer imports from `@cstar.help/js`. That makes
3077
+ * `instanceof CStarError` checks fail silently, invalidating every "did the
3078
+ * SDK throw a typed cStar error?" branch in user code.
3079
+ *
3080
+ * Fix: register each class on a `Symbol.for(...)` slot of `globalThis`. The
3081
+ * symbol is realm-shared, so every bundled copy of this module resolves to
3082
+ * the SAME class identity at runtime — the first copy to load wins, and all
3083
+ * subsequent copies surface the canonical class via the same slot. The
3084
+ * inline `Impl` definitions are only used as the seed for the very first
3085
+ * copy to register. Internal `parseError` / `parsePublicError` reference the
3086
+ * EXPORTED canonical names so instances they construct also land on the
3087
+ * canonical class.
3088
+ */
3059
3089
  /** Error type constants matching the cStar API. */
3060
3090
  declare const ErrorType: {
3061
3091
  readonly AUTHENTICATION_ERROR: "authentication_error";
@@ -3080,7 +3110,7 @@ interface ApiErrorBody {
3080
3110
  enable_url?: string;
3081
3111
  }
3082
3112
  /** Base error class for all cStar API errors. */
3083
- declare class CStarError extends Error {
3113
+ declare class CStarErrorImpl extends Error {
3084
3114
  readonly type: string;
3085
3115
  readonly code: string;
3086
3116
  readonly param?: string;
@@ -3089,49 +3119,51 @@ declare class CStarError extends Error {
3089
3119
  readonly statusCode: number;
3090
3120
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3091
3121
  }
3092
- /** Thrown when authentication fails (401). */
3093
- declare class CStarAuthenticationError extends CStarError {
3122
+ declare class CStarAuthenticationErrorImpl extends CStarErrorImpl {
3094
3123
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3095
3124
  }
3096
- /** Thrown when rate limited (429). Includes retry timing. */
3097
- declare class CStarRateLimitError extends CStarError {
3125
+ declare class CStarRateLimitErrorImpl extends CStarErrorImpl {
3098
3126
  readonly retryAfter: number;
3099
3127
  constructor(messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number);
3100
3128
  }
3101
- /** Thrown when a resource is not found (404). */
3102
- declare class CStarNotFoundError extends CStarError {
3129
+ declare class CStarNotFoundErrorImpl extends CStarErrorImpl {
3103
3130
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3104
3131
  }
3105
- /** Thrown on invalid request parameters (400/422). */
3106
- declare class CStarValidationError extends CStarError {
3132
+ declare class CStarValidationErrorImpl extends CStarErrorImpl {
3107
3133
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3108
3134
  }
3109
- /** Thrown when authenticated but lacking permission (403). */
3110
- declare class CStarPermissionError extends CStarError {
3135
+ declare class CStarPermissionErrorImpl extends CStarErrorImpl {
3111
3136
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3112
3137
  }
3113
- /** Thrown on resource conflicts (409). */
3114
- declare class CStarConflictError extends CStarError {
3138
+ declare class CStarConflictErrorImpl extends CStarErrorImpl {
3115
3139
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3116
3140
  }
3117
- /** Thrown on internal server errors (500+). */
3118
- declare class CStarServerError extends CStarError {
3141
+ declare class CStarServerErrorImpl extends CStarErrorImpl {
3119
3142
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3120
3143
  }
3121
- /**
3122
- * Thrown when the call landed on a feature that the team has not enabled
3123
- * or configured (e.g. Quick Help on a team without an AI agent). Carries
3124
- * `feature` and `enableUrl` so the caller can route the user to the
3125
- * dashboard setting that fixes it.
3126
- *
3127
- * Closes F-031 — anonymous QuickHelp `.ask()` previously surfaced as an
3128
- * unactionable 503.
3129
- */
3130
- declare class CStarFeatureDisabledError extends CStarError {
3144
+ declare class CStarFeatureDisabledErrorImpl extends CStarErrorImpl {
3131
3145
  readonly feature: string;
3132
3146
  readonly enableUrl: string;
3133
3147
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3134
3148
  }
3149
+ declare const CStarError: typeof CStarErrorImpl;
3150
+ type CStarError = InstanceType<typeof CStarErrorImpl>;
3151
+ declare const CStarAuthenticationError: typeof CStarAuthenticationErrorImpl;
3152
+ type CStarAuthenticationError = InstanceType<typeof CStarAuthenticationErrorImpl>;
3153
+ declare const CStarRateLimitError: typeof CStarRateLimitErrorImpl;
3154
+ type CStarRateLimitError = InstanceType<typeof CStarRateLimitErrorImpl>;
3155
+ declare const CStarNotFoundError: typeof CStarNotFoundErrorImpl;
3156
+ type CStarNotFoundError = InstanceType<typeof CStarNotFoundErrorImpl>;
3157
+ declare const CStarValidationError: typeof CStarValidationErrorImpl;
3158
+ type CStarValidationError = InstanceType<typeof CStarValidationErrorImpl>;
3159
+ declare const CStarPermissionError: typeof CStarPermissionErrorImpl;
3160
+ type CStarPermissionError = InstanceType<typeof CStarPermissionErrorImpl>;
3161
+ declare const CStarConflictError: typeof CStarConflictErrorImpl;
3162
+ type CStarConflictError = InstanceType<typeof CStarConflictErrorImpl>;
3163
+ declare const CStarServerError: typeof CStarServerErrorImpl;
3164
+ type CStarServerError = InstanceType<typeof CStarServerErrorImpl>;
3165
+ declare const CStarFeatureDisabledError: typeof CStarFeatureDisabledErrorImpl;
3166
+ type CStarFeatureDisabledError = InstanceType<typeof CStarFeatureDisabledErrorImpl>;
3135
3167
 
3136
3168
  /** Configuration for the CStarClient. */
3137
3169
  interface CStarClientConfig {
package/dist/index.d.ts CHANGED
@@ -1017,7 +1017,15 @@ interface Webhook {
1017
1017
  metadata: Metadata;
1018
1018
  createdAt: string;
1019
1019
  updatedAt: string;
1020
- /** Only returned on creation (POST). */
1020
+ /**
1021
+ * Signing secret for HMAC verification (`whsec_*`). Only returned on
1022
+ * creation (POST `/webhooks`). Save it immediately — subsequent reads
1023
+ * will not include it. Use it as the `secret` argument to
1024
+ * `constructEvent` / `verifySignature` from `@cstar.help/js/webhook`.
1025
+ */
1026
+ signingSecret?: string;
1027
+ /** @deprecated since 0.15.0 — use {@link signingSecret} instead. Kept
1028
+ * during the deprecation window so 0.14.x consumers keep working. */
1021
1029
  secret?: string;
1022
1030
  }
1023
1031
  /** Parameters for listing webhooks. */
@@ -3056,6 +3064,28 @@ declare class OfflineQueue {
3056
3064
  private loadFromStorage;
3057
3065
  }
3058
3066
 
3067
+ /**
3068
+ * Error classes for the cStar SDK.
3069
+ *
3070
+ * NEW-v3-01 — Cross-subpath instanceof identity.
3071
+ *
3072
+ * Each public subpath (`/library`, `/auth`, `/community`, `/quickhelp`, ...)
3073
+ * is bundled as a separate tsup entry with `splitting: false`, so each one
3074
+ * carries its own copy of this module. Without deduplication, errors thrown
3075
+ * by `LibraryClient` carry the LibraryClient-bundled `CStarError` class —
3076
+ * not the one a consumer imports from `@cstar.help/js`. That makes
3077
+ * `instanceof CStarError` checks fail silently, invalidating every "did the
3078
+ * SDK throw a typed cStar error?" branch in user code.
3079
+ *
3080
+ * Fix: register each class on a `Symbol.for(...)` slot of `globalThis`. The
3081
+ * symbol is realm-shared, so every bundled copy of this module resolves to
3082
+ * the SAME class identity at runtime — the first copy to load wins, and all
3083
+ * subsequent copies surface the canonical class via the same slot. The
3084
+ * inline `Impl` definitions are only used as the seed for the very first
3085
+ * copy to register. Internal `parseError` / `parsePublicError` reference the
3086
+ * EXPORTED canonical names so instances they construct also land on the
3087
+ * canonical class.
3088
+ */
3059
3089
  /** Error type constants matching the cStar API. */
3060
3090
  declare const ErrorType: {
3061
3091
  readonly AUTHENTICATION_ERROR: "authentication_error";
@@ -3080,7 +3110,7 @@ interface ApiErrorBody {
3080
3110
  enable_url?: string;
3081
3111
  }
3082
3112
  /** Base error class for all cStar API errors. */
3083
- declare class CStarError extends Error {
3113
+ declare class CStarErrorImpl extends Error {
3084
3114
  readonly type: string;
3085
3115
  readonly code: string;
3086
3116
  readonly param?: string;
@@ -3089,49 +3119,51 @@ declare class CStarError extends Error {
3089
3119
  readonly statusCode: number;
3090
3120
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3091
3121
  }
3092
- /** Thrown when authentication fails (401). */
3093
- declare class CStarAuthenticationError extends CStarError {
3122
+ declare class CStarAuthenticationErrorImpl extends CStarErrorImpl {
3094
3123
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3095
3124
  }
3096
- /** Thrown when rate limited (429). Includes retry timing. */
3097
- declare class CStarRateLimitError extends CStarError {
3125
+ declare class CStarRateLimitErrorImpl extends CStarErrorImpl {
3098
3126
  readonly retryAfter: number;
3099
3127
  constructor(messageOrStatus: string | number, body?: ApiErrorBody, retryAfter?: number);
3100
3128
  }
3101
- /** Thrown when a resource is not found (404). */
3102
- declare class CStarNotFoundError extends CStarError {
3129
+ declare class CStarNotFoundErrorImpl extends CStarErrorImpl {
3103
3130
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3104
3131
  }
3105
- /** Thrown on invalid request parameters (400/422). */
3106
- declare class CStarValidationError extends CStarError {
3132
+ declare class CStarValidationErrorImpl extends CStarErrorImpl {
3107
3133
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3108
3134
  }
3109
- /** Thrown when authenticated but lacking permission (403). */
3110
- declare class CStarPermissionError extends CStarError {
3135
+ declare class CStarPermissionErrorImpl extends CStarErrorImpl {
3111
3136
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3112
3137
  }
3113
- /** Thrown on resource conflicts (409). */
3114
- declare class CStarConflictError extends CStarError {
3138
+ declare class CStarConflictErrorImpl extends CStarErrorImpl {
3115
3139
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3116
3140
  }
3117
- /** Thrown on internal server errors (500+). */
3118
- declare class CStarServerError extends CStarError {
3141
+ declare class CStarServerErrorImpl extends CStarErrorImpl {
3119
3142
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3120
3143
  }
3121
- /**
3122
- * Thrown when the call landed on a feature that the team has not enabled
3123
- * or configured (e.g. Quick Help on a team without an AI agent). Carries
3124
- * `feature` and `enableUrl` so the caller can route the user to the
3125
- * dashboard setting that fixes it.
3126
- *
3127
- * Closes F-031 — anonymous QuickHelp `.ask()` previously surfaced as an
3128
- * unactionable 503.
3129
- */
3130
- declare class CStarFeatureDisabledError extends CStarError {
3144
+ declare class CStarFeatureDisabledErrorImpl extends CStarErrorImpl {
3131
3145
  readonly feature: string;
3132
3146
  readonly enableUrl: string;
3133
3147
  constructor(messageOrStatus: string | number, body?: ApiErrorBody);
3134
3148
  }
3149
+ declare const CStarError: typeof CStarErrorImpl;
3150
+ type CStarError = InstanceType<typeof CStarErrorImpl>;
3151
+ declare const CStarAuthenticationError: typeof CStarAuthenticationErrorImpl;
3152
+ type CStarAuthenticationError = InstanceType<typeof CStarAuthenticationErrorImpl>;
3153
+ declare const CStarRateLimitError: typeof CStarRateLimitErrorImpl;
3154
+ type CStarRateLimitError = InstanceType<typeof CStarRateLimitErrorImpl>;
3155
+ declare const CStarNotFoundError: typeof CStarNotFoundErrorImpl;
3156
+ type CStarNotFoundError = InstanceType<typeof CStarNotFoundErrorImpl>;
3157
+ declare const CStarValidationError: typeof CStarValidationErrorImpl;
3158
+ type CStarValidationError = InstanceType<typeof CStarValidationErrorImpl>;
3159
+ declare const CStarPermissionError: typeof CStarPermissionErrorImpl;
3160
+ type CStarPermissionError = InstanceType<typeof CStarPermissionErrorImpl>;
3161
+ declare const CStarConflictError: typeof CStarConflictErrorImpl;
3162
+ type CStarConflictError = InstanceType<typeof CStarConflictErrorImpl>;
3163
+ declare const CStarServerError: typeof CStarServerErrorImpl;
3164
+ type CStarServerError = InstanceType<typeof CStarServerErrorImpl>;
3165
+ declare const CStarFeatureDisabledError: typeof CStarFeatureDisabledErrorImpl;
3166
+ type CStarFeatureDisabledError = InstanceType<typeof CStarFeatureDisabledErrorImpl>;
3135
3167
 
3136
3168
  /** Configuration for the CStarClient. */
3137
3169
  interface CStarClientConfig {
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ function normalizeArgs(messageOrStatus, maybeBody, defaults) {
35
35
  }
36
36
  };
37
37
  }
38
- var CStarError = class extends Error {
38
+ var CStarErrorImpl = class extends Error {
39
39
  constructor(messageOrStatus, body) {
40
40
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body);
41
41
  super(resolved.message);
@@ -48,7 +48,7 @@ var CStarError = class extends Error {
48
48
  this.statusCode = statusCode;
49
49
  }
50
50
  };
51
- var CStarAuthenticationError = class extends CStarError {
51
+ var CStarAuthenticationErrorImpl = class extends CStarErrorImpl {
52
52
  constructor(messageOrStatus, body) {
53
53
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
54
54
  type: ErrorType.AUTHENTICATION_ERROR,
@@ -59,7 +59,7 @@ var CStarAuthenticationError = class extends CStarError {
59
59
  this.name = "CStarAuthenticationError";
60
60
  }
61
61
  };
62
- var CStarRateLimitError = class extends CStarError {
62
+ var CStarRateLimitErrorImpl = class extends CStarErrorImpl {
63
63
  constructor(messageOrStatus, body, retryAfter) {
64
64
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
65
65
  type: ErrorType.RATE_LIMIT_ERROR,
@@ -71,7 +71,7 @@ var CStarRateLimitError = class extends CStarError {
71
71
  this.retryAfter = retryAfter ?? 60;
72
72
  }
73
73
  };
74
- var CStarNotFoundError = class extends CStarError {
74
+ var CStarNotFoundErrorImpl = class extends CStarErrorImpl {
75
75
  constructor(messageOrStatus, body) {
76
76
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
77
77
  type: ErrorType.NOT_FOUND_ERROR,
@@ -82,7 +82,7 @@ var CStarNotFoundError = class extends CStarError {
82
82
  this.name = "CStarNotFoundError";
83
83
  }
84
84
  };
85
- var CStarValidationError = class extends CStarError {
85
+ var CStarValidationErrorImpl = class extends CStarErrorImpl {
86
86
  constructor(messageOrStatus, body) {
87
87
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
88
88
  type: ErrorType.INVALID_REQUEST_ERROR,
@@ -93,7 +93,7 @@ var CStarValidationError = class extends CStarError {
93
93
  this.name = "CStarValidationError";
94
94
  }
95
95
  };
96
- var CStarPermissionError = class extends CStarError {
96
+ var CStarPermissionErrorImpl = class extends CStarErrorImpl {
97
97
  constructor(messageOrStatus, body) {
98
98
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
99
99
  type: ErrorType.PERMISSION_ERROR,
@@ -104,7 +104,7 @@ var CStarPermissionError = class extends CStarError {
104
104
  this.name = "CStarPermissionError";
105
105
  }
106
106
  };
107
- var CStarConflictError = class extends CStarError {
107
+ var CStarConflictErrorImpl = class extends CStarErrorImpl {
108
108
  constructor(messageOrStatus, body) {
109
109
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
110
110
  type: ErrorType.CONFLICT_ERROR,
@@ -115,7 +115,7 @@ var CStarConflictError = class extends CStarError {
115
115
  this.name = "CStarConflictError";
116
116
  }
117
117
  };
118
- var CStarServerError = class extends CStarError {
118
+ var CStarServerErrorImpl = class extends CStarErrorImpl {
119
119
  constructor(messageOrStatus, body) {
120
120
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
121
121
  type: ErrorType.SERVER_ERROR,
@@ -126,7 +126,7 @@ var CStarServerError = class extends CStarError {
126
126
  this.name = "CStarServerError";
127
127
  }
128
128
  };
129
- var CStarFeatureDisabledError = class extends CStarError {
129
+ var CStarFeatureDisabledErrorImpl = class extends CStarErrorImpl {
130
130
  constructor(messageOrStatus, body) {
131
131
  const { statusCode, body: resolved } = normalizeArgs(messageOrStatus, body, {
132
132
  type: ErrorType.FEATURE_NOT_CONFIGURED,
@@ -139,7 +139,7 @@ var CStarFeatureDisabledError = class extends CStarError {
139
139
  this.enableUrl = resolved.enable_url ?? "";
140
140
  }
141
141
  };
142
- var CStarRealtimeUnavailableError = class extends CStarError {
142
+ var CStarRealtimeUnavailableErrorImpl = class extends CStarErrorImpl {
143
143
  constructor(message) {
144
144
  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";
145
145
  super(0, {
@@ -151,6 +151,30 @@ var CStarRealtimeUnavailableError = class extends CStarError {
151
151
  this.name = "CStarRealtimeUnavailableError";
152
152
  }
153
153
  };
154
+ var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@cstar.help/js/errors/v1");
155
+ var globalSlot = globalThis;
156
+ var registry = globalSlot[REGISTRY_KEY] ?? (globalSlot[REGISTRY_KEY] = {
157
+ CStarError: CStarErrorImpl,
158
+ CStarAuthenticationError: CStarAuthenticationErrorImpl,
159
+ CStarRateLimitError: CStarRateLimitErrorImpl,
160
+ CStarNotFoundError: CStarNotFoundErrorImpl,
161
+ CStarValidationError: CStarValidationErrorImpl,
162
+ CStarPermissionError: CStarPermissionErrorImpl,
163
+ CStarConflictError: CStarConflictErrorImpl,
164
+ CStarServerError: CStarServerErrorImpl,
165
+ CStarFeatureDisabledError: CStarFeatureDisabledErrorImpl,
166
+ CStarRealtimeUnavailableError: CStarRealtimeUnavailableErrorImpl
167
+ });
168
+ var CStarError = registry.CStarError;
169
+ var CStarAuthenticationError = registry.CStarAuthenticationError;
170
+ var CStarRateLimitError = registry.CStarRateLimitError;
171
+ var CStarNotFoundError = registry.CStarNotFoundError;
172
+ var CStarValidationError = registry.CStarValidationError;
173
+ var CStarPermissionError = registry.CStarPermissionError;
174
+ var CStarConflictError = registry.CStarConflictError;
175
+ var CStarServerError = registry.CStarServerError;
176
+ var CStarFeatureDisabledError = registry.CStarFeatureDisabledError;
177
+ var CStarRealtimeUnavailableError = registry.CStarRealtimeUnavailableError;
154
178
  var STATUS_TO_CLASS = {
155
179
  400: CStarValidationError,
156
180
  401: CStarAuthenticationError,
@@ -193,7 +217,7 @@ function parseError(statusCode, body, retryAfter) {
193
217
  }
194
218
 
195
219
  // src/client.ts
196
- var SDK_VERSION = "0.14.0";
220
+ var SDK_VERSION = "0.15.0";
197
221
  var DEFAULT_BASE_URL = "https://www.cstar.help";
198
222
  var DEFAULT_API_VERSION = "2026-03-01";
199
223
  var DEFAULT_MAX_RETRIES = 3;