@nuanu-ai/agentify-contracts 0.6.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.
package/dist/card.d.ts CHANGED
@@ -33,12 +33,16 @@ import type { Money } from "./primitives.js";
33
33
  * `sync` — in the answer to the purchase, and the payment executes last, after
34
34
  * the merchant has delivered. `async` — later, by a separate call, and the
35
35
  * payment executes at the moment of purchase. `confirm` — the merchant is
36
- * asked first, and the payment executes right after they say yes.
36
+ * asked first, and the payment executes right after they say yes. `ship` — a
37
+ * parcel the merchant hands to a carrier (ADR-0033): the payment executes at
38
+ * the moment of purchase, as in `async`, and the order carries the buyer's
39
+ * address until the merchant takes it on, or it ends without them.
37
40
  */
38
41
  export declare const FulfillmentSchema: z.ZodEnum<{
39
42
  sync: "sync";
40
43
  async: "async";
41
44
  confirm: "confirm";
45
+ ship: "ship";
42
46
  }>;
43
47
  /**
44
48
  * How the price and availability of this card are asked for, if they are.
@@ -66,6 +70,20 @@ export declare const PriceCheckSchema: z.ZodUnion<readonly [z.ZodLiteral<"handle
66
70
  * wherever a merchant's listing name is written down.
67
71
  */
68
72
  export declare const ServiceNameSchema: z.ZodString;
73
+ /**
74
+ * Who sells, as an agent reads it beside a product and on an order: the name
75
+ * the merchant sells under and the site of their shop (ADR-0034).
76
+ *
77
+ * Both are the merchant's own word and nothing here checked either, which the
78
+ * description says to the reader who acts on it — a name and a site can be
79
+ * anybody's. Null is "none given": a merchant who gave no site has none here,
80
+ * and a name is missing only from an order whose merchant has since lost it.
81
+ */
82
+ export declare const SellerSchema: z.ZodObject<{
83
+ name: z.ZodNullable<z.ZodString>;
84
+ site: z.ZodNullable<z.ZodString>;
85
+ }, z.core.$strict>;
86
+ export type Seller = z.infer<typeof SellerSchema>;
69
87
  /**
70
88
  * The words a merchant puts on one product so an agent searching a catalog can
71
89
  * find it.
@@ -101,7 +119,7 @@ export declare const CardSchema: z.ZodObject<{
101
119
  required: z.ZodOptional<z.ZodBoolean>;
102
120
  title: z.ZodOptional<z.ZodString>;
103
121
  }, z.core.$strict>>>>;
104
- result: z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodObject<{
122
+ result: z.ZodOptional<z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodObject<{
105
123
  type: z.ZodEnum<{
106
124
  string: "string";
107
125
  number: "number";
@@ -110,18 +128,20 @@ export declare const CardSchema: z.ZodObject<{
110
128
  }>;
111
129
  required: z.ZodOptional<z.ZodBoolean>;
112
130
  title: z.ZodOptional<z.ZodString>;
113
- }, z.core.$strict>>>;
131
+ }, z.core.$strict>>>>;
114
132
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
115
133
  fulfillment: z.ZodDefault<z.ZodEnum<{
116
134
  sync: "sync";
117
135
  async: "async";
118
136
  confirm: "confirm";
137
+ ship: "ship";
119
138
  }>>;
120
139
  price_check: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"handler">, z.ZodObject<{
121
140
  url: z.ZodURL;
122
141
  }, z.core.$strict>]>>;
123
142
  confirm_deadline_seconds: z.ZodOptional<z.ZodInt>;
124
143
  fulfill_deadline_seconds: z.ZodOptional<z.ZodInt>;
144
+ ship_within_seconds: z.ZodOptional<z.ZodInt>;
125
145
  }, z.core.$strict>;
126
146
  export type Fulfillment = z.infer<typeof FulfillmentSchema>;
127
147
  export type PriceCheck = z.infer<typeof PriceCheckSchema>;
@@ -148,7 +168,8 @@ export type CardInput = Omit<Card, "price" | "params" | "result" | "fulfillment"
148
168
  price: Money | string;
149
169
  /** Each field whole, or written as its type word alone: `email: 'string'`. */
150
170
  params?: ParamSpecInput;
