@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/package.json
CHANGED
|
@@ -1,26 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomosprotocol/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Official TypeScript SDK for the NOMOS governance runtime",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
|
-
"main": "./dist/index.
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
10
|
+
"module": "./dist/index.js",
|
|
10
11
|
"types": "./dist/index.d.ts",
|
|
11
12
|
"exports": {
|
|
12
13
|
".": {
|
|
13
|
-
"import":
|
|
14
|
-
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.cts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
15
22
|
}
|
|
16
23
|
},
|
|
17
24
|
"files": [
|
|
18
25
|
"dist"
|
|
19
26
|
],
|
|
20
27
|
"scripts": {
|
|
21
|
-
"build": "
|
|
22
|
-
"dev": "
|
|
23
|
-
"clean": "rm -rf dist"
|
|
28
|
+
"build": "tsup",
|
|
29
|
+
"dev": "tsup --watch",
|
|
30
|
+
"clean": "rm -rf dist",
|
|
31
|
+
"type-check": "tsc --noEmit"
|
|
32
|
+
},
|
|
33
|
+
"tsup": {
|
|
34
|
+
"entry": ["src/index.ts"],
|
|
35
|
+
"format": ["esm", "cjs"],
|
|
36
|
+
"dts": true,
|
|
37
|
+
"clean": true,
|
|
38
|
+
"target": "node18",
|
|
39
|
+
"splitting": false,
|
|
40
|
+
"sourcemap": true
|
|
24
41
|
},
|
|
25
42
|
"keywords": [
|
|
26
43
|
"nomos",
|
|
@@ -35,6 +52,7 @@
|
|
|
35
52
|
"node": ">=18"
|
|
36
53
|
},
|
|
37
54
|
"devDependencies": {
|
|
55
|
+
"tsup": "^8.5.1",
|
|
38
56
|
"typescript": "^5.9.3"
|
|
39
57
|
}
|
|
40
58
|
}
|
package/dist/errors.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export type NomosErrorCode = 'authentication_error' | 'authorization_error' | 'rate_limit_error' | 'validation_error' | 'not_found' | 'api_error' | 'network_error';
|
|
2
|
-
export declare class NomosError extends Error {
|
|
3
|
-
readonly code: NomosErrorCode;
|
|
4
|
-
readonly status?: number;
|
|
5
|
-
readonly requestId?: string;
|
|
6
|
-
constructor(message: string, code: NomosErrorCode, status?: number, requestId?: string);
|
|
7
|
-
}
|
|
8
|
-
export declare class NomosAuthenticationError extends NomosError {
|
|
9
|
-
constructor(message?: string, requestId?: string);
|
|
10
|
-
}
|
|
11
|
-
export declare class NomosAuthorizationError extends NomosError {
|
|
12
|
-
constructor(message?: string, requestId?: string);
|
|
13
|
-
}
|
|
14
|
-
export declare class NomosRateLimitError extends NomosError {
|
|
15
|
-
readonly retryAfter?: number;
|
|
16
|
-
constructor(message?: string, retryAfter?: number, requestId?: string);
|
|
17
|
-
}
|
|
18
|
-
export declare class NomosValidationError extends NomosError {
|
|
19
|
-
readonly details?: unknown;
|
|
20
|
-
constructor(message: string, details?: unknown, requestId?: string);
|
|
21
|
-
}
|
|
22
|
-
export declare class NomosNotFoundError extends NomosError {
|
|
23
|
-
constructor(message: string, requestId?: string);
|
|
24
|
-
}
|
|
25
|
-
export declare class NomosAPIError extends NomosError {
|
|
26
|
-
constructor(message: string, status: number, requestId?: string);
|
|
27
|
-
}
|
|
28
|
-
export declare class NomosNetworkError extends NomosError {
|
|
29
|
-
constructor(message: string);
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GACtB,sBAAsB,GACtB,qBAAqB,GACrB,kBAAkB,GAClB,kBAAkB,GAClB,WAAW,GACX,WAAW,GACX,eAAe,CAAC;AAEpB,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;gBAEhB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAOvF;AAED,qBAAa,wBAAyB,SAAQ,UAAU;gBAC1C,OAAO,SAAoB,EAAE,SAAS,CAAC,EAAE,MAAM;CAI5D;AAED,qBAAa,uBAAwB,SAAQ,UAAU;gBACzC,OAAO,SAAkB,EAAE,SAAS,CAAC,EAAE,MAAM;CAI1D;AAED,qBAAa,mBAAoB,SAAQ,UAAU;IACjD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEjB,OAAO,SAAwB,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAKrF;AAED,qBAAa,oBAAqB,SAAQ,UAAU;IAClD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM;CAKnE;AAED,qBAAa,kBAAmB,SAAQ,UAAU;gBACpC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAIhD;AAED,qBAAa,aAAc,SAAQ,UAAU;gBAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAIhE;AAED,qBAAa,iBAAkB,SAAQ,UAAU;gBACnC,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export class NomosError extends Error {
|
|
2
|
-
constructor(message, code, status, requestId) {
|
|
3
|
-
super(message);
|
|
4
|
-
this.name = 'NomosError';
|
|
5
|
-
this.code = code;
|
|
6
|
-
this.status = status;
|
|
7
|
-
this.requestId = requestId;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export class NomosAuthenticationError extends NomosError {
|
|
11
|
-
constructor(message = 'Invalid API key', requestId) {
|
|
12
|
-
super(message, 'authentication_error', 401, requestId);
|
|
13
|
-
this.name = 'NomosAuthenticationError';
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export class NomosAuthorizationError extends NomosError {
|
|
17
|
-
constructor(message = 'Access denied', requestId) {
|
|
18
|
-
super(message, 'authorization_error', 403, requestId);
|
|
19
|
-
this.name = 'NomosAuthorizationError';
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export class NomosRateLimitError extends NomosError {
|
|
23
|
-
constructor(message = 'Rate limit exceeded', retryAfter, requestId) {
|
|
24
|
-
super(message, 'rate_limit_error', 429, requestId);
|
|
25
|
-
this.name = 'NomosRateLimitError';
|
|
26
|
-
this.retryAfter = retryAfter;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export class NomosValidationError extends NomosError {
|
|
30
|
-
constructor(message, details, requestId) {
|
|
31
|
-
super(message, 'validation_error', 400, requestId);
|
|
32
|
-
this.name = 'NomosValidationError';
|
|
33
|
-
this.details = details;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export class NomosNotFoundError extends NomosError {
|
|
37
|
-
constructor(message, requestId) {
|
|
38
|
-
super(message, 'not_found', 404, requestId);
|
|
39
|
-
this.name = 'NomosNotFoundError';
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export class NomosAPIError extends NomosError {
|
|
43
|
-
constructor(message, status, requestId) {
|
|
44
|
-
super(message, 'api_error', status, requestId);
|
|
45
|
-
this.name = 'NomosAPIError';
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
export class NomosNetworkError extends NomosError {
|
|
49
|
-
constructor(message) {
|
|
50
|
-
super(message, 'network_error');
|
|
51
|
-
this.name = 'NomosNetworkError';
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,UAAW,SAAQ,KAAK;IAKnC,YAAY,OAAe,EAAE,IAAoB,EAAE,MAAe,EAAE,SAAkB;QACpF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,wBAAyB,SAAQ,UAAU;IACtD,YAAY,OAAO,GAAG,iBAAiB,EAAE,SAAkB;QACzD,KAAK,CAAC,OAAO,EAAE,sBAAsB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,UAAU;IACrD,YAAY,OAAO,GAAG,eAAe,EAAE,SAAkB;QACvD,KAAK,CAAC,OAAO,EAAE,qBAAqB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IAGjD,YAAY,OAAO,GAAG,qBAAqB,EAAE,UAAmB,EAAE,SAAkB;QAClF,KAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IAGlD,YAAY,OAAe,EAAE,OAAiB,EAAE,SAAkB;QAChE,KAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IAChD,YAAY,OAAe,EAAE,SAAkB;QAC7C,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,UAAU;IAC3C,YAAY,OAAe,EAAE,MAAc,EAAE,SAAkB;QAC7D,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF"}
|
package/dist/http-client.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface HttpClientOptions {
|
|
2
|
-
apiKey: string;
|
|
3
|
-
baseUrl: string;
|
|
4
|
-
maxRetries: number;
|
|
5
|
-
timeout: number;
|
|
6
|
-
}
|
|
7
|
-
export declare class HttpClient {
|
|
8
|
-
private readonly opts;
|
|
9
|
-
constructor(opts: HttpClientOptions);
|
|
10
|
-
get<T>(path: string): Promise<T>;
|
|
11
|
-
post<T>(path: string, body: unknown): Promise<T>;
|
|
12
|
-
private request;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=http-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,iBAAiB;IAE9C,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAIhC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;YAIxC,OAAO;CA6DtB"}
|
package/dist/http-client.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { NomosAuthenticationError, NomosAuthorizationError, NomosRateLimitError, NomosValidationError, NomosNotFoundError, NomosAPIError, NomosNetworkError, } from './errors.js';
|
|
2
|
-
import { sleep, jitteredBackoff, isRetryable } from './util.js';
|
|
3
|
-
export class HttpClient {
|
|
4
|
-
constructor(opts) {
|
|
5
|
-
this.opts = opts;
|
|
6
|
-
}
|
|
7
|
-
async get(path) {
|
|
8
|
-
return this.request('GET', path, undefined);
|
|
9
|
-
}
|
|
10
|
-
async post(path, body) {
|
|
11
|
-
return this.request('POST', path, body);
|
|
12
|
-
}
|
|
13
|
-
async request(method, path, body, attempt = 0) {
|
|
14
|
-
const url = `${this.opts.baseUrl}${path}`;
|
|
15
|
-
const controller = new AbortController();
|
|
16
|
-
const timer = setTimeout(() => controller.abort(), this.opts.timeout);
|
|
17
|
-
let res;
|
|
18
|
-
try {
|
|
19
|
-
res = await fetch(url, {
|
|
20
|
-
method,
|
|
21
|
-
signal: controller.signal,
|
|
22
|
-
headers: {
|
|
23
|
-
'Content-Type': 'application/json',
|
|
24
|
-
'X-Nomos-Api-Key': this.opts.apiKey,
|
|
25
|
-
'User-Agent': 'nomos-sdk/1.0.0',
|
|
26
|
-
},
|
|
27
|
-
body: body != null ? JSON.stringify(body) : undefined,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
catch (err) {
|
|
31
|
-
clearTimeout(timer);
|
|
32
|
-
if (err.name === 'AbortError') {
|
|
33
|
-
throw new NomosNetworkError(`Request timed out after ${this.opts.timeout}ms`);
|
|
34
|
-
}
|
|
35
|
-
throw new NomosNetworkError(err.message ?? 'Network error');
|
|
36
|
-
}
|
|
37
|
-
finally {
|
|
38
|
-
clearTimeout(timer);
|
|
39
|
-
}
|
|
40
|
-
const requestId = res.headers.get('x-request-id') ?? undefined;
|
|
41
|
-
if (res.ok) {
|
|
42
|
-
return res.json();
|
|
43
|
-
}
|
|
44
|
-
// Retry on 429 / 5xx
|
|
45
|
-
if (isRetryable(res.status) && attempt < this.opts.maxRetries) {
|
|
46
|
-
const retryAfter = res.headers.get('retry-after');
|
|
47
|
-
const delay = retryAfter
|
|
48
|
-
? parseInt(retryAfter, 10) * 1000
|
|
49
|
-
: jitteredBackoff(attempt);
|
|
50
|
-
await sleep(delay);
|
|
51
|
-
return this.request(method, path, body, attempt + 1);
|
|
52
|
-
}
|
|
53
|
-
let errBody = {};
|
|
54
|
-
try {
|
|
55
|
-
errBody = await res.json();
|
|
56
|
-
}
|
|
57
|
-
catch { }
|
|
58
|
-
const message = errBody?.error ?? errBody?.message ?? res.statusText;
|
|
59
|
-
switch (res.status) {
|
|
60
|
-
case 401: throw new NomosAuthenticationError(message, requestId);
|
|
61
|
-
case 403: throw new NomosAuthorizationError(message, requestId);
|
|
62
|
-
case 404: throw new NomosNotFoundError(message, requestId);
|
|
63
|
-
case 422:
|
|
64
|
-
case 400: throw new NomosValidationError(message, errBody?.details, requestId);
|
|
65
|
-
case 429: throw new NomosRateLimitError(message, res.headers.get('retry-after') ? parseInt(res.headers.get('retry-after'), 10) : undefined, requestId);
|
|
66
|
-
default: throw new NomosAPIError(message, res.status, requestId);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=http-client.js.map
|
package/dist/http-client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAShE,MAAM,OAAO,UAAU;IACrB,YAA6B,IAAuB;QAAvB,SAAI,GAAJ,IAAI,CAAmB;IAAG,CAAC;IAExD,KAAK,CAAC,GAAG,CAAI,IAAY;QACvB,OAAO,IAAI,CAAC,OAAO,CAAI,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,IAAI,CAAI,IAAY,EAAE,IAAa;QACvC,OAAO,IAAI,CAAC,OAAO,CAAI,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;IAEO,KAAK,CAAC,OAAO,CAAI,MAAc,EAAE,IAAY,EAAE,IAAa,EAAE,OAAO,GAAG,CAAC;QAC/E,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;QAC1C,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEtE,IAAI,GAAa,CAAC;QAClB,IAAI,CAAC;YACH,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;g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ACF"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,YAAY,EACV,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,QAAQ,EACR,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC1B,0BAA0B,EAC1B,aAAa,EACb,OAAO,GACR,MAAM,YAAY,CAAC"}
|
package/dist/nomos.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Decisions } from './resources/decisions.js';
|
|
2
|
-
import { Artifacts } from './resources/artifacts.js';
|
|
3
|
-
import { Governance } from './resources/governance.js';
|
|
4
|
-
import * as errors from './errors.js';
|
|
5
|
-
import type { NomosConfig } from './types.js';
|
|
6
|
-
export declare class Nomos {
|
|
7
|
-
readonly decisions: Decisions;
|
|
8
|
-
readonly artifacts: Artifacts;
|
|
9
|
-
readonly governance: Governance;
|
|
10
|
-
static readonly errors: typeof errors;
|
|
11
|
-
constructor(apiKey: string, config?: NomosConfig);
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=nomos.d.ts.map
|
package/dist/nomos.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nomos.d.ts","sourceRoot":"","sources":["../src/nomos.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM9C,qBAAa,KAAK;IAChB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAEhC,MAAM,CAAC,QAAQ,CAAC,MAAM,gBAAU;gBAEpB,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,WAAgB;CAkBrD"}
|
package/dist/nomos.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from './http-client.js';
|
|
2
|
-
import { Decisions } from './resources/decisions.js';
|
|
3
|
-
import { Artifacts } from './resources/artifacts.js';
|
|
4
|
-
import { Governance } from './resources/governance.js';
|
|
5
|
-
import * as errors from './errors.js';
|
|
6
|
-
const DEFAULT_BASE_URL = 'https://nomos.ai';
|
|
7
|
-
const DEFAULT_MAX_RETRIES = 3;
|
|
8
|
-
const DEFAULT_TIMEOUT = 30000;
|
|
9
|
-
export class Nomos {
|
|
10
|
-
constructor(apiKey, config = {}) {
|
|
11
|
-
if (!apiKey || typeof apiKey !== 'string') {
|
|
12
|
-
throw new errors.NomosAuthenticationError('A valid API key is required. Pass it as the first argument: new Nomos("nms_live_...")');
|
|
13
|
-
}
|
|
14
|
-
const http = new HttpClient({
|
|
15
|
-
apiKey,
|
|
16
|
-
baseUrl: (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, ''),
|
|
17
|
-
maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
18
|
-
timeout: config.timeout ?? DEFAULT_TIMEOUT,
|
|
19
|
-
});
|
|
20
|
-
this.decisions = new Decisions(http);
|
|
21
|
-
this.artifacts = new Artifacts(http);
|
|
22
|
-
this.governance = new Governance(http);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
Nomos.errors = errors;
|
|
26
|
-
//# sourceMappingURL=nomos.js.map
|
package/dist/nomos.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nomos.js","sourceRoot":"","sources":["../src/nomos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAGtC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAC5C,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,eAAe,GAAG,KAAM,CAAC;AAE/B,MAAM,OAAO,KAAK;IAOhB,YAAY,MAAc,EAAE,SAAsB,EAAE;QAClD,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC1C,MAAM,IAAI,MAAM,CAAC,wBAAwB,CACvC,uFAAuF,CACxF,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC;YAC1B,MAAM;YACN,OAAO,EAAK,CAAC,MAAM,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;YACnE,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,mBAAmB;YACpD,OAAO,EAAK,MAAM,CAAC,OAAO,IAAO,eAAe;SACjD,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAI,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS,GAAI,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;;AAnBe,YAAM,GAAG,MAAM,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { HttpClient } from '../http-client.js';
|
|
2
|
-
import type { Artifact, ArtifactList, ListArtifactsParams } from '../types.js';
|
|
3
|
-
export declare class Artifacts {
|
|
4
|
-
private readonly http;
|
|
5
|
-
constructor(http: HttpClient);
|
|
6
|
-
/**
|
|
7
|
-
* Retrieve a single artifact by ID.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* const artifact = await nomos.artifacts.retrieve('loan_approval_v1');
|
|
11
|
-
* console.log(artifact.ari_score, artifact.autonomy_band);
|
|
12
|
-
*/
|
|
13
|
-
retrieve(artifactId: string): Promise<Artifact>;
|
|
14
|
-
/**
|
|
15
|
-
* List published artifacts on the Exchange with optional filters.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* const { data } = await nomos.artifacts.list({ band: 'autonomous', limit: 10 });
|
|
19
|
-
*/
|
|
20
|
-
list(params?: ListArtifactsParams): Promise<ArtifactList>;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=artifacts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../../src/resources/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE/E,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;OAMG;IACG,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIrD;;;;;OAKG;IACG,IAAI,CAAC,MAAM,GAAE,mBAAwB,GAAG,OAAO,CAAC,YAAY,CAAC;CAkBpE"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export class Artifacts {
|
|
2
|
-
constructor(http) {
|
|
3
|
-
this.http = http;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Retrieve a single artifact by ID.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* const artifact = await nomos.artifacts.retrieve('loan_approval_v1');
|
|
10
|
-
* console.log(artifact.ari_score, artifact.autonomy_band);
|
|
11
|
-
*/
|
|
12
|
-
async retrieve(artifactId) {
|
|
13
|
-
return this.http.get(`/api/exchange/artifacts/${encodeURIComponent(artifactId)}`);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* List published artifacts on the Exchange with optional filters.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* const { data } = await nomos.artifacts.list({ band: 'autonomous', limit: 10 });
|
|
20
|
-
*/
|
|
21
|
-
async list(params = {}) {
|
|
22
|
-
const qs = new URLSearchParams();
|
|
23
|
-
if (params.band)
|
|
24
|
-
qs.set('band', params.band);
|
|
25
|
-
if (params.domain)
|
|
26
|
-
qs.set('domain', params.domain);
|
|
27
|
-
if (params.jurisdiction)
|
|
28
|
-
qs.set('jurisdiction', params.jurisdiction);
|
|
29
|
-
if (params.sort)
|
|
30
|
-
qs.set('sort', params.sort);
|
|
31
|
-
if (params.limit != null)
|
|
32
|
-
qs.set('limit', String(params.limit));
|
|
33
|
-
if (params.offset != null)
|
|
34
|
-
qs.set('offset', String(params.offset));
|
|
35
|
-
const query = qs.toString();
|
|
36
|
-
const raw = await this.http.get(`/api/exchange/artifacts${query ? `?${query}` : ''}`);
|
|
37
|
-
// API returns { artifacts: [], total: N } — normalise to { data: [], total: N }
|
|
38
|
-
return {
|
|
39
|
-
data: Array.isArray(raw) ? raw : (raw.artifacts ?? raw.data ?? []),
|
|
40
|
-
total: raw.total ?? (Array.isArray(raw) ? raw.length : 0),
|
|
41
|
-
limit: params.limit ?? 20,
|
|
42
|
-
offset: params.offset ?? 0,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=artifacts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","sourceRoot":"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CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3F,gFAAgF;QAChF,OAAO;YACL,IAAI,EAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;YACpE,KAAK,EAAG,GAAG,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1D,KAAK,EAAG,MAAM,CAAC,KAAK,IAAI,EAAE;YAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC;SAC3B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { HttpClient } from '../http-client.js';
|
|
2
|
-
import type { VerifyDecisionParams, VerifyDecisionResult } from '../types.js';
|
|
3
|
-
export declare class Decisions {
|
|
4
|
-
private readonly http;
|
|
5
|
-
constructor(http: HttpClient);
|
|
6
|
-
/**
|
|
7
|
-
* Verify whether an AI decision is permitted under a governance artifact.
|
|
8
|
-
*
|
|
9
|
-
* Public demo artifacts (pub_*) work without an API key.
|
|
10
|
-
* Custom artifacts require a valid API key.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* const result = await nomos.decisions.verify({
|
|
14
|
-
* artifact_id: 'pub_lending_v1',
|
|
15
|
-
* decision_context: { credit_score: 720, loan_amount: 50000 },
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* if (!result.allowed) {
|
|
19
|
-
* throw new Error(`Decision blocked: ${result.verdict_description}`);
|
|
20
|
-
* }
|
|
21
|
-
*/
|
|
22
|
-
verify(params: VerifyDecisionParams): Promise<VerifyDecisionResult>;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=decisions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decisions.d.ts","sourceRoot":"","sources":["../../src/resources/decisions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE9E,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;;;;;OAeG;IACG,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAiC1E"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export class Decisions {
|
|
2
|
-
constructor(http) {
|
|
3
|
-
this.http = http;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Verify whether an AI decision is permitted under a governance artifact.
|
|
7
|
-
*
|
|
8
|
-
* Public demo artifacts (pub_*) work without an API key.
|
|
9
|
-
* Custom artifacts require a valid API key.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* const result = await nomos.decisions.verify({
|
|
13
|
-
* artifact_id: 'pub_lending_v1',
|
|
14
|
-
* decision_context: { credit_score: 720, loan_amount: 50000 },
|
|
15
|
-
* });
|
|
16
|
-
*
|
|
17
|
-
* if (!result.allowed) {
|
|
18
|
-
* throw new Error(`Decision blocked: ${result.verdict_description}`);
|
|
19
|
-
* }
|
|
20
|
-
*/
|
|
21
|
-
async verify(params) {
|
|
22
|
-
const { artifact_id, decision_context, proposed_decision, correlation_id } = params;
|
|
23
|
-
// Public artifacts (pub_*) use the open /verify endpoint — no API key required
|
|
24
|
-
const isPublic = artifact_id.startsWith('pub_');
|
|
25
|
-
let raw;
|
|
26
|
-
if (isPublic) {
|
|
27
|
-
raw = await this.http.post('/api/v1/verify', {
|
|
28
|
-
artifact_id,
|
|
29
|
-
decision: proposed_decision ?? 'evaluate',
|
|
30
|
-
inputs: decision_context,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
raw = await this.http.post('/api/v1/verify-decision', {
|
|
35
|
-
artifact_id,
|
|
36
|
-
decision_context,
|
|
37
|
-
proposed_decision,
|
|
38
|
-
correlation_id: correlation_id ?? crypto.randomUUID(),
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
allowed: raw.allowed ?? false,
|
|
43
|
-
verdict: raw.outcome ?? raw.verdict ?? 'pending_human_review',
|
|
44
|
-
verdict_description: raw.verdict_description ?? '',
|
|
45
|
-
rule_reference: raw.rule_reference ?? raw.rule_applied,
|
|
46
|
-
audit_record: raw.audit_record ?? raw.audit_hash,
|
|
47
|
-
artifact_id: raw.artifact_id ?? artifact_id,
|
|
48
|
-
execution_id: raw.execution_id,
|
|
49
|
-
decided_at: raw.decided_at ?? raw.evaluated_at ?? new Date().toISOString(),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=decisions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decisions.js","sourceRoot":"","sources":["../../src/resources/decisions.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,SAAS;IACpB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,MAAM,CAAC,MAA4B;QACvC,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;QAEpF,+EAA+E;QAC/E,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,GAAQ,CAAC;QAEb,IAAI,QAAQ,EAAE,CAAC;YACb,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAM,gBAAgB,EAAE;gBAChD,WAAW;gBACX,QAAQ,EAAE,iBAAiB,IAAI,UAAU;gBACzC,MAAM,EAAI,gBAAgB;aAC3B,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAM,yBAAyB,EAAE;gBACzD,WAAW;gBACX,gBAAgB;gBAChB,iBAAiB;gBACjB,cAAc,EAAE,cAAc,IAAI,MAAM,CAAC,UAAU,EAAE;aACtD,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,OAAO,EAAc,GAAG,CAAC,OAAO,IAAI,KAAK;YACzC,OAAO,EAAc,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,IAAI,sBAAsB;YACzE,mBAAmB,EAAE,GAAG,CAAC,mBAAmB,IAAI,EAAE;YAClD,cAAc,EAAO,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,YAAY;YAC3D,YAAY,EAAS,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,UAAU;YACvD,WAAW,EAAU,GAAG,CAAC,WAAW,IAAI,WAAW;YACnD,YAAY,EAAS,GAAG,CAAC,YAAY;YACrC,UAAU,EAAW,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,YAAY,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { HttpClient } from '../http-client.js';
|
|
2
|
-
import type { GenerateGovernanceParams, GenerateGovernanceResult, DetectContradictionsParams, DetectContradictionsResult } from '../types.js';
|
|
3
|
-
export declare class Governance {
|
|
4
|
-
private readonly http;
|
|
5
|
-
constructor(http: HttpClient);
|
|
6
|
-
/**
|
|
7
|
-
* Generate a sealed .nomos governance artifact from policy documents
|
|
8
|
-
* and optional historical decision logs.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const artifact = await nomos.governance.generate({
|
|
12
|
-
* policies: [policyText],
|
|
13
|
-
* decision_logs: historicalRows,
|
|
14
|
-
* domain: 'loan_approval',
|
|
15
|
-
* });
|
|
16
|
-
* console.log(artifact.ari_score, artifact.seal_hash);
|
|
17
|
-
*/
|
|
18
|
-
generate(params: GenerateGovernanceParams): Promise<GenerateGovernanceResult>;
|
|
19
|
-
/**
|
|
20
|
-
* Detect contradictions and conflicts in a rule set before sealing.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* const report = await nomos.governance.detectContradictions({ rules });
|
|
24
|
-
* if (!report.clean) {
|
|
25
|
-
* console.log(report.contradictions);
|
|
26
|
-
* }
|
|
27
|
-
*/
|
|
28
|
-
detectContradictions(params: DetectContradictionsParams): Promise<DetectContradictionsResult>;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=governance.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"governance.d.ts","sourceRoot":"","sources":["../../src/resources/governance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,aAAa,CAAC;AAErB,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;OAWG;IACG,QAAQ,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAInF;;;;;;;;OAQG;IACG,oBAAoB,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,0BAA0B,CAAC;CAGpG"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export class Governance {
|
|
2
|
-
constructor(http) {
|
|
3
|
-
this.http = http;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Generate a sealed .nomos governance artifact from policy documents
|
|
7
|
-
* and optional historical decision logs.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* const artifact = await nomos.governance.generate({
|
|
11
|
-
* policies: [policyText],
|
|
12
|
-
* decision_logs: historicalRows,
|
|
13
|
-
* domain: 'loan_approval',
|
|
14
|
-
* });
|
|
15
|
-
* console.log(artifact.ari_score, artifact.seal_hash);
|
|
16
|
-
*/
|
|
17
|
-
async generate(params) {
|
|
18
|
-
return this.http.post('/api/v1/generate-governance', params);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Detect contradictions and conflicts in a rule set before sealing.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* const report = await nomos.governance.detectContradictions({ rules });
|
|
25
|
-
* if (!report.clean) {
|
|
26
|
-
* console.log(report.contradictions);
|
|
27
|
-
* }
|
|
28
|
-
*/
|
|
29
|
-
async detectContradictions(params) {
|
|
30
|
-
return this.http.post('/api/v1/detect-contradictions', params);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=governance.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"governance.js","sourceRoot":"","sources":["../../src/resources/governance.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,UAAU;IACrB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,QAAQ,CAAC,MAAgC;QAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAA2B,6BAA6B,EAAE,MAAM,CAAC,CAAC;IACzF,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,oBAAoB,CAAC,MAAkC;QAC3D,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAA6B,+BAA+B,EAAE,MAAM,CAAC,CAAC;IAC7F,CAAC;CACF"}
|