@auctra/sdk 0.6.0 → 0.6.2
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 +16 -0
- package/README.md +5 -4
- package/dist/cjs/action.js +2 -0
- package/dist/cjs/artifacts.js +110 -0
- package/dist/cjs/authority.js +2 -0
- package/dist/cjs/client.js +355 -0
- package/dist/cjs/evidence.js +6 -0
- package/dist/cjs/index.js +16 -455
- package/dist/cjs/types.js +7 -0
- package/dist/esm/action.d.ts +3 -0
- package/dist/esm/action.d.ts.map +1 -0
- package/dist/esm/action.js +1 -0
- package/dist/esm/artifacts.d.ts +28 -0
- package/dist/esm/artifacts.d.ts.map +1 -0
- package/dist/esm/artifacts.js +102 -0
- package/dist/esm/authority.d.ts +3 -0
- package/dist/esm/authority.d.ts.map +1 -0
- package/dist/esm/authority.js +1 -0
- package/dist/esm/client.d.ts +195 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +351 -0
- package/dist/esm/evidence.d.ts +4 -0
- package/dist/esm/evidence.d.ts.map +1 -0
- package/dist/esm/evidence.js +1 -0
- package/dist/esm/index.d.ts +10 -688
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +9 -450
- package/dist/esm/types.d.ts +477 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +4 -0
- package/package.json +1 -1
- package/src/action.ts +2 -0
- package/src/artifacts.ts +140 -0
- package/src/authority.ts +2 -0
- package/src/client.ts +555 -0
- package/src/evidence.ts +9 -0
- package/src/index.ts +10 -1125
- package/src/types.ts +488 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.2
|
|
4
|
+
|
|
5
|
+
**Fix — production default base URL**
|
|
6
|
+
|
|
7
|
+
- Default `baseUrl` is now `https://app.auctra.tech` (API + console are colocated there).
|
|
8
|
+
- Published `0.6.1` incorrectly defaulted to `https://console.auctra.tech` (NXDOMAIN).
|
|
9
|
+
- Export `DEFAULT_BASE_URL` so staging/local overrides stay explicit: `new Auctra({ apiKey, baseUrl })`.
|
|
10
|
+
|
|
11
|
+
## 0.6.1
|
|
12
|
+
|
|
13
|
+
**Stage 1.0 — SDK + Runtime convergence packaging**
|
|
14
|
+
|
|
15
|
+
- Modularize the client under `authority` / `action` / `evidence` modules (same public API as 0.6.0).
|
|
16
|
+
- Align with Stage 1.0 cloud surface: authorities, `action.evaluate` / `action.execute`, evidence verify.
|
|
17
|
+
- No public API break from 0.6.0.
|
|
18
|
+
|
|
3
19
|
## 0.6.0
|
|
4
20
|
|
|
5
21
|
**Breaking — Authority Protocol public API (clean break, no legacy aliases)**
|
package/README.md
CHANGED
|
@@ -6,11 +6,11 @@ Official TypeScript SDK for [Auctra](https://auctra.tech) — **Authority Protoc
|
|
|
6
6
|
|
|
7
7
|
| Resource | URL |
|
|
8
8
|
| -------------------------- | ------------------------------------------------------------- |
|
|
9
|
-
| **Console** | https://
|
|
10
|
-
| **Sign up (free
|
|
9
|
+
| **Console** | https://app.auctra.tech |
|
|
10
|
+
| **Sign up (free Developer)** | https://app.auctra.tech/auth/signup |
|
|
11
11
|
| **Docs** | https://auctra.tech/docs |
|
|
12
|
-
| **OpenAPI 3.1** | https://
|
|
13
|
-
| **API base URL** | `https://
|
|
12
|
+
| **OpenAPI 3.1** | https://app.auctra.tech/v1/openapi.json |
|
|
13
|
+
| **API base URL** | `https://app.auctra.tech` (`DEFAULT_BASE_URL` — override with `baseUrl`) |
|
|
14
14
|
|
|
15
15
|
## Install
|
|
16
16
|
|
|
@@ -41,6 +41,7 @@ import { Auctra } from "@auctra/sdk";
|
|
|
41
41
|
|
|
42
42
|
const auctra = new Auctra({
|
|
43
43
|
apiKey: process.env.AUCTRA_API_KEY!,
|
|
44
|
+
// baseUrl defaults to https://app.auctra.tech — set for staging/local only
|
|
44
45
|
timeoutMs: 10_000,
|
|
45
46
|
maxRetries: 2,
|
|
46
47
|
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuctraApiError = void 0;
|
|
4
|
+
exports.retryDelay = retryDelay;
|
|
5
|
+
exports.wait = wait;
|
|
6
|
+
exports.verifyMandateArtifact = verifyMandateArtifact;
|
|
7
|
+
exports.verifyDecisionArtifact = verifyDecisionArtifact;
|
|
8
|
+
/** @auctra/sdk — Authority Protocol client (Stage 1.0 modular layout). */
|
|
9
|
+
const node_crypto_1 = require("node:crypto");
|
|
10
|
+
class AuctraApiError extends Error {
|
|
11
|
+
status;
|
|
12
|
+
code;
|
|
13
|
+
details;
|
|
14
|
+
requestId;
|
|
15
|
+
constructor(message, options) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = "AuctraApiError";
|
|
18
|
+
this.status = options.status;
|
|
19
|
+
this.code = options.code;
|
|
20
|
+
this.details = options.details;
|
|
21
|
+
this.requestId = options.requestId;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.AuctraApiError = AuctraApiError;
|
|
25
|
+
function retryDelay(response, attempt) {
|
|
26
|
+
const retryAfter = response?.headers.get("retry-after");
|
|
27
|
+
if (retryAfter) {
|
|
28
|
+
const seconds = Number(retryAfter);
|
|
29
|
+
if (Number.isFinite(seconds))
|
|
30
|
+
return Math.min(30_000, Math.max(0, seconds * 1_000));
|
|
31
|
+
const dateDelay = Date.parse(retryAfter) - Date.now();
|
|
32
|
+
if (Number.isFinite(dateDelay))
|
|
33
|
+
return Math.min(30_000, Math.max(0, dateDelay));
|
|
34
|
+
}
|
|
35
|
+
return Math.min(5_000, 150 * 2 ** attempt);
|
|
36
|
+
}
|
|
37
|
+
function wait(ms, signal) {
|
|
38
|
+
if (signal?.aborted)
|
|
39
|
+
return Promise.reject(signal.reason);
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const timeout = setTimeout(resolve, ms);
|
|
42
|
+
signal?.addEventListener("abort", () => {
|
|
43
|
+
clearTimeout(timeout);
|
|
44
|
+
reject(signal.reason);
|
|
45
|
+
}, { once: true });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function canonicalizeJson(value) {
|
|
49
|
+
if (Array.isArray(value))
|
|
50
|
+
return value.map(canonicalizeJson);
|
|
51
|
+
if (value && typeof value === "object" && !(value instanceof Date)) {
|
|
52
|
+
return Object.fromEntries(Object.entries(value)
|
|
53
|
+
.filter(([, child]) => child !== undefined)
|
|
54
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
55
|
+
.map(([key, child]) => [key, canonicalizeJson(child)]));
|
|
56
|
+
}
|
|
57
|
+
if (value instanceof Date)
|
|
58
|
+
return value.toISOString();
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
function hashJson(value) {
|
|
62
|
+
return (0, node_crypto_1.createHash)("sha256")
|
|
63
|
+
.update(JSON.stringify(canonicalizeJson(value)))
|
|
64
|
+
.digest("hex");
|
|
65
|
+
}
|
|
66
|
+
function verifyEd25519(input) {
|
|
67
|
+
if (!input.publicKeyPem)
|
|
68
|
+
return false;
|
|
69
|
+
if (input.signature.alg !== "Ed25519")
|
|
70
|
+
return false;
|
|
71
|
+
return (0, node_crypto_1.verify)(null, Buffer.from(JSON.stringify(canonicalizeJson(input.payload))), typeof input.publicKeyPem === "string"
|
|
72
|
+
? (0, node_crypto_1.createPublicKey)(input.publicKeyPem)
|
|
73
|
+
: input.publicKeyPem, Buffer.from(input.signature.value, "base64url"));
|
|
74
|
+
}
|
|
75
|
+
function verifyMandateArtifact(input) {
|
|
76
|
+
const expectedHash = hashJson(input.payload);
|
|
77
|
+
if (input.evidence.format !== "auctra-mandate.v0.1") {
|
|
78
|
+
return { valid: false, hashValid: false, signatureValid: false };
|
|
79
|
+
}
|
|
80
|
+
if (!input.evidence.signed) {
|
|
81
|
+
const hashValid = input.evidence.payload_hash === expectedHash;
|
|
82
|
+
return { valid: hashValid, hashValid, signatureValid: false };
|
|
83
|
+
}
|
|
84
|
+
const hashValid = input.evidence.payload_hash === expectedHash;
|
|
85
|
+
const signatureValid = hashValid &&
|
|
86
|
+
verifyEd25519({
|
|
87
|
+
payload: input.payload,
|
|
88
|
+
signature: input.evidence.signature,
|
|
89
|
+
publicKeyPem: input.publicKeyPem,
|
|
90
|
+
});
|
|
91
|
+
return { valid: hashValid && signatureValid, hashValid, signatureValid };
|
|
92
|
+
}
|
|
93
|
+
function verifyDecisionArtifact(input) {
|
|
94
|
+
const expectedHash = hashJson(input.payload);
|
|
95
|
+
if (input.evidence.format !== "auctra-evidence.v0.1") {
|
|
96
|
+
return { valid: false, hashValid: false, signatureValid: false };
|
|
97
|
+
}
|
|
98
|
+
if (!input.evidence.signed) {
|
|
99
|
+
const hashValid = input.evidence.payload_hash === expectedHash;
|
|
100
|
+
return { valid: hashValid, hashValid, signatureValid: false };
|
|
101
|
+
}
|
|
102
|
+
const hashValid = input.evidence.payload_hash === expectedHash;
|
|
103
|
+
const signatureValid = hashValid &&
|
|
104
|
+
verifyEd25519({
|
|
105
|
+
payload: input.payload,
|
|
106
|
+
signature: input.evidence.signature,
|
|
107
|
+
publicKeyPem: input.publicKeyPem,
|
|
108
|
+
});
|
|
109
|
+
return { valid: hashValid && signatureValid, hashValid, signatureValid };
|
|
110
|
+
}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Auctra = void 0;
|
|
4
|
+
/** @auctra/sdk — Authority Protocol client (Stage 1.0 modular layout). */
|
|
5
|
+
const artifacts_js_1 = require("./artifacts.js");
|
|
6
|
+
const types_js_1 = require("./types.js");
|
|
7
|
+
class Auctra {
|
|
8
|
+
apiKey;
|
|
9
|
+
baseUrl;
|
|
10
|
+
timeoutMs;
|
|
11
|
+
maxRetries;
|
|
12
|
+
fetchImpl;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
if (!options.apiKey.trim())
|
|
15
|
+
throw new Error("apiKey is required");
|
|
16
|
+
if (options.timeoutMs !== undefined && options.timeoutMs <= 0) {
|
|
17
|
+
throw new Error("timeoutMs must be greater than zero");
|
|
18
|
+
}
|
|
19
|
+
if (options.maxRetries !== undefined &&
|
|
20
|
+
(!Number.isInteger(options.maxRetries) || options.maxRetries < 0)) {
|
|
21
|
+
throw new Error("maxRetries must be a non-negative integer");
|
|
22
|
+
}
|
|
23
|
+
this.apiKey = options.apiKey;
|
|
24
|
+
this.baseUrl = (options.baseUrl ?? types_js_1.DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
25
|
+
this.timeoutMs = options.timeoutMs ?? 10_000;
|
|
26
|
+
this.maxRetries = options.maxRetries ?? 2;
|
|
27
|
+
this.fetchImpl = options.fetch ?? globalThis.fetch;
|
|
28
|
+
if (!this.fetchImpl)
|
|
29
|
+
throw new Error("A fetch implementation is required");
|
|
30
|
+
}
|
|
31
|
+
async request(method, path, body, options = {}) {
|
|
32
|
+
const retryableRequest = method === "GET" || Boolean(options.idempotencyKey);
|
|
33
|
+
let lastError;
|
|
34
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt += 1) {
|
|
35
|
+
if (options.signal?.aborted)
|
|
36
|
+
throw options.signal.reason;
|
|
37
|
+
const timeoutSignal = AbortSignal.timeout(this.timeoutMs);
|
|
38
|
+
const signal = options.signal
|
|
39
|
+
? AbortSignal.any([options.signal, timeoutSignal])
|
|
40
|
+
: timeoutSignal;
|
|
41
|
+
let response;
|
|
42
|
+
try {
|
|
43
|
+
response = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
44
|
+
method,
|
|
45
|
+
signal,
|
|
46
|
+
headers: {
|
|
47
|
+
...(body !== undefined ? { "content-type": "application/json" } : {}),
|
|
48
|
+
...(options.idempotencyKey ? { "idempotency-key": options.idempotencyKey } : {}),
|
|
49
|
+
authorization: `Bearer ${this.apiKey}`,
|
|
50
|
+
"x-auctra-sdk-version": types_js_1.AUCTRA_SDK_VERSION,
|
|
51
|
+
},
|
|
52
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
53
|
+
});
|
|
54
|
+
const data = (await response.json().catch(() => ({})));
|
|
55
|
+
if (response.ok)
|
|
56
|
+
return data;
|
|
57
|
+
if (retryableRequest &&
|
|
58
|
+
(response.status === 429 || response.status >= 500) &&
|
|
59
|
+
attempt < this.maxRetries) {
|
|
60
|
+
await (0, artifacts_js_1.wait)((0, artifacts_js_1.retryDelay)(response, attempt), options.signal);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
throw new artifacts_js_1.AuctraApiError(typeof data.error === "string" ? data.error : `Auctra API error (${response.status})`, {
|
|
64
|
+
status: response.status,
|
|
65
|
+
code: typeof data.code === "string" ? data.code : undefined,
|
|
66
|
+
details: data.details,
|
|
67
|
+
requestId: response.headers.get("x-request-id") ?? undefined,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
lastError = error;
|
|
72
|
+
if (options.signal?.aborted)
|
|
73
|
+
throw options.signal.reason;
|
|
74
|
+
if (error instanceof artifacts_js_1.AuctraApiError || !retryableRequest || attempt >= this.maxRetries) {
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
await (0, artifacts_js_1.wait)((0, artifacts_js_1.retryDelay)(response, attempt), options.signal);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
throw lastError;
|
|
81
|
+
}
|
|
82
|
+
async executeOrEvaluateAction(input, options, mode) {
|
|
83
|
+
const idempotencyKey = mode === "execute" ? (options.idempotencyKey ?? crypto.randomUUID()) : options.idempotencyKey;
|
|
84
|
+
const path = mode === "execute" ? "/v1/actions/execute" : "/v1/actions/evaluate";
|
|
85
|
+
return this.request("POST", path, {
|
|
86
|
+
agent_id: input.agentId,
|
|
87
|
+
action_type: input.actionType,
|
|
88
|
+
payload: input.payload ?? {},
|
|
89
|
+
claimed_intent_id: input.claimedIntentId,
|
|
90
|
+
intent_anchor_token: input.intentAnchorToken,
|
|
91
|
+
parent_action_id: input.parentActionId,
|
|
92
|
+
dry_run: mode === "evaluate",
|
|
93
|
+
actor: input.actor
|
|
94
|
+
? {
|
|
95
|
+
id: input.actor.id,
|
|
96
|
+
type: input.actor.type,
|
|
97
|
+
name: input.actor.name,
|
|
98
|
+
}
|
|
99
|
+
: undefined,
|
|
100
|
+
action: input.action
|
|
101
|
+
? {
|
|
102
|
+
target: input.action.target,
|
|
103
|
+
description: input.action.description,
|
|
104
|
+
risk_level: input.action.riskLevel,
|
|
105
|
+
metadata: input.action.metadata,
|
|
106
|
+
}
|
|
107
|
+
: undefined,
|
|
108
|
+
}, mode === "execute" ? { ...options, idempotencyKey } : options);
|
|
109
|
+
}
|
|
110
|
+
async issueAuthorityRequest(input) {
|
|
111
|
+
const response = await this.request("POST", "/v1/authorities", {
|
|
112
|
+
agent_id: input.subject,
|
|
113
|
+
action_types: input.capabilities,
|
|
114
|
+
valid_until: input.expiresAt,
|
|
115
|
+
max_amount: input.constraints?.maxAmount,
|
|
116
|
+
max_count: input.constraints?.maxCount,
|
|
117
|
+
environment: input.constraints?.environment,
|
|
118
|
+
currency: input.constraints?.currency,
|
|
119
|
+
delegator_user_id: input.delegatorUserId ?? input.issuer,
|
|
120
|
+
parent_authority_id: input.parentAuthorityId,
|
|
121
|
+
max_delegation_depth: input.delegation?.maxDepth,
|
|
122
|
+
max_actions_per_window: input.maxActionsPerWindow
|
|
123
|
+
? {
|
|
124
|
+
count: input.maxActionsPerWindow.count,
|
|
125
|
+
window_seconds: input.maxActionsPerWindow.windowSeconds,
|
|
126
|
+
action_type: input.maxActionsPerWindow.actionType,
|
|
127
|
+
}
|
|
128
|
+
: undefined,
|
|
129
|
+
max_amount_per_window: input.maxAmountPerWindow
|
|
130
|
+
? {
|
|
131
|
+
amount: input.maxAmountPerWindow.amount,
|
|
132
|
+
window_seconds: input.maxAmountPerWindow.windowSeconds,
|
|
133
|
+
}
|
|
134
|
+
: undefined,
|
|
135
|
+
});
|
|
136
|
+
const authorityId = response.authority_id ?? response.delegation.id;
|
|
137
|
+
const authority = response.authority ?? {
|
|
138
|
+
id: authorityId,
|
|
139
|
+
protocol_version: "0.1",
|
|
140
|
+
status: response.delegation.status,
|
|
141
|
+
payload_hash: "",
|
|
142
|
+
signed: false,
|
|
143
|
+
parent_authority_id: input.parentAuthorityId ?? null,
|
|
144
|
+
capabilities: input.capabilities,
|
|
145
|
+
};
|
|
146
|
+
return {
|
|
147
|
+
authority,
|
|
148
|
+
authority_id: authorityId,
|
|
149
|
+
delegation: response.delegation,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Authority Protocol — issue, verify, delegate (subset), revoke.
|
|
154
|
+
* There is no legacy createDelegation() surface.
|
|
155
|
+
*/
|
|
156
|
+
get authority() {
|
|
157
|
+
return {
|
|
158
|
+
issue: (input) => this.issueAuthorityRequest(input),
|
|
159
|
+
verify: (payload, artifact) => this.request("POST", "/v1/authorities/verify", { payload, artifact }),
|
|
160
|
+
delegate: (input) => this.issueAuthorityRequest({
|
|
161
|
+
...input,
|
|
162
|
+
parentAuthorityId: input.parent,
|
|
163
|
+
}),
|
|
164
|
+
revoke: (authorityId) => this.request("POST", `/v1/authorities/${encodeURIComponent(authorityId)}/revoke`, {}),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Action Protocol — evaluate (dry-run) vs execute (enforce + evidence).
|
|
169
|
+
* There is no legacy evaluateAction() surface.
|
|
170
|
+
*/
|
|
171
|
+
get action() {
|
|
172
|
+
return {
|
|
173
|
+
evaluate: (input, options = {}) => this.executeOrEvaluateAction(input, options, "evaluate"),
|
|
174
|
+
execute: (input, options = {}) => this.executeOrEvaluateAction(input, options, "execute"),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
get evidence() {
|
|
178
|
+
return {
|
|
179
|
+
verify: (payload, evidence) => this.request("POST", "/v1/evidence/verify", { payload, evidence }),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
async verifyMandate(payload, evidence) {
|
|
183
|
+
return this.request("POST", "/v1/mandates/verify", { payload, evidence });
|
|
184
|
+
}
|
|
185
|
+
async listIntents() {
|
|
186
|
+
return this.request("GET", "/v1/intents");
|
|
187
|
+
}
|
|
188
|
+
async createIntent(input) {
|
|
189
|
+
return this.request("POST", "/v1/intents", {
|
|
190
|
+
title: input.title,
|
|
191
|
+
description: input.description,
|
|
192
|
+
intent_type: input.intentType,
|
|
193
|
+
risk_level: input.riskLevel,
|
|
194
|
+
max_risk_level: input.maxRiskLevel,
|
|
195
|
+
expires_at: input.expiresAt,
|
|
196
|
+
allowed_action_types: input.allowedActionTypes,
|
|
197
|
+
target_pattern: input.targetPattern,
|
|
198
|
+
resource_allowlist: input.resourceAllowlist,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
async getIntent(intentId) {
|
|
202
|
+
return this.request("GET", `/v1/intents/${encodeURIComponent(intentId)}`);
|
|
203
|
+
}
|
|
204
|
+
async updateIntentStatus(intentId, status) {
|
|
205
|
+
return this.updateIntent(intentId, { status });
|
|
206
|
+
}
|
|
207
|
+
async updateIntent(intentId, input) {
|
|
208
|
+
return this.request("PATCH", `/v1/intents/${encodeURIComponent(intentId)}`, {
|
|
209
|
+
status: input.status,
|
|
210
|
+
title: input.title,
|
|
211
|
+
description: input.description,
|
|
212
|
+
intent_type: input.intentType,
|
|
213
|
+
risk_level: input.riskLevel,
|
|
214
|
+
max_risk_level: input.maxRiskLevel,
|
|
215
|
+
expires_at: input.expiresAt,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
async getAuthorityGraph() {
|
|
219
|
+
return this.request("GET", "/v1/authority/graph");
|
|
220
|
+
}
|
|
221
|
+
async createAuthorityEdge(input) {
|
|
222
|
+
return this.request("POST", "/v1/authority/edges", {
|
|
223
|
+
from_actor_id: input.fromActorId,
|
|
224
|
+
from_actor_type: input.fromActorType,
|
|
225
|
+
to_actor_id: input.toActorId,
|
|
226
|
+
to_actor_type: input.toActorType,
|
|
227
|
+
authority_scope: input.authorityScope,
|
|
228
|
+
conditions: input.conditions,
|
|
229
|
+
max_risk_level: input.maxRiskLevel,
|
|
230
|
+
expires_at: input.expiresAt,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
async getActionEvaluation(actionRequestId) {
|
|
234
|
+
return this.request("GET", `/v1/action-requests/${encodeURIComponent(actionRequestId)}/evaluation`);
|
|
235
|
+
}
|
|
236
|
+
async getRootIntentChain(actionRequestId) {
|
|
237
|
+
return this.request("GET", `/v1/action-requests/${encodeURIComponent(actionRequestId)}/root-intent`);
|
|
238
|
+
}
|
|
239
|
+
async listAgents() {
|
|
240
|
+
return this.request("GET", "/v1/agents");
|
|
241
|
+
}
|
|
242
|
+
async getAgent(agentId) {
|
|
243
|
+
return this.request("GET", `/v1/agents/${encodeURIComponent(agentId)}`);
|
|
244
|
+
}
|
|
245
|
+
async createAgent(input) {
|
|
246
|
+
return this.request("POST", "/v1/agents", {
|
|
247
|
+
name: input.name,
|
|
248
|
+
model_provider: input.modelProvider,
|
|
249
|
+
model_name: input.modelName,
|
|
250
|
+
description: input.description,
|
|
251
|
+
environment: input.environment,
|
|
252
|
+
authority_level: input.authorityLevel,
|
|
253
|
+
sponsor_user_id: input.sponsorUserId,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
async updateAgentStatus(agentId, input) {
|
|
257
|
+
return this.request("PATCH", `/v1/agents/${encodeURIComponent(agentId)}`, {
|
|
258
|
+
status: input.status,
|
|
259
|
+
reason: input.reason,
|
|
260
|
+
revoke_delegations: input.revokeDelegations,
|
|
261
|
+
restore_delegations: input.restoreDelegations,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
async deleteAgent(agentId) {
|
|
265
|
+
return this.request("DELETE", `/v1/agents/${encodeURIComponent(agentId)}`);
|
|
266
|
+
}
|
|
267
|
+
async listAuthorities() {
|
|
268
|
+
return this.request("GET", "/v1/authorities");
|
|
269
|
+
}
|
|
270
|
+
async getAuthority(authorityId) {
|
|
271
|
+
return this.request("GET", `/v1/authorities/${encodeURIComponent(authorityId)}`);
|
|
272
|
+
}
|
|
273
|
+
async listActionRequests() {
|
|
274
|
+
return this.request("GET", "/v1/action-requests");
|
|
275
|
+
}
|
|
276
|
+
async approveActionRequest(actionRequestId, approverUserId, reason) {
|
|
277
|
+
return this.resolveActionRequest(actionRequestId, "approve", approverUserId, reason);
|
|
278
|
+
}
|
|
279
|
+
async rejectActionRequest(actionRequestId, approverUserId, reason) {
|
|
280
|
+
return this.resolveActionRequest(actionRequestId, "reject", approverUserId, reason);
|
|
281
|
+
}
|
|
282
|
+
async escalateActionRequest(actionRequestId, approverUserId, reason) {
|
|
283
|
+
return this.resolveActionRequest(actionRequestId, "escalate", approverUserId, reason);
|
|
284
|
+
}
|
|
285
|
+
async resolveActionRequest(actionRequestId, action, approverUserId, reason) {
|
|
286
|
+
return this.request("POST", `/v1/action-requests/${encodeURIComponent(actionRequestId)}/${action}`, { reason, approver_user_id: approverUserId });
|
|
287
|
+
}
|
|
288
|
+
async listPolicies() {
|
|
289
|
+
return this.request("GET", "/v1/policies");
|
|
290
|
+
}
|
|
291
|
+
async createPolicy(input) {
|
|
292
|
+
return this.request("POST", "/v1/policies", {
|
|
293
|
+
name: input.name,
|
|
294
|
+
description: input.description,
|
|
295
|
+
policy_type: input.policyType,
|
|
296
|
+
status: input.status,
|
|
297
|
+
priority: input.priority,
|
|
298
|
+
action_type: input.actionType,
|
|
299
|
+
amount_greater_than: input.amountGreaterThan,
|
|
300
|
+
resource_sensitivity: input.resourceSensitivity,
|
|
301
|
+
external_recipient: input.externalRecipient,
|
|
302
|
+
environment: input.environment,
|
|
303
|
+
decision: input.decision,
|
|
304
|
+
approver_role: input.approverRole,
|
|
305
|
+
max_actions_per_window: input.maxActionsPerWindow
|
|
306
|
+
? {
|
|
307
|
+
count: input.maxActionsPerWindow.count,
|
|
308
|
+
window_seconds: input.maxActionsPerWindow.windowSeconds,
|
|
309
|
+
action_type: input.maxActionsPerWindow.actionType,
|
|
310
|
+
}
|
|
311
|
+
: undefined,
|
|
312
|
+
max_amount_per_window: input.maxAmountPerWindow
|
|
313
|
+
? {
|
|
314
|
+
amount: input.maxAmountPerWindow.amount,
|
|
315
|
+
window_seconds: input.maxAmountPerWindow.windowSeconds,
|
|
316
|
+
}
|
|
317
|
+
: undefined,
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
async simulatePolicy(policyId, input = {}) {
|
|
321
|
+
return this.request("POST", `/v1/policies/${encodeURIComponent(policyId)}/simulate`, input);
|
|
322
|
+
}
|
|
323
|
+
async publishPolicy(policyId, input = {}) {
|
|
324
|
+
return this.request("POST", `/v1/policies/${encodeURIComponent(policyId)}/publish`, input);
|
|
325
|
+
}
|
|
326
|
+
async listActionTypes() {
|
|
327
|
+
return this.listCustomActionTypes();
|
|
328
|
+
}
|
|
329
|
+
async listCustomActionTypes() {
|
|
330
|
+
return this.request("GET", "/v1/action-types");
|
|
331
|
+
}
|
|
332
|
+
async createCustomActionType(input) {
|
|
333
|
+
return this.request("POST", "/v1/action-types", {
|
|
334
|
+
id: input.id,
|
|
335
|
+
label: input.label,
|
|
336
|
+
description: input.description,
|
|
337
|
+
category: input.category,
|
|
338
|
+
policy_type: input.policyType,
|
|
339
|
+
payload_schema: input.payloadSchema ?? {},
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
async listAuditEvents() {
|
|
343
|
+
return this.request("GET", "/v1/audit-events");
|
|
344
|
+
}
|
|
345
|
+
async getAuditEvent(auditEventId) {
|
|
346
|
+
return this.request("GET", `/v1/audit-events/${encodeURIComponent(auditEventId)}`);
|
|
347
|
+
}
|
|
348
|
+
async verifyAuditChain() {
|
|
349
|
+
return this.request("GET", "/v1/audit-events/verify");
|
|
350
|
+
}
|
|
351
|
+
async listApiKeys() {
|
|
352
|
+
return this.request("GET", "/v1/api-keys");
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
exports.Auctra = Auctra;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyMandateArtifact = exports.verifyDecisionArtifact = void 0;
|
|
4
|
+
var artifacts_js_1 = require("./artifacts.js");
|
|
5
|
+
Object.defineProperty(exports, "verifyDecisionArtifact", { enumerable: true, get: function () { return artifacts_js_1.verifyDecisionArtifact; } });
|
|
6
|
+
Object.defineProperty(exports, "verifyMandateArtifact", { enumerable: true, get: function () { return artifacts_js_1.verifyMandateArtifact; } });
|