151
- result: ParamSpecInput;
171
+ /** Left out on a parcel's card, whose mode fixes what the agent receives. */
172
+ result?: ParamSpecInput;
152
173
  /** Left out on a card that is delivered in the answer to the purchase. */
153
174
  fulfillment?: Fulfillment;
154
175
  };
@@ -162,47 +183,70 @@ export type CardInput = Omit<Card, "price" | "params" | "result" | "fulfillment"
162
183
  * place that picks.
163
184
  */
164
185
  export declare const purchaseCheckFor: (card: Card) => z.ZodType;
165
- /** The check this card's delivery is held to. */
186
+ /**
187
+ * The check this card's delivery is held to: the goods its `result` declared,
188
+ * or for a parcel, which is not delivered with goods at all, its shipment
189
+ * (ADR-0033).
190
+ */
166
191
  export declare const deliveryCheckFor: (card: Card) => z.ZodType;
167
- export declare const PublicCardSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
168
- id: z.ZodString;
169
- title: z.ZodString;
170
- description: z.ZodString;
171
- price: z.ZodObject<{
172
- amount: z.ZodString;
173
- currency: z.ZodString;
174
- }, z.core.$strict>;
175
- as_of: z.ZodISODateTime;
176
- params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
177
- type: z.ZodEnum<{
178
- string: "string";
179
- number: "number";
180
- boolean: "boolean";
181
- integer: "integer";
182
- }>;
183
- required: z.ZodOptional<z.ZodBoolean>;
184
- title: z.ZodOptional<z.ZodString>;
185
- }, z.core.$strict>>>;
186
- result: z.ZodRecord<z.ZodString, z.ZodObject<{
187
- type: z.ZodEnum<{
188
- string: "string";
189
- number: "number";
190
- boolean: "boolean";
191
- integer: "integer";
192
- }>;
193
- required: z.ZodOptional<z.ZodBoolean>;
194
- title: z.ZodOptional<z.ZodString>;
195
- }, z.core.$strict>>;
196
- price_checked_at_purchase: z.ZodBoolean;
197
- fulfillment: z.ZodLiteral<"sync">;
198
- }, z.core.$strict>, z.ZodObject<{
192
+ /**
193
+ * The fields of a card as an agent reads it in a catalog.
194
+ *
195
+ * The published card is what a merchant writes; this is what we say about it
196
+ * to somebody who is about to spend money. Every difference between the two is
197
+ * a decision, so each one is written down.
198
+ *
199
+ * Our catalog identifier replaces the merchant's own key. `id` is what a
200
+ * purchase, a receipt and a status all use, while `merchant_item_id` is unique
201
+ * only inside one merchant's catalog and means nothing outside it. An agent
202
+ * handed both would use the wrong one some of the time, for no gain.
203
+ *
204
+ * `price_check` is gone and one fact out of it stays. The address of a
205
+ * merchant's pricing service is infrastructure of theirs, no agent ever calls
206
+ * it, and publishing it would put it in front of everyone. What an agent does
207
+ * act on is that the price will be asked again: the number in the catalog is
208
+ * what it compares when choosing, and the sale can go through at another. So
209
+ * the projection carries `price_checked_at_purchase` and nothing else about
210
+ * how the asking is done. The flag says we ask, not that we get an answer —
211
+ * what happens when a merchant is silent depends on the mode and is the
212
+ * gateway's, and this document does not claim to know it.
213
+ *
214
+ * Both deadlines stay, because they are the merchant's promise to the agent
215
+ * about how long it may wait, and the agent is told them before it pays. The
216
+ * projection writes each only on a mode that has it, and the document says so
217
+ * in words rather than as structure: it takes fields added later (ADR-0006
218
+ * §5), so a field an agent does not expect is one it ignores, not one it can
219
+ * refuse.
220
+ *
221
+ * The mode is a word whose known values are listed beside it, for the same
222
+ * reason. The storefront has no version, so a mode added later reaches agents
223
+ * that still hold this contract, and to them it has to be a card to pass over
224
+ * rather than a catalog they cannot read.
225
+ *
226
+ * `as_of` is added: the moment the price shown here was published. A price
227
+ * with no moment behind it cannot be judged stale, and this is the only
228
+ * freshness claim a catalog makes.
229
+ *
230
+ * `tags` are gone as well, and that one is a decision rather than an omission.
231
+ * They are words a merchant chose so that a search in a discovery catalog finds
232
+ * this product, held to that catalog's own rule about length and alphabet. Our
233
+ * own catalog is not searched that way — an agent reading it has the whole
234
+ * page — so carrying them here would put a foreign catalog's constraint in
235
+ * front of a reader who has no use for it.
236
+ *
237
+ * Who sells is here as the merchant gave it, a name and the site of their
238
+ * shop (ADR-0034), and as nothing more: no profile, no contact of ours, and no
239
+ * claim that either was checked. Who "we" are to the buyer is a question this
240
+ * document still does not answer.
241
+ */
242
+ export declare const PublicCardSchema: z.ZodObject<{
199
243
  id: z.ZodString;
200
244
  title: z.ZodString;
201
245
  description: z.ZodString;
202
246
  price: z.ZodObject<{
203
247
  amount: z.ZodString;
204
248
  currency: z.ZodString;
205
- }, z.core.$strict>;
249
+ }, z.core.$loose>;
206
250
  as_of: z.ZodISODateTime;
207
251
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
208
252
  type: z.ZodEnum<{
@@ -213,8 +257,8 @@ export declare const PublicCardSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
213
257
  }>;
214
258
  required: z.ZodOptional<z.ZodBoolean>;
215
259
  title: z.ZodOptional<z.ZodString>;
216
- }, z.core.$strict>>>;
217
- result: z.ZodRecord<z.ZodString, z.ZodObject<{
260
+ }, z.core.$loose>>>;
261
+ result: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
218
262
  type: z.ZodEnum<{
219
263
  string: "string";
220
264
  number: "number";
@@ -223,45 +267,40 @@ export declare const PublicCardSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
223
267
  }>;
224
268
  required: z.ZodOptional<z.ZodBoolean>;
225
269
  title: z.ZodOptional<z.ZodString>;
226
- }, z.core.$strict>>;
270
+ }, z.core.$loose>>>;
227
271
  price_checked_at_purchase: z.ZodBoolean;
228
- fulfillment: z.ZodLiteral<"async">;
272
+ seller: z.ZodObject<{
273
+ name: z.ZodNullable<z.ZodString>;
274
+ site: z.ZodNullable<z.ZodString>;
275
+ }, z.core.$loose>;
276
+ fulfillment: z.ZodUnion<readonly [z.ZodEnum<{
277
+ sync: "sync";
278
+ async: "async";
279
+ confirm: "confirm";
280
+ ship: "ship";
281
+ }>, z.ZodString]>;
229
282
  fulfill_deadline_seconds: z.ZodOptional<z.ZodInt>;
230
- }, z.core.$strict>, z.ZodObject<{
231
- id: z.ZodString;
232
- title: z.ZodString;
233
- description: z.ZodString;
234
- price: z.ZodObject<{
235
- amount: z.ZodString;
236
- currency: z.ZodString;
237
- }, z.core.$strict>;
238
- as_of: z.ZodISODateTime;
239
- params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
240
- type: z.ZodEnum<{
241
- string: "string";
242
- number: "number";
243
- boolean: "boolean";
244
- integer: "integer";
245
- }>;
246
- required: z.ZodOptional<z.ZodBoolean>;
247
- title: z.ZodOptional<z.ZodString>;
248
- }, z.core.$strict>>>;
249
- result: z.ZodRecord<z.ZodString, z.ZodObject<{
250
- type: z.ZodEnum<{
251
- string: "string";
252
- number: "number";
253
- boolean: "boolean";
254
- integer: "integer";
255
- }>;
256
- required: z.ZodOptional<z.ZodBoolean>;
257
- title: z.ZodOptional<z.ZodString>;
258
- }, z.core.$strict>>;
259
- price_checked_at_purchase: z.ZodBoolean;
260
- fulfillment: z.ZodLiteral<"confirm">;
261
283
  confirm_deadline_seconds: z.ZodOptional<z.ZodInt>;
262
- fulfill_deadline_seconds: z.ZodOptional<z.ZodInt>;
263
- }, z.core.$strict>], "fulfillment">;
284
+ ship_within_seconds: z.ZodOptional<z.ZodInt>;
285
+ }, z.core.$loose>;
264
286
  export type PublicCard = z.infer<typeof PublicCardSchema>;
