@vorionsys/shared-constants 1.0.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.
- package/dist/api-versions.cjs +183 -0
- package/dist/api-versions.d.cts +91 -0
- package/dist/api-versions.js +46 -0
- package/dist/capabilities.cjs +246 -0
- package/dist/capabilities.d.cts +55 -0
- package/dist/capabilities.js +21 -0
- package/dist/chunk-F2R6HBF5.js +253 -0
- package/dist/chunk-IKLCEYZT.js +142 -0
- package/dist/chunk-JZJPDGG7.js +215 -0
- package/dist/chunk-P3VPMVF3.js +223 -0
- package/dist/chunk-PHL3CB53.js +159 -0
- package/dist/chunk-RZQZEF6Q.js +176 -0
- package/dist/chunk-TYCMBQGU.js +353 -0
- package/dist/chunk-UDCZKJSQ.js +139 -0
- package/dist/domains.cjs +175 -0
- package/dist/domains.d.cts +250 -0
- package/dist/domains.js +24 -0
- package/dist/error-codes.cjs +390 -0
- package/dist/error-codes.d.cts +633 -0
- package/dist/error-codes.js +32 -0
- package/dist/index.cjs +1762 -0
- package/dist/index.d.cts +54 -0
- package/dist/index.js +198 -0
- package/dist/products.cjs +208 -0
- package/dist/products.d.cts +80 -0
- package/dist/products.js +22 -0
- package/dist/rate-limits.cjs +295 -0
- package/dist/rate-limits.d.cts +80 -0
- package/dist/rate-limits.js +21 -0
- package/dist/themes.cjs +251 -0
- package/dist/themes.d.cts +85 -0
- package/dist/themes.js +14 -0
- package/dist/tiers.cjs +194 -0
- package/dist/tiers.d.cts +75 -0
- package/dist/tiers.js +28 -0
- package/package.json +71 -0
- package/src/api-versions.ts +250 -0
- package/src/capabilities.ts +272 -0
- package/src/domains.ts +216 -0
- package/src/error-codes.ts +494 -0
- package/src/index.ts +206 -0
- package/src/products.ts +285 -0
- package/src/rate-limits.ts +334 -0
- package/src/themes.ts +380 -0
- package/src/tiers.ts +239 -0
- package/tsconfig.json +25 -0
package/src/domains.ts
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vorionsys/shared-constants - Domain Configuration
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for all Vorion ecosystem domains and URLs
|
|
5
|
+
* Used across all products and sites for consistent linking
|
|
6
|
+
*
|
|
7
|
+
* @see https://vorion.org
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// VORION (OPEN SOURCE)
|
|
12
|
+
// =============================================================================
|
|
13
|
+
|
|
14
|
+
export const VORION_DOMAINS = {
|
|
15
|
+
/** Main Vorion organization site */
|
|
16
|
+
main: 'https://vorion.org',
|
|
17
|
+
|
|
18
|
+
/** BASIS specification and documentation */
|
|
19
|
+
basis: 'https://basis.vorion.org',
|
|
20
|
+
|
|
21
|
+
/** CAR ID specification */
|
|
22
|
+
carId: 'https://carid.vorion.org',
|
|
23
|
+
|
|
24
|
+
/** ATSF (Agent Trust & Safety Framework) */
|
|
25
|
+
atsf: 'https://atsf.vorion.org',
|
|
26
|
+
|
|
27
|
+
/** Learning and educational resources (primary) */
|
|
28
|
+
learn: 'https://learn.vorion.org',
|
|
29
|
+
|
|
30
|
+
/** Kaizen - Interactive AI Learning Experience (mirrors learn) */
|
|
31
|
+
kaizen: 'https://kaizen.vorion.org',
|
|
32
|
+
|
|
33
|
+
/** Technical documentation */
|
|
34
|
+
docs: 'https://docs.vorion.org',
|
|
35
|
+
|
|
36
|
+
/** Community forum */
|
|
37
|
+
community: 'https://community.vorion.org',
|
|
38
|
+
} as const;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Domain aliases - maps alternate domains to primary
|
|
42
|
+
* Used for domain detection and routing
|
|
43
|
+
*/
|
|
44
|
+
export const DOMAIN_ALIASES = {
|
|
45
|
+
'kaizen.vorion.org': 'learn.vorion.org',
|
|
46
|
+
} as const;
|
|
47
|
+
|
|
48
|
+
// =============================================================================
|
|
49
|
+
// AGENT ANCHOR AI (COMMERCIAL)
|
|
50
|
+
// =============================================================================
|
|
51
|
+
|
|
52
|
+
export const AGENTANCHOR_DOMAINS = {
|
|
53
|
+
/** Main Agent Anchor AI site */
|
|
54
|
+
main: 'https://agentanchorai.com',
|
|
55
|
+
|
|
56
|
+
/** Agent Anchor Trust - Trust verification and certification */
|
|
57
|
+
trust: 'https://trust.agentanchorai.com',
|
|
58
|
+
|
|
59
|
+
/** Agent Anchor Logic - Policy engine and governance logic */
|
|
60
|
+
logic: 'https://logic.agentanchorai.com',
|
|
61
|
+
|
|
62
|
+
/** Status page */
|
|
63
|
+
status: 'https://status.agentanchorai.com',
|
|
64
|
+
} as const;
|
|
65
|
+
|
|
66
|
+
// =============================================================================
|
|
67
|
+
// COGNIGATE
|
|
68
|
+
// =============================================================================
|
|
69
|
+
|
|
70
|
+
export const COGNIGATE_DOMAINS = {
|
|
71
|
+
/** Cognigate main site and documentation */
|
|
72
|
+
main: 'https://cognigate.dev',
|
|
73
|
+
|
|
74
|
+
/** Cognigate API documentation */
|
|
75
|
+
docs: 'https://cognigate.dev/docs',
|
|
76
|
+
} as const;
|
|
77
|
+
|
|
78
|
+
// =============================================================================
|
|
79
|
+
// API ENDPOINTS
|
|
80
|
+
// =============================================================================
|
|
81
|
+
|
|
82
|
+
export const API_ENDPOINTS = {
|
|
83
|
+
/** Cognigate Production API */
|
|
84
|
+
cognigate: {
|
|
85
|
+
production: 'https://cognigate.dev/v1',
|
|
86
|
+
staging: 'https://staging.cognigate.dev/v1',
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
/** Agent Anchor AI Production API */
|
|
90
|
+
agentAnchor: {
|
|
91
|
+
production: 'https://api.agentanchorai.com/v1',
|
|
92
|
+
staging: 'https://staging-api.agentanchorai.com/v1',
|
|
93
|
+
sandbox: 'https://sandbox.agentanchorai.com/v1',
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
/** Trust API */
|
|
97
|
+
trust: {
|
|
98
|
+
production: 'https://trust.agentanchorai.com/v1',
|
|
99
|
+
staging: 'https://staging.trust.agentanchorai.com/v1',
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
/** Logic/Policy API */
|
|
103
|
+
logic: {
|
|
104
|
+
production: 'https://logic.agentanchorai.com/v1',
|
|
105
|
+
staging: 'https://staging.logic.agentanchorai.com/v1',
|
|
106
|
+
},
|
|
107
|
+
} as const;
|
|
108
|
+
|
|
109
|
+
// =============================================================================
|
|
110
|
+
// EMAIL ADDRESSES
|
|
111
|
+
// =============================================================================
|
|
112
|
+
|
|
113
|
+
export const VORION_EMAILS = {
|
|
114
|
+
/** General inquiries */
|
|
115
|
+
info: 'info@vorion.org',
|
|
116
|
+
|
|
117
|
+
/** Security reports */
|
|
118
|
+
security: 'security@vorion.org',
|
|
119
|
+
|
|
120
|
+
/** Legal inquiries */
|
|
121
|
+
legal: 'legal@vorion.org',
|
|
122
|
+
|
|
123
|
+
/** Community and contributions */
|
|
124
|
+
community: 'community@vorion.org',
|
|
125
|
+
|
|
126
|
+
/** Contributing */
|
|
127
|
+
contribute: 'contribute@vorion.org',
|
|
128
|
+
} as const;
|
|
129
|
+
|
|
130
|
+
export const AGENTANCHOR_EMAILS = {
|
|
131
|
+
/** General support */
|
|
132
|
+
support: 'support@agentanchorai.com',
|
|
133
|
+
|
|
134
|
+
/** Sales inquiries */
|
|
135
|
+
sales: 'sales@agentanchorai.com',
|
|
136
|
+
|
|
137
|
+
/** Partner program */
|
|
138
|
+
partners: 'partners@agentanchorai.com',
|
|
139
|
+
|
|
140
|
+
/** API support */
|
|
141
|
+
apiSupport: 'api-support@agentanchorai.com',
|
|
142
|
+
|
|
143
|
+
/** Enterprise inquiries */
|
|
144
|
+
enterprise: 'enterprise@agentanchorai.com',
|
|
145
|
+
|
|
146
|
+
/** Compliance */
|
|
147
|
+
compliance: 'compliance@agentanchorai.com',
|
|
148
|
+
|
|
149
|
+
/** Team */
|
|
150
|
+
team: 'team@agentanchorai.com',
|
|
151
|
+
} as const;
|
|
152
|
+
|
|
153
|
+
// =============================================================================
|
|
154
|
+
// GITHUB
|
|
155
|
+
// =============================================================================
|
|
156
|
+
|
|
157
|
+
export const GITHUB = {
|
|
158
|
+
/** Vorion organization */
|
|
159
|
+
vorion: {
|
|
160
|
+
org: 'https://github.com/voriongit',
|
|
161
|
+
mainRepo: 'https://github.com/voriongit/vorion',
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
/** Agent Anchor AI (if separate) */
|
|
165
|
+
agentAnchor: {
|
|
166
|
+
org: 'https://github.com/agentanchorai',
|
|
167
|
+
},
|
|
168
|
+
} as const;
|
|
169
|
+
|
|
170
|
+
// =============================================================================
|
|
171
|
+
// NPM PACKAGES
|
|
172
|
+
// =============================================================================
|
|
173
|
+
|
|
174
|
+
export const NPM_PACKAGES = {
|
|
175
|
+
/** Open source packages (@vorionsys) */
|
|
176
|
+
vorion: {
|
|
177
|
+
basis: '@vorionsys/basis',
|
|
178
|
+
contracts: '@vorionsys/contracts',
|
|
179
|
+
carSpec: '@vorionsys/car-spec',
|
|
180
|
+
atsfCore: '@vorionsys/atsf-core',
|
|
181
|
+
cognigate: '@vorionsys/cognigate',
|
|
182
|
+
sharedConstants: '@vorionsys/shared-constants',
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
/** Commercial packages (@agentanchor) */
|
|
186
|
+
agentAnchor: {
|
|
187
|
+
sdk: '@agentanchor/sdk',
|
|
188
|
+
trust: '@agentanchor/trust',
|
|
189
|
+
logic: '@agentanchor/logic',
|
|
190
|
+
},
|
|
191
|
+
} as const;
|
|
192
|
+
|
|
193
|
+
// =============================================================================
|
|
194
|
+
// ALL DOMAINS COMBINED
|
|
195
|
+
// =============================================================================
|
|
196
|
+
|
|
197
|
+
export const ALL_DOMAINS = {
|
|
198
|
+
vorion: VORION_DOMAINS,
|
|
199
|
+
agentAnchor: AGENTANCHOR_DOMAINS,
|
|
200
|
+
cognigate: COGNIGATE_DOMAINS,
|
|
201
|
+
api: API_ENDPOINTS,
|
|
202
|
+
emails: {
|
|
203
|
+
vorion: VORION_EMAILS,
|
|
204
|
+
agentAnchor: AGENTANCHOR_EMAILS,
|
|
205
|
+
},
|
|
206
|
+
github: GITHUB,
|
|
207
|
+
npm: NPM_PACKAGES,
|
|
208
|
+
} as const;
|
|
209
|
+
|
|
210
|
+
// =============================================================================
|
|
211
|
+
// TYPE EXPORTS
|
|
212
|
+
// =============================================================================
|
|
213
|
+
|
|
214
|
+
export type VorionDomain = keyof typeof VORION_DOMAINS;
|
|
215
|
+
export type AgentAnchorDomain = keyof typeof AGENTANCHOR_DOMAINS;
|
|
216
|
+
export type CognigateDomain = keyof typeof COGNIGATE_DOMAINS;
|
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vorionsys/shared-constants - Error Codes
|
|
3
|
+
*
|
|
4
|
+
* Standardized error codes across all Vorion ecosystem APIs
|
|
5
|
+
* Ensures consistent error handling and reporting
|
|
6
|
+
*
|
|
7
|
+
* @see https://cognigate.dev/docs/errors
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// ERROR CATEGORIES
|
|
12
|
+
// =============================================================================
|
|
13
|
+
|
|
14
|
+
export enum ErrorCategory {
|
|
15
|
+
/** Authentication and authorization errors (4xx) */
|
|
16
|
+
AUTH = 'auth',
|
|
17
|
+
|
|
18
|
+
/** Validation and input errors (4xx) */
|
|
19
|
+
VALIDATION = 'validation',
|
|
20
|
+
|
|
21
|
+
/** Rate limiting and quota errors (429) */
|
|
22
|
+
RATE_LIMIT = 'rate_limit',
|
|
23
|
+
|
|
24
|
+
/** Resource not found errors (404) */
|
|
25
|
+
NOT_FOUND = 'not_found',
|
|
26
|
+
|
|
27
|
+
/** Trust and governance errors (4xx) */
|
|
28
|
+
TRUST = 'trust',
|
|
29
|
+
|
|
30
|
+
/** Server and internal errors (5xx) */
|
|
31
|
+
SERVER = 'server',
|
|
32
|
+
|
|
33
|
+
/** External service errors (5xx) */
|
|
34
|
+
EXTERNAL = 'external',
|
|
35
|
+
|
|
36
|
+
/** Configuration errors */
|
|
37
|
+
CONFIG = 'config',
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// =============================================================================
|
|
41
|
+
// ERROR CODE DEFINITIONS
|
|
42
|
+
// =============================================================================
|
|
43
|
+
|
|
44
|
+
export interface ErrorDefinition {
|
|
45
|
+
/** Unique error code */
|
|
46
|
+
code: string;
|
|
47
|
+
|
|
48
|
+
/** HTTP status code */
|
|
49
|
+
httpStatus: number;
|
|
50
|
+
|
|
51
|
+
/** Error category */
|
|
52
|
+
category: ErrorCategory;
|
|
53
|
+
|
|
54
|
+
/** Human-readable message template */
|
|
55
|
+
message: string;
|
|
56
|
+
|
|
57
|
+
/** Whether this error is retryable */
|
|
58
|
+
retryable: boolean;
|
|
59
|
+
|
|
60
|
+
/** Documentation URL for this error */
|
|
61
|
+
docsUrl?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// =============================================================================
|
|
65
|
+
// AUTHENTICATION ERRORS (1xxx)
|
|
66
|
+
// =============================================================================
|
|
67
|
+
|
|
68
|
+
export const AUTH_ERRORS = {
|
|
69
|
+
MISSING_API_KEY: {
|
|
70
|
+
code: 'E1001',
|
|
71
|
+
httpStatus: 401,
|
|
72
|
+
category: ErrorCategory.AUTH,
|
|
73
|
+
message: 'API key is missing. Include it in the Authorization header.',
|
|
74
|
+
retryable: false,
|
|
75
|
+
docsUrl: 'https://cognigate.dev/docs/authentication',
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
INVALID_API_KEY: {
|
|
79
|
+
code: 'E1002',
|
|
80
|
+
httpStatus: 401,
|
|
81
|
+
category: ErrorCategory.AUTH,
|
|
82
|
+
message: 'API key is invalid or has been revoked.',
|
|
83
|
+
retryable: false,
|
|
84
|
+
docsUrl: 'https://cognigate.dev/docs/authentication',
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
EXPIRED_API_KEY: {
|
|
88
|
+
code: 'E1003',
|
|
89
|
+
httpStatus: 401,
|
|
90
|
+
category: ErrorCategory.AUTH,
|
|
91
|
+
message: 'API key has expired. Generate a new key.',
|
|
92
|
+
retryable: false,
|
|
93
|
+
docsUrl: 'https://cognigate.dev/docs/authentication',
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
INSUFFICIENT_PERMISSIONS: {
|
|
97
|
+
code: 'E1004',
|
|
98
|
+
httpStatus: 403,
|
|
99
|
+
category: ErrorCategory.AUTH,
|
|
100
|
+
message: 'Insufficient permissions for this operation.',
|
|
101
|
+
retryable: false,
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
AGENT_NOT_AUTHORIZED: {
|
|
105
|
+
code: 'E1005',
|
|
106
|
+
httpStatus: 403,
|
|
107
|
+
category: ErrorCategory.AUTH,
|
|
108
|
+
message: 'Agent is not authorized for this action.',
|
|
109
|
+
retryable: false,
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
TOKEN_EXPIRED: {
|
|
113
|
+
code: 'E1006',
|
|
114
|
+
httpStatus: 401,
|
|
115
|
+
category: ErrorCategory.AUTH,
|
|
116
|
+
message: 'Authentication token has expired.',
|
|
117
|
+
retryable: false,
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
MFA_REQUIRED: {
|
|
121
|
+
code: 'E1007',
|
|
122
|
+
httpStatus: 403,
|
|
123
|
+
category: ErrorCategory.AUTH,
|
|
124
|
+
message: 'Multi-factor authentication is required for this operation.',
|
|
125
|
+
retryable: false,
|
|
126
|
+
},
|
|
127
|
+
} as const;
|
|
128
|
+
|
|
129
|
+
// =============================================================================
|
|
130
|
+
// VALIDATION ERRORS (2xxx)
|
|
131
|
+
// =============================================================================
|
|
132
|
+
|
|
133
|
+
export const VALIDATION_ERRORS = {
|
|
134
|
+
INVALID_REQUEST: {
|
|
135
|
+
code: 'E2001',
|
|
136
|
+
httpStatus: 400,
|
|
137
|
+
category: ErrorCategory.VALIDATION,
|
|
138
|
+
message: 'Request body is invalid or malformed.',
|
|
139
|
+
retryable: false,
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
MISSING_REQUIRED_FIELD: {
|
|
143
|
+
code: 'E2002',
|
|
144
|
+
httpStatus: 400,
|
|
145
|
+
category: ErrorCategory.VALIDATION,
|
|
146
|
+
message: 'Required field is missing: {field}',
|
|
147
|
+
retryable: false,
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
INVALID_FIELD_TYPE: {
|
|
151
|
+
code: 'E2003',
|
|
152
|
+
httpStatus: 400,
|
|
153
|
+
category: ErrorCategory.VALIDATION,
|
|
154
|
+
message: 'Field {field} has invalid type. Expected {expected}.',
|
|
155
|
+
retryable: false,
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
INVALID_FIELD_VALUE: {
|
|
159
|
+
code: 'E2004',
|
|
160
|
+
httpStatus: 400,
|
|
161
|
+
category: ErrorCategory.VALIDATION,
|
|
162
|
+
message: 'Field {field} has invalid value.',
|
|
163
|
+
retryable: false,
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
PAYLOAD_TOO_LARGE: {
|
|
167
|
+
code: 'E2005',
|
|
168
|
+
httpStatus: 413,
|
|
169
|
+
category: ErrorCategory.VALIDATION,
|
|
170
|
+
message: 'Request payload exceeds maximum size of {maxSize}.',
|
|
171
|
+
retryable: false,
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
INVALID_JSON: {
|
|
175
|
+
code: 'E2006',
|
|
176
|
+
httpStatus: 400,
|
|
177
|
+
category: ErrorCategory.VALIDATION,
|
|
178
|
+
message: 'Request body is not valid JSON.',
|
|
179
|
+
retryable: false,
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
INVALID_CAR_ID: {
|
|
183
|
+
code: 'E2007',
|
|
184
|
+
httpStatus: 400,
|
|
185
|
+
category: ErrorCategory.VALIDATION,
|
|
186
|
+
message: 'Invalid CAR ID format. Expected: car:domain/category/name:version',
|
|
187
|
+
retryable: false,
|
|
188
|
+
docsUrl: 'https://carid.vorion.org/format',
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
INVALID_TRUST_SCORE: {
|
|
192
|
+
code: 'E2008',
|
|
193
|
+
httpStatus: 400,
|
|
194
|
+
category: ErrorCategory.VALIDATION,
|
|
195
|
+
message: 'Trust score must be between 0 and 1000.',
|
|
196
|
+
retryable: false,
|
|
197
|
+
},
|
|
198
|
+
} as const;
|
|
199
|
+
|
|
200
|
+
// =============================================================================
|
|
201
|
+
// RATE LIMIT ERRORS (3xxx)
|
|
202
|
+
// =============================================================================
|
|
203
|
+
|
|
204
|
+
export const RATE_LIMIT_ERRORS = {
|
|
205
|
+
RATE_LIMIT_EXCEEDED: {
|
|
206
|
+
code: 'E3001',
|
|
207
|
+
httpStatus: 429,
|
|
208
|
+
category: ErrorCategory.RATE_LIMIT,
|
|
209
|
+
message: 'Rate limit exceeded. Retry after {retryAfter} seconds.',
|
|
210
|
+
retryable: true,
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
QUOTA_EXCEEDED: {
|
|
214
|
+
code: 'E3002',
|
|
215
|
+
httpStatus: 429,
|
|
216
|
+
category: ErrorCategory.RATE_LIMIT,
|
|
217
|
+
message: 'Monthly quota exceeded. Upgrade your tier or wait for reset.',
|
|
218
|
+
retryable: false,
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
CONCURRENT_LIMIT: {
|
|
222
|
+
code: 'E3003',
|
|
223
|
+
httpStatus: 429,
|
|
224
|
+
category: ErrorCategory.RATE_LIMIT,
|
|
225
|
+
message: 'Too many concurrent requests. Max burst: {burstLimit}.',
|
|
226
|
+
retryable: true,
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
DAILY_LIMIT_EXCEEDED: {
|
|
230
|
+
code: 'E3004',
|
|
231
|
+
httpStatus: 429,
|
|
232
|
+
category: ErrorCategory.RATE_LIMIT,
|
|
233
|
+
message: 'Daily request limit exceeded. Resets at midnight UTC.',
|
|
234
|
+
retryable: true,
|
|
235
|
+
},
|
|
236
|
+
} as const;
|
|
237
|
+
|
|
238
|
+
// =============================================================================
|
|
239
|
+
// NOT FOUND ERRORS (4xxx)
|
|
240
|
+
// =============================================================================
|
|
241
|
+
|
|
242
|
+
export const NOT_FOUND_ERRORS = {
|
|
243
|
+
RESOURCE_NOT_FOUND: {
|
|
244
|
+
code: 'E4001',
|
|
245
|
+
httpStatus: 404,
|
|
246
|
+
category: ErrorCategory.NOT_FOUND,
|
|
247
|
+
message: 'Resource not found: {resourceType}/{resourceId}',
|
|
248
|
+
retryable: false,
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
AGENT_NOT_FOUND: {
|
|
252
|
+
code: 'E4002',
|
|
253
|
+
httpStatus: 404,
|
|
254
|
+
category: ErrorCategory.NOT_FOUND,
|
|
255
|
+
message: 'Agent not found: {agentId}',
|
|
256
|
+
retryable: false,
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
PROOF_NOT_FOUND: {
|
|
260
|
+
code: 'E4003',
|
|
261
|
+
httpStatus: 404,
|
|
262
|
+
category: ErrorCategory.NOT_FOUND,
|
|
263
|
+
message: 'Proof not found: {proofId}',
|
|
264
|
+
retryable: false,
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
ENDPOINT_NOT_FOUND: {
|
|
268
|
+
code: 'E4004',
|
|
269
|
+
httpStatus: 404,
|
|
270
|
+
category: ErrorCategory.NOT_FOUND,
|
|
271
|
+
message: 'API endpoint not found.',
|
|
272
|
+
retryable: false,
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
ATTESTATION_NOT_FOUND: {
|
|
276
|
+
code: 'E4005',
|
|
277
|
+
httpStatus: 404,
|
|
278
|
+
category: ErrorCategory.NOT_FOUND,
|
|
279
|
+
message: 'Attestation not found: {attestationId}',
|
|
280
|
+
retryable: false,
|
|
281
|
+
},
|
|
282
|
+
} as const;
|
|
283
|
+
|
|
284
|
+
// =============================================================================
|
|
285
|
+
// TRUST & GOVERNANCE ERRORS (5xxx)
|
|
286
|
+
// =============================================================================
|
|
287
|
+
|
|
288
|
+
export const TRUST_ERRORS = {
|
|
289
|
+
TRUST_TIER_INSUFFICIENT: {
|
|
290
|
+
code: 'E5001',
|
|
291
|
+
httpStatus: 403,
|
|
292
|
+
category: ErrorCategory.TRUST,
|
|
293
|
+
message: 'Trust tier {currentTier} insufficient. Required: {requiredTier}.',
|
|
294
|
+
retryable: false,
|
|
295
|
+
docsUrl: 'https://basis.vorion.org/tiers',
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
CAPABILITY_NOT_AVAILABLE: {
|
|
299
|
+
code: 'E5002',
|
|
300
|
+
httpStatus: 403,
|
|
301
|
+
category: ErrorCategory.TRUST,
|
|
302
|
+
message: 'Capability {capability} not available at tier {tier}.',
|
|
303
|
+
retryable: false,
|
|
304
|
+
docsUrl: 'https://cognigate.dev/docs/capabilities',
|
|
305
|
+
},
|
|
306
|
+
|
|
307
|
+
GOVERNANCE_DENIED: {
|
|
308
|
+
code: 'E5003',
|
|
309
|
+
httpStatus: 403,
|
|
310
|
+
category: ErrorCategory.TRUST,
|
|
311
|
+
message: 'Action denied by governance policy: {reason}.',
|
|
312
|
+
retryable: false,
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
AGENT_SUSPENDED: {
|
|
316
|
+
code: 'E5004',
|
|
317
|
+
httpStatus: 403,
|
|
318
|
+
category: ErrorCategory.TRUST,
|
|
319
|
+
message: 'Agent is suspended. Contact support for reinstatement.',
|
|
320
|
+
retryable: false,
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
PROOF_VERIFICATION_FAILED: {
|
|
324
|
+
code: 'E5005',
|
|
325
|
+
httpStatus: 400,
|
|
326
|
+
category: ErrorCategory.TRUST,
|
|
327
|
+
message: 'Proof verification failed: {reason}.',
|
|
328
|
+
retryable: false,
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
ATTESTATION_INVALID: {
|
|
332
|
+
code: 'E5006',
|
|
333
|
+
httpStatus: 400,
|
|
334
|
+
category: ErrorCategory.TRUST,
|
|
335
|
+
message: 'Attestation is invalid or has expired.',
|
|
336
|
+
retryable: false,
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
ESCALATION_REQUIRED: {
|
|
340
|
+
code: 'E5007',
|
|
341
|
+
httpStatus: 403,
|
|
342
|
+
category: ErrorCategory.TRUST,
|
|
343
|
+
message: 'Action requires human approval. Escalation ID: {escalationId}.',
|
|
344
|
+
retryable: false,
|
|
345
|
+
},
|
|
346
|
+
} as const;
|
|
347
|
+
|
|
348
|
+
// =============================================================================
|
|
349
|
+
// SERVER ERRORS (6xxx)
|
|
350
|
+
// =============================================================================
|
|
351
|
+
|
|
352
|
+
export const SERVER_ERRORS = {
|
|
353
|
+
INTERNAL_ERROR: {
|
|
354
|
+
code: 'E6001',
|
|
355
|
+
httpStatus: 500,
|
|
356
|
+
category: ErrorCategory.SERVER,
|
|
357
|
+
message: 'An internal error occurred. Please try again later.',
|
|
358
|
+
retryable: true,
|
|
359
|
+
},
|
|
360
|
+
|
|
361
|
+
SERVICE_UNAVAILABLE: {
|
|
362
|
+
code: 'E6002',
|
|
363
|
+
httpStatus: 503,
|
|
364
|
+
category: ErrorCategory.SERVER,
|
|
365
|
+
message: 'Service is temporarily unavailable. Please try again later.',
|
|
366
|
+
retryable: true,
|
|
367
|
+
},
|
|
368
|
+
|
|
369
|
+
DATABASE_ERROR: {
|
|
370
|
+
code: 'E6003',
|
|
371
|
+
httpStatus: 500,
|
|
372
|
+
category: ErrorCategory.SERVER,
|
|
373
|
+
message: 'Database operation failed. Please try again later.',
|
|
374
|
+
retryable: true,
|
|
375
|
+
},
|
|
376
|
+
|
|
377
|
+
MAINTENANCE_MODE: {
|
|
378
|
+
code: 'E6004',
|
|
379
|
+
httpStatus: 503,
|
|
380
|
+
category: ErrorCategory.SERVER,
|
|
381
|
+
message: 'Service is under maintenance. Expected completion: {eta}.',
|
|
382
|
+
retryable: true,
|
|
383
|
+
},
|
|
384
|
+
} as const;
|
|
385
|
+
|
|
386
|
+
// =============================================================================
|
|
387
|
+
// EXTERNAL SERVICE ERRORS (7xxx)
|
|
388
|
+
// =============================================================================
|
|
389
|
+
|
|
390
|
+
export const EXTERNAL_ERRORS = {
|
|
391
|
+
BLOCKCHAIN_ERROR: {
|
|
392
|
+
code: 'E7001',
|
|
393
|
+
httpStatus: 502,
|
|
394
|
+
category: ErrorCategory.EXTERNAL,
|
|
395
|
+
message: 'Blockchain network error. Please try again later.',
|
|
396
|
+
retryable: true,
|
|
397
|
+
},
|
|
398
|
+
|
|
399
|
+
UPSTREAM_TIMEOUT: {
|
|
400
|
+
code: 'E7002',
|
|
401
|
+
httpStatus: 504,
|
|
402
|
+
category: ErrorCategory.EXTERNAL,
|
|
403
|
+
message: 'Upstream service timed out.',
|
|
404
|
+
retryable: true,
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
EXTERNAL_SERVICE_ERROR: {
|
|
408
|
+
code: 'E7003',
|
|
409
|
+
httpStatus: 502,
|
|
410
|
+
category: ErrorCategory.EXTERNAL,
|
|
411
|
+
message: 'External service error: {service}.',
|
|
412
|
+
retryable: true,
|
|
413
|
+
},
|
|
414
|
+
} as const;
|
|
415
|
+
|
|
416
|
+
// =============================================================================
|
|
417
|
+
// ALL ERROR CODES
|
|
418
|
+
// =============================================================================
|
|
419
|
+
|
|
420
|
+
export const ERROR_CODES = {
|
|
421
|
+
...AUTH_ERRORS,
|
|
422
|
+
...VALIDATION_ERRORS,
|
|
423
|
+
...RATE_LIMIT_ERRORS,
|
|
424
|
+
...NOT_FOUND_ERRORS,
|
|
425
|
+
...TRUST_ERRORS,
|
|
426
|
+
...SERVER_ERRORS,
|
|
427
|
+
...EXTERNAL_ERRORS,
|
|
428
|
+
} as const;
|
|
429
|
+
|
|
430
|
+
// =============================================================================
|
|
431
|
+
// HELPER FUNCTIONS
|
|
432
|
+
// =============================================================================
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Get error definition by code
|
|
436
|
+
*/
|
|
437
|
+
export function getErrorByCode(code: string): ErrorDefinition | undefined {
|
|
438
|
+
return Object.values(ERROR_CODES).find(e => e.code === code);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Get all errors by category
|
|
443
|
+
*/
|
|
444
|
+
export function getErrorsByCategory(category: ErrorCategory): ErrorDefinition[] {
|
|
445
|
+
return Object.values(ERROR_CODES).filter(e => e.category === category);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Get all retryable errors
|
|
450
|
+
*/
|
|
451
|
+
export function getRetryableErrors(): ErrorDefinition[] {
|
|
452
|
+
return Object.values(ERROR_CODES).filter(e => e.retryable);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Format error message with parameters
|
|
457
|
+
*/
|
|
458
|
+
export function formatErrorMessage(
|
|
459
|
+
error: ErrorDefinition,
|
|
460
|
+
params: Record<string, string | number>,
|
|
461
|
+
): string {
|
|
462
|
+
let message = error.message;
|
|
463
|
+
for (const [key, value] of Object.entries(params)) {
|
|
464
|
+
message = message.replace(`{${key}}`, String(value));
|
|
465
|
+
}
|
|
466
|
+
return message;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Create a structured error response
|
|
471
|
+
*/
|
|
472
|
+
export function createErrorResponse(
|
|
473
|
+
error: ErrorDefinition,
|
|
474
|
+
params?: Record<string, string | number>,
|
|
475
|
+
requestId?: string,
|
|
476
|
+
) {
|
|
477
|
+
return {
|
|
478
|
+
error: {
|
|
479
|
+
code: error.code,
|
|
480
|
+
message: params ? formatErrorMessage(error, params) : error.message,
|
|
481
|
+
category: error.category,
|
|
482
|
+
retryable: error.retryable,
|
|
483
|
+
...(error.docsUrl && { docsUrl: error.docsUrl }),
|
|
484
|
+
...(requestId && { requestId }),
|
|
485
|
+
},
|
|
486
|
+
status: error.httpStatus,
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// =============================================================================
|
|
491
|
+
// TYPE EXPORTS
|
|
492
|
+
// =============================================================================
|
|
493
|
+
|
|
494
|
+
export type ErrorCode = keyof typeof ERROR_CODES;
|