@delegance/cli 0.2.0 → 0.2.2

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 CHANGED
@@ -1,78 +1,165 @@
1
1
  # @delegance/cli
2
2
 
3
- Command-line interface for the Delegance Brokerage platform: upload policies, read your coverage, check carrier appetite, and generate certificates from a terminal.
3
+ Get commercial insurance quotes from your terminal. Quote, bind, and pay; read your policies; generate certificates; quote bonds; file claims. Works from AI coding agents too.
4
+
5
+ ```bash
6
+ npx -y @delegance/cli quote start --demo
7
+ ```
8
+
9
+ The demo runs on sample data. It sends nothing to Delegance or to any carrier.
4
10
 
5
11
  ## Install
6
12
 
7
13
  ```bash
8
- # Install globally
14
+ # Run without installing
15
+ npx -y @delegance/cli --help
16
+
17
+ # Or install globally
9
18
  npm install -g @delegance/cli
10
19
  delegance --version
11
-
12
- # Or run without installing
13
- npx @delegance/cli --help
14
20
  ```
15
21
 
22
+ Every `delegance` below is `npx -y @delegance/cli` if you did not install globally. The `-y` skips npx's "Ok to proceed?" prompt, which would hang a script or an agent.
23
+
16
24
  Requires Node 20.19 or newer. Older versions cannot load the CLI's ESM-only dependencies.
17
25
 
18
26
  ## Availability
19
27
 
20
- - **Quoting is live for enrolled companies.** Delegance turns on API quoting account by account today.
21
- - **Public access opens on 2026-10-06.** From that date any new account can run `delegance signup` and quote from the terminal.
22
- - **Until your account has access,** the quote, bind, and pay commands return "not available over the API yet" and print the portal link.
23
- - **A licensed Delegance broker reviews every bind.** A bind request never charges your card and never binds coverage by itself.
24
-
25
- Try the flow first with `delegance quote start --demo`. It runs on sample data and sends nothing to Delegance or to any carrier.
28
+ - Quoting is open to every account. Run `delegance signup` and quote the same day.
29
+ - Bind, pay, bonds, and claims are live from the terminal.
30
+ - A licensed Delegance broker approves every bind before coverage starts. A bind request never charges your card.
26
31
 
27
- ## Insurance from the terminal
32
+ ## Get a quote
28
33
 
29
34
  ```bash
30
- # See the whole flow on sample data first. Nothing leaves your machine.
31
- delegance quote start --demo
32
-
33
35
  # 1. Sign up. We email you a confirm link; the key lands in ~/.delegance/credentials.
34
36
  delegance signup
35
37
 
36
38
  # 2. Quote general liability and workers comp. Answer the carriers' questions.
37
39
  delegance quote start --coverage gl,wc
38
40
 
39
- # 3. Request a bind on the offer you want.
41
+ # 3. Request a bind on the offer you want. A broker approves it.
40
42
  delegance bind <submission-id> <offer-id>
41
43
 
42
- # 4. Pay once a broker has reviewed the bind.
44
+ # 4. Pay once the broker approves the bind.
43
45
  delegance pay
44
46
  ```
45
47
 
46
48
  What happens at each step:
47
49
 
48
50
  - **Signup** creates your company, emails a confirm link, and waits for the click. It then stores a new API key in `~/.delegance/credentials` (mode 600). If you stop it with Ctrl-C, `delegance verify` resumes.
49
- - **Quoting** asks the carriers' underwriting questions in the terminal and prices the coverage with the carriers that quote it instantly. A coverage no carrier can quote instantly goes to a broker instead of failing.
50
- - **Binding** is a request. A licensed Delegance broker reviews it, and you get an email when payment is ready.
51
+ - **Quoting** asks the carriers' underwriting questions in the terminal. Answers we already know from your account are filled in for you to confirm. Yes/no questions come as one checklist: space to select, Enter to continue.
52
+ - **No instant carrier?** The CLI asks the few application questions a broker needs and hands the request to a Delegance broker, who places it with a market that quotes by hand. Ctrl-C stops the questions and sends what you answered.
53
+ - **Binding** files a request. A Delegance broker approves it, and you get an email when payment is ready.
51
54
  - **Paying** opens a Stripe checkout link.
52
- - **Bonds** (`delegance bond quote`) price in the terminal; you buy the bond on the surety's own page.
53
- - **Claims** (`delegance claim file`) need you to accept the claims disclaimer once in the portal.
54
55
 
55
- Scripted use: `quote start --answers answers.json --json` takes answers keyed by question id (run it once with `--json` and no answers to print the questions).
56
+ Coverages for `--coverage`: `gl`, `wc`, `bop`, `cyber`, `pl` (E&O), `auto`, `property`, `umbrella`.
56
57
 
