@auctra/sdk 0.2.0 → 0.3.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/CHANGELOG.md +20 -0
- package/LICENSE +21 -0
- package/README.md +41 -4
- package/dist/cjs/index.js +247 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/index.d.ts +355 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +242 -0
- package/package.json +18 -8
- package/src/index.ts +569 -0
- package/dist/index.d.ts +0 -129
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -143
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
export declare const AUCTRA_SDK_VERSION = "0.3.0";
|
|
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 ActorType = "human" | "agent" | "service" | "tool";
|
|
7
|
+
export type RiskLevel = "low" | "medium" | "high" | "critical";
|
|
8
|
+
export type EvaluateActionInput = {
|
|
9
|
+
agentId: string;
|
|
10
|
+
actionType: string;
|
|
11
|
+
payload?: Record<string, unknown>;
|
|
12
|
+
claimedIntentId?: string;
|
|
13
|
+
parentActionId?: string;
|
|
14
|
+
actor?: {
|
|
15
|
+
id?: string;
|
|
16
|
+
type?: ActorType;
|
|
17
|
+
name?: string;
|
|
18
|
+
};
|
|
19
|
+
action?: {
|
|
20
|
+
target?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
riskLevel?: RiskLevel;
|
|
23
|
+
metadata?: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type EvaluateActionResponse = {
|
|
27
|
+
decision: Decision;
|
|
28
|
+
risk_score: number;
|
|
29
|
+
reason: string;
|
|
30
|
+
delegation_id: string | null;
|
|
31
|
+
delegator: string | null;
|
|
32
|
+
sponsor: string;
|
|
33
|
+
matched_policies: string[];
|
|
34
|
+
action_request_id: string;
|
|
35
|
+
intelligence?: {
|
|
36
|
+
authority_valid: boolean;
|
|
37
|
+
root_intent_valid: boolean;
|
|
38
|
+
intent_status: string;
|
|
39
|
+
trust_summary?: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export type RequestOptions = {
|
|
43
|
+
idempotencyKey?: string;
|
|
44
|
+
signal?: AbortSignal;
|
|
45
|
+
};
|
|
46
|
+
export type AuctraClientOptions = {
|
|
47
|
+
apiKey: string;
|
|
48
|
+
baseUrl?: string;
|
|
49
|
+
timeoutMs?: number;
|
|
50
|
+
maxRetries?: number;
|
|
51
|
+
fetch?: typeof fetch;
|
|
52
|
+
};
|
|
53
|
+
export type Agent = {
|
|
54
|
+
id: string;
|
|
55
|
+
identity_id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
description: string | null;
|
|
58
|
+
model_provider: "openai" | "anthropic" | "gemini" | "local";
|
|
59
|
+
model_name: string;
|
|
60
|
+
environment: AgentEnvironment;
|
|
61
|
+
authority_level: AuthorityLevel;
|
|
62
|
+
status: "active" | "suspended" | "restricted" | "compromised";
|
|
63
|
+
trust_rating: number;
|
|
64
|
+
sponsor: {
|
|
65
|
+
id: string;
|
|
66
|
+
full_name: string;
|
|
67
|
+
email: string;
|
|
68
|
+
};
|
|
69
|
+
created_at: string;
|
|
70
|
+
};
|
|
71
|
+
export type CreateAgentInput = {
|
|
72
|
+
name: string;
|
|
73
|
+
modelProvider: Agent["model_provider"];
|
|
74
|
+
modelName: string;
|
|
75
|
+
description?: string;
|
|
76
|
+
environment?: AgentEnvironment;
|
|
77
|
+
authorityLevel?: AuthorityLevel;
|
|
78
|
+
sponsorUserId?: string;
|
|
79
|
+
};
|
|
80
|
+
export type Delegation = {
|
|
81
|
+
id: string;
|
|
82
|
+
agent: {
|
|
83
|
+
id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
};
|
|
86
|
+
delegator: {
|
|
87
|
+
id: string;
|
|
88
|
+
full_name: string;
|
|
89
|
+
email: string;
|
|
90
|
+
};
|
|
91
|
+
scope: {
|
|
92
|
+
action_types: string[];
|
|
93
|
+
};
|
|
94
|
+
limits: {
|
|
95
|
+
max_amount?: number;
|
|
96
|
+
max_count?: number;
|
|
97
|
+
currency?: string;
|
|
98
|
+
environment?: AgentEnvironment;
|
|
99
|
+
};
|
|
100
|
+
valid_from: string;
|
|
101
|
+
valid_until: string;
|
|
102
|
+
status: "active" | "revoked" | "expired";
|
|
103
|
+
is_active: boolean;
|
|
104
|
+
created_at: string;
|
|
105
|
+
};
|
|
106
|
+
export type CreateDelegationInput = {
|
|
107
|
+
agentId: string;
|
|
108
|
+
actionTypes: string[];
|
|
109
|
+
validUntil: string;
|
|
110
|
+
maxAmount?: number;
|
|
111
|
+
maxCount?: number;
|
|
112
|
+
environment?: AgentEnvironment;
|
|
113
|
+
currency?: string;
|
|
114
|
+
delegatorUserId?: string;
|
|
115
|
+
};
|
|
116
|
+
export type ActionRequest = {
|
|
117
|
+
id: string;
|
|
118
|
+
agent_name: string;
|
|
119
|
+
action_type: string;
|
|
120
|
+
action_summary: string;
|
|
121
|
+
payload: Record<string, unknown>;
|
|
122
|
+
decision: string;
|
|
123
|
+
decision_reason: string | null;
|
|
124
|
+
risk_score: number;
|
|
125
|
+
delegation_id: string | null;
|
|
126
|
+
policy_ids: string[];
|
|
127
|
+
pending_approval_id: string | null;
|
|
128
|
+
created_at: string;
|
|
129
|
+
decided_at: string | null;
|
|
130
|
+
};
|
|
131
|
+
export type Intent = {
|
|
132
|
+
id: string;
|
|
133
|
+
title: string;
|
|
134
|
+
description: string | null;
|
|
135
|
+
intent_type: string | null;
|
|
136
|
+
status: string;
|
|
137
|
+
risk_level: RiskLevel;
|
|
138
|
+
max_risk_level: RiskLevel;
|
|
139
|
+
expires_at: string | null;
|
|
140
|
+
created_at: string;
|
|
141
|
+
owner: {
|
|
142
|
+
id: string;
|
|
143
|
+
full_name: string;
|
|
144
|
+
email: string;
|
|
145
|
+
} | null;
|
|
146
|
+
linked_actions: number;
|
|
147
|
+
};
|
|
148
|
+
export type IntentDetail = Omit<Intent, "linked_actions"> & {
|
|
149
|
+
linked_action_records: Array<{
|
|
150
|
+
action_request_id: string;
|
|
151
|
+
action_type: string;
|
|
152
|
+
summary: string;
|
|
153
|
+
decision: string;
|
|
154
|
+
alignment_status: string;
|
|
155
|
+
alignment_score: number | null;
|
|
156
|
+
}>;
|
|
157
|
+
};
|
|
158
|
+
export type CreateIntentInput = {
|
|
159
|
+
title: string;
|
|
160
|
+
description?: string;
|
|
161
|
+
intentType?: string;
|
|
162
|
+
riskLevel?: RiskLevel;
|
|
163
|
+
maxRiskLevel?: RiskLevel;
|
|
164
|
+
expiresAt?: string;
|
|
165
|
+
};
|
|
166
|
+
export type AuthorityGraph = {
|
|
167
|
+
nodes: Array<{
|
|
168
|
+
id: string;
|
|
169
|
+
type: ActorType;
|
|
170
|
+
label: string;
|
|
171
|
+
}>;
|
|
172
|
+
edges: Array<{
|
|
173
|
+
id: string;
|
|
174
|
+
from: string;
|
|
175
|
+
to: string;
|
|
176
|
+
fromType: ActorType;
|
|
177
|
+
toType: ActorType;
|
|
178
|
+
scope: string;
|
|
179
|
+
status: string;
|
|
180
|
+
edgeType: string;
|
|
181
|
+
}>;
|
|
182
|
+
};
|
|
183
|
+
export type ActionEvaluation = {
|
|
184
|
+
id: string;
|
|
185
|
+
action_request_id: string;
|
|
186
|
+
intent_id: string | null;
|
|
187
|
+
decision: "allowed" | "requires_approval" | "blocked";
|
|
188
|
+
risk_score: number;
|
|
189
|
+
authority_valid: boolean;
|
|
190
|
+
intent_valid: boolean;
|
|
191
|
+
root_intent_valid: boolean;
|
|
192
|
+
reasons: string[];
|
|
193
|
+
created_at: string;
|
|
194
|
+
};
|
|
195
|
+
export type RootIntentChain = {
|
|
196
|
+
valid: boolean;
|
|
197
|
+
root_human_id: string | null;
|
|
198
|
+
root_intent_id: string | null;
|
|
199
|
+
reason: string | null;
|
|
200
|
+
chain: Array<{
|
|
201
|
+
actionId?: string;
|
|
202
|
+
actorId: string;
|
|
203
|
+
actorType: ActorType;
|
|
204
|
+
intentId?: string;
|
|
205
|
+
parentActionId?: string;
|
|
206
|
+
label?: string;
|
|
207
|
+
}>;
|
|
208
|
+
};
|
|
209
|
+
export type Policy = {
|
|
210
|
+
id: string;
|
|
211
|
+
name: string;
|
|
212
|
+
description: string | null;
|
|
213
|
+
policy_type: PolicyType;
|
|
214
|
+
status: "active" | "draft" | "archived";
|
|
215
|
+
priority: number;
|
|
216
|
+
conditions: Record<string, unknown>;
|
|
217
|
+
actions: Record<string, unknown>;
|
|
218
|
+
created_at: string;
|
|
219
|
+
};
|
|
220
|
+
export type CreatePolicyInput = {
|
|
221
|
+
name: string;
|
|
222
|
+
description?: string;
|
|
223
|
+
policyType: PolicyType;
|
|
224
|
+
status?: "active" | "draft";
|
|
225
|
+
priority?: number;
|
|
226
|
+
actionType?: string;
|
|
227
|
+
amountGreaterThan?: number;
|
|
228
|
+
resourceSensitivity?: "public" | "internal" | "confidential" | "pii";
|
|
229
|
+
externalRecipient?: boolean;
|
|
230
|
+
environment?: AgentEnvironment;
|
|
231
|
+
decision: "block" | "require_approval";
|
|
232
|
+
approverRole?: "owner" | "admin" | "reviewer";
|
|
233
|
+
};
|
|
234
|
+
export type AuditEvent = {
|
|
235
|
+
id: string;
|
|
236
|
+
event_type: string;
|
|
237
|
+
event_summary: string;
|
|
238
|
+
decision: string | null;
|
|
239
|
+
decision_reason: string | null;
|
|
240
|
+
authority_valid_at_action: boolean | null;
|
|
241
|
+
actor_name: string;
|
|
242
|
+
approver_name: string | null;
|
|
243
|
+
policy_applied: string | null;
|
|
244
|
+
delegation_id: string | null;
|
|
245
|
+
hash: string | null;
|
|
246
|
+
previous_hash: string | null;
|
|
247
|
+
created_at: string;
|
|
248
|
+
};
|
|
249
|
+
export type ApiKeySummary = {
|
|
250
|
+
id: string;
|
|
251
|
+
name: string;
|
|
252
|
+
key_prefix: string;
|
|
253
|
+
environment: "development" | "production";
|
|
254
|
+
permissions: string[];
|
|
255
|
+
status: "active" | "revoked";
|
|
256
|
+
last_used_at: string | null;
|
|
257
|
+
created_at: string;
|
|
258
|
+
};
|
|
259
|
+
export declare class AuctraApiError extends Error {
|
|
260
|
+
readonly status: number;
|
|
261
|
+
readonly code?: string;
|
|
262
|
+
readonly details?: unknown;
|
|
263
|
+
readonly requestId?: string;
|
|
264
|
+
constructor(message: string, options: {
|
|
265
|
+
status: number;
|
|
266
|
+
code?: string;
|
|
267
|
+
details?: unknown;
|
|
268
|
+
requestId?: string;
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
export declare class Auctra {
|
|
272
|
+
private readonly apiKey;
|
|
273
|
+
private readonly baseUrl;
|
|
274
|
+
private readonly timeoutMs;
|
|
275
|
+
private readonly maxRetries;
|
|
276
|
+
private readonly fetchImpl;
|
|
277
|
+
constructor(options: AuctraClientOptions);
|
|
278
|
+
private request;
|
|
279
|
+
evaluateAction(input: EvaluateActionInput, options?: RequestOptions): Promise<EvaluateActionResponse>;
|
|
280
|
+
listIntents(): Promise<{
|
|
281
|
+
intents: Intent[];
|
|
282
|
+
}>;
|
|
283
|
+
createIntent(input: CreateIntentInput): Promise<{
|
|
284
|
+
intent: {
|
|
285
|
+
id: string;
|
|
286
|
+
title: string;
|
|
287
|
+
status: string;
|
|
288
|
+
};
|
|
289
|
+
}>;
|
|
290
|
+
getIntent(intentId: string): Promise<{
|
|
291
|
+
intent: IntentDetail;
|
|
292
|
+
}>;
|
|
293
|
+
getAuthorityGraph(): Promise<{
|
|
294
|
+
authority_graph: AuthorityGraph;
|
|
295
|
+
}>;
|
|
296
|
+
getActionEvaluation(actionRequestId: string): Promise<{
|
|
297
|
+
evaluation: ActionEvaluation;
|
|
298
|
+
}>;
|
|
299
|
+
getRootIntentChain(actionRequestId: string): Promise<{
|
|
300
|
+
root_intent_chain: RootIntentChain;
|
|
301
|
+
}>;
|
|
302
|
+
listAgents(): Promise<{
|
|
303
|
+
agents: Agent[];
|
|
304
|
+
}>;
|
|
305
|
+
getAgent(agentId: string): Promise<{
|
|
306
|
+
agent: Agent;
|
|
307
|
+
}>;
|
|
308
|
+
createAgent(input: CreateAgentInput): Promise<{
|
|
309
|
+
agent: Agent;
|
|
310
|
+
}>;
|
|
311
|
+
listDelegations(): Promise<{
|
|
312
|
+
delegations: Delegation[];
|
|
313
|
+
}>;
|
|
314
|
+
getDelegation(delegationId: string): Promise<{
|
|
315
|
+
delegation: Delegation;
|
|
316
|
+
}>;
|
|
317
|
+
createDelegation(input: CreateDelegationInput): Promise<{
|
|
318
|
+
delegation: Delegation;
|
|
319
|
+
}>;
|
|
320
|
+
revokeDelegation(delegationId: string): Promise<{
|
|
321
|
+
ok: true;
|
|
322
|
+
}>;
|
|
323
|
+
listActionRequests(): Promise<{
|
|
324
|
+
action_requests: ActionRequest[];
|
|
325
|
+
}>;
|
|
326
|
+
approveActionRequest(actionRequestId: string, approverUserId: string, reason?: string): Promise<{
|
|
327
|
+
ok: true;
|
|
328
|
+
decision: string;
|
|
329
|
+
reason: string;
|
|
330
|
+
}>;
|
|
331
|
+
rejectActionRequest(actionRequestId: string, approverUserId: string, reason?: string): Promise<{
|
|
332
|
+
ok: true;
|
|
333
|
+
decision: string;
|
|
334
|
+
reason: string;
|
|
335
|
+
}>;
|
|
336
|
+
escalateActionRequest(actionRequestId: string, approverUserId: string, reason?: string): Promise<{
|
|
337
|
+
ok: true;
|
|
338
|
+
decision: string;
|
|
339
|
+
reason: string;
|
|
340
|
+
}>;
|
|
341
|
+
private resolveActionRequest;
|
|
342
|
+
listPolicies(): Promise<{
|
|
343
|
+
policies: Policy[];
|
|
344
|
+
}>;
|
|
345
|
+
createPolicy(input: CreatePolicyInput): Promise<{
|
|
346
|
+
policy: Pick<Policy, "id" | "name" | "status" | "created_at">;
|
|
347
|
+
}>;
|
|
348
|
+
listAuditEvents(): Promise<{
|
|
349
|
+
audit_events: AuditEvent[];
|
|
350
|
+
}>;
|
|
351
|
+
listApiKeys(): Promise<{
|
|
352
|
+
api_keys: ApiKeySummary[];
|
|
353
|
+
}>;
|
|
354
|
+
}
|
|
355
|
+
//# 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,MAAM,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,kBAAkB,CAAC;AAClE,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,aAAa,GAAG,eAAe,GAAG,UAAU,CAAC;AACnF,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAC/D,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAE/D,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE;QACN,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,SAAS,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC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;IAInE,oBAAoB,CAAC,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;YAiB1E,IAAI;kBAAY,MAAM;gBAAU,MAAM;;IAbjD,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;YAazE,IAAI;kBAAY,MAAM;gBAAU,MAAM;;IATjD,qBAAqB,CAAC,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;YAS3E,IAAI;kBAAY,MAAM;gBAAU,MAAM;;YALzC,oBAAoB;IAa5B,YAAY,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAI/C,YAAY,CAChB,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC;QAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,QAAQ,GAAG,YAAY,CAAC,CAAA;KAAE,CAAC;IAiBvE,eAAe,IAAI,OAAO,CAAC;QAAE,YAAY,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC;IAI1D,WAAW,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;CAG5D"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
export const AUCTRA_SDK_VERSION = "0.3.0";
|
|
2
|
+
export class AuctraApiError extends Error {
|
|
3
|
+
status;
|
|
4
|
+
code;
|
|
5
|
+
details;
|
|
6
|
+
requestId;
|
|
7
|
+
constructor(message, options) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "AuctraApiError";
|
|
10
|
+
this.status = options.status;
|
|
11
|
+
this.code = options.code;
|
|
12
|
+
this.details = options.details;
|
|
13
|
+
this.requestId = options.requestId;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function retryDelay(response, attempt) {
|
|
17
|
+
const retryAfter = response?.headers.get("retry-after");
|
|
18
|
+
if (retryAfter) {
|
|
19
|
+
const seconds = Number(retryAfter);
|
|
20
|
+
if (Number.isFinite(seconds))
|
|
21
|
+
return Math.min(30_000, Math.max(0, seconds * 1_000));
|
|
22
|
+
const dateDelay = Date.parse(retryAfter) - Date.now();
|
|
23
|
+
if (Number.isFinite(dateDelay))
|
|
24
|
+
return Math.min(30_000, Math.max(0, dateDelay));
|
|
25
|
+
}
|
|
26
|
+
return Math.min(5_000, 150 * 2 ** attempt);
|
|
27
|
+
}
|
|
28
|
+
function wait(ms, signal) {
|
|
29
|
+
if (signal?.aborted)
|
|
30
|
+
return Promise.reject(signal.reason);
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const timeout = setTimeout(resolve, ms);
|
|
33
|
+
signal?.addEventListener("abort", () => {
|
|
34
|
+
clearTimeout(timeout);
|
|
35
|
+
reject(signal.reason);
|
|
36
|
+
}, { once: true });
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export class Auctra {
|
|
40
|
+
apiKey;
|
|
41
|
+
baseUrl;
|
|
42
|
+
timeoutMs;
|
|
43
|
+
maxRetries;
|
|
44
|
+
fetchImpl;
|
|
45
|
+
constructor(options) {
|
|
46
|
+
if (!options.apiKey.trim())
|
|
47
|
+
throw new Error("apiKey is required");
|
|
48
|
+
if (options.timeoutMs !== undefined && options.timeoutMs <= 0) {
|
|
49
|
+
throw new Error("timeoutMs must be greater than zero");
|
|
50
|
+
}
|
|
51
|
+
if (options.maxRetries !== undefined &&
|
|
52
|
+
(!Number.isInteger(options.maxRetries) || options.maxRetries < 0)) {
|
|
53
|
+
throw new Error("maxRetries must be a non-negative integer");
|
|
54
|
+
}
|
|
55
|
+
this.apiKey = options.apiKey;
|
|
56
|
+
this.baseUrl = (options.baseUrl ?? "https://console.auctra.tech").replace(/\/$/, "");
|
|
57
|
+
this.timeoutMs = options.timeoutMs ?? 10_000;
|
|
58
|
+
this.maxRetries = options.maxRetries ?? 2;
|
|
59
|
+
this.fetchImpl = options.fetch ?? globalThis.fetch;
|
|
60
|
+
if (!this.fetchImpl)
|
|
61
|
+
throw new Error("A fetch implementation is required");
|
|
62
|
+
}
|
|
63
|
+
async request(method, path, body, options = {}) {
|
|
64
|
+
const retryableRequest = method === "GET" || Boolean(options.idempotencyKey);
|
|
65
|
+
let lastError;
|
|
66
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt += 1) {
|
|
67
|
+
if (options.signal?.aborted)
|
|
68
|
+
throw options.signal.reason;
|
|
69
|
+
const timeoutSignal = AbortSignal.timeout(this.timeoutMs);
|
|
70
|
+
const signal = options.signal
|
|
71
|
+
? AbortSignal.any([options.signal, timeoutSignal])
|
|
72
|
+
: timeoutSignal;
|
|
73
|
+
let response;
|
|
74
|
+
try {
|
|
75
|
+
response = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
76
|
+
method,
|
|
77
|
+
signal,
|
|
78
|
+
headers: {
|
|
79
|
+
...(body !== undefined ? { "content-type": "application/json" } : {}),
|
|
80
|
+
...(options.idempotencyKey ? { "idempotency-key": options.idempotencyKey } : {}),
|
|
81
|
+
authorization: `Bearer ${this.apiKey}`,
|
|
82
|
+
"x-auctra-sdk-version": AUCTRA_SDK_VERSION,
|
|
83
|
+
},
|
|
84
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
85
|
+
});
|
|
86
|
+
const data = (await response.json().catch(() => ({})));
|
|
87
|
+
if (response.ok)
|
|
88
|
+
return data;
|
|
89
|
+
if (retryableRequest &&
|
|
90
|
+
(response.status === 429 || response.status >= 500) &&
|
|
91
|
+
attempt < this.maxRetries) {
|
|
92
|
+
await wait(retryDelay(response, attempt), options.signal);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
throw new AuctraApiError(typeof data.error === "string" ? data.error : `Auctra API error (${response.status})`, {
|
|
96
|
+
status: response.status,
|
|
97
|
+
code: typeof data.code === "string" ? data.code : undefined,
|
|
98
|
+
details: data.details,
|
|
99
|
+
requestId: response.headers.get("x-request-id") ?? undefined,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
lastError = error;
|
|
104
|
+
if (options.signal?.aborted)
|
|
105
|
+
throw options.signal.reason;
|
|
106
|
+
if (error instanceof AuctraApiError || !retryableRequest || attempt >= this.maxRetries) {
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
await wait(retryDelay(response, attempt), options.signal);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
throw lastError;
|
|
113
|
+
}
|
|
114
|
+
async evaluateAction(input, options = {}) {
|
|
115
|
+
const idempotencyKey = options.idempotencyKey ?? crypto.randomUUID();
|
|
116
|
+
return this.request("POST", "/v1/action-requests/evaluate", {
|
|
117
|
+
agent_id: input.agentId,
|
|
118
|
+
action_type: input.actionType,
|
|
119
|
+
payload: input.payload ?? {},
|
|
120
|
+
claimed_intent_id: input.claimedIntentId,
|
|
121
|
+
parent_action_id: input.parentActionId,
|
|
122
|
+
actor: input.actor
|
|
123
|
+
? {
|
|
124
|
+
id: input.actor.id,
|
|
125
|
+
type: input.actor.type,
|
|
126
|
+
name: input.actor.name,
|
|
127
|
+
}
|
|
128
|
+
: undefined,
|
|
129
|
+
action: input.action
|
|
130
|
+
? {
|
|
131
|
+
target: input.action.target,
|
|
132
|
+
description: input.action.description,
|
|
133
|
+
risk_level: input.action.riskLevel,
|
|
134
|
+
metadata: input.action.metadata,
|
|
135
|
+
}
|
|
136
|
+
: undefined,
|
|
137
|
+
}, { ...options, idempotencyKey });
|
|
138
|
+
}
|
|
139
|
+
async listIntents() {
|
|
140
|
+
return this.request("GET", "/v1/intents");
|
|
141
|
+
}
|
|
142
|
+
async createIntent(input) {
|
|
143
|
+
return this.request("POST", "/v1/intents", {
|
|
144
|
+
title: input.title,
|
|
145
|
+
description: input.description,
|
|
146
|
+
intent_type: input.intentType,
|
|
147
|
+
risk_level: input.riskLevel,
|
|
148
|
+
max_risk_level: input.maxRiskLevel,
|
|
149
|
+
expires_at: input.expiresAt,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
async getIntent(intentId) {
|
|
153
|
+
return this.request("GET", `/v1/intents/${encodeURIComponent(intentId)}`);
|
|
154
|
+
}
|
|
155
|
+
async getAuthorityGraph() {
|
|
156
|
+
return this.request("GET", "/v1/authority/graph");
|
|
157
|
+
}
|
|
158
|
+
async getActionEvaluation(actionRequestId) {
|
|
159
|
+
return this.request("GET", `/v1/action-requests/${encodeURIComponent(actionRequestId)}/evaluation`);
|
|
160
|
+
}
|
|
161
|
+
async getRootIntentChain(actionRequestId) {
|
|
162
|
+
return this.request("GET", `/v1/action-requests/${encodeURIComponent(actionRequestId)}/root-intent`);
|
|
163
|
+
}
|
|
164
|
+
async listAgents() {
|
|
165
|
+
return this.request("GET", "/v1/agents");
|
|
166
|
+
}
|
|
167
|
+
async getAgent(agentId) {
|
|
168
|
+
return this.request("GET", `/v1/agents/${encodeURIComponent(agentId)}`);
|
|
169
|
+
}
|
|
170
|
+
async createAgent(input) {
|
|
171
|
+
return this.request("POST", "/v1/agents", {
|
|
172
|
+
name: input.name,
|
|
173
|
+
model_provider: input.modelProvider,
|
|
174
|
+
model_name: input.modelName,
|
|
175
|
+
description: input.description,
|
|
176
|
+
environment: input.environment,
|
|
177
|
+
authority_level: input.authorityLevel,
|
|
178
|
+
sponsor_user_id: input.sponsorUserId,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
async listDelegations() {
|
|
182
|
+
return this.request("GET", "/v1/delegations");
|
|
183
|
+
}
|
|
184
|
+
async getDelegation(delegationId) {
|
|
185
|
+
return this.request("GET", `/v1/delegations/${encodeURIComponent(delegationId)}`);
|
|
186
|
+
}
|
|
187
|
+
async createDelegation(input) {
|
|
188
|
+
return this.request("POST", "/v1/delegations", {
|
|
189
|
+
agent_id: input.agentId,
|
|
190
|
+
action_types: input.actionTypes,
|
|
191
|
+
valid_until: input.validUntil,
|
|
192
|
+
max_amount: input.maxAmount,
|
|
193
|
+
max_count: input.maxCount,
|
|
194
|
+
environment: input.environment,
|
|
195
|
+
currency: input.currency,
|
|
196
|
+
delegator_user_id: input.delegatorUserId,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
async revokeDelegation(delegationId) {
|
|
200
|
+
return this.request("POST", `/v1/delegations/${encodeURIComponent(delegationId)}/revoke`, {});
|
|
201
|
+
}
|
|
202
|
+
async listActionRequests() {
|
|
203
|
+
return this.request("GET", "/v1/action-requests");
|
|
204
|
+
}
|
|
205
|
+
async approveActionRequest(actionRequestId, approverUserId, reason) {
|
|
206
|
+
return this.resolveActionRequest(actionRequestId, "approve", approverUserId, reason);
|
|
207
|
+
}
|
|
208
|
+
async rejectActionRequest(actionRequestId, approverUserId, reason) {
|
|
209
|
+
return this.resolveActionRequest(actionRequestId, "reject", approverUserId, reason);
|
|
210
|
+
}
|
|
211
|
+
async escalateActionRequest(actionRequestId, approverUserId, reason) {
|
|
212
|
+
return this.resolveActionRequest(actionRequestId, "escalate", approverUserId, reason);
|
|
213
|
+
}
|
|
214
|
+
async resolveActionRequest(actionRequestId, action, approverUserId, reason) {
|
|
215
|
+
return this.request("POST", `/v1/action-requests/${encodeURIComponent(actionRequestId)}/${action}`, { reason, approver_user_id: approverUserId });
|
|
216
|
+
}
|
|
217
|
+
async listPolicies() {
|
|
218
|
+
return this.request("GET", "/v1/policies");
|
|
219
|
+
}
|
|
220
|
+
async createPolicy(input) {
|
|
221
|
+
return this.request("POST", "/v1/policies", {
|
|
222
|
+
name: input.name,
|
|
223
|
+
description: input.description,
|
|
224
|
+
policy_type: input.policyType,
|
|
225
|
+
status: input.status,
|
|
226
|
+
priority: input.priority,
|
|
227
|
+
action_type: input.actionType,
|
|
228
|
+
amount_greater_than: input.amountGreaterThan,
|
|
229
|
+
resource_sensitivity: input.resourceSensitivity,
|
|
230
|
+
external_recipient: input.externalRecipient,
|
|
231
|
+
environment: input.environment,
|
|
232
|
+
decision: input.decision,
|
|
233
|
+
approver_role: input.approverRole,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
async listAuditEvents() {
|
|
237
|
+
return this.request("GET", "/v1/audit-events");
|
|
238
|
+
}
|
|
239
|
+
async listApiKeys() {
|
|
240
|
+
return this.request("GET", "/v1/api-keys");
|
|
241
|
+
}
|
|
242
|
+
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auctra/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Authority delegation SDK for AI agents — evaluate agent actions against delegated authority and org policies",
|
|
5
5
|
"homepage": "https://auctra.tech/docs",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/Matik103/auctra/issues"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"main": "./dist/cjs/index.js",
|
|
12
|
+
"module": "./dist/esm/index.js",
|
|
13
|
+
"types": "./dist/esm/index.d.ts",
|
|
12
14
|
"exports": {
|
|
13
15
|
".": {
|
|
14
|
-
"types": "./dist/index.d.ts",
|
|
15
|
-
"import": "./dist/index.js"
|
|
16
|
+
"types": "./dist/esm/index.d.ts",
|
|
17
|
+
"import": "./dist/esm/index.js",
|
|
18
|
+
"require": "./dist/cjs/index.js"
|
|
16
19
|
}
|
|
17
20
|
},
|
|
18
21
|
"files": [
|
|
19
22
|
"dist",
|
|
20
|
-
"
|
|
23
|
+
"src",
|
|
24
|
+
"README.md",
|
|
25
|
+
"CHANGELOG.md",
|
|
26
|
+
"LICENSE"
|
|
21
27
|
],
|
|
22
28
|
"scripts": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
29
|
+
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
30
|
+
"build": "npm run clean && tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && node scripts/finalize-build.mjs",
|
|
31
|
+
"test": "npm run build && node --test test/*.test.mjs",
|
|
32
|
+
"check": "npm run test && npm pack --dry-run",
|
|
33
|
+
"publish:local": "npm publish --access public --provenance=false",
|
|
34
|
+
"prepublishOnly": "npm run check"
|
|
25
35
|
},
|
|
26
36
|
"repository": {
|
|
27
37
|
"type": "git",
|