@omnicross/contracts 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +15 -15
- package/dist/account-tokens-types.d.cts +157 -1
- package/dist/account-tokens-types.d.ts +157 -1
- package/dist/audit-types.cjs +36 -0
- package/dist/audit-types.d.cts +98 -0
- package/dist/audit-types.d.ts +98 -0
- package/dist/audit-types.js +11 -0
- package/dist/billing-types.cjs +33 -0
- package/dist/billing-types.d.cts +98 -0
- package/dist/billing-types.d.ts +98 -0
- package/dist/billing-types.js +8 -0
- package/dist/canonical-models.d.cts +1 -1
- package/dist/canonical-models.d.ts +1 -1
- package/dist/endpoint-resolver.d.cts +1 -1
- package/dist/endpoint-resolver.d.ts +1 -1
- package/dist/health-logging-types.cjs +32 -0
- package/dist/health-logging-types.d.cts +68 -0
- package/dist/health-logging-types.d.ts +68 -0
- package/dist/health-logging-types.js +7 -0
- package/dist/index.cjs +63 -0
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +55 -0
- package/dist/{llm-config-D1jKQLVp.d.ts → llm-config-CKOaFFdy.d.ts} +8 -1
- package/dist/{llm-config-CQjOimv2.d.cts → llm-config-DeWNx1ig.d.cts} +8 -1
- package/dist/llm-config.d.cts +1 -1
- package/dist/llm-config.d.ts +1 -1
- package/dist/provider-presets/index.d.cts +2 -2
- package/dist/provider-presets/index.d.ts +2 -2
- package/dist/subscription-model-catalog.cjs +40 -0
- package/dist/subscription-model-catalog.d.cts +34 -0
- package/dist/subscription-model-catalog.d.ts +34 -0
- package/dist/subscription-model-catalog.js +14 -0
- package/dist/thinking-config.d.cts +1 -1
- package/dist/thinking-config.d.ts +1 -1
- package/dist/usage-stats-types.d.cts +22 -1
- package/dist/usage-stats-types.d.ts +22 -1
- package/dist/voucher-types.cjs +32 -0
- package/dist/voucher-types.d.cts +153 -0
- package/dist/voucher-types.d.ts +153 -0
- package/dist/voucher-types.js +7 -0
- package/dist/webhook-types.cjs +40 -0
- package/dist/webhook-types.d.cts +122 -0
- package/dist/webhook-types.d.ts +122 -0
- package/dist/webhook-types.js +14 -0
- package/package.json +156 -126
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request-audit contracts (request-audit-log, design D1/D2).
|
|
3
|
+
*
|
|
4
|
+
* Two dependency-light shapes shared across the `@omnicross/*` packages:
|
|
5
|
+
* - `AuditRecord` — the FROZEN per-request audit entry. It carries request
|
|
6
|
+
* METADATA (who/where/when/status/latency/model) plus, ONLY when body capture
|
|
7
|
+
* is explicitly enabled, a redacted+truncated request/response body snapshot.
|
|
8
|
+
* It is SECRET-FREE BY CONSTRUCTION: it holds the outbound key ID (NEVER the
|
|
9
|
+
* key material/hash), the client IP + user-agent (PII, hence the whole store
|
|
10
|
+
* is authed-only + TTL-pruned), and NEVER a token, Authorization header, or
|
|
11
|
+
* api-key header value (request headers are NEVER captured). A secret-scan
|
|
12
|
+
* test asserts no key/token pattern survives in a written record.
|
|
13
|
+
* - `AuditConfig` — the `audit` config segment. Two independent switches:
|
|
14
|
+
* `enabled` (record metadata) and `captureBodies` (the sensitive second
|
|
15
|
+
* opt-in — record bodies too), both default OFF (zero regression).
|
|
16
|
+
*
|
|
17
|
+
* @module audit-types
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* One per-request audit entry (design D1). The metadata fields are recorded
|
|
21
|
+
* whenever audit is `enabled`; the two body snapshots are present ONLY when
|
|
22
|
+
* `captureBodies` is ALSO on, and always after truncation + redaction. NO field
|
|
23
|
+
* ever holds key material, an upstream token, or an Authorization/api-key header.
|
|
24
|
+
*/
|
|
25
|
+
interface AuditRecord {
|
|
26
|
+
/** Unique record id (a generated request id — NOT any secret). */
|
|
27
|
+
id: string;
|
|
28
|
+
/** Epoch ms the request was captured. */
|
|
29
|
+
ts: number;
|
|
30
|
+
/** Outbound key id (attribution) — NEVER the key secret/hash. Null when unauthenticated. */
|
|
31
|
+
keyId?: string | null;
|
|
32
|
+
/** Client IP (PII). Socket address by default; a trusted forwarded header only when configured. */
|
|
33
|
+
ip?: string;
|
|
34
|
+
/** Client user-agent (PII). */
|
|
35
|
+
ua?: string;
|
|
36
|
+
/** HTTP method. */
|
|
37
|
+
method: string;
|
|
38
|
+
/** Request path (query string dropped so no secret query param is stored). */
|
|
39
|
+
path: string;
|
|
40
|
+
/** Resolved upstream model. */
|
|
41
|
+
model?: string;
|
|
42
|
+
/** Upstream provider id (or `'byo'`). */
|
|
43
|
+
provider?: string;
|
|
44
|
+
/** HTTP status the client received. */
|
|
45
|
+
status: number;
|
|
46
|
+
/** End-to-end latency (ms). */
|
|
47
|
+
latencyMs: number;
|
|
48
|
+
/** Prompt-side token count (present only when the host correlates usage). */
|
|
49
|
+
inputTokens?: number;
|
|
50
|
+
/** Completion-side token count (present only when the host correlates usage). */
|
|
51
|
+
outputTokens?: number;
|
|
52
|
+
/** Cost in USD (present only when the host correlates usage). */
|
|
53
|
+
costUsd?: number;
|
|
54
|
+
/** Sanitized error message (present only on a failed relay). */
|
|
55
|
+
error?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Request body snapshot — present ONLY when `captureBodies`, truncated to the
|
|
58
|
+
* configured cap, and ALWAYS run through the secret-redaction pass first.
|
|
59
|
+
*/
|
|
60
|
+
requestBody?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Response body snapshot — present ONLY when `captureBodies` AND the response
|
|
63
|
+
* was NON-streaming (a streaming response records metadata only), truncated +
|
|
64
|
+
* redacted like `requestBody`.
|
|
65
|
+
*/
|
|
66
|
+
responseBody?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The `audit` config segment (design D2), normalized like `accountHealth`.
|
|
70
|
+
* Absent/`enabled:false` ⇒ no sink wired + no capture ⇒ byte-identical zero
|
|
71
|
+
* regression. `captureBodies` is a SEPARATE, sensitive opt-in that does nothing
|
|
72
|
+
* unless `enabled` is also on.
|
|
73
|
+
*/
|
|
74
|
+
interface AuditConfig {
|
|
75
|
+
/** Master switch; default FALSE (zero regression). */
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
/** Capture request/response bodies too (redacted+truncated); default FALSE. */
|
|
78
|
+
captureBodies: boolean;
|
|
79
|
+
/** Per-body truncation cap in bytes; default 8192, clamped. */
|
|
80
|
+
maxBodyBytes: number;
|
|
81
|
+
/** TTL retention in days; default 7, clamped `[1, 365]`. */
|
|
82
|
+
retentionDays: number;
|
|
83
|
+
/**
|
|
84
|
+
* Trust the `X-Forwarded-For` header for the client IP (LEAD OQ1 anti-spoof).
|
|
85
|
+
* Default FALSE — the socket remote address is authoritative. Only set true
|
|
86
|
+
* behind a trusted reverse proxy; a client-supplied XFF is NEVER trusted by
|
|
87
|
+
* default.
|
|
88
|
+
*/
|
|
89
|
+
trustForwardedFor: boolean;
|
|
90
|
+
}
|
|
91
|
+
/** Frozen defaults for the `audit` segment (SSOT). */
|
|
92
|
+
declare const DEFAULT_AUDIT_CONFIG: AuditConfig;
|
|
93
|
+
/** One page of audit records the authed admin query returns (newest first). */
|
|
94
|
+
interface AuditQueryResult {
|
|
95
|
+
records: AuditRecord[];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { type AuditConfig, type AuditQueryResult, type AuditRecord, DEFAULT_AUDIT_CONFIG };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/billing-types.ts
|
|
21
|
+
var billing_types_exports = {};
|
|
22
|
+
__export(billing_types_exports, {
|
|
23
|
+
DEFAULT_BILLING_CONFIG: () => DEFAULT_BILLING_CONFIG
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(billing_types_exports);
|
|
26
|
+
var DEFAULT_BILLING_CONFIG = {
|
|
27
|
+
enabled: false,
|
|
28
|
+
maxRetryAgeMs: 24 * 60 * 6e4
|
|
29
|
+
};
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
DEFAULT_BILLING_CONFIG
|
|
33
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Billing-event-stream contracts (billing-event-stream, design D1/D6).
|
|
3
|
+
*
|
|
4
|
+
* Two dependency-light shapes shared across the `@omnicross/*` packages:
|
|
5
|
+
* - `BillingEvent` — the FROZEN per-request metered fact an EXTERNAL consumer
|
|
6
|
+
* ingests (a metering service, a data warehouse, a billing platform). It is
|
|
7
|
+
* SECRET-FREE BY CONSTRUCTION: it carries the outbound key ID (an id, NEVER
|
|
8
|
+
* the key material/hash) and NEVER a token, Authorization header, or the
|
|
9
|
+
* signing secret. Its `id` (the request id) doubles as the consumer's
|
|
10
|
+
* IDEMPOTENCY KEY — delivery is at-least-once, so a consumer dedupes by `id`.
|
|
11
|
+
* A secret-scan test asserts no key/token/secret pattern survives in a
|
|
12
|
+
* written/POSTed event.
|
|
13
|
+
* - `BillingConfig` — the `billing` config segment. Default OFF (zero
|
|
14
|
+
* regression). Carries the OPTIONAL POST `endpoint` (absent ⇒ ledger-only
|
|
15
|
+
* mode) and the OPTIONAL HMAC `secret` (the ONLY secret — encrypted at rest +
|
|
16
|
+
* masked in admin, never in a payload/log).
|
|
17
|
+
*
|
|
18
|
+
* Distinct from `usage-events.jsonl` (internal dashboard telemetry): billing is
|
|
19
|
+
* the external-facing metered fact with its OWN schema + delivery + HMAC.
|
|
20
|
+
*
|
|
21
|
+
* @module billing-types
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* One per-request billing event (design D1) — the metered fact for external
|
|
25
|
+
* consumption. Produced at the post-response point from the SAME computed cost
|
|
26
|
+
* the usage telemetry records (no double pricing). NO field ever holds key
|
|
27
|
+
* material, an upstream token, or the HMAC signing secret.
|
|
28
|
+
*/
|
|
29
|
+
interface BillingEvent {
|
|
30
|
+
/**
|
|
31
|
+
* Request id — the consumer's IDEMPOTENCY KEY. Stable for one event across
|
|
32
|
+
* delivery RETRIES (the retry sweep re-POSTs the SAME id) so an at-least-once
|
|
33
|
+
* consumer applies it exactly once. NOT any secret.
|
|
34
|
+
*/
|
|
35
|
+
id: string;
|
|
36
|
+
/** Epoch ms the request was billed (the request timestamp). */
|
|
37
|
+
ts: number;
|
|
38
|
+
/** Outbound key id (attribution) — NEVER the key secret/hash. Null when unattributed. */
|
|
39
|
+
keyId?: string | null;
|
|
40
|
+
/** Resolved upstream model the request billed against. */
|
|
41
|
+
model: string;
|
|
42
|
+
/** Upstream provider id (or `'byo'`). */
|
|
43
|
+
provider?: string;
|
|
44
|
+
/** Re-auth mode the request billed under (BYO key vs subscription OAuth). */
|
|
45
|
+
authMode: 'byo' | 'subscription';
|
|
46
|
+
/** Prompt-side token count. */
|
|
47
|
+
inputTokens: number;
|
|
48
|
+
/** Completion-side token count. */
|
|
49
|
+
outputTokens: number;
|
|
50
|
+
/** Cost in USD (the SAME value the usage telemetry recorded). */
|
|
51
|
+
costUsd: number;
|
|
52
|
+
/** HTTP status of the billed request. */
|
|
53
|
+
status: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The `billing` config segment (design D6), normalized like `audit`.
|
|
57
|
+
* Absent/`enabled:false` ⇒ no sink wired ⇒ `publishBillingEvent` is a no-op ⇒
|
|
58
|
+
* no append, no POST, byte-identical zero regression. `enabled` WITHOUT an
|
|
59
|
+
* `endpoint` is a first-class LEDGER-ONLY mode (the durable jsonl IS the product;
|
|
60
|
+
* an external tailer consumes it). The `secret` is the ONLY secret field
|
|
61
|
+
* (encrypted at rest + masked in admin).
|
|
62
|
+
*/
|
|
63
|
+
interface BillingConfig {
|
|
64
|
+
/** Master switch; default FALSE (zero regression). */
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* POST target for the built-in delivery. ABSENT ⇒ ledger-only mode: events are
|
|
68
|
+
* durably appended and an external consumer tails the jsonl directly (no push).
|
|
69
|
+
*/
|
|
70
|
+
endpoint?: string;
|
|
71
|
+
/**
|
|
72
|
+
* HMAC-SHA256 signing key — a SECRET. When set, each POST carries
|
|
73
|
+
* `X-Omnicross-Billing-Signature: sha256=<hmac hex of body>`. Encrypted at rest
|
|
74
|
+
* + masked in admin views; the secret ONLY signs, it NEVER travels in the event
|
|
75
|
+
* payload or a log line.
|
|
76
|
+
*/
|
|
77
|
+
secret?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Stop RE-POSTing an undelivered event after this age (ms); default 24h,
|
|
80
|
+
* clamped. This governs RETRY only — an over-age undelivered event is RETAINED
|
|
81
|
+
* in the ledger for reconciliation, NEVER deleted (a billing ledger is a
|
|
82
|
+
* financial record).
|
|
83
|
+
*/
|
|
84
|
+
maxRetryAgeMs: number;
|
|
85
|
+
}
|
|
86
|
+
/** Frozen defaults for the `billing` segment (SSOT). 24h retry bound. */
|
|
87
|
+
declare const DEFAULT_BILLING_CONFIG: BillingConfig;
|
|
88
|
+
/** Aggregate delivery status the authed admin surfaces (secret-free counts). */
|
|
89
|
+
interface BillingDeliveryStatus {
|
|
90
|
+
/** Total events in the durable ledger. */
|
|
91
|
+
total: number;
|
|
92
|
+
/** Events an external endpoint has acknowledged (delivered). */
|
|
93
|
+
delivered: number;
|
|
94
|
+
/** Events not yet delivered (still retried within `maxRetryAgeMs`, then retained). */
|
|
95
|
+
pending: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { type BillingConfig, type BillingDeliveryStatus, type BillingEvent, DEFAULT_BILLING_CONFIG };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Billing-event-stream contracts (billing-event-stream, design D1/D6).
|
|
3
|
+
*
|
|
4
|
+
* Two dependency-light shapes shared across the `@omnicross/*` packages:
|
|
5
|
+
* - `BillingEvent` — the FROZEN per-request metered fact an EXTERNAL consumer
|
|
6
|
+
* ingests (a metering service, a data warehouse, a billing platform). It is
|
|
7
|
+
* SECRET-FREE BY CONSTRUCTION: it carries the outbound key ID (an id, NEVER
|
|
8
|
+
* the key material/hash) and NEVER a token, Authorization header, or the
|
|
9
|
+
* signing secret. Its `id` (the request id) doubles as the consumer's
|
|
10
|
+
* IDEMPOTENCY KEY — delivery is at-least-once, so a consumer dedupes by `id`.
|
|
11
|
+
* A secret-scan test asserts no key/token/secret pattern survives in a
|
|
12
|
+
* written/POSTed event.
|
|
13
|
+
* - `BillingConfig` — the `billing` config segment. Default OFF (zero
|
|
14
|
+
* regression). Carries the OPTIONAL POST `endpoint` (absent ⇒ ledger-only
|
|
15
|
+
* mode) and the OPTIONAL HMAC `secret` (the ONLY secret — encrypted at rest +
|
|
16
|
+
* masked in admin, never in a payload/log).
|
|
17
|
+
*
|
|
18
|
+
* Distinct from `usage-events.jsonl` (internal dashboard telemetry): billing is
|
|
19
|
+
* the external-facing metered fact with its OWN schema + delivery + HMAC.
|
|
20
|
+
*
|
|
21
|
+
* @module billing-types
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* One per-request billing event (design D1) — the metered fact for external
|
|
25
|
+
* consumption. Produced at the post-response point from the SAME computed cost
|
|
26
|
+
* the usage telemetry records (no double pricing). NO field ever holds key
|
|
27
|
+
* material, an upstream token, or the HMAC signing secret.
|
|
28
|
+
*/
|
|
29
|
+
interface BillingEvent {
|
|
30
|
+
/**
|
|
31
|
+
* Request id — the consumer's IDEMPOTENCY KEY. Stable for one event across
|
|
32
|
+
* delivery RETRIES (the retry sweep re-POSTs the SAME id) so an at-least-once
|
|
33
|
+
* consumer applies it exactly once. NOT any secret.
|
|
34
|
+
*/
|
|
35
|
+
id: string;
|
|
36
|
+
/** Epoch ms the request was billed (the request timestamp). */
|
|
37
|
+
ts: number;
|
|
38
|
+
/** Outbound key id (attribution) — NEVER the key secret/hash. Null when unattributed. */
|
|
39
|
+
keyId?: string | null;
|
|
40
|
+
/** Resolved upstream model the request billed against. */
|
|
41
|
+
model: string;
|
|
42
|
+
/** Upstream provider id (or `'byo'`). */
|
|
43
|
+
provider?: string;
|
|
44
|
+
/** Re-auth mode the request billed under (BYO key vs subscription OAuth). */
|
|
45
|
+
authMode: 'byo' | 'subscription';
|
|
46
|
+
/** Prompt-side token count. */
|
|
47
|
+
inputTokens: number;
|
|
48
|
+
/** Completion-side token count. */
|
|
49
|
+
outputTokens: number;
|
|
50
|
+
/** Cost in USD (the SAME value the usage telemetry recorded). */
|
|
51
|
+
costUsd: number;
|
|
52
|
+
/** HTTP status of the billed request. */
|
|
53
|
+
status: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The `billing` config segment (design D6), normalized like `audit`.
|
|
57
|
+
* Absent/`enabled:false` ⇒ no sink wired ⇒ `publishBillingEvent` is a no-op ⇒
|
|
58
|
+
* no append, no POST, byte-identical zero regression. `enabled` WITHOUT an
|
|
59
|
+
* `endpoint` is a first-class LEDGER-ONLY mode (the durable jsonl IS the product;
|
|
60
|
+
* an external tailer consumes it). The `secret` is the ONLY secret field
|
|
61
|
+
* (encrypted at rest + masked in admin).
|
|
62
|
+
*/
|
|
63
|
+
interface BillingConfig {
|
|
64
|
+
/** Master switch; default FALSE (zero regression). */
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* POST target for the built-in delivery. ABSENT ⇒ ledger-only mode: events are
|
|
68
|
+
* durably appended and an external consumer tails the jsonl directly (no push).
|
|
69
|
+
*/
|
|
70
|
+
endpoint?: string;
|
|
71
|
+
/**
|
|
72
|
+
* HMAC-SHA256 signing key — a SECRET. When set, each POST carries
|
|
73
|
+
* `X-Omnicross-Billing-Signature: sha256=<hmac hex of body>`. Encrypted at rest
|
|
74
|
+
* + masked in admin views; the secret ONLY signs, it NEVER travels in the event
|
|
75
|
+
* payload or a log line.
|
|
76
|
+
*/
|
|
77
|
+
secret?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Stop RE-POSTing an undelivered event after this age (ms); default 24h,
|
|
80
|
+
* clamped. This governs RETRY only — an over-age undelivered event is RETAINED
|
|
81
|
+
* in the ledger for reconciliation, NEVER deleted (a billing ledger is a
|
|
82
|
+
* financial record).
|
|
83
|
+
*/
|
|
84
|
+
maxRetryAgeMs: number;
|
|
85
|
+
}
|
|
86
|
+
/** Frozen defaults for the `billing` segment (SSOT). 24h retry bound. */
|
|
87
|
+
declare const DEFAULT_BILLING_CONFIG: BillingConfig;
|
|
88
|
+
/** Aggregate delivery status the authed admin surfaces (secret-free counts). */
|
|
89
|
+
interface BillingDeliveryStatus {
|
|
90
|
+
/** Total events in the durable ledger. */
|
|
91
|
+
total: number;
|
|
92
|
+
/** Events an external endpoint has acknowledged (delivered). */
|
|
93
|
+
delivered: number;
|
|
94
|
+
/** Events not yet delivered (still retried within `maxRetryAgeMs`, then retained). */
|
|
95
|
+
pending: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { type BillingConfig, type BillingDeliveryStatus, type BillingEvent, DEFAULT_BILLING_CONFIG };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/health-logging-types.ts
|
|
21
|
+
var health_logging_types_exports = {};
|
|
22
|
+
__export(health_logging_types_exports, {
|
|
23
|
+
healthHttpStatus: () => healthHttpStatus
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(health_logging_types_exports);
|
|
26
|
+
function healthHttpStatus(status) {
|
|
27
|
+
return status === "ok" ? 200 : 503;
|
|
28
|
+
}
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
healthHttpStatus
|
|
32
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health-probe + logging contracts (daemon-health-endpoint / configurable-logging).
|
|
3
|
+
*
|
|
4
|
+
* Two small, dependency-light shapes shared across the `@omnicross/*` packages:
|
|
5
|
+
* - `HealthReport` — the coarse, SECRET-FREE body served by the unauthenticated
|
|
6
|
+
* `/health` probe (mounted on the admin server before its auth gate, and
|
|
7
|
+
* optionally on the outbound `/v1/*` server before key-auth). Frozen so a
|
|
8
|
+
* liveness/readiness probe + sibling changes (#8 health-cron surfacing into
|
|
9
|
+
* `checks`) agree on one shape.
|
|
10
|
+
* - `LogLevel` / `LoggingConfig` — the configurable-logger's level enum + config
|
|
11
|
+
* segment. Frozen so sibling changes (#5 webhooks / #13 audit-log) reuse the
|
|
12
|
+
* SAME level vocabulary + config shape rather than reinventing it.
|
|
13
|
+
*
|
|
14
|
+
* NON-SECRET by construction: nothing here carries a token, email, config value,
|
|
15
|
+
* or record-of-count. `HealthReport.checks` are COARSE booleans only.
|
|
16
|
+
*
|
|
17
|
+
* @module health-logging-types
|
|
18
|
+
*/
|
|
19
|
+
/** The coarse health status. Anything other than `ok` maps to HTTP 503. */
|
|
20
|
+
type HealthStatus = 'ok' | 'degraded' | 'error';
|
|
21
|
+
/**
|
|
22
|
+
* The `/health` probe body (design D2). COARSE + SECRET-FREE:
|
|
23
|
+
* - `status` — `ok` (200) | `degraded` | `error` (both 503).
|
|
24
|
+
* - `version` — the daemon package version (already exposed pre-auth via
|
|
25
|
+
* the `x-omnicross-daemon` response header; non-sensitive).
|
|
26
|
+
* - `uptimeSeconds` — `Math.floor(process.uptime())`.
|
|
27
|
+
* - `timestamp` — ISO time the report was built.
|
|
28
|
+
* - `memory` — coarse process stats (rss / heapUsed, MB).
|
|
29
|
+
* - `checks` — COARSE dependency booleans ONLY (never tokens/emails/
|
|
30
|
+
* config-values/record-counts).
|
|
31
|
+
*/
|
|
32
|
+
interface HealthReport {
|
|
33
|
+
status: HealthStatus;
|
|
34
|
+
version: string;
|
|
35
|
+
uptimeSeconds: number;
|
|
36
|
+
timestamp: string;
|
|
37
|
+
memory: {
|
|
38
|
+
rssMb: number;
|
|
39
|
+
heapUsedMb: number;
|
|
40
|
+
};
|
|
41
|
+
checks: Record<string, boolean>;
|
|
42
|
+
}
|
|
43
|
+
/** Map a {@link HealthStatus} to its probe HTTP code: `ok` → 200, else → 503. */
|
|
44
|
+
declare function healthHttpStatus(status: HealthStatus): number;
|
|
45
|
+
/**
|
|
46
|
+
* The logger's level threshold (configurable-logging, design D3). Numeric
|
|
47
|
+
* severity order `error(0) < warn(1) < info(2) < debug(3)`; a message at a level
|
|
48
|
+
* BELOW the configured threshold's severity (i.e. a higher ordinal) is dropped.
|
|
49
|
+
*/
|
|
50
|
+
type LogLevel = 'error' | 'warn' | 'info' | 'debug';
|
|
51
|
+
/** Output shape of the logger sinks. */
|
|
52
|
+
type LogFormat = 'text' | 'json';
|
|
53
|
+
/**
|
|
54
|
+
* The daemon's `logging` config segment (design D3/D4). ALL fields optional; an
|
|
55
|
+
* absent/empty segment reads as the zero-regression default (console + all
|
|
56
|
+
* levels + text — byte-identical to the legacy `ConsoleLogger`).
|
|
57
|
+
* - `level` — threshold (default `debug` = print everything).
|
|
58
|
+
* - `format` — `text` (human-readable, legacy shape) | `json` (structured lines).
|
|
59
|
+
* - `file` — OPTIONAL append-only file sink path. A PLAIN config value (NOT a
|
|
60
|
+
* secret — never walked by the at-rest secret encryption).
|
|
61
|
+
*/
|
|
62
|
+
interface LoggingConfig {
|
|
63
|
+
level?: LogLevel;
|
|
64
|
+
format?: LogFormat;
|
|
65
|
+
file?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { type HealthReport, type HealthStatus, type LogFormat, type LogLevel, type LoggingConfig, healthHttpStatus };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health-probe + logging contracts (daemon-health-endpoint / configurable-logging).
|
|
3
|
+
*
|
|
4
|
+
* Two small, dependency-light shapes shared across the `@omnicross/*` packages:
|
|
5
|
+
* - `HealthReport` — the coarse, SECRET-FREE body served by the unauthenticated
|
|
6
|
+
* `/health` probe (mounted on the admin server before its auth gate, and
|
|
7
|
+
* optionally on the outbound `/v1/*` server before key-auth). Frozen so a
|
|
8
|
+
* liveness/readiness probe + sibling changes (#8 health-cron surfacing into
|
|
9
|
+
* `checks`) agree on one shape.
|
|
10
|
+
* - `LogLevel` / `LoggingConfig` — the configurable-logger's level enum + config
|
|
11
|
+
* segment. Frozen so sibling changes (#5 webhooks / #13 audit-log) reuse the
|
|
12
|
+
* SAME level vocabulary + config shape rather than reinventing it.
|
|
13
|
+
*
|
|
14
|
+
* NON-SECRET by construction: nothing here carries a token, email, config value,
|
|
15
|
+
* or record-of-count. `HealthReport.checks` are COARSE booleans only.
|
|
16
|
+
*
|
|
17
|
+
* @module health-logging-types
|
|
18
|
+
*/
|
|
19
|
+
/** The coarse health status. Anything other than `ok` maps to HTTP 503. */
|
|
20
|
+
type HealthStatus = 'ok' | 'degraded' | 'error';
|
|
21
|
+
/**
|
|
22
|
+
* The `/health` probe body (design D2). COARSE + SECRET-FREE:
|
|
23
|
+
* - `status` — `ok` (200) | `degraded` | `error` (both 503).
|
|
24
|
+
* - `version` — the daemon package version (already exposed pre-auth via
|
|
25
|
+
* the `x-omnicross-daemon` response header; non-sensitive).
|
|
26
|
+
* - `uptimeSeconds` — `Math.floor(process.uptime())`.
|
|
27
|
+
* - `timestamp` — ISO time the report was built.
|
|
28
|
+
* - `memory` — coarse process stats (rss / heapUsed, MB).
|
|
29
|
+
* - `checks` — COARSE dependency booleans ONLY (never tokens/emails/
|
|
30
|
+
* config-values/record-counts).
|
|
31
|
+
*/
|
|
32
|
+
interface HealthReport {
|
|
33
|
+
status: HealthStatus;
|
|
34
|
+
version: string;
|
|
35
|
+
uptimeSeconds: number;
|
|
36
|
+
timestamp: string;
|
|
37
|
+
memory: {
|
|
38
|
+
rssMb: number;
|
|
39
|
+
heapUsedMb: number;
|
|
40
|
+
};
|
|
41
|
+
checks: Record<string, boolean>;
|
|
42
|
+
}
|
|
43
|
+
/** Map a {@link HealthStatus} to its probe HTTP code: `ok` → 200, else → 503. */
|
|
44
|
+
declare function healthHttpStatus(status: HealthStatus): number;
|
|
45
|
+
/**
|
|
46
|
+
* The logger's level threshold (configurable-logging, design D3). Numeric
|
|
47
|
+
* severity order `error(0) < warn(1) < info(2) < debug(3)`; a message at a level
|
|
48
|
+
* BELOW the configured threshold's severity (i.e. a higher ordinal) is dropped.
|
|
49
|
+
*/
|
|
50
|
+
type LogLevel = 'error' | 'warn' | 'info' | 'debug';
|
|
51
|
+
/** Output shape of the logger sinks. */
|
|
52
|
+
type LogFormat = 'text' | 'json';
|
|
53
|
+
/**
|
|
54
|
+
* The daemon's `logging` config segment (design D3/D4). ALL fields optional; an
|
|
55
|
+
* absent/empty segment reads as the zero-regression default (console + all
|
|
56
|
+
* levels + text — byte-identical to the legacy `ConsoleLogger`).
|
|
57
|
+
* - `level` — threshold (default `debug` = print everything).
|
|
58
|
+
* - `format` — `text` (human-readable, legacy shape) | `json` (structured lines).
|
|
59
|
+
* - `file` — OPTIONAL append-only file sink path. A PLAIN config value (NOT a
|
|
60
|
+
* secret — never walked by the at-rest secret encryption).
|
|
61
|
+
*/
|
|
62
|
+
interface LoggingConfig {
|
|
63
|
+
level?: LogLevel;
|
|
64
|
+
format?: LogFormat;
|
|
65
|
+
file?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { type HealthReport, type HealthStatus, type LogFormat, type LogLevel, type LoggingConfig, healthHttpStatus };
|