reply-cli 0.5.0 → 0.11.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 (62) hide show
  1. package/README.md +149 -16
  2. package/dist/commands/api.d.ts +2 -1
  3. package/dist/commands/api.js +42 -42
  4. package/dist/commands/api.js.map +1 -1
  5. package/dist/index.js +22 -7
  6. package/dist/index.js.map +1 -1
  7. package/dist/operations/call.d.ts +35 -0
  8. package/dist/operations/call.js +131 -0
  9. package/dist/operations/call.js.map +1 -0
  10. package/dist/operations/commands.d.ts +6 -0
  11. package/dist/operations/commands.js +153 -0
  12. package/dist/operations/commands.js.map +1 -0
  13. package/dist/operations/contact-input.d.ts +29 -0
  14. package/dist/operations/contact-input.js +84 -0
  15. package/dist/operations/contact-input.js.map +1 -0
  16. package/dist/operations/contact-list.d.ts +9 -0
  17. package/dist/operations/contact-list.js +50 -0
  18. package/dist/operations/contact-list.js.map +1 -0
  19. package/dist/operations/contact.d.ts +7 -0
  20. package/dist/operations/contact.js +49 -0
  21. package/dist/operations/contact.js.map +1 -0
  22. package/dist/operations/contacts.d.ts +11 -0
  23. package/dist/operations/contacts.js +115 -0
  24. package/dist/operations/contacts.js.map +1 -0
  25. package/dist/operations/inbox.d.ts +22 -0
  26. package/dist/operations/inbox.js +76 -0
  27. package/dist/operations/inbox.js.map +1 -0
  28. package/dist/operations/options.d.ts +18 -0
  29. package/dist/operations/options.js +63 -0
  30. package/dist/operations/options.js.map +1 -0
  31. package/dist/operations/result.d.ts +5 -0
  32. package/dist/operations/result.js +20 -0
  33. package/dist/operations/result.js.map +1 -0
  34. package/dist/operations/sequence-membership.d.ts +13 -0
  35. package/dist/operations/sequence-membership.js +227 -0
  36. package/dist/operations/sequence-membership.js.map +1 -0
  37. package/dist/operations/sequence-read.d.ts +26 -0
  38. package/dist/operations/sequence-read.js +121 -0
  39. package/dist/operations/sequence-read.js.map +1 -0
  40. package/dist/operations/sequence-state.d.ts +7 -0
  41. package/dist/operations/sequence-state.js +88 -0
  42. package/dist/operations/sequence-state.js.map +1 -0
  43. package/dist/skills/adapter-flat.d.ts +3 -1
  44. package/dist/skills/adapter-flat.js +49 -19
  45. package/dist/skills/adapter-flat.js.map +1 -1
  46. package/dist/skills/hosts.js +35 -13
  47. package/dist/skills/hosts.js.map +1 -1
  48. package/dist/skills/orchestrate.js +41 -4
  49. package/dist/skills/orchestrate.js.map +1 -1
  50. package/dist/skills/report.js +36 -10
  51. package/dist/skills/report.js.map +1 -1
  52. package/dist/skills/types.d.ts +11 -1
  53. package/dist/utils/client.d.ts +5 -2
  54. package/dist/utils/client.js +113 -78
  55. package/dist/utils/client.js.map +1 -1
  56. package/dist/utils/errors.d.ts +30 -2
  57. package/dist/utils/errors.js +51 -2
  58. package/dist/utils/errors.js.map +1 -1
  59. package/dist/utils/json-arg.d.ts +10 -0
  60. package/dist/utils/json-arg.js +45 -0
  61. package/dist/utils/json-arg.js.map +1 -0
  62. package/package.json +1 -1
package/README.md CHANGED
@@ -55,6 +55,22 @@ after a second and a half, and stays silent when it fails. It never runs for any
55
55
  other command, and never at all with `--json`, when output is piped, in CI, or
56
56
  with `REPLY_NO_UPDATE_CHECK=1` set.
57
57
 
