@auctra/sdk 0.1.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 +73 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +87 -0
- package/package.json +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# @auctra/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for [Auctra](https://auctra.tech) — authority infrastructure for AI agents.
|
|
4
|
+
|
|
5
|
+
Evaluate every agent action against delegated authority and org policies before execution.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @auctra/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Auctra } from "@auctra/sdk";
|
|
17
|
+
|
|
18
|
+
const auctra = new Auctra({
|
|
19
|
+
apiKey: process.env.AUCTRA_API_KEY!,
|
|
20
|
+
// baseUrl defaults to https://console.auctra.tech
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const decision = await auctra.evaluateAction({
|
|
24
|
+
agentId: "your-agent-uuid",
|
|
25
|
+
actionType: "send_payment",
|
|
26
|
+
payload: { amount: 1200, currency: "USD" },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (decision.decision === "allowed") {
|
|
30
|
+
// proceed with action
|
|
31
|
+
} else if (decision.decision === "require_approval") {
|
|
32
|
+
// pause for human review
|
|
33
|
+
console.log(decision.reason, decision.action_request_id);
|
|
34
|
+
} else {
|
|
35
|
+
throw new Error(decision.reason);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## API
|
|
40
|
+
|
|
41
|
+
| Method | Description |
|
|
42
|
+
|--------|-------------|
|
|
43
|
+
| `evaluateAction(input)` | Check authority before an agent acts |
|
|
44
|
+
| `listAgents()` | List registered agents |
|
|
45
|
+
| `createAgent(input)` | Register a new agent |
|
|
46
|
+
| `listDelegations()` | List authority delegations |
|
|
47
|
+
| `createDelegation(input)` | Grant bounded authority |
|
|
48
|
+
| `revokeDelegation(id)` | Revoke a delegation |
|
|
49
|
+
| `listActionRequests()` | List recent evaluations |
|
|
50
|
+
| `approveActionRequest(id)` | Approve pending action |
|
|
51
|
+
| `rejectActionRequest(id)` | Reject pending action |
|
|
52
|
+
| `escalateActionRequest(id)` | Escalate for review |
|
|
53
|
+
| `listPolicies()` | List org policies |
|
|
54
|
+
| `listAuditEvents()` | List audit ledger events |
|
|
55
|
+
|
|
56
|
+
## Get an API key
|
|
57
|
+
|
|
58
|
+
1. Sign in to the [Auctra console](https://console.auctra.tech/auth/login)
|
|
59
|
+
2. Go to **API Keys** → **Create API key**
|
|
60
|
+
3. Use a key with `write` permission for `evaluateAction`
|
|
61
|
+
|
|
62
|
+
## Publish to npm
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
cd packages/sdk
|
|
66
|
+
npm login # one-time, needs npm account with @auctra scope access
|
|
67
|
+
npm run build
|
|
68
|
+
npm publish --access public
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or from repo root: `npm run publish:sdk`
|
|
72
|
+
|
|
73
|
+
Set `NPM_TOKEN` in GitHub Actions secrets if you add a publish workflow later.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export type EvaluateActionInput = {
|
|
2
|
+
agentId: string;
|
|
3
|
+
actionType: string;
|
|
4
|
+
payload?: Record<string, unknown>;
|
|
5
|
+
};
|
|
6
|
+
export type EvaluateActionResponse = {
|
|
7
|
+
decision: "allowed" | "blocked" | "require_approval";
|
|
8
|
+
risk_score: number;
|
|
9
|
+
reason: string;
|
|
10
|
+
delegation_id: string | null;
|
|
11
|
+
delegator: string | null;
|
|
12
|
+
sponsor: string;
|
|
13
|
+
matched_policies: string[];
|
|
14
|
+
action_request_id: string;
|
|
15
|
+
};
|
|
16
|
+
export type AuctraClientOptions = {
|
|
17
|
+
apiKey: string;
|
|
18
|
+
baseUrl?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare class Auctra {
|
|
21
|
+
private apiKey;
|
|
22
|
+
private baseUrl;
|
|
23
|
+
constructor(options: AuctraClientOptions);
|
|
24
|
+
private request;
|
|
25
|
+
evaluateAction(input: EvaluateActionInput): Promise<EvaluateActionResponse>;
|
|
26
|
+
listAgents(): Promise<{
|
|
27
|
+
agents: unknown[];
|
|
28
|
+
}>;
|
|
29
|
+
getAgent(agentId: string): Promise<{
|
|
30
|
+
agent: unknown;
|
|
31
|
+
}>;
|
|
32
|
+
createAgent(input: {
|
|
33
|
+
name: string;
|
|
34
|
+
modelProvider: string;
|
|
35
|
+
modelName: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
environment?: string;
|
|
38
|
+
authorityLevel?: string;
|
|
39
|
+
sponsorUserId?: string;
|
|
40
|
+
}): Promise<unknown>;
|
|
41
|
+
listDelegations(): Promise<{
|
|
42
|
+
delegations: unknown[];
|
|
43
|
+
}>;
|
|
44
|
+
createDelegation(input: {
|
|
45
|
+
agentId: string;
|
|
46
|
+
actionTypes: string[];
|
|
47
|
+
validUntil: string;
|
|
48
|
+
maxAmount?: number;
|
|
49
|
+
currency?: string;
|
|
50
|
+
delegatorUserId?: string;
|
|
51
|
+
}): Promise<unknown>;
|
|
52
|
+
revokeDelegation(delegationId: string): Promise<unknown>;
|
|
53
|
+
listActionRequests(): Promise<{
|
|
54
|
+
action_requests: unknown[];
|
|
55
|
+
}>;
|
|
56
|
+
approveActionRequest(actionRequestId: string, reason?: string): Promise<unknown>;
|
|
57
|
+
rejectActionRequest(actionRequestId: string, reason?: string): Promise<unknown>;
|
|
58
|
+
escalateActionRequest(actionRequestId: string, reason?: string): Promise<unknown>;
|
|
59
|
+
listPolicies(): Promise<{
|
|
60
|
+
policies: unknown[];
|
|
61
|
+
}>;
|
|
62
|
+
listAuditEvents(): Promise<{
|
|
63
|
+
audit_events: unknown[];
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,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;CACnC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,SAAS,GAAG,SAAS,GAAG,kBAAkB,CAAC;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,mBAAmB;YAK1B,OAAO;IAqBf,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAQ3E,UAAU;gBACgB,OAAO,EAAE;;IAGnC,QAAQ,CAAC,OAAO,EAAE,MAAM;eACC,OAAO;;IAGhC,WAAW,CAAC,KAAK,EAAE;QACvB,IAAI,EAAE,MAAM,CAAC;QACb,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB;IAYK,eAAe;qBACgB,OAAO,EAAE;;IAGxC,gBAAgB,CAAC,KAAK,EAAE;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B;IAWK,gBAAgB,CAAC,YAAY,EAAE,MAAM;IAIrC,kBAAkB;yBACiB,OAAO,EAAE;;IAG5C,oBAAoB,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAM7D,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAM5D,qBAAqB,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAM9D,YAAY;kBACgB,OAAO,EAAE;;IAGrC,eAAe;sBACiB,OAAO,EAAE;;CAEhD"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export class Auctra {
|
|
2
|
+
apiKey;
|
|
3
|
+
baseUrl;
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.apiKey = options.apiKey;
|
|
6
|
+
this.baseUrl = (options.baseUrl ?? "https://console.auctra.tech").replace(/\/$/, "");
|
|
7
|
+
}
|
|
8
|
+
async request(method, path, body) {
|
|
9
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
10
|
+
method,
|
|
11
|
+
headers: {
|
|
12
|
+
...(body ? { "content-type": "application/json" } : {}),
|
|
13
|
+
authorization: `Bearer ${this.apiKey}`,
|
|
14
|
+
},
|
|
15
|
+
...(body ? { body: JSON.stringify(body) } : {}),
|
|
16
|
+
});
|
|
17
|
+
const data = await response.json();
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new Error(data.error ?? `Auctra API error (${response.status})`);
|
|
20
|
+
}
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
async evaluateAction(input) {
|
|
24
|
+
return this.request("POST", "/v1/action-requests/evaluate", {
|
|
25
|
+
agent_id: input.agentId,
|
|
26
|
+
action_type: input.actionType,
|
|
27
|
+
payload: input.payload ?? {},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async listAgents() {
|
|
31
|
+
return this.request("GET", "/v1/agents");
|
|
32
|
+
}
|
|
33
|
+
async getAgent(agentId) {
|
|
34
|
+
return this.request("GET", `/v1/agents/${agentId}`);
|
|
35
|
+
}
|
|
36
|
+
async createAgent(input) {
|
|
37
|
+
return this.request("POST", "/v1/agents", {
|
|
38
|
+
name: input.name,
|
|
39
|
+
model_provider: input.modelProvider,
|
|
40
|
+
model_name: input.modelName,
|
|
41
|
+
description: input.description,
|
|
42
|
+
environment: input.environment,
|
|
43
|
+
authority_level: input.authorityLevel,
|
|
44
|
+
sponsor_user_id: input.sponsorUserId,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async listDelegations() {
|
|
48
|
+
return this.request("GET", "/v1/delegations");
|
|
49
|
+
}
|
|
50
|
+
async createDelegation(input) {
|
|
51
|
+
return this.request("POST", "/v1/delegations", {
|
|
52
|
+
agent_id: input.agentId,
|
|
53
|
+
action_types: input.actionTypes,
|
|
54
|
+
valid_until: input.validUntil,
|
|
55
|
+
max_amount: input.maxAmount,
|
|
56
|
+
currency: input.currency,
|
|
57
|
+
delegator_user_id: input.delegatorUserId,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async revokeDelegation(delegationId) {
|
|
61
|
+
return this.request("POST", `/v1/delegations/${delegationId}/revoke`, {});
|
|
62
|
+
}
|
|
63
|
+
async listActionRequests() {
|
|
64
|
+
return this.request("GET", "/v1/action-requests");
|
|
65
|
+
}
|
|
66
|
+
async approveActionRequest(actionRequestId, reason) {
|
|
67
|
+
return this.request("POST", `/v1/action-requests/${actionRequestId}/approve`, {
|
|
68
|
+
reason,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async rejectActionRequest(actionRequestId, reason) {
|
|
72
|
+
return this.request("POST", `/v1/action-requests/${actionRequestId}/reject`, {
|
|
73
|
+
reason,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async escalateActionRequest(actionRequestId, reason) {
|
|
77
|
+
return this.request("POST", `/v1/action-requests/${actionRequestId}/escalate`, {
|
|
78
|
+
reason,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
async listPolicies() {
|
|
82
|
+
return this.request("GET", "/v1/policies");
|
|
83
|
+
}
|
|
84
|
+
async listAuditEvents() {
|
|
85
|
+
return this.request("GET", "/v1/audit-events");
|
|
86
|
+
}
|
|
87
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@auctra/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Authority delegation SDK for AI agents — evaluate agent actions against delegated authority and org policies",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["dist", "README.md"],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/Matik103/auctra.git",
|
|
22
|
+
"directory": "packages/sdk"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org"
|
|
27
|
+
},
|
|
28
|
+
"keywords": ["auctra", "ai-agents", "authority", "delegation", "governance", "agents"],
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.8.3"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18"
|
|
35
|
+
}
|
|
36
|
+
}
|