@agirails/sdk 3.3.0 → 3.5.3

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 (130) hide show
  1. package/dist/api/agirailsApp.d.ts +21 -1
  2. package/dist/api/agirailsApp.d.ts.map +1 -1
  3. package/dist/api/agirailsApp.js.map +1 -1
  4. package/dist/builders/CounterAcceptBuilder.d.ts +96 -0
  5. package/dist/builders/CounterAcceptBuilder.d.ts.map +1 -0
  6. package/dist/builders/CounterAcceptBuilder.js +226 -0
  7. package/dist/builders/CounterAcceptBuilder.js.map +1 -0
  8. package/dist/builders/CounterOfferBuilder.d.ts +143 -0
  9. package/dist/builders/CounterOfferBuilder.d.ts.map +1 -0
  10. package/dist/builders/CounterOfferBuilder.js +329 -0
  11. package/dist/builders/CounterOfferBuilder.js.map +1 -0
  12. package/dist/builders/QuoteBuilder.d.ts +9 -3
  13. package/dist/builders/QuoteBuilder.d.ts.map +1 -1
  14. package/dist/builders/QuoteBuilder.js +22 -6
  15. package/dist/builders/QuoteBuilder.js.map +1 -1
  16. package/dist/builders/index.d.ts +2 -0
  17. package/dist/builders/index.d.ts.map +1 -1
  18. package/dist/builders/index.js +7 -1
  19. package/dist/builders/index.js.map +1 -1
  20. package/dist/cli/agirails.js +22 -2
  21. package/dist/cli/agirails.js.map +1 -1
  22. package/dist/cli/commands/agent.d.ts +22 -0
  23. package/dist/cli/commands/agent.d.ts.map +1 -0
  24. package/dist/cli/commands/agent.js +209 -0
  25. package/dist/cli/commands/agent.js.map +1 -0
  26. package/dist/cli/commands/health.js +21 -5
  27. package/dist/cli/commands/health.js.map +1 -1
  28. package/dist/cli/commands/init.d.ts.map +1 -1
  29. package/dist/cli/commands/init.js +25 -5
  30. package/dist/cli/commands/init.js.map +1 -1
  31. package/dist/cli/commands/publish.d.ts +34 -0
  32. package/dist/cli/commands/publish.d.ts.map +1 -1
  33. package/dist/cli/commands/publish.js +256 -80
  34. package/dist/cli/commands/publish.js.map +1 -1
  35. package/dist/cli/commands/repair.d.ts +23 -0
  36. package/dist/cli/commands/repair.d.ts.map +1 -0
  37. package/dist/cli/commands/repair.js +210 -0
  38. package/dist/cli/commands/repair.js.map +1 -0
  39. package/dist/cli/commands/serve.d.ts +38 -0
  40. package/dist/cli/commands/serve.d.ts.map +1 -0
  41. package/dist/cli/commands/serve.js +308 -0
  42. package/dist/cli/commands/serve.js.map +1 -0
  43. package/dist/cli/commands/test.js +2 -2
  44. package/dist/cli/commands/test.js.map +1 -1
  45. package/dist/cli/index.js +10 -0
  46. package/dist/cli/index.js.map +1 -1
  47. package/dist/config/agirailsmdV4.d.ts +46 -1
  48. package/dist/config/agirailsmdV4.d.ts.map +1 -1
  49. package/dist/config/agirailsmdV4.js +65 -8
  50. package/dist/config/agirailsmdV4.js.map +1 -1
  51. package/dist/config/defaults.d.ts +10 -0
  52. package/dist/config/defaults.d.ts.map +1 -1
  53. package/dist/config/defaults.js +10 -0
  54. package/dist/config/defaults.js.map +1 -1
  55. package/dist/config/networks.d.ts.map +1 -1
  56. package/dist/config/networks.js +7 -1
  57. package/dist/config/networks.js.map +1 -1
  58. package/dist/config/publishPipeline.d.ts +23 -1
  59. package/dist/config/publishPipeline.d.ts.map +1 -1
  60. package/dist/config/publishPipeline.js +70 -15
  61. package/dist/config/publishPipeline.js.map +1 -1
  62. package/dist/index.d.ts +26 -0
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +39 -3
  65. package/dist/index.js.map +1 -1
  66. package/dist/level1/Agent.d.ts +27 -0
  67. package/dist/level1/Agent.d.ts.map +1 -1
  68. package/dist/level1/Agent.js +77 -6
  69. package/dist/level1/Agent.js.map +1 -1
  70. package/dist/negotiation/BuyerOrchestrator.d.ts +115 -1
  71. package/dist/negotiation/BuyerOrchestrator.d.ts.map +1 -1
  72. package/dist/negotiation/BuyerOrchestrator.js +530 -4
  73. package/dist/negotiation/BuyerOrchestrator.js.map +1 -1
  74. package/dist/negotiation/DecisionEngine.d.ts +69 -1
  75. package/dist/negotiation/DecisionEngine.d.ts.map +1 -1
  76. package/dist/negotiation/DecisionEngine.js +140 -1
  77. package/dist/negotiation/DecisionEngine.js.map +1 -1
  78. package/dist/negotiation/MockChannel.d.ts +63 -0
  79. package/dist/negotiation/MockChannel.d.ts.map +1 -0
  80. package/dist/negotiation/MockChannel.js +175 -0
  81. package/dist/negotiation/MockChannel.js.map +1 -0
  82. package/dist/negotiation/NegotiationChannel.d.ts +142 -0
  83. package/dist/negotiation/NegotiationChannel.d.ts.map +1 -0
  84. package/dist/negotiation/NegotiationChannel.js +59 -0
  85. package/dist/negotiation/NegotiationChannel.js.map +1 -0
  86. package/dist/negotiation/PolicyEngine.d.ts +32 -0
  87. package/dist/negotiation/PolicyEngine.d.ts.map +1 -1
  88. package/dist/negotiation/PolicyEngine.js.map +1 -1
  89. package/dist/negotiation/ProviderOrchestrator.d.ts +158 -0
  90. package/dist/negotiation/ProviderOrchestrator.d.ts.map +1 -0
  91. package/dist/negotiation/ProviderOrchestrator.js +286 -0
  92. package/dist/negotiation/ProviderOrchestrator.js.map +1 -0
  93. package/dist/negotiation/ProviderPolicy.d.ts +188 -0
  94. package/dist/negotiation/ProviderPolicy.d.ts.map +1 -0
  95. package/dist/negotiation/ProviderPolicy.js +259 -0
  96. package/dist/negotiation/ProviderPolicy.js.map +1 -0
  97. package/dist/negotiation/RelayChannel.d.ts +59 -0
  98. package/dist/negotiation/RelayChannel.d.ts.map +1 -0
  99. package/dist/negotiation/RelayChannel.js +208 -0
  100. package/dist/negotiation/RelayChannel.js.map +1 -0
  101. package/dist/negotiation/index.d.ts +8 -1
  102. package/dist/negotiation/index.d.ts.map +1 -1
  103. package/dist/negotiation/index.js +8 -1
  104. package/dist/negotiation/index.js.map +1 -1
  105. package/dist/negotiation/verifyQuoteOnChain.d.ts +58 -0
  106. package/dist/negotiation/verifyQuoteOnChain.d.ts.map +1 -0
  107. package/dist/negotiation/verifyQuoteOnChain.js +83 -0
  108. package/dist/negotiation/verifyQuoteOnChain.js.map +1 -0
  109. package/dist/protocol/ACTPKernel.d.ts.map +1 -1
  110. package/dist/protocol/ACTPKernel.js +51 -1
  111. package/dist/protocol/ACTPKernel.js.map +1 -1
  112. package/dist/runtime/BlockchainRuntime.d.ts +13 -0
  113. package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
  114. package/dist/runtime/BlockchainRuntime.js +33 -2
  115. package/dist/runtime/BlockchainRuntime.js.map +1 -1
  116. package/dist/runtime/IACTPRuntime.d.ts +35 -0
  117. package/dist/runtime/IACTPRuntime.d.ts.map +1 -1
  118. package/dist/runtime/MockRuntime.d.ts +11 -0
  119. package/dist/runtime/MockRuntime.d.ts.map +1 -1
  120. package/dist/runtime/MockRuntime.js +39 -0
  121. package/dist/runtime/MockRuntime.js.map +1 -1
  122. package/dist/runtime/types/MockState.d.ts +10 -0
  123. package/dist/runtime/types/MockState.d.ts.map +1 -1
  124. package/dist/runtime/types/MockState.js.map +1 -1
  125. package/dist/transport/QuoteChannel.d.ts +201 -0
  126. package/dist/transport/QuoteChannel.d.ts.map +1 -0
  127. package/dist/transport/QuoteChannel.js +358 -0
  128. package/dist/transport/QuoteChannel.js.map +1 -0
  129. package/dist/types/adapter.d.ts +24 -24
  130. package/package.json +16 -1
