@omnicross/contracts 0.1.2 → 0.1.3

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 (41) hide show
  1. package/dist/account-tokens-types.d.cts +157 -1
  2. package/dist/account-tokens-types.d.ts +157 -1
  3. package/dist/audit-types.cjs +36 -0
  4. package/dist/audit-types.d.cts +98 -0
  5. package/dist/audit-types.d.ts +98 -0
  6. package/dist/audit-types.js +11 -0
  7. package/dist/billing-types.cjs +33 -0
  8. package/dist/billing-types.d.cts +98 -0
  9. package/dist/billing-types.d.ts +98 -0
  10. package/dist/billing-types.js +8 -0
  11. package/dist/canonical-models.d.cts +1 -1
  12. package/dist/canonical-models.d.ts +1 -1
  13. package/dist/endpoint-resolver.d.cts +1 -1
  14. package/dist/endpoint-resolver.d.ts +1 -1
  15. package/dist/health-logging-types.cjs +32 -0
  16. package/dist/health-logging-types.d.cts +68 -0
  17. package/dist/health-logging-types.d.ts +68 -0
  18. package/dist/health-logging-types.js +7 -0
  19. package/dist/index.cjs +48 -0
  20. package/dist/index.d.cts +8 -3
  21. package/dist/index.d.ts +8 -3
  22. package/dist/index.js +42 -0
  23. package/dist/{llm-config-D1jKQLVp.d.ts → llm-config-CKOaFFdy.d.ts} +8 -1
  24. package/dist/{llm-config-CQjOimv2.d.cts → llm-config-DeWNx1ig.d.cts} +8 -1
  25. package/dist/llm-config.d.cts +1 -1
  26. package/dist/llm-config.d.ts +1 -1
  27. package/dist/provider-presets/index.d.cts +2 -2
  28. package/dist/provider-presets/index.d.ts +2 -2
  29. package/dist/thinking-config.d.cts +1 -1
  30. package/dist/thinking-config.d.ts +1 -1
  31. package/dist/usage-stats-types.d.cts +22 -1
  32. package/dist/usage-stats-types.d.ts +22 -1
  33. package/dist/voucher-types.cjs +32 -0
  34. package/dist/voucher-types.d.cts +153 -0
  35. package/dist/voucher-types.d.ts +153 -0
  36. package/dist/voucher-types.js +7 -0
  37. package/dist/webhook-types.cjs +40 -0
  38. package/dist/webhook-types.d.cts +122 -0
  39. package/dist/webhook-types.d.ts +122 -0
  40. package/dist/webhook-types.js +14 -0
  41. package/package.json +26 -1
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Webhook notification contracts (webhook-notifications, design D1).
3
+ *
4
+ * Two small, dependency-light shapes shared across the `@omnicross/*` packages:
5
+ * - `WebhookEvent` — the FROZEN discriminated union of operational signals a
6
+ * relay can deliver out-of-band (account recovery/anomaly, key quota
7
+ * warning/exceeded, server error, and a config-UI `test`). Every payload is
8
+ * SECRET-FREE BY CONSTRUCTION: it carries only opaque provider/account ids, a
9
+ * key id (NEVER key material or a hash), a coarse state, limit/spend numbers,
10
+ * and a sanitized message. Nothing here can hold a token, secret, or hash.
11
+ * - `WebhookDestination` / `WebhookConfig` — the destination config schema. A
12
+ * destination's `secret` (its HMAC signing key) is the ONLY secret; it is
13
+ * encrypted at rest, masked in admin views, and used ONLY to sign an outgoing
14
+ * request — it is NEVER placed in a payload or a log line.
15
+ *
16
+ * The union is FROZEN: the emit port (core), the dispatcher (daemon), and the
17
+ * sources (#2 health / #4 quota / server-error) all agree on this one shape.
18
+ * Adding a destination `type` is additive behind the dispatcher's formatter.
19
+ *
20
+ * @module webhook-types
21
+ */
22
+ /** The coarse anomaly state an account transitioned into (secret-free). */
23
+ type WebhookAnomalyState = 'blocked' | 'unauthorized' | 'rate_limited' | 'overloaded';
24
+ /** The cost-limit scope a key quota event refers to. */
25
+ type WebhookQuotaScope = 'daily' | 'weekly' | 'total';
26
+ /**
27
+ * The FROZEN webhook event union (design D1). EVERY field is non-secret:
28
+ * opaque provider/account ids, a key id (NOT key material/hash), a coarse state,
29
+ * numbers, and a sanitized message. A test asserts no token/secret/hash string
30
+ * can appear in any serialized payload.
31
+ */
32
+ type WebhookEvent = {
33
+ kind: 'account.recovery';
34
+ at: number;
35
+ providerId: string;
36
+ accountId: string;
37
+ } | {
38
+ kind: 'account.anomaly';
39
+ at: number;
40
+ providerId: string;
41
+ accountId: string;
42
+ state: WebhookAnomalyState;
43
+ } | {
44
+ kind: 'key.quotaWarning';
45
+ at: number;
46
+ keyId: string;
47
+ scope: WebhookQuotaScope;
48
+ limitUsd: number;
49
+ spentUsd: number;
50
+ } | {
51
+ kind: 'key.quotaExceeded';
52
+ at: number;
53
+ keyId: string;
54
+ scope: WebhookQuotaScope;
55
+ limitUsd: number;
56
+ spentUsd: number;
57
+ } | {
58
+ kind: 'server.error';
59
+ at: number;
60
+ message: string;
61
+ } | {
62
+ kind: 'test';
63
+ at: number;
64
+ };
65
+ /** The event discriminator — the value a destination `events` filter matches. */
66
+ type WebhookEventKind = WebhookEvent['kind'];
67
+ /** All event kinds (SSOT for validation + the admin UI's filter checklist). */
68
+ declare const WEBHOOK_EVENT_KINDS: readonly WebhookEventKind[];
69
+ /** The v1 destination types (dingtalk/slack/… are additive later). */
70
+ type WebhookDestinationType = 'custom' | 'feishu';
71
+ /** All destination types (SSOT for validation + the admin UI's type select). */
72
+ declare const WEBHOOK_DESTINATION_TYPES: readonly WebhookDestinationType[];
73
+ /**
74
+ * One webhook destination (design D5). `secret` is the OPTIONAL HMAC signing key
75
+ * (a SECRET — encrypted at rest, masked in views, never in a payload/log). An
76
+ * absent/empty `events` filter matches ALL event kinds.
77
+ */
78
+ interface WebhookDestination {
79
+ /** Stable id (the admin CRUD key + the test-button target). */
80
+ id: string;
81
+ /** The formatter/signing scheme to use. */
82
+ type: WebhookDestinationType;
83
+ /** The POST target URL. */
84
+ url: string;
85
+ /** OPTIONAL HMAC signing key (SECRET; may be an `enc:`/`$ENV` envelope at rest). */
86
+ secret?: string;
87
+ /** OPTIONAL event-kind filter; absent/empty ⇒ receive ALL kinds. */
88
+ events?: WebhookEventKind[];
89
+ /** Whether this destination receives events. */
90
+ enabled: boolean;
91
+ }
92
+ /**
93
+ * The `webhook` config segment (design D5). Absent/`enabled:false` ⇒ inert (no
94
+ * dispatcher wiring, emit is a no-op — byte-identical zero regression).
95
+ */
96
+ interface WebhookConfig {
97
+ /** Master switch; false/absent ⇒ webhooks are inert. */
98
+ enabled: boolean;
99
+ /** Configured destinations (each independently enable-able + filterable). */
100
+ destinations: WebhookDestination[];
101
+ }
102
+ /**
103
+ * Secret-free projection of a destination for admin GET views: the signing
104
+ * `secret` is replaced by a `hasSecret` presence flag — the plaintext never
105
+ * leaves the daemon.
106
+ */
107
+ interface SanitizedWebhookDestination {
108
+ id: string;
109
+ type: WebhookDestinationType;
110
+ url: string;
111
+ /** Whether a signing secret is configured (the value itself never leaves). */
112
+ hasSecret: boolean;
113
+ events?: WebhookEventKind[];
114
+ enabled: boolean;
115
+ }
116
+ /** Secret-free projection of the whole webhook segment (admin GET view). */
117
+ interface SanitizedWebhookConfig {
118
+ enabled: boolean;
119
+ destinations: SanitizedWebhookDestination[];
120
+ }
121
+
122
+ export { type SanitizedWebhookConfig, type SanitizedWebhookDestination, WEBHOOK_DESTINATION_TYPES, WEBHOOK_EVENT_KINDS, type WebhookAnomalyState, type WebhookConfig, type WebhookDestination, type WebhookDestinationType, type WebhookEvent, type WebhookEventKind, type WebhookQuotaScope };
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Webhook notification contracts (webhook-notifications, design D1).
3
+ *
4
+ * Two small, dependency-light shapes shared across the `@omnicross/*` packages:
5
+ * - `WebhookEvent` — the FROZEN discriminated union of operational signals a
6
+ * relay can deliver out-of-band (account recovery/anomaly, key quota
7
+ * warning/exceeded, server error, and a config-UI `test`). Every payload is
8
+ * SECRET-FREE BY CONSTRUCTION: it carries only opaque provider/account ids, a
9
+ * key id (NEVER key material or a hash), a coarse state, limit/spend numbers,
10
+ * and a sanitized message. Nothing here can hold a token, secret, or hash.
11
+ * - `WebhookDestination` / `WebhookConfig` — the destination config schema. A
12
+ * destination's `secret` (its HMAC signing key) is the ONLY secret; it is
13
+ * encrypted at rest, masked in admin views, and used ONLY to sign an outgoing
14
+ * request — it is NEVER placed in a payload or a log line.
15
+ *
16
+ * The union is FROZEN: the emit port (core), the dispatcher (daemon), and the
17
+ * sources (#2 health / #4 quota / server-error) all agree on this one shape.
18
+ * Adding a destination `type` is additive behind the dispatcher's formatter.
19
+ *
20
+ * @module webhook-types
21
+ */
22
+ /** The coarse anomaly state an account transitioned into (secret-free). */
23
+ type WebhookAnomalyState = 'blocked' | 'unauthorized' | 'rate_limited' | 'overloaded';
24
+ /** The cost-limit scope a key quota event refers to. */
25
+ type WebhookQuotaScope = 'daily' | 'weekly' | 'total';
26
+ /**
27
+ * The FROZEN webhook event union (design D1). EVERY field is non-secret:
28
+ * opaque provider/account ids, a key id (NOT key material/hash), a coarse state,
29
+ * numbers, and a sanitized message. A test asserts no token/secret/hash string
30
+ * can appear in any serialized payload.
31
+ */
32
+ type WebhookEvent = {
33
+ kind: 'account.recovery';
34
+ at: number;
35
+ providerId: string;
36
+ accountId: string;
37
+ } | {
38
+ kind: 'account.anomaly';
39
+ at: number;
40
+ providerId: string;
41
+ accountId: string;
42
+ state: WebhookAnomalyState;
43
+ } | {
44
+ kind: 'key.quotaWarning';
45
+ at: number;
46
+ keyId: string;
47
+ scope: WebhookQuotaScope;
48
+ limitUsd: number;
49
+ spentUsd: number;
50
+ } | {
51
+ kind: 'key.quotaExceeded';
52
+ at: number;
53
+ keyId: string;
54
+ scope: WebhookQuotaScope;
55
+ limitUsd: number;
56
+ spentUsd: number;
57
+ } | {
58
+ kind: 'server.error';
59
+ at: number;
60
+ message: string;
61
+ } | {
62
+ kind: 'test';
63
+ at: number;
64
+ };
65
+ /** The event discriminator — the value a destination `events` filter matches. */
66
+ type WebhookEventKind = WebhookEvent['kind'];
67
+ /** All event kinds (SSOT for validation + the admin UI's filter checklist). */
68
+ declare const WEBHOOK_EVENT_KINDS: readonly WebhookEventKind[];
69
+ /** The v1 destination types (dingtalk/slack/… are additive later). */
70
+ type WebhookDestinationType = 'custom' | 'feishu';
71
+ /** All destination types (SSOT for validation + the admin UI's type select). */
72
+ declare const WEBHOOK_DESTINATION_TYPES: readonly WebhookDestinationType[];
73
+ /**
74
+ * One webhook destination (design D5). `secret` is the OPTIONAL HMAC signing key
75
+ * (a SECRET — encrypted at rest, masked in views, never in a payload/log). An
76
+ * absent/empty `events` filter matches ALL event kinds.
77
+ */
78
+ interface WebhookDestination {
79
+ /** Stable id (the admin CRUD key + the test-button target). */
80
+ id: string;
81
+ /** The formatter/signing scheme to use. */
82
+ type: WebhookDestinationType;
83
+ /** The POST target URL. */
84
+ url: string;
85
+ /** OPTIONAL HMAC signing key (SECRET; may be an `enc:`/`$ENV` envelope at rest). */
86
+ secret?: string;
87
+ /** OPTIONAL event-kind filter; absent/empty ⇒ receive ALL kinds. */
88
+ events?: WebhookEventKind[];
89
+ /** Whether this destination receives events. */
90
+ enabled: boolean;
91
+ }
92
+ /**
93
+ * The `webhook` config segment (design D5). Absent/`enabled:false` ⇒ inert (no
94
+ * dispatcher wiring, emit is a no-op — byte-identical zero regression).
95
+ */
96
+ interface WebhookConfig {
97
+ /** Master switch; false/absent ⇒ webhooks are inert. */
98
+ enabled: boolean;
99
+ /** Configured destinations (each independently enable-able + filterable). */
100
+ destinations: WebhookDestination[];
101
+ }
102
+ /**
103
+ * Secret-free projection of a destination for admin GET views: the signing
104
+ * `secret` is replaced by a `hasSecret` presence flag — the plaintext never
105
+ * leaves the daemon.
106
+ */
107
+ interface SanitizedWebhookDestination {
108
+ id: string;
109
+ type: WebhookDestinationType;
110
+ url: string;
111
+ /** Whether a signing secret is configured (the value itself never leaves). */
112
+ hasSecret: boolean;
113
+ events?: WebhookEventKind[];
114
+ enabled: boolean;
115
+ }
116
+ /** Secret-free projection of the whole webhook segment (admin GET view). */
117
+ interface SanitizedWebhookConfig {
118
+ enabled: boolean;
119
+ destinations: SanitizedWebhookDestination[];
120
+ }
121
+
122
+ export { type SanitizedWebhookConfig, type SanitizedWebhookDestination, WEBHOOK_DESTINATION_TYPES, WEBHOOK_EVENT_KINDS, type WebhookAnomalyState, type WebhookConfig, type WebhookDestination, type WebhookDestinationType, type WebhookEvent, type WebhookEventKind, type WebhookQuotaScope };
@@ -0,0 +1,14 @@
1
+ // src/webhook-types.ts
2
+ var WEBHOOK_EVENT_KINDS = [
3
+ "account.recovery",
4
+ "account.anomaly",
5
+ "key.quotaWarning",
6
+ "key.quotaExceeded",
7
+ "server.error",
8
+ "test"
9
+ ];
10
+ var WEBHOOK_DESTINATION_TYPES = ["custom", "feishu"];
11
+ export {
12
+ WEBHOOK_DESTINATION_TYPES,
13
+ WEBHOOK_EVENT_KINDS
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnicross/contracts",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Dependency-light, host-agnostic contract types + runtime-value helpers shared by the @omnicross/* packages.",
5
5
  "license": "MIT",
6
6
  "author": "Sayo (https://github.com/Dumoedss)",
@@ -40,6 +40,16 @@
40
40
  "import": "./dist/account-tokens-types.js",
41
41
  "require": "./dist/account-tokens-types.cjs"
42
42
  },
43
+ "./audit-types": {
44
+ "types": "./dist/audit-types.d.ts",
45
+ "import": "./dist/audit-types.js",
46
+ "require": "./dist/audit-types.cjs"
47
+ },
48
+ "./billing-types": {
49
+ "types": "./dist/billing-types.d.ts",
50
+ "import": "./dist/billing-types.js",
51
+ "require": "./dist/billing-types.cjs"
52
+ },
43
53
  "./canonical-models": {
44
54
  "types": "./dist/canonical-models.d.ts",
45
55
  "import": "./dist/canonical-models.js",
@@ -60,6 +70,11 @@
60
70
  "import": "./dist/extended-context.js",
61
71
  "require": "./dist/extended-context.cjs"
62
72
  },
73
+ "./health-logging-types": {
74
+ "types": "./dist/health-logging-types.d.ts",
75
+ "import": "./dist/health-logging-types.js",
76
+ "require": "./dist/health-logging-types.cjs"
77
+ },
63
78
  "./llm-config": {
64
79
  "types": "./dist/llm-config.d.ts",
65
80
  "import": "./dist/llm-config.js",
@@ -105,6 +120,16 @@
105
120
  "import": "./dist/usage-types.js",
106
121
  "require": "./dist/usage-types.cjs"
107
122
  },
123
+ "./voucher-types": {
124
+ "types": "./dist/voucher-types.d.ts",
125
+ "import": "./dist/voucher-types.js",
126
+ "require": "./dist/voucher-types.cjs"
127
+ },
128
+ "./webhook-types": {
129
+ "types": "./dist/webhook-types.d.ts",
130
+ "import": "./dist/webhook-types.js",
131
+ "require": "./dist/webhook-types.cjs"
132
+ },
108
133
  "./websearch-types": {
109
134
  "types": "./dist/websearch-types.d.ts",
110
135
  "import": "./dist/websearch-types.js",