@avow-finance/spec 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/agent-session.d.ts +8 -0
  2. package/dist/agent-session.d.ts.map +1 -1
  3. package/dist/api.d.ts +24 -0
  4. package/dist/api.d.ts.map +1 -1
  5. package/dist/dependencies.d.ts.map +1 -1
  6. package/dist/dependencies.js +8 -2
  7. package/dist/dependencies.js.map +1 -1
  8. package/dist/eip712.d.ts +212 -1
  9. package/dist/eip712.d.ts.map +1 -1
  10. package/dist/eip712.js +34 -0
  11. package/dist/eip712.js.map +1 -1
  12. package/dist/gpu-reservation.d.ts.map +1 -1
  13. package/dist/gpu-reservation.js +1 -1
  14. package/dist/gpu-reservation.js.map +1 -1
  15. package/dist/index.d.ts +4 -0
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +4 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/job-session.d.ts +16 -0
  20. package/dist/job-session.d.ts.map +1 -1
  21. package/dist/job.d.ts.map +1 -1
  22. package/dist/job.js +1 -1
  23. package/dist/job.js.map +1 -1
  24. package/dist/json-fields.d.ts +2 -0
  25. package/dist/json-fields.d.ts.map +1 -1
  26. package/dist/json-fields.js +2 -0
  27. package/dist/json-fields.js.map +1 -1
  28. package/dist/mailbox.d.ts +77 -104
  29. package/dist/mailbox.d.ts.map +1 -1
  30. package/dist/mailbox.js +8 -30
  31. package/dist/mailbox.js.map +1 -1
  32. package/dist/negotiation.d.ts +514 -0
  33. package/dist/negotiation.d.ts.map +1 -0
  34. package/dist/negotiation.js +490 -0
  35. package/dist/negotiation.js.map +1 -0
  36. package/dist/offer-search.d.ts +282 -0
  37. package/dist/offer-search.d.ts.map +1 -0
  38. package/dist/offer-search.js +252 -0
  39. package/dist/offer-search.js.map +1 -0
  40. package/dist/order-wire.d.ts +73 -0
  41. package/dist/order-wire.d.ts.map +1 -0
  42. package/dist/order-wire.js +33 -0
  43. package/dist/order-wire.js.map +1 -0
  44. package/dist/reasons.d.ts +10 -2
  45. package/dist/reasons.d.ts.map +1 -1
  46. package/dist/reasons.js +10 -2
  47. package/dist/reasons.js.map +1 -1
  48. package/dist/sandbox.d.ts +81 -0
  49. package/dist/sandbox.d.ts.map +1 -1
  50. package/dist/sandbox.js +18 -0
  51. package/dist/sandbox.js.map +1 -1
  52. package/dist/service-order.d.ts +747 -0
  53. package/dist/service-order.d.ts.map +1 -0
  54. package/dist/service-order.js +182 -0
  55. package/dist/service-order.js.map +1 -0
  56. package/dist/service.d.ts +248 -0
  57. package/dist/service.d.ts.map +1 -0
  58. package/dist/service.js +379 -0
  59. package/dist/service.js.map +1 -0
  60. package/dist/session-fields.d.ts +8 -0
  61. package/dist/session-fields.d.ts.map +1 -1
  62. package/dist/terms.d.ts.map +1 -1
  63. package/dist/terms.js +4 -0
  64. package/dist/terms.js.map +1 -1
  65. package/dist/test-customer.d.ts +16 -0
  66. package/dist/test-customer.d.ts.map +1 -1
  67. package/dist/text.d.ts +5 -0
  68. package/dist/text.d.ts.map +1 -0
  69. package/dist/text.js +5 -0
  70. package/dist/text.js.map +1 -0
  71. package/dist/types.d.ts +7 -4
  72. package/dist/types.d.ts.map +1 -1
  73. package/dist/types.js +6 -3
  74. package/dist/types.js.map +1 -1
  75. package/dist/version.d.ts +1 -0
  76. package/dist/version.d.ts.map +1 -1
  77. package/dist/version.js +2 -0
  78. package/dist/version.js.map +1 -1
  79. package/dist/wire.d.ts +312 -0
  80. package/dist/wire.d.ts.map +1 -1
  81. package/dist/wire.js +28 -1
  82. package/dist/wire.js.map +1 -1
  83. package/package.json +1 -1
