@nuanu-ai/agentify 0.2.4

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Nuanu AI
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,2 @@
1
+ Agentify
2
+ Copyright 2026 Nuanu AI
package/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # `@nuanu-ai/agentify`
2
+
3
+ Agentify puts a merchant's existing products where AI agents buy. Each product
4
+ gets a card in an agent-facing storefront and a paid address of its own,
5
+ `/x402/<item>/purchase`, where an agent pays for it with the x402 payment
6
+ protocol; the money goes from the buyer's wallet to the merchant's without
7
+ passing through us.
8
+
9
+ This package is the merchant's side of it. It publishes the cards, receives
10
+ paid orders and price questions through one outgoing connection, and closes
11
+ each order with the goods or with a refusal. Nothing of the merchant's has to
12
+ be reachable from outside — the process opens that connection itself, so no
13
+ public address and no open port are needed.
14
+
15
+ ## Install
16
+
17
+ ```sh
18
+ npm install @nuanu-ai/agentify
19
+ ```
20
+
21
+ Node.js 24 or newer is required. What arrives with it is our own contracts
22
+ package and zod underneath that, and nothing else.
23
+
24
+ ## The address you give it is the world you are in
25
+
26
+ ```ts
27
+ import { createClient } from '@nuanu-ai/agentify'
28
+
29
+ const agentify = createClient({
30
+ apiKey: process.env.AGENTIFY_API_KEY,
31
+ baseUrl: process.env.AGENTIFY_URL,
32
+ })
33
+ ```
34
+
35
+ There are two addresses, one per world. At `https://test.agentify.ad` you
36
+ build: payments settle on a test chain and the money there is not real. At
37
+ `https://app.agentify.ad` you sell, and it is. A key issued in one does not
38
+ open the other, and the key says which one you are holding: `csk_test_` for the
39
+ first, `csk_live_` for the second. This package picks neither address for you,
40
+ and the worker's first log line names the one it started against and whether
41
+ the money there is real.
42
+
43
+ ## A card, and the handler that fills the orders
44
+
45
+ The card is the whole of what an agent reads before it buys: what you sell, at
46
+ what price, and what the buyer receives. This one is complete.
47
+
48
+ ```ts
49
+ await agentify.catalog.publish({
50
+ merchant_item_id: 'access-monthly',
51
+ title: 'One month of access to the service',
52
+ description: 'Access for 30 days from delivery, renewal not included',
53
+ price: '5.00 USD',
54
+ result: { access_url: 'string', expires_at: 'string' },
55
+ })
56
+ ```
57
+
58
+ Then say what this process answers with, and open the subscription. Paid
59
+ orders, price questions and order events all travel that one connection.
60
+ `grantAccess` below is the seller's own delivery; the handler returns its
61
+ answer and this package sends it, because an answer that has to be returned is
62
+ one nobody can forget to send.
63
+
64
+ ```ts
65
+ agentify.on('order', async (order) => {
66
+ const access = await grantAccess({ idempotencyKey: order.id })
67
+
68
+ if (!access.ok) {
69
+ return order.refused({
70
+ code: 'out_of_stock',
71
+ message: 'No seats left on that plan',
72
+ })
73
+ }
74
+
75
+ return order.delivered({
76
+ access_url: access.url,
77
+ expires_at: access.expiresAt,
78
+ })
79
+ })
80
+
81
+ await agentify.start()
82
+ ```
83
+
84
+ The same order can arrive twice, after a dropped connection or a restart of
85
+ yours, so its `id` is also its idempotency key: pass it into your own delivery
86
+ system and the second arrival hands back the first result instead of delivering
87
+ again.
88
+
89
+ A call that can fail hands the failure back rather than throwing it, in one
90
+ envelope: `ok` says which it was, and a failure carries a code, a sentence a
91
+ person can read, and whether repeating could change the outcome. A card we
92
+ would not publish carries its findings under `problems`, and what no envelope
93
+ can carry — a call that reached nothing at all — is thrown as an `AgentifyError`
94
+ under those same codes.
95
+
96
+ ## The check that needs no key
97
+
98
+ ```sh
99
+ npm exec --offline --package=@nuanu-ai/agentify -- agentify verify card.json
100
+ ```
101
+
102
+ It reads a card the way we read it at publication and names what is wrong,
103
+ offline: no key, no address, no order raised, nothing asked of us. The same
104
+ check is exported as `checkCard`, for cards assembled in code rather than kept
105
+ in files.
106
+
107
+ That is one half of checking yourself. The other half — whether your handler
108
+ holds against a real order, and against that same order arriving twice — is a
109
+ test purchase on the test site rather than anything this command can do; the
110
+ [quickstart](https://app.agentify.ad/docs/quickstart) walks you through one.
111
+
112
+ ## Where the rest of it is written
113
+
114
+ The merchant documentation is public. [The first test
115
+ sale](https://app.agentify.ad/docs/quickstart) walks from an empty project to
116
+ a test purchase your side runs end to end; the other three pages are [the
117
+ product card](https://app.agentify.ad/docs/cards) field by field, [orders and
118
+ fulfillment modes](https://app.agentify.ad/docs/orders) for delivering later
119
+ rather than in the answer to the purchase, and [what can go
120
+ wrong](https://app.agentify.ad/docs/failures).
121
+
122
+ ## Versions
123
+
124
+ This is an early `0.x` pilot surface and the names in it can still change. What
125
+ does not change quietly is the wire: the SDK and the gateway agree on a
126
+ contract version, and a worker whose version the gateway does not share stops
127
+ before it takes an order rather than half reading a document and misreporting
128
+ its own successes. Register `agentify.on('problem', …)`, which is where you
129
+ hear about that and about everything else that did not get through.
130
+
131
+ ## License
132
+
133
+ Licensed under the Apache License 2.0. Distributions that include this package
134
+ must retain the notices required by that license, including the attribution to
135
+ Nuanu AI in `NOTICE`.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * How long the worker waits before asking a gateway that did not answer.
3
+ *
4
+ * This is protocol behaviour rather than infrastructure, which is why it is
5
+ * written here at all. The hand-rolling rule (ADR-0003 §9) reads a wish to
6
+ * build retries by hand as a signal that the wrong component was chosen — and
7
+ * it is right about the general case. This is not the general case: it is the
8
+ * one wait between two calls of one long poll, three constants and a formula,
9
+ * and a retry framework brought in to hold them would be a dependency in the
10
+ * tree a merchant installs (ADR-0003 §8) for something the loop above it does
11
+ * in four lines. If this file ever grows a policy, a registry or a second
12
+ * caller with different needs, that is the trigger to stop and choose one.
13
+ *
14
+ * The numbers are ours and they are not a claim about the gateway. Half a
15
+ * second is short enough that a dropped connection costs a merchant nothing
16
+ * visible, and thirty seconds is close to the long poll's own window, so a
17
+ * worker that waited out an outage comes back within about one window of the
18
+ * gateway returning rather than an hour later.
19
+ *
20
+ * The jitter is the part that is easy to leave out and expensive to lack. Every
21
+ * worker that lost the same gateway failed in the same second; without jitter
22
+ * they all come back in the same millisecond, forever, and the gateway that was
23
+ * struggling is now being hit by the whole fleet in step. Half the delay is
24
+ * fixed and half is drawn, so the delay stays inside the bounds above while no
25
+ * two workers keep the same phase.
26
+ */
27
+ /** The wait after the first failed call. */
28
+ export declare const FIRST_RETRY_MS = 500;
29
+ /**
30
+ * The longest this file will ever ask a worker to wait.
31
+ *
32
+ * Copied outside this package, and the copy is named here rather than only
33
+ * where it is read, because whoever raises this number opens this file and not
34
+ * that one. `DOUBT_MS` in packages/slice/src/subscription.ts is the window a
35
+ * mock merchant waits before it decides its subscription is alive again, and it
36
+ * is this ceiling plus the poll deadline plus a margin. Raise this and that
37
+ * window is too narrow, which makes a healthcheck report a dead subscription as
38
+ * a live one.
39
+ */
40
+ export declare const RETRY_CEILING_MS = 30000;
41
+ /** What the wait is multiplied by for each further failure in a row. */
42
+ export declare const RETRY_GROWTH = 2;
43
+ /**
44
+ * The wait before attempt number `attempt`, given one draw from [0, 1].
45
+ *
46
+ * The draw is a parameter rather than a call to `Math.random` inside, because
47
+ * a test cannot assert a bound it cannot reproduce, and a delay whose bounds
48
+ * are not tested is a delay nobody has checked.
49
+ *
50
+ * Both refusals are bugs in the caller rather than conditions to handle, so
51
+ * they are thrown. A zeroth attempt or a draw outside the range would produce
52
+ * a number outside the bounds this file promises, and nothing downstream could
53
+ * tell that it had.
54
+ */
55
+ export declare const retryDelayMs: (attempt: number, random: number) => number;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * How long the worker waits before asking a gateway that did not answer.
3
+ *
4
+ * This is protocol behaviour rather than infrastructure, which is why it is
5
+ * written here at all. The hand-rolling rule (ADR-0003 §9) reads a wish to
6
+ * build retries by hand as a signal that the wrong component was chosen — and
7
+ * it is right about the general case. This is not the general case: it is the
8
+ * one wait between two calls of one long poll, three constants and a formula,
9
+ * and a retry framework brought in to hold them would be a dependency in the
10
+ * tree a merchant installs (ADR-0003 §8) for something the loop above it does
11
+ * in four lines. If this file ever grows a policy, a registry or a second
12
+ * caller with different needs, that is the trigger to stop and choose one.
13
+ *
14
+ * The numbers are ours and they are not a claim about the gateway. Half a
15
+ * second is short enough that a dropped connection costs a merchant nothing
16
+ * visible, and thirty seconds is close to the long poll's own window, so a
17
+ * worker that waited out an outage comes back within about one window of the
18
+ * gateway returning rather than an hour later.
19
+ *
20
+ * The jitter is the part that is easy to leave out and expensive to lack. Every
21
+ * worker that lost the same gateway failed in the same second; without jitter
22
+ * they all come back in the same millisecond, forever, and the gateway that was
23
+ * struggling is now being hit by the whole fleet in step. Half the delay is
24
+ * fixed and half is drawn, so the delay stays inside the bounds above while no
25
+ * two workers keep the same phase.
26
+ */
27
+ /** The wait after the first failed call. */
28
+ export const FIRST_RETRY_MS = 500;
29
+ /**
30
+ * The longest this file will ever ask a worker to wait.
31
+ *
32
+ * Copied outside this package, and the copy is named here rather than only
33
+ * where it is read, because whoever raises this number opens this file and not
34
+ * that one. `DOUBT_MS` in packages/slice/src/subscription.ts is the window a
35
+ * mock merchant waits before it decides its subscription is alive again, and it
36
+ * is this ceiling plus the poll deadline plus a margin. Raise this and that
37
+ * window is too narrow, which makes a healthcheck report a dead subscription as
38
+ * a live one.
39
+ */
40
+ export const RETRY_CEILING_MS = 30_000;
41
+ /** What the wait is multiplied by for each further failure in a row. */
42
+ export const RETRY_GROWTH = 2;
43
+ /**
44
+ * The wait before attempt number `attempt`, given one draw from [0, 1].
45
+ *
46
+ * The draw is a parameter rather than a call to `Math.random` inside, because
47
+ * a test cannot assert a bound it cannot reproduce, and a delay whose bounds
48
+ * are not tested is a delay nobody has checked.
49
+ *
50
+ * Both refusals are bugs in the caller rather than conditions to handle, so
51
+ * they are thrown. A zeroth attempt or a draw outside the range would produce
52
+ * a number outside the bounds this file promises, and nothing downstream could
53
+ * tell that it had.
54
+ */
55
+ export const retryDelayMs = (attempt, random) => {
56
+ if (!Number.isInteger(attempt) || attempt < 1) {
57
+ throw new TypeError(`the attempt is a whole number from 1 upwards, and was ${attempt}`);
58
+ }
59
+ if (!(random >= 0 && random <= 1)) {
60
+ throw new TypeError(`the random draw is a number from 0 to 1, and was ${random}`);
61
+ }
62
+ const capped = Math.min(RETRY_CEILING_MS, FIRST_RETRY_MS * RETRY_GROWTH ** (attempt - 1));
63
+ return capped / 2 + (capped / 2) * random;
64
+ };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Is this card enough for an agent to buy from?
3
+ *
4
+ * The check is the contracts schema and nothing beside it. A second opinion
5
+ * written here would be a second definition of a complete card, and the day the
6
+ * two disagreed a merchant would pass one and be refused by the other.
7
+ *
8
+ * What the check cannot see is worth stating, because a merchant reading a
9
+ * short list of findings would otherwise assume it is the whole list. A card is
10
+ * checked in two stages: first its shape — which fields are there, what they
11
+ * hold, whether any field was invented — and then the rules that compare one
12
+ * field against another, such as a delivery deadline being allowed only on the
13
+ * modes that wait. The second stage is only reached when the first passes. So a
14
+ * card that failed on its shape may still have a finding waiting behind the
15
+ * ones it was given, and the report says so instead of implying a clean second
16
+ * run. A card that passes has passed both stages and there is nothing behind
17
+ * it.
18
+ *
19
+ * What no local check can decide at all: whether the gateway will accept the
20
+ * card. Publishing is the authority — a currency we do not settle in, a
21
+ * merchant key already in use, a policy nobody has written into a schema — and
22
+ * this check makes no claim about any of that.
23
+ */
24
+ import { type Problem } from "@nuanu-ai/agentify-contracts";
25
+ export interface CardCheck {
26
+ /**
27
+ * Everything wrong with the card that one pass could see, under the same word
28
+ * and in the same shape the publish call answers in. Empty means the card is
29
+ * complete as far as the contract can tell.
30
+ */
31
+ readonly problems: readonly Problem[];
32
+ }
33
+ export declare const checkCard: (card: unknown) => CardCheck;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Is this card enough for an agent to buy from?
3
+ *
4
+ * The check is the contracts schema and nothing beside it. A second opinion
5
+ * written here would be a second definition of a complete card, and the day the
6
+ * two disagreed a merchant would pass one and be refused by the other.
7
+ *
8
+ * What the check cannot see is worth stating, because a merchant reading a
9
+ * short list of findings would otherwise assume it is the whole list. A card is
10
+ * checked in two stages: first its shape — which fields are there, what they
11
+ * hold, whether any field was invented — and then the rules that compare one
12
+ * field against another, such as a delivery deadline being allowed only on the
13
+ * modes that wait. The second stage is only reached when the first passes. So a
14
+ * card that failed on its shape may still have a finding waiting behind the
15
+ * ones it was given, and the report says so instead of implying a clean second
16
+ * run. A card that passes has passed both stages and there is nothing behind
17
+ * it.
18
+ *
19
+ * What no local check can decide at all: whether the gateway will accept the
20
+ * card. Publishing is the authority — a currency we do not settle in, a
21
+ * merchant key already in use, a policy nobody has written into a schema — and
22
+ * this check makes no claim about any of that.
23
+ */
24
+ import { CardSchema } from "@nuanu-ai/agentify-contracts";
25
+ import { problemsOf } from "./schema.js";
26
+ export const checkCard = (card) => {
27
+ const result = CardSchema.safeParse(card);
28
+ return { problems: result.success ? [] : problemsOf(result.error.issues) };
29
+ };
package/dist/cli.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The command installed by `@nuanu-ai/agentify` as `agentify`.
4
+ *
5
+ * It is glue and nothing else: the work is in `verify.ts`, which answers with
6
+ * a number and a stream of lines, so that everything the command does can be
7
+ * tested without a process, a shell or a temporary directory of output.
8
+ *
9
+ * What a merchant runs is not this file but `dist/cli.js` compiled from it, and
10
+ * the distinction is the whole reason the package has a build. These sources
11
+ * import each other with `.js` specifiers; Node's type stripping does not
12
+ * rewrite such a specifier, so it would look for a `.js` file that is not
13
+ * there and stop. `tsc` writes exactly that file, and `publishConfig.bin` in
14
+ * `package.json` is what points the installed `agentify` command at it.
15
+ *
16
+ * Nothing in this repository runs the compiled command, so nothing in
17
+ * `pnpm test` can tell you it still starts. `pnpm outside` is what does: it
18
+ * installs the packed tarball into a directory with no path back here and runs
19
+ * the installed `agentify verify` command there.
20
+ */
21
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The command installed by `@nuanu-ai/agentify` as `agentify`.
4
+ *
5
+ * It is glue and nothing else: the work is in `verify.ts`, which answers with
6
+ * a number and a stream of lines, so that everything the command does can be
7
+ * tested without a process, a shell or a temporary directory of output.
8
+ *
9
+ * What a merchant runs is not this file but `dist/cli.js` compiled from it, and
10
+ * the distinction is the whole reason the package has a build. These sources
11
+ * import each other with `.js` specifiers; Node's type stripping does not
12
+ * rewrite such a specifier, so it would look for a `.js` file that is not
13
+ * there and stop. `tsc` writes exactly that file, and `publishConfig.bin` in
14
+ * `package.json` is what points the installed `agentify` command at it.
15
+ *
16
+ * Nothing in this repository runs the compiled command, so nothing in
17
+ * `pnpm test` can tell you it still starts. `pnpm outside` is what does: it
18
+ * installs the packed tarball into a directory with no path back here and runs
19
+ * the installed `agentify verify` command there.
20
+ */
21
+ import { runVerify } from "./verify.js";
22
+ process.exitCode = await runVerify(process.argv.slice(2), (line) => {
23
+ process.stdout.write(`${line}\n`);
24
+ });