@nomosprotocol/sdk 1.0.0 → 1.2.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/README.md +98 -0
- package/dist/index.cjs +608 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +489 -0
- package/dist/index.d.ts +489 -4
- package/dist/index.js +575 -2
- package/dist/index.js.map +1 -1
- package/package.json +25 -7
- package/dist/errors.d.ts +0 -31
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -54
- package/dist/errors.js.map +0 -1
- package/dist/http-client.d.ts +0 -14
- package/dist/http-client.d.ts.map +0 -1
- package/dist/http-client.js +0 -70
- package/dist/http-client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/nomos.d.ts +0 -13
- package/dist/nomos.d.ts.map +0 -1
- package/dist/nomos.js +0 -26
- package/dist/nomos.js.map +0 -1
- package/dist/resources/artifacts.d.ts +0 -22
- package/dist/resources/artifacts.d.ts.map +0 -1
- package/dist/resources/artifacts.js +0 -46
- package/dist/resources/artifacts.js.map +0 -1
- package/dist/resources/decisions.d.ts +0 -24
- package/dist/resources/decisions.d.ts.map +0 -1
- package/dist/resources/decisions.js +0 -53
- package/dist/resources/decisions.js.map +0 -1
- package/dist/resources/governance.d.ts +0 -30
- package/dist/resources/governance.d.ts.map +0 -1
- package/dist/resources/governance.js +0 -33
- package/dist/resources/governance.js.map +0 -1
- package/dist/types.d.ts +0 -117
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/util.d.ts +0 -4
- package/dist/util.d.ts.map +0 -1
- package/dist/util.js +0 -11
- package/dist/util.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,489 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
interface VerifyDecisionParams {
|
|
2
|
+
/** Artifact ID from NOMOS Studio or the Exchange */
|
|
3
|
+
artifact_id: string;
|
|
4
|
+
/** The data fields this decision is based on */
|
|
5
|
+
decision_context: Record<string, unknown>;
|
|
6
|
+
/** Optional: the AI's proposed decision (for audit trail) */
|
|
7
|
+
proposed_decision?: string;
|
|
8
|
+
/** Optional: unique ID for idempotency */
|
|
9
|
+
correlation_id?: string;
|
|
10
|
+
}
|
|
11
|
+
interface ListArtifactsParams {
|
|
12
|
+
/** Filter by autonomy band */
|
|
13
|
+
band?: 'autonomous' | 'bounded' | 'human_governed';
|
|
14
|
+
/** Filter by domain */
|
|
15
|
+
domain?: string;
|
|
16
|
+
/** Filter by jurisdiction tag */
|
|
17
|
+
jurisdiction?: string;
|
|
18
|
+
/** Sort order */
|
|
19
|
+
sort?: 'newest' | 'top_rated' | 'most_used';
|
|
20
|
+
/** Number of results (default 20, max 100) */
|
|
21
|
+
limit?: number;
|
|
22
|
+
/** Pagination offset */
|
|
23
|
+
offset?: number;
|
|
24
|
+
}
|
|
25
|
+
interface GenerateGovernanceParams {
|
|
26
|
+
/** Policy documents as plain text */
|
|
27
|
+
policies: string[];
|
|
28
|
+
/** Historical decision logs (CSV rows or JSON objects) */
|
|
29
|
+
decision_logs?: Record<string, unknown>[];
|
|
30
|
+
/** Domain name (e.g. "loan_approval") */
|
|
31
|
+
domain?: string;
|
|
32
|
+
/** Organisation name */
|
|
33
|
+
organisation?: string;
|
|
34
|
+
}
|
|
35
|
+
interface DetectContradictionsParams {
|
|
36
|
+
/** Array of rules to check */
|
|
37
|
+
rules: Array<{
|
|
38
|
+
id: string;
|
|
39
|
+
condition: string;
|
|
40
|
+
outcome: string;
|
|
41
|
+
priority?: number;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
type Verdict = 'approved' | 'rejected' | 'escalated';
|
|
45
|
+
type CanVerdict = 'AUTHORIZED' | 'DENIED' | 'ESCALATED';
|
|
46
|
+
interface CanParams {
|
|
47
|
+
/** Exchange artifact id or slug, e.g. "eu-ai-act-full-regulation-2024-1689" */
|
|
48
|
+
authority: string;
|
|
49
|
+
/** Optional human-readable label for what's being asked (recorded in the transcript) */
|
|
50
|
+
action?: string;
|
|
51
|
+
/** The facts to evaluate. Either pass this explicitly, or spread the facts flat alongside
|
|
52
|
+
* `authority`/`action` — both shapes are accepted (explicit `inputs` wins if both given). */
|
|
53
|
+
inputs?: Record<string, unknown>;
|
|
54
|
+
/** Flat-facts convenience: any extra keys are treated as inputs when `inputs` is omitted. */
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
interface CanOptions {
|
|
58
|
+
/** Override the API host (defaults to the public NOMOS Exchange). */
|
|
59
|
+
baseUrl?: string;
|
|
60
|
+
/** AbortSignal to cancel the request. */
|
|
61
|
+
signal?: AbortSignal;
|
|
62
|
+
}
|
|
63
|
+
interface CanResult {
|
|
64
|
+
/** True only for an AUTHORIZED verdict. DENIED and ESCALATED are both `false`. */
|
|
65
|
+
allowed: boolean;
|
|
66
|
+
/** The authority's own verdict, verbatim. */
|
|
67
|
+
verdict: CanVerdict;
|
|
68
|
+
/** Human-readable explanation of the verdict. */
|
|
69
|
+
reason: string;
|
|
70
|
+
/** The rule id that decided it, if any. */
|
|
71
|
+
rule: string | null;
|
|
72
|
+
/** Permanent, addressable transcript id — open it any time. */
|
|
73
|
+
query_id: string;
|
|
74
|
+
/** Relative URL of the transcript. */
|
|
75
|
+
url: string;
|
|
76
|
+
/** Which authority answered, and its standing. */
|
|
77
|
+
authority: {
|
|
78
|
+
id: string;
|
|
79
|
+
title: string;
|
|
80
|
+
standing: string;
|
|
81
|
+
};
|
|
82
|
+
/** On ESCALATED: the facts the authority still needs to reach a verdict. */
|
|
83
|
+
missing_inputs: string[];
|
|
84
|
+
}
|
|
85
|
+
interface VerifyDecisionResult {
|
|
86
|
+
/** Unique request ID — include in support tickets */
|
|
87
|
+
id: string;
|
|
88
|
+
/** Always "decision" */
|
|
89
|
+
object: 'decision';
|
|
90
|
+
/** The artifact that governed this decision */
|
|
91
|
+
artifact_id: string;
|
|
92
|
+
/** Artifact name */
|
|
93
|
+
artifact_name: string;
|
|
94
|
+
/** Whether the decision is permitted under current governance */
|
|
95
|
+
allowed: boolean;
|
|
96
|
+
/** Human-readable verdict */
|
|
97
|
+
verdict: Verdict;
|
|
98
|
+
/** The rule that triggered this verdict, if any */
|
|
99
|
+
rule?: {
|
|
100
|
+
id: string;
|
|
101
|
+
description: string | null;
|
|
102
|
+
action: 'allow' | 'deny' | 'escalate';
|
|
103
|
+
};
|
|
104
|
+
/** Evaluation metrics */
|
|
105
|
+
evaluation: {
|
|
106
|
+
rules_evaluated: number;
|
|
107
|
+
rules_matched: number;
|
|
108
|
+
rules_expired: number;
|
|
109
|
+
conflicts_resolved: number;
|
|
110
|
+
};
|
|
111
|
+
/** Confidence in the verdict */
|
|
112
|
+
confidence: {
|
|
113
|
+
/** Artifact verification tier */
|
|
114
|
+
tier: string;
|
|
115
|
+
/** 0–1 confidence score */
|
|
116
|
+
score: number;
|
|
117
|
+
/** Human-readable explanation of the tier */
|
|
118
|
+
description: string;
|
|
119
|
+
};
|
|
120
|
+
/** Audit record — store the hash for compliance */
|
|
121
|
+
audit: {
|
|
122
|
+
hash: string;
|
|
123
|
+
timestamp: string;
|
|
124
|
+
};
|
|
125
|
+
/** Performance metrics */
|
|
126
|
+
performance: {
|
|
127
|
+
latency_ms: number;
|
|
128
|
+
};
|
|
129
|
+
/** API schema version */
|
|
130
|
+
schema_version: string;
|
|
131
|
+
/** Human-readable explanation */
|
|
132
|
+
verdict_description: string;
|
|
133
|
+
/** Missing input fields, if any rule-referenced fields were absent */
|
|
134
|
+
incomplete_inputs?: {
|
|
135
|
+
fields: string[];
|
|
136
|
+
count: number;
|
|
137
|
+
warning: string;
|
|
138
|
+
};
|
|
139
|
+
/** How to satisfy an approval rule when current verdict is not approved */
|
|
140
|
+
paths_to_approval?: Array<{
|
|
141
|
+
rule_id: string | null;
|
|
142
|
+
rule_name: string | null;
|
|
143
|
+
required_changes: Array<{
|
|
144
|
+
field: string;
|
|
145
|
+
current: unknown;
|
|
146
|
+
must_satisfy: string;
|
|
147
|
+
}>;
|
|
148
|
+
}>;
|
|
149
|
+
}
|
|
150
|
+
interface Artifact {
|
|
151
|
+
id: string;
|
|
152
|
+
title: string;
|
|
153
|
+
description?: string;
|
|
154
|
+
domain?: string;
|
|
155
|
+
verification_tier: 'DECLARED' | 'VALIDATED' | 'CERTIFIED' | 'PROVEN' | 'SOVEREIGN';
|
|
156
|
+
autonomy_band: 'autonomous' | 'bounded' | 'human_governed';
|
|
157
|
+
ari_score?: number;
|
|
158
|
+
rule_count?: number;
|
|
159
|
+
jurisdiction_tags: string[];
|
|
160
|
+
industry_tags: string[];
|
|
161
|
+
publisher_org?: string;
|
|
162
|
+
seal_hash?: string;
|
|
163
|
+
downloads: number;
|
|
164
|
+
rating?: number;
|
|
165
|
+
price_usd: number;
|
|
166
|
+
published_at?: string;
|
|
167
|
+
created_at: string;
|
|
168
|
+
}
|
|
169
|
+
interface ArtifactList {
|
|
170
|
+
data: Artifact[];
|
|
171
|
+
total: number;
|
|
172
|
+
limit: number;
|
|
173
|
+
offset: number;
|
|
174
|
+
}
|
|
175
|
+
interface ArtifactSchemaField {
|
|
176
|
+
name: string;
|
|
177
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'date' | 'datetime' | 'enum' | 'array';
|
|
178
|
+
required: boolean;
|
|
179
|
+
description?: string;
|
|
180
|
+
enum?: string[];
|
|
181
|
+
min?: number;
|
|
182
|
+
max?: number;
|
|
183
|
+
format?: string;
|
|
184
|
+
}
|
|
185
|
+
interface ArtifactSchema {
|
|
186
|
+
artifact_id: string;
|
|
187
|
+
name: string;
|
|
188
|
+
fields: ArtifactSchemaField[];
|
|
189
|
+
required_fields: string[];
|
|
190
|
+
example_inputs: Record<string, unknown>;
|
|
191
|
+
field_count: number;
|
|
192
|
+
}
|
|
193
|
+
interface Contradiction {
|
|
194
|
+
type: 'threshold_conflict' | 'role_conflict' | 'ghost_term' | 'rule_collision' | 'layer_divergence';
|
|
195
|
+
severity: 'critical' | 'warning' | 'info';
|
|
196
|
+
rule_ids: string[];
|
|
197
|
+
description: string;
|
|
198
|
+
suggested_resolution?: string;
|
|
199
|
+
}
|
|
200
|
+
interface DetectContradictionsResult {
|
|
201
|
+
contradiction_count: number;
|
|
202
|
+
contradictions: Contradiction[];
|
|
203
|
+
clean: boolean;
|
|
204
|
+
}
|
|
205
|
+
interface GenerateGovernanceResult {
|
|
206
|
+
artifact_id: string;
|
|
207
|
+
seal_hash: string;
|
|
208
|
+
ari_score: number;
|
|
209
|
+
autonomy_band: 'autonomous' | 'bounded' | 'human_governed';
|
|
210
|
+
rule_count: number;
|
|
211
|
+
verification_tier: string;
|
|
212
|
+
download_url?: string;
|
|
213
|
+
}
|
|
214
|
+
interface NomosConfig {
|
|
215
|
+
/** Base URL override — defaults to https://nomos.ai */
|
|
216
|
+
baseUrl?: string;
|
|
217
|
+
/** Max retries on 429 / 5xx (default: 3) */
|
|
218
|
+
maxRetries?: number;
|
|
219
|
+
/** Request timeout in ms (default: 30000) */
|
|
220
|
+
timeout?: number;
|
|
221
|
+
}
|
|
222
|
+
interface RequestOptions {
|
|
223
|
+
/** Per-request timeout override in ms */
|
|
224
|
+
timeout?: number;
|
|
225
|
+
/** Per-request max retries override */
|
|
226
|
+
maxRetries?: number;
|
|
227
|
+
/** Idempotency key — safe to retry the same request server-side */
|
|
228
|
+
idempotencyKey?: string;
|
|
229
|
+
/** Per-request API key — useful for multi-tenant platforms */
|
|
230
|
+
apiKey?: string;
|
|
231
|
+
}
|
|
232
|
+
interface NomosRawResponse {
|
|
233
|
+
/** x-request-id header value — include in support tickets */
|
|
234
|
+
requestId: string;
|
|
235
|
+
statusCode: number;
|
|
236
|
+
headers: Record<string, string>;
|
|
237
|
+
}
|
|
238
|
+
/** Every SDK response carries `.lastResponse` for debugging and tracing. */
|
|
239
|
+
type WithLastResponse<T> = T & {
|
|
240
|
+
lastResponse: NomosRawResponse;
|
|
241
|
+
};
|
|
242
|
+
type NomosWebhookEventType = 'artifact.sealed' | 'artifact.published' | 'decision.verified' | 'decision.escalated' | 'exchange.purchased' | 'exchange.reviewed' | 'drift.detected';
|
|
243
|
+
interface NomosWebhookEvent {
|
|
244
|
+
id: string;
|
|
245
|
+
type: NomosWebhookEventType;
|
|
246
|
+
created: number;
|
|
247
|
+
artifact_id?: string;
|
|
248
|
+
data: Record<string, unknown>;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
interface HttpClientOptions {
|
|
252
|
+
apiKey: string;
|
|
253
|
+
baseUrl: string;
|
|
254
|
+
maxRetries: number;
|
|
255
|
+
timeout: number;
|
|
256
|
+
}
|
|
257
|
+
interface HttpResponse<T> {
|
|
258
|
+
data: T;
|
|
259
|
+
lastResponse: NomosRawResponse;
|
|
260
|
+
}
|
|
261
|
+
declare class HttpClient {
|
|
262
|
+
private readonly opts;
|
|
263
|
+
constructor(opts: HttpClientOptions);
|
|
264
|
+
get<T>(path: string, reqOpts?: RequestOptions): Promise<HttpResponse<T>>;
|
|
265
|
+
post<T>(path: string, body: unknown, reqOpts?: RequestOptions): Promise<HttpResponse<T>>;
|
|
266
|
+
private request;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
declare class Decisions {
|
|
270
|
+
private readonly http;
|
|
271
|
+
constructor(http: HttpClient);
|
|
272
|
+
/**
|
|
273
|
+
* Verify whether an AI decision is permitted under a governance artifact.
|
|
274
|
+
*
|
|
275
|
+
* Public demo artifacts (`pub_*`) work without an API key.
|
|
276
|
+
* Custom artifacts require a valid API key.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* const result = await nomos.decisions.verify({
|
|
280
|
+
* artifact_id: 'pub_lending_v1',
|
|
281
|
+
* decision_context: { credit_score: 720, loan_amount: 50000 },
|
|
282
|
+
* });
|
|
283
|
+
*
|
|
284
|
+
* if (!result.allowed) {
|
|
285
|
+
* throw new Error(`Blocked: ${result.verdict_description}`);
|
|
286
|
+
* }
|
|
287
|
+
*
|
|
288
|
+
* // Debugging / tracing
|
|
289
|
+
* console.log(result.lastResponse.requestId);
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* // Per-request options
|
|
293
|
+
* const result = await nomos.decisions.verify(params, {
|
|
294
|
+
* idempotencyKey: `verify-${transactionId}`,
|
|
295
|
+
* timeout: 5000,
|
|
296
|
+
* });
|
|
297
|
+
*/
|
|
298
|
+
verify(params: VerifyDecisionParams, opts?: RequestOptions): Promise<WithLastResponse<VerifyDecisionResult>>;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
declare class Artifacts {
|
|
302
|
+
private readonly http;
|
|
303
|
+
constructor(http: HttpClient);
|
|
304
|
+
/**
|
|
305
|
+
* Retrieve a single artifact by ID.
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* const artifact = await nomos.artifacts.retrieve('loan_approval_v1');
|
|
309
|
+
* console.log(artifact.ari_score, artifact.autonomy_band);
|
|
310
|
+
* console.log(artifact.lastResponse.requestId); // for support tickets
|
|
311
|
+
*/
|
|
312
|
+
retrieve(artifactId: string, opts?: RequestOptions): Promise<WithLastResponse<Artifact>>;
|
|
313
|
+
/**
|
|
314
|
+
* List published artifacts on the Exchange with optional filters.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* const { data, total } = await nomos.artifacts.list({ band: 'autonomous', limit: 10 });
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* // With per-request options
|
|
321
|
+
* const page = await nomos.artifacts.list({ limit: 20 }, { timeout: 5000 });
|
|
322
|
+
*/
|
|
323
|
+
list(params?: ListArtifactsParams, opts?: RequestOptions): Promise<WithLastResponse<ArtifactList>>;
|
|
324
|
+
/**
|
|
325
|
+
* Auto-paginating iterator — yields every artifact across all pages.
|
|
326
|
+
* Stops automatically when the last page is reached.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* for await (const artifact of nomos.artifacts.listAutoPaging({ band: 'autonomous' })) {
|
|
330
|
+
* console.log(artifact.title, artifact.ari_score);
|
|
331
|
+
* }
|
|
332
|
+
*/
|
|
333
|
+
listAutoPaging(params?: ListArtifactsParams, opts?: RequestOptions): AsyncGenerator<Artifact>;
|
|
334
|
+
/**
|
|
335
|
+
* Retrieve the declared input schema for a sealed artifact.
|
|
336
|
+
*
|
|
337
|
+
* Returns every field the artifact's rules reference — name, type, whether it's
|
|
338
|
+
* required, and a ready-to-use example_inputs object. Use this to build forms,
|
|
339
|
+
* validate payloads, or generate API docs without reading the rules manually.
|
|
340
|
+
*
|
|
341
|
+
* Requires an API key (artifact schemas are not public).
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* const schema = await nomos.artifacts.schema('art_abc123');
|
|
345
|
+
* console.log(schema.required_fields); // ['credit_score', 'loan_amount']
|
|
346
|
+
* console.log(schema.example_inputs); // { credit_score: 0, loan_amount: 0 }
|
|
347
|
+
*/
|
|
348
|
+
schema(artifactId: string, opts?: RequestOptions): Promise<WithLastResponse<ArtifactSchema>>;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
declare class Governance {
|
|
352
|
+
private readonly http;
|
|
353
|
+
constructor(http: HttpClient);
|
|
354
|
+
/**
|
|
355
|
+
* Generate a sealed .nomos governance artifact from policy documents
|
|
356
|
+
* and optional historical decision logs.
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* const artifact = await nomos.governance.generate({
|
|
360
|
+
* policies: [policyText],
|
|
361
|
+
* decision_logs: historicalRows,
|
|
362
|
+
* domain: 'loan_approval',
|
|
363
|
+
* });
|
|
364
|
+
* console.log(artifact.ari_score, artifact.seal_hash);
|
|
365
|
+
*/
|
|
366
|
+
generate(params: GenerateGovernanceParams, opts?: RequestOptions): Promise<WithLastResponse<GenerateGovernanceResult>>;
|
|
367
|
+
/**
|
|
368
|
+
* Detect contradictions and conflicts in a rule set before sealing.
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* const report = await nomos.governance.detectContradictions({ rules });
|
|
372
|
+
* if (!report.clean) {
|
|
373
|
+
* console.log(report.contradictions);
|
|
374
|
+
* }
|
|
375
|
+
*/
|
|
376
|
+
detectContradictions(params: DetectContradictionsParams, opts?: RequestOptions): Promise<WithLastResponse<DetectContradictionsResult>>;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
declare class Webhooks {
|
|
380
|
+
/**
|
|
381
|
+
* Verify a NOMOS webhook signature and return the parsed event.
|
|
382
|
+
*
|
|
383
|
+
* Signature header format: `t=<unix_ts>,v1=<hmac_sha256_hex>`
|
|
384
|
+
* Signed payload: `<timestamp>.<raw_body>`
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* // Express
|
|
388
|
+
* app.post('/webhooks/nomos', express.raw({ type: 'application/json' }), async (req, res) => {
|
|
389
|
+
* const event = await nomos.webhooks.constructEvent(
|
|
390
|
+
* req.body,
|
|
391
|
+
* req.headers['nomos-signature'] as string,
|
|
392
|
+
* process.env.NOMOS_WEBHOOK_SECRET!,
|
|
393
|
+
* );
|
|
394
|
+
* console.log(event.type, event.data);
|
|
395
|
+
* res.sendStatus(200);
|
|
396
|
+
* });
|
|
397
|
+
*
|
|
398
|
+
* @throws {NomosWebhookSignatureError} if signature is invalid, expired, or malformed
|
|
399
|
+
*/
|
|
400
|
+
constructEvent(payload: string | Uint8Array, signature: string, secret: string, toleranceSeconds?: number): Promise<NomosWebhookEvent>;
|
|
401
|
+
/**
|
|
402
|
+
* Verify a webhook signature without parsing the event.
|
|
403
|
+
* Returns `true` if valid, `false` if not (never throws).
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* const valid = await nomos.webhooks.verifySignature(rawBody, sig, secret);
|
|
407
|
+
* if (!valid) return res.sendStatus(400);
|
|
408
|
+
*/
|
|
409
|
+
verifySignature(payload: string | Uint8Array, signature: string, secret: string, toleranceSeconds?: number): Promise<boolean>;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
type NomosErrorCode = 'authentication_error' | 'authorization_error' | 'rate_limit_error' | 'validation_error' | 'not_found' | 'api_error' | 'network_error' | 'webhook_signature_error';
|
|
413
|
+
declare class NomosError extends Error {
|
|
414
|
+
readonly code: NomosErrorCode;
|
|
415
|
+
readonly status?: number;
|
|
416
|
+
readonly requestId?: string;
|
|
417
|
+
constructor(message: string, code: NomosErrorCode, status?: number, requestId?: string);
|
|
418
|
+
}
|
|
419
|
+
declare class NomosAuthenticationError extends NomosError {
|
|
420
|
+
constructor(message?: string, requestId?: string);
|
|
421
|
+
}
|
|
422
|
+
declare class NomosAuthorizationError extends NomosError {
|
|
423
|
+
constructor(message?: string, requestId?: string);
|
|
424
|
+
}
|
|
425
|
+
declare class NomosRateLimitError extends NomosError {
|
|
426
|
+
readonly retryAfter?: number;
|
|
427
|
+
constructor(message?: string, retryAfter?: number, requestId?: string);
|
|
428
|
+
}
|
|
429
|
+
declare class NomosValidationError extends NomosError {
|
|
430
|
+
readonly details?: unknown;
|
|
431
|
+
constructor(message: string, details?: unknown, requestId?: string);
|
|
432
|
+
}
|
|
433
|
+
declare class NomosNotFoundError extends NomosError {
|
|
434
|
+
constructor(message: string, requestId?: string);
|
|
435
|
+
}
|
|
436
|
+
declare class NomosAPIError extends NomosError {
|
|
437
|
+
constructor(message: string, status: number, requestId?: string);
|
|
438
|
+
}
|
|
439
|
+
declare class NomosNetworkError extends NomosError {
|
|
440
|
+
constructor(message: string);
|
|
441
|
+
}
|
|
442
|
+
declare class NomosWebhookSignatureError extends NomosError {
|
|
443
|
+
constructor(message: string);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
type errors_NomosAPIError = NomosAPIError;
|
|
447
|
+
declare const errors_NomosAPIError: typeof NomosAPIError;
|
|
448
|
+
type errors_NomosAuthenticationError = NomosAuthenticationError;
|
|
449
|
+
declare const errors_NomosAuthenticationError: typeof NomosAuthenticationError;
|
|
450
|
+
type errors_NomosAuthorizationError = NomosAuthorizationError;
|
|
451
|
+
declare const errors_NomosAuthorizationError: typeof NomosAuthorizationError;
|
|
452
|
+
type errors_NomosError = NomosError;
|
|
453
|
+
declare const errors_NomosError: typeof NomosError;
|
|
454
|
+
type errors_NomosErrorCode = NomosErrorCode;
|
|
455
|
+
type errors_NomosNetworkError = NomosNetworkError;
|
|
456
|
+
declare const errors_NomosNetworkError: typeof NomosNetworkError;
|
|
457
|
+
type errors_NomosNotFoundError = NomosNotFoundError;
|
|
458
|
+
declare const errors_NomosNotFoundError: typeof NomosNotFoundError;
|
|
459
|
+
type errors_NomosRateLimitError = NomosRateLimitError;
|
|
460
|
+
declare const errors_NomosRateLimitError: typeof NomosRateLimitError;
|
|
461
|
+
type errors_NomosValidationError = NomosValidationError;
|
|
462
|
+
declare const errors_NomosValidationError: typeof NomosValidationError;
|
|
463
|
+
type errors_NomosWebhookSignatureError = NomosWebhookSignatureError;
|
|
464
|
+
declare const errors_NomosWebhookSignatureError: typeof NomosWebhookSignatureError;
|
|
465
|
+
declare namespace errors {
|
|
466
|
+
export { errors_NomosAPIError as NomosAPIError, errors_NomosAuthenticationError as NomosAuthenticationError, errors_NomosAuthorizationError as NomosAuthorizationError, errors_NomosError as NomosError, type errors_NomosErrorCode as NomosErrorCode, errors_NomosNetworkError as NomosNetworkError, errors_NomosNotFoundError as NomosNotFoundError, errors_NomosRateLimitError as NomosRateLimitError, errors_NomosValidationError as NomosValidationError, errors_NomosWebhookSignatureError as NomosWebhookSignatureError };
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
declare class Nomos {
|
|
470
|
+
readonly decisions: Decisions;
|
|
471
|
+
readonly artifacts: Artifacts;
|
|
472
|
+
readonly governance: Governance;
|
|
473
|
+
readonly webhooks: Webhooks;
|
|
474
|
+
/** Whether this instance is using a live or test API key. */
|
|
475
|
+
readonly mode: 'live' | 'test';
|
|
476
|
+
static readonly errors: typeof errors;
|
|
477
|
+
constructor(apiKey: string, config?: NomosConfig);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
declare function can(params: CanParams, opts?: CanOptions): Promise<CanResult>;
|
|
481
|
+
/**
|
|
482
|
+
* Ready-to-use, keyless entry point matching the canonical `nomos.can(...)` form.
|
|
483
|
+
* For authenticated, key-scoped operations use the `Nomos` class instead.
|
|
484
|
+
*/
|
|
485
|
+
declare const nomos: {
|
|
486
|
+
can: typeof can;
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
export { type Artifact, type ArtifactList, type ArtifactSchema, type ArtifactSchemaField, type CanOptions, type CanParams, type CanResult, type CanVerdict, type Contradiction, type DetectContradictionsParams, type DetectContradictionsResult, type GenerateGovernanceParams, type GenerateGovernanceResult, type ListArtifactsParams, Nomos, NomosAPIError, NomosAuthenticationError, NomosAuthorizationError, type NomosConfig, NomosError, type NomosErrorCode, NomosNetworkError, NomosNotFoundError, NomosRateLimitError, type NomosRawResponse, NomosValidationError, type NomosWebhookEvent, type NomosWebhookEventType, NomosWebhookSignatureError, type RequestOptions, type Verdict, type VerifyDecisionParams, type VerifyDecisionResult, type WithLastResponse, can, nomos };
|