@@ -0,0 +1,514 @@
1
+ import type { Hex } from 'viem';
2
+ import { z } from 'zod';
3
+ import { type AvowDomain, type NegotiationMove, type TermsAgreement } from './eip712.js';
4
+ import type { ReasonCode } from './reasons.js';
5
+ import { type ServiceOfferVersion, type ServiceTerms } from './service.js';
6
+ import { type ServiceSettlement } from './service-order.js';
7
+ import type { Side } from './types.js';
8
+ /**
9
+ * A negotiation thread: the signed moves two businesses' agents make about one prospective
10
+ * commitment, from the buyer's first proposal to an agreement or a decline. A fixed-price order is
11
+ * the shortest thread, a proposal the supplier accepts.
12
+ *
13
+ * A thread is about one base offer version, which never changes. A proposal states a quantity, a
14
+ * unit price and a lead time against that base, and the terms are the ones `serviceOfferTerms`
15
+ * builds from the base with those three in place. Everything else in the terms comes from the
16
+ * base, so no move can change the item, what counts as delivery, a charge's share or how the
17
+ * price is paid.
18
+ *
19
+ * Either side accepts the other's open proposal. A supplier's proposal or acceptance carries its
20
+ * signed agreement to the terms' hash. The buyer signs that hash only when it accepts a supplier's
21
+ * proposal. When the supplier accepts the buyer's, the buyer has signed the quantity, the price,
22
+ * the lead time and the build moment, and it has signed no hash. Its signature doesn't cover the
23
+ * arbiter or the day-90 share the terms are built with, so the buyer builds the terms itself and
24
+ * compares their hash with the supplier's before it reserves.
25
+ *
26
+ * An accepted proposal is an agreed thread, and it is no commitment yet. Nothing is reserved until
27
+ * the buyer's lock takes the reserve, and the commitment exists only once the supplier's
28
+ * acceptance is on that lock. Until then either side can walk away. A decline shows which side
29
+ * ended the thread. A thread that ran out of time shows only that no move followed, and never
30
+ * whose fault that was.
31
+ *
32
+ * This module holds the moves and what makes each one valid where it stands. It reads no lock and
33
+ * checks no signature, so a caller establishes who signed a move before it asks whether the move
34
+ * fits. Nothing here says a move is within either side's authority, which is the mandates' part.
35
+ */
36
+ /** The most proposals and counter-offers one thread takes. Accepting and declining don't count. */
37
+ export declare const THREAD_PROPOSALS_MAX = 6;
38
+ /**
39
+ * The longest one move stands, in seconds. A reader allows `SERVICE_ORDER_CLOCK_SKEW` on top for a
40
+ * sender whose clock runs ahead, so a move can stand a minute longer by the reader's clock.
41
+ */
42
+ export declare const THREAD_MOVE_SECONDS: bigint;
43
+ /** The longest a thread runs from the moment its first proposal is built, in seconds. */
44
+ export declare const THREAD_SECONDS: bigint;
45
+ /** The most moves a thread holds: every proposal and counter, an acceptance, and a decline. */
46
+ export declare const THREAD_MOVES_MAX: number;
47
+ /** The furthest past a thread's first build moment a decline can say to ask again, in seconds. */
48
+ export declare const DECLINE_RETRY_MAX: bigint;
49
+ /**
50
+ * What the side that reads a decline does next. An agent acts on the step and the decline's typed
51
+ * fields, and never on words from the other side, since a decline carries no free text.
52
+ *
53
+ * - `retry_later`: send the order again at the time the decline gives, or after a while when it
54
+ * gives none.
55
+ * - `change_order`: the order as it stood won't be taken, so open a new thread for something else.
56
+ * For a replaced offer that is the version the decline names, read and checked as any offer the
57
+ * agent has never seen, since its price and rules can differ from the one it ordered.
58
+ * - `choose_another`: this business won't take the order, so look elsewhere.
59
+ *
60
+ * No step says to send the same order again unchanged and at once. A decline never turns an order
61
+ * for one offer version into an order for another without the buyer's own checks.
62
+ */
63
+ export type DeclineNext = 'retry_later' | 'change_order' | 'choose_another';
64
+ /** What one reason to decline allows: the next step, who can give it, and what it can carry. */
65
+ export interface DeclineRule {
66
+ next: DeclineNext;
67
+ /** Whether only the supplier can decline for this reason, or either side. */
68
+ by: 'supplier' | 'either';
69
+ /** Whether the decline can say when to ask again. */
70
+ retryAt: boolean;
71
+ /** Whether the decline can say how many units the supplier would take. */
72
+ available: boolean;
73
+ }
74
+ /**
75
+ * Every reason a move can decline with. A reason about the offer or the supplier's capacity is the
76
+ * supplier's to give, and only `offer.superseded` names another offer version, which it has to.
77
+ */
78
+ export declare const DECLINE_RULES: {
79
+ readonly 'offer.superseded': {
80
+ readonly next: 'change_order';
81
+ readonly by: 'supplier';
82
+ readonly retryAt: false;
83
+ readonly available: false;
84
+ };
85
+ readonly 'offer.withdrawn': {
86
+ readonly next: 'choose_another';
87
+ readonly by: 'supplier';
88
+ readonly retryAt: false;
89
+ readonly available: false;
90
+ };
91
+ readonly 'capacity.exhausted': {
92
+ readonly next: 'retry_later';
93
+ readonly by: 'supplier';
94
+ readonly retryAt: true;
95
+ readonly available: true;
96
+ };
97
+ readonly 'quantity.out_of_range': {
98
+ readonly next: 'change_order';
99
+ readonly by: 'supplier';
100
+ readonly retryAt: false;
101
+ readonly available: true;
102
+ };
103
+ readonly 'terms.not_negotiable': {
104
+ readonly next: 'change_order';
105
+ readonly by: 'either';
106
+ readonly retryAt: false;
107
+ readonly available: false;
108
+ };
109
+ readonly 'proposal.unacceptable': {
110
+ readonly next: 'change_order';
111
+ readonly by: 'either';
112
+ readonly retryAt: false;
113
+ readonly available: false;
114
+ };
115
+ readonly 'counterparty.not_eligible': {
116
+ readonly next: 'choose_another';
117
+ readonly by: 'either';
118
+ readonly retryAt: false;
119
+ readonly available: false;
120
+ };
121
+ readonly 'approval.human_required': {
122
+ readonly next: 'retry_later';
123
+ readonly by: 'either';
124
+ readonly retryAt: true;
125
+ readonly available: false;
126
+ };
127
+ readonly 'negotiation.rounds_exhausted': {
128
+ readonly next: 'choose_another';
129
+ readonly by: 'either';
130
+ readonly retryAt: false;
131
+ readonly available: false;
132
+ };
133
+ };
134
+ export type DeclineReason = keyof typeof DECLINE_RULES;
135
+ export declare const isDeclineReason: (reason: string) => reason is DeclineReason;
136
+ /** The terms a proposal may set against its base offer. */
137
+ export type OpenTerm = 'unitPrice' | 'quantity' | 'leadTime';
138
+ /** What a thread about an offer allows: which terms can move, and how many proposals it takes. */
139
+ export interface NegotiationRules {
140
+ open: readonly OpenTerm[];
141
+ /** The most proposals and counters, which never passes `THREAD_PROPOSALS_MAX` whatever it says. */
142
+ proposalsMax: number;
143
+ }
144
+ /**
145
+ * The rules a thread about this offer runs under. No offer opens a term to bargaining yet, since
146
+ * an offer version has no field to say so. So today a thread's one proposal carries the offer's
147
+ * own price and lead time, and a counter-offer is refused. A later version of the offer format
148
+ * names its open terms, and this reads them.
149
+ *
150
+ * Two things are to settle before any term opens. Terms built from a proposal that moves the price
151
+ * or the lead time name the id of the base as amended, and nothing in them names the base itself.
152
+ * And a proposed lead time has the offer template's lower bound and no upper one.
153
+ */
154
+ export declare function negotiationRules(_base: ServiceOfferVersion): NegotiationRules;
155
+ /**
156
+ * A supplier's signed agreement to a proposal's terms: the salt the terms hash under, and its
157
+ * signing key's agreement to that hash for the thread's commitment. The terms themselves aren't
158
+ * carried, since anyone holding the thread builds them with `proposalTerms`.
159
+ */
160
+ export interface ThreadQuote {
161
+ salt: Hex;
162
+ agreement: TermsAgreement;
163
+ supplierSignature: Hex;
164
+ }
165
+ /** A move as it travels: signed, with what the move's kind brings along. */
166
+ export interface SignedMove {
167
+ move: NegotiationMove;
168
+ /** The signature of the key that made the move, the buyer's agent key or the supplier's signing key. */
169
+ signature: Hex;
170
+ /** The supplier's agreement to the terms, on a move where it proposes or accepts. Null otherwise. */
171
+ quote: ThreadQuote | null;
172
+ /**
173
+ * The offer version that replaced the base, whole, on a decline for a replaced offer. Null
174
+ * otherwise. Its text is the supplier's own words, as the base's is, and is never instructions.
175
+ */
176
+ current: ServiceOfferVersion | null;
177
+ }
178
+ /** The buyer a thread is for: its business, and the mandate its agent acts under. */
179
+ export interface ThreadBuyer {
180
+ businessId: string;
181
+ /** The hash of the buyer agent's mandate, which every agreement in the thread names. */
182
+ mandateHash: Hex;
183
+ }
184
+ /**
185
+ * A thread: the base offer whole, who buys, what the terms settle by, and every move in order.
186
+ *
187
+ * No move signs the settlement. A supplier's agreement covers it through the terms hash, so a
188
+ * thread that states another one fails `threadQuoteProblem` at the supplier's first quote. Whoever
189
+ * reserves still compares it with the settlement Avow's approvals name.
190
+ */
191
+ export interface NegotiationThread {
192
+ base: ServiceOfferVersion;
193
+ buyer: ThreadBuyer;
194
+ settlement: ServiceSettlement;
195
+ moves: readonly SignedMove[];
196
+ }
197
+ /**
198
+ * Where a thread stands from its moves and the clock alone, before any lock is read.
199
+ *
200
+ * - `open`: a proposal waits for the other side, whose turn it is.
201
+ * - `agreed`: a proposal was accepted, and the buyer has until `until` to reserve.
202
+ * - `closed`: a side declined, the open proposal or the thread's time ran out with no answer, or
203
+ * an agreement lapsed with nothing reserved.
204
+ *
205
+ * A caller that has seen the reserve on the buyer's lock no longer asks this, since the lock's
206
+ * own deadlines govern from then on.
207
+ */
208
+ export type ThreadState = {
209
+ status: 'open';
210
+ head: NegotiationMove;
211
+ turn: Side;
212
+ proposals: number;
213
+ } | {
214
+ status: 'agreed';
215
+ proposal: NegotiationMove;
216
+ termsHash: Hex;
217
+ until: bigint;
218
+ } | {
219
+ status: 'closed';
220
+ why: 'declined';
221
+ reason: DeclineReason;
222
+ by: Side;
223
+ } | {
224
+ status: 'closed';
225
+ why: 'expired' | 'lapsed';
226
+ };
227
+ /** The digest a move is signed over, which the move after it names as `previous`. */
228
+ export declare const moveDigest: (move: NegotiationMove, domain: AvowDomain) => Hex;
229
+ /**
230
+ * Where a thread stands at `now`. It trusts the moves, so a thread from anywhere else goes through
231
+ * `threadProblem` first. It throws for moves that could never have passed that check: none at
232
+ * all, none that proposes, or a decline whose reason isn't one of `DECLINE_RULES`.
233
+ */
234
+ export declare function threadStateAt(thread: Pick<NegotiationThread, 'moves'>, now: bigint): ThreadState;
235
+ /** The offer version a proposal asks for: the base with the proposal's price and lead time. */
236
+ export declare function proposedVersion(base: ServiceOfferVersion, proposal: Pick<NegotiationMove, 'unitPrice' | 'leadTime'>): ServiceOfferVersion;
237
+ /**
238
+ * The terms a proposal builds, which the supplier's agreement signs the hash of. Throws for a
239
+ * proposal the template refuses, which `moveProblem` never lets into a thread.
240
+ */
241
+ export declare function proposalTerms(base: ServiceOfferVersion, proposal: Pick<NegotiationMove, 'unitPrice' | 'leadTime' | 'quantity' | 'builtAt'>, settlement: ServiceSettlement): ServiceTerms;
242
+ /**
243
+ * Why `next` can't be the thread's next move at `now`, or null when it can. `moves` are the
244
+ * thread's moves so far, each of which passed this check, and none for a first proposal.
245
+ *
246
+ * A move takes the next number and names the digest of the move before it, so one copy of a
247
+ * thread holds one chain. This can't stop a key signing two different moves for one number. Avow's
248
+ * copy takes the first, and the two signatures together prove the key signed both. The buyer opens
249
+ * with a proposal. After that the side a proposal waits on counters or accepts, and either side
250
+ * declines at any point before the thread closes. A proposal or an acceptance stands for
251
+ * `THREAD_MOVE_SECONDS` at most, and none outlasts `THREAD_SECONDS` from the first proposal. A
252
+ * buyer's acceptance stands no longer than the supplier's proposal it accepts.
253
+ *
254
+ * The caller checks the signature and that its signer is the side the move names. This checks
255
+ * neither, and it doesn't read a supplier's quote, which `threadQuoteProblem` does.
256
+ */
257
+ export declare function moveProblem(thread: Pick<NegotiationThread, 'base' | 'moves'>, next: NegotiationMove, domain: AvowDomain, now: bigint, rules?: NegotiationRules): ReasonCode | null;
258
+ /**
259
+ * Why a supplier's quote doesn't agree to a proposal's terms, or null when it does. The quote's
260
+ * agreement has to carry the hash of the terms the proposal builds with the thread's settlement,
261
+ * under the quote's salt, for the thread's commitment, the base offer's supplier, the thread's
262
+ * buyer and a service. That hash is the one the supplier's move states.
263
+ *
264
+ * It leaves the supplier's signature to Avow, as `serviceQuoteProblem` does, and how long the
265
+ * agreement stands to `signedMoveProblem`. It never throws.
266
+ */
267
+ export declare function threadQuoteProblem(thread: Pick<NegotiationThread, 'base' | 'buyer' | 'settlement'>, proposal: Pick<NegotiationMove, 'unitPrice' | 'leadTime' | 'quantity' | 'builtAt' | 'commitmentId'>, stated: Hex, quote: ThreadQuote): ReasonCode | null;
268
+ /**
269
+ * Why a signed move, with what it brings along, can't be the thread's next at `now`, or null when
270
+ * it can. It runs `moveProblem`, then checks what travels beside the move. A supplier's proposal
271
+ * or acceptance brings its quote, which has to agree to the proposal's terms under the hash the
272
+ * move states, and stand at least as long as the move does. A decline for a replaced offer brings
273
+ * the replacing version whole, from the same supplier, for the same item, under the id the move
274
+ * names. Nothing else brings either.
275
+ *
276
+ * The caller still checks the move's signature, and Avow checks the quote's.
277
+ */
278
+ export declare function signedMoveProblem(thread: NegotiationThread, next: SignedMove, domain: AvowDomain, now: bigint, rules?: NegotiationRules): ReasonCode | null;
279
+ /**
280
+ * Why a thread from anywhere else isn't one its moves could have made, or null when it is. Run it
281
+ * on every thread read from the wire before `threadStateAt` or anything else trusts the moves.
282
+ *
283
+ * It replays the thread from its first move with `signedMoveProblem`, each move at the earliest
284
+ * moment it could have been sent, given its own times and the moves before it. A thread whose
285
+ * moves were each taken in turn always passes, since a move valid when it was sent is valid at
286
+ * that earlier moment too. No move carries the moment it was sent, so the replay shows only that
287
+ * each move could have arrived in time. When it did arrive is known only to whoever took it in,
288
+ * and the copy that whoever keeps the thread holds decides. It checks no signature.
289
+ */
290
+ export declare function threadProblem(thread: NegotiationThread, domain: AvowDomain, rules?: NegotiationRules): ReasonCode | null;
291
+ export declare const negotiationMoveJson: z.ZodObject<{
292
+ thread: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
293
+ commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
294
+ seq: z.ZodNumber;
295
+ previous: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
296
+ side: z.ZodEnum<{
297
+ buyer: "buyer";
298
+ supplier: "supplier";
299
+ }>;
300
+ kind: z.ZodEnum<{
301
+ accept: "accept";
302
+ counter: "counter";
303
+ decline: "decline";
304
+ propose: "propose";
305
+ }>;
306
+ baseOffer: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
307
+ quantity: z.ZodNumber;
308
+ unitPrice: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
309
+ leadTime: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
310
+ builtAt: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
311
+ termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
312
+ reason: z.ZodString;
313
+ retryAt: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
314
+ available: z.ZodNumber;
315
+ currentOffer: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
316
+ expiry: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
317
+ }, z.core.$strict>;
318
+ export declare const threadQuoteJson: z.ZodObject<{
319
+ salt: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
320
+ agreement: z.ZodObject<{
321
+ commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
322
+ termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
323
+ category: z.ZodString;
324
+ buyerBusinessId: z.ZodString;
325
+ supplierBusinessId: z.ZodString;
326
+ mandateHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
327
+ nonce: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
328
+ expiry: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
329
+ }, z.core.$strict>;
330
+ supplierSignature: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
331
+ }, z.core.$strict>;
332
+ export declare const signedMoveJson: z.ZodObject<{
333
+ move: z.ZodObject<{
334
+ thread: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
335
+ commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
336
+ seq: z.ZodNumber;
337
+ previous: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
338
+ side: z.ZodEnum<{
339
+ buyer: "buyer";
340
+ supplier: "supplier";
341
+ }>;
342
+ kind: z.ZodEnum<{
343
+ accept: "accept";
344
+ counter: "counter";
345
+ decline: "decline";
346
+ propose: "propose";
347
+ }>;
348
+ baseOffer: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
349
+ quantity: z.ZodNumber;
350
+ unitPrice: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
351
+ leadTime: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
352
+ builtAt: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
353
+ termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
354
+ reason: z.ZodString;
355
+ retryAt: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
356
+ available: z.ZodNumber;
357
+ currentOffer: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
358
+ expiry: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
359
+ }, z.core.$strict>;
360
+ signature: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
361
+ quote: z.ZodNullable<z.ZodObject<{
362
+ salt: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
363
+ agreement: z.ZodObject<{
364
+ commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
365
+ termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
366
+ category: z.ZodString;
367
+ buyerBusinessId: z.ZodString;
368
+ supplierBusinessId: z.ZodString;
369
+ mandateHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
370
+ nonce: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
371
+ expiry: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
372
+ }, z.core.$strict>;
373
+ supplierSignature: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
374
+ }, z.core.$strict>>;
375
+ current: z.ZodNullable<z.ZodObject<{
376
+ supplier: z.ZodString;
377
+ item: z.ZodObject<{
378
+ name: z.ZodString;
379
+ summary: z.ZodString;
380
+ }, z.core.$strict>;
381
+ currency: z.ZodEnum<{
382
+ USD: "USD";
383
+ }>;
384
+ unitPrice: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
385
+ rules: z.ZodObject<{
386
+ evidence: z.ZodString;
387
+ leadTime: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
388
+ maxPerBooking: z.ZodNumber;
389
+ dailyCapacity: z.ZodNumber;
390
+ freeCancelWindow: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
391
+ lateCancellationBps: z.ZodNumber;
392
+ noShowBps: z.ZodNumber;
393
+ payment: z.ZodObject<{
394
+ route: z.ZodEnum<{
395
+ invoice: "invoice";
396
+ transfer: "transfer";
397
+ }>;
398
+ dueAfterDelivery: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
399
+ }, z.core.$strict>;
400
+ }, z.core.$strict>;
401
+ }, z.core.$strict>>;
402
+ }, z.core.$strict>;
403
+ export declare const negotiationThreadJson: z.ZodObject<{
404
+ base: z.ZodObject<{
405
+ supplier: z.ZodString;
406
+ item: z.ZodObject<{
407
+ name: z.ZodString;
408
+ summary: z.ZodString;
409
+ }, z.core.$strict>;
410
+ currency: z.ZodEnum<{
411
+ USD: "USD";
412
+ }>;
413
+ unitPrice: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
414
+ rules: z.ZodObject<{
415
+ evidence: z.ZodString;
416
+ leadTime: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
417
+ maxPerBooking: z.ZodNumber;
418
+ dailyCapacity: z.ZodNumber;
419
+ freeCancelWindow: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
420
+ lateCancellationBps: z.ZodNumber;
421
+ noShowBps: z.ZodNumber;
422
+ payment: z.ZodObject<{
423
+ route: z.ZodEnum<{
424
+ invoice: "invoice";
425
+ transfer: "transfer";
426
+ }>;
427
+ dueAfterDelivery: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
428
+ }, z.core.$strict>;
429
+ }, z.core.$strict>;
430
+ }, z.core.$strict>;
431
+ buyer: z.ZodObject<{
432
+ businessId: z.ZodString;
433
+ mandateHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
434
+ }, z.core.$strict>;
435
+ settlement: z.ZodObject<{
436
+ arbiter: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
437
+ day90SupplierShareBps: z.ZodNumber;
438
+ }, z.core.$strict>;
439
+ moves: z.ZodArray<z.ZodObject<{
440
+ move: z.ZodObject<{
441
+ thread: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
442
+ commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
443
+ seq: z.ZodNumber;
444
+ previous: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
445
+ side: z.ZodEnum<{
446
+ buyer: "buyer";
447
+ supplier: "supplier";
448
+ }>;
449
+ kind: z.ZodEnum<{
450
+ accept: "accept";
451
+ counter: "counter";
452
+ decline: "decline";
453
+ propose: "propose";
454
+ }>;
455
+ baseOffer: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
456
+ quantity: z.ZodNumber;
457
+ unitPrice: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
458
+ leadTime: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
459
+ builtAt: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
460
+ termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
461
+ reason: z.ZodString;
462
+ retryAt: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
463
+ available: z.ZodNumber;
464
+ currentOffer: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
465
+ expiry: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
466
+ }, z.core.$strict>;
467
+ signature: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
468
+ quote: z.ZodNullable<z.ZodObject<{
469
+ salt: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
470
+ agreement: z.ZodObject<{
471
+ commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
472
+ termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
473
+ category: z.ZodString;
474
+ buyerBusinessId: z.ZodString;
475
+ supplierBusinessId: z.ZodString;
476
+ mandateHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
477
+ nonce: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
478
+ expiry: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
479
+ }, z.core.$strict>;
480
+ supplierSignature: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
481
+ }, z.core.$strict>>;
482
+ current: z.ZodNullable<z.ZodObject<{
483
+ supplier: z.ZodString;
484
+ item: z.ZodObject<{
485
+ name: z.ZodString;
486
+ summary: z.ZodString;
487
+ }, z.core.$strict>;
488
+ currency: z.ZodEnum<{
489
+ USD: "USD";
490
+ }>;
491
+ unitPrice: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
492
+ rules: z.ZodObject<{
493
+ evidence: z.ZodString;
494
+ leadTime: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
495
+ maxPerBooking: z.ZodNumber;
496
+ dailyCapacity: z.ZodNumber;
497
+ freeCancelWindow: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
498
+ lateCancellationBps: z.ZodNumber;
499
+ noShowBps: z.ZodNumber;
500
+ payment: z.ZodObject<{
501
+ route: z.ZodEnum<{
502
+ invoice: "invoice";
503
+ transfer: "transfer";
504
+ }>;
505
+ dueAfterDelivery: z.ZodPipe<z.ZodString, z.ZodTransform<bigint, string>>;
506
+ }, z.core.$strict>;
507
+ }, z.core.$strict>;
508
+ }, z.core.$strict>>;
509
+ }, z.core.$strict>>;
510
+ }, z.core.$strict>;
511
+ export declare const parseNegotiationMove: (json: unknown) => NegotiationMove | null;
512
+ export declare const parseSignedMove: (json: unknown) => SignedMove | null;
513
+ export declare const parseNegotiationThread: (json: unknown) => NegotiationThread | null;
514
+ //# sourceMappingURL=negotiation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"negotiation.d.ts","sourceRoot":"","sources":["../src/negotiation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAA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