@agenzo/merchant-cli 0.1.1

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/README.md ADDED
@@ -0,0 +1,180 @@
1
+ # @agenzo/merchant-cli
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@agenzo/merchant-cli)](https://www.npmjs.com/package/@agenzo/merchant-cli)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
5
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org)
6
+
7
+ CLI tool for AI Agents to order rides and query merchant services. Ships with a
8
+ structured [SKILL.md](SKILL.md) so AI Agents can run the full ride flow with zero
9
+ extra setup.
10
+
11
+ [Install](#installation) · [AI Agent Skill](#ai-agent-skill) · [Quick Start](#quick-start) · [Commands](#commands) · [Auth](#authentication)
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install -g @agenzo/merchant-cli
17
+ ```
18
+
19
+ **Requirements**: Node.js 18+
20
+
21
+ The package installs a single binary, `agenzo-merchant-cli`:
22
+
23
+ ```bash
24
+ agenzo-merchant-cli --help
25
+ agenzo-merchant-cli --version
26
+ ```
27
+
28
+ ## AI Agent Skill
29
+
30
+ This CLI ships with a structured [SKILL.md](SKILL.md) that AI Agents can load to
31
+ understand capability discovery, the `quote → book → get → [cancel]` ride flow,
32
+ command parameters, and error recovery. Include `SKILL.md` in the agent's context
33
+ or tool definition.
34
+
35
+ ## Quick Start
36
+
37
+ ```bash
38
+ # 1. (Optional) point at a non-default host
39
+ agenzo-merchant-cli config set-host https://agent.everonet.com
40
+
41
+ # 2. Discover available services
42
+ agenzo-merchant-cli services list --api-key sk_xxx
43
+
44
+ # 3. Get fare quotes for a trip
45
+ agenzo-merchant-cli ride quote --api-key sk_xxx \
46
+ --pickup-lat 1.3 --pickup-lng 103.8 --pickup-name "Changi" \
47
+ --dropoff-lat 1.29 --dropoff-lng 103.85 --dropoff-name "Marina Bay"
48
+
49
+ # 4. Book against a returned quote (write op → idempotency key required)
50
+ agenzo-merchant-cli --yes ride book --api-key sk_xxx \
51
+ --quote-id qt_123 --vehicle-class standard \
52
+ --passenger-name "Ada" --idempotency-key idem_001
53
+
54
+ # 5. Poll the order until a terminal status
55
+ agenzo-merchant-cli ride get ord_123 --api-key sk_xxx
56
+
57
+ # 6. Cancel if needed (write op → idempotency key required)
58
+ agenzo-merchant-cli --yes ride cancel ord_123 --api-key sk_xxx --idempotency-key idem_002
59
+ ```
60
+
61
+ ## Commands
62
+
63
+ | Command | Description |
64
+ |---------|-------------|
65
+ | `config set-host <url>` | Set the API host (persisted locally) |
66
+ | `config reset-host` | Reset the API host to the default |
67
+ | `config show` | Show the current configuration |
68
+ | `services list` | List available merchant services |
69
+ | `services get <service-id>` | Retrieve a single service by id |
70
+ | `ride quote` | Request fare quotes between two points |
71
+ | `ride book` | Book a ride against a returned quote |
72
+ | `ride get <order-id>` | Retrieve a single ride order |
73
+ | `ride cancel <order-id>` | Cancel a ride order (may incur a fee) |
74
+ | `ride list-orders` | List ride orders (paginated, optional status filter) |
75
+
76
+ ### Command Reference
77
+
78
+ ```bash
79
+ # Configuration (local only, no network)
80
+ agenzo-merchant-cli config set-host https://agent.everonet.com
81
+ agenzo-merchant-cli config reset-host
82
+ agenzo-merchant-cli config show
83
+
84
+ # Services registry
85
+ agenzo-merchant-cli services list --api-key sk_xxx
86
+ agenzo-merchant-cli services get svc_001 --api-key sk_xxx
87
+
88
+ # Ride flow
89
+ agenzo-merchant-cli ride quote --api-key sk_xxx \
90
+ --pickup-lat <lat> --pickup-lng <lng> --pickup-name <name> \
91
+ --dropoff-lat <lat> --dropoff-lng <lng> --dropoff-name <name> [--service-id <id>]
92
+ agenzo-merchant-cli ride book --api-key sk_xxx \
93
+ --quote-id <id> --vehicle-class <class> --passenger-name <name> \
94
+ [--passenger-phone <phone>] [--passenger-email <email>] --idempotency-key <key>
95
+ agenzo-merchant-cli ride get <order-id> --api-key sk_xxx
96
+ agenzo-merchant-cli ride cancel <order-id> --api-key sk_xxx --idempotency-key <key>
97
+ agenzo-merchant-cli ride list-orders --api-key sk_xxx [--status <status>] [--page <n>] [--page-size <n>]
98
+ ```
99
+
100
+ ## Global Flags
101
+
102
+ | Flag | Description |
103
+ |------|-------------|
104
+ | `--format <json\|table>` | Output format. Defaults to `json`; pass `--format table` for a human-readable table. |
105
+ | `--api-key <key>` | API key for runtime requests, sent as the `X-API-Key` header. |
106
+ | `--idempotency-key <key>` | Caller-supplied idempotency key for write operations (`ride book`, `ride cancel`). |
107
+ | `--yes` | Skip confirmation/interactive prompts (for automation / AI Agents). |
108
+
109
+ ### Output format
110
+
111
+ All commands emit JSON by default, which is ideal for scripting and AI Agents.
112
+ Add `--format table` for a readable summary instead:
113
+
114
+ ```bash
115
+ agenzo-merchant-cli ride list-orders --api-key sk_xxx --format table
116
+ ```
117
+
118
+ ### Progress feedback
119
+
120
+ Ride commands make a network call, so while one is in flight the CLI shows a
121
+ spinner (e.g. `⠋ Fetching quotes...`) so you can tell it is working rather than
122
+ hung. This feedback is written to **stderr**, never stdout — so piping or
123
+ redirecting stdout still yields a clean payload:
124
+
125
+ ```bash
126
+ # stdout stays pure JSON; the spinner (on stderr) does not leak in
127
+ agenzo-merchant-cli ride quote --api-key sk_xxx ... | jq '.vehicle_classes'
128
+ ```
129
+
130
+ The spinner animates only when stderr is an interactive terminal (TTY). When
131
+ output is piped, redirected, or run in CI / by an agent, the animation is
132
+ suppressed so no control characters end up in logs. Local commands (`config`,
133
+ `services`) return instantly and show no spinner.
134
+
135
+ ### Idempotency
136
+
137
+ Write operations (`ride book`, `ride cancel`) require a caller-supplied
138
+ `--idempotency-key`. The CLI **never** auto-generates one:
139
+
140
+ - Without `--yes`, the CLI prompts for the key interactively.
141
+ - With `--yes`, a missing key is a hard error (`PARAM_IDEMPOTENCY_KEY_REQUIRED`).
142
+
143
+ The key must be 1–128 characters from `[A-Za-z0-9_-]` and is sent as the
144
+ `Idempotency-Key` header — never in the request body.
145
+
146
+ ## Authentication
147
+
148
+ Runtime commands (`services`, `ride`) require `--api-key`. The value is sent on
149
+ every request as the `X-API-Key` header. `config` commands are local-only and
150
+ need no API key.
151
+
152
+ ## Host configuration
153
+
154
+ The default API host is `https://agent.everonet.com`. Override it with
155
+ `config set-host` (persisted at `~/.agenzo-merchant-cli/config.json`) and revert
156
+ with `config reset-host`:
157
+
158
+ ```bash
159
+ agenzo-merchant-cli config set-host http://localhost:8000 # local dev
160
+ agenzo-merchant-cli config reset-host # back to https://agent.everonet.com
161
+ agenzo-merchant-cli config show
162
+ ```
163
+
164
+ ## Amounts
165
+
166
+ Monetary amounts are **decimals in the currency's standard unit** (e.g. `12.50`
167
+ USD), not minor units / cents.
168
+
169
+ ## Development
170
+
171
+ ```bash
172
+ npm install
173
+ npm run build # tsup production build
174
+ npm run dev # watch build
175
+ npm run lint # eslint
176
+ ```
177
+
178
+ ## License
179
+
180
+ MIT
package/SKILL.md ADDED
@@ -0,0 +1,132 @@
1
+ # @agenzo/merchant-cli — AI Agent Skill
2
+
3
+ CLI for ordering rides and querying merchant services. This skill tells an AI
4
+ Agent how to discover capabilities and drive the full ride lifecycle.
5
+
6
+ ## Setup
7
+
8
+ - Binary: `agenzo-merchant-cli`
9
+ - Auth: every runtime command needs `--api-key <key>` (sent as `X-API-Key`).
10
+ - Output: JSON by default (machine-readable). Add `--format table` only for
11
+ human display.
12
+ - Streams: parse **stdout** for results. Progress spinners and status lines go
13
+ to **stderr** and never contaminate stdout — read only stdout as data. (The
14
+ spinner is auto-suppressed when stderr is not a TTY, e.g. agent-invoked.)
15
+ - Automation: pass `--yes` to skip interactive prompts. In `--yes` mode every
16
+ required value must be supplied via flags.
17
+ - Host: defaults to `https://agent.everonet.com`. Change with
18
+ `config set-host <url>`; reset with `config reset-host`.
19
+ - **Amounts are decimals in the currency's standard unit** (e.g. `12.50` USD),
20
+ never minor units / cents.
21
+
22
+ ## Capability discovery
23
+
24
+ Before quoting, discover which services exist and are enabled:
25
+
26
+ ```bash
27
+ agenzo-merchant-cli services list --api-key sk_xxx
28
+ agenzo-merchant-cli services get <service-id> --api-key sk_xxx
29
+ ```
30
+
31
+ - `services list` → `{ services: Service[] }`. Each `Service` has
32
+ `service_id`, `name`, `enabled`.
33
+ - `services get <service-id>` → a single `Service`. A missing/unknown id raises
34
+ `SERVICE_NOT_FOUND`.
35
+ - Use a discovered `service_id` as the optional `--service-id` on `ride quote`.
36
+
37
+ ## Ride workflow (closed loop)
38
+
39
+ The ride lifecycle is `quote → book → get (poll) → [cancel]`.
40
+
41
+ ```
42
+ quote ──► book ──► get (poll until terminal) ──► [cancel if still active]
43
+ ```
44
+
45
+ ### 1. quote
46
+
47
+ Request fare quotes for a trip between two points.
48
+
49
+ ```bash
50
+ agenzo-merchant-cli ride quote --api-key sk_xxx \
51
+ --pickup-lat <num> --pickup-lng <num> --pickup-name <str> \
52
+ --dropoff-lat <num> --dropoff-lng <num> --dropoff-name <str> \
53
+ [--service-id <id>]
54
+ ```
55
+
56
+ Returns `{ vehicle_classes: VehicleClass[] }`. Each class carries
57
+ `vehicle_class`, `passenger_capacity`, `luggage_capacity`, and a `price` with
58
+ `amount`, `currency`, and a `quote_id`. **Carry `quote_id` and the chosen
59
+ `vehicle_class` into `book`.** Quotes expire — book promptly.
60
+
61
+ ### 2. book (write — idempotency key required)
62
+
63
+ ```bash
64
+ agenzo-merchant-cli --yes ride book --api-key sk_xxx \
65
+ --quote-id <id> --vehicle-class <class> --passenger-name <name> \
66
+ [--passenger-phone <phone>] [--passenger-email <email>] \
67
+ --idempotency-key <key>
68
+ ```
69
+
70
+ Returns an `Order` with `order_id` and an initial `status`. Reuse the **same**
71
+ `--idempotency-key` if you retry the same booking, so a network retry never
72
+ creates a duplicate order.
73
+
74
+ ### 3. get (poll)
75
+
76
+ ```bash
77
+ agenzo-merchant-cli ride get <order-id> --api-key sk_xxx
78
+ ```
79
+
80
+ Returns an `Order` with `status`. Poll periodically until a terminal status.
81
+
82
+ - Active (keep polling): `Pending`, `Accepted`, `On my way`, `Waiting`, `On board`
83
+ - Terminal (stop): `At destination`, `Rejected`, `Cancelled`,
84
+ `Customer no show`, `Driver no show`
85
+
86
+ Status strings are case-sensitive — match the server casing exactly.
87
+
88
+ ### 4. cancel (optional, write — idempotency key required)
89
+
90
+ ```bash
91
+ agenzo-merchant-cli --yes ride cancel <order-id> --api-key sk_xxx \
92
+ --idempotency-key <key>
93
+ ```
94
+
95
+ Only while the order is still active. Returns
96
+ `{ cancellation: { cancellation_fee, reversal_amount, currency } }` — a
97
+ cancellation may incur a fee.
98
+
99
+ ### Listing
100
+
101
+ ```bash
102
+ agenzo-merchant-cli ride list-orders --api-key sk_xxx \
103
+ [--status <status>] [--page <n>] [--page-size <n>]
104
+ ```
105
+
106
+ Returns `{ orders, total, page, page_size }` (default `page` 1, `page-size` 20).
107
+
108
+ ## Idempotency rule
109
+
110
+ All write operations (`ride book`, `ride cancel`) require a caller-supplied
111
+ `--idempotency-key`. The CLI never auto-generates one.
112
+
113
+ - Key format: 1–128 chars from `[A-Za-z0-9_-]`, sent as the `Idempotency-Key`
114
+ header (not in the body).
115
+ - With `--yes` and no key → hard error `PARAM_IDEMPOTENCY_KEY_REQUIRED`.
116
+ - Without `--yes` → the CLI prompts for the key.
117
+
118
+ ## Error codes & recovery
119
+
120
+ Errors are emitted with a SCREAMING_SNAKE_CASE `code`. Common ones:
121
+
122
+ | Code | Meaning | Recovery |
123
+ |------|---------|----------|
124
+ | `QUOTE_EXPIRED` | The `quote_id` is no longer valid | Re-run `ride quote` and book with the fresh `quote_id`. |
125
+ | `VEHICLE_UNAVAILABLE` | The chosen `vehicle_class` is unavailable | Re-quote and pick another `vehicle_class` from `vehicle_classes`. |
126
+ | `BOOKING_FAILED` | Booking could not be completed | Re-quote, then retry `book` with a fresh quote and the same idempotency key. |
127
+ | `CANCELLATION_NOT_ALLOWED` | Order can't be cancelled (terminal/too late) | Re-check status via `ride get`; no action if already terminal. |
128
+ | `SERVICE_NOT_FOUND` | Unknown `service_id` | Re-run `services list` and use a valid, enabled `service_id`. |
129
+ | `PARAM_IDEMPOTENCY_KEY_REQUIRED` | Missing/invalid idempotency key on a write op | Pass a valid `--idempotency-key` (1–128 chars, `[A-Za-z0-9_-]`). |
130
+
131
+ Other codes you may see: `NETWORK_ERROR` / `TIMEOUT` (retry, check host),
132
+ `CLI_OUTDATED` (upgrade the CLI), `CONFIG_ERROR` (fix/reset local config).
@@ -0,0 +1,2 @@
1
+
2
+ export { }