@sparkysolutions/agentrail 0.1.0 → 0.1.1

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.
Files changed (113) hide show
  1. package/README.md +249 -146
  2. package/dist/cli/mcp-stdio.d.ts +8 -0
  3. package/dist/cli/mcp-stdio.js +454 -0
  4. package/dist/cli/pipeline.d.ts +40 -0
  5. package/dist/cli/pipeline.js +114 -0
  6. package/dist/cli/sandbox.d.ts +15 -1
  7. package/dist/cli/sandbox.js +30 -5
  8. package/dist/index.d.ts +13 -0
  9. package/dist/index.js +13 -0
  10. package/dist/lib/agent-badge-issuer.d.ts +36 -0
  11. package/dist/lib/agent-badge-issuer.js +166 -0
  12. package/dist/lib/agent-registry.d.ts +136 -0
  13. package/dist/lib/agent-registry.js +124 -0
  14. package/dist/lib/agenthustle-pipeline.d.ts +68 -0
  15. package/dist/lib/agenthustle-pipeline.js +143 -0
  16. package/dist/lib/agentpass-pipeline.d.ts +44 -0
  17. package/dist/lib/agentpass-pipeline.js +84 -0
  18. package/dist/lib/audit-trail-provider.d.ts +24 -0
  19. package/dist/lib/audit-trail-provider.js +60 -0
  20. package/dist/lib/axis-clob-provider.d.ts +50 -0
  21. package/dist/lib/axis-clob-provider.js +150 -0
  22. package/dist/lib/circuit-breaker.d.ts +60 -0
  23. package/dist/lib/circuit-breaker.js +136 -0
  24. package/dist/lib/conditional-escrow.d.ts +42 -0
  25. package/dist/lib/conditional-escrow.js +126 -0
  26. package/dist/lib/mcp-server.d.ts +29 -0
  27. package/dist/lib/mcp-server.js +165 -0
  28. package/dist/lib/receipts.d.ts +153 -0
  29. package/dist/lib/receipts.js +173 -0
  30. package/dist/lib/reflector-oracle-adapter.d.ts +44 -0
  31. package/dist/lib/reflector-oracle-adapter.js +173 -0
  32. package/dist/lib/scoped-allowance.d.ts +4 -0
  33. package/dist/lib/scoped-allowance.js +22 -1
  34. package/dist/lib/universal-adapters.d.ts +42 -0
  35. package/dist/lib/universal-adapters.js +69 -0
  36. package/dist/lib/x402-gateway.d.ts +86 -0
  37. package/dist/lib/x402-gateway.js +128 -0
  38. package/dist/lib/x402-pipeline.d.ts +51 -0
  39. package/dist/lib/x402-pipeline.js +105 -0
  40. package/dist/types.d.ts +109 -0
  41. package/glama.json +12 -0
  42. package/package.json +56 -40
  43. package/smithery.json +43 -0
  44. package/smithery.yaml +29 -0
  45. package/.github/ISSUE_TEMPLATE/drips_wave_task.md +0 -33
  46. package/.github/workflows/auto-merge.yml +0 -119
  47. package/.github/workflows/ci.yml +0 -35
  48. package/BENCHMARKS.md +0 -67
  49. package/CONTRIBUTING.md +0 -40
  50. package/DRIPS_WAVE.md +0 -81
  51. package/FUNDING.json +0 -7
  52. package/ISSUES_PIPELINE.json +0 -106
  53. package/RUNBOOK.md +0 -95
  54. package/SCF_ACTIVATION_PROPOSAL.md +0 -137
  55. package/assets/sorobanagents_avatar.jpg +0 -0
  56. package/assets/sorobanagents_avatar.png +0 -0
  57. package/assets/sorobanagents_avatar_elite.png +0 -0
  58. package/contracts/agentrail/Cargo.lock +0 -1895
  59. package/contracts/agentrail/Cargo.toml +0 -25
  60. package/contracts/agentrail/src/lib.rs +0 -296
  61. package/contracts/agentrail/src/test.rs +0 -442
  62. package/contracts/agentrail/test_snapshots/test/test_circuit_breaker_pause_and_unpause.1.json +0 -195
  63. package/contracts/agentrail/test_snapshots/test/test_double_initialize_fails.1.json +0 -123
  64. package/contracts/agentrail/test_snapshots/test/test_execute_spend_deducts_and_accumulates.1.json +0 -347
  65. package/contracts/agentrail/test_snapshots/test/test_get_allowance_returns_none_for_unregistered.1.json +0 -61
  66. package/contracts/agentrail/test_snapshots/test/test_get_version_matches_cargo_toml.1.json +0 -61
  67. package/contracts/agentrail/test_snapshots/test/test_grant_allowance_negative_amount_fails.1.json +0 -123
  68. package/contracts/agentrail/test_snapshots/test/test_grant_allowance_success.1.json +0 -250
  69. package/contracts/agentrail/test_snapshots/test/test_grant_allowance_zero_amount_fails.1.json +0 -123
  70. package/contracts/agentrail/test_snapshots/test/test_initialize_and_protocol_fee.1.json +0 -154
  71. package/contracts/agentrail/test_snapshots/test/test_initialize_success.1.json +0 -124
  72. package/contracts/agentrail/test_snapshots/test/test_initialize_with_excessive_fee_fails.1.json +0 -61
  73. package/contracts/agentrail/test_snapshots/test/test_max_protocol_fee_spend_boundary.1.json +0 -298
  74. package/contracts/agentrail/test_snapshots/test/test_multi_agent_allowance_isolation.1.json +0 -426
  75. package/contracts/agentrail/test_snapshots/test/test_multi_owner_isolation.1.json +0 -426
  76. package/contracts/agentrail/test_snapshots/test/test_regrant_allowance_updates_limits.1.json +0 -346
  77. package/contracts/agentrail/test_snapshots/test/test_revoke_allowance_freezes_spending.1.json +0 -292
  78. package/contracts/agentrail/test_snapshots/test/test_set_protocol_fee_by_admin.1.json +0 -165
  79. package/contracts/agentrail/test_snapshots/test/test_spend_after_expiry_fails.1.json +0 -250
  80. package/contracts/agentrail/test_snapshots/test/test_spend_exact_allowance_boundary.1.json +0 -298
  81. package/contracts/agentrail/test_snapshots/test/test_spend_exceeding_allowance_fails.1.json +0 -250
  82. package/contracts/agentrail/test_snapshots/test/test_spend_fails_when_circuit_breaker_tripped.1.json +0 -285
  83. package/contracts/agentrail/test_snapshots/test/test_spend_negative_amount_fails.1.json +0 -250
  84. package/contracts/agentrail/test_snapshots/test/test_spend_non_existent_allowance_fails.1.json +0 -123
  85. package/contracts/agentrail/test_snapshots/test/test_spend_on_revoked_allowance_fails.1.json +0 -292
  86. package/contracts/agentrail/test_snapshots/test/test_spend_with_protocol_fee.1.json +0 -286
  87. package/contracts/agentrail/test_snapshots/test/test_spend_zero_amount_fails.1.json +0 -250
  88. package/contracts/agentrail/test_snapshots/test/test_unpause_restores_spend_operations.1.json +0 -370
  89. package/contracts/agentrail/test_snapshots/test/test_zero_protocol_fee_spend.1.json +0 -298
  90. package/deployment.testnet.json +0 -15
  91. package/docs/assets/favicon.png +0 -0
  92. package/docs/assets/logo.png +0 -0
  93. package/docs/index.html +0 -840
  94. package/scripts/demo-agent.ts +0 -52
  95. package/scripts/deploy-testnet.ts +0 -228
  96. package/scripts/security-audit.mjs +0 -159
  97. package/src/cli/sandbox.ts +0 -127
  98. package/src/index.ts +0 -11
  99. package/src/lib/micro-stream.ts +0 -52
  100. package/src/lib/proof-of-task.ts +0 -39
  101. package/src/lib/scoped-allowance.ts +0 -112
  102. package/src/lib/ttl-keeper.ts +0 -44
  103. package/src/sdk/agent-client.ts +0 -66
  104. package/src/types.ts +0 -78
  105. package/tests/agent-client.test.ts +0 -62
  106. package/tests/cli.test.ts +0 -68
  107. package/tests/micro-stream.test.ts +0 -38
  108. package/tests/proof-of-task.test.ts +0 -78
  109. package/tests/scoped-allowance.test.ts +0 -135
  110. package/tests/security-audit.test.ts +0 -76
  111. package/tests/ttl-keeper.test.ts +0 -36
  112. package/tsconfig.json +0 -16
  113. package/vitest.config.ts +0 -8