57
- Already a customer? Skip signup and run `delegance auth login`: it opens the portal, you approve the terminal there, and the key lands in `~/.delegance/credentials`. You can also paste a key with `delegance auth login --key <key>`, or set `DELEGANCE_API_KEY`.
58
+ ### What a quote looks like
58
59
 
59
- ## Coverage you already have
60
+ ```
61
+ Coverage starts Nov 1, 2026
62
+ Best price per coverage:
63
+ General Liability Carrier A $612/yr
64
+ Workers' Comp Carrier C $1,184/yr
65
+
66
+ Carrier Coverage Premium/yr Limits Deductible Status Offer
67
+ ───────── ───────────────── ────────── ─────────────────────────────────── ────────── ──────── ──────
68
+ Carrier A General Liability $612 $1M per occurrence / $2M aggregate $500 Quoted demo-1
69
+ Carrier B General Liability $748 $1M per occurrence / $2M aggregate $1,000 Quoted demo-2
70
+ Carrier C Workers' Comp $1,184 Statutory / $1M employers liability None Quoted demo-3
71
+ Carrier D Workers' Comp - - - Declined demo-4
72
+
73
+ 3 of 4 carriers priced.
74
+ ```
75
+
76
+ That table is the `--demo` sample. A real quote names the carriers. The best price is per coverage: a GL premium is never compared with a WC one. A real quote prints one bind command per coverage. `-` means the carrier did not send that field.
77
+
78
+ ## Sign in on an existing account
60
79
 
61
80
  ```bash
62
- # 1. Authenticate. Approve this terminal in the portal when the browser opens.
63
81
  delegance auth login
82
+ ```
64
83
 
65
- # 2. Check your account setup
66
- delegance onboarding status
84
+ It opens the portal, you approve the terminal there, and the key lands in `~/.delegance/credentials`. Other ways in:
67
85
 
68
- # 3. Upload policies and wait for extraction
69
- delegance doc upload "./policies/*.pdf" --type policy --wait
86
+ - `delegance auth login --no-browser` prints the approval link instead of opening a browser.
87
+ - `delegance auth login --key <key>` stores a key you created in the portal.
88
+ - `DELEGANCE_API_KEY=<key>` overrides the stored key for one shell.
89
+
90
+ Keys from `signup` and `auth login` expire after 90 days without use. `delegance auth status` shows the date; `delegance auth refresh` extends it.
91
+
92
+ ## Use it from an AI agent
93
+
94
+ Claude Code, Codex, Gemini CLI, or any coding agent can run the CLI. Open the agent in a folder with your insurance documents and ask it to get you a quote with `npx -y @delegance/cli`.
95
+
96
+ How the CLI behaves without a terminal:
97
+
98
+ - It never waits on a prompt. With no TTY and no `--answers` file, `quote start` exits 1 with "No terminal to ask the questions in."
99
+ - `--json` without `--answers` prints the session and its questions as JSON, then stops: `{ "submissionId", "sessionVersion", "questions": [...] }`.
100
+ - `signup` without a TTY needs every field as a flag: `--email --business --first --last --industry --size --street --city --state --zip`.
101
+ - `auth login` prints the approval link; a person approves it in the browser.
102
+ - Exit code `0` means success; `1` means an error. Errors print the server trace id.
103
+ - In `--json` mode stdout stays parseable. Progress and hints go to stderr.
104
+
105
+ The scripted quote flow:
106
+
107
+ ```bash
108
+ # 1. Start the session and save the questions
109
+ npx -y @delegance/cli quote start --coverage gl --json > session.json
110
+
111
+ # 2. Write answers.json (keys are question ids), then file it
112
+ npx -y @delegance/cli quote submit "$(jq -r .submissionId session.json)" \
113
+ --session-version "$(jq -r .sessionVersion session.json)" \
114
+ --answers answers.json --idempotency-key "gl-$(date +%Y%m%d)" --json
115
+
116
+ # 3. Read premiums later
117
+ npx -y @delegance/cli quote status <submission-id> --wait --json
118
+ ```
119
+
120
+ Or do it in one call when you already know the question ids: `quote start --coverage gl --answers answers.json --json`.
121
+
122
+ `answers.json` format:
123
+
124
+ ```json
125
+ {
126
+ "annual_revenue": 850000,
127
+ "employees": 6,
128
+ "delivery": "no",
129
+ "claims_5y": "0"
130
+ }
131
+ ```
132
+
133
+ - Keys are question `id`s from the session.
134
+ - `yes_no` takes `"yes"` or `"no"`. `number`, `currency`, `percentage` take a number. `select` takes one option `value`. Other types take text.
135
+ - A question you leave out uses its `prefill` (data from your own account). A `suggested` value is a guess and counts only if you send it.
136
+ - `showIf` hides a follow-up until its parent answer matches. A hidden question is never required; `requiredIfShown` makes it required while visible.
137
+ - `quote start --answers` checks every answer first and lists every problem at once, with the valid question ids.
138
+ - Reuse the same `--idempotency-key` on a retry of `quote submit`, so a lost response never files twice.
139
+ - A `quote submit` for coverage that already has a request with carriers exits 1 with `active_request_exists`. To close that request and re-quote, re-run the same submit with `--replace` and a new idempotency key (or none). Running `quote start --replace` alone does not re-quote in this flow: it only starts a fresh session.
140
+
141
+ When the submit result is `no_carriers`, hand it to a broker:
142
+
143
+ ```bash
144
+ npx -y @delegance/cli quote handoff <submission-id> --answers acord-answers.json --json
145
+ ```
146
+
147
+ Without `--answers` (and no TTY) the request goes to the broker as is, and the broker emails for what is missing.
148
+
149
+ If something fails, report it with the context attached (command name, exit code, trace id, versions; never the arguments):
70
150
 
