@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,259 @@
1
+ "use strict";
2
+ /**
3
+ * ProviderPolicy — hard guardrails for autonomous provider quoting.
4
+ *
5
+ * Symmetric to BuyerPolicy. Provider configures what they'll deliver,
6
+ * their price floor, and their lifecycle preferences; ProviderPolicyEngine
7
+ * enforces those invariants on every incoming request so the provider
8
+ * never quotes below floor, outside their service menu, or for a
9
+ * transaction they can't realistically complete before the deadline.
10
+ *
11
+ * @module negotiation/ProviderPolicy
12
+ * @see Protocol/aips/AIP-2.1-DRAFT.md §5.2 (ProviderPolicy.ts creation)
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.parseTtl = exports.ProviderPolicyEngine = void 0;
16
+ // ============================================================================
17
+ // Engine
18
+ // ============================================================================
19
+ /** Base units per $1 for supported currencies. USDC = 1e6 (6 decimals). */
20
+ const BASE_UNITS_PER_USD = {
21
+ USDC: 1000000n,
22
+ };
23
+ /** Platform minimum in base units — $0.05 × 1e6 for USDC. */
24
+ const PLATFORM_MIN_BASE_UNITS = {
25
+ USDC: 50000n,
26
+ };
27
+ const DEFAULT_MIN_DEADLINE_SECONDS = 60;
28
+ /** Convert a human amount (e.g. 5, 10.5) to base units (bigint). */
29
+ function toBaseUnits(amount, currency) {
30
+ const perUsd = BASE_UNITS_PER_USD[currency.toUpperCase()];
31
+ if (!perUsd)
32
+ throw new Error(`Unsupported currency: ${currency}`);
33
+ // Do the scaling as string→BigInt to avoid float drift on amounts
34
+ // that don't fit cleanly in double precision (e.g. 0.1).
35
+ const [whole, frac = ''] = String(amount).split('.');
36
+ const fracPadded = (frac + '000000').slice(0, String(perUsd).length - 1);
37
+ return BigInt(whole) * perUsd + BigInt(fracPadded || '0');
38
+ }
39
+ /** Format base units back to a human string for error messages. */
40
+ function formatFromBaseUnits(baseUnits, currency) {
41
+ const perUsd = BASE_UNITS_PER_USD[currency.toUpperCase()];
42
+ if (!perUsd)
43
+ return `${baseUnits} base units`;
44
+ const whole = baseUnits / perUsd;
45
+ const frac = baseUnits % perUsd;
46
+ const fracStr = frac.toString().padStart(String(perUsd).length - 1, '0').replace(/0+$/, '');
47
+ return fracStr ? `$${whole}.${fracStr}` : `$${whole}`;
48
+ }
49
+ class ProviderPolicyEngine {
50
+ constructor(policy) {
51
+ const currency = policy.pricing.min_acceptable.currency;
52
+ const platformMin = PLATFORM_MIN_BASE_UNITS[currency.toUpperCase()];
53
+ if (!platformMin) {
54
+ throw new Error(`Unsupported currency in policy: ${currency}`);
55
+ }
56
+ // Enforce pricing invariants at construction — fail fast so mis-
57
+ // configured providers don't quote garbage.
58
+ const floorBu = toBaseUnits(policy.pricing.min_acceptable.amount, currency);
59
+ const idealBu = toBaseUnits(policy.pricing.ideal_price.amount, currency);
60
+ if (floorBu < platformMin) {
61
+ throw new Error(`min_acceptable.amount (${formatFromBaseUnits(floorBu, currency)}) below platform minimum (${formatFromBaseUnits(platformMin, currency)})`);
62
+ }
63
+ if (idealBu < floorBu) {
64
+ throw new Error(`ideal_price.amount (${formatFromBaseUnits(idealBu, currency)}) must be ≥ min_acceptable.amount (${formatFromBaseUnits(floorBu, currency)})`);
65
+ }
66
+ if (policy.pricing.min_acceptable.currency !== policy.pricing.ideal_price.currency) {
67
+ throw new Error('min_acceptable.currency must equal ideal_price.currency');
68
+ }
69
+ if (policy.pricing.min_acceptable.unit !== policy.pricing.ideal_price.unit) {
70
+ throw new Error('min_acceptable.unit must equal ideal_price.unit');
71
+ }
72
+ this.policy = policy;
73
+ this.floorBaseUnits = floorBu;
74
+ this.idealBaseUnits = idealBu;
75
+ this.currency = currency;
76
+ }
77
+ /**
78
+ * Evaluate an incoming request against policy. Returns `allowed: true`
79
+ * with `recommended_quote_amount_base_units` (bigint-as-string) when
80
+ * we should quote, or `allowed: false` with the specific rule(s)
81
+ * violated.
82
+ *
83
+ * All numeric comparisons use BigInt on base units — no float drift,
84
+ * no precision loss for large amounts.
85
+ */
86
+ evaluate(req) {
87
+ const violations = [];
88
+ if (!this.policy.services.includes(req.serviceType)) {
89
+ violations.push({
90
+ rule: 'service_not_offered',
91
+ detail: `We don't offer service "${req.serviceType}". Configured: ${this.policy.services.join(', ')}`,
92
+ });
93
+ }
94
+ if (req.currency.toUpperCase() !== this.currency.toUpperCase()) {
95
+ violations.push({
96
+ rule: 'currency_mismatch',
97
+ detail: `Request in ${req.currency}, we quote in ${this.currency}`,
98
+ });
99
+ }
100
+ // `unit` is the pricing unit (job, hour, page, request, …).
101
+ // Buyer quoting $5/hour vs provider priced-per-job is a genuine
102
+ // mismatch and must not silently be quoted.
103
+ if (req.unit !== this.policy.pricing.min_acceptable.unit) {
104
+ violations.push({
105
+ rule: 'unit_mismatch',
106
+ detail: `Request unit "${req.unit}" does not match policy unit "${this.policy.pricing.min_acceptable.unit}"`,
107
+ });
108
+ }
109
+ let maxPriceBu;
110
+ try {
111
+ maxPriceBu = BigInt(req.maxPrice);
112
+ }
113
+ catch {
114
+ violations.push({
115
+ rule: 'max_price_below_floor',
116
+ detail: `Invalid maxPrice: ${req.maxPrice}`,
117
+ });
118
+ maxPriceBu = 0n;
119
+ }
120
+ if (maxPriceBu < this.floorBaseUnits) {
121
+ violations.push({
122
+ rule: 'max_price_below_floor',
123
+ detail: `Buyer maxPrice ${formatFromBaseUnits(maxPriceBu, this.currency)} below our floor ${formatFromBaseUnits(this.floorBaseUnits, this.currency)}`,
124
+ });
125
+ }
126
+ const now = Math.floor(Date.now() / 1000);
127
+ const minDeadlineSeconds = this.policy.min_deadline_seconds ?? DEFAULT_MIN_DEADLINE_SECONDS;
128
+ if (req.deadline - now < minDeadlineSeconds) {
129
+ violations.push({
130
+ rule: 'deadline_too_tight',
131
+ detail: `tx.deadline - now = ${req.deadline - now}s, need ≥ ${minDeadlineSeconds}s`,
132
+ });
133
+ }
134
+ if (violations.length > 0) {
135
+ return { allowed: false, violations };
136
+ }
137
+ // Recommended quote: ideal unless buyer can't afford it, in which
138
+ // case we quote at maxPrice (still above floor — validated above).
139
+ // BigInt min/max via ternary since there's no Math.min for BigInt.
140
+ const ceilingBu = maxPriceBu < this.idealBaseUnits ? maxPriceBu : this.idealBaseUnits;
141
+ const recommendedBu = ceilingBu > this.floorBaseUnits ? ceilingBu : this.floorBaseUnits;
142
+ return {
143
+ allowed: true,
144
+ violations: [],
145
+ recommended_quote_amount_base_units: recommendedBu.toString(),
146
+ };
147
+ }
148
+ /**
149
+ * Decide what to do with a buyer's counter-offer (3.5.0 multi-round).
150
+ *
151
+ * accept — counter ≥ floor: take the deal
152
+ * requote — counter < floor AND counter_strategy === 'concede' AND
153
+ * requotesUsed < max_requotes: send a new quote at the
154
+ * concession price (between last quote and floor)
155
+ * reject — anything else (walk strategy, or requote budget spent)
156
+ *
157
+ * `lastQuoteAmountBaseUnits` is the amount we most recently quoted to
158
+ * this txId — the concession baseline. On the FIRST counter it equals
159
+ * the counter's `quoteAmount` field (provider's original quote);
160
+ * on subsequent rounds it equals the orchestrator's most recent
161
+ * re-quote.
162
+ *
163
+ * `requotesUsed` is how many re-quotes we've already sent for this
164
+ * txId. Pass 0 on first call.
165
+ *
166
+ * All arithmetic uses BigInt on base units — no float drift.
167
+ */
168
+ evaluateCounter(counterAmountBaseUnits, lastQuoteAmountBaseUnits, requotesUsed) {
169
+ let counter;
170
+ try {
171
+ counter = BigInt(counterAmountBaseUnits);
172
+ }
173
+ catch {
174
+ return { decision: 'reject', reason: `Invalid counter amount: ${counterAmountBaseUnits}` };
175
+ }
176
+ if (counter >= this.floorBaseUnits) {
177
+ return {
178
+ decision: 'accept',
179
+ reason: `Counter ${formatFromBaseUnits(counter, this.currency)} meets our floor`,
180
+ };
181
+ }
182
+ // Below floor — consider concession.
183
+ const strategy = this.policy.counter_strategy ?? 'walk';
184
+ if (strategy === 'walk') {
185
+ return {
186
+ decision: 'reject',
187
+ reason: `Counter ${formatFromBaseUnits(counter, this.currency)} below floor; counter_strategy=walk`,
188
+ };
189
+ }
190
+ const maxRequotes = this.policy.max_requotes ?? 2;
191
+ if (requotesUsed >= maxRequotes) {
192
+ return {
193
+ decision: 'reject',
194
+ reason: `Counter below floor and requote budget exhausted (${requotesUsed}/${maxRequotes})`,
195
+ };
196
+ }
197
+ // Concede: new quote = last - (last - floor) * pct / 100.
198
+ let lastQuote;
199
+ try {
200
+ lastQuote = BigInt(lastQuoteAmountBaseUnits);
201
+ }
202
+ catch {
203
+ return { decision: 'reject', reason: `Invalid lastQuoteAmount: ${lastQuoteAmountBaseUnits}` };
204
+ }
205
+ if (lastQuote <= this.floorBaseUnits) {
206
+ // Already at floor — nothing to concede.
207
+ return {
208
+ decision: 'reject',
209
+ reason: `Cannot concede: last quote ${formatFromBaseUnits(lastQuote, this.currency)} already at/below floor`,
210
+ };
211
+ }
212
+ const pct = this.policy.concede_pct ?? 30;
213
+ const safePct = pct < 1 ? 1 : pct > 99 ? 99 : pct;
214
+ const gap = lastQuote - this.floorBaseUnits;
215
+ const concession = (gap * BigInt(safePct)) / 100n;
216
+ let newQuote = lastQuote - concession;
217
+ // Defensive: never go below floor regardless of math.
218
+ if (newQuote < this.floorBaseUnits)
219
+ newQuote = this.floorBaseUnits;
220
+ return {
221
+ decision: 'requote',
222
+ amountBaseUnits: newQuote.toString(),
223
+ reason: `Conceding ${safePct}% from ${formatFromBaseUnits(lastQuote, this.currency)} toward floor → ${formatFromBaseUnits(newQuote, this.currency)} (round ${requotesUsed + 1}/${maxRequotes})`,
224
+ };
225
+ }
226
+ /** Expose ttl as seconds for callers building QuoteMessage.expiresAt. */
227
+ get quoteTtlSeconds() {
228
+ return parseTtl(this.policy.quote_ttl);
229
+ }
230
+ /** Expose the policy's currency for orchestrator wiring. */
231
+ get policyCurrency() {
232
+ return this.currency;
233
+ }
234
+ /** Expose the policy's unit for orchestrator wiring + UI. */
235
+ get policyUnit() {
236
+ return this.policy.pricing.min_acceptable.unit;
237
+ }
238
+ }
239
+ exports.ProviderPolicyEngine = ProviderPolicyEngine;
240
+ /**
241
+ * Parse a short duration string like "15m", "1h", "30s" into seconds.
242
+ * Mirror of PolicyEngine.parseTtl (buyer side) so both sides use the
243
+ * same format in their JSON policies.
244
+ */
245
+ function parseTtl(ttl) {
246
+ const match = ttl.trim().match(/^(\d+)\s*([smh])$/i);
247
+ if (!match) {
248
+ throw new Error(`Invalid TTL format: "${ttl}" (expected e.g. "15m", "1h", "30s")`);
249
+ }
250
+ const n = Number(match[1]);
251
+ const unit = match[2].toLowerCase();
252
+ if (unit === 's')
253
+ return n;
254
+ if (unit === 'm')
255
+ return n * 60;
256
+ return n * 3600;
257
+ }
258
+ exports.parseTtl = parseTtl;
259
+ //# sourceMappingURL=ProviderPolicy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProviderPolicy.js","sourceRoot":"","sources":["../../src/negotiation/ProviderPolicy.ts"],"names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AC3B,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,CAAC,GAAG,EAAE,CAAC;IAChC,OAAO,CAAC,GAAG,IAAI,CAAC;AAClB,CAAC;AAVD,4BAUC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * RelayChannel — default NegotiationChannel impl, polls agirails.app.
3
+ *
4
+ * Both buyer and provider can use this — neither needs to host an HTTP
5
+ * endpoint. Messages are POSTed to and pulled from agirails.app's
6
+ * negotiation relay (see Protocol/aips/AIP-2.1.md §6).
7
+ *
8
+ * Verification model: relay stores messages opaquely (just bytes +
9
+ * cursor + indexes). The receiving SDK runs full EIP-712 verify
10
+ * BEFORE delivering to the orchestrator subscriber, so a malicious
11
+ * relay or intercepted POST can at worst spam the subscriber's
12
+ * deduper with junk that fails verify on the receive side.
13
+ *
14
+ * Polling cadence: 1500ms by default. Conservative: short enough that
15
+ * negotiations feel snappy (< 1.5s p95 latency per round trip), long
16
+ * enough that 100 idle subscriptions don't burn a CPU. Tunable via
17
+ * `pollIntervalMs` for tests.
18
+ *
19
+ * @module negotiation/RelayChannel
20
+ */
21
+ import { NegotiationChannel, NegotiationMessage, Subscription, DeliveredMessage } from './NegotiationChannel';
22
+ export interface RelayChannelConfig {
23
+ /** Base URL of the relay. Default: https://agirails.app */
24
+ baseUrl?: string;
25
+ /**
26
+ * Kernel address per chainId — needed for EIP-712 verify on receive.
27
+ * If a message arrives for a chainId not in this map, it's dropped
28
+ * (channel logs + skips delivery).
29
+ */
30
+ kernelAddressByChainId: Record<number, string>;
31
+ /** Poll interval in ms. Default: 1500. Tests use 50. */
32
+ pollIntervalMs?: number;
33
+ /** fetch override (Node 18+ has it built-in; injected for tests). */
34
+ fetchImpl?: typeof fetch;
35
+ /** Logger. Default: noop. */
36
+ log?: (level: 'info' | 'warn' | 'error', msg: string, ctx?: unknown) => void;
37
+ }
38
+ export declare class RelayChannel implements NegotiationChannel {
39
+ private readonly baseUrl;
40
+ private readonly kernelAddressByChainId;
41
+ private readonly pollIntervalMs;
42
+ private readonly fetchImpl;
43
+ private readonly log;
44
+ private readonly quoteVerifier;
45
+ private readonly counterVerifier;
46
+ private readonly counterAcceptVerifier;
47
+ private readonly subscriptions;
48
+ constructor(cfg: RelayChannelConfig);
49
+ post(txId: string, envelope: NegotiationMessage): Promise<void>;
50
+ subscribeTxId(txId: string, onMessage: (delivered: DeliveredMessage) => void | Promise<void>): Subscription;
51
+ subscribeAgent(agentDid: string, onMessage: (txId: string, delivered: DeliveredMessage) => void | Promise<void>): Subscription;
52
+ close(): Promise<void>;
53
+ /**
54
+ * Verify + dedup + dispatch one item. Errors in the subscriber callback
55
+ * are caught + logged so a single bad handler doesn't kill the loop.
56
+ */
57
+ private deliver;
58
+ }
59
+ //# sourceMappingURL=RelayChannel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelayChannel.d.ts","sourceRoot":"","sources":["../../src/negotiation/RelayChannel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAIjB,MAAM,sBAAsB,CAAC;AAM9B,MAAM,WAAW,kBAAkB;IACjC,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,6BAA6B;IAC7B,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9E;AAmBD,qBAAa,YAAa,YAAW,kBAAkB;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAyB;IAChE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAyC;IAE7D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAsB;IACpD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA6B;IAC7D,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA8B;IAEpE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAwB;gBAE1C,GAAG,EAAE,kBAAkB;IAQ7B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAarE,aAAa,CACX,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,CAAC,SAAS,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC/D,YAAY;IA6Cf,cAAc,CACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC7E,YAAY;IAyCT,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAY5B;;;OAGG;YACW,OAAO;CAkDtB"}
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ /**
3
+ * RelayChannel — default NegotiationChannel impl, polls agirails.app.
4
+ *
5
+ * Both buyer and provider can use this — neither needs to host an HTTP
6
+ * endpoint. Messages are POSTed to and pulled from agirails.app's
7
+ * negotiation relay (see Protocol/aips/AIP-2.1.md §6).
8
+ *
9
+ * Verification model: relay stores messages opaquely (just bytes +
10
+ * cursor + indexes). The receiving SDK runs full EIP-712 verify
11
+ * BEFORE delivering to the orchestrator subscriber, so a malicious
12
+ * relay or intercepted POST can at worst spam the subscriber's
13
+ * deduper with junk that fails verify on the receive side.
14
+ *
15
+ * Polling cadence: 1500ms by default. Conservative: short enough that
16
+ * negotiations feel snappy (< 1.5s p95 latency per round trip), long
17
+ * enough that 100 idle subscriptions don't burn a CPU. Tunable via
18
+ * `pollIntervalMs` for tests.
19
+ *
20
+ * @module negotiation/RelayChannel
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.RelayChannel = void 0;
24
+ const QuoteBuilder_1 = require("../builders/QuoteBuilder");
25
+ const CounterOfferBuilder_1 = require("../builders/CounterOfferBuilder");
26
+ const CounterAcceptBuilder_1 = require("../builders/CounterAcceptBuilder");
27
+ const NegotiationChannel_1 = require("./NegotiationChannel");
28
+ const DEFAULT_BASE_URL = 'https://agirails.app';
29
+ const DEFAULT_POLL_MS = 1500;
30
+ class RelayChannel {
31
+ constructor(cfg) {
32
+ // Verifier instances are signer-independent (verify-only) — see CounterOfferBuilder/CounterAcceptBuilder.
33
+ this.quoteVerifier = new QuoteBuilder_1.QuoteBuilder();
34
+ this.counterVerifier = new CounterOfferBuilder_1.CounterOfferBuilder();
35
+ this.counterAcceptVerifier = new CounterAcceptBuilder_1.CounterAcceptBuilder();
36
+ this.subscriptions = new Set();
37
+ this.baseUrl = (cfg.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
38
+ this.kernelAddressByChainId = cfg.kernelAddressByChainId;
39
+ this.pollIntervalMs = cfg.pollIntervalMs ?? DEFAULT_POLL_MS;
40
+ this.fetchImpl = cfg.fetchImpl ?? fetch;
41
+ this.log = cfg.log ?? (() => undefined);
42
+ }
43
+ async post(txId, envelope) {
44
+ const url = `${this.baseUrl}/api/v1/negotiations/${encodeURIComponent(txId)}/messages`;
45
+ const res = await this.fetchImpl(url, {
46
+ method: 'POST',
47
+ headers: { 'Content-Type': 'application/json' },
48
+ body: JSON.stringify(envelope),
49
+ });
50
+ if (!res.ok) {
51
+ const body = await res.text().catch(() => '');
52
+ throw new Error(`Relay POST ${res.status}: ${body.slice(0, 200)}`);
53
+ }
54
+ }
55
+ subscribeTxId(txId, onMessage) {
56
+ const state = { cursor: null, delivered: new Set(), cancelled: false };
57
+ this.subscriptions.add(state);
58
+ const pollOnce = async () => {
59
+ if (state.cancelled)
60
+ return;
61
+ try {
62
+ const url = new URL(`${this.baseUrl}/api/v1/negotiations/${encodeURIComponent(txId)}/messages`);
63
+ if (state.cursor)
64
+ url.searchParams.set('after', state.cursor);
65
+ const res = await this.fetchImpl(url.toString());
66
+ if (res.ok) {
67
+ const body = await res.json();
68
+ for (const item of body.messages ?? []) {
69
+ await this.deliver(item, state, (d) => onMessage(d));
70
+ state.cursor = item.cursor;
71
+ }
72
+ }
73
+ else {
74
+ this.log('warn', `Relay GET ${res.status} for tx ${txId.slice(0, 12)}…`);
75
+ }
76
+ }
77
+ catch (err) {
78
+ this.log('warn', `Relay poll error for tx ${txId.slice(0, 12)}…`, err);
79
+ }
80
+ if (!state.cancelled) {
81
+ state.timer = setTimeout(pollOnce, this.pollIntervalMs);
82
+ // Allow process to exit even if subscription is still armed
83
+ // (matches Node's `unref()` convention; no-op in browsers).
84
+ if (typeof state.timer.unref === 'function') {
85
+ state.timer.unref();
86
+ }
87
+ }
88
+ };
89
+ // Kick off first poll on next tick so subscribers can attach handlers
90
+ // synchronously before the first delivery attempt.
91
+ state.timer = setTimeout(pollOnce, 0);
92
+ return {
93
+ unsubscribe: () => {
94
+ state.cancelled = true;
95
+ if (state.timer)
96
+ clearTimeout(state.timer);
97
+ this.subscriptions.delete(state);
98
+ },
99
+ };
100
+ }
101
+ subscribeAgent(agentDid, onMessage) {
102
+ const state = { cursor: null, delivered: new Set(), cancelled: false };
103
+ this.subscriptions.add(state);
104
+ const pollOnce = async () => {
105
+ if (state.cancelled)
106
+ return;
107
+ try {
108
+ const url = new URL(`${this.baseUrl}/api/v1/negotiations/inbox/${encodeURIComponent(agentDid)}`);
109
+ if (state.cursor)
110
+ url.searchParams.set('after', state.cursor);
111
+ const res = await this.fetchImpl(url.toString());
112
+ if (res.ok) {
113
+ const body = await res.json();
114
+ for (const item of body.messages ?? []) {
115
+ await this.deliver(item, state, (d) => onMessage(item.txId, d));
116
+ state.cursor = item.cursor;
117
+ }
118
+ }
119
+ else {
120
+ this.log('warn', `Relay agent-inbox GET ${res.status} for ${agentDid}`);
121
+ }
122
+ }
123
+ catch (err) {
124
+ this.log('warn', `Relay agent-inbox poll error for ${agentDid}`, err);
125
+ }
126
+ if (!state.cancelled) {
127
+ state.timer = setTimeout(pollOnce, this.pollIntervalMs);
128
+ if (typeof state.timer.unref === 'function') {
129
+ state.timer.unref();
130
+ }
131
+ }
132
+ };
133
+ state.timer = setTimeout(pollOnce, 0);
134
+ return {
135
+ unsubscribe: () => {
136
+ state.cancelled = true;
137
+ if (state.timer)
138
+ clearTimeout(state.timer);
139
+ this.subscriptions.delete(state);
140
+ },
141
+ };
142
+ }
143
+ async close() {
144
+ for (const state of this.subscriptions) {
145
+ state.cancelled = true;
146
+ if (state.timer)
147
+ clearTimeout(state.timer);
148
+ }
149
+ this.subscriptions.clear();
150
+ }
151
+ // --------------------------------------------------------------------------
152
+ // Internals
153
+ // --------------------------------------------------------------------------
154
+ /**
155
+ * Verify + dedup + dispatch one item. Errors in the subscriber callback
156
+ * are caught + logged so a single bad handler doesn't kill the loop.
157
+ */
158
+ async deliver(item, state, invoke) {
159
+ // Dedup by signature (every signed message has a unique sig per nonce).
160
+ // CRITICAL: dedup-check BEFORE verify, but only ADD to dedup-set AFTER
161
+ // verify SUCCEEDS. Otherwise an attacker who can POST to the relay
162
+ // (it's permissionless) can craft a tampered envelope carrying a
163
+ // valid signature — verify fails, message is dropped, but the sig
164
+ // is now in the dedup-set; when the legitimate message later
165
+ // arrives it gets silently dropped as "duplicate". (P0 audit finding.)
166
+ const sig = item.envelope.message.signature;
167
+ if (state.delivered.has(sig))
168
+ return;
169
+ // Verify EIP-712 against the kernel address for this chainId.
170
+ const chainId = item.envelope.message.chainId;
171
+ const kernelAddress = this.kernelAddressByChainId[chainId];
172
+ if (!kernelAddress) {
173
+ this.log('warn', `Dropping message for unknown chainId ${chainId}`);
174
+ return;
175
+ }
176
+ try {
177
+ if ((0, NegotiationChannel_1.isQuoteEnvelope)(item.envelope)) {
178
+ await this.quoteVerifier.verify(item.envelope.message, kernelAddress);
179
+ }
180
+ else if ((0, NegotiationChannel_1.isCounterOfferEnvelope)(item.envelope)) {
181
+ await this.counterVerifier.verify(item.envelope.message, kernelAddress);
182
+ }
183
+ else if ((0, NegotiationChannel_1.isCounterAcceptEnvelope)(item.envelope)) {
184
+ await this.counterAcceptVerifier.verify(item.envelope.message, kernelAddress);
185
+ }
186
+ }
187
+ catch (err) {
188
+ this.log('warn', `Dropping message that failed verify`, err);
189
+ return;
190
+ }
191
+ // Verify passed → safe to dedup. From here on the same sig will not
192
+ // re-deliver even on poll-loop overlap.
193
+ state.delivered.add(sig);
194
+ const delivered = {
195
+ cursor: item.cursor,
196
+ receivedAt: item.receivedAt ?? Math.floor(Date.now() / 1000),
197
+ envelope: item.envelope,
198
+ };
199
+ try {
200
+ await invoke(delivered);
201
+ }
202
+ catch (err) {
203
+ this.log('error', 'Subscriber callback threw', err);
204
+ }
205
+ }
206
+ }
207
+ exports.RelayChannel = RelayChannel;
208
+ //# sourceMappingURL=RelayChannel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelayChannel.js","sourceRoot":"","sources":["../../src/negotiation/RelayChannel.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,2DAAwD;AACxD,yEAAsE;AACtE,2EAAwE;AACxE,6DAQ8B;AAuB9B,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AAChD,MAAM,eAAe,GAAG,IAAI,CAAC;AAgB7B,MAAa,YAAY;IAavB,YAAY,GAAuB;QAPnC,0GAA0G;QACzF,kBAAa,GAAG,IAAI,2BAAY,EAAE,CAAC;QACnC,oBAAe,GAAG,IAAI,yCAAmB,EAAE,CAAC;QAC5C,0BAAqB,GAAG,IAAI,2CAAoB,EA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MD,oCAgMC"}
@@ -5,5 +5,12 @@ export type { ScoringWeights, CandidateStats, ScoredCandidate } from './Decision
5
5
  export { SessionStore } from './SessionStore';
