@auctra/sdk 0.1.1 → 0.2.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 CHANGED
@@ -1,9 +1,15 @@
1
1
  # @auctra/sdk
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@auctra/sdk.svg)](https://www.npmjs.com/package/@auctra/sdk)
4
+
3
5
  Official TypeScript SDK for [Auctra](https://auctra.tech) — authority infrastructure for AI agents.
4
6
 
5
7
  Evaluate every agent action against delegated authority and org policies before execution.
6
8
 
9
+ - **Console:** https://console.auctra.tech
10
+ - **Docs:** https://auctra.tech/docs
11
+ - **API base URL:** `https://console.auctra.tech` (default — no `baseUrl` needed)
12
+
7
13
  ## Install
8
14
 
9
15
  ```bash
@@ -17,14 +23,18 @@ import { Auctra } from "@auctra/sdk";
17
23
 
18
24
  const auctra = new Auctra({
19
25
  apiKey: process.env.AUCTRA_API_KEY!,
20
- // baseUrl defaults to https://console.auctra.tech
26
+ timeoutMs: 10_000,
27
+ maxRetries: 2,
21
28
  });
22
29
 
23
- const decision = await auctra.evaluateAction({
24
- agentId: "your-agent-uuid",
25
- actionType: "send_payment",
26
- payload: { amount: 1200, currency: "USD" },
27
- });
30
+ const decision = await auctra.evaluateAction(
31
+ {
32
+ agentId: "your-agent-uuid",
33
+ actionType: "send_payment",
34
+ payload: { amount: 1200, currency: "USD" },
35
+ },
36
+ { idempotencyKey: crypto.randomUUID() },
37
+ );
28
38
 
29
39
  if (decision.decision === "allowed") {
30
40
  // proceed with action
@@ -36,38 +46,50 @@ if (decision.decision === "allowed") {
36
46
  }
37
47
  ```
38
48
 
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
49
  ## Get an API key
57
50
 
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`
51
+ 1. [Sign up](https://console.auctra.tech/auth/signup) and create an organization
52
+ 2. Register an agent and delegate scoped authority
53
+ 3. Open [API Keys](https://console.auctra.tech/console/api-keys) **Create API key**
54
+ 4. Use a key with `write` permission for `evaluateAction`
55
+
56
+ ## API
61
57
 
62
- ## Publish to npm
58
+ | Method | Description |
59
+ | ------------------------------------------- | ------------------------------------------------- |
60
+ | `evaluateAction(input, options)` | Idempotently check authority before an agent acts |
61
+ | `listAgents()` | List registered agents |
62
+ | `createAgent(input)` | Register a new agent |
63
+ | `listDelegations()` | List authority delegations |
64
+ | `createDelegation(input)` | Grant bounded authority |
65
+ | `revokeDelegation(id)` | Revoke a delegation |
66
+ | `listActionRequests()` | List recent evaluations |
67
+ | `approveActionRequest(id, approverUserId)` | Approve as an accountable reviewer |
68
+ | `rejectActionRequest(id, approverUserId)` | Reject as an accountable reviewer |
69
+ | `escalateActionRequest(id, approverUserId)` | Escalate as an accountable reviewer |
70
+ | `listPolicies()` | List org policies |
71
+ | `listAuditEvents()` | List audit ledger events |
72
+
73
+ ## REST API (curl)
63
74
 
64
75
  ```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
76
+ curl -X POST https://console.auctra.tech/v1/action-requests/evaluate \
77
+ -H "Authorization: Bearer YOUR_API_KEY" \
78
+ -H "Idempotency-Key: $(uuidgen)" \
79
+ -H "Content-Type: application/json" \
80
+ -d '{
81
+ "agentId": "your-agent-uuid",
82
+ "actionType": "send_payment",
83
+ "payload": { "amount": 100, "currency": "USD" }
84
+ }'
69
85
  ```
70
86
 
71
- Or from repo root: `npm run publish:sdk`
87
+ The SDK applies bounded retries only to reads and idempotent evaluations. API failures throw
88
+ `AuctraApiError` with `status`, optional structured `details`, and the server `requestId`.
89
+
90
+ The machine-readable OpenAPI 3.1 contract is available at
91
+ `https://console.auctra.tech/v1/openapi.json`.
92
+
93
+ ## License
72
94
 
73
- Set `NPM_TOKEN` in GitHub Actions secrets if you add a publish workflow later.
95
+ MIT
package/dist/index.d.ts CHANGED
@@ -16,18 +16,81 @@ export type EvaluateActionResponse = {
16
16
  export type AuctraClientOptions = {
17
17
  apiKey: string;
18
18
  baseUrl?: string;
19
+ timeoutMs?: number;
20
+ maxRetries?: number;
21
+ fetch?: typeof fetch;
19
22
  };
23
+ export type Agent = {
24
+ id: string;
25
+ identity_id: string;
26
+ name: string;
27
+ description: string | null;
28
+ model_provider: string;
29
+ model_name: string;
30
+ environment: "dev" | "staging" | "production";
31
+ authority_level: "low" | "medium" | "high" | "critical";
32
+ status: "active" | "suspended" | "restricted" | "compromised";
33
+ trust_rating: number;
34
+ sponsor: {
35
+ id: string;
36
+ full_name: string;
37
+ email: string;
38
+ };
39
+ created_at: string;
40
+ };
41
+ export type Delegation = {
42
+ id: string;
43
+ agent: {
44
+ id: string;
45
+ name: string;
46
+ };
47
+ delegator: {
48
+ id: string;
49
+ full_name: string;
50
+ email: string;
51
+ };
52
+ scope: {
53
+ action_types: string[];
54
+ };
55
+ limits: {
56
+ max_amount?: number;
57
+ currency?: string;
58
+ };
59
+ valid_from: string;
60
+ valid_until: string;
61
+ status: "active" | "revoked" | "expired";
62
+ is_active: boolean;
63
+ created_at: string;
64
+ };
65
+ export declare class AuctraApiError extends Error {
66
+ readonly status: number;
67
+ readonly code?: string;
68
+ readonly details?: unknown;
69
+ readonly requestId?: string;
70
+ constructor(message: string, options: {
71
+ status: number;
72
+ code?: string;
73
+ details?: unknown;
74
+ requestId?: string;
75
+ });
76
+ }
20
77
  export declare class Auctra {
21
78
  private apiKey;
22
79
  private baseUrl;
80
+ private timeoutMs;
81
+ private maxRetries;
82
+ private fetchImpl;
23
83
  constructor(options: AuctraClientOptions);
24
84
  private request;
25
- evaluateAction(input: EvaluateActionInput): Promise<EvaluateActionResponse>;
85
+ evaluateAction(input: EvaluateActionInput, options?: {
86
+ idempotencyKey?: string;
87
+ signal?: AbortSignal;
88
+ }): Promise<EvaluateActionResponse>;
26
89
  listAgents(): Promise<{
27
- agents: unknown[];
90
+ agents: Agent[];
28
91
  }>;
29
92
  getAgent(agentId: string): Promise<{
30
- agent: unknown;
93
+ agent: Agent;
31
94
  }>;
32
95
  createAgent(input: {
33
96
  name: string;
@@ -39,7 +102,7 @@ export declare class Auctra {
39
102
  sponsorUserId?: string;
40
103
  }): Promise<unknown>;
41
104
  listDelegations(): Promise<{
42
- delegations: unknown[];
105
+ delegations: Delegation[];
43
106
  }>;
44
107
  createDelegation(input: {
45
108
  agentId: string;
@@ -53,9 +116,9 @@ export declare class Auctra {
53
116
  listActionRequests(): Promise<{
54
117
  action_requests: unknown[];
55
118
  }>;
56
- approveActionRequest(actionRequestId: string, reason?: string): Promise<unknown>;
57
- rejectActionRequest(actionRequestId: string, reason?: string): Promise<unknown>;
58
- escalateActionRequest(actionRequestId: string, reason?: string): Promise<unknown>;
119
+ approveActionRequest(actionRequestId: string, approverUserId: string, reason?: string): Promise<unknown>;
120
+ rejectActionRequest(actionRequestId: string, approverUserId: string, reason?: string): Promise<unknown>;
121
+ escalateActionRequest(actionRequestId: string, approverUserId: string, reason?: string): Promise<unknown>;
59
122
  listPolicies(): Promise<{
60
123
  policies: unknown[];
61
124
  }>;
@@ -1 +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,C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;qBACgB,UAAU,EAAE;;IAG3C,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,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAOrF,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAOpF,qBAAqB,CAAC,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAOtF,YAAY;kBACgB,OAAO,EAAE;;IAGrC,eAAe;sBACiB,OAAO,EAAE;;CAEhD"}
package/dist/index.js CHANGED
@@ -1,31 +1,84 @@
1
+ export class AuctraApiError extends Error {
2
+ status;
3
+ code;
4
+ details;
5
+ requestId;
6
+ constructor(message, options) {
7
+ super(message);
8
+ this.name = "AuctraApiError";
9
+ this.status = options.status;
10
+ this.code = options.code;
11
+ this.details = options.details;
12
+ this.requestId = options.requestId;
13
+ }
14
+ }
1
15
  export class Auctra {
2
16
  apiKey;
3
17
  baseUrl;
18
+ timeoutMs;
19
+ maxRetries;
20
+ fetchImpl;
4
21
  constructor(options) {
5
22
  this.apiKey = options.apiKey;
6
23
  this.baseUrl = (options.baseUrl ?? "https://console.auctra.tech").replace(/\/$/, "");
24
+ this.timeoutMs = options.timeoutMs ?? 10_000;
25
+ this.maxRetries = options.maxRetries ?? 2;
26
+ this.fetchImpl = options.fetch ?? globalThis.fetch;
27
+ if (!this.fetchImpl)
28
+ throw new Error("A fetch implementation is required");
7
29
  }
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})`);
30
+ async request(method, path, body, options = {}) {
31
+ const retryableRequest = method === "GET" || Boolean(options.idempotencyKey);
32
+ let lastError;
33
+ for (let attempt = 0; attempt <= this.maxRetries; attempt += 1) {
34
+ const timeoutSignal = AbortSignal.timeout(this.timeoutMs);
35
+ const signal = options.signal
36
+ ? AbortSignal.any([options.signal, timeoutSignal])
37
+ : timeoutSignal;
38
+ try {
39
+ const response = await this.fetchImpl(`${this.baseUrl}${path}`, {
40
+ method,
41
+ signal,
42
+ headers: {
43
+ ...(body ? { "content-type": "application/json" } : {}),
44
+ ...(options.idempotencyKey ? { "idempotency-key": options.idempotencyKey } : {}),
45
+ authorization: `Bearer ${this.apiKey}`,
46
+ "x-auctra-sdk-version": "0.2",
47
+ },
48
+ ...(body ? { body: JSON.stringify(body) } : {}),
49
+ });
50
+ const data = (await response.json().catch(() => ({})));
51
+ if (response.ok)
52
+ return data;
53
+ const retryableResponse = response.status === 429 || response.status >= 500;
54
+ if (retryableRequest && retryableResponse && attempt < this.maxRetries) {
55
+ await new Promise((resolve) => setTimeout(resolve, 150 * 2 ** attempt));
56
+ continue;
57
+ }
58
+ throw new AuctraApiError(typeof data.error === "string" ? data.error : `Auctra API error (${response.status})`, {
59
+ status: response.status,
60
+ code: typeof data.code === "string" ? data.code : undefined,
61
+ details: data.details,
62
+ requestId: response.headers.get("x-request-id") ?? undefined,
63
+ });
64
+ }
65
+ catch (error) {
66
+ lastError = error;
67
+ if (error instanceof AuctraApiError || !retryableRequest || attempt >= this.maxRetries) {
68
+ throw error;
69
+ }
70
+ await new Promise((resolve) => setTimeout(resolve, 150 * 2 ** attempt));
71
+ }
20
72
  }
21
- return data;
73
+ throw lastError;
22
74
  }
23
- async evaluateAction(input) {
75
+ async evaluateAction(input, options = {}) {
76
+ const idempotencyKey = options.idempotencyKey ?? crypto.randomUUID();
24
77
  return this.request("POST", "/v1/action-requests/evaluate", {
25
78
  agent_id: input.agentId,
26
79
  action_type: input.actionType,
27
80
  payload: input.payload ?? {},
28
- });
81
+ }, { ...options, idempotencyKey });
29
82
  }
30
83
  async listAgents() {
31
84
  return this.request("GET", "/v1/agents");
@@ -63,19 +116,22 @@ export class Auctra {
63
116
  async listActionRequests() {
64
117
  return this.request("GET", "/v1/action-requests");
65
118
  }
66
- async approveActionRequest(actionRequestId, reason) {
119
+ async approveActionRequest(actionRequestId, approverUserId, reason) {
67
120
  return this.request("POST", `/v1/action-requests/${actionRequestId}/approve`, {
68
121
  reason,
122
+ approver_user_id: approverUserId,
69
123
  });
70
124
  }
71
- async rejectActionRequest(actionRequestId, reason) {
125
+ async rejectActionRequest(actionRequestId, approverUserId, reason) {
72
126
  return this.request("POST", `/v1/action-requests/${actionRequestId}/reject`, {
73
127
  reason,
128
+ approver_user_id: approverUserId,
74
129
  });
75
130
  }
76
- async escalateActionRequest(actionRequestId, reason) {
131
+ async escalateActionRequest(actionRequestId, approverUserId, reason) {
77
132
  return this.request("POST", `/v1/action-requests/${actionRequestId}/escalate`, {
78
133
  reason,
134
+ approver_user_id: approverUserId,
79
135
  });
80
136
  }
81
137
  async listPolicies() {
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@auctra/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Authority delegation SDK for AI agents — evaluate agent actions against delegated authority and org policies",
5
+ "homepage": "https://auctra.tech/docs",
6
+ "bugs": {
7
+ "url": "https://github.com/Matik103/auctra/issues"
8
+ },
5
9
  "type": "module",
6
10
  "main": "./dist/index.js",
7
11
  "types": "./dist/index.d.ts",
@@ -11,7 +15,10 @@
11
15
  "import": "./dist/index.js"
12
16
  }
13
17
  },
14
- "files": ["dist", "README.md"],
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
15
22
  "scripts": {
16
23
  "build": "tsc",
17
24
  "prepublishOnly": "npm run build"
@@ -25,12 +32,19 @@
25
32
  "access": "public",
26
33
  "registry": "https://registry.npmjs.org"
27
34
  },
28
- "keywords": ["auctra", "ai-agents", "authority", "delegation", "governance", "agents"],
35
+ "keywords": [
36
+ "auctra",
37
+ "ai-agents",
38
+ "authority",
39
+ "delegation",
40
+ "governance",
41
+ "agents"
42
+ ],
29
43
  "license": "MIT",
30
44
  "devDependencies": {
31
45
  "typescript": "^5.8.3"
32
46
  },
33
47
  "engines": {
34
- "node": ">=18"
48
+ "node": ">=20"
35
49
  }
36
50
  }