@edge-protocol/sdk 0.7.0 → 0.9.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 +110 -0
- package/dist/core/EdgePass.d.ts +88 -28
- package/dist/core/EdgePass.d.ts.map +1 -1
- package/dist/core/EdgePass.js +118 -63
- package/dist/core/EdgePass.js.map +1 -1
- package/dist/core/ExecutionEngine.d.ts +4 -4
- package/dist/core/ExecutionEngine.d.ts.map +1 -1
- package/dist/core/ExecutionEngine.js +18 -42
- package/dist/core/ExecutionEngine.js.map +1 -1
- package/dist/core/PolicyEngine.d.ts +57 -1
- package/dist/core/PolicyEngine.d.ts.map +1 -1
- package/dist/core/PolicyEngine.js +138 -35
- package/dist/core/PolicyEngine.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +29 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +74 -0
- package/dist/react/index.js.map +1 -0
- package/dist/utils/types.d.ts +40 -5
- package/dist/utils/types.d.ts.map +1 -1
- package/package.json +23 -41
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@edge-protocol/sdk` are documented here.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## [0.8.0] — 2026-06-20
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **`sdk.simulate(pass, requests[])`** — predict outcomes for a sequence of transactions without executing. Zero network calls. Returns `SimulationResult` with approved, blocked, and escalated decisions plus projected budget state after each step. Use to show agents their plan before touching the chain.
|
|
12
|
+
|
|
13
|
+
- **`sdk.budgetStatus(pass)`** — returns a complete `BudgetStatus` snapshot: spent, remaining, utilization percentage, `isNearLimit`, `isExhausted`.
|
|
14
|
+
|
|
15
|
+
- **`sdk.utilizationPct(pass)`** — budget utilization as 0-100 number. Use for progress bars and budget warnings.
|
|
16
|
+
|
|
17
|
+
- **`sdk.isNearLimit(pass, threshold?)`** — returns true if utilization exceeds threshold (default 80%). Use to warn agents before they exhaust budget.
|
|
18
|
+
|
|
19
|
+
- **`sdk.timeRemaining(pass)`** — milliseconds until pass expires. Returns 0 if expired.
|
|
20
|
+
|
|
21
|
+
- **`sdk.isExpiringSoon(pass, withinMs?)`** — returns true if pass expires within the given window (default 1 hour).
|
|
22
|
+
|
|
23
|
+
- **`EdgePass.withPolicy(pass, signer, sdk, fn)`** — higher-order function that wraps any async tool call with EdgePass policy enforcement. The wrapped function only executes if the transaction is approved. Perfect for Vercel AI SDK / Mastra tool definitions.
|
|
24
|
+
|
|
25
|
+
- **New types exported:** `SimulatedDecision`, `SimulationResult`, `BudgetStatus`
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- `PolicyEngine.simulate()` is now a static method on `PolicyEngine` and also exposed as `sdk.simulate()` on the `EdgePass` class for convenience.
|
|
30
|
+
- All budget and time helpers are now available both as static `PolicyEngine` methods and instance `sdk` methods.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## [0.7.1] — 2026-06-19
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- Reverted `tx.objectRef()` optimization from v0.7.0. While theoretically faster, storing object version at fetch time caused version conflicts when Enoki gas sponsorship updated the object between fetch and execution. `tx.object(pass.id)` resolves version at signing time which is the correct and safe pattern.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## [0.7.0] — 2026-06-19 — YANKED
|
|
43
|
+
|
|
44
|
+
Version yanked due to object version conflict regression. Use 0.7.1 instead.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## [0.6.6] — 2026-06-18
|
|
49
|
+
|
|
50
|
+
### Changed
|
|
51
|
+
|
|
52
|
+
- Updated README with mainnet contract address and live transaction digests
|
|
53
|
+
- Stronger competitive positioning and security model documentation
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## [0.6.0] — 2026-06-17
|
|
58
|
+
|
|
59
|
+
### Added
|
|
60
|
+
|
|
61
|
+
- **Error status as a distinct fourth outcome** — infrastructure failures (`status: 'error'`) are now clearly distinguished from policy rejections (`status: 'blocked'`). A network failure no longer pretends to be a policy decision.
|
|
62
|
+
- **`classifyError()`** — internal error classifier that maps RPC/network/signing errors to typed `EdgeErrorCode` values for programmatic handling.
|
|
63
|
+
- **`fetchPass()` validation** — validates objectId format before hitting the RPC. Throws with a clear message for malformed IDs rather than a cryptic RPC error.
|
|
64
|
+
- **Config validation on `create()`** — prevents impossible EdgePass configurations (e.g. autoThreshold >= escalateThreshold) at creation time rather than at execution time.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## [0.5.0] — 2026-06-16
|
|
69
|
+
|
|
70
|
+
### Added
|
|
71
|
+
|
|
72
|
+
- **Events system** — `sdk.on('approved')`, `sdk.on('escalated')`, `sdk.on('blocked')`. React to transaction outcomes without polling. Chain-able.
|
|
73
|
+
- `sdk.off()` and `sdk.removeAllListeners()` for cleanup.
|
|
74
|
+
- 34 comprehensive tests — PolicyEngine, fromTemplate, constants, events system.
|
|
75
|
+
|
|
76
|
+
### Changed
|
|
77
|
+
|
|
78
|
+
- Events fire for policy outcomes only (`approved`, `escalated`, `blocked`). Infrastructure errors (`status: 'error'`) do not fire events — check `outcome.status === 'error'` explicitly.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## [0.4.7] — 2026-06-15
|
|
83
|
+
|
|
84
|
+
### Added
|
|
85
|
+
|
|
86
|
+
- Comprehensive `DOCS.md` — full API reference, examples, types, architecture.
|
|
87
|
+
- `maxPerTransaction` field on `EdgePassConfig` — optional per-transaction cap independent of escalation threshold.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## [0.4.6] — 2026-06-14
|
|
92
|
+
|
|
93
|
+
### Added
|
|
94
|
+
|
|
95
|
+
- 27 comprehensive tests — PolicyEngine validation, `fromTemplate()`, constants.
|
|
96
|
+
- `EDGE_TEMPLATES` constants for festival, gaming, subscription, defi, enterprise.
|
|
97
|
+
- `EdgePass.fromTemplate()` static helper.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## [0.4.0] — 2026-06-13
|
|
102
|
+
|
|
103
|
+
### Added
|
|
104
|
+
|
|
105
|
+
- Initial public release.
|
|
106
|
+
- `EdgePass` class with `create()`, `execute()`, `validate()`, `fetch()`, `revoke()`.
|
|
107
|
+
- `PolicyEngine` with 7-rule validation chain.
|
|
108
|
+
- `ExecutionEngine` with on-chain PTB construction.
|
|
109
|
+
- Mainnet + testnet support.
|
|
110
|
+
- zkLogin compatible signer interface.
|
package/dist/core/EdgePass.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
-
import { EdgePassConfig, EdgePassObject, TransactionRequest, TransactionOutcome, EdgeSDKConfig } from "../utils/types";
|
|
2
|
+
import { EdgePassConfig, EdgePassObject, TransactionRequest, TransactionOutcome, EdgeSDKConfig, SimulationResult, BudgetStatus } from "../utils/types";
|
|
3
3
|
import { EdgePassTemplate } from "../utils/constants";
|
|
4
4
|
export type EdgePassEventType = 'approved' | 'escalated' | 'blocked';
|
|
5
5
|
export type EdgePassEventPayload = {
|
|
@@ -35,14 +35,13 @@ export declare class EdgePass {
|
|
|
35
35
|
constructor(config: EdgeSDKConfig);
|
|
36
36
|
/**
|
|
37
37
|
* Subscribe to transaction outcomes.
|
|
38
|
-
* Note: 'error' status (network/signing failures) does NOT fire events.
|
|
39
|
-
* Check outcome.status === 'error' in your execute() handler instead.
|
|
40
38
|
*
|
|
41
39
|
* @example
|
|
42
40
|
* sdk.on('approved', ({ outcome, pass }) => {
|
|
41
|
+
* updateBudgetUI(pass);
|
|
43
42
|
* console.log('executed:', outcome.digest);
|
|
44
43
|
* });
|
|
45
|
-
* sdk.on('escalated', ({
|
|
44
|
+
* sdk.on('escalated', ({ request }) => {
|
|
46
45
|
* notifyUser(`Approve $${request.amount} at ${request.merchant}?`);
|
|
47
46
|
* });
|
|
48
47
|
* sdk.on('blocked', ({ outcome }) => {
|
|
@@ -50,13 +49,7 @@ export declare class EdgePass {
|
|
|
50
49
|
* });
|
|
51
50
|
*/
|
|
52
51
|
on<T extends EdgePassEventType>(event: T, listener: EventListener<T>): this;
|
|
53
|
-
/**
|
|
54
|
-
* Unsubscribe a specific listener.
|
|
55
|
-
*/
|
|
56
52
|
off<T extends EdgePassEventType>(event: T, listener: EventListener<T>): this;
|
|
57
|
-
/**
|
|
58
|
-
* Remove all listeners for an event (or all events if none specified).
|
|
59
|
-
*/
|
|
60
53
|
removeAllListeners(event?: EdgePassEventType): this;
|
|
61
54
|
private emit;
|
|
62
55
|
/**
|
|
@@ -71,6 +64,30 @@ export declare class EdgePass {
|
|
|
71
64
|
static fromTemplate(template: EdgePassTemplate, overrides: Partial<EdgePassConfig> & {
|
|
72
65
|
owner: string;
|
|
73
66
|
}): EdgePassConfig;
|
|
67
|
+
/**
|
|
68
|
+
* Higher-order function — wraps any async function with EdgePass policy enforcement.
|
|
69
|
+
* The wrapped function only executes if the transaction is approved.
|
|
70
|
+
* Returns blocked/escalated outcomes without calling the wrapped function.
|
|
71
|
+
*
|
|
72
|
+
* Perfect for wrapping AI tool calls.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* const safePurchase = EdgePass.withPolicy(pass, signer, sdk, async (request) => {
|
|
76
|
+
* return await purchaseItem(request.merchant, request.amount);
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
79
|
+
* // Now safePurchase enforces EdgePass policy automatically
|
|
80
|
+
* const result = await safePurchase({ merchant: 'Hydra Bar', amount: 32n * MIST_PER_SUI });
|
|
81
|
+
* // result.outcome === 'approved' | 'blocked' | 'escalated'
|
|
82
|
+
*/
|
|
83
|
+
static withPolicy<T>(pass: EdgePassObject, signer: {
|
|
84
|
+
signAndExecute: (tx: Transaction) => Promise<{
|
|
85
|
+
digest: string;
|
|
86
|
+
}>;
|
|
87
|
+
}, sdk: EdgePass, fn: (request: TransactionRequest) => Promise<T>): (request: TransactionRequest) => Promise<{
|
|
88
|
+
outcome: TransactionOutcome;
|
|
89
|
+
result?: T;
|
|
90
|
+
}>;
|
|
74
91
|
/**
|
|
75
92
|
* Mint a new EdgePass on Sui.
|
|
76
93
|
*/
|
|
@@ -88,14 +105,6 @@ export declare class EdgePass {
|
|
|
88
105
|
* - 'escalated' — exceeds threshold, needs human approval
|
|
89
106
|
* - 'blocked' — policy rejected the transaction
|
|
90
107
|
* - 'error' — network/signing failure, transaction NOT submitted
|
|
91
|
-
*
|
|
92
|
-
* Events fire for approved/escalated/blocked only.
|
|
93
|
-
* Check outcome.status === 'error' separately for infrastructure failures.
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* sdk.on('approved', ({ outcome }) => console.log('tx:', outcome.digest));
|
|
97
|
-
* const outcome = await sdk.execute(pass, { merchant, amount }, signer);
|
|
98
|
-
* if (outcome.status === 'error') handleInfrastructureFailure(outcome.reason);
|
|
99
108
|
*/
|
|
100
109
|
execute(pass: EdgePassObject, request: TransactionRequest, signer: {
|
|
101
110
|
signAndExecute: (tx: Transaction) => Promise<{
|
|
@@ -103,13 +112,72 @@ export declare class EdgePass {
|
|
|
103
112
|
}>;
|
|
104
113
|
}): Promise<TransactionOutcome>;
|
|
105
114
|
/**
|
|
106
|
-
*
|
|
115
|
+
* Simulate a sequence of transactions against an EdgePass.
|
|
116
|
+
* Zero network calls. Sub-millisecond. Returns predicted outcomes for
|
|
117
|
+
* all decisions including projected budget state after each step.
|
|
118
|
+
*
|
|
119
|
+
* Use this to show an agent its plan before executing, or to build
|
|
120
|
+
* approval UIs that show what will happen before touching the chain.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* const plan = sdk.simulate(pass, [
|
|
124
|
+
* { merchant: 'Hydra Bar', amount: 32n * MIST_PER_SUI },
|
|
125
|
+
* { merchant: 'ShadyTokens.xyz', amount: 1n },
|
|
126
|
+
* { merchant: 'Stage Access VIP', amount: 220n * MIST_PER_SUI },
|
|
127
|
+
* ]);
|
|
128
|
+
*
|
|
129
|
+
* console.log(plan.summary);
|
|
130
|
+
* // { approvedCount: 1, blockedCount: 1, escalatedCount: 1, totalDecisions: 3 }
|
|
131
|
+
*
|
|
132
|
+
* // Show plan, then execute approved decisions
|
|
133
|
+
* for (const decision of plan.approved) {
|
|
134
|
+
* await sdk.execute(pass, decision.request, signer);
|
|
135
|
+
* }
|
|
136
|
+
*/
|
|
137
|
+
simulate(pass: EdgePassObject, requests: TransactionRequest[]): SimulationResult;
|
|
138
|
+
/**
|
|
139
|
+
* Preview a single transaction outcome without executing.
|
|
140
|
+
* Zero network calls. Sub-millisecond.
|
|
107
141
|
*/
|
|
108
142
|
validate(pass: EdgePassObject, request: TransactionRequest): import("../utils/types").PolicyValidation;
|
|
143
|
+
/**
|
|
144
|
+
* Returns a complete budget status snapshot.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* const status = sdk.budgetStatus(pass);
|
|
148
|
+
* if (status.isExhausted) stopAgent();
|
|
149
|
+
* if (status.isNearLimit) warnUser(`${status.utilizationPct.toFixed(1)}% of budget used`);
|
|
150
|
+
*/
|
|
151
|
+
budgetStatus(pass: EdgePassObject, nearLimitThreshold?: number): BudgetStatus;
|
|
152
|
+
/**
|
|
153
|
+
* Returns budget utilization as a percentage (0-100).
|
|
154
|
+
*/
|
|
155
|
+
utilizationPct(pass: EdgePassObject): number;
|
|
156
|
+
/**
|
|
157
|
+
* Returns true if budget utilization exceeds the given threshold.
|
|
158
|
+
* Default threshold is 80%.
|
|
159
|
+
*/
|
|
160
|
+
isNearLimit(pass: EdgePassObject, threshold?: number): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Returns the remaining budget in MIST.
|
|
163
|
+
*/
|
|
164
|
+
remainingBudget(pass: EdgePassObject): bigint;
|
|
165
|
+
/**
|
|
166
|
+
* Returns time remaining on the pass in milliseconds. 0 if expired.
|
|
167
|
+
*/
|
|
168
|
+
timeRemaining(pass: EdgePassObject): number;
|
|
169
|
+
/**
|
|
170
|
+
* Returns true if the pass will expire within the given window.
|
|
171
|
+
* Default window is 1 hour.
|
|
172
|
+
*/
|
|
173
|
+
isExpiringSoon(pass: EdgePassObject, withinMs?: number): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Returns true if the pass is active and not expired.
|
|
176
|
+
*/
|
|
177
|
+
isValid(pass: EdgePassObject): boolean;
|
|
109
178
|
/**
|
|
110
179
|
* Fetch a live EdgePass from Sui.
|
|
111
180
|
* Returns null if not found.
|
|
112
|
-
* Throws if objectId is invalid or a network error occurs.
|
|
113
181
|
*/
|
|
114
182
|
fetch(objectId: string): Promise<EdgePassObject | null>;
|
|
115
183
|
/**
|
|
@@ -122,14 +190,6 @@ export declare class EdgePass {
|
|
|
122
190
|
}): Promise<{
|
|
123
191
|
digest: string;
|
|
124
192
|
}>;
|
|
125
|
-
/**
|
|
126
|
-
* Returns remaining budget in MIST.
|
|
127
|
-
*/
|
|
128
|
-
remainingBudget(pass: EdgePassObject): bigint;
|
|
129
|
-
/**
|
|
130
|
-
* Returns true if the pass is active and not expired.
|
|
131
|
-
*/
|
|
132
|
-
isValid(pass: EdgePassObject): boolean;
|
|
133
193
|
}
|
|
134
194
|
export {};
|
|
135
195
|
//# sourceMappingURL=EdgePass.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EdgePass.d.ts","sourceRoot":"","sources":["../../src/core/EdgePass.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EACL,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,aAA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c,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,GAC3E,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAU/B"}
|
package/dist/core/EdgePass.js
CHANGED
|
@@ -7,7 +7,6 @@ const utils_1 = require("@mysten/sui/utils");
|
|
|
7
7
|
const PolicyEngine_1 = require("./PolicyEngine");
|
|
8
8
|
const ExecutionEngine_1 = require("./ExecutionEngine");
|
|
9
9
|
const constants_1 = require("../utils/constants");
|
|
10
|
-
// Sui Clock object ID — shared object, always the same address
|
|
11
10
|
const SUI_CLOCK_OBJECT_ID = '0x0000000000000000000000000000000000000000000000000000000000000006';
|
|
12
11
|
// ── EdgePass class ────────────────────────────────────────────────────────────
|
|
13
12
|
class EdgePass {
|
|
@@ -17,17 +16,16 @@ class EdgePass {
|
|
|
17
16
|
this.client = new client_1.SuiClient({ url: constants_1.NETWORK_URLS[config.network] });
|
|
18
17
|
this.engine = new ExecutionEngine_1.ExecutionEngine(config.network);
|
|
19
18
|
}
|
|
20
|
-
// ── Event system
|
|
19
|
+
// ── Event system ─────────────────────────────────────────────────────────────
|
|
21
20
|
/**
|
|
22
21
|
* Subscribe to transaction outcomes.
|
|
23
|
-
* Note: 'error' status (network/signing failures) does NOT fire events.
|
|
24
|
-
* Check outcome.status === 'error' in your execute() handler instead.
|
|
25
22
|
*
|
|
26
23
|
* @example
|
|
27
24
|
* sdk.on('approved', ({ outcome, pass }) => {
|
|
25
|
+
* updateBudgetUI(pass);
|
|
28
26
|
* console.log('executed:', outcome.digest);
|
|
29
27
|
* });
|
|
30
|
-
* sdk.on('escalated', ({
|
|
28
|
+
* sdk.on('escalated', ({ request }) => {
|
|
31
29
|
* notifyUser(`Approve $${request.amount} at ${request.merchant}?`);
|
|
32
30
|
* });
|
|
33
31
|
* sdk.on('blocked', ({ outcome }) => {
|
|
@@ -35,29 +33,20 @@ class EdgePass {
|
|
|
35
33
|
* });
|
|
36
34
|
*/
|
|
37
35
|
on(event, listener) {
|
|
38
|
-
if (!this.listeners.has(event))
|
|
36
|
+
if (!this.listeners.has(event))
|
|
39
37
|
this.listeners.set(event, new Set());
|
|
40
|
-
}
|
|
41
38
|
this.listeners.get(event).add(listener);
|
|
42
39
|
return this;
|
|
43
40
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Unsubscribe a specific listener.
|
|
46
|
-
*/
|
|
47
41
|
off(event, listener) {
|
|
48
42
|
this.listeners.get(event)?.delete(listener);
|
|
49
43
|
return this;
|
|
50
44
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Remove all listeners for an event (or all events if none specified).
|
|
53
|
-
*/
|
|
54
45
|
removeAllListeners(event) {
|
|
55
|
-
if (event)
|
|
46
|
+
if (event)
|
|
56
47
|
this.listeners.delete(event);
|
|
57
|
-
|
|
58
|
-
else {
|
|
48
|
+
else
|
|
59
49
|
this.listeners.clear();
|
|
60
|
-
}
|
|
61
50
|
return this;
|
|
62
51
|
}
|
|
63
52
|
emit(payload) {
|
|
@@ -73,7 +62,7 @@ class EdgePass {
|
|
|
73
62
|
}
|
|
74
63
|
}
|
|
75
64
|
}
|
|
76
|
-
// ── Static helpers
|
|
65
|
+
// ── Static helpers ────────────────────────────────────────────────────────────
|
|
77
66
|
/**
|
|
78
67
|
* Creates an EdgePassConfig from a template with optional overrides.
|
|
79
68
|
*
|
|
@@ -91,39 +80,57 @@ class EdgePass {
|
|
|
91
80
|
approvedMerchants: overrides.approvedMerchants ?? base.approvedMerchants,
|
|
92
81
|
};
|
|
93
82
|
}
|
|
94
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Higher-order function — wraps any async function with EdgePass policy enforcement.
|
|
85
|
+
* The wrapped function only executes if the transaction is approved.
|
|
86
|
+
* Returns blocked/escalated outcomes without calling the wrapped function.
|
|
87
|
+
*
|
|
88
|
+
* Perfect for wrapping AI tool calls.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* const safePurchase = EdgePass.withPolicy(pass, signer, sdk, async (request) => {
|
|
92
|
+
* return await purchaseItem(request.merchant, request.amount);
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* // Now safePurchase enforces EdgePass policy automatically
|
|
96
|
+
* const result = await safePurchase({ merchant: 'Hydra Bar', amount: 32n * MIST_PER_SUI });
|
|
97
|
+
* // result.outcome === 'approved' | 'blocked' | 'escalated'
|
|
98
|
+
*/
|
|
99
|
+
static withPolicy(pass, signer, sdk, fn) {
|
|
100
|
+
return async (request) => {
|
|
101
|
+
const outcome = await sdk.execute(pass, request, signer);
|
|
102
|
+
if (outcome.status === 'blocked' || outcome.status === 'escalated' || outcome.status === 'error') {
|
|
103
|
+
return { outcome };
|
|
104
|
+
}
|
|
105
|
+
const result = await fn(request);
|
|
106
|
+
return { outcome, result };
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// ── Core API ──────────────────────────────────────────────────────────────────
|
|
95
110
|
/**
|
|
96
111
|
* Mint a new EdgePass on Sui.
|
|
97
112
|
*/
|
|
98
113
|
async create(passConfig, signer) {
|
|
99
|
-
// ── Config validation ─────────────────────────────────────────────────
|
|
100
114
|
if (passConfig.autoThreshold >= passConfig.escalateThreshold) {
|
|
101
115
|
throw new Error(`EdgePass.create: autoThreshold (${passConfig.autoThreshold}) must be less than escalateThreshold (${passConfig.escalateThreshold})`);
|
|
102
116
|
}
|
|
103
117
|
if (passConfig.escalateThreshold > passConfig.budget) {
|
|
104
118
|
throw new Error(`EdgePass.create: escalateThreshold (${passConfig.escalateThreshold}) must be less than budget (${passConfig.budget})`);
|
|
105
119
|
}
|
|
106
|
-
if (passConfig.maxPerTransaction !== undefined &&
|
|
107
|
-
passConfig.maxPerTransaction < passConfig.escalateThreshold) {
|
|
120
|
+
if (passConfig.maxPerTransaction !== undefined && passConfig.maxPerTransaction < passConfig.escalateThreshold) {
|
|
108
121
|
throw new Error(`EdgePass.create: maxPerTransaction (${passConfig.maxPerTransaction}) should be >= escalateThreshold (${passConfig.escalateThreshold}) to avoid unexpected blocking`);
|
|
109
122
|
}
|
|
110
|
-
if (passConfig.approvedMerchants.length === 0)
|
|
123
|
+
if (passConfig.approvedMerchants.length === 0)
|
|
111
124
|
throw new Error('EdgePass.create: approvedMerchants cannot be empty');
|
|
112
|
-
|
|
113
|
-
if (passConfig.expiryMs <= 0) {
|
|
125
|
+
if (passConfig.expiryMs <= 0)
|
|
114
126
|
throw new Error('EdgePass.create: expiryMs must be greater than 0');
|
|
115
|
-
|
|
116
|
-
if (passConfig.budget <= BigInt(0)) {
|
|
127
|
+
if (passConfig.budget <= BigInt(0))
|
|
117
128
|
throw new Error('EdgePass.create: budget must be greater than 0');
|
|
118
|
-
}
|
|
119
|
-
// ─────────────────────────────────────────────────────────────────────
|
|
120
129
|
const tx = new transactions_1.Transaction();
|
|
121
130
|
tx.setGasBudget(constants_1.DEFAULT_GAS_BUDGET);
|
|
122
131
|
const packageId = constants_1.EDGE_PACKAGE_ID[this.config.network];
|
|
123
|
-
if (!packageId)
|
|
124
|
-
throw new Error(`EdgePass.create: no package ID configured for network "${this.config.network}"
|
|
125
|
-
`Update EDGE_PACKAGE_ID in constants.ts after deploying the Move contract.`);
|
|
126
|
-
}
|
|
132
|
+
if (!packageId)
|
|
133
|
+
throw new Error(`EdgePass.create: no package ID configured for network "${this.config.network}".`);
|
|
127
134
|
tx.moveCall({
|
|
128
135
|
target: `${packageId}::edge_pass::create_pass`,
|
|
129
136
|
arguments: [
|
|
@@ -159,39 +166,99 @@ class EdgePass {
|
|
|
159
166
|
* - 'escalated' — exceeds threshold, needs human approval
|
|
160
167
|
* - 'blocked' — policy rejected the transaction
|
|
161
168
|
* - 'error' — network/signing failure, transaction NOT submitted
|
|
162
|
-
*
|
|
163
|
-
* Events fire for approved/escalated/blocked only.
|
|
164
|
-
* Check outcome.status === 'error' separately for infrastructure failures.
|
|
165
|
-
*
|
|
166
|
-
* @example
|
|
167
|
-
* sdk.on('approved', ({ outcome }) => console.log('tx:', outcome.digest));
|
|
168
|
-
* const outcome = await sdk.execute(pass, { merchant, amount }, signer);
|
|
169
|
-
* if (outcome.status === 'error') handleInfrastructureFailure(outcome.reason);
|
|
170
169
|
*/
|
|
171
170
|
async execute(pass, request, signer) {
|
|
172
171
|
const outcome = await this.engine.execute(pass, request, signer);
|
|
173
|
-
// Fire events for policy outcomes only
|
|
174
|
-
// 'error' status = infrastructure failure, not a policy decision
|
|
175
172
|
if (outcome.status !== 'error') {
|
|
176
|
-
this.emit({
|
|
177
|
-
type: outcome.status,
|
|
178
|
-
outcome: outcome,
|
|
179
|
-
pass,
|
|
180
|
-
request,
|
|
181
|
-
});
|
|
173
|
+
this.emit({ type: outcome.status, outcome: outcome, pass, request });
|
|
182
174
|
}
|
|
183
175
|
return outcome;
|
|
184
176
|
}
|
|
185
177
|
/**
|
|
186
|
-
*
|
|
178
|
+
* Simulate a sequence of transactions against an EdgePass.
|
|
179
|
+
* Zero network calls. Sub-millisecond. Returns predicted outcomes for
|
|
180
|
+
* all decisions including projected budget state after each step.
|
|
181
|
+
*
|
|
182
|
+
* Use this to show an agent its plan before executing, or to build
|
|
183
|
+
* approval UIs that show what will happen before touching the chain.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* const plan = sdk.simulate(pass, [
|
|
187
|
+
* { merchant: 'Hydra Bar', amount: 32n * MIST_PER_SUI },
|
|
188
|
+
* { merchant: 'ShadyTokens.xyz', amount: 1n },
|
|
189
|
+
* { merchant: 'Stage Access VIP', amount: 220n * MIST_PER_SUI },
|
|
190
|
+
* ]);
|
|
191
|
+
*
|
|
192
|
+
* console.log(plan.summary);
|
|
193
|
+
* // { approvedCount: 1, blockedCount: 1, escalatedCount: 1, totalDecisions: 3 }
|
|
194
|
+
*
|
|
195
|
+
* // Show plan, then execute approved decisions
|
|
196
|
+
* for (const decision of plan.approved) {
|
|
197
|
+
* await sdk.execute(pass, decision.request, signer);
|
|
198
|
+
* }
|
|
199
|
+
*/
|
|
200
|
+
simulate(pass, requests) {
|
|
201
|
+
return PolicyEngine_1.PolicyEngine.simulate(pass, requests);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Preview a single transaction outcome without executing.
|
|
205
|
+
* Zero network calls. Sub-millisecond.
|
|
187
206
|
*/
|
|
188
207
|
validate(pass, request) {
|
|
189
208
|
return PolicyEngine_1.PolicyEngine.validate(pass, request);
|
|
190
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Returns a complete budget status snapshot.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* const status = sdk.budgetStatus(pass);
|
|
215
|
+
* if (status.isExhausted) stopAgent();
|
|
216
|
+
* if (status.isNearLimit) warnUser(`${status.utilizationPct.toFixed(1)}% of budget used`);
|
|
217
|
+
*/
|
|
218
|
+
budgetStatus(pass, nearLimitThreshold = 0.8) {
|
|
219
|
+
return PolicyEngine_1.PolicyEngine.budgetStatus(pass, nearLimitThreshold);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Returns budget utilization as a percentage (0-100).
|
|
223
|
+
*/
|
|
224
|
+
utilizationPct(pass) {
|
|
225
|
+
return PolicyEngine_1.PolicyEngine.utilizationPct(pass);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Returns true if budget utilization exceeds the given threshold.
|
|
229
|
+
* Default threshold is 80%.
|
|
230
|
+
*/
|
|
231
|
+
isNearLimit(pass, threshold = 0.8) {
|
|
232
|
+
return PolicyEngine_1.PolicyEngine.isNearLimit(pass, threshold);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Returns the remaining budget in MIST.
|
|
236
|
+
*/
|
|
237
|
+
remainingBudget(pass) {
|
|
238
|
+
return PolicyEngine_1.PolicyEngine.remainingBudget(pass);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Returns time remaining on the pass in milliseconds. 0 if expired.
|
|
242
|
+
*/
|
|
243
|
+
timeRemaining(pass) {
|
|
244
|
+
return PolicyEngine_1.PolicyEngine.timeRemaining(pass);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Returns true if the pass will expire within the given window.
|
|
248
|
+
* Default window is 1 hour.
|
|
249
|
+
*/
|
|
250
|
+
isExpiringSoon(pass, withinMs = 60 * 60 * 1000) {
|
|
251
|
+
return PolicyEngine_1.PolicyEngine.isExpiringSoon(pass, withinMs);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Returns true if the pass is active and not expired.
|
|
255
|
+
*/
|
|
256
|
+
isValid(pass) {
|
|
257
|
+
return PolicyEngine_1.PolicyEngine.isValid(pass);
|
|
258
|
+
}
|
|
191
259
|
/**
|
|
192
260
|
* Fetch a live EdgePass from Sui.
|
|
193
261
|
* Returns null if not found.
|
|
194
|
-
* Throws if objectId is invalid or a network error occurs.
|
|
195
262
|
*/
|
|
196
263
|
async fetch(objectId) {
|
|
197
264
|
return this.engine.fetchPass(objectId);
|
|
@@ -209,18 +276,6 @@ class EdgePass {
|
|
|
209
276
|
});
|
|
210
277
|
return signer.signAndExecute(tx);
|
|
211
278
|
}
|
|
212
|
-
/**
|
|
213
|
-
* Returns remaining budget in MIST.
|
|
214
|
-
*/
|
|
215
|
-
remainingBudget(pass) {
|
|
216
|
-
return PolicyEngine_1.PolicyEngine.remainingBudget(pass);
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Returns true if the pass is active and not expired.
|
|
220
|
-
*/
|
|
221
|
-
isValid(pass) {
|
|
222
|
-
return PolicyEngine_1.PolicyEngine.isValid(pass);
|
|
223
|
-
}
|
|
224
279
|
}
|
|
225
280
|
exports.EdgePass = EdgePass;
|
|
226
281
|
//# sourceMappingURL=EdgePass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EdgePass.js","sourceRoot":"","sources":["../../src/core/EdgePass.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAC/C,2DAAuD;AACvD,6CA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
9
|
-
readonly VERSION_CONFLICT: "VERSION_CONFLICT";
|
|
10
9
|
readonly UNKNOWN: "UNKNOWN";
|
|
11
10
|
};
|
|
12
11
|
export type EdgeErrorCode = typeof EDGE_ERROR_CODES[keyof typeof EDGE_ERROR_CODES];
|
|
@@ -22,9 +21,10 @@ export declare class ExecutionEngine {
|
|
|
22
21
|
private buildPTB;
|
|
23
22
|
/**
|
|
24
23
|
* Fetch a live EdgePass from Sui.
|
|
25
|
-
*
|
|
26
|
-
* Returns null if
|
|
27
|
-
* Throws if objectId is invalid or a network error occurs
|
|
24
|
+
*
|
|
25
|
+
* Returns null if the object doesn't exist.
|
|
26
|
+
* Throws EdgePassError if the objectId is invalid or a network error occurs —
|
|
27
|
+
* so callers can distinguish "not found" from "broken".
|
|
28
28
|
*/
|
|
29
29
|
fetchPass(objectId: string): Promise<EdgePassObject | null>;
|
|
30
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExecutionEngine.d.ts","sourceRoot":"","sources":["../../src/core/ExecutionEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,OAAO,EACR,MAAM,gBAAgB,CAAC;AAKxB,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"ExecutionEngine.d.ts","sourceRoot":"","sources":["../../src/core/ExecutionEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,OAAO,EACR,MAAM,gBAAgB,CAAC;AAKxB,eAAO,MAAM,gBAAgB;;;;;;;CAOnB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,OAAO,gBAAgB,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AA2CnF,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,OAAO,CAAU;gBAEb,OAAO,EAAE,OAAO;IAKtB,OAAO,CACX,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE;QAAE,cAAc,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,GAC3E,OAAO,CAAC,kBAAkB,CAAC;IA2B9B,OAAO,CAAC,QAAQ;IA4BhB;;;;;;OAMG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;CA6ElE"}
|