6
6
  export type { SessionMapping } from './SessionStore';
7
7
  export { BuyerOrchestrator } from './BuyerOrchestrator';
8
- export type { NegotiationResult, RoundResult, OrchestratorConfig, ProgressEvent } from './BuyerOrchestrator';
8
+ export type { NegotiationResult, RoundResult, OrchestratorConfig, ProgressEvent, BuyerNegotiationContext, } from './BuyerOrchestrator';
9
+ export { verifyQuoteHashOnChain } from './verifyQuoteOnChain';
10
+ export type { VerifySource, VerifyOnChainResult } from './verifyQuoteOnChain';
11
+ export type { QuoteForEvaluation, QuoteEvaluation } from './DecisionEngine';
12
+ export { ProviderPolicyEngine, parseTtl as parseProviderTtl } from './ProviderPolicy';
13
+ export type { ProviderPolicy, ProviderPolicyViolation, ProviderPolicyResult, IncomingRequest } from './ProviderPolicy';
14
+ export { ProviderOrchestrator } from './ProviderOrchestrator';
15
+ export type { ProviderOrchestratorConfig, QuoteDecision, QuoteResult, CounterDecision } from './ProviderOrchestrator';
9
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/negotiation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE1G,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YA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
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuyerOrchestrator = exports.SessionStore = exports.DecisionEngine = exports.PolicyEngine = void 0;
3
+ exports.ProviderOrchestrator = exports.parseProviderTtl = exports.ProviderPolicyEngine = exports.verifyQuoteHashOnChain = exports.BuyerOrchestrator = exports.SessionStore = exports.DecisionEngine = exports.PolicyEngine = void 0;
4
4
  var PolicyEngine_1 = require("./PolicyEngine");
