@auctra/sdk 0.1.2 → 0.2.1
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/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/README.md +39 -21
- package/dist/cjs/index.js +201 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/index.d.ts +234 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +196 -0
- package/package.json +30 -10
- package/src/index.ts +414 -0
- package/dist/index.d.ts +0 -66
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -87
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
- Add complete response types for agents, delegations, action requests, policies, audit events, and API keys.
|
|
6
|
+
- Add `getDelegation`, `createPolicy`, and `listApiKeys`.
|
|
7
|
+
- Honor `Retry-After`, preserve caller cancellation, and validate client options.
|
|
8
|
+
- Correct the REST example to use the API's snake_case contract.
|
|
9
|
+
- Add package-level integration tests and npm provenance metadata.
|
|
10
|
+
- Ship tested ESM and CommonJS entry points.
|
|
11
|
+
|
|
12
|
+
## 0.2.0
|
|
13
|
+
|
|
14
|
+
- Add bounded retries, request deadlines, idempotent evaluation, and structured API errors.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Auctra
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -16,6 +16,8 @@ Evaluate every agent action against delegated authority and org policies before
|
|
|
16
16
|
npm install @auctra/sdk
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
Both ESM (`import`) and CommonJS (`require`) entry points are included.
|
|
20
|
+
|
|
19
21
|
## Quick start
|
|
20
22
|
|
|
21
23
|
```typescript
|
|
@@ -23,13 +25,18 @@ import { Auctra } from "@auctra/sdk";
|
|
|
23
25
|
|
|
24
26
|
const auctra = new Auctra({
|
|
25
27
|
apiKey: process.env.AUCTRA_API_KEY!,
|
|
28
|
+
timeoutMs: 10_000,
|
|
29
|
+
maxRetries: 2,
|
|
26
30
|
});
|
|
27
31
|
|
|
28
|
-
const decision = await auctra.evaluateAction(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
32
|
+
const decision = await auctra.evaluateAction(
|
|
33
|
+
{
|
|
34
|
+
agentId: "your-agent-uuid",
|
|
35
|
+
actionType: "send_payment",
|
|
36
|
+
payload: { amount: 1200, currency: "USD" },
|
|
37
|
+
},
|
|
38
|
+
{ idempotencyKey: crypto.randomUUID() },
|
|
39
|
+
);
|
|
33
40
|
|
|
34
41
|
if (decision.decision === "allowed") {
|
|
35
42
|
// proceed with action
|
|
@@ -50,34 +57,45 @@ if (decision.decision === "allowed") {
|
|
|
50
57
|
|
|
51
58
|
## API
|
|
52
59
|
|
|
53
|
-
| Method
|
|
54
|
-
|
|
55
|
-
| `evaluateAction(input)`
|
|
56
|
-
| `listAgents()`
|
|
57
|
-
| `createAgent(input)`
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
60
|
+
| Method | Description |
|
|
61
|
+
| ------------------------------------------- | ------------------------------------------------- |
|
|
62
|
+
| `evaluateAction(input, options)` | Idempotently check authority before an agent acts |
|
|
63
|
+
| `listAgents()` | List registered agents |
|
|
64
|
+
| `createAgent(input)` | Register a new agent |
|
|
65
|
+
| `getAgent(id)` | Get one registered agent |
|
|
66
|
+
| `listDelegations()` | List authority delegations |
|
|
67
|
+
| `getDelegation(id)` | Get one authority delegation |
|
|
68
|
+
| `createDelegation(input)` | Grant bounded authority |
|
|
69
|
+
| `revokeDelegation(id)` | Revoke a delegation |
|
|
70
|
+
| `listActionRequests()` | List recent evaluations |
|
|
71
|
+
| `approveActionRequest(id, approverUserId)` | Approve as an accountable reviewer |
|
|
72
|
+
| `rejectActionRequest(id, approverUserId)` | Reject as an accountable reviewer |
|
|
73
|
+
| `escalateActionRequest(id, approverUserId)` | Escalate as an accountable reviewer |
|
|
74
|
+
| `listPolicies()` | List org policies |
|
|
75
|
+
| `createPolicy(input)` | Create an org policy |
|
|
76
|
+
| `listAuditEvents()` | List audit ledger events |
|
|
77
|
+
| `listApiKeys()` | List API key metadata |
|
|
67
78
|
|
|
68
79
|
## REST API (curl)
|
|
69
80
|
|
|
70
81
|
```bash
|
|
71
82
|
curl -X POST https://console.auctra.tech/v1/action-requests/evaluate \
|
|
72
83
|
-H "Authorization: Bearer YOUR_API_KEY" \
|
|
84
|
+
-H "Idempotency-Key: $(uuidgen)" \
|
|
73
85
|
-H "Content-Type: application/json" \
|
|
74
86
|
-d '{
|
|
75
|
-
"
|
|
76
|
-
"
|
|
87
|
+
"agent_id": "your-agent-uuid",
|
|
88
|
+
"action_type": "send_payment",
|
|
77
89
|
"payload": { "amount": 100, "currency": "USD" }
|
|
78
90
|
}'
|
|
79
91
|
```
|
|
80
92
|
|
|
93
|
+
The SDK applies bounded retries only to reads and idempotent evaluations. API failures throw
|
|
94
|
+
`AuctraApiError` with `status`, optional structured `details`, and the server `requestId`.
|
|
95
|
+
|
|
96
|
+
The machine-readable OpenAPI 3.1 contract is available at
|
|
97
|
+
`https://console.auctra.tech/v1/openapi.json`.
|
|
98
|
+
|
|
81
99
|
## License
|
|
82
100
|
|
|
83
101
|
MIT
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Auctra = exports.AuctraApiError = exports.AUCTRA_SDK_VERSION = void 0;
|
|
4
|
+
exports.AUCTRA_SDK_VERSION = "0.2.1";
|
|
5
|
+
class AuctraApiError extends Error {
|
|
6
|
+
status;
|
|
7
|
+
code;
|
|
8
|
+
details;
|
|
9
|
+
requestId;
|
|
10
|
+
constructor(message, options) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "AuctraApiError";
|
|
13
|
+
this.status = options.status;
|
|
14
|
+
this.code = options.code;
|
|
15
|
+
this.details = options.details;
|
|
16
|
+
this.requestId = options.requestId;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.AuctraApiError = AuctraApiError;
|
|
20
|
+
function retryDelay(response, attempt) {
|
|
21
|
+
const retryAfter = response?.headers.get("retry-after");
|
|
22
|
+
if (retryAfter) {
|
|
23
|
+
const seconds = Number(retryAfter);
|
|
24
|
+
if (Number.isFinite(seconds))
|
|
25
|
+
return Math.min(30_000, Math.max(0, seconds * 1_000));
|
|
26
|
+
const dateDelay = Date.parse(retryAfter) - Date.now();
|
|
27
|
+
if (Number.isFinite(dateDelay))
|
|
28
|
+
return Math.min(30_000, Math.max(0, dateDelay));
|
|
29
|
+
}
|
|
30
|
+
return Math.min(5_000, 150 * 2 ** attempt);
|
|
31
|
+
}
|
|
32
|
+
function wait(ms, signal) {
|
|
33
|
+
if (signal?.aborted)
|
|
34
|
+
return Promise.reject(signal.reason);
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
const timeout = setTimeout(resolve, ms);
|
|
37
|
+
signal?.addEventListener("abort", () => {
|
|
38
|
+
clearTimeout(timeout);
|
|
39
|
+
reject(signal.reason);
|
|
40
|
+
}, { once: true });
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
class Auctra {
|
|
44
|
+
apiKey;
|
|
45
|
+
baseUrl;
|
|
46
|
+
timeoutMs;
|
|
47
|
+
maxRetries;
|
|
48
|
+
fetchImpl;
|
|
49
|
+
constructor(options) {
|
|
50
|
+
if (!options.apiKey.trim())
|
|
51
|
+
throw new Error("apiKey is required");
|
|
52
|
+
if (options.timeoutMs !== undefined && options.timeoutMs <= 0) {
|
|
53
|
+
throw new Error("timeoutMs must be greater than zero");
|
|
54
|
+
}
|
|
55
|
+
if (options.maxRetries !== undefined &&
|
|
56
|
+
(!Number.isInteger(options.maxRetries) || options.maxRetries < 0)) {
|
|
57
|
+
throw new Error("maxRetries must be a non-negative integer");
|
|
58
|
+
}
|
|
59
|
+
this.apiKey = options.apiKey;
|
|
60
|
+
this.baseUrl = (options.baseUrl ?? "https://console.auctra.tech").replace(/\/$/, "");
|
|
61
|
+
this.timeoutMs = options.timeoutMs ?? 10_000;
|
|
62
|
+
this.maxRetries = options.maxRetries ?? 2;
|
|
63
|
+
this.fetchImpl = options.fetch ?? globalThis.fetch;
|
|
64
|
+
if (!this.fetchImpl)
|
|
65
|
+
throw new Error("A fetch implementation is required");
|
|
66
|
+
}
|
|
67
|
+
async request(method, path, body, options = {}) {
|
|
68
|
+
const retryableRequest = method === "GET" || Boolean(options.idempotencyKey);
|
|
69
|
+
let lastError;
|
|
70
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt += 1) {
|
|
71
|
+
if (options.signal?.aborted)
|
|
72
|
+
throw options.signal.reason;
|
|
73
|
+
const timeoutSignal = AbortSignal.timeout(this.timeoutMs);
|
|
74
|
+
const signal = options.signal
|
|
75
|
+
? AbortSignal.any([options.signal, timeoutSignal])
|
|
76
|
+
: timeoutSignal;
|
|
77
|
+
let response;
|
|
78
|
+
try {
|
|
79
|
+
response = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
80
|
+
method,
|
|
81
|
+
signal,
|
|
82
|
+
headers: {
|
|
83
|
+
...(body !== undefined ? { "content-type": "application/json" } : {}),
|
|
84
|
+
...(options.idempotencyKey ? { "idempotency-key": options.idempotencyKey } : {}),
|
|
85
|
+
authorization: `Bearer ${this.apiKey}`,
|
|
86
|
+
"x-auctra-sdk-version": exports.AUCTRA_SDK_VERSION,
|
|
87
|
+
},
|
|
88
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
89
|
+
});
|
|
90
|
+
const data = (await response.json().catch(() => ({})));
|
|
91
|
+
if (response.ok)
|
|
92
|
+
return data;
|
|
93
|
+
if (retryableRequest &&
|
|
94
|
+
(response.status === 429 || response.status >= 500) &&
|
|
95
|
+
attempt < this.maxRetries) {
|
|
96
|
+
await wait(retryDelay(response, attempt), options.signal);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
throw new AuctraApiError(typeof data.error === "string" ? data.error : `Auctra API error (${response.status})`, {
|
|
100
|
+
status: response.status,
|
|
101
|
+
code: typeof data.code === "string" ? data.code : undefined,
|
|
102
|
+
details: data.details,
|
|
103
|
+
requestId: response.headers.get("x-request-id") ?? undefined,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
lastError = error;
|
|
108
|
+
if (options.signal?.aborted)
|
|
109
|
+
throw options.signal.reason;
|
|
110
|
+
if (error instanceof AuctraApiError || !retryableRequest || attempt >= this.maxRetries) {
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
await wait(retryDelay(response, attempt), options.signal);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
throw lastError;
|
|
117
|
+
}
|
|
118
|
+
async evaluateAction(input, options = {}) {
|
|
119
|
+
const idempotencyKey = options.idempotencyKey ?? crypto.randomUUID();
|
|
120
|
+
return this.request("POST", "/v1/action-requests/evaluate", { agent_id: input.agentId, action_type: input.actionType, payload: input.payload ?? {} }, { ...options, idempotencyKey });
|
|
121
|
+
}
|
|
122
|
+
async listAgents() {
|
|
123
|
+
return this.request("GET", "/v1/agents");
|
|
124
|
+
}
|
|
125
|
+
async getAgent(agentId) {
|
|
126
|
+
return this.request("GET", `/v1/agents/${encodeURIComponent(agentId)}`);
|
|
127
|
+
}
|
|
128
|
+
async createAgent(input) {
|
|
129
|
+
return this.request("POST", "/v1/agents", {
|
|
130
|
+
name: input.name,
|
|
131
|
+
model_provider: input.modelProvider,
|
|
132
|
+
model_name: input.modelName,
|
|
133
|
+
description: input.description,
|
|
134
|
+
environment: input.environment,
|
|
135
|
+
authority_level: input.authorityLevel,
|
|
136
|
+
sponsor_user_id: input.sponsorUserId,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
async listDelegations() {
|
|
140
|
+
return this.request("GET", "/v1/delegations");
|
|
141
|
+
}
|
|
142
|
+
async getDelegation(delegationId) {
|
|
143
|
+
return this.request("GET", `/v1/delegations/${encodeURIComponent(delegationId)}`);
|
|
144
|
+
}
|
|
145
|
+
async createDelegation(input) {
|
|
146
|
+
return this.request("POST", "/v1/delegations", {
|
|
147
|
+
agent_id: input.agentId,
|
|
148
|
+
action_types: input.actionTypes,
|
|
149
|
+
valid_until: input.validUntil,
|
|
150
|
+
max_amount: input.maxAmount,
|
|
151
|
+
max_count: input.maxCount,
|
|
152
|
+
environment: input.environment,
|
|
153
|
+
currency: input.currency,
|
|
154
|
+
delegator_user_id: input.delegatorUserId,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
async revokeDelegation(delegationId) {
|
|
158
|
+
return this.request("POST", `/v1/delegations/${encodeURIComponent(delegationId)}/revoke`, {});
|
|
159
|
+
}
|
|
160
|
+
async listActionRequests() {
|
|
161
|
+
return this.request("GET", "/v1/action-requests");
|
|
162
|
+
}
|
|
163
|
+
async approveActionRequest(actionRequestId, approverUserId, reason) {
|
|
164
|
+
return this.resolveActionRequest(actionRequestId, "approve", approverUserId, reason);
|
|
165
|
+
}
|
|
166
|
+
async rejectActionRequest(actionRequestId, approverUserId, reason) {
|
|
167
|
+
return this.resolveActionRequest(actionRequestId, "reject", approverUserId, reason);
|
|
168
|
+
}
|
|
169
|
+
async escalateActionRequest(actionRequestId, approverUserId, reason) {
|
|
170
|
+
return this.resolveActionRequest(actionRequestId, "escalate", approverUserId, reason);
|
|
171
|
+
}
|
|
172
|
+
async resolveActionRequest(actionRequestId, action, approverUserId, reason) {
|
|
173
|
+
return this.request("POST", `/v1/action-requests/${encodeURIComponent(actionRequestId)}/${action}`, { reason, approver_user_id: approverUserId });
|
|
174
|
+
}
|
|
175
|
+
async listPolicies() {
|
|
176
|
+
return this.request("GET", "/v1/policies");
|
|
177
|
+
}
|
|
178
|
+
async createPolicy(input) {
|
|
179
|
+
return this.request("POST", "/v1/policies", {
|
|
180
|
+
name: input.name,
|
|
181
|
+
description: input.description,
|
|
182
|
+
policy_type: input.policyType,
|
|
183
|
+
status: input.status,
|
|
184
|
+
priority: input.priority,
|
|
185
|
+
action_type: input.actionType,
|
|
186
|
+
amount_greater_than: input.amountGreaterThan,
|
|
187
|
+
resource_sensitivity: input.resourceSensitivity,
|
|
188
|
+
external_recipient: input.externalRecipient,
|
|
189
|
+
environment: input.environment,
|
|
190
|
+
decision: input.decision,
|
|
191
|
+
approver_role: input.approverRole,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
async listAuditEvents() {
|
|
195
|
+
return this.request("GET", "/v1/audit-events");
|
|
196
|
+
}
|
|
197
|
+
async listApiKeys() {
|
|
198
|
+
return this.request("GET", "/v1/api-keys");
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.Auctra = Auctra;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
export declare const AUCTRA_SDK_VERSION = "0.2.1";
|
|
2
|
+
export type AgentEnvironment = "dev" | "staging" | "production";
|
|
3
|
+
export type AuthorityLevel = "low" | "medium" | "high" | "critical";
|
|
4
|
+
export type Decision = "allowed" | "blocked" | "require_approval";
|
|
5
|
+
export type PolicyType = "spending" | "data_access" | "communication" | "approval";
|
|
6
|
+
export type EvaluateActionInput = {
|
|
7
|
+
agentId: string;
|
|
8
|
+
actionType: string;
|
|
9
|
+
payload?: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
export type EvaluateActionResponse = {
|
|
12
|
+
decision: Decision;
|
|
13
|
+
risk_score: number;
|
|
14
|
+
reason: string;
|
|
15
|
+
delegation_id: string | null;
|
|
16
|
+
delegator: string | null;
|
|
17
|
+
sponsor: string;
|
|
18
|
+
matched_policies: string[];
|
|
19
|
+
action_request_id: string;
|
|
20
|
+
};
|
|
21
|
+
export type RequestOptions = {
|
|
22
|
+
idempotencyKey?: string;
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
};
|
|
25
|
+
export type AuctraClientOptions = {
|
|
26
|
+
apiKey: string;
|
|
27
|
+
baseUrl?: string;
|
|
28
|
+
timeoutMs?: number;
|
|
29
|
+
maxRetries?: number;
|
|
30
|
+
fetch?: typeof fetch;
|
|
31
|
+
};
|
|
32
|
+
export type Agent = {
|
|
33
|
+
id: string;
|
|
34
|
+
identity_id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
description: string | null;
|
|
37
|
+
model_provider: "openai" | "anthropic" | "gemini" | "local";
|
|
38
|
+
model_name: string;
|
|
39
|
+
environment: AgentEnvironment;
|
|
40
|
+
authority_level: AuthorityLevel;
|
|
41
|
+
status: "active" | "suspended" | "restricted" | "compromised";
|
|
42
|
+
trust_rating: number;
|
|
43
|
+
sponsor: {
|
|
44
|
+
id: string;
|
|
45
|
+
full_name: string;
|
|
46
|
+
email: string;
|
|
47
|
+
};
|
|
48
|
+
created_at: string;
|
|
49
|
+
};
|
|
50
|
+
export type CreateAgentInput = {
|
|
51
|
+
name: string;
|
|
52
|
+
modelProvider: Agent["model_provider"];
|
|
53
|
+
modelName: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
environment?: AgentEnvironment;
|
|
56
|
+
authorityLevel?: AuthorityLevel;
|
|
57
|
+
sponsorUserId?: string;
|
|
58
|
+
};
|
|
59
|
+
export type Delegation = {
|
|
60
|
+
id: string;
|
|
61
|
+
agent: {
|
|
62
|
+
id: string;
|
|
63
|
+
name: string;
|
|
64
|
+
};
|
|
65
|
+
delegator: {
|
|
66
|
+
id: string;
|
|
67
|
+
full_name: string;
|
|
68
|
+
email: string;
|
|
69
|
+
};
|
|
70
|
+
scope: {
|
|
71
|
+
action_types: string[];
|
|
72
|
+
};
|
|
73
|
+
limits: {
|
|
74
|
+
max_amount?: number;
|
|
75
|
+
max_count?: number;
|
|
76
|
+
currency?: string;
|
|
77
|
+
environment?: AgentEnvironment;
|
|
78
|
+
};
|
|
79
|
+
valid_from: string;
|
|
80
|
+
valid_until: string;
|
|
81
|
+
status: "active" | "revoked" | "expired";
|
|
82
|
+
is_active: boolean;
|
|
83
|
+
created_at: string;
|
|
84
|
+
};
|
|
85
|
+
export type CreateDelegationInput = {
|
|
86
|
+
agentId: string;
|
|
87
|
+
actionTypes: string[];
|
|
88
|
+
validUntil: string;
|
|
89
|
+
maxAmount?: number;
|
|
90
|
+
maxCount?: number;
|
|
91
|
+
environment?: AgentEnvironment;
|
|
92
|
+
currency?: string;
|
|
93
|
+
delegatorUserId?: string;
|
|
94
|
+
};
|
|
95
|
+
export type ActionRequest = {
|
|
96
|
+
id: string;
|
|
97
|
+
agent_name: string;
|
|
98
|
+
action_type: string;
|
|
99
|
+
action_summary: string;
|
|
100
|
+
payload: Record<string, unknown>;
|
|
101
|
+
decision: string;
|
|
102
|
+
decision_reason: string | null;
|
|
103
|
+
risk_score: number;
|
|
104
|
+
delegation_id: string | null;
|
|
105
|
+
policy_ids: string[];
|
|
106
|
+
pending_approval_id: string | null;
|
|
107
|
+
created_at: string;
|
|
108
|
+
decided_at: string | null;
|
|
109
|
+
};
|
|
110
|
+
export type Policy = {
|
|
111
|
+
id: string;
|
|
112
|
+
name: string;
|
|
113
|
+
description: string | null;
|
|
114
|
+
policy_type: PolicyType;
|
|
115
|
+
status: "active" | "draft" | "archived";
|
|
116
|
+
priority: number;
|
|
117
|
+
conditions: Record<string, unknown>;
|
|
118
|
+
actions: Record<string, unknown>;
|
|
119
|
+
created_at: string;
|
|
120
|
+
};
|
|
121
|
+
export type CreatePolicyInput = {
|
|
122
|
+
name: string;
|
|
123
|
+
description?: string;
|
|
124
|
+
policyType: PolicyType;
|
|
125
|
+
status?: "active" | "draft";
|
|
126
|
+
priority?: number;
|
|
127
|
+
actionType?: string;
|
|
128
|
+
amountGreaterThan?: number;
|
|
129
|
+
resourceSensitivity?: "public" | "internal" | "confidential" | "pii";
|
|
130
|
+
externalRecipient?: boolean;
|
|
131
|
+
environment?: AgentEnvironment;
|
|
132
|
+
decision: "block" | "require_approval";
|
|
133
|
+
approverRole?: "owner" | "admin" | "reviewer";
|
|
134
|
+
};
|
|
135
|
+
export type AuditEvent = {
|
|
136
|
+
id: string;
|
|
137
|
+
event_type: string;
|
|
138
|
+
event_summary: string;
|
|
139
|
+
decision: string | null;
|
|
140
|
+
decision_reason: string | null;
|
|
141
|
+
authority_valid_at_action: boolean | null;
|
|
142
|
+
actor_name: string;
|
|
143
|
+
approver_name: string | null;
|
|
144
|
+
policy_applied: string | null;
|
|
145
|
+
delegation_id: string | null;
|
|
146
|
+
hash: string | null;
|
|
147
|
+
previous_hash: string | null;
|
|
148
|
+
created_at: string;
|
|
149
|
+
};
|
|
150
|
+
export type ApiKeySummary = {
|
|
151
|
+
id: string;
|
|
152
|
+
name: string;
|
|
153
|
+
key_prefix: string;
|
|
154
|
+
environment: "development" | "production";
|
|
155
|
+
permissions: string[];
|
|
156
|
+
status: "active" | "revoked";
|
|
157
|
+
last_used_at: string | null;
|
|
158
|
+
created_at: string;
|
|
159
|
+
};
|
|
160
|
+
export declare class AuctraApiError extends Error {
|
|
161
|
+
readonly status: number;
|
|
162
|
+
readonly code?: string;
|
|
163
|
+
readonly details?: unknown;
|
|
164
|
+
readonly requestId?: string;
|
|
165
|
+
constructor(message: string, options: {
|
|
166
|
+
status: number;
|
|
167
|
+
code?: string;
|
|
168
|
+
details?: unknown;
|
|
169
|
+
requestId?: string;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
export declare class Auctra {
|
|
173
|
+
private readonly apiKey;
|
|
174
|
+
private readonly baseUrl;
|
|
175
|
+
private readonly timeoutMs;
|
|
176
|
+
private readonly maxRetries;
|
|
177
|
+
private readonly fetchImpl;
|
|
178
|
+
constructor(options: AuctraClientOptions);
|
|
179
|
+
private request;
|
|
180
|
+
evaluateAction(input: EvaluateActionInput, options?: RequestOptions): Promise<EvaluateActionResponse>;
|
|
181
|
+
listAgents(): Promise<{
|
|
182
|
+
agents: Agent[];
|
|
183
|
+
}>;
|
|
184
|
+
getAgent(agentId: string): Promise<{
|
|
185
|
+
agent: Agent;
|
|
186
|
+
}>;
|
|
187
|
+
createAgent(input: CreateAgentInput): Promise<{
|
|
188
|
+
agent: Agent;
|
|
189
|
+
}>;
|
|
190
|
+
listDelegations(): Promise<{
|
|
191
|
+
delegations: Delegation[];
|
|
192
|
+
}>;
|
|
193
|
+
getDelegation(delegationId: string): Promise<{
|
|
194
|
+
delegation: Delegation;
|
|
195
|
+
}>;
|
|
196
|
+
createDelegation(input: CreateDelegationInput): Promise<{
|
|
197
|
+
delegation: Delegation;
|
|
198
|
+
}>;
|
|
199
|
+
revokeDelegation(delegationId: string): Promise<{
|
|
200
|
+
ok: true;
|
|
201
|
+
}>;
|
|
202
|
+
listActionRequests(): Promise<{
|
|
203
|
+
action_requests: ActionRequest[];
|
|
204
|
+
}>;
|
|
205
|
+
approveActionRequest(actionRequestId: string, approverUserId: string, reason?: string): Promise<{
|
|
206
|
+
ok: true;
|
|
207
|
+
decision: string;
|
|
208
|
+
reason: string;
|
|
209
|
+
}>;
|
|
210
|
+
rejectActionRequest(actionRequestId: string, approverUserId: string, reason?: string): Promise<{
|
|
211
|
+
ok: true;
|
|
212
|
+
decision: string;
|
|
213
|
+
reason: string;
|
|
214
|
+
}>;
|
|
215
|
+
escalateActionRequest(actionRequestId: string, approverUserId: string, reason?: string): Promise<{
|
|
216
|
+
ok: true;
|
|
217
|
+
decision: string;
|
|
218
|
+
reason: string;
|
|
219
|
+
}>;
|
|
220
|
+
private resolveActionRequest;
|
|
221
|
+
listPolicies(): Promise<{
|
|
222
|
+
policies: Policy[];
|
|
223
|
+
}>;
|
|
224
|
+
createPolicy(input: CreatePolicyInput): Promise<{
|
|
225
|
+
policy: Pick<Policy, "id" | "name" | "status" | "created_at">;
|
|
226
|
+
}>;
|
|
227
|
+
listAuditEvents(): Promise<{
|
|
228
|
+
audit_events: AuditEvent[];
|
|
229
|
+
}>;
|
|
230
|
+
listApiKeys(): Promise<{
|
|
231
|
+
api_keys: ApiKeySummary[];
|
|
232
|
+
}>;
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAE1C,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,SAAS,GAAG,YAAY,CAAC;AAChE,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AACpE,MAAM,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