@sequence0/sdk 2.1.0 → 2.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/dist/chains/cardano.d.ts +1 -1
- package/dist/chains/cardano.d.ts.map +1 -1
- package/dist/chains/cardano.js +6 -3
- package/dist/chains/cardano.js.map +1 -1
- package/dist/chains/dogecoin-litecoin.d.ts +1 -1
- package/dist/chains/dogecoin-litecoin.d.ts.map +1 -1
- package/dist/chains/dogecoin-litecoin.js +8 -5
- package/dist/chains/dogecoin-litecoin.js.map +1 -1
- package/dist/chains/ethereum.d.ts.map +1 -1
- package/dist/chains/ethereum.js +26 -0
- package/dist/chains/ethereum.js.map +1 -1
- package/dist/chains/polkadot.js +2 -2
- package/dist/chains/polkadot.js.map +1 -1
- package/dist/chains/stellar.d.ts +1 -1
- package/dist/chains/stellar.d.ts.map +1 -1
- package/dist/chains/stellar.js +7 -2
- package/dist/chains/stellar.js.map +1 -1
- package/dist/chains/tezos.d.ts.map +1 -1
- package/dist/chains/tezos.js +3 -4
- package/dist/chains/tezos.js.map +1 -1
- package/dist/chains/ton.d.ts +1 -1
- package/dist/chains/ton.d.ts.map +1 -1
- package/dist/chains/ton.js +5 -2
- package/dist/chains/ton.js.map +1 -1
- package/dist/core/aegis.d.ts +160 -0
- package/dist/core/aegis.d.ts.map +1 -0
- package/dist/core/aegis.js +373 -0
- package/dist/core/aegis.js.map +1 -0
- package/dist/core/client.d.ts +76 -0
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +99 -1
- package/dist/core/client.js.map +1 -1
- package/dist/core/nexus.d.ts +110 -0
- package/dist/core/nexus.d.ts.map +1 -0
- package/dist/core/nexus.js +229 -0
- package/dist/core/nexus.js.map +1 -0
- package/dist/core/signet.d.ts +158 -0
- package/dist/core/signet.d.ts.map +1 -0
- package/dist/core/signet.js +231 -0
- package/dist/core/signet.js.map +1 -0
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/discovery.d.ts.map +1 -1
- package/dist/utils/discovery.js +32 -2
- package/dist/utils/discovery.js.map +1 -1
- package/dist/wallet/wallet.d.ts +14 -1
- package/dist/wallet/wallet.d.ts.map +1 -1
- package/dist/wallet/wallet.js +19 -5
- package/dist/wallet/wallet.js.map +1 -1
- package/package.json +7 -3
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AEGIS: Sovereign Agency Protocol Client
|
|
3
|
+
*
|
|
4
|
+
* Cryptographic delegation of signing authority across all 81 chains.
|
|
5
|
+
* Enables scoped, hierarchical, revocable delegation enforced by
|
|
6
|
+
* threshold cryptography -- not law, not smart contracts, not trust.
|
|
7
|
+
*
|
|
8
|
+
* Delegates can sign within their constraints without the owner's
|
|
9
|
+
* involvement. Sub-delegation enables multi-level hierarchies
|
|
10
|
+
* (e.g., fund -> portfolio manager -> trader). Dead-man's switches
|
|
11
|
+
* activate authority when the owner goes silent.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { AegisClient } from '@sequence0/sdk';
|
|
16
|
+
*
|
|
17
|
+
* const aegis = new AegisClient({ baseUrl: 'http://agent:8080' });
|
|
18
|
+
*
|
|
19
|
+
* // Delegate trading authority to an AI agent
|
|
20
|
+
* const grant = await aegis.createDelegation('my-wallet', {
|
|
21
|
+
* to: '0xAiAgent...',
|
|
22
|
+
* chains: ['ethereum', 'arbitrum'],
|
|
23
|
+
* constraints: {
|
|
24
|
+
* maxPerTransaction: '1000000000000000000',
|
|
25
|
+
* allowedOperations: ['swap', 'transfer'],
|
|
26
|
+
* },
|
|
27
|
+
* validUntil: '2026-12-31T23:59:59Z',
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Check authority status
|
|
31
|
+
* const status = await aegis.checkAuthority(grant.delegationId);
|
|
32
|
+
* console.log('Active:', status.status);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
import { DelegateOptions, SubDelegateOptions, DelegationGrant, DelegationTree } from './delegation';
|
|
36
|
+
/**
|
|
37
|
+
* Client for the AEGIS Sovereign Agency Protocol.
|
|
38
|
+
*
|
|
39
|
+
* Communicates with delegation endpoints on the agent node to create,
|
|
40
|
+
* manage, and revoke delegation grants, query delegation trees, and
|
|
41
|
+
* send heartbeats for dead-man's switch scenarios.
|
|
42
|
+
*/
|
|
43
|
+
export declare class AegisClient {
|
|
44
|
+
private baseUrl;
|
|
45
|
+
/**
|
|
46
|
+
* Create a new AegisClient.
|
|
47
|
+
*
|
|
48
|
+
* @param options - Client configuration
|
|
49
|
+
* @param options.baseUrl - Agent node HTTP endpoint URL
|
|
50
|
+
*/
|
|
51
|
+
constructor(options: {
|
|
52
|
+
baseUrl: string;
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Create a new delegation grant from the wallet owner to a delegate.
|
|
56
|
+
*
|
|
57
|
+
* The delegate will be able to sign transactions within the
|
|
58
|
+
* specified constraints without the owner's involvement. The
|
|
59
|
+
* grant is recorded on-chain in the DelegationRegistry contract.
|
|
60
|
+
*
|
|
61
|
+
* @param walletId - The wallet to delegate authority for
|
|
62
|
+
* @param options - Delegation parameters (delegate address, chains, constraints, etc.)
|
|
63
|
+
* @returns The created delegation grant
|
|
64
|
+
*
|
|
65
|
+
* @throws {Sequence0Error} If the parameters are invalid
|
|
66
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
67
|
+
*/
|
|
68
|
+
createDelegation(walletId: string, options: DelegateOptions): Promise<DelegationGrant>;
|
|
69
|
+
/**
|
|
70
|
+
* Create a sub-delegation from an existing grant.
|
|
71
|
+
*
|
|
72
|
+
* A delegate with sub-delegation permission can further scope down
|
|
73
|
+
* authority to a child delegate. Constraints can only be narrowed,
|
|
74
|
+
* never expanded beyond the parent grant's limits.
|
|
75
|
+
*
|
|
76
|
+
* @param walletId - The wallet the parent grant belongs to
|
|
77
|
+
* @param options - Sub-delegation parameters including parent grant ID
|
|
78
|
+
* @returns The created sub-delegation grant
|
|
79
|
+
*
|
|
80
|
+
* @throws {Sequence0Error} If the parameters are invalid
|
|
81
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
82
|
+
*/
|
|
83
|
+
createSubDelegation(walletId: string, options: SubDelegateOptions): Promise<DelegationGrant>;
|
|
84
|
+
/**
|
|
85
|
+
* Revoke a delegation grant.
|
|
86
|
+
*
|
|
87
|
+
* Once revoked, the delegate can no longer sign transactions
|
|
88
|
+
* for this wallet. All sub-delegations under the revoked grant
|
|
89
|
+
* are also automatically revoked.
|
|
90
|
+
*
|
|
91
|
+
* @param walletId - The wallet the delegation belongs to
|
|
92
|
+
* @param delegationId - The delegation grant to revoke
|
|
93
|
+
*
|
|
94
|
+
* @throws {Sequence0Error} If the parameters are invalid
|
|
95
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
96
|
+
*/
|
|
97
|
+
revokeDelegation(walletId: string, delegationId: string): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* List all active delegation grants for a wallet.
|
|
100
|
+
*
|
|
101
|
+
* @param walletId - The wallet to query
|
|
102
|
+
* @returns Array of delegation grants
|
|
103
|
+
*
|
|
104
|
+
* @throws {Sequence0Error} If the wallet ID is invalid
|
|
105
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
106
|
+
*/
|
|
107
|
+
listDelegations(walletId: string): Promise<DelegationGrant[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Get the full delegation tree for a wallet.
|
|
110
|
+
*
|
|
111
|
+
* Returns a hierarchical view of all delegations and sub-delegations
|
|
112
|
+
* rooted at the wallet owner. Useful for visualizing the authority
|
|
113
|
+
* structure and auditing delegation chains.
|
|
114
|
+
*
|
|
115
|
+
* @param walletId - The wallet to query
|
|
116
|
+
* @returns The delegation tree
|
|
117
|
+
*
|
|
118
|
+
* @throws {Sequence0Error} If the wallet ID is invalid
|
|
119
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
120
|
+
*/
|
|
121
|
+
getDelegationTree(walletId: string): Promise<DelegationTree>;
|
|
122
|
+
/**
|
|
123
|
+
* Send a heartbeat for a dead-man's switch delegation.
|
|
124
|
+
*
|
|
125
|
+
* The owner must send periodic heartbeats to prevent the dead-man's
|
|
126
|
+
* switch from activating. If heartbeats stop for longer than the
|
|
127
|
+
* configured grace period, the delegate's authority automatically
|
|
128
|
+
* becomes active.
|
|
129
|
+
*
|
|
130
|
+
* @param delegationId - The delegation grant with a dead-man's switch
|
|
131
|
+
*
|
|
132
|
+
* @throws {Sequence0Error} If the delegation ID is invalid
|
|
133
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
134
|
+
*/
|
|
135
|
+
heartbeat(delegationId: string): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Check the current authority status of a delegation.
|
|
138
|
+
*
|
|
139
|
+
* Returns the delegation's active state, remaining budgets, and
|
|
140
|
+
* the full grant details. Useful for delegates to check their
|
|
141
|
+
* remaining authority before submitting a sign request.
|
|
142
|
+
*
|
|
143
|
+
* @param delegationId - The delegation grant to check
|
|
144
|
+
* @returns Status string and delegation grant details
|
|
145
|
+
*
|
|
146
|
+
* @throws {Sequence0Error} If the delegation ID is invalid
|
|
147
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
148
|
+
*/
|
|
149
|
+
checkAuthority(delegationId: string): Promise<{
|
|
150
|
+
status: string;
|
|
151
|
+
delegation: DelegationGrant | null;
|
|
152
|
+
}>;
|
|
153
|
+
private get;
|
|
154
|
+
private post;
|
|
155
|
+
private marshalConstraints;
|
|
156
|
+
private mapGrantResponse;
|
|
157
|
+
private unmarshalConstraints;
|
|
158
|
+
private mapTreeResponse;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=aegis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aegis.d.ts","sourceRoot":"","sources":["../../src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OAAO,CAAC,eAAe;CAQ1B"}
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AEGIS: Sovereign Agency Protocol Client
|
|
4
|
+
*
|
|
5
|
+
* Cryptographic delegation of signing authority across all 81 chains.
|
|
6
|
+
* Enables scoped, hierarchical, revocable delegation enforced by
|
|
7
|
+
* threshold cryptography -- not law, not smart contracts, not trust.
|
|
8
|
+
*
|
|
9
|
+
* Delegates can sign within their constraints without the owner's
|
|
10
|
+
* involvement. Sub-delegation enables multi-level hierarchies
|
|
11
|
+
* (e.g., fund -> portfolio manager -> trader). Dead-man's switches
|
|
12
|
+
* activate authority when the owner goes silent.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { AegisClient } from '@sequence0/sdk';
|
|
17
|
+
*
|
|
18
|
+
* const aegis = new AegisClient({ baseUrl: 'http://agent:8080' });
|
|
19
|
+
*
|
|
20
|
+
* // Delegate trading authority to an AI agent
|
|
21
|
+
* const grant = await aegis.createDelegation('my-wallet', {
|
|
22
|
+
* to: '0xAiAgent...',
|
|
23
|
+
* chains: ['ethereum', 'arbitrum'],
|
|
24
|
+
* constraints: {
|
|
25
|
+
* maxPerTransaction: '1000000000000000000',
|
|
26
|
+
* allowedOperations: ['swap', 'transfer'],
|
|
27
|
+
* },
|
|
28
|
+
* validUntil: '2026-12-31T23:59:59Z',
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Check authority status
|
|
32
|
+
* const status = await aegis.checkAuthority(grant.delegationId);
|
|
33
|
+
* console.log('Active:', status.status);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.AegisClient = void 0;
|
|
38
|
+
const errors_1 = require("../utils/errors");
|
|
39
|
+
// ── Aegis Client ──
|
|
40
|
+
/**
|
|
41
|
+
* Client for the AEGIS Sovereign Agency Protocol.
|
|
42
|
+
*
|
|
43
|
+
* Communicates with delegation endpoints on the agent node to create,
|
|
44
|
+
* manage, and revoke delegation grants, query delegation trees, and
|
|
45
|
+
* send heartbeats for dead-man's switch scenarios.
|
|
46
|
+
*/
|
|
47
|
+
class AegisClient {
|
|
48
|
+
/**
|
|
49
|
+
* Create a new AegisClient.
|
|
50
|
+
*
|
|
51
|
+
* @param options - Client configuration
|
|
52
|
+
* @param options.baseUrl - Agent node HTTP endpoint URL
|
|
53
|
+
*/
|
|
54
|
+
constructor(options) {
|
|
55
|
+
this.baseUrl = options.baseUrl.replace(/\/+$/, '');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create a new delegation grant from the wallet owner to a delegate.
|
|
59
|
+
*
|
|
60
|
+
* The delegate will be able to sign transactions within the
|
|
61
|
+
* specified constraints without the owner's involvement. The
|
|
62
|
+
* grant is recorded on-chain in the DelegationRegistry contract.
|
|
63
|
+
*
|
|
64
|
+
* @param walletId - The wallet to delegate authority for
|
|
65
|
+
* @param options - Delegation parameters (delegate address, chains, constraints, etc.)
|
|
66
|
+
* @returns The created delegation grant
|
|
67
|
+
*
|
|
68
|
+
* @throws {Sequence0Error} If the parameters are invalid
|
|
69
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
70
|
+
*/
|
|
71
|
+
async createDelegation(walletId, options) {
|
|
72
|
+
if (!walletId || typeof walletId !== 'string') {
|
|
73
|
+
throw new errors_1.Sequence0Error('walletId must be a non-empty string');
|
|
74
|
+
}
|
|
75
|
+
if (!options.to || typeof options.to !== 'string') {
|
|
76
|
+
throw new errors_1.Sequence0Error('options.to must be a non-empty string (delegate address)');
|
|
77
|
+
}
|
|
78
|
+
if (!Array.isArray(options.chains) || options.chains.length === 0) {
|
|
79
|
+
throw new errors_1.Sequence0Error('options.chains must be a non-empty array of chain names');
|
|
80
|
+
}
|
|
81
|
+
if (!options.constraints || typeof options.constraints !== 'object') {
|
|
82
|
+
throw new errors_1.Sequence0Error('options.constraints must be a non-empty object');
|
|
83
|
+
}
|
|
84
|
+
const response = await this.post('/delegation/create', {
|
|
85
|
+
wallet_id: walletId,
|
|
86
|
+
to: options.to,
|
|
87
|
+
chains: options.chains,
|
|
88
|
+
wasm_policy_id: options.wasmPolicyId,
|
|
89
|
+
constraints: this.marshalConstraints(options.constraints),
|
|
90
|
+
valid_from: options.validFrom,
|
|
91
|
+
valid_until: options.validUntil,
|
|
92
|
+
sub_delegation: options.subDelegation ?? false,
|
|
93
|
+
max_sub_depth: options.maxSubDepth ?? 0,
|
|
94
|
+
revocation: options.revocation ?? 'immediate',
|
|
95
|
+
activation: options.activation ? {
|
|
96
|
+
heartbeat_interval: options.activation.heartbeatInterval,
|
|
97
|
+
grace_period: options.activation.gracePeriod,
|
|
98
|
+
} : undefined,
|
|
99
|
+
});
|
|
100
|
+
return this.mapGrantResponse(response);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create a sub-delegation from an existing grant.
|
|
104
|
+
*
|
|
105
|
+
* A delegate with sub-delegation permission can further scope down
|
|
106
|
+
* authority to a child delegate. Constraints can only be narrowed,
|
|
107
|
+
* never expanded beyond the parent grant's limits.
|
|
108
|
+
*
|
|
109
|
+
* @param walletId - The wallet the parent grant belongs to
|
|
110
|
+
* @param options - Sub-delegation parameters including parent grant ID
|
|
111
|
+
* @returns The created sub-delegation grant
|
|
112
|
+
*
|
|
113
|
+
* @throws {Sequence0Error} If the parameters are invalid
|
|
114
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
115
|
+
*/
|
|
116
|
+
async createSubDelegation(walletId, options) {
|
|
117
|
+
if (!walletId || typeof walletId !== 'string') {
|
|
118
|
+
throw new errors_1.Sequence0Error('walletId must be a non-empty string');
|
|
119
|
+
}
|
|
120
|
+
if (!options.parentGrantId || typeof options.parentGrantId !== 'string') {
|
|
121
|
+
throw new errors_1.Sequence0Error('options.parentGrantId must be a non-empty string');
|
|
122
|
+
}
|
|
123
|
+
if (!options.signerKey || typeof options.signerKey !== 'string') {
|
|
124
|
+
throw new errors_1.Sequence0Error('options.signerKey must be a non-empty string (parent delegate private key)');
|
|
125
|
+
}
|
|
126
|
+
if (!options.to || typeof options.to !== 'string') {
|
|
127
|
+
throw new errors_1.Sequence0Error('options.to must be a non-empty string (sub-delegate address)');
|
|
128
|
+
}
|
|
129
|
+
if (!Array.isArray(options.chains) || options.chains.length === 0) {
|
|
130
|
+
throw new errors_1.Sequence0Error('options.chains must be a non-empty array of chain names');
|
|
131
|
+
}
|
|
132
|
+
if (!options.constraints || typeof options.constraints !== 'object') {
|
|
133
|
+
throw new errors_1.Sequence0Error('options.constraints must be a non-empty object');
|
|
134
|
+
}
|
|
135
|
+
const response = await this.post('/delegation/sub-delegate', {
|
|
136
|
+
wallet_id: walletId,
|
|
137
|
+
parent_grant_id: options.parentGrantId,
|
|
138
|
+
signer_key: options.signerKey,
|
|
139
|
+
to: options.to,
|
|
140
|
+
chains: options.chains,
|
|
141
|
+
wasm_policy_id: options.wasmPolicyId,
|
|
142
|
+
constraints: this.marshalConstraints(options.constraints),
|
|
143
|
+
valid_from: options.validFrom,
|
|
144
|
+
valid_until: options.validUntil,
|
|
145
|
+
sub_delegation: options.subDelegation ?? false,
|
|
146
|
+
max_sub_depth: options.maxSubDepth ?? 0,
|
|
147
|
+
revocation: options.revocation ?? 'immediate',
|
|
148
|
+
activation: options.activation ? {
|
|
149
|
+
heartbeat_interval: options.activation.heartbeatInterval,
|
|
150
|
+
grace_period: options.activation.gracePeriod,
|
|
151
|
+
} : undefined,
|
|
152
|
+
});
|
|
153
|
+
return this.mapGrantResponse(response);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Revoke a delegation grant.
|
|
157
|
+
*
|
|
158
|
+
* Once revoked, the delegate can no longer sign transactions
|
|
159
|
+
* for this wallet. All sub-delegations under the revoked grant
|
|
160
|
+
* are also automatically revoked.
|
|
161
|
+
*
|
|
162
|
+
* @param walletId - The wallet the delegation belongs to
|
|
163
|
+
* @param delegationId - The delegation grant to revoke
|
|
164
|
+
*
|
|
165
|
+
* @throws {Sequence0Error} If the parameters are invalid
|
|
166
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
167
|
+
*/
|
|
168
|
+
async revokeDelegation(walletId, delegationId) {
|
|
169
|
+
if (!walletId || typeof walletId !== 'string') {
|
|
170
|
+
throw new errors_1.Sequence0Error('walletId must be a non-empty string');
|
|
171
|
+
}
|
|
172
|
+
if (!delegationId || typeof delegationId !== 'string') {
|
|
173
|
+
throw new errors_1.Sequence0Error('delegationId must be a non-empty string');
|
|
174
|
+
}
|
|
175
|
+
await this.post('/delegation/revoke', {
|
|
176
|
+
wallet_id: walletId,
|
|
177
|
+
delegation_id: delegationId,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* List all active delegation grants for a wallet.
|
|
182
|
+
*
|
|
183
|
+
* @param walletId - The wallet to query
|
|
184
|
+
* @returns Array of delegation grants
|
|
185
|
+
*
|
|
186
|
+
* @throws {Sequence0Error} If the wallet ID is invalid
|
|
187
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
188
|
+
*/
|
|
189
|
+
async listDelegations(walletId) {
|
|
190
|
+
if (!walletId || typeof walletId !== 'string') {
|
|
191
|
+
throw new errors_1.Sequence0Error('walletId must be a non-empty string');
|
|
192
|
+
}
|
|
193
|
+
const response = await this.get(`/delegation/list/${walletId}`);
|
|
194
|
+
if (!response || !Array.isArray(response.delegations)) {
|
|
195
|
+
throw new errors_1.Sequence0Error('Invalid response from /delegation/list: missing delegations array');
|
|
196
|
+
}
|
|
197
|
+
return response.delegations.map((d) => this.mapGrantResponse(d));
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Get the full delegation tree for a wallet.
|
|
201
|
+
*
|
|
202
|
+
* Returns a hierarchical view of all delegations and sub-delegations
|
|
203
|
+
* rooted at the wallet owner. Useful for visualizing the authority
|
|
204
|
+
* structure and auditing delegation chains.
|
|
205
|
+
*
|
|
206
|
+
* @param walletId - The wallet to query
|
|
207
|
+
* @returns The delegation tree
|
|
208
|
+
*
|
|
209
|
+
* @throws {Sequence0Error} If the wallet ID is invalid
|
|
210
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
211
|
+
*/
|
|
212
|
+
async getDelegationTree(walletId) {
|
|
213
|
+
if (!walletId || typeof walletId !== 'string') {
|
|
214
|
+
throw new errors_1.Sequence0Error('walletId must be a non-empty string');
|
|
215
|
+
}
|
|
216
|
+
const response = await this.get(`/delegation/tree/${walletId}`);
|
|
217
|
+
if (!response || !response.grant) {
|
|
218
|
+
throw new errors_1.Sequence0Error('Invalid response from /delegation/tree: missing grant');
|
|
219
|
+
}
|
|
220
|
+
return this.mapTreeResponse(response);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Send a heartbeat for a dead-man's switch delegation.
|
|
224
|
+
*
|
|
225
|
+
* The owner must send periodic heartbeats to prevent the dead-man's
|
|
226
|
+
* switch from activating. If heartbeats stop for longer than the
|
|
227
|
+
* configured grace period, the delegate's authority automatically
|
|
228
|
+
* becomes active.
|
|
229
|
+
*
|
|
230
|
+
* @param delegationId - The delegation grant with a dead-man's switch
|
|
231
|
+
*
|
|
232
|
+
* @throws {Sequence0Error} If the delegation ID is invalid
|
|
233
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
234
|
+
*/
|
|
235
|
+
async heartbeat(delegationId) {
|
|
236
|
+
if (!delegationId || typeof delegationId !== 'string') {
|
|
237
|
+
throw new errors_1.Sequence0Error('delegationId must be a non-empty string');
|
|
238
|
+
}
|
|
239
|
+
await this.post('/delegation/heartbeat', {
|
|
240
|
+
delegation_id: delegationId,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Check the current authority status of a delegation.
|
|
245
|
+
*
|
|
246
|
+
* Returns the delegation's active state, remaining budgets, and
|
|
247
|
+
* the full grant details. Useful for delegates to check their
|
|
248
|
+
* remaining authority before submitting a sign request.
|
|
249
|
+
*
|
|
250
|
+
* @param delegationId - The delegation grant to check
|
|
251
|
+
* @returns Status string and delegation grant details
|
|
252
|
+
*
|
|
253
|
+
* @throws {Sequence0Error} If the delegation ID is invalid
|
|
254
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
255
|
+
*/
|
|
256
|
+
async checkAuthority(delegationId) {
|
|
257
|
+
if (!delegationId || typeof delegationId !== 'string') {
|
|
258
|
+
throw new errors_1.Sequence0Error('delegationId must be a non-empty string');
|
|
259
|
+
}
|
|
260
|
+
const response = await this.get(`/delegation/status/${delegationId}`);
|
|
261
|
+
if (!response || typeof response.status !== 'string') {
|
|
262
|
+
throw new errors_1.Sequence0Error('Invalid response from /delegation/status: missing status');
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
status: response.status,
|
|
266
|
+
delegation: response.delegation
|
|
267
|
+
? this.mapGrantResponse(response.delegation)
|
|
268
|
+
: null,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
// ── Internal HTTP helpers ──
|
|
272
|
+
async get(path) {
|
|
273
|
+
const url = `${this.baseUrl}${path}`;
|
|
274
|
+
let res;
|
|
275
|
+
try {
|
|
276
|
+
res = await fetch(url, {
|
|
277
|
+
method: 'GET',
|
|
278
|
+
headers: { 'Content-Type': 'application/json' },
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
catch (err) {
|
|
282
|
+
throw new errors_1.NetworkError(`Failed to reach agent at ${url}: ${err.message}`);
|
|
283
|
+
}
|
|
284
|
+
if (!res.ok) {
|
|
285
|
+
const body = await res.text().catch(() => '');
|
|
286
|
+
throw new errors_1.NetworkError(`GET ${path} failed with status ${res.status}: ${body}`, res.status);
|
|
287
|
+
}
|
|
288
|
+
return res.json();
|
|
289
|
+
}
|
|
290
|
+
async post(path, body) {
|
|
291
|
+
const url = `${this.baseUrl}${path}`;
|
|
292
|
+
let res;
|
|
293
|
+
try {
|
|
294
|
+
res = await fetch(url, {
|
|
295
|
+
method: 'POST',
|
|
296
|
+
headers: { 'Content-Type': 'application/json' },
|
|
297
|
+
body: JSON.stringify(body),
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
catch (err) {
|
|
301
|
+
throw new errors_1.NetworkError(`Failed to reach agent at ${url}: ${err.message}`);
|
|
302
|
+
}
|
|
303
|
+
if (!res.ok) {
|
|
304
|
+
const errBody = await res.text().catch(() => '');
|
|
305
|
+
throw new errors_1.NetworkError(`POST ${path} failed with status ${res.status}: ${errBody}`, res.status);
|
|
306
|
+
}
|
|
307
|
+
return res.json();
|
|
308
|
+
}
|
|
309
|
+
// ── Constraint marshaling ──
|
|
310
|
+
marshalConstraints(constraints) {
|
|
311
|
+
return {
|
|
312
|
+
max_per_transaction: constraints.maxPerTransaction,
|
|
313
|
+
max_per_day: constraints.maxPerDay,
|
|
314
|
+
max_total: constraints.maxTotal,
|
|
315
|
+
allowed_operations: constraints.allowedOperations,
|
|
316
|
+
allowed_targets: constraints.allowedTargets,
|
|
317
|
+
denied_targets: constraints.deniedTargets,
|
|
318
|
+
deny_external_transfers: constraints.denyExternalTransfers,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
// ── Response Mappers ──
|
|
322
|
+
mapGrantResponse(response) {
|
|
323
|
+
if (!response || typeof response.delegation_id !== 'string') {
|
|
324
|
+
throw new errors_1.Sequence0Error('Invalid delegation response: missing delegation_id');
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
delegationId: response.delegation_id,
|
|
328
|
+
delegator: response.delegator,
|
|
329
|
+
delegate: response.delegate,
|
|
330
|
+
walletId: response.wallet_id,
|
|
331
|
+
chains: response.chains ?? [],
|
|
332
|
+
wasmPolicyId: response.wasm_policy_id,
|
|
333
|
+
constraints: this.unmarshalConstraints(response.constraints),
|
|
334
|
+
validFrom: response.valid_from,
|
|
335
|
+
validUntil: response.valid_until,
|
|
336
|
+
parentGrantId: response.parent_grant_id,
|
|
337
|
+
maxSubDepth: response.max_sub_depth ?? 0,
|
|
338
|
+
currentDepth: response.current_depth ?? 0,
|
|
339
|
+
allowSubDelegation: response.allow_sub_delegation ?? false,
|
|
340
|
+
isActive: response.is_active ?? true,
|
|
341
|
+
activation: response.activation ? {
|
|
342
|
+
heartbeatInterval: response.activation.heartbeat_interval,
|
|
343
|
+
gracePeriod: response.activation.grace_period,
|
|
344
|
+
} : undefined,
|
|
345
|
+
createdAt: response.created_at,
|
|
346
|
+
spentToday: response.spent_today ?? '0',
|
|
347
|
+
spentTotal: response.spent_total ?? '0',
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
unmarshalConstraints(raw) {
|
|
351
|
+
if (!raw)
|
|
352
|
+
return {};
|
|
353
|
+
return {
|
|
354
|
+
maxPerTransaction: raw.max_per_transaction,
|
|
355
|
+
maxPerDay: raw.max_per_day,
|
|
356
|
+
maxTotal: raw.max_total,
|
|
357
|
+
allowedOperations: raw.allowed_operations,
|
|
358
|
+
allowedTargets: raw.allowed_targets,
|
|
359
|
+
deniedTargets: raw.denied_targets,
|
|
360
|
+
denyExternalTransfers: raw.deny_external_transfers,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
mapTreeResponse(response) {
|
|
364
|
+
return {
|
|
365
|
+
grant: this.mapGrantResponse(response.grant),
|
|
366
|
+
children: Array.isArray(response.children)
|
|
367
|
+
? response.children.map((child) => this.mapTreeResponse(child))
|
|
368
|
+
: [],
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
exports.AegisClient = AegisClient;
|
|
373
|
+
//# sourceMappingURL=aegis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aegis.js","sourceRoot":"","sources":["../../src/core/aegis.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;AAEH,4CAA6E;AAW7E,qBAAqB;AAErB;;;;;;GAMG;AACH,MAAa,WAAW;IAGpB;;;;;OAKG;IACH,YAAY,OAA4B;QACpC,IAAI,CAAC,OA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@ -31,6 +31,9 @@ import { WsClient } from '../utils/websocket';
|
|
|
31
31
|
import { UnsignedFeeTx } from '../utils/fee';
|
|
32
32
|
import { SettlementClient } from '../settlement/settlement';
|
|
33
33
|
import { UniversalAccountClient, UniversalAccountInfo, CreateUniversalAccountOptions } from './universal-account';
|
|
34
|
+
import { SignetClient } from './signet';
|
|
35
|
+
import { AegisClient } from './aegis';
|
|
36
|
+
import { NexusClient } from './nexus';
|
|
34
37
|
export declare class Sequence0 {
|
|
35
38
|
private config;
|
|
36
39
|
private http;
|
|
@@ -428,6 +431,79 @@ export declare class Sequence0 {
|
|
|
428
431
|
* @throws {NetworkError} If no healthy agent is available
|
|
429
432
|
*/
|
|
430
433
|
createUniversalAccount(options: CreateUniversalAccountOptions): Promise<UniversalAccountInfo>;
|
|
434
|
+
/**
|
|
435
|
+
* Get a SignetClient for SIGNET Programmable Signing operations.
|
|
436
|
+
*
|
|
437
|
+
* The client provides methods to deploy WASM signing policy programs,
|
|
438
|
+
* attach/detach them to wallets, and query program information.
|
|
439
|
+
*
|
|
440
|
+
* @returns A SignetClient instance bound to the current agent
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```typescript
|
|
444
|
+
* const signet = await s0.getSignetClient();
|
|
445
|
+
*
|
|
446
|
+
* const { programId } = await signet.deployProgram({
|
|
447
|
+
* bytecode: wasmHex,
|
|
448
|
+
* name: 'spending-limit',
|
|
449
|
+
* description: 'Enforces a 1 ETH per-tx limit',
|
|
450
|
+
* });
|
|
451
|
+
*
|
|
452
|
+
* await signet.attachProgram('my-wallet', programId);
|
|
453
|
+
* ```
|
|
454
|
+
*/
|
|
455
|
+
getSignetClient(): Promise<SignetClient>;
|
|
456
|
+
/**
|
|
457
|
+
* Get an AegisClient for AEGIS Sovereign Agency Protocol operations.
|
|
458
|
+
*
|
|
459
|
+
* The client provides methods to create, manage, and revoke
|
|
460
|
+
* delegation grants, query delegation trees, and send heartbeats
|
|
461
|
+
* for dead-man's switch scenarios.
|
|
462
|
+
*
|
|
463
|
+
* @returns An AegisClient instance bound to the current agent
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* ```typescript
|
|
467
|
+
* const aegis = await s0.getAegisClient();
|
|
468
|
+
*
|
|
469
|
+
* const grant = await aegis.createDelegation('my-wallet', {
|
|
470
|
+
* to: '0xAiAgent...',
|
|
471
|
+
* chains: ['ethereum', 'arbitrum'],
|
|
472
|
+
* constraints: { maxPerTransaction: '1000000000000000000' },
|
|
473
|
+
* });
|
|
474
|
+
*
|
|
475
|
+
* const tree = await aegis.getDelegationTree('my-wallet');
|
|
476
|
+
* ```
|
|
477
|
+
*/
|
|
478
|
+
getAegisClient(): Promise<AegisClient>;
|
|
479
|
+
/**
|
|
480
|
+
* Get a NexusClient for NEXUS Atomic Composability operations.
|
|
481
|
+
*
|
|
482
|
+
* The client provides methods to submit multi-wallet, multi-chain
|
|
483
|
+
* atomic signing manifests, poll manifest status, and wait for
|
|
484
|
+
* completion with automatic polling.
|
|
485
|
+
*
|
|
486
|
+
* @returns A NexusClient instance bound to the current agent
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* ```typescript
|
|
490
|
+
* const nexus = await s0.getNexusClient();
|
|
491
|
+
*
|
|
492
|
+
* const result = await nexus.signAtomic({
|
|
493
|
+
* operations: [
|
|
494
|
+
* { walletId: 'eth-wallet', chain: 'ethereum', message: '0xabc...' },
|
|
495
|
+
* { walletId: 'arb-wallet', chain: 'arbitrum', message: '0xdef...' },
|
|
496
|
+
* ],
|
|
497
|
+
* });
|
|
498
|
+
*
|
|
499
|
+
* if (result.status === 'committed') {
|
|
500
|
+
* for (const [reqId, sig] of result.signatures) {
|
|
501
|
+
* console.log(reqId, sig);
|
|
502
|
+
* }
|
|
503
|
+
* }
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
getNexusClient(): Promise<NexusClient>;
|
|
431
507
|
/**
|
|
432
508
|
* Subscribe to real-time events from the agent network
|
|
433
509
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACH,aAAa,EACb,mBAAmB,EAEnB,cAAc,EACd,cAAc,EAEd,YAAY,EAGZ,kBAAkB,EAErB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAmB,MAAM,UAAU,CAAC;AAChF,OAAO,EACH,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,eAAe,EAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,MAAM,EAAgB,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAa,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAc,aAAa,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACH,aAAa,EACb,mBAAmB,EAEnB,cAAc,EACd,cAAc,EAEd,YAAY,EAGZ,kBAAkB,EAErB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAmB,MAAM,UAAU,CAAC;AAChF,OAAO,EACH,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,eAAe,EAClB,MAAM,cAAc,CAAC;AAEtB,OAAO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