5
5
  Object.defineProperty(exports, "PolicyEngine", { enumerable: true, get: function () { return PolicyEngine_1.PolicyEngine; } });
6
6
  var DecisionEngine_1 = require("./DecisionEngine");
@@ -9,4 +9,11 @@ var SessionStore_1 = require("./SessionStore");
9
9
  Object.defineProperty(exports, "SessionStore", { enumerable: true, get: function () { return SessionStore_1.SessionStore; } });
10
10
  var BuyerOrchestrator_1 = require("./BuyerOrchestrator");
11
11
  Object.defineProperty(exports, "BuyerOrchestrator", { enumerable: true, get: function () { return BuyerOrchestrator_1.BuyerOrchestrator; } });
12
+ var verifyQuoteOnChain_1 = require("./verifyQuoteOnChain");
13
+ Object.defineProperty(exports, "verifyQuoteHashOnChain", { enumerable: true, get: function () { return verifyQuoteOnChain_1.verifyQuoteHashOnChain; } });
14
+ var ProviderPolicy_1 = require("./ProviderPolicy");
15
+ Object.defineProperty(exports, "ProviderPolicyEngine", { enumerable: true, get: function () { return ProviderPolicy_1.ProviderPolicyEngine; } });
16
+ Object.defineProperty(exports, "parseProviderTtl", { enumerable: true, get: function () { return ProviderPolicy_1.parseTtl; } });
17
+ var ProviderOrchestrator_1 = require("./ProviderOrchestrator");
18
+ Object.defineProperty(exports, "ProviderOrchestrator", { enumerable: true, get: function () { return ProviderOrchestrator_1.ProviderOrchestrator; } });
12
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/negotiation/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAGrB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AAGvB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAGrB,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/negotiation/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAGrB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AAGvB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAGrB,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAS1B,2DAA8D;AAArD,4HAAA,sBAAsB,OAAA;AAK/B,mDAAsF;AAA7E,sHAAA,oBAAoB,OAAA;AAAE,kHAAA,QAAQ,OAAoB;AAG3D,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA"}