@enlitt/protocol 0.0.0-stage → 0.1.1

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 (51) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +15 -2
  4. package/dist/admin.d.cts +353 -0
  5. package/dist/admin.d.ts +354 -0
  6. package/dist/admin.d.ts.map +1 -0
  7. package/dist/authentication.d.cts +8 -0
  8. package/dist/authentication.d.ts +9 -0
  9. package/dist/authentication.d.ts.map +1 -0
  10. package/dist/canonical-integer.d.cts +48 -0
  11. package/dist/canonical-integer.d.ts +49 -0
  12. package/dist/canonical-integer.d.ts.map +1 -0
  13. package/dist/compatibility.d.cts +23 -0
  14. package/dist/compatibility.d.ts +24 -0
  15. package/dist/compatibility.d.ts.map +1 -0
  16. package/dist/contract.d.cts +67 -0
  17. package/dist/contract.d.ts +68 -0
  18. package/dist/contract.d.ts.map +1 -0
  19. package/dist/dashboard.d.cts +1078 -0
  20. package/dist/dashboard.d.ts +1079 -0
  21. package/dist/dashboard.d.ts.map +1 -0
  22. package/dist/errors.d.cts +113 -0
  23. package/dist/errors.d.ts +114 -0
  24. package/dist/errors.d.ts.map +1 -0
  25. package/dist/idempotency.d.cts +79 -0
  26. package/dist/idempotency.d.ts +80 -0
  27. package/dist/idempotency.d.ts.map +1 -0
  28. package/dist/index.cjs +5050 -0
  29. package/dist/index.cjs.map +1 -0
  30. package/dist/index.d.cts +33 -0
  31. package/dist/index.d.ts +34 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +4857 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/outreach.d.cts +73 -0
  36. package/dist/outreach.d.ts +74 -0
  37. package/dist/outreach.d.ts.map +1 -0
  38. package/dist/premium-operations.d.cts +84 -0
  39. package/dist/premium-operations.d.ts +85 -0
  40. package/dist/premium-operations.d.ts.map +1 -0
  41. package/dist/response-stream.d.cts +246 -0
  42. package/dist/response-stream.d.ts +247 -0
  43. package/dist/response-stream.d.ts.map +1 -0
  44. package/dist/responses.d.cts +233 -0
  45. package/dist/responses.d.ts +234 -0
  46. package/dist/responses.d.ts.map +1 -0
  47. package/dist/usage.d.cts +11 -0
  48. package/dist/usage.d.ts +12 -0
  49. package/dist/usage.d.ts.map +1 -0
  50. package/generated/contract.json +491 -0
  51. package/package.json +60 -3