71
- # 4. Read what you have
151
+ ```bash
152
+ npx -y @delegance/cli feedback "quote submit hung on the delivery question" --include-last
153
+ ```
154
+
155
+ ## Coverage you already have
156
+
157
+ ```bash
158
+ delegance onboarding status
159
+ delegance doc upload "./policies/*.pdf" --type policy --wait
72
160
  delegance policy list
73
161
  delegance policy expiring 60
74
-
75
- # 5. Ask a question about your coverage
162
+ delegance coi generate --interactive
76
163
  delegance ask "Does my GL policy cover products liability?"
77
164
  ```
78
165
 
@@ -80,45 +167,78 @@ delegance ask "Does my GL policy cover products liability?"
80
167
 
81
168
  | Command | What it does |
82
169
  |---------|--------------|
83
- | `auth` | Log in with an API key, check status, log out |
84
- | `company` | List, create, and pick the default company |
85
- | `doc` | Upload documents, check extraction, reprocess, archive |
86
- | `ask` / `chat` | Ask the Orin assistant about your coverage |
87
- | `policy` | List policies, show one policy, list what expires soon |
88
- | `coi` | Generate and list certificates of insurance |
89
- | `sov` | Upload and track schedules of values |
90
170
  | `signup` / `verify` | Create an account and collect an API key from the terminal |
91
- | `quote` | Instant quotes: `quote start`, `quote status`; plus the legacy partner queue commands |
92
- | `bind` | Request a bind on one offer (broker-reviewed) |
171
+ | `auth` | Log in (browser approval or key), status, whoami, refresh, log out |
172
+ | `quote` | Instant quotes: `quote start`, `quote submit`, `quote status`, `quote handoff` |
173
+ | `bind` | Request a bind on one offer; a broker approves it |
93
174
  | `pay` | List payment requests and open a Stripe checkout link |
94
- | `bond` | Surety bond quotes |
175
+ | `billing` | What you owe and what you paid |
176
+ | `bond` | Surety bond quotes; you buy on the surety's own page |
95
177
  | `claim` | File and track claims |
178
+ | `policy` | List policies, show one policy, list what expires soon |
179
+ | `coi` | Generate and list certificates of insurance |
180
+ | `doc` | Upload documents, check extraction, reprocess, archive |
181
+ | `sov` | Upload and track schedules of values |
182
+ | `ask` / `chat` | Ask the Orin assistant about your coverage |
183
+ | `knowledge` | Search notecards and read the facts extracted from a document |
96
184
  | `appetite` | Match a business to the carriers that will write it |
97
185
  | `lead` | Send a prospect business to Delegance |
98
- | `knowledge` | Search notecards and read the facts extracted from a document |
99
186
  | `onboarding` | Show setup status, send the verification email, wait for a state |
187
+ | `company` | Show your company and set the default |
188
+ | `feedback` / `bug` | Report a bug, an idea, or a question |
100
189
  | `usage` | Billing-period usage, daily usage, rate limits |
101
190
  | `keys` | List and create API keys, rotate by replacement |
102
191
  | `config` | Local settings and profiles |
103
192
 
