@agirails/sdk 2.5.3 → 2.5.5
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/ACTPClient.d.ts +18 -0
- package/dist/ACTPClient.d.ts.map +1 -1
- package/dist/ACTPClient.js +72 -23
- package/dist/ACTPClient.js.map +1 -1
- package/dist/adapters/BasicAdapter.d.ts +15 -0
- package/dist/adapters/BasicAdapter.d.ts.map +1 -1
- package/dist/adapters/BasicAdapter.js +33 -4
- package/dist/adapters/BasicAdapter.js.map +1 -1
- package/dist/adapters/StandardAdapter.d.ts +20 -3
- package/dist/adapters/StandardAdapter.d.ts.map +1 -1
- package/dist/adapters/StandardAdapter.js +90 -12
- package/dist/adapters/StandardAdapter.js.map +1 -1
- package/dist/cli/commands/publish.js +16 -4
- package/dist/cli/commands/publish.js.map +1 -1
- package/dist/cli/commands/register.js +16 -4
- package/dist/cli/commands/register.js.map +1 -1
- package/dist/cli/commands/tx.js +31 -3
- package/dist/cli/commands/tx.js.map +1 -1
- package/dist/config/networks.d.ts +10 -2
- package/dist/config/networks.d.ts.map +1 -1
- package/dist/config/networks.js +31 -22
- package/dist/config/networks.js.map +1 -1
- package/dist/level0/request.d.ts.map +1 -1
- package/dist/level0/request.js +2 -1
- package/dist/level0/request.js.map +1 -1
- package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
- package/dist/runtime/BlockchainRuntime.js +11 -5
- package/dist/runtime/BlockchainRuntime.js.map +1 -1
- package/dist/utils/IPFSClient.d.ts +3 -1
- package/dist/utils/IPFSClient.d.ts.map +1 -1
- package/dist/utils/IPFSClient.js +27 -7
- package/dist/utils/IPFSClient.js.map +1 -1
- package/dist/wallet/AutoWalletProvider.d.ts +11 -1
- package/dist/wallet/AutoWalletProvider.d.ts.map +1 -1
- package/dist/wallet/AutoWalletProvider.js +84 -19
- package/dist/wallet/AutoWalletProvider.js.map +1 -1
- package/dist/wallet/IWalletProvider.d.ts +34 -0
- package/dist/wallet/IWalletProvider.d.ts.map +1 -1
- package/dist/wallet/SmartWalletRouter.d.ts +128 -0
- package/dist/wallet/SmartWalletRouter.d.ts.map +1 -0
- package/dist/wallet/SmartWalletRouter.js +248 -0
- package/dist/wallet/SmartWalletRouter.js.map +1 -0
- package/dist/wallet/aa/DualNonceManager.d.ts +26 -1
- package/dist/wallet/aa/DualNonceManager.d.ts.map +1 -1
- package/dist/wallet/aa/DualNonceManager.js +140 -6
- package/dist/wallet/aa/DualNonceManager.js.map +1 -1
- package/package.json +3 -6
- package/src/ACTPClient.ts +0 -1579
- package/src/abi/ACTPKernel.json +0 -1356
- package/src/abi/AgentRegistry.json +0 -915
- package/src/abi/ERC20.json +0 -40
- package/src/abi/EscrowVault.json +0 -134
- package/src/abi/IdentityRegistry.json +0 -316
- package/src/adapters/AdapterRegistry.ts +0 -173
- package/src/adapters/AdapterRouter.ts +0 -416
- package/src/adapters/BaseAdapter.ts +0 -498
- package/src/adapters/BasicAdapter.ts +0 -514
- package/src/adapters/IAdapter.ts +0 -292
- package/src/adapters/StandardAdapter.ts +0 -555
- package/src/adapters/X402Adapter.ts +0 -731
- package/src/adapters/index.ts +0 -60
- package/src/builders/DeliveryProofBuilder.ts +0 -327
- package/src/builders/QuoteBuilder.ts +0 -483
- package/src/builders/index.ts +0 -17
- package/src/cli/commands/balance.ts +0 -110
- package/src/cli/commands/batch.ts +0 -487
- package/src/cli/commands/config.ts +0 -231
- package/src/cli/commands/deploy-check.ts +0 -364
- package/src/cli/commands/deploy-env.ts +0 -120
- package/src/cli/commands/diff.ts +0 -141
- package/src/cli/commands/init.ts +0 -469
- package/src/cli/commands/mint.ts +0 -116
- package/src/cli/commands/pay.ts +0 -113
- package/src/cli/commands/publish.ts +0 -475
- package/src/cli/commands/pull.ts +0 -124
- package/src/cli/commands/register.ts +0 -247
- package/src/cli/commands/simulate.ts +0 -345
- package/src/cli/commands/time.ts +0 -302
- package/src/cli/commands/tx.ts +0 -448
- package/src/cli/commands/watch.ts +0 -211
- package/src/cli/index.ts +0 -134
- package/src/cli/utils/client.ts +0 -252
- package/src/cli/utils/config.ts +0 -389
- package/src/cli/utils/output.ts +0 -465
- package/src/cli/utils/wallet.ts +0 -109
- package/src/config/agirailsmd.ts +0 -262
- package/src/config/networks.ts +0 -275
- package/src/config/pendingPublish.ts +0 -237
- package/src/config/publishPipeline.ts +0 -359
- package/src/config/syncOperations.ts +0 -279
- package/src/erc8004/ERC8004Bridge.ts +0 -462
- package/src/erc8004/ReputationReporter.ts +0 -468
- package/src/erc8004/index.ts +0 -61
- package/src/errors/index.ts +0 -427
- package/src/index.ts +0 -364
- package/src/level0/Provider.ts +0 -117
- package/src/level0/ServiceDirectory.ts +0 -131
- package/src/level0/index.ts +0 -10
- package/src/level0/provide.ts +0 -132
- package/src/level0/request.ts +0 -432
- package/src/level1/Agent.ts +0 -1426
- package/src/level1/index.ts +0 -10
- package/src/level1/pricing/PriceCalculator.ts +0 -255
- package/src/level1/pricing/PricingStrategy.ts +0 -198
- package/src/level1/types/Job.ts +0 -179
- package/src/level1/types/Options.ts +0 -291
- package/src/level1/types/index.ts +0 -8
- package/src/protocol/ACTPKernel.ts +0 -808
- package/src/protocol/AgentRegistry.ts +0 -559
- package/src/protocol/DIDManager.ts +0 -629
- package/src/protocol/DIDResolver.ts +0 -554
- package/src/protocol/EASHelper.ts +0 -378
- package/src/protocol/EscrowVault.ts +0 -255
- package/src/protocol/EventMonitor.ts +0 -204
- package/src/protocol/MessageSigner.ts +0 -510
- package/src/protocol/ProofGenerator.ts +0 -339
- package/src/protocol/QuoteBuilder.ts +0 -15
- package/src/registry/AgentRegistryClient.ts +0 -202
- package/src/runtime/BlockchainRuntime.ts +0 -1015
- package/src/runtime/IACTPRuntime.ts +0 -306
- package/src/runtime/MockRuntime.ts +0 -1298
- package/src/runtime/MockStateManager.ts +0 -577
- package/src/runtime/index.ts +0 -25
- package/src/runtime/types/MockState.ts +0 -237
- package/src/storage/ArchiveBundleBuilder.ts +0 -561
- package/src/storage/ArweaveClient.ts +0 -946
- package/src/storage/FilebaseClient.ts +0 -790
- package/src/storage/index.ts +0 -96
- package/src/storage/types.ts +0 -348
- package/src/types/adapter.ts +0 -310
- package/src/types/agent.ts +0 -79
- package/src/types/did.ts +0 -223
- package/src/types/eip712.ts +0 -175
- package/src/types/erc8004.ts +0 -293
- package/src/types/escrow.ts +0 -27
- package/src/types/index.ts +0 -17
- package/src/types/message.ts +0 -145
- package/src/types/state.ts +0 -87
- package/src/types/transaction.ts +0 -69
- package/src/types/x402.ts +0 -251
- package/src/utils/ErrorRecoveryGuide.ts +0 -676
- package/src/utils/Helpers.ts +0 -688
- package/src/utils/IPFSClient.ts +0 -368
- package/src/utils/Logger.ts +0 -484
- package/src/utils/NonceManager.ts +0 -591
- package/src/utils/RateLimiter.ts +0 -534
- package/src/utils/ReceivedNonceTracker.ts +0 -567
- package/src/utils/SDKLifecycle.ts +0 -416
- package/src/utils/SecureNonce.ts +0 -78
- package/src/utils/Semaphore.ts +0 -276
- package/src/utils/UsedAttestationTracker.ts +0 -385
- package/src/utils/canonicalJson.ts +0 -38
- package/src/utils/circuitBreaker.ts +0 -324
- package/src/utils/computeTypeHash.ts +0 -48
- package/src/utils/fsSafe.ts +0 -80
- package/src/utils/index.ts +0 -80
- package/src/utils/retry.ts +0 -364
- package/src/utils/security.ts +0 -418
- package/src/utils/validation.ts +0 -540
- package/src/wallet/AutoWalletProvider.ts +0 -299
- package/src/wallet/EOAWalletProvider.ts +0 -69
- package/src/wallet/IWalletProvider.ts +0 -135
- package/src/wallet/aa/BundlerClient.ts +0 -274
- package/src/wallet/aa/DualNonceManager.ts +0 -173
- package/src/wallet/aa/PaymasterClient.ts +0 -174
- package/src/wallet/aa/TransactionBatcher.ts +0 -353
- package/src/wallet/aa/UserOpBuilder.ts +0 -246
- package/src/wallet/aa/constants.ts +0 -60
- package/src/wallet/keystore.ts +0 -240
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sync Operations - Pull + Diff for AGIRAILS.md
|
|
3
|
-
*
|
|
4
|
-
* Terraform-style sync: compare local AGIRAILS.md with on-chain state.
|
|
5
|
-
* Never auto-overwrites — shows diff and requires explicit confirmation.
|
|
6
|
-
*
|
|
7
|
-
* @module config/syncOperations
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
11
|
-
import { Provider } from 'ethers';
|
|
12
|
-
import { computeConfigHash, parseAgirailsMd, serializeAgirailsMd } from './agirailsmd';
|
|
13
|
-
import { validateCID } from '../utils/validation';
|
|
14
|
-
import { AgentRegistryClient } from '../registry/AgentRegistryClient';
|
|
15
|
-
|
|
16
|
-
// ============================================================================
|
|
17
|
-
// Constants
|
|
18
|
-
// ============================================================================
|
|
19
|
-
|
|
20
|
-
/** Public IPFS gateways for read-only access (no credentials needed) */
|
|
21
|
-
const IPFS_GATEWAYS = [
|
|
22
|
-
'https://ipfs.io/ipfs/',
|
|
23
|
-
'https://dweb.link/ipfs/',
|
|
24
|
-
'https://cloudflare-ipfs.com/ipfs/',
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
// ============================================================================
|
|
28
|
-
// Types
|
|
29
|
-
// ============================================================================
|
|
30
|
-
|
|
31
|
-
export interface DiffResult {
|
|
32
|
-
/** Whether local and on-chain are in sync */
|
|
33
|
-
inSync: boolean;
|
|
34
|
-
/** Local config hash (or null if no local file) */
|
|
35
|
-
localHash: string | null;
|
|
36
|
-
/** On-chain config hash (or zero hash if not published) */
|
|
37
|
-
onChainHash: string;
|
|
38
|
-
/** On-chain IPFS CID (or empty if not published) */
|
|
39
|
-
onChainCID: string;
|
|
40
|
-
/** Whether on-chain has a published config */
|
|
41
|
-
hasOnChainConfig: boolean;
|
|
42
|
-
/** Whether local file exists */
|
|
43
|
-
hasLocalFile: boolean;
|
|
44
|
-
/** Human-readable status message */
|
|
45
|
-
status: 'in-sync' | 'local-ahead' | 'remote-ahead' | 'diverged' | 'no-local' | 'no-remote';
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface PullResult {
|
|
49
|
-
/** Whether a file was written */
|
|
50
|
-
written: boolean;
|
|
51
|
-
/** The pulled content (if any) */
|
|
52
|
-
content?: string;
|
|
53
|
-
/** IPFS CID that was fetched */
|
|
54
|
-
cid?: string;
|
|
55
|
-
/** Status message */
|
|
56
|
-
status: string;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface DiffOptions {
|
|
60
|
-
/** Path to local AGIRAILS.md */
|
|
61
|
-
path: string;
|
|
62
|
-
/** Agent address to check on-chain */
|
|
63
|
-
agentAddress: string;
|
|
64
|
-
/** AgentRegistry contract address */
|
|
65
|
-
registryAddress: string;
|
|
66
|
-
/** Provider for reading on-chain state */
|
|
67
|
-
provider: Provider;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface PullOptions extends DiffOptions {
|
|
71
|
-
/** Force overwrite without confirmation */
|
|
72
|
-
force?: boolean;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// ============================================================================
|
|
76
|
-
// Diff
|
|
77
|
-
// ============================================================================
|
|
78
|
-
|
|
79
|
-
const ZERO_HASH = '0x' + '0'.repeat(64);
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Compare local AGIRAILS.md with on-chain config state.
|
|
83
|
-
*
|
|
84
|
-
* @param options - Diff configuration
|
|
85
|
-
* @returns Diff result showing sync status
|
|
86
|
-
*/
|
|
87
|
-
export async function diff(options: DiffOptions): Promise<DiffResult> {
|
|
88
|
-
const { path, agentAddress, registryAddress, provider } = options;
|
|
89
|
-
|
|
90
|
-
// Read on-chain state
|
|
91
|
-
const registryClient = AgentRegistryClient.readOnly(registryAddress, provider);
|
|
92
|
-
const onChainState = await registryClient.getConfig(agentAddress);
|
|
93
|
-
|
|
94
|
-
const hasOnChainConfig = onChainState.configHash !== ZERO_HASH && onChainState.configCID !== '';
|
|
95
|
-
const onChainHash = onChainState.configHash;
|
|
96
|
-
const onChainCID = onChainState.configCID;
|
|
97
|
-
|
|
98
|
-
// Read local state
|
|
99
|
-
const hasLocalFile = existsSync(path);
|
|
100
|
-
let localHash: string | null = null;
|
|
101
|
-
|
|
102
|
-
if (hasLocalFile) {
|
|
103
|
-
const content = readFileSync(path, 'utf-8');
|
|
104
|
-
const { configHash } = computeConfigHash(content);
|
|
105
|
-
localHash = configHash;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Determine status
|
|
109
|
-
let status: DiffResult['status'];
|
|
110
|
-
let inSync: boolean;
|
|
111
|
-
|
|
112
|
-
if (!hasLocalFile && !hasOnChainConfig) {
|
|
113
|
-
status = 'no-local';
|
|
114
|
-
inSync = true; // both empty = in sync
|
|
115
|
-
} else if (!hasLocalFile && hasOnChainConfig) {
|
|
116
|
-
status = 'remote-ahead';
|
|
117
|
-
inSync = false;
|
|
118
|
-
} else if (hasLocalFile && !hasOnChainConfig) {
|
|
119
|
-
status = 'no-remote';
|
|
120
|
-
inSync = false;
|
|
121
|
-
} else if (localHash === onChainHash) {
|
|
122
|
-
status = 'in-sync';
|
|
123
|
-
inSync = true;
|
|
124
|
-
} else {
|
|
125
|
-
// Both exist but hashes differ. Use the stored config_hash in frontmatter
|
|
126
|
-
// to determine directionality:
|
|
127
|
-
// - config_hash matches on-chain → user edited locally after last publish → local-ahead
|
|
128
|
-
// - config_hash doesn't match on-chain → remote was updated too → diverged
|
|
129
|
-
// - no config_hash → never published from this file → local-ahead
|
|
130
|
-
status = 'diverged';
|
|
131
|
-
inSync = false;
|
|
132
|
-
|
|
133
|
-
if (hasLocalFile) {
|
|
134
|
-
try {
|
|
135
|
-
const content = readFileSync(path, 'utf-8');
|
|
136
|
-
const { frontmatter } = parseAgirailsMd(content);
|
|
137
|
-
if (!frontmatter.config_hash) {
|
|
138
|
-
// Never published — local is the only source
|
|
139
|
-
status = 'local-ahead';
|
|
140
|
-
} else if (frontmatter.config_hash === onChainHash) {
|
|
141
|
-
// Last publish matches on-chain, so local edits are newer
|
|
142
|
-
status = 'local-ahead';
|
|
143
|
-
}
|
|
144
|
-
// else: frontmatter.config_hash !== onChainHash → remote updated → diverged
|
|
145
|
-
} catch {
|
|
146
|
-
// Parse error — keep as diverged
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return {
|
|
152
|
-
inSync,
|
|
153
|
-
localHash,
|
|
154
|
-
onChainHash,
|
|
155
|
-
onChainCID,
|
|
156
|
-
hasOnChainConfig,
|
|
157
|
-
hasLocalFile,
|
|
158
|
-
status,
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// ============================================================================
|
|
163
|
-
// IPFS Fetch (public gateway, no credentials needed)
|
|
164
|
-
// ============================================================================
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Fetch content from IPFS using public gateways (no Filebase credentials needed).
|
|
168
|
-
* Tries multiple gateways with fallback.
|
|
169
|
-
*
|
|
170
|
-
* @param cid - IPFS CID to fetch (validated before use)
|
|
171
|
-
* @returns Raw content as string
|
|
172
|
-
* @throws InvalidCIDError if CID format is invalid
|
|
173
|
-
* @throws Error if all gateways fail
|
|
174
|
-
*/
|
|
175
|
-
async function fetchFromIPFS(cid: string): Promise<string> {
|
|
176
|
-
// Validate CID format before hitting any gateway
|
|
177
|
-
validateCID(cid, 'onChainCID');
|
|
178
|
-
|
|
179
|
-
const errors: string[] = [];
|
|
180
|
-
|
|
181
|
-
for (const gateway of IPFS_GATEWAYS) {
|
|
182
|
-
try {
|
|
183
|
-
const response = await fetch(`${gateway}${cid}`, {
|
|
184
|
-
signal: AbortSignal.timeout(15_000),
|
|
185
|
-
});
|
|
186
|
-
if (!response.ok) {
|
|
187
|
-
errors.push(`${gateway}: HTTP ${response.status}`);
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
return await response.text();
|
|
191
|
-
} catch (err) {
|
|
192
|
-
errors.push(`${gateway}: ${err instanceof Error ? err.message : String(err)}`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
throw new Error(
|
|
197
|
-
`Failed to fetch CID ${cid} from all IPFS gateways:\n${errors.map(e => ` - ${e}`).join('\n')}`
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// ============================================================================
|
|
202
|
-
// Pull
|
|
203
|
-
// ============================================================================
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Pull on-chain config to local AGIRAILS.md.
|
|
207
|
-
*
|
|
208
|
-
* Downloads from IPFS via public gateways (no Filebase credentials needed),
|
|
209
|
-
* verifies integrity against on-chain configHash, then writes locally.
|
|
210
|
-
*
|
|
211
|
-
* @param options - Pull configuration
|
|
212
|
-
* @returns Pull result
|
|
213
|
-
*/
|
|
214
|
-
export async function pull(options: PullOptions): Promise<PullResult> {
|
|
215
|
-
const { path, agentAddress, registryAddress, provider, force = false } = options;
|
|
216
|
-
|
|
217
|
-
// First, run diff
|
|
218
|
-
const diffResult = await diff({ path, agentAddress, registryAddress, provider });
|
|
219
|
-
|
|
220
|
-
if (!diffResult.hasOnChainConfig) {
|
|
221
|
-
return {
|
|
222
|
-
written: false,
|
|
223
|
-
status: 'No config published on-chain for this agent.',
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (diffResult.inSync) {
|
|
228
|
-
return {
|
|
229
|
-
written: false,
|
|
230
|
-
status: 'Already in sync. No changes needed.',
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// Fetch raw AGIRAILS.md from IPFS (public gateway, no credentials)
|
|
235
|
-
const content = await fetchFromIPFS(diffResult.onChainCID);
|
|
236
|
-
|
|
237
|
-
// Integrity verification: hash downloaded content and compare with on-chain hash
|
|
238
|
-
const { configHash: downloadedHash } = computeConfigHash(content);
|
|
239
|
-
if (downloadedHash !== diffResult.onChainHash) {
|
|
240
|
-
return {
|
|
241
|
-
written: false,
|
|
242
|
-
cid: diffResult.onChainCID,
|
|
243
|
-
status: `Integrity check failed! Downloaded content hash (${downloadedHash}) does not match on-chain hash (${diffResult.onChainHash}). The IPFS content may have been tampered with.`,
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// Check if local file exists and we're not forcing
|
|
248
|
-
if (diffResult.hasLocalFile && !force) {
|
|
249
|
-
return {
|
|
250
|
-
written: false,
|
|
251
|
-
content,
|
|
252
|
-
cid: diffResult.onChainCID,
|
|
253
|
-
status: `Remote config differs from local. Use --force to overwrite. CID: ${diffResult.onChainCID}`,
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// Stamp on-chain metadata into frontmatter so diff heuristic can detect
|
|
258
|
-
// future remote changes (without this, pulled files have no config_hash
|
|
259
|
-
// and diff would always report "local-ahead" instead of "diverged")
|
|
260
|
-
const { frontmatter, body } = parseAgirailsMd(content);
|
|
261
|
-
const stamped = serializeAgirailsMd(
|
|
262
|
-
{
|
|
263
|
-
...frontmatter,
|
|
264
|
-
config_hash: diffResult.onChainHash,
|
|
265
|
-
config_cid: diffResult.onChainCID,
|
|
266
|
-
},
|
|
267
|
-
body
|
|
268
|
-
);
|
|
269
|
-
|
|
270
|
-
// Write the stamped file
|
|
271
|
-
writeFileSync(path, stamped, 'utf-8');
|
|
272
|
-
|
|
273
|
-
return {
|
|
274
|
-
written: true,
|
|
275
|
-
content: stamped,
|
|
276
|
-
cid: diffResult.onChainCID,
|
|
277
|
-
status: `Pulled and verified config from IPFS (${diffResult.onChainCID}) → ${path}`,
|
|
278
|
-
};
|
|
279
|
-
}
|