@auctra/sdk 0.7.20 → 0.7.21

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.21
4
+
5
+ **Docs — first-call samples match the live gates**
6
+
7
+ - Finance samples send the same amount on `payload.amount` and `metadata.amount`.
8
+ - The `execute_sql` sample sets the action target to the authorized scope and uses a grant with no dollar cap.
9
+
3
10
  ## 0.7.20
4
11
 
5
12
  **Interop — OpenAPI method constraints on catalog mapping**
package/README.md CHANGED
@@ -53,8 +53,10 @@ There is **no** public `createDelegation()` or `evaluateAction()`.
53
53
 
54
54
  ## Quick start
55
55
 
56
+ Create the key in the console. Use an admin key for `authority.issue` and `createIntent`, and a write key for `action.execute`. Register the agent in Agents first, with a human sponsor. The model name is inventory. Auctra does not call it. HTTP 402 `plan_agent_limit` means the plan is full (Startup allows 25 agents): reuse one. Keep one live grant on that agent. The sample below is one finance action. The same client calls cover data access, messages, infrastructure, workflow, and tools. When a call fails, read `decision.reason` and `AuctraApiError.status` / `code`. The fix list is [Roadblocks](https://www.auctra.tech/docs#start-roadblocks): 402 `plan_agent_limit`, `plan_intent_limit`, 403 without an admin key, no grant for the action type, missing anchor token, `PROVENANCE_REQUIRED`, a hard limit (blocked, not queued), `SQL_SCOPE_EXCEEDED`, `require_approval`, `WORKLOAD_BIND_REQUIRED`, `ENVIRONMENT_MISMATCH`, and HTTP 409 on a second lease consume. `currently_authorized: false` on evidence verify is expected.
57
+
56
58
  ```typescript
57
- import { Auctra } from "@auctra/sdk";
59
+ import { Auctra, withExecutionLease } from "@auctra/sdk";
58
60
 
59
61
  const auctra = new Auctra({
60
62
  apiKey: process.env.AUCTRA_API_KEY!,
@@ -69,51 +71,65 @@ const expiresAt = new Date(Date.now() + 30 * 864e5).toISOString();
69
71
  const { authority } = await auctra.authority.issue({
70
72
  subject: agentId,
71
73
  capabilities: ["send_payment"],
72
- constraints: { maxAmount: 1200, currency: "USD" },
74
+ constraints: { maxAmount: 20, currency: "USD" },
73
75
  expiresAt,
74
76
  });
75
77
 
76
- // Declare human intent first — every action.execute needs the returned anchor_token
78
+ // Declare human intent first. Save anchor_token. It is not returned on GET.
79
+ const title = "Pay the docs vendor under $20";
77
80
  const { intent } = await auctra.createIntent({
78
- title: "Pay matched vendor invoices",
81
+ title,
82
+ description: title,
79
83
  intentType: "payment",
80
84
  riskLevel: "high",
81
85
  maxRiskLevel: "critical",
82
86
  allowedActionTypes: ["send_payment"],
87
+ maxAmount: 20,
88
+ currency: "USD",
89
+ vendorAllowlist: ["vendor:docs-walkthrough"],
83
90
  expiresAt,
84
91
  });
85
92
 
86
- // Dry-run
87
- await auctra.action.evaluate({
88
- agentId,
89
- actionType: "send_payment",
90
- payload: { amount: 500, currency: "USD" },
91
- intent, // wires claimed_intent_id + intent_anchor_token
92
- });
93
-
94
- // Production enforcement path
95
93
  const decision = await auctra.action.execute(
96
94
  {
97
95
  agentId,
98
96
  actionType: "send_payment",
99
- payload: { amount: 500, currency: "USD", target: "vendor:acme" },
100
- intent, // do not pass claimedIntentId alone — omit anchor → require_approval
97
+ payload: { amount: 9, currency: "USD", target: "vendor:docs-walkthrough" },
98
+ intent, // id + anchor_token. The id alone returned blocked on a payment.
101
99
  action: {
102
- target: "vendor:acme",
103
- description: "Net-30 invoice payment",
100
+ target: "vendor:docs-walkthrough",
101
+ description: title,
104
102
  riskLevel: "medium",
103
+ metadata: {
104
+ inputs: [{
105
+ source: "billing",
106
+ source_type: "invoice",
107
+ trust_level: "internal",
108
+ authority: "none",
109
+ received_at: new Date().toISOString(),
110
+ }],
111
+ context_refs: [{
112
+ source_id: "invoice:docs",
113
+ fetched_at: new Date().toISOString(),
114
+ trust_level: "internal",
115
+ }],
116
+ amount: 9,
117
+ currency: "USD",
118
+ },
105
119
  },
106
120
  },
107
121
  { idempotencyKey: crypto.randomUUID() },
108
122
  );
109
123
 
110
124
  if (decision.decision === "allowed") {
111
- // proceed
125
+ await withExecutionLease(auctra, decision, async () => {
126
+ // call your payment API here; Auctra does not hold that secret
127
+ }, { expectedActionType: "send_payment" });
112
128
  } else if (decision.decision === "require_approval") {
113
- // Pass the decision object — SDK forwards approval_nonce automatically (TEST-004).
129
+ // Org policy or velocity hold. Open Authority Reviews. Not a missing-field payment.
114
130
  await auctra.approveActionRequest(decision, sponsorUserId, "Approved after review");
115
131
  } else {
116
- // "blocked" includes over-maxAmount, unknown agent, revoked/expired grant
132
+ // blocked: missing provenance, missing anchor, over maxAmount, unknown agent, revoked grant
117
133
  throw new Error(decision.reason);
118
134
  }
119
135
 
@@ -121,6 +137,69 @@ const pack = await auctra.getActionRequest(decision.action_request_id);
121
137
 
122
138
  ```
123
139
 
140
+ ### Same calls for other action types
141
+
142
+ Finance is not the only type. A message and a SQL query use the same intent object, the same lease consume, and a grant that lists that type. A dollar cap is only for types that carry an amount.
143
+
144
+ ```typescript
145
+ await auctra.authority.issue({
146
+ subject: agentId,
147
+ capabilities: ["send_email", "execute_sql"],
148
+ expiresAt,
149
+ });
150
+
151
+ const mailIntent = (await auctra.createIntent({
152
+ title: "Notify the customer about the ticket",
153
+ description: "Notify the customer about the ticket",
154
+ allowedActionTypes: ["send_email"],
155
+ expiresAt,
156
+ })).intent;
157
+
158
+ const mail = await auctra.action.execute({
159
+ agentId,
160
+ actionType: "send_email",
161
+ intent: mailIntent,
162
+ payload: { target: "customer:docs" },
163
+ action: {
164
+ target: "customer:docs",
165
+ description: "Notify the customer about the ticket",
166
+ metadata: {
167
+ inputs: [{ source: "ticket", source_type: "case", trust_level: "internal", authority: "none", received_at: new Date().toISOString() }],
168
+ },
169
+ },
170
+ });
171
+ if (mail.decision === "allowed") {
172
+ await withExecutionLease(auctra, mail, async () => {
173
+ // call your mailer here
174
+ }, { expectedActionType: "send_email" });
175
+ }
176
+
177
+ const sqlIntent = (await auctra.createIntent({
178
+ title: "Read aggregate customer metrics",
179
+ description: "Read aggregate customer metrics",
180
+ allowedActionTypes: ["execute_sql"],
181
+ expiresAt,
182
+ })).intent;
183
+
184
+ const query = await auctra.action.execute({
185
+ agentId,
186
+ actionType: "execute_sql",
187
+ intent: sqlIntent,
188
+ payload: { target: "customers.aggregate_metrics" },
189
+ action: {
190
+ target: "customers.aggregate_metrics",
191
+ description: "Read aggregate customer metrics",
192
+ metadata: {
193
+ inputs: [{ source: "warehouse", source_type: "schema", trust_level: "internal", authority: "none", received_at: new Date().toISOString() }],
194
+ context_refs: [{ source_id: "schema:customers", fetched_at: new Date().toISOString(), trust_level: "internal" }],
195
+ sql: { requested_scope: "customers.aggregate_metrics", authorized_scope: "customers.aggregate_metrics" },
196
+ },
197
+ },
198
+ });
199
+ // requested_scope or the action target outside authorized_scope returns blocked SQL_SCOPE_EXCEEDED.
200
+ // Omitting the target uses the action type name, and that name is also a requested scope.
201
+ ```
202
+
124
203
  ### Delegate (Child ⊆ Parent)
125
204
 
126
205
  ```typescript
@@ -149,7 +228,7 @@ const { intent } = await auctra.createIntent({ /* ... */ });
149
228
  await auctra.action.execute({ agentId, actionType, payload, intent, action: { /* ... */ } });
150
229
  ```
151
230
 
152
- **Do not** send `claimedIntentId` without `intentAnchorToken` — the runtime returns `require_approval` with a message about the missing anchor. That is intentional (fail-safe), not a policy misconfiguration.
231
+ **Do not** send `claimedIntentId` without `intentAnchorToken`. On a payment that already included provenance, the id without the anchor token returned **blocked**, and the reason told the caller to send `intent_anchor_token`. A payment without `action.metadata.inputs` and `context_refs` returned **blocked** with `PROVENANCE_REQUIRED` and `CONTEXT_REFS_MISSING` before the intent check. `require_approval` is an org policy or a velocity hold, not the missing-token payment.
153
232
 
154
233
  Full onboarding guide: [`docs/integrations/intent-anchors.md`](../../docs/integrations/intent-anchors.md).
155
234
 
package/dist/cjs/types.js CHANGED
@@ -2,6 +2,6 @@
2
2
  /** @auctra/sdk — Authority Protocol client (Stage 1.0 modular layout). */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.DEFAULT_BASE_URL = exports.AUCTRA_SDK_VERSION = void 0;
5
- exports.AUCTRA_SDK_VERSION = "0.7.20";
5
+ exports.AUCTRA_SDK_VERSION = "0.7.21";
6
6
  /** Production API + console host (Architecture A: colocated on app.auctra.tech). */
7
7
  exports.DEFAULT_BASE_URL = "https://app.auctra.tech";
@@ -1,5 +1,5 @@
1
1
  /** @auctra/sdk — Authority Protocol client (Stage 1.0 modular layout). */
2
- export declare const AUCTRA_SDK_VERSION = "0.7.20";
2
+ export declare const AUCTRA_SDK_VERSION = "0.7.21";
3
3
  /** Production API + console host (Architecture A: colocated on app.auctra.tech). */
4
4
  export declare const DEFAULT_BASE_URL = "https://app.auctra.tech";
5
5
  export type AgentEnvironment = "dev" | "staging" | "production";
package/dist/esm/types.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /** @auctra/sdk — Authority Protocol client (Stage 1.0 modular layout). */
2
- export const AUCTRA_SDK_VERSION = "0.7.20";
2
+ export const AUCTRA_SDK_VERSION = "0.7.21";
3
3
  /** Production API + console host (Architecture A: colocated on app.auctra.tech). */
4
4
  export const DEFAULT_BASE_URL = "https://app.auctra.tech";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auctra/sdk",
3
- "version": "0.7.20",
3
+ "version": "0.7.21",
4
4
  "description": "Authority Protocol SDK — issue portable authority, evaluate/execute actions, verify evidence",
5
5
  "homepage": "https://www.auctra.tech/docs",
6
6
  "bugs": {
package/src/types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /** @auctra/sdk — Authority Protocol client (Stage 1.0 modular layout). */
2
2
 
3
- export const AUCTRA_SDK_VERSION = "0.7.20";
3
+ export const AUCTRA_SDK_VERSION = "0.7.21";
4
4
 
5
5
  /** Production API + console host (Architecture A: colocated on app.auctra.tech). */
6
6
  export const DEFAULT_BASE_URL = "https://app.auctra.tech";