104
193
  Every command and flag, generated from the CLI itself: [portal.delegancebrokerage.com/docs/cli/commands](https://portal.delegancebrokerage.com/docs/cli/commands). Run `delegance <command> --help` for the same list offline.
105
194
 
106
- ### Scopes
195
+ `quote request`, `quote list`, `quote get`, `quote wait`, and `quote cancel` belong to the legacy partner queue. Submission there is not live; use `quote start`.
107
196
 
108
- An API key carries scopes. `read` covers the read commands and `write` covers commands that change data. `appetite match` needs `appetite:read`, which neither `read` nor `write` includes:
197
+ ### Bonds and claims
109
198
 
110
199
  ```bash
111
- delegance keys create "appetite checks" --scopes read,appetite:read
200
+ delegance bond quote --state TX --bond "notary"
201
+ delegance bond answer <session-id> --answers bond-answers.json
202
+ delegance bond status <session-id>
203
+
204
+ delegance claim file --description-file what-happened.txt --date 2026-10-01
205
+ delegance claim list
112
206
  ```
113
207
 
114
- ### What still needs the portal
208
+ Filing a claim needs a key with the `claims:write` scope. Keys from `signup` and `auth login` carry it for owners and admins. The first time, accept the claims disclaimer in the portal; nobody can accept it for you.
209
+
210
+ ### Carrier checkout (fast bind)
211
+
212
+ `delegance bind` also takes `--attest`, `--step-up <id>`, and `--code <code>` for fast bind: you confirm the application answers, and we email a 6-digit code. Fast bind into the carrier's own checkout is not open yet. Until it is, every bind goes to a broker for approval.
213
+
214
+ ## API keys
215
+
216
+ - A key belongs to one company. Every command acts on that company. Naming another company's id fails with 403 `company_mismatch`.
217
+ - A new key expires in 90 days unless you pick another expiry with `--expires-in-days`.
218
+ - A key with `write`, `admin`, or `claims:write` must expire within 365 days. `--expires-in-days never` works only for a read-only key.
219
+ - `claims:write` can be created only while signed in to the portal.
220
+ - Delegance staff accounts cannot create client keys.
221
+ - `appetite match` needs `appetite:read`, which neither `read` nor `write` includes.
222
+ - `delegance keys revoke` needs a signed-in portal session. `delegance keys rotate` creates the replacement key and tells you where to revoke the old one.
223
+
224
+ ```bash
225
+ delegance keys create "appetite checks" --scopes read,appetite:read --expires-in-days 90
226
+ ```
115
227
 
116
- - **Quote submission.** `delegance quote request` reports that submission is not available over the API and prints the portal link.
117
- - **Revoking a key.** `delegance keys revoke` needs a signed-in portal session. `delegance keys rotate` creates the replacement key and tells you where to revoke the old one.
228
+ ## Limits
229
+
230
+ | Limit | What you see |
231
+ |-------|--------------|
232
+ | Quote starts per key per day | 429 `quote_limit_reached` |
233
+ | Per-key daily AI budget | 429 `api_key_budget_exhausted` |
234
+ | Delegance-wide daily API AI budget | 429 `api_budget_exhausted` (try again in an hour) |
235
+ | Requests per minute | 429; `delegance usage limits` shows where you stand |
236
+
237
+ The CLI does not retry a 429. Wait and run the command again.
118
238
 
119
239
  ## Configuration
120
240
 
121
- The API key lives only in `~/.delegance/credentials` (mode 600). Other settings live in `~/.config/delegance-nodejs/config.json` (mode 600), which holds a masked hint of the key and never the key itself. Keys from `signup` and `auth login` expire after 90 days without use; `delegance auth status` shows the date and `delegance auth refresh` extends it.
241
+ The API key lives only in `~/.delegance/credentials` (mode 600). Other settings live in `~/.config/delegance-nodejs/config.json` (mode 600), which holds a masked hint of the key and never the key itself.
122
242
 
123
243
  | Variable | Description |
124
244
  |----------|-------------|
@@ -127,10 +247,6 @@ The API key lives only in `~/.delegance/credentials` (mode 600). Other settings
127
247
  | `DEBUG` | Debug output |
128
248
  | `VERBOSE` | Verbose output |
129
249
 
130
- ## Output and exit codes
131
-
132
- Most commands take `--json` for machine-readable output. Exit code `0` means success and `1` means an error. Errors print the server trace id, which support can look up.
133
-
134
250
  ## Examples
135
251
 
136
252
  ### Bulk upload
@@ -151,16 +267,6 @@ delegance appetite match --state CA --industry "commercial bakery" \
151
267
  --coverage general_liability,workers_comp
152
268
  ```
153
269
 
154
- ### Scripting
155
-
156
- ```bash
157
- #!/bin/bash
158
- for file in "$@"; do
159
- result=$(delegance doc upload "$file" --wait --json)
160
- echo "$(echo "$result" | jq -r '.[0].docId'): $(echo "$result" | jq -r '.[0].status')"
161
- done
162
- ```
163
-
164
270
  ## Developing in the monorepo
165
271
 
166
272
  Inside the monorepo the CLI resolves the SDK from the sibling source (`"@delegance/sdk": "file:../sdk"`). Build the SDK first: