@coderifts/sdk 0.8.2 → 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/README.md +112 -45
- package/dist/cjs/client.d.ts +47 -0
- package/dist/cjs/client.d.ts.map +1 -0
- package/dist/cjs/client.js +239 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/{errors.d.ts → cjs/errors.d.ts} +2 -1
- package/dist/cjs/errors.d.ts.map +1 -0
- package/dist/{errors.js → cjs/errors.js} +3 -1
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.d.ts +18 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/{index.js → cjs/index.js} +7 -6
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.d.ts +172 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/client.d.ts +47 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +235 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/errors.d.ts +39 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +57 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.d.ts +18 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.d.ts +172 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +5 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +28 -8
- package/dist/client.d.ts +0 -70
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -159
- package/dist/client.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/index.d.ts +0 -17
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts +0 -119
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- /package/dist/{types.js → cjs/types.js} +0 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @coderifts/sdk — Type definitions
|
|
3
|
+
*/
|
|
4
|
+
export interface CodeRiftsOptions {
|
|
5
|
+
/** API key (cr_live_... or cr_test_...) */
|
|
6
|
+
apiKey: string;
|
|
7
|
+
/** Base URL override. Defaults to https://app.coderifts.com */
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
/** Request timeout in milliseconds. Defaults to 30000 */
|
|
10
|
+
timeout?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ApiErrorBody {
|
|
13
|
+
error: string;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PreflightCheckRequest {
|
|
17
|
+
tool_name: string;
|
|
18
|
+
old_spec: string;
|
|
19
|
+
new_spec: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ReflexTrigger {
|
|
22
|
+
rule: string;
|
|
23
|
+
decision: string;
|
|
24
|
+
}
|
|
25
|
+
export interface AffectedTool {
|
|
26
|
+
tool_name: string;
|
|
27
|
+
status: string;
|
|
28
|
+
changes?: string[];
|
|
29
|
+
patterns?: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface PreflightCheckResponse {
|
|
32
|
+
decision: string;
|
|
33
|
+
omega_api: number;
|
|
34
|
+
safe: boolean;
|
|
35
|
+
reflex_triggers: ReflexTrigger[];
|
|
36
|
+
affected_tools: AffectedTool[];
|
|
37
|
+
confidence_score?: number;
|
|
38
|
+
reflex_override?: boolean;
|
|
39
|
+
omega_components?: Record<string, unknown>;
|
|
40
|
+
breaking_changes?: unknown[];
|
|
41
|
+
stats?: Record<string, unknown>;
|
|
42
|
+
mitigation_available?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface DiffRequest {
|
|
45
|
+
before: string;
|
|
46
|
+
after: string;
|
|
47
|
+
branch_name?: string;
|
|
48
|
+
config?: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
export interface BreakingChange {
|
|
51
|
+
type: string;
|
|
52
|
+
path: string;
|
|
53
|
+
method?: string;
|
|
54
|
+
field?: string;
|
|
55
|
+
severity: string;
|
|
56
|
+
description: string;
|
|
57
|
+
}
|
|
58
|
+
export interface DiffResponse {
|
|
59
|
+
risk_score: number;
|
|
60
|
+
risk_level: string;
|
|
61
|
+
risk_dimensions?: Record<string, number>;
|
|
62
|
+
semver_suggestion: string;
|
|
63
|
+
breaking_changes: BreakingChange[];
|
|
64
|
+
non_breaking_changes: unknown[];
|
|
65
|
+
security_findings: unknown[];
|
|
66
|
+
changelog: Record<string, string[]>;
|
|
67
|
+
policy_violations: unknown[];
|
|
68
|
+
should_block: boolean;
|
|
69
|
+
detected_patterns: unknown[];
|
|
70
|
+
compatibility_suggestions: unknown[];
|
|
71
|
+
omega_api?: number;
|
|
72
|
+
omega_decision?: string;
|
|
73
|
+
reflex_override?: boolean;
|
|
74
|
+
reflex_triggers?: ReflexTrigger[];
|
|
75
|
+
confidence_score?: number;
|
|
76
|
+
omega_components?: Record<string, unknown>;
|
|
77
|
+
omega_audit?: Record<string, unknown>;
|
|
78
|
+
stats?: Record<string, unknown>;
|
|
79
|
+
pii_findings?: unknown[];
|
|
80
|
+
}
|
|
81
|
+
export interface ExplainDecisionRequest {
|
|
82
|
+
omega_api: number;
|
|
83
|
+
decision: string;
|
|
84
|
+
reflex_triggers?: ReflexTrigger[];
|
|
85
|
+
omega_components?: Record<string, unknown>;
|
|
86
|
+
}
|
|
87
|
+
export interface ExplainComponent {
|
|
88
|
+
name: string;
|
|
89
|
+
value: number;
|
|
90
|
+
description: string;
|
|
91
|
+
}
|
|
92
|
+
export interface ExplainDecisionResponse {
|
|
93
|
+
summary: string;
|
|
94
|
+
components: ExplainComponent[];
|
|
95
|
+
}
|
|
96
|
+
export interface HowToUnblockRequest {
|
|
97
|
+
decision: string;
|
|
98
|
+
breaking_changes?: BreakingChange[];
|
|
99
|
+
detected_patterns?: unknown[];
|
|
100
|
+
reflex_triggers?: ReflexTrigger[];
|
|
101
|
+
}
|
|
102
|
+
export interface UnblockAction {
|
|
103
|
+
step: number;
|
|
104
|
+
description: string;
|
|
105
|
+
code_example?: string;
|
|
106
|
+
}
|
|
107
|
+
export interface HowToUnblockResponse {
|
|
108
|
+
actions: UnblockAction[];
|
|
109
|
+
}
|
|
110
|
+
export interface ScoreMcpRequest {
|
|
111
|
+
manifest: {
|
|
112
|
+
tools: unknown[];
|
|
113
|
+
[key: string]: unknown;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export interface ScoreMcpResponse {
|
|
117
|
+
overall_score: number;
|
|
118
|
+
band: string;
|
|
119
|
+
label?: string;
|
|
120
|
+
signals?: unknown[];
|
|
121
|
+
tool_count?: number;
|
|
122
|
+
}
|
|
123
|
+
export interface GetLedgerRequest {
|
|
124
|
+
repo?: string;
|
|
125
|
+
decision?: string;
|
|
126
|
+
from?: string;
|
|
127
|
+
to?: string;
|
|
128
|
+
limit?: number;
|
|
129
|
+
}
|
|
130
|
+
export interface LedgerEntry {
|
|
131
|
+
id: number;
|
|
132
|
+
repo: string | null;
|
|
133
|
+
pr_number: number | null;
|
|
134
|
+
pr_author: string | null;
|
|
135
|
+
commit_sha: string | null;
|
|
136
|
+
decision: string;
|
|
137
|
+
omega_api: number | null;
|
|
138
|
+
risk_score: number | null;
|
|
139
|
+
risk_level: string | null;
|
|
140
|
+
breaking_changes: number;
|
|
141
|
+
reflex_override: boolean;
|
|
142
|
+
reflex_triggers: ReflexTrigger[];
|
|
143
|
+
policy_rule_id: string | null;
|
|
144
|
+
policy_action: string | null;
|
|
145
|
+
approved_by: string | null;
|
|
146
|
+
approved_at: string | null;
|
|
147
|
+
override_reason: string | null;
|
|
148
|
+
overridden_by: string | null;
|
|
149
|
+
overridden_at: string | null;
|
|
150
|
+
created_at: string;
|
|
151
|
+
}
|
|
152
|
+
export interface GetLedgerResponse {
|
|
153
|
+
repo: string | null;
|
|
154
|
+
total: number;
|
|
155
|
+
entries: LedgerEntry[];
|
|
156
|
+
}
|
|
157
|
+
export interface SimulatePolicyRequest {
|
|
158
|
+
policy_yaml: string;
|
|
159
|
+
old_spec: string;
|
|
160
|
+
new_spec: string;
|
|
161
|
+
}
|
|
162
|
+
export interface MatchedRule {
|
|
163
|
+
rule_id?: string;
|
|
164
|
+
action: string;
|
|
165
|
+
conditions?: Record<string, unknown>;
|
|
166
|
+
}
|
|
167
|
+
export interface SimulatePolicyResponse {
|
|
168
|
+
effective_action: string;
|
|
169
|
+
matched_rules: MatchedRule[];
|
|
170
|
+
[key: string]: unknown;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAID,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAID,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,S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9B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAID,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,WAAW,EAAE,CAAC;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @coderifts/sdk — Main client class
|
|
3
|
+
*/
|
|
4
|
+
import type { CodeRiftsOptions, DiffRequest, DiffResponse, PreflightCheckRequest, PreflightCheckResponse, ExplainDecisionRequest, ExplainDecisionResponse, HowToUnblockRequest, HowToUnblockResponse, ScoreMcpRequest, ScoreMcpResponse, GetLedgerRequest, GetLedgerResponse, SimulatePolicyRequest, SimulatePolicyResponse } from './types';
|
|
5
|
+
export declare class CodeRifts {
|
|
6
|
+
private readonly apiKey;
|
|
7
|
+
private readonly baseUrl;
|
|
8
|
+
private readonly timeout;
|
|
9
|
+
constructor(options: CodeRiftsOptions);
|
|
10
|
+
private request;
|
|
11
|
+
/**
|
|
12
|
+
* Check whether it is safe to proceed with a tool invocation.
|
|
13
|
+
*
|
|
14
|
+
* Accepts `old_spec` / `new_spec` (OpenAPI YAML strings) and a `tool_name`.
|
|
15
|
+
* The SDK converts the specs to MCP tool arrays and calls POST /api/v1/agent/preflight.
|
|
16
|
+
*/
|
|
17
|
+
preflightCheck(req: PreflightCheckRequest): Promise<PreflightCheckResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Full analysis of two OpenAPI specs.
|
|
20
|
+
*/
|
|
21
|
+
diff(req: DiffRequest): Promise<DiffResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Returns a human-readable explanation of why a decision was made.
|
|
24
|
+
*
|
|
25
|
+
* Computed client-side from the omega components and reflex triggers.
|
|
26
|
+
*/
|
|
27
|
+
explainDecision(req: ExplainDecisionRequest): Promise<ExplainDecisionResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns actionable steps to resolve a BLOCK decision.
|
|
30
|
+
*
|
|
31
|
+
* Computed client-side from breaking changes and detected patterns.
|
|
32
|
+
*/
|
|
33
|
+
howToUnblock(req: HowToUnblockRequest): Promise<HowToUnblockResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Score an MCP manifest for agent safety.
|
|
36
|
+
*/
|
|
37
|
+
scoreMcp(req: ScoreMcpRequest): Promise<ScoreMcpResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Query compliance ledger entries.
|
|
40
|
+
*/
|
|
41
|
+
getLedger(req?: GetLedgerRequest): Promise<GetLedgerResponse>;
|
|
42
|
+
/**
|
|
43
|
+
* Test a YAML policy against two OpenAPI specs.
|
|
44
|
+
*/
|
|
45
|
+
simulatePolicy(req: SimulatePolicyRequest): Promise<SimulatePolicyResponse>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAMjB,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,OAAO,EAAE,gBAAgB;YAWvB,OAAO;IA0CrB;;;;;OAKG;IACG,cAAc,CAAC,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA2CjF;;OAEG;IACG,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAMnD;;;;OAIG;IACG,eAAe,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAqCpF;;;;OAIG;IACG,YAAY,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA2C3E;;OAEG;IACG,QAAQ,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAS/D;;OAEG;IACG,SAAS,CAAC,GAAG,GAAE,gBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAevE;;OAEG;IACG,cAAc,CAAC,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAGlF"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { ApiError, AuthError, RateLimitError, TimeoutError } from './errors';
|
|
2
|
+
const DEFAULT_BASE_URL = 'https://app.coderifts.com';
|
|
3
|
+
const DEFAULT_TIMEOUT = 30_000;
|
|
4
|
+
export class CodeRifts {
|
|
5
|
+
apiKey;
|
|
6
|
+
baseUrl;
|
|
7
|
+
timeout;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
if (!options.apiKey) {
|
|
10
|
+
throw new Error('apiKey is required');
|
|
11
|
+
}
|
|
12
|
+
this.apiKey = options.apiKey;
|
|
13
|
+
this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
14
|
+
this.timeout = options.timeout || DEFAULT_TIMEOUT;
|
|
15
|
+
}
|
|
16
|
+
// ─── Internal HTTP helper ──────────────────────────────────────────────
|
|
17
|
+
async request(method, path, body) {
|
|
18
|
+
const url = `${this.baseUrl}${path}`;
|
|
19
|
+
const controller = new AbortController();
|
|
20
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
21
|
+
try {
|
|
22
|
+
const res = await fetch(url, {
|
|
23
|
+
method,
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
27
|
+
},
|
|
28
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
29
|
+
signal: controller.signal,
|
|
30
|
+
});
|
|
31
|
+
const json = (await res.json());
|
|
32
|
+
if (!res.ok) {
|
|
33
|
+
const errorBody = {
|
|
34
|
+
error: json.error || 'unknown',
|
|
35
|
+
message: json.message || res.statusText,
|
|
36
|
+
};
|
|
37
|
+
if (res.status === 401)
|
|
38
|
+
throw new AuthError(errorBody);
|
|
39
|
+
if (res.status === 429)
|
|
40
|
+
throw new RateLimitError(errorBody);
|
|
41
|
+
throw new ApiError(res.status, errorBody);
|
|
42
|
+
}
|
|
43
|
+
return json;
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
if (err instanceof ApiError)
|
|
47
|
+
throw err;
|
|
48
|
+
if (err.name === 'AbortError') {
|
|
49
|
+
throw new TimeoutError(this.timeout);
|
|
50
|
+
}
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
clearTimeout(timer);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// ─── 1. preflightCheck ─────────────────────────────────────────────────
|
|
58
|
+
/**
|
|
59
|
+
* Check whether it is safe to proceed with a tool invocation.
|
|
60
|
+
*
|
|
61
|
+
* Accepts `old_spec` / `new_spec` (OpenAPI YAML strings) and a `tool_name`.
|
|
62
|
+
* The SDK converts the specs to MCP tool arrays and calls POST /api/v1/agent/preflight.
|
|
63
|
+
*/
|
|
64
|
+
async preflightCheck(req) {
|
|
65
|
+
// The backend expects tools_before / tools_after arrays.
|
|
66
|
+
// We wrap the raw specs as single-tool arrays so the caller can pass plain YAML.
|
|
67
|
+
const toolsBefore = [
|
|
68
|
+
{
|
|
69
|
+
name: req.tool_name,
|
|
70
|
+
description: `Tool: ${req.tool_name}`,
|
|
71
|
+
inputSchema: { type: 'object', 'x-raw-spec': req.old_spec },
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
const toolsAfter = [
|
|
75
|
+
{
|
|
76
|
+
name: req.tool_name,
|
|
77
|
+
description: `Tool: ${req.tool_name}`,
|
|
78
|
+
inputSchema: { type: 'object', 'x-raw-spec': req.new_spec },
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
const raw = await this.request('POST', '/api/v1/agent/preflight', { tools_before: toolsBefore, tools_after: toolsAfter });
|
|
82
|
+
const decision = raw.decision || 'ALLOW';
|
|
83
|
+
return {
|
|
84
|
+
decision,
|
|
85
|
+
omega_api: raw.omega_api ?? 0,
|
|
86
|
+
safe: decision === 'ALLOW' || decision === 'WARN',
|
|
87
|
+
reflex_triggers: raw.reflex_triggers || [],
|
|
88
|
+
affected_tools: raw.affected_tools || [],
|
|
89
|
+
confidence_score: raw.confidence_score,
|
|
90
|
+
reflex_override: raw.reflex_override,
|
|
91
|
+
omega_components: raw.omega_components,
|
|
92
|
+
breaking_changes: raw.breaking_changes,
|
|
93
|
+
stats: raw.stats,
|
|
94
|
+
mitigation_available: raw.mitigation_available,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// ─── 2. diff ───────────────────────────────────────────────────────────
|
|
98
|
+
/**
|
|
99
|
+
* Full analysis of two OpenAPI specs.
|
|
100
|
+
*/
|
|
101
|
+
async diff(req) {
|
|
102
|
+
return this.request('POST', '/api/v1/diff', req);
|
|
103
|
+
}
|
|
104
|
+
// ─── 3. explainDecision ────────────────────────────────────────────────
|
|
105
|
+
/**
|
|
106
|
+
* Returns a human-readable explanation of why a decision was made.
|
|
107
|
+
*
|
|
108
|
+
* Computed client-side from the omega components and reflex triggers.
|
|
109
|
+
*/
|
|
110
|
+
async explainDecision(req) {
|
|
111
|
+
const components = [];
|
|
112
|
+
if (req.omega_components) {
|
|
113
|
+
for (const [name, value] of Object.entries(req.omega_components)) {
|
|
114
|
+
if (typeof value === 'number') {
|
|
115
|
+
components.push({
|
|
116
|
+
name,
|
|
117
|
+
value,
|
|
118
|
+
description: describeComponent(name, value),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const triggers = req.reflex_triggers || [];
|
|
124
|
+
let summary = `Decision: ${req.decision} (Ω_API = ${req.omega_api}).`;
|
|
125
|
+
if (triggers.length > 0) {
|
|
126
|
+
summary += ` ${triggers.length} reflex rule(s) triggered.`;
|
|
127
|
+
}
|
|
128
|
+
if (req.decision === 'BLOCK') {
|
|
129
|
+
summary += ' This change is blocked due to high risk.';
|
|
130
|
+
}
|
|
131
|
+
else if (req.decision === 'REQUIRE_APPROVAL') {
|
|
132
|
+
summary += ' This change requires manual approval before merging.';
|
|
133
|
+
}
|
|
134
|
+
else if (req.decision === 'WARN') {
|
|
135
|
+
summary += ' This change has warnings but can proceed.';
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
summary += ' This change is safe to proceed.';
|
|
139
|
+
}
|
|
140
|
+
return { summary, components };
|
|
141
|
+
}
|
|
142
|
+
// ─── 4. howToUnblock ───────────────────────────────────────────────────
|
|
143
|
+
/**
|
|
144
|
+
* Returns actionable steps to resolve a BLOCK decision.
|
|
145
|
+
*
|
|
146
|
+
* Computed client-side from breaking changes and detected patterns.
|
|
147
|
+
*/
|
|
148
|
+
async howToUnblock(req) {
|
|
149
|
+
const actions = [];
|
|
150
|
+
let step = 1;
|
|
151
|
+
if (req.decision !== 'BLOCK') {
|
|
152
|
+
actions.push({
|
|
153
|
+
step: step++,
|
|
154
|
+
description: `Current decision is "${req.decision}" — no unblock needed.`,
|
|
155
|
+
});
|
|
156
|
+
return { actions };
|
|
157
|
+
}
|
|
158
|
+
const bcs = req.breaking_changes || [];
|
|
159
|
+
if (bcs.length > 0) {
|
|
160
|
+
actions.push({
|
|
161
|
+
step: step++,
|
|
162
|
+
description: `Fix ${bcs.length} breaking change(s) in your spec.`,
|
|
163
|
+
code_example: bcs
|
|
164
|
+
.slice(0, 3)
|
|
165
|
+
.map((bc) => `# ${bc.type} at ${bc.path}: ${bc.description}`)
|
|
166
|
+
.join('\n'),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
const triggers = req.reflex_triggers || [];
|
|
170
|
+
for (const trigger of triggers) {
|
|
171
|
+
actions.push({
|
|
172
|
+
step: step++,
|
|
173
|
+
description: `Resolve reflex rule: ${trigger.rule}`,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
actions.push({
|
|
177
|
+
step: step++,
|
|
178
|
+
description: 'Request a manual override via POST /api/v1/ledger/:id/override if this is an emergency.',
|
|
179
|
+
});
|
|
180
|
+
return { actions };
|
|
181
|
+
}
|
|
182
|
+
// ─── 5. scoreMcp ──────────────────────────────────────────────────────
|
|
183
|
+
/**
|
|
184
|
+
* Score an MCP manifest for agent safety.
|
|
185
|
+
*/
|
|
186
|
+
async scoreMcp(req) {
|
|
187
|
+
return this.request('POST', '/api/v1/agent-readiness-score', {
|
|
188
|
+
spec: req.manifest,
|
|
189
|
+
spec_type: 'mcp',
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
// ─── 6. getLedger ─────────────────────────────────────────────────────
|
|
193
|
+
/**
|
|
194
|
+
* Query compliance ledger entries.
|
|
195
|
+
*/
|
|
196
|
+
async getLedger(req = {}) {
|
|
197
|
+
const params = new URLSearchParams();
|
|
198
|
+
if (req.repo)
|
|
199
|
+
params.set('repo', req.repo);
|
|
200
|
+
if (req.decision)
|
|
201
|
+
params.set('decision', req.decision);
|
|
202
|
+
if (req.from)
|
|
203
|
+
params.set('from', req.from);
|
|
204
|
+
if (req.to)
|
|
205
|
+
params.set('to', req.to);
|
|
206
|
+
if (req.limit)
|
|
207
|
+
params.set('limit', String(req.limit));
|
|
208
|
+
const qs = params.toString();
|
|
209
|
+
const path = `/api/v1/ledger${qs ? `?${qs}` : ''}`;
|
|
210
|
+
return this.request('GET', path);
|
|
211
|
+
}
|
|
212
|
+
// ─── 7. simulatePolicy ───────────────────────────────────────────────
|
|
213
|
+
/**
|
|
214
|
+
* Test a YAML policy against two OpenAPI specs.
|
|
215
|
+
*/
|
|
216
|
+
async simulatePolicy(req) {
|
|
217
|
+
return this.request('POST', '/api/v1/policy-simulator', req);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
221
|
+
function describeComponent(name, value) {
|
|
222
|
+
const descriptions = {
|
|
223
|
+
S_contract: 'Contract severity score — measures how severe the breaking changes are',
|
|
224
|
+
P_break: 'Break probability — likelihood that downstream consumers will break',
|
|
225
|
+
S_blast_eff: 'Blast radius — how many consumers are affected',
|
|
226
|
+
S_agent: 'Agent safety score — risk to AI agent tool invocations',
|
|
227
|
+
S_runtime: 'Runtime impact — risk of runtime failures',
|
|
228
|
+
ECI: 'Ecosystem coupling index — how tightly coupled the API is',
|
|
229
|
+
M_eff: 'Migration effort — estimated effort to migrate consumers',
|
|
230
|
+
D_contract: 'Contract distance — semantic distance between old and new contracts',
|
|
231
|
+
confidence_score: 'Confidence in the analysis result',
|
|
232
|
+
};
|
|
233
|
+
return descriptions[name] || `${name} = ${value}`;
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7E,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AACrD,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B,MAAM,OAAO,SAAS;IACH,MAAM,CAAS;IACf,OAAO,CAAS;IAChB,OAAO,CAAS;IAEjC,YAAY,OAAyB;QACnC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,eAAe,CAAC;IACpD,CAAC;IAED,0EAA0E;IAElE,KAAK,CAAC,OAAO,CAAI,MAAc,EAAE,IAAY,EAAE,IAAc;QACnE,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;QACrC,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,UAAU,CAA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AC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACnD,OAAO,IAAI,CAAC,OAAO,CAAoB,KAAK,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,wEAAwE;IAExE;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,GAA0B;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAyB,MAAM,EAAE,0BAA0B,EAAE,GAAG,CAAC,CAAC;IACvF,CAAC;CACF;AAED,gFAAgF;AAEhF,SAAS,iBAAiB,CAAC,IAAY,EAAE,KAAa;IACpD,MAAM,YAAY,GAA2B;QAC3C,UAAU,EAAE,wEAAwE;QACpF,OAAO,EAAE,qEAAqE;QAC9E,WAAW,EAAE,gDAAgD;QAC7D,OAAO,EAAE,wDAAwD;QACjE,SAAS,EAAE,2CAA2C;QACtD,GAAG,EAAE,2DAA2D;QAChE,KAAK,EAAE,0DAA0D;QACjE,UAAU,EAAE,qEAAqE;QACjF,gBAAgB,EAAE,mCAAmC;KACtD,CAAC;IACF,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,MAAM,KAAK,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @coderifts/sdk — Error classes
|
|
3
|
+
*/
|
|
4
|
+
import type { ApiErrorBody } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Base error for all CodeRifts API errors.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CodeRiftsError extends Error {
|
|
9
|
+
readonly code: string;
|
|
10
|
+
constructor(message: string, code?: string);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Thrown when the API returns a non-2xx status code.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ApiError extends CodeRiftsError {
|
|
16
|
+
readonly status: number;
|
|
17
|
+
readonly code: string;
|
|
18
|
+
readonly body: ApiErrorBody;
|
|
19
|
+
constructor(status: number, body: ApiErrorBody);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Thrown when the request times out.
|
|
23
|
+
*/
|
|
24
|
+
export declare class TimeoutError extends CodeRiftsError {
|
|
25
|
+
constructor(timeoutMs: number);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Thrown when rate limited (429).
|
|
29
|
+
*/
|
|
30
|
+
export declare class RateLimitError extends ApiError {
|
|
31
|
+
constructor(body: ApiErrorBody);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Thrown when authentication fails (401).
|
|
35
|
+
*/
|
|
36
|
+
export declare class AuthError extends ApiError {
|
|
37
|
+
constructor(body: ApiErrorBody);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,IAAI,SAAY;CAK9C;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,cAAc;IAC1C,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,IAAI,EAAE,YAAY,CAAC;gBAEvB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY;CAO/C;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,cAAc;gBAClC,SAAS,EAAE,MAAM;CAI9B;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,IAAI,EAAE,YAAY;CAI/B;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,QAAQ;gBACzB,IAAI,EAAE,YAAY;CAI/B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @coderifts/sdk — Error classes
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Base error for all CodeRifts API errors.
|
|
6
|
+
*/
|
|
7
|
+
export class CodeRiftsError extends Error {
|
|
8
|
+
code;
|
|
9
|
+
constructor(message, code = 'unknown') {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'CodeRiftsError';
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Thrown when the API returns a non-2xx status code.
|
|
17
|
+
*/
|
|
18
|
+
export class ApiError extends CodeRiftsError {
|
|
19
|
+
status;
|
|
20
|
+
code;
|
|
21
|
+
body;
|
|
22
|
+
constructor(status, body) {
|
|
23
|
+
super(`[${status}] ${body.error}: ${body.message}`);
|
|
24
|
+
this.name = 'ApiError';
|
|
25
|
+
this.status = status;
|
|
26
|
+
this.code = body.error;
|
|
27
|
+
this.body = body;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Thrown when the request times out.
|
|
32
|
+
*/
|
|
33
|
+
export class TimeoutError extends CodeRiftsError {
|
|
34
|
+
constructor(timeoutMs) {
|
|
35
|
+
super(`Request timed out after ${timeoutMs}ms`);
|
|
36
|
+
this.name = 'TimeoutError';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Thrown when rate limited (429).
|
|
41
|
+
*/
|
|
42
|
+
export class RateLimitError extends ApiError {
|
|
43
|
+
constructor(body) {
|
|
44
|
+
super(429, body);
|
|
45
|
+
this.name = 'RateLimitError';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Thrown when authentication fails (401).
|
|
50
|
+
*/
|
|
51
|
+
export class AuthError extends ApiError {
|
|
52
|
+
constructor(body) {
|
|
53
|
+
super(401, body);
|
|
54
|
+
this.name = 'AuthError';
|
|
55
|
+
}
|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,SAAQ,QAAQ;IACrC,YAAY,IAAkB;QAC5B,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @coderifts/sdk — Agent Governance SDK
|
|
3
|
+
*
|
|
4
|
+
* TypeScript/JavaScript SDK for the CodeRifts API.
|
|
5
|
+
* Validates API changes before tool invocations.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { CodeRifts } from '@coderifts/sdk';
|
|
10
|
+
*
|
|
11
|
+
* const client = new CodeRifts({ apiKey: 'cr_live_...' });
|
|
12
|
+
* const result = await client.diff({ before: oldSpec, after: newSpec });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export { CodeRifts } from './client';
|
|
16
|
+
export { CodeRiftsError, ApiError, TimeoutError, RateLimitError, AuthError } from './errors';
|
|
17
|
+
export type { CodeRiftsOptions, ApiErrorBody, PreflightCheckRequest, PreflightCheckResponse, ReflexTrigger, AffectedTool, DiffRequest, DiffResponse, BreakingChange, ExplainDecisionRequest, ExplainDecisionResponse, ExplainComponent, HowToUnblockRequest, HowToUnblockResponse, UnblockAction, ScoreMcpRequest, ScoreMcpResponse, GetLedgerRequest, GetLedgerResponse, LedgerEntry, SimulatePolicyRequest, SimulatePolicyResponse, MatchedRule, } from './types';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC7F,YAAY,EACV,gBAAgB,EAChB,YAAY,EAEZ,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,YAAY,EAEZ,WAAW,EACX,YAAY,EACZ,cAAc,EAEd,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAEhB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EAEb,eAAe,EACf,gBAAgB,EAEhB,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EAEX,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,GACZ,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @coderifts/sdk — Agent Governance SDK
|
|
3
|
+
*
|
|
4
|
+
* TypeScript/JavaScript SDK for the CodeRifts API.
|
|
5
|
+
* Validates API changes before tool invocations.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { CodeRifts } from '@coderifts/sdk';
|
|
10
|
+
*
|
|
11
|
+
* const client = new CodeRifts({ apiKey: 'cr_live_...' });
|
|
12
|
+
* const result = await client.diff({ before: oldSpec, after: newSpec });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export { CodeRifts } from './client';
|
|
16
|
+
export { CodeRiftsError, ApiError, TimeoutError, RateLimitError, AuthError } from './errors';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC"}
|