@@ -0,0 +1,358 @@
1
+ "use strict";
2
+ /**
3
+ * QuoteChannel — HTTPS transport for AIP-2.1 quote + counter-offer messages.
4
+ *
5
+ * Split into three responsibilities so the SDK is framework-agnostic:
6
+ *
7
+ * 1. `QuoteChannelClient` — sends a signed message to a peer's endpoint.
8
+ * Used by buyers (posting counter-offers to the provider) and by
9
+ * providers (posting quotes to the buyer). Plain fetch + timeout.
10
+ *
11
+ * 2. `QuoteChannelHandler` — framework-agnostic receive-side handler.
12
+ * Callers wire it into whatever HTTP framework they use (Express,
13
+ * Next.js route handler, Fastify, etc). Enforces the security model
14
+ * from AIP-2.1-DRAFT §8:
15
+ * - URL path binding: `/quote-channel/{chainId}/{txId}` must
16
+ * match message.chainId / message.txId (closes T2 + T5).
17
+ * - EIP-712 signature verification (closes "anyone can POST").
18
+ * - TTL + grace window (closes T3).
19
+ * - Nonce LRU dedup (closes T1, idempotent replay).
20
+ * Rate limiting is intentionally out of scope — framework-level
21
+ * concern (Next.js middleware, Express rate-limit, nginx, etc).
22
+ *
23
+ * 3. `DedupStore` — swappable backing for the nonce LRU. In-memory
24
+ * default for single-process use; callers can plug Redis etc. for
25
+ * multi-worker production.
26
+ *
27
+ * @module transport/QuoteChannel
28
+ * @see Protocol/aips/AIP-2.1-DRAFT.md §8 (threat model + mitigations)
29
+ */
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.assertSafePeerUrl = exports.QuoteChannelHandler = exports.QuoteChannelClient = exports.InMemoryDedupStore = exports.DEDUP_TTL_SECONDS = exports.TTL_GRACE_SECONDS = exports.buildChannelPath = void 0;
32
+ const QuoteBuilder_1 = require("../builders/QuoteBuilder");
33
+ const CounterOfferBuilder_1 = require("../builders/CounterOfferBuilder");
34
+ const NonceManager_1 = require("../utils/NonceManager");
35
+ const ethers_1 = require("ethers");
36
+ // ============================================================================
37
+ // Constants (exported for tests + callers that want to align)
38
+ // ============================================================================
39
+ /** Path pattern builders use / handlers expect. */
40
+ function buildChannelPath(chainId, txId) {
41
+ return `/quote-channel/${chainId}/${txId}`;
42
+ }
43
+ exports.buildChannelPath = buildChannelPath;
44
+ exports.TTL_GRACE_SECONDS = 30;
45
+ exports.DEDUP_TTL_SECONDS = 90000; // 25h (covers max quote TTL + grace)
46
+ /**
47
+ * Single-process in-memory LRU. Callers replace this in production
48
+ * with a distributed store (Redis SET NX EX, DynamoDB conditional put,
49
+ * Postgres INSERT ... ON CONFLICT DO NOTHING, etc).
50
+ *
51
+ * Atomicity here is free because JavaScript event-loop execution is
52
+ * single-threaded — a `recordOnce` call cannot be interrupted mid-way.
53
+ * Multi-worker deployments MUST use a real distributed store or will
54
+ * see duplicate 'recorded' returns across workers.
55
+ */
56
+ class InMemoryDedupStore {
57
+ constructor(maxSize = 10000) {
58
+ this.entries = new Map(); // key → expires_at_ms
59
+ this.maxSize = maxSize;
60
+ }
61
+ async recordOnce(key, ttlMs) {
62
+ this.dropExpired();
63
+ const now = Date.now();
64
+ const exp = this.entries.get(key);
65
+ if (exp !== undefined && exp > now) {
66
+ return 'duplicate';
67
+ }
68
+ // Atomic in single-threaded JS — the check above and this set happen
69
+ // without any await in between, so no other task can interleave.
70
+ this.entries.set(key, now + ttlMs);
71
+ // Trim AFTER the set so `size <= maxSize` is an invariant. Trimming
72
+ // before the set would still leave the map at maxSize+1 after set.
73
+ this.trimToSize();
74
+ return 'recorded';
75
+ }
76
+ /** Drop entries whose TTL has elapsed. O(n) — fine for our sizes. */
77
+ dropExpired() {
78
+ const now = Date.now();
79
+ for (const [k, exp] of this.entries) {
80
+ if (exp <= now)
81
+ this.entries.delete(k);
82
+ }
83
+ }
84
+ /** Bound the map at `maxSize` by evicting oldest-inserted keys. */
85
+ trimToSize() {
86
+ while (this.entries.size > this.maxSize) {
87
+ const firstKey = this.entries.keys().next().value;
88
+ if (firstKey === undefined)
89
+ break;
90
+ this.entries.delete(firstKey);
91
+ }
92
+ }
93
+ }
94
+ exports.InMemoryDedupStore = InMemoryDedupStore;
95
+ class QuoteChannelClient {
96
+ constructor(cfg = {}) {
97
+ this.timeoutMs = cfg.timeoutMs ?? 10000;
98
+ this.fetchImpl = cfg.fetchImpl ?? fetch;
99
+ this.allowInsecureTargets = cfg.allowInsecureTargets ?? false;
100
+ }
101
+ /** POST a provider quote to the buyer's endpoint. */
102
+ async sendQuote(peerEndpoint, quote) {
103
+ await this.post(peerEndpoint, quote.chainId, quote.txId, {
104
+ type: 'agirails.quote.v1',
105
+ message: quote,
106
+ });
107
+ }
108
+ /** POST a buyer counter-offer to the provider's endpoint. */
109
+ async sendCounter(peerEndpoint, counter) {
110
+ await this.post(peerEndpoint, counter.chainId, counter.txId, {
111
+ type: 'agirails.counteroffer.v1',
112
+ message: counter,
113
+ });
114
+ }
115
+ async post(peerEndpoint, chainId, txId, payload) {
116
+ const url = `${stripTrailingSlash(peerEndpoint)}${buildChannelPath(chainId, txId)}`;
117
+ // SSRF guard. Peer endpoints come from on-chain AgentRegistry / the
118
+ // agirails.app DB — both technically writable by an adversary. A
119
+ // malicious endpoint pointing at http://169.254.169.254/ (AWS metadata),
120
+ // http://localhost:8080 (internal service), or http://10.x.x.x (RFC1918
121
+ // internal) would have the client leak signed payloads inside the
122
+ // deployer's infrastructure. Fail fast in `new URL()` + string checks.
123
+ assertSafePeerUrl(url, this.allowInsecureTargets);
124
+ const controller = new AbortController();
125
+ const timer = setTimeout(() => controller.abort(), this.timeoutMs);
126
+ try {
127
+ const res = await this.fetchImpl(url, {
128
+ method: 'POST',
129
+ headers: { 'Content-Type': 'application/json' },
130
+ body: JSON.stringify(payload),
131
+ signal: controller.signal,
132
+ });
133
+ if (!res.ok) {
134
+ const text = await res.text().catch(() => '');
135
+ throw new Error(`Quote channel POST failed: ${res.status} ${res.statusText}${text ? ` — ${text}` : ''}`);
136
+ }
137
+ }
138
+ finally {
139
+ clearTimeout(timer);
140
+ }
141
+ }
142
+ }
143
+ exports.QuoteChannelClient = QuoteChannelClient;
144
+ class QuoteChannelHandler {
145
+ constructor(cfg) {
146
+ this.kernelAddressByChainId = cfg.kernelAddressByChainId;
147
+ this.dedupStore = cfg.dedupStore ?? new InMemoryDedupStore();
148
+ this.ttlGraceSeconds = cfg.ttlGraceSeconds ?? exports.TTL_GRACE_SECONDS;
149
+ const throwawayWallet = ethers_1.Wallet.createRandom();
150
+ const throwawayNonces = new NonceManager_1.InMemoryNonceManager();
151
+ this.quoteVerifier = new QuoteBuilder_1.QuoteBuilder(throwawayWallet, throwawayNonces);
152
+ this.counterVerifier = new CounterOfferBuilder_1.CounterOfferBuilder(throwawayWallet, throwawayNonces);
153
+ }
154
+ /**
155
+ * Validate + dedup an incoming POST.
156
+ * Caller is responsible for: parsing URL path into `pathChainId` /
157
+ * `pathTxId`, parsing request body into `ChannelPayload`, and rate
158
+ * limiting the endpoint at the framework level.
159
+ */
160
+ async handle(payload, ctx) {
161
+ // 1. Shape check on the payload wrapper.
162
+ if (!isChannelPayload(payload)) {
163
+ return {
164
+ status: 400,
165
+ body: { accepted: false, reason: 'Invalid payload shape' },
166
+ };
167
+ }
168
+ // 2. Path binding — the URL path chainId/txId MUST match the inner message.
169
+ if (payload.message.chainId !== ctx.pathChainId) {
170
+ return {
171
+ status: 400,
172
+ body: { accepted: false, reason: 'chainId mismatch between URL and message' },
173
+ };
174
+ }
175
+ if (payload.message.txId.toLowerCase() !== ctx.pathTxId.toLowerCase()) {
176
+ return {
177
+ status: 400,
178
+ body: { accepted: false, reason: 'txId mismatch between URL and message' },
179
+ };
180
+ }
181
+ // 3. Kernel address must be configured for this chain.
182
+ const kernelAddress = this.kernelAddressByChainId[payload.message.chainId];
183
+ if (!kernelAddress) {
184
+ return {
185
+ status: 400,
186
+ body: { accepted: false, reason: `Unsupported chainId: ${payload.message.chainId}` },
187
+ };
188
+ }
189
+ // 4. TTL + grace. Check expiry BEFORE signature to fast-reject stale traffic
190
+ // cheaply; signature verification is the expensive step.
191
+ const now = Math.floor(Date.now() / 1000);
192
+ if (payload.message.expiresAt + this.ttlGraceSeconds < now) {
193
+ return {
194
+ status: 410,
195
+ body: { accepted: false, reason: 'Message expired' },
196
+ };
197
+ }
198
+ // 5. Signature verification + business rules (delegated to the builder).
199
+ try {
200
+ if (payload.type === 'agirails.quote.v1') {
201
+ await this.quoteVerifier.verify(payload.message, kernelAddress);
202
+ }
203
+ else {
204
+ await this.counterVerifier.verify(payload.message, kernelAddress);
205
+ }
206
+ }
207
+ catch (err) {
208
+ const reason = err instanceof Error ? err.message : String(err);
209
+ // Signature failures vs schema/band failures are both client errors;
210
+ // distinguish with 401 (auth) vs 422 (validation) for better diagnostics.
211
+ const isAuth = /signature|Invalid signature|recovered/i.test(reason);
212
+ return {
213
+ status: isAuth ? 401 : 422,
214
+ body: { accepted: false, reason },
215
+ };
216
+ }
217
+ // 6. Dedup via nonce LRU. Key is (type, signerDID, nonce) — uniquely
218
+ // identifies a signed message within its issuing agent's nonce space.
219
+ // Single atomic recordOnce() call (not check-then-record) so concurrent
220
+ // workers competing on the same key see exactly one 'recorded'; the
221
+ // rest see 'duplicate' and return the idempotent cached response.
222
+ const signerDID = payload.type === 'agirails.quote.v1'
223
+ ? payload.message.provider
224
+ : payload.message.consumer;
225
+ const dedupKey = `${payload.type}:${signerDID}:${payload.message.nonce}`;
226
+ const outcome = await this.dedupStore.recordOnce(dedupKey, exports.DEDUP_TTL_SECONDS * 1000);
227
+ if (outcome === 'duplicate') {
228
+ return { status: 200, body: { accepted: true, duplicate: true } };
229
+ }
230
+ return { status: 201, body: { accepted: true, duplicate: false } };
231
+ }
232
+ }
233
+ exports.QuoteChannelHandler = QuoteChannelHandler;
234
+ // ============================================================================
235
+ // Helpers
236
+ // ============================================================================
237
+ function stripTrailingSlash(url) {
238
+ return url.endsWith('/') ? url.slice(0, -1) : url;
239
+ }
240
+ /**
241
+ * Reject peer URLs that could SSRF into local / internal infrastructure.
242
+ *
243
+ * Rules (default, `allowInsecureTargets=false`):
244
+ * - scheme MUST be https
245
+ * - hostname MUST NOT be `localhost`
246
+ * - hostname MUST NOT be a literal loopback IP (127.x.x.x, ::1)
247
+ * - hostname MUST NOT be a literal link-local IP (169.254.x.x, fe80::/10)
248
+ * — this also covers AWS metadata at 169.254.169.254
249
+ * - hostname MUST NOT be a literal RFC1918 private IP (10.x, 172.16-31.x,
250
+ * 192.168.x) or IPv6 ULA (fc00::/7)
251
+ *
252
+ * Dev mode (`allowInsecureTargets=true`): no restrictions, callers
253
+ * opting in are responsible for their own network security.
254
+ *
255
+ * @throws Error if the URL fails the checks. Error message is deliberately
256
+ * specific so test fixtures and diagnostics can assert on it.
257
+ * @internal Exported for unit tests.
258
+ */
259
+ function assertSafePeerUrl(url, allowInsecureTargets) {
260
+ let parsed;
261
+ try {
262
+ parsed = new URL(url);
263
+ }
264
+ catch {
265
+ throw new Error(`Invalid peer URL: ${url}`);
266
+ }
267
+ if (allowInsecureTargets)
268
+ return;
269
+ if (parsed.protocol !== 'https:') {
270
+ throw new Error(`Peer URL must use https:// (got ${parsed.protocol}//). ` +
271
+ `Set allowInsecureTargets=true on the QuoteChannelClient for dev/test only.`);
272
+ }
273
+ // Node's URL() keeps brackets around IPv6 hosts. Strip them so the
274
+ // downstream string checks work uniformly for IPv4 and IPv6 literals.
275
+ const rawHost = parsed.hostname.toLowerCase();
276
+ const stripped = rawHost.startsWith('[') && rawHost.endsWith(']')
277
+ ? rawHost.slice(1, -1)
278
+ : rawHost;
279
+ // IPv4-mapped IPv6 — the OS resolves this to the corresponding IPv4
280
+ // address, so the same loopback / RFC1918 / link-local rules MUST apply.
281
+ // Two normalized shapes can come out of Node's URL():
282
+ // 1. dotted-quad: `::ffff:127.0.0.1` (rare, some Node versions)
283
+ // 2. hex pair: `::ffff:7f00:1` (Node default — folds the v4 octets)
284
+ // Without this re-extraction, an attacker crafts `[::ffff:127.0.0.1]`
285
+ // or `[::ffff:169.254.169.254]` and bypasses the IPv4 checks below
286
+ // (which only match dotted-quad).
287
+ let host = stripped;
288
+ const mappedDotted = stripped.match(/^::ffff:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
289
+ const mappedHex = stripped.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/);
290
+ if (mappedDotted) {
291
+ host = mappedDotted[1];
292
+ }
293
+ else if (mappedHex) {
294
+ const hi = parseInt(mappedHex[1], 16);
295
+ const lo = parseInt(mappedHex[2], 16);
296
+ host = `${(hi >> 8) & 0xff}.${hi & 0xff}.${(lo >> 8) & 0xff}.${lo & 0xff}`;
297
+ }
298
+ if (host === 'localhost' || host.endsWith('.localhost')) {
299
+ throw new Error(`Peer URL points at localhost (${host}) — refusing (SSRF guard)`);
300
+ }
301
+ // IPv4 literals
302
+ const ipv4 = host.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
303
+ if (ipv4) {
304
+ const [, a, b] = ipv4.map(Number);
305
+ if (a === 127) {
306
+ throw new Error(`Peer URL points at loopback IP (${host}) — refusing (SSRF guard)`);
307
+ }
308
+ if (a === 169 && b === 254) {
309
+ throw new Error(`Peer URL points at link-local / cloud-metadata IP (${host}) — refusing (SSRF guard)`);
310
+ }
311
+ if (a === 10) {
312
+ throw new Error(`Peer URL points at RFC1918 10.x.x.x (${host}) — refusing (SSRF guard)`);
313
+ }
314
+ if (a === 192 && b === 168) {
315
+ throw new Error(`Peer URL points at RFC1918 192.168.x.x (${host}) — refusing (SSRF guard)`);
316
+ }
317
+ if (a === 172 && b >= 16 && b <= 31) {
318
+ throw new Error(`Peer URL points at RFC1918 172.16-31.x (${host}) — refusing (SSRF guard)`);
319
+ }
320
+ }
321
+ // IPv6 literals — URL() wraps with brackets; the hostname getter strips them.
322
+ if (host === '::1') {
323
+ throw new Error(`Peer URL points at IPv6 loopback (${host}) — refusing (SSRF guard)`);
324
+ }
325
+ if (host.startsWith('fe80:') || host.startsWith('fe80::')) {
326
+ throw new Error(`Peer URL points at IPv6 link-local (${host}) — refusing (SSRF guard)`);
327
+ }
328
+ // IPv6 ULA fc00::/7 → high byte starts with 0xfc or 0xfd.
329
+ if (host.startsWith('fc') || host.startsWith('fd')) {
330
+ // Narrow to the fc00::/7 pattern: fc?? or fd?? as the first group.
331
+ if (/^(fc|fd)[0-9a-f]{0,2}:/.test(host)) {
332
+ throw new Error(`Peer URL points at IPv6 ULA (${host}) — refusing (SSRF guard)`);
333
+ }
334
+ }
335
+ }
336
+ exports.assertSafePeerUrl = assertSafePeerUrl;
337
+ function isChannelPayload(x) {
338
+ if (!x || typeof x !== 'object')
339
+ return false;
340
+ const p = x;
341
+ if (p.type !== 'agirails.quote.v1' && p.type !== 'agirails.counteroffer.v1')
342
+ return false;
343
+ if (!p.message || typeof p.message !== 'object')
344
+ return false;
345
+ const msg = p.message;
346
+ if (typeof msg.chainId !== 'number')
347
+ return false;
348
+ if (typeof msg.txId !== 'string')
349
+ return false;
350
+ if (typeof msg.nonce !== 'number')
351
+ return false;
352
+ if (typeof msg.expiresAt !== 'number')
353
+ return false;
354
+ if (typeof msg.signature !== 'string')
355
+ return false;
356
+ return true;
357
+ }
358
+ //# sourceMappingURL=QuoteChannel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuoteChannel.js","sourceRoot":"","sources":["../../src/transport/QuoteChannel.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AAEH,2DAAsE;AACtE,yEAA2F;AAC3F,wDAA6D;AAC7D,mCAAgC;AAEhC,+EAA+E;AAC/E,8DAA8D;AAC9D,+EAA+E;AAE/E,mDAAmD;AACnD,SAAgB,gBAAgB,CAAC,OAAe,EAAE,IAAY;IAC5D,OAAO,kBAAkB,OAAO,IAAI,IAAI,EAAE,CAAC;AAC7C,CAAC;AAFD,4CAEC;AAEY,QAAA,iBAAiB,GAAG,EAAE,CAAC;AACvB,QAAA,iBAAiB,GAAG,KAAM,CAAC,CAAC,qCAAqC;AAwC9E;;;;;;;;;GASG;AACH,MAAa,kBAAkB;IAI7B,YAAY,OAAO,GAAG,KAAM;QAHX,YAAO,GAAwB,IAAI,GAAG,EAAE,CAAC,CAAC,sBAAsB;QAI/E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,GAAW,EAAE,KAAa;QACzC,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC;YACnC,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,qEAAqE;QACrE,iEAAiE;QACjE,IAAI,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CAAC,GAAG,CAA4B,CAAC;IACvC,IAAI,CAAC,CAAC,IAAI,KAAK,mBAAmB,IAAI,CAAC,CAAC,IAAI,KAAK,0BAA0B;QAAE,OAAO,KAAK,CAAC;IAC1F,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,GAAG,GAAG,CAAC,CAAC,OAAkC,CAAC;IACjD,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAClD,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC/C,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAChD,IAAI,OAAO,GAAG,CAAC,SAAS,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACpD,IAAI,OAAO,GAAG,CAAC,SAAS,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACpD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -55,8 +55,8 @@ export declare const AdapterMetadataSchema: z.ZodObject<{
55
55
  settlementMode: z.ZodEnum<["explicit", "timed", "atomic"]>;