58
+ ## Where this fits
59
+
60
+ Reply's agentic toolkit is three pieces. They are complementary, not alternatives:
61
+
62
+ | | What it is | When you want it |
63
+ |---|---|---|
64
+ | **reply CLI** (this repo) | `npm i -g reply-cli` — authenticated access to *every* v3 endpoint via `reply api` | Your agent has a shell. This is the complete surface. |
65
+ | **[Reply MCP](https://github.com/reply-team/reply-mcp)** | A curated tool catalog over `mcp.reply.io` | Your client speaks MCP and has no shell — desktop apps, hosted assistants. |
66
+ | **[reply-skills](https://github.com/reply-team/reply-skills)** | Outbound expertise as markdown skills: what to do, in what order, with what guardrails | Your agent knows *how* to call things but not *what* to run. |
67
+
68
+ MCP gives your agent tools. Skills give it judgement. Most setups want both; a shell-capable
69
+ agent can do everything through the CLI alone.
70
+
71
+ The shortest path that works: install the CLI, `reply auth login`, `reply skills install`, then
72
+ talk to your agent in plain words. MCP is optional — add it when your client has no shell.
73
+
58
74
  ## Usage
59
75
 
60
76
  ```sh
@@ -67,6 +83,16 @@ machine-readable output suitable for scripts.
67
83
 
68
84
  ## Authentication
69
85
 
86
+ **You need a Reply.io account.** If you have one, sign in with it. If you don't, `reply auth
87
+ login` takes you to the browser, where you can create one and start a free trial — no credit
88
+ card. The CLI, the skill packs and the local tooling are free and open source; what a Reply.io
89
+ account gives you is the execution: mailboxes, sending, the contact store, the inbox, analytics.
90
+
91
+ > **Open source, not self-hosted.** The CLI and the skill packs are MIT and yours to fork.
92
+ > Execution always runs against Reply.io — the API, the hosted MCP server at `mcp.reply.io`,
93
+ > your mailboxes and your data. There is no local mode, and outreach without a Reply.io account
94
+ > is not something this toolkit can do.
95
+
70
96
  Log in through your browser with OAuth:
71
97
 
72
98
  ```sh
@@ -102,6 +128,7 @@ reply profile use alice@reply.io # make it the active profile
102
128
  reply auth login # signs in alice@reply.io
103
129
 
104
130
  reply profile list # '*' marks the active profile
131
+ reply profile current # just the active profile's name
105
132
  reply --profile bob@reply.io auth whoami # override for a single command
106
133
  ```
107
134
 
@@ -111,11 +138,21 @@ set with `profile use` → the built-in default.
111
138
  Manage profiles after creating them:
112
139
 
113
140
  ```sh
114
- reply profile show # inspect the current profile (no secrets)
115
- reply profile show alice@reply.io # inspect a specific one
116
- reply profile rename alice@reply.io ally # also moves the stored credential
117
- reply profile unset ally team-id # clear a field (authority|api_base|team-id)
118
- reply profile delete ally # remove it and its stored credential
141
+ reply profile show # inspect the current profile (no secrets)
142
+ reply profile show alice@reply.io # inspect a specific one
143
+ reply profile set alice@reply.io --team-id 1045 # edit in place; only what you pass changes
144
+ reply profile rename alice@reply.io ally # also moves the stored credential
145
+ reply profile unset ally team-id # clear a field (authority|api_base|team-id)
146
+ reply profile delete ally # remove it and its stored credential (-y skips the prompt)
147
+ ```
148
+
149
+ `profile set` takes `--team-id`, and `--authority` / `--api-base` for pointing a
150
+ profile at a non-production backend. Naming `default` edits the built-in
151
+ profile, which is how you pin a team for everything without creating a profile
152
+ first:
153
+
154
+ ```sh
155
+ reply profile set default --team-id 1045
119
156
  ```
120
157
 
121
158
  `profile show` lists the backend URLs, pinned team, and which authorization
@@ -139,6 +176,53 @@ reply team clear # remove the pin
139
176
  If a call needs a team and you're in more than one, the API answers with a
140
177
  `TEAM_REQUIRED` error listing your teams — run `reply team use <id>` to pin one.
141
178
 
179
+ ## Working with your Reply account
180
+
181
+ First-class commands for the operations an agent or an automation performs most. Every command
182
+ prints JSON (indented; compact with `--json`) and says what happened in a stable `status`.
183
+
184
+ | Command | Does |
185
+ |---|---|
186
+ | `reply sequence get <id>` | the sequence as Reply holds it |
187
+ | `reply sequence contacts <id> [--limit] [--offset]` | one page of its contacts, plus the total |
188
+ | `reply sequence stats <id> (--preset … \| --from … --to …)` | its email and LinkedIn counts over a window |
189
+ | `reply sequence add-contact <id> <contact> [--start-step N] [--ignore-step-delay]` | put a contact in → `added` / `already_in_sequence` |
190
+ | `reply sequence remove-contact <id> <contact>` | take a contact out → `removed` / `not_in_sequence` |
191
+ | `reply sequence pause <id>` | → `paused` |
192
+ | `reply sequence start <id> [--expect-contacts N]` | → `started` / `already_active` |
193
+ | `reply contact-list add-contact <list-id> <contact> [--refuse-opted-out]` | → `added` |
194
+ | `reply contact opt-out <contact>` | → `opted_out` |
195
+ | `reply inbox list (--contact-id \| --sequence-id) [--source] [--since]` | one page of threads |
196
+ | `reply inbox get <thread-id>` | a thread with its subject, and one page of its messages |
197
+
198
+ `<contact>` is exactly one of `--contact <json>|@file|-`, `--email <address>` (with `--first-name`,
199
+ `--last-name`, `--company`, `--title`), or `--contact-id <id>`. The JSON takes the same fields
200
+ (`email`, `first_name`, …), and `-` reads it from stdin, which keeps personal data out of the
201
+ argument list:
202
+
203
+ ```sh
204
+ echo '{"email":"ann@example.com","first_name":"Ann"}' | reply sequence add-contact 123 --contact -
205
+ ```
206
+
207
+ The two `add-contact` commands always import a contact given by email, and Reply refuses an import
208
+ without a first name, even for a contact it already holds. `contact opt-out` imports only someone
209
+ Reply doesn't hold yet; `sequence remove-contact` never imports.
210
+
211
+ **Errors.** With `--json`, a failure is one line on stderr:
212
+ `{"error":{"code":"contact.opted_out","title":…,"status":…,"reply_code":…,"ids":{…}}}`. `ids` is
213
+ whatever the command learned before failing, for example the id of a contact it created before
214
+ Reply refused the add. `reply.invalid_request` means Reply didn't accept a field as given;
215
+ `details.fields` names the fields, never their values. Each command's `--help` lists its error codes.
216
+
217
+ **Exit codes.** `0` done · `1` failed, and the main effect did not happen · `2` usage error, nothing
218
+ sent · `3` **outcome unknown**: a write may have happened and no answer came back. Re-running the
219
+ same command is safe: each one checks or relies on Reply's own state rather than repeating an effect
220
+ blindly.
221
+
222
+ **Retries.** Reads are retried on errors. A write is retried only when it can't have reached Reply:
223
+ the connection was never made, or a `429` asked to wait 3 seconds or less. A longer `429` comes back
224
+ as `rate_limited` with `retry_after`.
225
+
142
226
  ## Raw API access
143
227
 
144
228
  `reply api` is a raw, authenticated passthrough to any v3 endpoint — the
@@ -166,6 +250,28 @@ It prints `{ "code": <status>, "data": <body> }` and exits non-zero on HTTP
166
250
  stderr. Add `--verbose` for a full request/response trace on stderr with
167
251
  credentials redacted; stdout stays the plain JSON, so pipes keep working.
168
252
 
253
+ A write through `reply api` (POST, PUT, PATCH, DELETE) is never resent on a 5xx or on a
254
+ connection that broke after sending. That last case exits 3: the write may have happened. `reply api`
255
+ goes by the method alone, so this includes a POST that only reads, such as the `…/filter` calls; run
256
+ it again yourself if it failed. A `429` is waited out only when `Retry-After` asks for 3 seconds or
257
+ less; a longer one is printed as the `429` it is.
258
+
259
+ ### Windows: Git Bash rewrites the path
260
+
261
+ Under Git Bash / MSYS, `reply api /v3/whoami` never reaches the CLI as you typed
262
+ it — MSYS converts a leading-slash argument into a Windows path, so the request
263
+ would go to `https://api.reply.io/C:/Program Files/Git/v3/whoami`. **Quoting does
264
+ not help**: quotes are removed before the conversion. Either of these does:
265
+
266
+ ```sh
267
+ reply api //v3/whoami # a doubled leading slash survives
268
+ MSYS_NO_PATHCONV=1 reply api /v3/whoami # or turn the conversion off
269
+ ```
270
+
271
+ The CLI refuses such a path instead of sending it, and exits `2` (usage) rather
272
+ than `1`, so a mangled path can never be mistaken for an endpoint that does not
273
+ exist. PowerShell, cmd, macOS and Linux are unaffected.
274
+
169
275
  ## Skills
170
276
 
171
277
  Reply's outbound expertise ships as three markdown skill packs in
@@ -213,17 +319,44 @@ plugin mechanism, so they keep updating through it. Other `SKILL.md` hosts
213
319
  receive the skills as files. Add `--json` for a machine-readable report, and
214
320
  `--dry-run` to see the plan without changing anything.
215
321
 
216
- | Assistant | How it receives the packs | Paths verified |
217
- |---|---|---|
218
- | Claude Code | its own plugin CLI | yes |
219
- | Codex | its own plugin CLI (`--project` copies files instead) | yes |
220
- | Cursor · Gemini CLI · GitHub Copilot · Windsurf | copied files | not yet |
221
-
222
- "Not yet" means the skills directory for that assistant comes from its
223
- documentation and has not been confirmed by a verification run of our own: the
224
- install works, but we cannot promise the assistant reads from where we put the
225
- files. Those hosts are marked `(paths not yet verified)`
226
- in the report and carry `"verified": false` in `--json`.
322
+ | Assistant | How it receives the packs | Skills path | Paths verified | To take effect |
323
+ |---|---|---|---|---|
324
+ | Claude Code | its own plugin CLI | managed by the plugin CLI | yes | start a new session |
325
+ | Codex | its own plugin CLI (`--project` copies files instead) | managed by the plugin CLI | yes | start a new session |
326
+ | Cursor | copied files | `~/.cursor/skills`, or `.agents/skills` with `--project` | Cursor 3.14.27, cursor-agent 2026.08.04-aaa8809 | a new session (a new chat) |
327
+ | Windsurf (ships as Devin) | copied files | `~/.codeium/windsurf/skills`, or `.windsurf/skills` with `--project` | Devin 3.6.27, devin CLI 3000.3.27 | a new session (the next `devin` run) |
328
+ | Antigravity | copied files | `~/.gemini/config/skills`, or `.agents/skills` with `--project` | Antigravity 2.0.1 | nothing — it re-reads its skills every turn, including in a conversation already open |
329
+ | GitHub Copilot | copied files | `~/.copilot/skills`, or `.agents/skills` with `--project` | Copilot CLI 1.0.80 | a new session, or `/skills reload` in the open one |
330
+
331
+ The project directories overlap in a way the rows above do not show: Windsurf
332
+ also reads `.agents/skills`, which is where `--project` puts things for Cursor,
333
+ Codex, Antigravity and GitHub Copilot. A project-scope install aimed at one of
334
+ them therefore makes those skills visible in the others, and removing them for
335
+ one changes what the others see. Use user scope when you want a host's skills to
336
+ itself. GitHub Copilot reads two further repository directories, `.claude/skills`
337
+ and `.github/skills`. This command never writes to either — Claude Code installs
338
+ through its own plugin CLI in both scopes — so that crossover appears only when
339
+ something else fills them: a skill copied there by hand, or the `npx skills`
340
+ channel, which writes `.claude/skills` for a project-scoped Claude Code install.
341
+
342
+ Every assistant in the table has been verified against the version named. A host
343
+ added later may arrive with its skills directory taken from the vendor's
344
+ documentation alone; until someone confirms it by installing and using a skill,
345
+ the report marks that host `(paths not yet verified)` and `--json` carries
346
+ `"verified": false`. Cursor and Windsurf were verified with reply-cli 0.5.1,
347
+ Antigravity and GitHub Copilot with the release that adds them.
348
+
349
+ GitHub Copilot is two products over one directory: the `copilot` CLI and the
350
+ VS Code agent host, which ships `~/.copilot/skills` among the defaults of its
351
+ `chat.agentSkillsLocations` setting — alongside `~/.claude/skills` and
352
+ `~/.agents/skills`, user directories the CLI itself does not read. The CLI is
353
+ what the row above was verified against. VS Code scans those directories once per window and does not watch them,
354
+ so an install made while it is open needs `Developer: Reload Window` rather than
355
+ just a new chat.
356
+
357
+ Antigravity is the one host that needs nothing to pick up new skills — it
358
+ re-reads them every turn, so an install lands in a conversation you already have
359
+ open.
227
360
 
228
361
  Installing skills is not the same as connecting Reply: `reply-adapter` needs a
229
362
  Reply.io login (`reply auth login`) to actually do anything.
@@ -11,9 +11,10 @@ type Global_opts = {
11
11
  verbose?: boolean;
12
12
  };
13
13
  declare const read_body_arg: (raw: string | undefined, read_stdin?: () => string) => unknown;
14
+ declare const assert_api_path: (path: string) => void;
14
15
  declare const handle_api: (path: string, opts: {
15
16
  method?: string;
16
17
  body?: string;
17
18
  }, ctx: Cli_context, g: Global_opts) => Promise<void>;
18
19
  declare const api_command: Command;
19
- export { api_command, handle_api, read_body_arg };
20
+ export { api_command, handle_api, read_body_arg, assert_api_path };
@@ -1,16 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.read_body_arg = exports.handle_api = exports.api_command = void 0;
7
- const fs_1 = __importDefault(require("fs"));
3
+ exports.assert_api_path = exports.read_body_arg = exports.handle_api = exports.api_command = void 0;
8
4
  const commander_1 = require("commander");
9
5
  const context_1 = require("../context");
10
6
  const client_1 = require("../utils/client");
11
7
  const teams_1 = require("../teams");
12
8
  const authed_1 = require("./authed");
13
9
  const errors_1 = require("../utils/errors");
10
+ const json_arg_1 = require("../utils/json-arg");
14
11
  const output_1 = require("../utils/output");
15
12
  const read_globals = (cmd) => {
16
13
  const o = cmd.optsWithGlobals();
@@ -39,44 +36,9 @@ const print_trace = (r) => {
39
36
  };
40
37
  const print_opts = (g) => ({ json: g.json, pretty: g.pretty });
41
38
  const ALLOWED_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];
42
- const read_all_stdin = () => {
43
- try {
44
- return fs_1.default.readFileSync(0, 'utf8');
45
- }
46
- catch {
47
- return '';
48
- }
49
- };
50
39
  // Parse the --body argument: inline JSON, @<file>, or '-' for stdin. Injectable
51
40
  // stdin reader keeps it unit-testable.
52
- const read_body_arg = (raw, read_stdin = read_all_stdin) => {
53
- if (raw === undefined) {
54
- return undefined;
55
- }
56
- let text;
57
- if (raw === '-') {
58
- text = read_stdin();
59
- }
60
- else if (raw.startsWith('@')) {
61
- try {
62
- text = fs_1.default.readFileSync(raw.slice(1), 'utf8');
63
- }
64
- catch (e) {
65
- throw new errors_1.UsageError(`Could not read body file '${raw.slice(1)}'.`, {
66
- code: 'usage.api', hint: e.message,
67
- });
68
- }
69
- }
70
- else {
71
- text = raw;
72
- }
73
- try {
74
- return JSON.parse(text);
75
- }
76
- catch {
77
- throw new errors_1.UsageError('--body must be valid JSON (inline, @file, or - for stdin).', { code: 'usage.api' });
78
- }
79
- };
41
+ const read_body_arg = (raw, read_stdin = json_arg_1.read_all_stdin) => raw === undefined ? undefined : (0, json_arg_1.read_json_arg)(raw, { flag: '--body', what: 'body', code: 'usage.api', read_stdin });
80
42
  exports.read_body_arg = read_body_arg;
81
43
  const resolve_method = (flag, has_body) => {
82
44
  if (flag === undefined) {
@@ -90,10 +52,45 @@ const resolve_method = (flag, has_body) => {
90
52
  }
91
53
  return m;
92
54
  };
55
+ // A drive-prefixed path is the signature of MSYS/Cygwin path conversion, not of
56
+ // anything a caller would type: Git Bash on Windows rewrites a leading-slash
57
+ // argument into a Windows path before the CLI is even started.
58
+ const MSYS_DRIVE = /^[A-Za-z]:[\\/]/;
59
+ // Recover the intended path out of a mangled one, so the fix can be quoted back
60
+ // verbatim instead of described. `C:/Program Files/Git/v3/whoami` -> `v3/whoami`.
61
+ // Both separators, because MSYS emits forward slashes but a path pasted from cmd
62
+ // arrives with backslashes.
63
+ const VERSION_SEGMENT = /[\\/](v\d+[\\/].*)$/;
64
+ // The request URL is built literally as api_base + path, so a path that is not a
65
+ // path silently produces a nonsense URL and a 404 — indistinguishable from an
66
+ // endpoint that genuinely does not exist. That is not hypothetical: an agent hit
67
+ // exactly this under Git Bash and told its user a documented feature was "not
68
+ // enabled on this account". Refuse instead, before spending a request, and exit 2
69
+ // (usage) so the failure cannot be mistaken for an upstream one.
70
+ const assert_api_path = (path) => {
71
+ if (path.startsWith('/')) {
72
+ return;
73
+ }
74
+ const recovered = path.match(VERSION_SEGMENT)?.[1].replace(/\\/g, '/');
75
+ const intended = recovered ? `/${recovered}` : '/v3/whoami';
76
+ const hint = MSYS_DRIVE.test(path)
77
+ ? [
78
+ 'Your shell rewrote the argument before the CLI saw it: Git Bash / MSYS on',
79
+ 'Windows turns a leading-slash argument into a Windows path. Quoting does not',
80
+ 'help — quotes are removed before the conversion. Any of these does:',
81
+ ` reply api /${intended}`,
82
+ ` MSYS_NO_PATHCONV=1 reply api ${intended}`,
83
+ ' ...or run the same command from PowerShell or cmd.',
84
+ ].join('\n')
85
+ : `Paths are taken verbatim from the docs and start with a slash, e.g. ${intended}.`;
86
+ throw new errors_1.UsageError(`The path must start with '/' — got '${path}'.`, { code: 'usage.api', hint });
87
+ };
88
+ exports.assert_api_path = assert_api_path;
93
89
  // Raw passthrough to a v3 endpoint. Prints {code, data} for any status; exits 1
94
90
  // on >=400. On a team/user-resolution conflict, adds tailored guidance to stderr
95
91
  // — this is the workload surface where such guidance belongs.
96
92
  const handle_api = async (path, opts, ctx, g) => {
93
+ assert_api_path(path);
97
94
  const body = read_body_arg(opts.body);
98
95
  const method = resolve_method(opts.method, body !== undefined);
99
96
  const { token, headers } = await (0, authed_1.authed)(ctx, g);
@@ -127,7 +124,10 @@ const api_command = new commander_1.Command('api')
127
124
  + ' reply api /v3/contacts --pretty # list contacts (indented)\n'
128
125
  + ' reply api /v3/sequences/12345 # one sequence by id\n'
129
126
  + ' reply api /v3/contacts --body @contact.json # create a contact (POST; body per docs)\n'
130
- + ' echo \'<json>\' | reply api /v3/contacts --body - # body from stdin')
127
+ + ' echo \'<json>\' | reply api /v3/contacts --body - # body from stdin\n'
128
+ + '\nGit Bash / MSYS on Windows rewrites a leading-slash argument into a Windows\n'
129
+ + 'path, and quoting does not help. Double the slash — reply api //v3/whoami —\n'
130
+ + 'or set MSYS_NO_PATHCONV=1. PowerShell, macOS and Linux are unaffected.')
131
131
  .action(async function (path) {
132
132
  const g = read_globals(this);
133
133
  const o = this.opts();
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,yCAAkC;AAClC,wCAA2D;AAC3D,4CAA+D;AAC/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,CAAC,CAAC,IAAI,EAAC,EAAE,IAAA,uBAAa,EAAC,EAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACrG,CAAC,CAAC,CAAC;AAEC,kCAAW"}
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ const team_1 = require("./commands/team");
10
10
  const api_1 = require("./commands/api");
11
11
  const skills_1 = require("./commands/skills");
12
12
  const install_1 = require("./commands/install");
13
+ const commands_1 = require("./operations/commands");
13
14
  const notice_1 = require("./selfupdate/notice");
14
15
  const errors_1 = require("./utils/errors");
15
16
  const output_1 = require("./utils/output");
@@ -26,7 +27,7 @@ const build_program = () => {
26
27
  const PREFIX = config_1.PROGRAM_NAME.toUpperCase();
27
28
  program
28
29
  .name(config_1.PROGRAM_NAME)
29
- .description('Command-line interface for Reply.io — authentication and identity (v1).')
30
+ .description('Command-line interface for Reply.io.')
30
31
  .version((0, config_1.cli_version)(), '-v, --version')
31
32
  .option('-k, --api-key <key>', 'API key (overrides env var and stored credential)')
32
33
  .option('-p, --profile <name>', 'Named backend profile (default: prod)')
@@ -41,12 +42,16 @@ const build_program = () => {
41
42
  // Apply --quiet before any command action runs, so progress output is
42
43
  // silenced for the whole invocation.
43
44
  program.hook('preAction', () => { (0, output_1.set_quiet)(program.opts().quiet === true); });
44
- program.addCommand(auth_1.auth_command);
45
- program.addCommand(profile_1.profile_command);
46
- program.addCommand(team_1.team_command);
47
- program.addCommand(api_1.api_command);
48
- program.addCommand(skills_1.skills_command);
49
- program.addCommand(install_1.install_command);
45
+ const WORK = 'Work with your Reply account:';
46
+ const SETUP = 'Setup:';
47
+ for (const c of [commands_1.sequence_command, commands_1.contact_list_command, commands_1.contact_command, commands_1.inbox_command, api_1.api_command]) {
48
+ program.addCommand(c.helpGroup(WORK));
49
+ }
50
+ for (const c of [auth_1.auth_command, profile_1.profile_command, team_1.team_command, skills_1.skills_command, install_1.install_command]) {
51
+ program.addCommand(c.helpGroup(SETUP));
52
+ }
53
+ // Named explicitly so it takes the Setup group; the implicit one would sit in a group of its own.
54
+ program.commandsGroup(SETUP).helpCommand('help [command]', 'display help for command');
50
55
  program.addHelpText('after', `
51
56
  Credential precedence:
52
57
  1. --api-key <key> 2. ${PREFIX}_API_KEY env 3. stored credential
@@ -75,6 +80,13 @@ Team & acting user (headers):
75
80
  ${config_1.PROGRAM_NAME} team use <id> # pin a team on the current profile
76
81
  ${config_1.PROGRAM_NAME} team clear # remove the pin
77
82
 
83
+ Work commands (JSON out; exit 0 done, 1 failed, 2 usage, 3 outcome unknown):
84
+ echo '{"email":"ann@example.com","first_name":"Ann"}' | ${config_1.PROGRAM_NAME} sequence add-contact 123 --contact -
85
+ ${config_1.PROGRAM_NAME} sequence start 123 --expect-contacts 40
86
+ ${config_1.PROGRAM_NAME} contact opt-out --contact-id 456
87
+ ${config_1.PROGRAM_NAME} inbox list --contact-id 456
88
+ Each command's --help lists its flags, its result and its error codes.
89
+
78
90
  Raw API (agent/CI escape hatch) — docs: https://docs.reply.io/api-reference/introduction
79
91
  Use the path as in the docs (starts with /v3); the query string goes in the path.
80
92
  ${config_1.PROGRAM_NAME} api /v3/whoami # GET your identity + team
@@ -150,6 +162,9 @@ void main().catch(async (error) => {
150
162
  }
151
163
  else {
152
164
  console.error(error.message);
165
+ if (error.hint) {
166
+ console.error((0, errors_1.format_hint)(error.hint));
167
+ }
153
168
  }
154
169
  process.exit(error.exit_code);
155
170
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,yCAAkD;AAClD,qCAAmD;AACnD,0CAA6C;AAC7C,gDAAmD;AACnD,0CAA6C;AAC7C,wCAA2C;AAC3C,8CAAiD;AACjD,gDAAmD;AACnD,gDAAkD;AAClD,2CAAwC;AACxC,2CAA+C;AAE/C,8EAA8E;AAC9E,sEAAsE;AACtE,MAAM,iBAAiB,GAAG,CAAC,GAAY,EAA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 +1,35 @@
1
+ import { type Call_kind } from '../utils/client';
2
+ import { Operation_error } from '../utils/errors';
3
+ import { type Op_globals } from './options';
4
+ import type { Cli_context } from '../context';
5
+ type Op_session = {
6
+ api_base: string;
7
+ token: string;
8
+ headers: Record<string, string>;
9
+ };
10
+ type Answer = {
11
+ status: number;
12
+ data: unknown;
13
+ headers: Record<string, string>;
14
+ };
15
+ type Item_failure = {
16
+ error: string | null;
17
+ details: string | null;
18
+ };
19
+ declare const open_session: (ctx: Cli_context, g: Op_globals) => Promise<Op_session>;
20
+ declare const is_object: (v: unknown) => v is Record<string, unknown>;
21
+ declare const is_reply_id: (v: unknown) => v is number;
22
+ declare const reply_code_of: (a: Answer) => string | undefined;
23
+ declare const detail_of: (a: Answer) => string | undefined;
24
+ declare const call_reply: (s: Op_session, method: string, path: string, kind: Call_kind, body?: unknown) => Promise<Answer>;
25
+ declare const unreadable: (a: Answer, kind: Call_kind) => Operation_error;
26
+ declare const expect_object: (a: Answer, kind: Call_kind) => Record<string, unknown>;
27
+ declare const read_page: (a: Answer) => {
28
+ items: unknown[];
29
+ has_more: boolean;
30
+ };
31
+ declare const item_failure: (dict: unknown, id: number) => Item_failure | undefined;
32
+ declare const invalid_fields: (a: Answer) => string[] | undefined;
33
+ declare const refusal: (a: Answer, kind: Call_kind) => Operation_error;
34
+ export { open_session, call_reply, is_object, is_reply_id, reply_code_of, detail_of, unreadable, expect_object, read_page, item_failure, invalid_fields, refusal, };
35
+ export type { Op_session, Answer, Item_failure };
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.refusal = exports.invalid_fields = exports.item_failure = exports.read_page = exports.expect_object = exports.unreadable = exports.detail_of = exports.reply_code_of = exports.is_reply_id = exports.is_object = exports.call_reply = exports.open_session = void 0;
4
+ const client_1 = require("../utils/client");
5
+ const errors_1 = require("../utils/errors");
6
+ const teams_1 = require("../teams");
7
+ const authed_1 = require("../commands/authed");
8
+ const options_1 = require("./options");
9
+ const open_session = async (ctx, g) => {
10
+ const { token, headers } = await (0, authed_1.authed)(ctx, g);
11
+ return { api_base: ctx.api_base, token, headers };
12
+ };
13
+ exports.open_session = open_session;
14
+ const is_object = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
15
+ exports.is_object = is_object;
16
+ const is_reply_id = (v) => typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= options_1.LARGEST_REPLY_ID;
17
+ exports.is_reply_id = is_reply_id;
18
+ const reply_code_of = (a) => is_object(a.data) && typeof a.data.code === 'string' ? a.data.code : undefined;
19
+ exports.reply_code_of = reply_code_of;
20
+ const detail_of = (a) => {
21
+ if (is_object(a.data)) {
22
+ if (typeof a.data.detail === 'string') {
23
+ return a.data.detail;
24
+ }
25
+ return typeof a.data.title === 'string' ? a.data.title : undefined;
26
+ }
27
+ return typeof a.data === 'string' && a.data ? a.data.slice(0, 500) : undefined;
28
+ };
29
+ exports.detail_of = detail_of;
30
+ // One call to Reply for an operation. Every HTTP status comes back as an Answer for the command
31
+ // to read. If Reply can't be reached, nothing happened, so that becomes reply.unavailable. A
32
+ // write whose answer was lost passes through as outcome.unknown.
33
+ const call_reply = async (s, method, path, kind, body) => {
34
+ try {
35
+ const r = await (0, client_1.request_raw)(s.api_base, s.token, method, path, body, { headers: s.headers, kind });
36
+ return { status: r.status, data: r.data, headers: r.response_headers };
37
+ }
38
+ catch (e) {
39
+ if (e instanceof errors_1.RuntimeError) {
40
+ throw new errors_1.Operation_error('reply.unavailable', 'Reply could not be reached.', { detail: e.detail, hint: e.hint });
41
+ }
42
+ throw e;
43
+ }
44
+ };
45
+ exports.call_reply = call_reply;
46
+ // An answer that can't be read: on a read nothing happened and it can be asked again; on a
47
+ // write, the write may have happened.
48
+ const unreadable = (a, kind) => kind === 'write'
49
+ ? new errors_1.Unknown_outcome_error('Reply answered the write, but the answer could not be read.', { status: a.status })
50
+ : new errors_1.Operation_error('reply.unavailable', 'Reply answered with something that could not be read.', { status: a.status });
51
+ exports.unreadable = unreadable;
52
+ const expect_object = (a, kind) => {
53
+ if (!is_object(a.data)) {
54
+ throw unreadable(a, kind);
55
+ }
56
+ return a.data;
57
+ };
58
+ exports.expect_object = expect_object;
59
+ const read_page = (a) => {
60
+ const body = expect_object(a, 'read');
61
+ if (!Array.isArray(body.items) || typeof body.hasMore !== 'boolean') {
62
+ throw unreadable(a, 'read');
63
+ }
64
+ return { items: body.items, has_more: body.hasMore };
65
+ };
66
+ exports.read_page = read_page;
67
+ // One contact's entry in a v3 per-item failure dictionary ({"<id>": {error, errorDetails}}), or
68
+ // undefined when the contact is not in it, which is how v3 says that contact succeeded.
69
+ const item_failure = (dict, id) => {
70
+ if (!is_object(dict) || !Object.prototype.hasOwnProperty.call(dict, String(id))) {
71
+ return undefined;
72
+ }
73
+ const entry = dict[String(id)];
74
+ return {
75
+ error: is_object(entry) && typeof entry.error === 'string' ? entry.error : null,
76
+ details: is_object(entry) && typeof entry.errorDetails === 'string' ? entry.errorDetails : null,
77
+ };
78
+ };
79
+ exports.item_failure = item_failure;
80
+ // v3 answers a request it can't accept as given with `errors[]`, each entry naming a field by a
81
+ // JSON pointer, and no `code`. Only the field names are kept: the values may be personal data.
82
+ const invalid_fields = (a) => {
83
+ if (!is_object(a.data) || !Array.isArray(a.data.errors)) {
84
+ return undefined;
85
+ }
86
+ const names = a.data.errors
87
+ .map(entry => (is_object(entry) && typeof entry.pointer === 'string' ? entry.pointer.split('/').pop() : undefined))
88
+ .filter((name) => Boolean(name));
89
+ return [...new Set(names)];
90
+ };
91
+ exports.invalid_fields = invalid_fields;
92
+ // The answers every operation reads the same way. Each command reads its own statuses and codes
93
+ // first and falls back to this.
94
+ const refusal = (a, kind) => {
95
+ const reply_code = reply_code_of(a);
96
+ const base = { status: a.status, reply_code, detail: detail_of(a) };
97
+ if (a.status < 400) {
98
+ // An answer the command didn't expect, but not a refusal: on a write it may have happened.
99
+ return unreadable(a, kind);
100
+ }
101
+ if (a.status === 401) {
102
+ return new errors_1.Operation_error('access.denied', 'Reply refused the credential.', {
103
+ ...base, hint: 'Sign in again with `reply auth login`, or check the API key.',
104
+ });
105
+ }
106
+ if (a.status === 403) {
107
+ // v3's feature-scope check answers a 403 with no code at all; the endpoints' own refusals
108
+ // end in `.forbidden`. Both mean the plan or role lacks the feature, not a bad credential.
109
+ if (reply_code === undefined || reply_code.endsWith('.forbidden')) {
110
+ return new errors_1.Operation_error('access.feature_unavailable', 'The account\'s plan or role does not include this.', base);
111
+ }
112
+ return new errors_1.Operation_error('access.denied', 'Reply refused access.', { ...base, hint: (0, teams_1.team_error_guidance)(a.status, a.data) });
113
+ }
114
+ if (a.status === 429) {
115
+ return new errors_1.Operation_error('rate_limited', 'Reply asked for this call to be made later.', {
116
+ ...base, retry_after: (0, client_1.parse_retry_after)(a.headers['retry-after']) ?? undefined,
117
+ });
118
+ }
119
+ if (a.status >= 500) {
120
+ return kind === 'write'
121
+ ? new errors_1.Unknown_outcome_error('Reply failed while handling the write; it may or may not have taken effect.', base)
122
+ : new errors_1.Operation_error('reply.unavailable', 'Reply failed to answer.', base);
123
+ }
124
+ const fields = a.status === 400 && reply_code === undefined ? invalid_fields(a) : undefined;
125
+ if (fields !== undefined) {
126
+ return new errors_1.Operation_error('reply.invalid_request', 'Reply did not accept the request as given.', { ...base, details: { fields } });
127
+ }
128
+ return new errors_1.Operation_error('reply.refused', 'Reply refused the call.', base);
129
+ };
130
+ exports.refusal = refusal;
131
+ //# sourceMappingURL=call.js.map