287
+ /**
288
+ * A card as `publicCardOf` builds it: the card's own fields without the index
289
+ * signature the open schema adds, and a mode this version knows.
290
+ *
291
+ * An agent reads a card with `PublicCardSchema`, which takes fields and modes
292
+ * added later (ADR-0006 §5); what is built is held to the opposite. The type
293
+ * catches part of that: an unknown field written straight into the returned
294
+ * object is a compile error. It does not reach inside the card's parts, which
295
+ * keep the open schema's index signatures, nor tie a deadline to its mode. The
296
+ * gateway's outbound check holds the rest, at every depth, before anything is
297
+ * sent (`checksBeforeSending`).
298
+ */
299
+ export type ProjectedCard = {
300
+ [Field in keyof PublicCard as string extends Field ? never : Field]: PublicCard[Field];
301
+ } & {
302
+ readonly fulfillment: Fulfillment;
303
+ };
265
304
  /**
266
305
  * The card as an agent reads it, built from the card the merchant published.
267
306
  *
@@ -272,13 +311,15 @@ export type PublicCard = z.infer<typeof PublicCardSchema>;
272
311
  * every agent by default, and the first anybody heard of it would be a
273
312
  * merchant's pricing address in a public catalog.
274
313
  *
275
- * The two things the card cannot know are passed in: the catalog identifier we
276
- * issued when it was published, and the moment its price was published.
314
+ * The three things the card cannot know are passed in: the catalog identifier
315
+ * we issued when it was published, the moment its price was published, and
316
+ * who sells it as their merchant stands now.
277
317
  */
278
318
  export declare const publicCardOf: (card: Card, issued: {
279
319
  readonly id: string;
280
320
  readonly as_of: string;
281
- }) => PublicCard;
321
+ readonly seller: Seller;
322
+ }) => ProjectedCard;
282
323
  /**
283
324
  * One card as a discovery catalog reads it: what an agent that has never seen
284
325
  * our own catalog finds when it searches somewhere else.
@@ -327,7 +368,10 @@ export interface BazaarDeclaration {
327
368
  readonly input: Record<string, unknown>;
328
369
  /** The JSON Schema that body is held to, derived from the card's `params`. */
329
370
  readonly inputSchema: Record<string, unknown>;
330
- /** An example of what arrives on delivery, derived from the card's `result`. */
371
+ /**
372
+ * An example of what arrives on delivery, derived from the card's `result`,
373
+ * or for a parcel the record of its shipment.
374
+ */
331
375
  readonly output: {
332
376
  readonly example: Record<string, unknown>;
333
377
  };
@@ -392,7 +436,7 @@ export declare const MerchantCardSchema: z.ZodObject<{
392
436
  required: z.ZodOptional<z.ZodBoolean>;
393
437
  title: z.ZodOptional<z.ZodString>;
394
438
  }, z.core.$strict>>>>;
395
- result: z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodObject<{
439
+ result: z.ZodOptional<z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodObject<{
396
440
  type: z.ZodEnum<{
397
441
  string: "string";
398
442
  number: "number";
@@ -401,18 +445,20 @@ export declare const MerchantCardSchema: z.ZodObject<{
401
445
  }>;
402
446
  required: z.ZodOptional<z.ZodBoolean>;
403
447
  title: z.ZodOptional<z.ZodString>;
404
- }, z.core.$strict>>>;
448
+ }, z.core.$strict>>>>;
405
449
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
406
450
  fulfillment: z.ZodDefault<z.ZodEnum<{
407
451
  sync: "sync";
408
452
  async: "async";
409
453
  confirm: "confirm";
454
+ ship: "ship";
410
455
  }>>;
411
456
  price_check: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"handler">, z.ZodObject<{
412
457
  url: z.ZodURL;
413
458
  }, z.core.$strict>]>>;
414
459
  confirm_deadline_seconds: z.ZodOptional<z.ZodInt>;
415
460
  fulfill_deadline_seconds: z.ZodOptional<z.ZodInt>;
461
+ ship_within_seconds: z.ZodOptional<z.ZodInt>;
416
462
  }, z.core.$strict>;
417
463
  selling: z.ZodEnum<{
418
464
  open: "open";