@@ -0,0 +1,354 @@
1
+ /**
2
+ * The operator-CLI wire contract: `POST /v1/admin/actions` (`specs/PROTOCOLS.md`
3
+ * "Admin actions"). It is not a public or browser API and is deliberately
4
+ * absent from `contract.json`'s route list; only the operator CLI and the
5
+ * backend admin route use these validators.
6
+ *
7
+ * Requests are strict: an unknown field, a missing required field, a float
8
+ * amount, or a write command without a reason is refused. Responses are read
9
+ * strictly by default, or tolerantly with `{ mode: "tolerant" }` (unknown
10
+ * fields dropped, future closed-enum members mapped to `"other"`).
11
+ *
12
+ * Amounts follow the shared rule: credits are milli-credit integer strings,
13
+ * money is minor-unit or NANOUSD integer strings (canonical base-10, no sign,
14
+ * no fraction). Instants are RFC 3339.
15
+ */
16
+ import { type ParseOptions } from "./compatibility.js";
17
+ import type { ResponseValidationResult } from "./responses.js";
18
+ type Result<T> = ResponseValidationResult<T>;
19
+ /** Read commands: they change nothing and need no reason. */
20
+ export declare const ADMIN_READ_COMMANDS: readonly ["inspect.user", "inspect.business", "inspect.app", "inspect.order", "inspect.call", "inspect.txn", "sql", "log", "report.platform"];
21
+ /** Write commands: a reason of 1 to 1,000 characters is required. */
22
+ export declare const ADMIN_WRITE_COMMANDS: readonly ["refund.cash", "refund.manual", "refund.mark_paid", "refund.cancel_manual", "credits.grant", "plan.set", "plan.reset", "status.suspend", "status.unsuspend", "payout.block", "payout.unblock", "payout.create", "payout.execute", "gift.create", "gift.revoke", "account.set_email", "account.release_phone", "account.set_app_limits", "account.set_default_limit"];
23
+ export declare const ADMIN_COMMAND_NAMES: readonly ["inspect.user", "inspect.business", "inspect.app", "inspect.order", "inspect.call", "inspect.txn", "sql", "log", "report.platform", "refund.cash", "refund.manual", "refund.mark_paid", "refund.cancel_manual", "credits.grant", "plan.set", "plan.reset", "status.suspend", "status.unsuspend", "payout.block", "payout.unblock", "payout.create", "payout.execute", "gift.create", "gift.revoke", "account.set_email", "account.release_phone", "account.set_app_limits", "account.set_default_limit"];
24
+ export type AdminCommandName = (typeof ADMIN_COMMAND_NAMES)[number];
25
+ export declare const ADMIN_ACTION_KINDS: readonly ["read", "write"];
26
+ export declare const ADMIN_ACTION_STATUSES: readonly ["started", "succeeded", "failed"];
27
+ export declare const ADMIN_SUBJECTS: readonly ["user", "business", "app"];
28
+ export declare const ADMIN_REASON_MAX_LENGTH = 1000;
29
+ export declare const ADMIN_SQL_MAX_LENGTH = 20000;
30
+ export declare const ADMIN_SQL_MAX_LIMIT = 1000;
31
+ export declare const ADMIN_LOG_MAX_LIMIT = 200;
32
+ export declare const ADMIN_SUSPEND_MAX_DAYS = 3650;
33
+ /** `report.platform` reports on at most the last 90 days; the weekly email uses 7. */
34
+ export declare const ADMIN_REPORT_MAX_DAYS = 90;
35
+ export declare const ADMIN_REPORT_DEFAULT_DAYS = 7;
36
+ /** How a `PlatformReportRow` value is measured, and so how a client formats it. */
37
+ export declare const PLATFORM_REPORT_UNITS: readonly ["count", "nano_usd", "usd_cents", "milli_credits"];
38
+ /** The request body limit the route enforces. */
39
+ export declare const ADMIN_REQUEST_MAX_BYTES: number;
40
+ export declare function isAdminCommandName(value: unknown): value is AdminCommandName;
41
+ /** `"read"` or `"write"` for a known command. */
42
+ export declare function adminCommandKind(command: AdminCommandName): "read" | "write";
43
+ export type AdminSubject = (typeof ADMIN_SUBJECTS)[number];
44
+ export interface AdminLimits {
45
+ readonly standard_per_call?: string;
46
+ readonly premium_per_call?: string;
47
+ }
48
+ export interface AdminCommandArgs {
49
+ "inspect.user": {
50
+ readonly id?: string;
51
+ readonly email?: string;
52
+ };
53
+ "inspect.business": {
54
+ readonly id?: string;
55
+ readonly email?: string;
56
+ };
57
+ "inspect.app": {
58
+ readonly id: string;
59
+ };
60
+ "inspect.order": {
61
+ readonly id: string;
62
+ };
63
+ "inspect.call": {
64
+ readonly id: string;
65
+ };
66
+ "inspect.txn": {
67
+ readonly id: string;
68
+ };
69
+ sql: {
70
+ readonly sql: string;
71
+ readonly limit?: number;
72
+ };
73
+ log: {
74
+ readonly operator?: string;
75
+ readonly target_id?: string;
76
+ readonly limit?: number;
77
+ readonly cursor?: string;
78
+ };
79
+ "report.platform": {
80
+ readonly days?: number;
81
+ };
82
+ "refund.cash": {
83
+ readonly order_id: string;
84
+ readonly amount_minor_units: string | null;
85
+ };
86
+ "refund.manual": {
87
+ readonly order_id: string;
88
+ readonly amount_minor_units: string;
89
+ };
90
+ "refund.mark_paid": {
91
+ readonly transaction_id: string;
92
+ readonly bank_reference: string;
93
+ };
94
+ "refund.cancel_manual": {
95
+ readonly transaction_id: string;
96
+ };
97
+ "credits.grant": {
98
+ readonly user_id: string;
99
+ readonly standard_units: string;
100
+ readonly premium_units: string;
101
+ readonly call_id: string | null;
102
+ };
103
+ "plan.set": {
104
+ readonly user_id: string;
105
+ readonly plan_id: string;
106
+ readonly catalog_version: string;
107
+ };
108
+ "plan.reset": {
109
+ readonly user_id: string;
110
+ };
111
+ "status.suspend": {
112
+ readonly subject: AdminSubject;
113
+ readonly id: string;
114
+ readonly days: number | null;
115
+ };
116
+ "status.unsuspend": {
117
+ readonly subject: AdminSubject;
118
+ readonly id: string;
119
+ };
120
+ "payout.block": {
121
+ readonly business_id: string;
122
+ };
123
+ "payout.unblock": {
124
+ readonly business_id: string;
125
+ };
126
+ "payout.create": {
127
+ readonly business_id: string;
128
+ readonly nano_usd: string;
129
+ };
130
+ "payout.execute": {
131
+ readonly transaction_id: string;
132
+ };
133
+ "gift.create": {
134
+ readonly product_kind: "subscription" | "bundle";
135
+ readonly product_id: string;
136
+ readonly catalog_version: string;
137
+ readonly expires_at: string | null;
138
+ };
139
+ "gift.revoke": {
140
+ readonly gift_code_id: string;
141
+ };
142
+ "account.set_email": {
143
+ readonly auth_user_id: string;
144
+ readonly email: string;
145
+ };
146
+ "account.release_phone": {
147
+ readonly user_id: string;
148
+ };
149
+ "account.set_app_limits": {
150
+ readonly user_id: string;
151
+ readonly application_id: string;
152
+ readonly limits: AdminLimits;
153
+ };
154
+ "account.set_default_limit": {
155
+ readonly user_id: string;
156
+ readonly premium_per_call: string;
157
+ };
158
+ }
159
+ export interface AdminActionSummary {
160
+ readonly action_id: string;
161
+ readonly operator: string;
162
+ readonly command: string;
163
+ readonly kind: "read" | "write";
164
+ readonly reason: string | null;
165
+ readonly status: "started" | "succeeded" | "failed";
166
+ readonly target_type: string | null;
167
+ readonly target_id: string | null;
168
+ readonly error_code: string | null;
169
+ readonly created_at: string;
170
+ readonly finished_at: string | null;
171
+ }
172
+ export type PlatformReportUnit = (typeof PLATFORM_REPORT_UNITS)[number];
173
+ /**
174
+ * One line of the platform report (`PROTOCOLS.md` "Admin actions"). Both values
175
+ * are decimal integer strings and may be negative; `window` is null on a
176
+ * snapshot row, whose `total` is the state at `window_end`.
177
+ */
178
+ export interface PlatformReportRow {
179
+ readonly label: string;
180
+ readonly unit: PlatformReportUnit;
181
+ readonly window: string | null;
182
+ readonly total: string;
183
+ }
184
+ /** The `report.platform` result; its sections and labels are owned by `specs/Admin.md`. */
185
+ export interface PlatformReport {
186
+ readonly environment: string;
187
+ readonly window_start: string;
188
+ readonly window_end: string;
189
+ readonly sections: readonly {
190
+ readonly title: string;
191
+ readonly rows: readonly PlatformReportRow[];
192
+ }[];
193
+ }
194
+ /** An `inspect.*` summary: backend-owned, content-free, shaped per record kind. */
195
+ export type AdminInspectResult = Readonly<Record<string, unknown>>;
196
+ export interface AdminCommandResult {
197
+ "inspect.user": AdminInspectResult;
198
+ "inspect.business": AdminInspectResult;
199
+ "inspect.app": AdminInspectResult;
200
+ "inspect.order": AdminInspectResult;
201
+ "inspect.call": AdminInspectResult;
202
+ "inspect.txn": AdminInspectResult;
203
+ sql: {
204
+ readonly columns: readonly string[];
205
+ readonly rows: readonly (readonly unknown[])[];
206
+ readonly truncated: boolean;
207
+ };
208
+ log: {
209
+ readonly actions: readonly AdminActionSummary[];
210
+ readonly next_cursor: string | null;
211
+ };
212
+ "report.platform": Pick<PlatformReport, keyof PlatformReport>;
213
+ "refund.cash": {
214
+ readonly order_id: string;
215
+ readonly refunds: readonly {
216
+ readonly transaction_id: string;
217
+ readonly amount_minor_units: string;
218
+ readonly status: string;
219
+ }[];
220
+ readonly remaining_minor_units: string;
221
+ };
222
+ "refund.manual": {
223
+ readonly transaction_id: string;
224
+ readonly status: "pending";
225
+ };
226
+ "refund.mark_paid": {
227
+ readonly transaction_id: string;
228
+ readonly status: "completed";
229
+ };
230
+ "refund.cancel_manual": {
231
+ readonly transaction_id: string;
232
+ readonly status: "canceled";
233
+ };
234
+ "credits.grant": {
235
+ readonly transaction_id: string;
236
+ readonly extra_credit: {
237
+ readonly standard_units: string;
238
+ readonly premium_units: string;
239
+ };
240
+ };
241
+ "plan.set": {
242
+ readonly subscription: unknown;
243
+ };
244
+ "plan.reset": {
245
+ readonly subscription: unknown;
246
+ readonly period_start: string;
247
+ readonly period_end: string;
248
+ };
249
+ "status.suspend": {
250
+ readonly subject: AdminSubject;
251
+ readonly id: string;
252
+ readonly status: "suspended";
253
+ readonly suspended_until: string | null;
254
+ /**
255
+ * What the billing step did for a user suspension: each order's refund
256
+ * outcome under the refund policy and whether the subscription was
257
+ * canceled. Null for a business or an app, which hold no purchase orders.
258
+ */
259
+ readonly billing: {
260
+ readonly refunds: readonly {
261
+ readonly order_id: string;
262
+ readonly outcome: "refunded" | "under_review" | "refused" | "ineligible";
263
+ readonly refund_minor_units: string;
264
+ readonly reason: string;
265
+ }[];
266
+ readonly subscription_canceled: boolean;
267
+ } | null;
268
+ };
269
+ "status.unsuspend": {
270
+ readonly subject: AdminSubject;
271
+ readonly id: string;
272
+ readonly status: "active";
273
+ };
274
+ "payout.block": {
275
+ readonly business_id: string;
276
+ readonly payout_blocked: boolean;
277
+ };
278
+ "payout.unblock": {
279
+ readonly business_id: string;
280
+ readonly payout_blocked: boolean;
281
+ };
282
+ "payout.create": {
283
+ readonly transaction_id: string;
284
+ readonly nano_usd: string;
285
+ readonly status: "pending";
286
+ };
287
+ "payout.execute": {
288
+ readonly transaction_id: string;
289
+ readonly status: string;
290
+ };
291
+ "gift.create": {
292
+ readonly gift_code_id: string;
293
+ readonly code: string | null;
294
+ };
295
+ "gift.revoke": {
296
+ readonly gift_code_id: string;
297
+ readonly status: "revoked";
298
+ };
299
+ "account.set_email": {
300
+ readonly auth_user_id: string;
301
+ readonly email: string;
302
+ };
303
+ "account.release_phone": {
304
+ readonly user_id: string;
305
+ readonly phone_released: true;
306
+ };
307
+ "account.set_app_limits": {
308
+ readonly application_id: string;
309
+ readonly limits: AdminLimits;
310
+ };
311
+ "account.set_default_limit": {
312
+ readonly user_id: string;
313
+ readonly new_application_premium_per_call_limit: string;
314
+ };
315
+ }
316
+ export interface AdminActionRequest {
317
+ readonly action_id: string;
318
+ readonly command: AdminCommandName;
319
+ readonly args: Readonly<Record<string, unknown>>;
320
+ readonly reason: string | null;
321
+ }
322
+ export interface AdminActionSuccessResponse {
323
+ readonly action_id: string;
324
+ readonly command: string;
325
+ readonly status: "succeeded";
326
+ readonly replayed: boolean;
327
+ readonly result: Readonly<Record<string, unknown>>;
328
+ }
329
+ export interface AdminActionErrorResponse {
330
+ readonly error: {
331
+ readonly code: string;
332
+ readonly message: string;
333
+ readonly param?: string;
334
+ };
335
+ readonly request_id: string;
336
+ readonly action_id?: string;
337
+ }
338
+ /** Validates `args` for one command (strict: unknown or missing fields fail). */
339
+ export declare function validateAdminCommandArgs<C extends AdminCommandName>(command: C, args: unknown): Result<AdminCommandArgs[C]>;
340
+ /** Validates a command's `result` object (tolerant mode drops unknown fields). */
341
+ export declare function validateAdminCommandResult<C extends AdminCommandName>(command: C, result: unknown, options?: ParseOptions): Result<AdminCommandResult[C]>;
342
+ /**
343
+ * `POST /v1/admin/actions` body: exactly `{ action_id, command, args, reason }`.
344
+ * The returned `args` are the validated, normalised arguments for `command`.
345
+ */
346
+ export declare function validateAdminActionRequest(value: unknown): Result<AdminActionRequest>;
347
+ /** `200` body of `POST /v1/admin/actions`; `result` is checked against the command. */
348
+ export declare function validateAdminActionResponse(value: unknown, options?: ParseOptions): Result<AdminActionSuccessResponse>;
349
+ /** Error body of the admin route: the dashboard envelope plus `action_id` when the body parsed. */
350
+ export declare function validateAdminActionErrorResponse(value: unknown, options?: ParseOptions): Result<AdminActionErrorResponse>;
351
+ /** One audit-log row, as returned by `log`. */
352
+ export declare function validateAdminActionSummary(value: unknown, options?: ParseOptions): Result<AdminActionSummary>;
353
+ export {};
354
+ //# sourceMappingURL=admin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE3E,OAAO,KAAK,EAA4B,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAGzF,KAAK,MAAM,CAAC,CAAC,IAAI,wBAAwB,CAAC,CAAC,CAAC,CAAC;AAQ7C,6DAA6D;AAC7D,eAAO,MAAM,mBAAmB,YAC9B,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,cAAc,EACd,aAAa,EACb,KAAK,EACL,KAAK,EACL,iBAAiB,CACT,CAAC;AAEX,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,YAC/B,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,2BAA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O,CAAC,EAAE,YAAY,GACrB,MAAM,CAAC,0BAA0B,CAAC,CAoBpC;AAED,mGAAmG;AACnG,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,YAAY,GACrB,MAAM,CAAC,wBAAwB,CAAC,CASlC;AAED,+CAA+C;AAC/C,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,YAAY,GACrB,MAAM,CAAC,kBAAkB,CAAC,CAG5B"}
@@ -0,0 +1,8 @@
1
+ import type { ParseOptions } from "./compatibility.cjs";
2
+ import type { ResponseValidationResult } from "./responses.cjs";
3
+ /** Identity returned only by the authenticated, server-side code exchange. */
4
+ export interface AuthorizationExchangeResponse {
5
+ readonly session_token: string;
6
+ readonly subject: string;
7
+ }
8
+ export declare function validateAuthorizationExchangeResponse(payload: unknown, options?: ParseOptions): ResponseValidationResult<AuthorizationExchangeResponse>;
@@ -0,0 +1,9 @@
1
+ import type { ParseOptions } from "./compatibility.js";
2
+ import type { ResponseValidationResult } from "./responses.js";
3
+ /** Identity returned only by the authenticated, server-side code exchange. */
4
+ export interface AuthorizationExchangeResponse {
5
+ readonly session_token: string;
6
+ readonly subject: string;
7
+ }
8
+ export declare function validateAuthorizationExchangeResponse(payload: unknown, options?: ParseOptions): ResponseValidationResult<AuthorizationExchangeResponse>;
9
+ //# sourceMappingURL=authentication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../src/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,8EAA8E;AAC9E,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAMD,wBAAgB,qCAAqC,CACnD,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,YAAY,GACrB,wBAAwB,CAAC,6BAA6B,CAAC,CAiBzD"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The canonical base-10 integer string, defined once for both sides of the
3
+ * wire.
4
+ *
5
+ * `specs/PROTOCOLS.md` transports every credit and NANOUSD amount as a string
6
+ * of digits with no sign, fraction, exponent, or noncanonical leading zero, so
7
+ * that an exact `bigint` survives JSON without ever touching a float. The
8
+ * backend, the SDK, and the frontend all parse and serialize these, and one
9
+ * definition here is the difference between one notion of canonical and three
10
+ * that agree until they do not.
11
+ *
12
+ * The rejection of noncanonical forms is not pedantry. `"007"` and `"7"` are
13
+ * the same number and different strings, and amounts are compared, keyed, and
14
+ * audited as strings elsewhere in the system; accepting both would let one
15
+ * amount have two identities.
16
+ */
17
+ /**
18
+ * Raised when a value is not a canonical base-10 integer string. It is a
19
+ * validation failure on untrusted input, so callers on a request path are
20
+ * expected to catch it and refuse the request.
21
+ */
22
+ export declare class CanonicalIntegerError extends Error {
23
+ readonly name = "CanonicalIntegerError";
24
+ }
25
+ export declare function isCanonicalIntegerString(value: unknown): value is string;
26
+ /**
27
+ * Parse a canonical base-10 integer string into an exact `bigint`.
28
+ *
29
+ * `field` names the wire field for the error message only; it never reaches a
30
+ * response body on its own.
31
+ */
32
+ export declare function parseCanonicalInteger(value: unknown, field?: string): bigint;
33
+ /**
34
+ * Parse a canonical integer that must be strictly positive.
35
+ *
36
+ * A premium quote uses this: zero is not a quote, and rounding a strictly
37
+ * positive quote up is what makes a per-call limit of zero an absolute block
38
+ * rather than a free pass for amounts too small to reach one credit.
39
+ */
40
+ export declare function parsePositiveCanonicalInteger(value: unknown, field?: string): bigint;
41
+ /**
42
+ * Serialize a nonnegative `bigint` to its canonical string form.
43
+ *
44
+ * Negative values are refused rather than serialized with a sign: no amount on
45
+ * this wire is negative, and a negative one reaching the wire would mean a
46
+ * balance calculation went wrong somewhere upstream of here.
47
+ */
48
+ export declare function formatCanonicalInteger(value: bigint, field?: string): string;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The canonical base-10 integer string, defined once for both sides of the
3
+ * wire.
4
+ *
5
+ * `specs/PROTOCOLS.md` transports every credit and NANOUSD amount as a string
6
+ * of digits with no sign, fraction, exponent, or noncanonical leading zero, so
7
+ * that an exact `bigint` survives JSON without ever touching a float. The
8
+ * backend, the SDK, and the frontend all parse and serialize these, and one
9
+ * definition here is the difference between one notion of canonical and three
10
+ * that agree until they do not.
11
+ *
12
+ * The rejection of noncanonical forms is not pedantry. `"007"` and `"7"` are
13
+ * the same number and different strings, and amounts are compared, keyed, and
14
+ * audited as strings elsewhere in the system; accepting both would let one
15
+ * amount have two identities.
16
+ */
17
+ /**
18
+ * Raised when a value is not a canonical base-10 integer string. It is a
19
+ * validation failure on untrusted input, so callers on a request path are
20
+ * expected to catch it and refuse the request.
21
+ */
22
+ export declare class CanonicalIntegerError extends Error {
23
+ readonly name = "CanonicalIntegerError";
24
+ }
25
+ export declare function isCanonicalIntegerString(value: unknown): value is string;
26
+ /**
27
+ * Parse a canonical base-10 integer string into an exact `bigint`.
28
+ *
29
+ * `field` names the wire field for the error message only; it never reaches a
30
+ * response body on its own.
31
+ */
32
+ export declare function parseCanonicalInteger(value: unknown, field?: string): bigint;
33
+ /**
34
+ * Parse a canonical integer that must be strictly positive.
35
+ *
36
+ * A premium quote uses this: zero is not a quote, and rounding a strictly
37
+ * positive quote up is what makes a per-call limit of zero an absolute block
38
+ * rather than a free pass for amounts too small to reach one credit.
39
+ */
40
+ export declare function parsePositiveCanonicalInteger(value: unknown, field?: string): bigint;
41
+ /**
42
+ * Serialize a nonnegative `bigint` to its canonical string form.
43
+ *
44
+ * Negative values are refused rather than serialized with a sign: no amount on
45
+ * this wire is negative, and a negative one reaching the wire would mean a
46
+ * balance calculation went wrong somewhere upstream of here.
47
+ */
48
+ export declare function formatCanonicalInteger(value: bigint, field?: string): string;
49
+ //# sourceMappingURL=canonical-integer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-integer.d.ts","sourceRoot":"","sources":["../src/canonical-integer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,SAAkB,IAAI,2BAA2B;CAClD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAW,GAAG,MAAM,CAY9E;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAW,GAAG,MAAM,CAMtF;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAW,GAAG,MAAM,CAQ9E"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Version and tolerant-reading vocabulary shared by every protocol parser.
3
+ *
4
+ * These are wire values, not application configuration. Keeping them here
5
+ * makes a client built from this package send the exact contract date and use
6
+ * the same reserved values as every other client.
7
+ */
8
+ export declare const ENLITT_API_VERSION = "2026-10-05";
9
+ export declare const ENLITT_VERSION_HEADER = "Enlitt-Version";
10
+ export declare const UNKNOWN_ENUM_VALUE = "other";
11
+ export declare const UNRECOGNIZED_ERROR_CODE = "unrecognized";
12
+ export type ParseMode = "strict" | "tolerant";
13
+ /** An omitted mode is strict; only response readers opt into tolerant mode. */
14
+ export interface ParseOptions {
15
+ readonly mode?: ParseMode;
16
+ }
17
+ /** A closed response enum after a tolerant reader sees a future member. */
18
+ export type Readable<T extends string> = T | typeof UNKNOWN_ENUM_VALUE;
19
+ /** A future discriminated response variant whose remaining fields cannot be trusted. */
20
+ export interface UnknownVariant {
21
+ readonly unknown: true;
22
+ readonly type: string;
23
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Version and tolerant-reading vocabulary shared by every protocol parser.
3
+ *
4
+ * These are wire values, not application configuration. Keeping them here
5
+ * makes a client built from this package send the exact contract date and use
6
+ * the same reserved values as every other client.
7
+ */
8
+ export declare const ENLITT_API_VERSION = "2026-10-05";
9
+ export declare const ENLITT_VERSION_HEADER = "Enlitt-Version";
10
+ export declare const UNKNOWN_ENUM_VALUE = "other";
11
+ export declare const UNRECOGNIZED_ERROR_CODE = "unrecognized";
12
+ export type ParseMode = "strict" | "tolerant";
13
+ /** An omitted mode is strict; only response readers opt into tolerant mode. */
14
+ export interface ParseOptions {
15
+ readonly mode?: ParseMode;
16
+ }
17
+ /** A closed response enum after a tolerant reader sees a future member. */
18
+ export type Readable<T extends string> = T | typeof UNKNOWN_ENUM_VALUE;
19
+ /** A future discriminated response variant whose remaining fields cannot be trusted. */
20
+ export interface UnknownVariant {
21
+ readonly unknown: true;
22
+ readonly type: string;
23
+ }
24
+ //# sourceMappingURL=compatibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compatibility.d.ts","sourceRoot":"","sources":["../src/compatibility.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,eAAe,CAAC;AAC/C,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AACtD,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAC1C,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE9C,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,2EAA2E;AAC3E,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG,OAAO,kBAAkB,CAAC;AAEvE,wFAAwF;AACxF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,67 @@
1
+ import { type ParseOptions } from "./compatibility.cjs";
2
+ import { type ResponseValidationResult } from "./responses.cjs";
3
+ export declare const WIRE_CONTRACT_FORMAT = 1;
4
+ /** Every closed string set a response parser must handle in strict and tolerant modes. */
5
+ export declare const WIRE_CLOSED_SETS: Readonly<{
6
+ readonly "api_key.scope": readonly ["model", "reporting"];
7
+ readonly "api_key.status": readonly ["active", "revoked", "expired"];
8
+ readonly "application.environment": readonly ["test", "live"];
9
+ readonly "application.status": readonly ["active", "suspended", "closed"];
10
+ readonly "cli_authorization.kind": readonly ["login", "step_up"];
11
+ readonly "contact.type": readonly ["email", "phone"];
12
+ readonly "email_sign_in.account_type": readonly ["user", "business"];
13
+ readonly "order.kind": readonly ["subscription", "bundle"];
14
+ readonly "order.refund.eligibility": readonly ["full", "half", "none"];
15
+ readonly "order.refund.reason": readonly ["unused", "within_usage_threshold", "usage_threshold_exceeded", "window_expired", "not_active", "gift"];
16
+ readonly "order.status": readonly ["pending", "active", "refund_pending", "refunded", "failed", "expired"];
17
+ readonly "payout.blocked_reason": readonly ["payout_blocked", "below_minimum", "outstanding_deficit", "tax_details_required", "payout_account_incomplete", "monthly_payout_taken", "payout_pending"];
18
+ readonly "payout.connected_account_status": readonly ["none", "onboarding", "restricted", "enabled", "rejected"];
19
+ readonly "personal_application_call.credit_type": readonly ["standard", "premium"];
20
+ readonly "personal_application_call.sort": readonly ["time", "charge"];
21
+ readonly "personal_application_call.status": readonly ["pending", "running", "completed", "failed", "canceled", "expired"];
22
+ readonly "plan.interval": readonly ["month", "year"];
23
+ readonly "premium_operation.billing": readonly ["managed"];
24
+ readonly "premium_terminal.status": readonly ["completed", "failed", "canceled"];
25
+ readonly "response.incomplete_details.reason": readonly ["max_output_tokens"];
26
+ readonly "response.output_item.status": readonly ["in_progress", "completed", "incomplete"];
27
+ readonly "response.status": readonly ["completed", "failed", "in_progress", "cancelled", "queued", "incomplete"];
28
+ readonly "response_stream.type": readonly ("response.completed" | "response.content_part.added" | "response.content_part.done" | "response.created" | "response.failed" | "response.function_call_arguments.delta" | "response.function_call_arguments.done" | "response.in_progress" | "response.incomplete" | "response.output_item.added" | "response.output_item.done" | "response.output_text.delta" | "response.output_text.done")[];
29
+ readonly "subscription.change_mode": readonly ["checkout", "change", "locked", "unavailable"];
30
+ readonly "subscription.locked_downgrade": readonly ["checkout", "change"];
31
+ readonly "subscription.service_tier": readonly ["normal", "reduced", "minimum"];
32
+ readonly "subscription.status": readonly ["active", "past_due", "canceled", "suspended"];
33
+ }>;
34
+ export interface WireContract {
35
+ readonly contract_format: typeof WIRE_CONTRACT_FORMAT;
36
+ readonly api_version: string;
37
+ readonly version_header: string;
38
+ readonly unknown_enum_value: string;
39
+ readonly unrecognized_error_code: string;
40
+ readonly idempotency_key: {
41
+ readonly min_length: number;
42
+ readonly max_length: number;
43
+ readonly min_retention_days: number;
44
+ };
45
+ readonly error_types: readonly string[];
46
+ readonly error_codes: Readonly<Record<string, {
47
+ readonly type: string;
48
+ readonly http_status: number;
49
+ readonly retryable: boolean;
50
+ readonly retry_after: "required" | "forbidden";
51
+ readonly authorize_url: "allowed" | "forbidden";
52
+ readonly admissible_max_charge: "allowed" | "forbidden";
53
+ readonly limit_rule: "required" | "forbidden";
54
+ }>>;
55
+ readonly closed_sets: Readonly<Record<string, readonly string[]>>;
56
+ }
57
+ export declare function buildWireContract(): WireContract;
58
+ export declare function serializeWireContract(contract: WireContract): string;
59
+ export type FixtureEndpoint = "create-response" | "begin-operation" | "report-terminal" | "usage" | "business-info";
60
+ interface FixtureEndpointDefinition {
61
+ readonly method: "GET" | "POST";
62
+ readonly path: string;
63
+ readonly validateRequest: ((value: unknown) => ResponseValidationResult<unknown>) | null;
64
+ readonly validateResponse: (value: unknown, options?: ParseOptions) => ResponseValidationResult<unknown>;
65
+ }
66
+ export declare const FIXTURE_ENDPOINTS: Readonly<Record<FixtureEndpoint, FixtureEndpointDefinition>>;
67
+ export {};