@@ -1,25 +0,0 @@
1
- [package]
2
- name = "agentrail-contract"
3
- version = "0.1.0"
4
- edition = "2021"
5
- license = "MIT"
6
- description = "Soroban Smart Contract for AgentRail Scoped Allowances & AI Agent Escrow"
7
-
8
- [lib]
9
- crate-type = ["cdylib", "rlib"]
10
-
11
- [dependencies]
12
- soroban-sdk = "27.0.2"
13
-
14
- [dev-dependencies]
15
- soroban-sdk = { version = "27.0.2", features = ["testutils"] }
16
-
17
- [profile.release]
18
- opt-level = "z"
19
- overflow-checks = true
20
- debug = 0
21
- strip = "symbols"
22
- debug-assertions = false
23
- panic = "abort"
24
- codegen-units = 1
25
- lto = true
@@ -1,296 +0,0 @@
1
- #![no_std]
2
- use soroban_sdk::{
3
- contract, contracterror, contractimpl, contracttype, symbol_short, Address, Env, String, Symbol,
4
- };
5
-
6
- #[contracterror]
7
- #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
8
- #[repr(u32)]
9
- pub enum Error {
10
- AlreadyInitialized = 1,
11
- NotInitialized = 2,
12
- Unauthorized = 3,
13
- AllowanceNotFound = 4,
14
- AllowanceExpired = 5,
15
- AllowanceExceeded = 6,
16
- AllowanceInactive = 7,
17
- InvalidAmount = 8,
18
- InvalidFeeBps = 9,
19
- ContractPaused = 10,
20
- }
21
-
22
- #[contracttype]
23
- #[derive(Clone, Debug, Eq, PartialEq)]
24
- pub struct ScopedAllowance {
25
- pub owner: Address,
26
- pub agent: Address,
27
- pub max_stroops: i128,
28
- pub spent_stroops: i128,
29
- pub valid_until: u64,
30
- pub active: bool,
31
- }
32
-
33
- #[contracttype]
34
- pub enum DataKey {
35
- Admin,
36
- Token,
37
- Treasury,
38
- ProtocolFeeBps,
39
- Paused,
40
- Allowance(Address, Address), // (Owner, Agent)
41
- }
42
-
43
- const ALLOWANCE_EVENT: Symbol = symbol_short!("allowance");
44
- const SPEND_EVENT: Symbol = symbol_short!("spend");
45
- const FEE_EVENT: Symbol = symbol_short!("fee");
46
- const CIRCUIT_EVENT: Symbol = symbol_short!("circuit");
47
-
48
- /// Maximum protocol fee is 500 bps (5.00%). Default is 20 bps (0.20%).
49
- pub const MAX_FEE_BPS: u32 = 500;
50
- pub const DEFAULT_FEE_BPS: u32 = 20;
51
- pub const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
52
-
53
- #[contract]
54
- pub struct AgentRailContract;
55
-
56
- #[contractimpl]
57
- impl AgentRailContract {
58
- /// Return the contract semver string matching Cargo.toml
59
- pub fn get_version(env: Env) -> String {
60
- String::from_str(&env, CONTRACT_VERSION)
61
- }
62
-
63
- /// Initialize the AgentRail Vault contract with an admin, settlement token (Circle USDC),
64
- /// treasury address for protocol monetization, and initial fee basis points.
65
- pub fn initialize(
66
- env: Env,
67
- admin: Address,
68
- token: Address,
69
- treasury: Address,
70
- fee_bps: u32,
71
- ) -> Result<(), Error> {
72
- if env.storage().instance().has(&DataKey::Admin) {
73
- return Err(Error::AlreadyInitialized);
74
- }
75
- if fee_bps > MAX_FEE_BPS {
76
- return Err(Error::InvalidFeeBps);
77
- }
78
-
79
- env.storage().instance().set(&DataKey::Admin, &admin);
80
- env.storage().instance().set(&DataKey::Token, &token);
81
- env.storage().instance().set(&DataKey::Treasury, &treasury);
82
- env.storage().instance().set(&DataKey::ProtocolFeeBps, &fee_bps);
83
- env.storage().instance().set(&DataKey::Paused, &false);
84
- Ok(())
85
- }
86
-
87
- /// Emergency Circuit Breaker: Freeze all spend transactions (requires admin auth).
88
- pub fn pause(env: Env) -> Result<(), Error> {
89
- let admin: Address = env
90
- .storage()
91
- .instance()
92
- .get(&DataKey::Admin)
93
- .ok_or(Error::NotInitialized)?;
94
- admin.require_auth();
95
-
96
- env.storage().instance().set(&DataKey::Paused, &true);
97
- env.events()
98
- .publish((CIRCUIT_EVENT, symbol_short!("pause")), (admin,));
99
- Ok(())
100
- }
101
-
102
- /// Unfreeze contract and restore spend execution (requires admin auth).
103
- pub fn unpause(env: Env) -> Result<(), Error> {
104
- let admin: Address = env
105
- .storage()
106
- .instance()
107
- .get(&DataKey::Admin)
108
- .ok_or(Error::NotInitialized)?;
109
- admin.require_auth();
110
-
111
- env.storage().instance().set(&DataKey::Paused, &false);
112
- env.events()
113
- .publish((CIRCUIT_EVENT, symbol_short!("unpause")), (admin,));
114
- Ok(())
115
- }
116
-
117
- /// Query current pause circuit breaker state.
118
- pub fn is_paused(env: Env) -> bool {
119
- env.storage().instance().get(&DataKey::Paused).unwrap_or(false)
120
- }
121
-
122
- /// Admin configuration to adjust protocol monetization fee & treasury address.
123
- pub fn set_protocol_fee(
124
- env: Env,
125
- treasury: Address,
126
- fee_bps: u32,
127
- ) -> Result<(), Error> {
128
- let admin: Address = env
129
- .storage()
130
- .instance()
131
- .get(&DataKey::Admin)
132
- .ok_or(Error::NotInitialized)?;
133
- admin.require_auth();
134
-
135
- if fee_bps > MAX_FEE_BPS {
136
- return Err(Error::InvalidFeeBps);
137
- }
138
-
139
- env.storage().instance().set(&DataKey::Treasury, &treasury);
140
- env.storage().instance().set(&DataKey::ProtocolFeeBps, &fee_bps);
141
-
142
- env.events()
143
- .publish((FEE_EVENT, symbol_short!("set")), (treasury, fee_bps));
144
-
145
- Ok(())
146
- }
147
-
148
- /// Retrieve the current protocol fee configuration: (treasury_address, fee_bps).
149
- pub fn get_protocol_fee(env: Env) -> Result<(Address, u32), Error> {
150
- let treasury: Address = env
151
- .storage()
152
- .instance()
153
- .get(&DataKey::Treasury)
154
- .ok_or(Error::NotInitialized)?;
155
- let fee_bps: u32 = env
156
- .storage()
157
- .instance()
158
- .get(&DataKey::ProtocolFeeBps)
159
- .unwrap_or(DEFAULT_FEE_BPS);
160
- Ok((treasury, fee_bps))
161
- }
162
-
163
- /// Grant a scoped allowance from a human owner to an autonomous AI agent keypair.
164
- pub fn grant_allowance(
165
- env: Env,
166
- owner: Address,
167
- agent: Address,
168
- max_stroops: i128,
169
- valid_until: u64,
170
- ) -> Result<(), Error> {
171
- owner.require_auth();
172
-
173
- if max_stroops <= 0 {
174
- return Err(Error::InvalidAmount);
175
- }
176
-
177
- let allowance = ScopedAllowance {
178
- owner: owner.clone(),
179
- agent: agent.clone(),
180
- max_stroops,
181
- spent_stroops: 0,
182
- valid_until,
183
- active: true,
184
- };
185
-
186
- let key = DataKey::Allowance(owner.clone(), agent.clone());
187
- env.storage().persistent().set(&key, &allowance);
188
-
189
- // Emit Soroban topic event for indexing
190
- env.events()
191
- .publish((ALLOWANCE_EVENT, symbol_short!("grant")), (owner, agent, max_stroops));
192
-
193
- Ok(())
194
- }
195
-
196
- /// Execute a micro-spend from an agent's active allowance.
197
- /// Calculates protocol fee routed to treasury and net amount to destination.
198
- pub fn execute_spend(
199
- env: Env,
200
- owner: Address,
201
- agent: Address,
202
- destination: Address,
203
- amount: i128,
204
- ) -> Result<(), Error> {
205
- // Enforce Circuit Breaker
206
- if Self::is_paused(env.clone()) {
207
- return Err(Error::ContractPaused);
208
- }
209
-
210
- agent.require_auth();
211
-
212
- if amount <= 0 {
213
- return Err(Error::InvalidAmount);
214
- }
215
-
216
- let key = DataKey::Allowance(owner.clone(), agent.clone());
217
- let mut allowance: ScopedAllowance = env
218
- .storage()
219
- .persistent()
220
- .get(&key)
221
- .ok_or(Error::AllowanceNotFound)?;
222
-
223
- if !allowance.active {
224
- return Err(Error::AllowanceInactive);
225
- }
226
-
227
- let now = env.ledger().timestamp();
228
- if now > allowance.valid_until {
229
- return Err(Error::AllowanceExpired);
230
- }
231
-
232
- let new_spent = allowance.spent_stroops.checked_add(amount).ok_or(Error::AllowanceExceeded)?;
233
- if new_spent > allowance.max_stroops {
234
- return Err(Error::AllowanceExceeded);
235
- }
236
-
237
- allowance.spent_stroops = new_spent;
238
- env.storage().persistent().set(&key, &allowance);
239
-
240
- // Compute Protocol Fee monetization
241
- let fee_bps: u32 = env
242
- .storage()
243
- .instance()
244
- .get(&DataKey::ProtocolFeeBps)
245
- .unwrap_or(0);
246
- let fee_amount = if fee_bps > 0 {
247
- (amount * fee_bps as i128) / 10_000
248
- } else {
249
- 0
250
- };
251
- let net_amount = amount - fee_amount;
252
-
253
- // Emit spend execution event
254
- env.events()
255
- .publish((SPEND_EVENT, symbol_short!("exec")), (agent, destination, net_amount));
256
-
257
- // If fee was deducted, emit fee event for treasury tracking
258
- if fee_amount > 0 {
259
- if let Some(treasury) = env.storage().instance().get::<DataKey, Address>(&DataKey::Treasury) {
260
- env.events()
261
- .publish((FEE_EVENT, symbol_short!("route")), (treasury, fee_amount));
262
- }
263
- }
264
-
265
- Ok(())
266
- }
267
-
268
- /// Revoke an active allowance immediately (emergency stop).
269
- pub fn revoke_allowance(env: Env, owner: Address, agent: Address) -> Result<(), Error> {
270
- owner.require_auth();
271
-
272
- let key = DataKey::Allowance(owner.clone(), agent.clone());
273
- let mut allowance: ScopedAllowance = env
274
- .storage()
275
- .persistent()
276
- .get(&key)
277
- .ok_or(Error::AllowanceNotFound)?;
278
-
279
- allowance.active = false;
280
- env.storage().persistent().set(&key, &allowance);
281
-
282
- env.events()
283
- .publish((ALLOWANCE_EVENT, symbol_short!("revoke")), (owner, agent));
284
-
285
- Ok(())
286
- }
287
-
288
- /// Fetch allowance status
289
- pub fn get_allowance(env: Env, owner: Address, agent: Address) -> Option<ScopedAllowance> {
290
- let key = DataKey::Allowance(owner, agent);
291
- env.storage().persistent().get(&key)
292
- }
293
- }
294
-
295
- #[cfg(test)]
296
- mod test;