56
56
  priority: z.ZodNumber;
57
57
  }, "strip", z.ZodTypeAny, {
58
- id: string;
59
58
  name: string;
59
+ id: string;
60
60
  usesEscrow: boolean;
61
61
  supportsDisputes: boolean;
62
62
  requiresIdentity: boolean;
@@ -64,8 +64,8 @@ export declare const AdapterMetadataSchema: z.ZodObject<{
64
64
  priority: number;
65
65
  supportedIdentityTypes?: string[] | undefined;
66
66
  }, {
67
- id: string;
68
67
  name: string;
68
+ id: string;
69
69
  usesEscrow: boolean;
70
70
  supportsDisputes: boolean;
71
71
  requiresIdentity: boolean;
@@ -102,11 +102,11 @@ export declare const PaymentIdentitySchema: z.ZodObject<{
102
102
  type: z.ZodEnum<["erc8004", "did", "ens", "address"]>;
103
103
  value: z.ZodString;
104
104
  }, "strip", z.ZodTypeAny, {
105
- type: "address" | "erc8004" | "did" | "ens";
106
105
  value: string;
106
+ type: "did" | "address" | "erc8004" | "ens";
107
107
  }, {
108
- type: "address" | "erc8004" | "did" | "ens";
109
108
  value: string;
109
+ type: "did" | "address" | "erc8004" | "ens";
110
110
  }>;
111
111
  /**
112
112
  * Zod schema for PaymentMetadata runtime validation.
@@ -119,11 +119,11 @@ export declare const PaymentMetadataSchema: z.ZodObject<{
119
119
  type: z.ZodEnum<["erc8004", "did", "ens", "address"]>;
120
120
  value: z.ZodString;
121
121
  }, "strip", z.ZodTypeAny, {
122
- type: "address" | "erc8004" | "did" | "ens";
123
122
  value: string;
123
+ type: "did" | "address" | "erc8004" | "ens";
124
124
  }, {
125
- type: "address" | "erc8004" | "did" | "ens";
126
125
  value: string;
126
+ type: "did" | "address" | "erc8004" | "ens";
127
127
  }>>;
128
128
  paymentMethod: z.ZodOptional<z.ZodEnum<["x402", "actp", "auto"]>>;
129
129
  }, "strip", z.ZodTypeAny, {
@@ -131,8 +131,8 @@ export declare const PaymentMetadataSchema: z.ZodObject<{
131
131
  requiresEscrow?: boolean | undefined;
132
132
  requiresDispute?: boolean | undefined;
133
133
  identity?: {
134
- type: "address" | "erc8004" | "did" | "ens";
135
134
  value: string;
135
+ type: "did" | "address" | "erc8004" | "ens";
136
136
  } | undefined;
137
137
  paymentMethod?: "x402" | "actp" | "auto" | undefined;
138
138
  }, {
@@ -140,8 +140,8 @@ export declare const PaymentMetadataSchema: z.ZodObject<{
140
140
  requiresEscrow?: boolean | undefined;
141
141
  requiresDispute?: boolean | undefined;
142
142
  identity?: {
143
- type: "address" | "erc8004" | "did" | "ens";
144
143
  value: string;
144
+ type: "did" | "address" | "erc8004" | "ens";
145
145
  } | undefined;
146
146
  paymentMethod?: "x402" | "actp" | "auto" | undefined;
147
147
  }>;
@@ -201,11 +201,11 @@ export declare const UnifiedPayParamsSchema: z.ZodObject<{
201
201
  type: z.ZodEnum<["erc8004", "did", "ens", "address"]>;
202
202
  value: z.ZodString;
203
203
  }, "strip", z.ZodTypeAny, {
204
- type: "address" | "erc8004" | "did" | "ens";
205
204
  value: string;
205
+ type: "did" | "address" | "erc8004" | "ens";
206
206
  }, {
207
- type: "address" | "erc8004" | "did" | "ens";
208
207
  value: string;
208
+ type: "did" | "address" | "erc8004" | "ens";
209
209
  }>>;
210
210
  paymentMethod: z.ZodOptional<z.ZodEnum<["x402", "actp", "auto"]>>;
211
211
  }, "strip", z.ZodTypeAny, {
@@ -213,8 +213,8 @@ export declare const UnifiedPayParamsSchema: z.ZodObject<{
213
213
  requiresEscrow?: boolean | undefined;
214
214
  requiresDispute?: boolean | undefined;
215
215
  identity?: {
216
- type: "address" | "erc8004" | "did" | "ens";
217
216
  value: string;
217
+ type: "did" | "address" | "erc8004" | "ens";
218
218
  } | undefined;
219
219
  paymentMethod?: "x402" | "actp" | "auto" | undefined;
220
220
  }, {
@@ -222,8 +222,8 @@ export declare const UnifiedPayParamsSchema: z.ZodObject<{
222
222
  requiresEscrow?: boolean | undefined;
223
223
  requiresDispute?: boolean | undefined;
224
224
  identity?: {
225
- type: "address" | "erc8004" | "did" | "ens";
226
225
  value: string;
226
+ type: "did" | "address" | "erc8004" | "ens";
227
227
  } | undefined;
228
228
  paymentMethod?: "x402" | "actp" | "auto" | undefined;
229
229
  }>>;
@@ -242,8 +242,8 @@ export declare const UnifiedPayParamsSchema: z.ZodObject<{
242
242
  requiresEscrow?: boolean | undefined;
243
243
  requiresDispute?: boolean | undefined;
244
244
  identity?: {
245
- type: "address" | "erc8004" | "did" | "ens";
246
245
  value: string;
246
+ type: "did" | "address" | "erc8004" | "ens";
247
247
  } | undefined;
248
248
  paymentMethod?: "x402" | "actp" | "auto" | undefined;
249
249
  } | undefined;
@@ -262,8 +262,8 @@ export declare const UnifiedPayParamsSchema: z.ZodObject<{
262
262
  requiresEscrow?: boolean | undefined;
263
263
  requiresDispute?: boolean | undefined;
264
264
  identity?: {
265
- type: "address" | "erc8004" | "did" | "ens";
266
265
  value: string;
266
+ type: "did" | "address" | "erc8004" | "ens";
267
267
  } | undefined;
268
268
  paymentMethod?: "x402" | "actp" | "auto" | undefined;
269
269
  } | undefined;
@@ -369,18 +369,18 @@ export declare const UnifiedPayResultSchema: z.ZodObject<{
369
369
  }>>;
370
370
  }, "strip", z.ZodTypeAny, {
371
371
  txId: string;
372
- requester: string;
373
- provider: string;
372
+ escrowId: string | null;
374
373
  amount: string;
374
+ success: boolean;
375
375
  deadline: string;
376
- escrowId: string | null;
376
+ provider: string;
377
377
  adapter: string;
378
378
  state: "COMMITTED" | "IN_PROGRESS";
379
- success: boolean;
380
379
  releaseRequired: boolean;
380
+ requester: string;
381
+ error?: string | undefined;
381
382
  erc8004AgentId?: string | undefined;
382
383
  response?: any;
383
- error?: string | undefined;
384
384
  feeBreakdown?: {
385
385
  grossAmount: string;
386
386
  providerNet: string;
@@ -390,18 +390,18 @@ export declare const UnifiedPayResultSchema: z.ZodObject<{
390
390
  } | undefined;
391
391
  }, {
392
392
  txId: string;
393
- requester: string;
394
- provider: string;
393
+ escrowId: string | null;
395
394
  amount: string;
395
+ success: boolean;
396
396
  deadline: string;
397
- escrowId: string | null;
397
+ provider: string;
398
398
  adapter: string;
399
399
  state: "COMMITTED" | "IN_PROGRESS";
400
- success: boolean;
401
400
  releaseRequired: boolean;
401
+ requester: string;
402
+ error?: string | undefined;
402
403
  erc8004AgentId?: string | undefined;
403
404
  response?: any;
404
- error?: string | undefined;
405
405
  feeBreakdown?: {
406
406
  grossAmount: string;
407
407
  providerNet: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agirails/sdk",
3
- "version": "3.3.0",
3
+ "version": "3.5.3",
4
4
  "description": "AGIRAILS SDK for the ACTP (Agent Commerce Transaction Protocol) - Unified mock + blockchain support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,6 +19,21 @@
19
19
  "types": "./dist/server/index.d.ts",
20
20
  "require": "./dist/server/index.js",
21
21
  "default": "./dist/server/index.js"
22
+ },
23
+ "./negotiation": {
24
+ "types": "./dist/negotiation/index.d.ts",
25
+ "require": "./dist/negotiation/index.js",
26
+ "default": "./dist/negotiation/index.js"
27
+ },
28
+ "./builders": {
29
+ "types": "./dist/builders/index.d.ts",
30
+ "require": "./dist/builders/index.js",
31
+ "default": "./dist/builders/index.js"
32
+ },
33
+ "./transport": {
34
+ "types": "./dist/transport/QuoteChannel.d.ts",
35
+ "require": "./dist/transport/QuoteChannel.js",
36
+ "default": "./dist/transport/QuoteChannel.js"
22
37
  }
23
38
  },
24
39
  "bin": {