@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
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @coderifts/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Agent Governance SDK for the [CodeRifts](https://coderifts.com) API. Validate API changes before tool invocations in AI agent infrastructure (LangChain, AutoGen, Copilot, Claude, Grok, etc.).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @coderifts/sdk
|
|
@@ -10,76 +10,143 @@ npm install @coderifts/sdk
|
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
|
-
```
|
|
13
|
+
```typescript
|
|
14
14
|
import { CodeRifts } from '@coderifts/sdk';
|
|
15
15
|
|
|
16
16
|
const client = new CodeRifts({ apiKey: 'cr_live_...' });
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const result = await client.preflightCheck({
|
|
19
|
+
tool_name: 'get_refund_status',
|
|
20
20
|
old_spec: oldYaml,
|
|
21
21
|
new_spec: newYaml,
|
|
22
22
|
});
|
|
23
|
-
console.log(diff.breaking_changes_count, diff.risk_level);
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
if (!result.safe) {
|
|
25
|
+
console.error('Blocked:', result.decision, result.reflex_triggers);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Methods
|
|
31
|
+
|
|
32
|
+
### `preflightCheck(options)`
|
|
33
|
+
|
|
34
|
+
Check whether it is safe to proceed with a tool invocation.
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
const result = await client.preflightCheck({
|
|
38
|
+
tool_name: 'get_refund_status',
|
|
39
|
+
old_spec: '...',
|
|
40
|
+
new_spec: '...',
|
|
41
|
+
});
|
|
42
|
+
// result.decision: 'BLOCK' | 'REQUIRE_APPROVAL' | 'WARN' | 'ALLOW'
|
|
43
|
+
// result.omega_api: number
|
|
44
|
+
// result.safe: boolean
|
|
45
|
+
// result.reflex_triggers: Array<{ rule: string; decision: string }>
|
|
46
|
+
// result.affected_tools: Array<{ tool_name: string; status: string }>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### `diff(options)`
|
|
50
|
+
|
|
51
|
+
Full analysis of two OpenAPI specs.
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const result = await client.diff({
|
|
55
|
+
before: '...',
|
|
56
|
+
after: '...',
|
|
57
|
+
});
|
|
58
|
+
// result.omega_decision: string
|
|
59
|
+
// result.risk_score: number
|
|
60
|
+
// result.breaking_changes: BreakingChange[]
|
|
61
|
+
// result.should_block: boolean
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### `explainDecision(options)`
|
|
65
|
+
|
|
66
|
+
Human-readable explanation of why a decision was made.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const explanation = await client.explainDecision({
|
|
70
|
+
omega_api: 43.95,
|
|
71
|
+
decision: 'BLOCK',
|
|
72
|
+
reflex_triggers: [...],
|
|
29
73
|
});
|
|
30
|
-
|
|
74
|
+
// explanation.summary: string
|
|
75
|
+
// explanation.components: Array<{ name: string; value: number; description: string }>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### `howToUnblock(options)`
|
|
79
|
+
|
|
80
|
+
Actionable steps to resolve a BLOCK decision.
|
|
31
81
|
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
82
|
+
```typescript
|
|
83
|
+
const steps = await client.howToUnblock({
|
|
84
|
+
decision: 'BLOCK',
|
|
85
|
+
breaking_changes: [...],
|
|
86
|
+
detected_patterns: [...],
|
|
36
87
|
});
|
|
37
|
-
|
|
88
|
+
// steps.actions: Array<{ step: number; description: string; code_example?: string }>
|
|
38
89
|
```
|
|
39
90
|
|
|
40
|
-
|
|
91
|
+
### `scoreMcp(manifest)`
|
|
92
|
+
|
|
93
|
+
Score an MCP manifest for agent safety.
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const score = await client.scoreMcp({
|
|
97
|
+
manifest: { tools: [...] },
|
|
98
|
+
});
|
|
99
|
+
// score.overall_score: number (0-100)
|
|
100
|
+
// score.band: 'STRONG' | 'GOOD' | 'NEEDS_WORK' | 'POOR' | 'CRITICAL'
|
|
101
|
+
```
|
|
41
102
|
|
|
42
|
-
### `
|
|
103
|
+
### `getLedger(options)`
|
|
43
104
|
|
|
44
|
-
|
|
45
|
-
|---|---|---|---|
|
|
46
|
-
| `apiKey` | `string` | *required* | Your API key (`cr_live_...` or `cr_test_...`) |
|
|
47
|
-
| `baseUrl` | `string` | `https://app.coderifts.com` | API base URL |
|
|
48
|
-
| `timeout` | `number` | `30000` | Request timeout in ms |
|
|
105
|
+
Query compliance ledger entries.
|
|
49
106
|
|
|
50
|
-
|
|
107
|
+
```typescript
|
|
108
|
+
const ledger = await client.getLedger({
|
|
109
|
+
repo: 'owner/repo',
|
|
110
|
+
decision: 'BLOCK',
|
|
111
|
+
limit: 10,
|
|
112
|
+
});
|
|
113
|
+
// ledger.entries: LedgerEntry[]
|
|
114
|
+
// ledger.total: number
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### `simulatePolicy(options)`
|
|
118
|
+
|
|
119
|
+
Test a YAML policy against two OpenAPI specs.
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
const result = await client.simulatePolicy({
|
|
123
|
+
policy_yaml: '...',
|
|
124
|
+
old_spec: '...',
|
|
125
|
+
new_spec: '...',
|
|
126
|
+
});
|
|
127
|
+
// result.effective_action: string
|
|
128
|
+
// result.matched_rules: MatchedRule[]
|
|
129
|
+
```
|
|
51
130
|
|
|
52
|
-
|
|
53
|
-
|---|---|---|
|
|
54
|
-
| `diff(req)` | Compare two OpenAPI specs | Yes |
|
|
55
|
-
| `agentReadinessScore(req)` | Score a spec for agent readiness | Yes |
|
|
56
|
-
| `scoreMcp(url)` | Score an MCP manifest by URL | No |
|
|
57
|
-
| `stability(req)` | Get API stability analytics | Yes |
|
|
58
|
-
| `agentPreflight(req)` | Generate tool schemas from a spec | Yes |
|
|
131
|
+
## Error Handling
|
|
59
132
|
|
|
60
|
-
|
|
133
|
+
All methods throw a typed `CodeRiftsError` on non-2xx responses:
|
|
61
134
|
|
|
62
|
-
```
|
|
63
|
-
import {
|
|
135
|
+
```typescript
|
|
136
|
+
import { CodeRifts, CodeRiftsError } from '@coderifts/sdk';
|
|
64
137
|
|
|
65
138
|
try {
|
|
66
|
-
await client.
|
|
139
|
+
const result = await client.preflightCheck({ ... });
|
|
67
140
|
} catch (err) {
|
|
68
|
-
if (err instanceof
|
|
69
|
-
console.
|
|
70
|
-
} else if (err instanceof AuthError) {
|
|
71
|
-
console.log('Invalid API key');
|
|
72
|
-
} else if (err instanceof TimeoutError) {
|
|
73
|
-
console.log('Request timed out');
|
|
74
|
-
} else if (err instanceof ApiError) {
|
|
75
|
-
console.log(err.status, err.code, err.body);
|
|
141
|
+
if (err instanceof CodeRiftsError) {
|
|
142
|
+
console.error(err.code, err.message);
|
|
76
143
|
}
|
|
77
144
|
}
|
|
78
145
|
```
|
|
79
146
|
|
|
80
|
-
##
|
|
147
|
+
## Documentation
|
|
81
148
|
|
|
82
|
-
|
|
149
|
+
Full API documentation: [https://coderifts.com/docs](https://coderifts.com/docs)
|
|
83
150
|
|
|
84
151
|
## License
|
|
85
152
|
|
|
@@ -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
|
+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"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodeRifts = void 0;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
const DEFAULT_BASE_URL = 'https://app.coderifts.com';
|
|
6
|
+
const DEFAULT_TIMEOUT = 30_000;
|
|
7
|
+
class CodeRifts {
|
|
8
|
+
apiKey;
|
|
9
|
+
baseUrl;
|
|
10
|
+
timeout;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
if (!options.apiKey) {
|
|
13
|
+
throw new Error('apiKey is required');
|
|
14
|
+
}
|
|
15
|
+
this.apiKey = options.apiKey;
|
|
16
|
+
this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
17
|
+
this.timeout = options.timeout || DEFAULT_TIMEOUT;
|
|
18
|
+
}
|
|
19
|
+
// ─── Internal HTTP helper ──────────────────────────────────────────────
|
|
20
|
+
async request(method, path, body) {
|
|
21
|
+
const url = `${this.baseUrl}${path}`;
|
|
22
|
+
const controller = new AbortController();
|
|
23
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
24
|
+
try {
|
|
25
|
+
const res = await fetch(url, {
|
|
26
|
+
method,
|
|
27
|
+
headers: {
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
30
|
+
},
|
|
31
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
32
|
+
signal: controller.signal,
|
|
33
|
+
});
|
|
34
|
+
const json = (await res.json());
|
|
35
|
+
if (!res.ok) {
|
|
36
|
+
const errorBody = {
|
|
37
|
+
error: json.error || 'unknown',
|
|
38
|
+
message: json.message || res.statusText,
|
|
39
|
+
};
|
|
40
|
+
if (res.status === 401)
|
|
41
|
+
throw new errors_1.AuthError(errorBody);
|
|
42
|
+
if (res.status === 429)
|
|
43
|
+
throw new errors_1.RateLimitError(errorBody);
|
|
44
|
+
throw new errors_1.ApiError(res.status, errorBody);
|
|
45
|
+
}
|
|
46
|
+
return json;
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if (err instanceof errors_1.ApiError)
|
|
50
|
+
throw err;
|
|
51
|
+
if (err.name === 'AbortError') {
|
|
52
|
+
throw new errors_1.TimeoutError(this.timeout);
|
|
53
|
+
}
|
|
54
|
+
throw err;
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
clearTimeout(timer);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// ─── 1. preflightCheck ─────────────────────────────────────────────────
|
|
61
|
+
/**
|
|
62
|
+
* Check whether it is safe to proceed with a tool invocation.
|
|
63
|
+
*
|
|
64
|
+
* Accepts `old_spec` / `new_spec` (OpenAPI YAML strings) and a `tool_name`.
|
|
65
|
+
* The SDK converts the specs to MCP tool arrays and calls POST /api/v1/agent/preflight.
|
|
66
|
+
*/
|
|
67
|
+
async preflightCheck(req) {
|
|
68
|
+
// The backend expects tools_before / tools_after arrays.
|
|
69
|
+
// We wrap the raw specs as single-tool arrays so the caller can pass plain YAML.
|
|
70
|
+
const toolsBefore = [
|
|
71
|
+
{
|
|
72
|
+
name: req.tool_name,
|
|
73
|
+
description: `Tool: ${req.tool_name}`,
|
|
74
|
+
inputSchema: { type: 'object', 'x-raw-spec': req.old_spec },
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
const toolsAfter = [
|
|
78
|
+
{
|
|
79
|
+
name: req.tool_name,
|
|
80
|
+
description: `Tool: ${req.tool_name}`,
|
|
81
|
+
inputSchema: { type: 'object', 'x-raw-spec': req.new_spec },
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
const raw = await this.request('POST', '/api/v1/agent/preflight', { tools_before: toolsBefore, tools_after: toolsAfter });
|
|
85
|
+
const decision = raw.decision || 'ALLOW';
|
|
86
|
+
return {
|
|
87
|
+
decision,
|
|
88
|
+
omega_api: raw.omega_api ?? 0,
|
|
89
|
+
safe: decision === 'ALLOW' || decision === 'WARN',
|
|
90
|
+
reflex_triggers: raw.reflex_triggers || [],
|
|
91
|
+
affected_tools: raw.affected_tools || [],
|
|
92
|
+
confidence_score: raw.confidence_score,
|
|
93
|
+
reflex_override: raw.reflex_override,
|
|
94
|
+
omega_components: raw.omega_components,
|
|
95
|
+
breaking_changes: raw.breaking_changes,
|
|
96
|
+
stats: raw.stats,
|
|
97
|
+
mitigation_available: raw.mitigation_available,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// ─── 2. diff ───────────────────────────────────────────────────────────
|
|
101
|
+
/**
|
|
102
|
+
* Full analysis of two OpenAPI specs.
|
|
103
|
+
*/
|
|
104
|
+
async diff(req) {
|
|
105
|
+
return this.request('POST', '/api/v1/diff', req);
|
|
106
|
+
}
|
|
107
|
+
// ─── 3. explainDecision ────────────────────────────────────────────────
|
|
108
|
+
/**
|
|
109
|
+
* Returns a human-readable explanation of why a decision was made.
|
|
110
|
+
*
|
|
111
|
+
* Computed client-side from the omega components and reflex triggers.
|
|
112
|
+
*/
|
|
113
|
+
async explainDecision(req) {
|
|
114
|
+
const components = [];
|
|
115
|
+
if (req.omega_components) {
|
|
116
|
+
for (const [name, value] of Object.entries(req.omega_components)) {
|
|
117
|
+
if (typeof value === 'number') {
|
|
118
|
+
components.push({
|
|
119
|
+
name,
|
|
120
|
+
value,
|
|
121
|
+
description: describeComponent(name, value),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const triggers = req.reflex_triggers || [];
|
|
127
|
+
let summary = `Decision: ${req.decision} (Ω_API = ${req.omega_api}).`;
|
|
128
|
+
if (triggers.length > 0) {
|
|
129
|
+
summary += ` ${triggers.length} reflex rule(s) triggered.`;
|
|
130
|
+
}
|
|
131
|
+
if (req.decision === 'BLOCK') {
|
|
132
|
+
summary += ' This change is blocked due to high risk.';
|
|
133
|
+
}
|
|
134
|
+
else if (req.decision === 'REQUIRE_APPROVAL') {
|
|
135
|
+
summary += ' This change requires manual approval before merging.';
|
|
136
|
+
}
|
|
137
|
+
else if (req.decision === 'WARN') {
|
|
138
|
+
summary += ' This change has warnings but can proceed.';
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
summary += ' This change is safe to proceed.';
|
|
142
|
+
}
|
|
143
|
+
return { summary, components };
|
|
144
|
+
}
|
|
145
|
+
// ─── 4. howToUnblock ───────────────────────────────────────────────────
|
|
146
|
+
/**
|
|
147
|
+
* Returns actionable steps to resolve a BLOCK decision.
|
|
148
|
+
*
|
|
149
|
+
* Computed client-side from breaking changes and detected patterns.
|
|
150
|
+
*/
|
|
151
|
+
async howToUnblock(req) {
|
|
152
|
+
const actions = [];
|
|
153
|
+
let step = 1;
|
|
154
|
+
if (req.decision !== 'BLOCK') {
|
|
155
|
+
actions.push({
|
|
156
|
+
step: step++,
|
|
157
|
+
description: `Current decision is "${req.decision}" — no unblock needed.`,
|
|
158
|
+
});
|
|
159
|
+
return { actions };
|
|
160
|
+
}
|
|
161
|
+
const bcs = req.breaking_changes || [];
|
|
162
|
+
if (bcs.length > 0) {
|
|
163
|
+
actions.push({
|
|
164
|
+
step: step++,
|
|
165
|
+
description: `Fix ${bcs.length} breaking change(s) in your spec.`,
|
|
166
|
+
code_example: bcs
|
|
167
|
+
.slice(0, 3)
|
|
168
|
+
.map((bc) => `# ${bc.type} at ${bc.path}: ${bc.description}`)
|
|
169
|
+
.join('\n'),
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
const triggers = req.reflex_triggers || [];
|
|
173
|
+
for (const trigger of triggers) {
|
|
174
|
+
actions.push({
|
|
175
|
+
step: step++,
|
|
176
|
+
description: `Resolve reflex rule: ${trigger.rule}`,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
actions.push({
|
|
180
|
+
step: step++,
|
|
181
|
+
description: 'Request a manual override via POST /api/v1/ledger/:id/override if this is an emergency.',
|
|
182
|
+
});
|
|
183
|
+
return { actions };
|
|
184
|
+
}
|
|
185
|
+
// ─── 5. scoreMcp ──────────────────────────────────────────────────────
|
|
186
|
+
/**
|
|
187
|
+
* Score an MCP manifest for agent safety.
|
|
188
|
+
*/
|
|
189
|
+
async scoreMcp(req) {
|
|
190
|
+
return this.request('POST', '/api/v1/agent-readiness-score', {
|
|
191
|
+
spec: req.manifest,
|
|
192
|
+
spec_type: 'mcp',
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
// ─── 6. getLedger ─────────────────────────────────────────────────────
|
|
196
|
+
/**
|
|
197
|
+
* Query compliance ledger entries.
|
|
198
|
+
*/
|
|
199
|
+
async getLedger(req = {}) {
|
|
200
|
+
const params = new URLSearchParams();
|
|
201
|
+
if (req.repo)
|
|
202
|
+
params.set('repo', req.repo);
|
|
203
|
+
if (req.decision)
|
|
204
|
+
params.set('decision', req.decision);
|
|
205
|
+
if (req.from)
|
|
206
|
+
params.set('from', req.from);
|
|
207
|
+
if (req.to)
|
|
208
|
+
params.set('to', req.to);
|
|
209
|
+
if (req.limit)
|
|
210
|
+
params.set('limit', String(req.limit));
|
|
211
|
+
const qs = params.toString();
|
|
212
|
+
const path = `/api/v1/ledger${qs ? `?${qs}` : ''}`;
|
|
213
|
+
return this.request('GET', path);
|
|
214
|
+
}
|
|
215
|
+
// ─── 7. simulatePolicy ───────────────────────────────────────────────
|
|
216
|
+
/**
|
|
217
|
+
* Test a YAML policy against two OpenAPI specs.
|
|
218
|
+
*/
|
|
219
|
+
async simulatePolicy(req) {
|
|
220
|
+
return this.request('POST', '/api/v1/policy-simulator', req);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
exports.CodeRifts = CodeRifts;
|
|
224
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
225
|
+
function describeComponent(name, value) {
|
|
226
|
+
const descriptions = {
|
|
227
|
+
S_contract: 'Contract severity score — measures how severe the breaking changes are',
|
|
228
|
+
P_break: 'Break probability — likelihood that downstream consumers will break',
|
|
229
|
+
S_blast_eff: 'Blast radius — how many consumers are affected',
|
|
230
|
+
S_agent: 'Agent safety score — risk to AI agent tool invocations',
|
|
231
|
+
S_runtime: 'Runtime impact — risk of runtime failures',
|
|
232
|
+
ECI: 'Ecosystem coupling index — how tightly coupled the API is',
|
|
233
|
+
M_eff: 'Migration effort — estimated effort to migrate consumers',
|
|
234
|
+
D_contract: 'Contract distance — semantic distance between old and new contracts',
|
|
235
|
+
confidence_score: 'Confidence in the analysis result',
|
|
236
|
+
};
|
|
237
|
+
return descriptions[name] || `${name} = ${value}`;
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAoBA,qCAA6E;AAE7E,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AACrD,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B,MAAa,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,CAAC,GA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AAC,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;AAlPD,8BAkPC;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"}
|
|
@@ -6,7 +6,8 @@ import type { ApiErrorBody } from './types';
|
|
|
6
6
|
* Base error for all CodeRifts API errors.
|
|
7
7
|
*/
|
|
8
8
|
export declare class CodeRiftsError extends Error {
|
|
9
|
-
|
|
9
|
+
readonly code: string;
|
|
10
|
+
constructor(message: string, code?: string);
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* Thrown when the API returns a non-2xx status code.
|
|
@@ -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"}
|
|
@@ -8,9 +8,11 @@ exports.AuthError = exports.RateLimitError = exports.TimeoutError = exports.ApiE
|
|
|
8
8
|
* Base error for all CodeRifts API errors.
|
|
9
9
|
*/
|
|
10
10
|
class CodeRiftsError extends Error {
|
|
11
|
-
|
|
11
|
+
code;
|
|
12
|
+
constructor(message, code = 'unknown') {
|
|
12
13
|
super(message);
|
|
13
14
|
this.name = 'CodeRiftsError';
|
|
15
|
+
this.code = code;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
exports.CodeRiftsError = CodeRiftsError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAIH;;GAEG;AACH,MAAa,cAAe,SAAQ,KAAK;IACvB,IAAI,CAAS;IAE7B,YAAY,OAAe,EAAE,IAAI,GAAG,SAAS;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AARD,wCAQC;AAED;;GAEG;AACH,MAAa,QAAS,SAAQ,cAAc;IAC1B,MAAM,CAAS;IACf,IAAI,CAAS;IACb,IAAI,CAAe;IAEnC,YAAY,MAAc,EAAE,IAAkB;QAC5C,KAAK,CAAC,IAAI,MAAM,KAAK,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAZD,4BAYC;AAED;;GAEG;AACH,MAAa,YAAa,SAAQ,cAAc;IAC9C,YAAY,SAAiB;QAC3B,KAAK,CAAC,2BAA2B,SAAS,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED;;GAEG;AACH,MAAa,cAAe,SAAQ,QAAQ;IAC1C,YAAY,IAAkB;QAC5B,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AALD,wCAKC;AAED;;GAEG;AACH,MAAa,SAAU,SAAQ,QAAQ;IACrC,YAAY,IAAkB;QAC5B,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AALD,8BAKC"}
|
|
@@ -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"}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* @coderifts/sdk
|
|
3
|
+
* @coderifts/sdk — Agent Governance SDK
|
|
4
4
|
*
|
|
5
|
-
* TypeScript
|
|
5
|
+
* TypeScript/JavaScript SDK for the CodeRifts API.
|
|
6
|
+
* Validates API changes before tool invocations.
|
|
6
7
|
*
|
|
7
8
|
* @example
|
|
8
9
|
* ```ts
|
|
9
10
|
* import { CodeRifts } from '@coderifts/sdk';
|
|
10
11
|
*
|
|
11
12
|
* const client = new CodeRifts({ apiKey: 'cr_live_...' });
|
|
12
|
-
* const result = await client.diff({
|
|
13
|
+
* const result = await client.diff({ before: oldSpec, after: newSpec });
|
|
13
14
|
* ```
|
|
14
15
|
*/
|
|
15
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
17
|
+
exports.AuthError = exports.RateLimitError = exports.TimeoutError = exports.ApiError = exports.CodeRiftsError = exports.CodeRifts = void 0;
|
|
17
18
|
var client_1 = require("./client");
|
|
18
19
|
Object.defineProperty(exports, "CodeRifts", { enumerable: true, get: function () { return client_1.CodeRifts; } });
|
|
19
20
|
var errors_1 = require("./errors");
|
|
20
21
|
Object.defineProperty(exports, "CodeRiftsError", { enumerable: true, get: function () { return errors_1.CodeRiftsError; } });
|
|
21
22
|
Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return errors_1.ApiError; } });
|
|
22
|
-
Object.defineProperty(exports, "AuthError", { enumerable: true, get: function () { return errors_1.AuthError; } });
|
|
23
|
-
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_1.RateLimitError; } });
|
|
24
23
|
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_1.TimeoutError; } });
|
|
24
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_1.RateLimitError; } });
|
|
25
|
+
Object.defineProperty(exports, "AuthError", { enumerable: true, get: function () { return errors_1.AuthError; } });
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,mCAAqC;AAA5B,mGAAA,SAAS,OAAA;AAClB,mCAA6F;AAApF,wGAAA,cAAc,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,mGAAA,SAAS,OAAA"}
|