reply-cli 0.5.1 → 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.
- package/README.md +91 -11
- package/dist/commands/api.js +2 -40
- package/dist/commands/api.js.map +1 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/operations/call.d.ts +35 -0
- package/dist/operations/call.js +131 -0
- package/dist/operations/call.js.map +1 -0
- package/dist/operations/commands.d.ts +6 -0
- package/dist/operations/commands.js +153 -0
- package/dist/operations/commands.js.map +1 -0
- package/dist/operations/contact-input.d.ts +29 -0
- package/dist/operations/contact-input.js +84 -0
- package/dist/operations/contact-input.js.map +1 -0
- package/dist/operations/contact-list.d.ts +9 -0
- package/dist/operations/contact-list.js +50 -0
- package/dist/operations/contact-list.js.map +1 -0
- package/dist/operations/contact.d.ts +7 -0
- package/dist/operations/contact.js +49 -0
- package/dist/operations/contact.js.map +1 -0
- package/dist/operations/contacts.d.ts +11 -0
- package/dist/operations/contacts.js +115 -0
- package/dist/operations/contacts.js.map +1 -0
- package/dist/operations/inbox.d.ts +22 -0
- package/dist/operations/inbox.js +76 -0
- package/dist/operations/inbox.js.map +1 -0
- package/dist/operations/options.d.ts +18 -0
- package/dist/operations/options.js +63 -0
- package/dist/operations/options.js.map +1 -0
- package/dist/operations/result.d.ts +5 -0
- package/dist/operations/result.js +20 -0
- package/dist/operations/result.js.map +1 -0
- package/dist/operations/sequence-membership.d.ts +13 -0
- package/dist/operations/sequence-membership.js +227 -0
- package/dist/operations/sequence-membership.js.map +1 -0
- package/dist/operations/sequence-read.d.ts +26 -0
- package/dist/operations/sequence-read.js +121 -0
- package/dist/operations/sequence-read.js.map +1 -0
- package/dist/operations/sequence-state.d.ts +7 -0
- package/dist/operations/sequence-state.js +88 -0
- package/dist/operations/sequence-state.js.map +1 -0
- package/dist/skills/adapter-flat.d.ts +3 -1
- package/dist/skills/adapter-flat.js +49 -19
- package/dist/skills/adapter-flat.js.map +1 -1
- package/dist/skills/hosts.js +35 -13
- package/dist/skills/hosts.js.map +1 -1
- package/dist/skills/orchestrate.js +41 -4
- package/dist/skills/orchestrate.js.map +1 -1
- package/dist/skills/report.js +36 -10
- package/dist/skills/report.js.map +1 -1
- package/dist/skills/types.d.ts +11 -1
- package/dist/utils/client.d.ts +5 -2
- package/dist/utils/client.js +113 -78
- package/dist/utils/client.js.map +1 -1
- package/dist/utils/errors.d.ts +29 -2
- package/dist/utils/errors.js +40 -2
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/json-arg.d.ts +10 -0
- package/dist/utils/json-arg.js +45 -0
- package/dist/utils/json-arg.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -176,6 +176,53 @@ reply team clear # remove the pin
|
|
|
176
176
|
If a call needs a team and you're in more than one, the API answers with a
|
|
177
177
|
`TEAM_REQUIRED` error listing your teams — run `reply team use <id>` to pin one.
|
|
178
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
|
+
|
|
179
226
|
## Raw API access
|
|
180
227
|
|
|
181
228
|
`reply api` is a raw, authenticated passthrough to any v3 endpoint — the
|
|
@@ -203,6 +250,12 @@ It prints `{ "code": <status>, "data": <body> }` and exits non-zero on HTTP
|
|
|
203
250
|
stderr. Add `--verbose` for a full request/response trace on stderr with
|
|
204
251
|
credentials redacted; stdout stays the plain JSON, so pipes keep working.
|
|
205
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
|
+
|
|
206
259
|
### Windows: Git Bash rewrites the path
|
|
207
260
|
|
|
208
261
|
Under Git Bash / MSYS, `reply api /v3/whoami` never reaches the CLI as you typed
|
|
@@ -266,17 +319,44 @@ plugin mechanism, so they keep updating through it. Other `SKILL.md` hosts
|
|
|
266
319
|
receive the skills as files. Add `--json` for a machine-readable report, and
|
|
267
320
|
`--dry-run` to see the plan without changing anything.
|
|
268
321
|
|
|
269
|
-
| Assistant | How it receives the packs | Paths verified |
|
|
270
|
-
|
|
271
|
-
| Claude Code | its own plugin CLI | yes |
|
|
272
|
-
| Codex | its own plugin CLI (`--project` copies files instead) | yes |
|
|
273
|
-
| Cursor
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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.
|
|
280
360
|
|
|
281
361
|
Installing skills is not the same as connecting Reply: `reply-adapter` needs a
|
|
282
362
|
Reply.io login (`reply auth login`) to actually do anything.
|
package/dist/commands/api.js
CHANGED
|
@@ -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
3
|
exports.assert_api_path = exports.read_body_arg = exports.handle_api = exports.api_command = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
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) {
|
package/dist/commands/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api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AACL,CAAC,CAAC;AA2BmB,gCAAU;AAzB/B,MAAM,WAAW,GAAG,IAAI,mBAAO,CAAC,KAAK,CAAC;KACjC,QAAQ,CAAC,QAAQ,EAAE,iEAAiE,CAAC;KACrF,MAAM,CAAC,iBAAiB,EAAE,sDAAsD,CAAC;KACjF,MAAM,CAAC,eAAe,EAAE,0CAA0C,CAAC;KACnE,WAAW,CAAC,iEAAiE,CAAC;KAC9E,WAAW,CAAC,OAAO,EAChB,4DAA4D;MAC1D,6EAA6E;MAC7E,qBAAqB;MACrB,eAAe;MACf,wEAAwE;MACxE,kEAAkE;MAClE,4EAA4E;MAC5E,sEAAsE;MACtE,0FAA0F;MAC1F,2EAA2E;MAC3E,iFAAiF;MACjF,+EAA+E;MAC/E,wEAAwE,CAAC;KAC9E,MAAM,CAAC,KAAK,WAAyB,IAAY;IAC9C,MAAM,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IACtB,MAAM,UAAU,CAAC,IAAI,EAAE,EAAC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,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
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
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,2CAAqD;AACrD,2CAA+C;AAE/C,8EAA8E;AAC9E,sEAAsE;AACtE,MAAM,iBAAiB,GAAG,CAAC,GAAY,EAAO,EAAE;IAC5C,GAAG,CAAC,YAAY,EAAE,CAAC;IACnB,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,QAAQ,EAC9B,CAAC;QACG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,GAAW,EAAE;IAC/B,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,qBAAY,CAAC,WAAW,EAAE,CAAC;IAC1C,OAAO;SACF,IAAI,CAAC,qBAAY,CAAC;SAClB,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.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C,KAAK,CAAC,IAAI,KAAK,mBAAmB;eAClC,KAAK,CAAC,IAAI,KAAK,gBAAgB,CAAC;QACvC,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB,EACtC,CAAC;YACG,MAAM,YAAY,EAAE,CAAC;QACzB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,KAAK,YAAY,iBAAQ,EAC7B,CAAC;QACG,IAAI,UAAU,EAAE,EAChB,CAAC;YACG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACnD,CAAC;aAED,CAAC;YACG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7B,IAAI,KAAK,CAAC,IAAI,EACd,CAAC;gBACG,OAAO,CAAC,KAAK,CAAC,IAAA,oBAAW,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3C,CAAC;QACL,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../src/operations/call.ts"],"names":[],"mappings":";;;AAAA,4CAA+E;AAC/E,4CAAqF;AACrF,oCAA6C;AAC7C,+CAA0C;AAC1C,uCAA4D;AAO5D,MAAM,YAAY,GAAG,KAAK,EAAC,GAAgB,EAAE,CAAa,EAAsB,EAAE;IAC9E,MAAM,EAAC,KAAK,EAAE,OAAO,EAAC,GAAG,MAAM,IAAA,eAAM,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC9C,OAAO,EAAC,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAC,CAAC;AACpD,CAAC,CAAC;AAyIE,oCAAY;AAvIhB,MAAM,SAAS,GAAG,CAAC,CAAU,EAA+B,EAAE,CAC1D,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KA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AAC,uBAAuB,EAAE,4CAA4C,EAAE,EAAC,GAAG,IAAI,EAAE,OAAO,EAAE,EAAC,MAAM,EAAC,EAAC,CAAC,CAAC;IACpI,CAAC;IACD,OAAO,IAAI,wBAAe,CAAC,eAAe,EAAE,yBAAyB,EAAE,IAAI,CAAC,CAAC;AACjF,CAAC,CAAC;AAIsE,0BAAO"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
declare const sequence_command: Command;
|
|
3
|
+
declare const contact_list_command: Command;
|
|
4
|
+
declare const contact_command: Command;
|
|
5
|
+
declare const inbox_command: Command;
|
|
6
|
+
export { sequence_command, contact_list_command, contact_command, inbox_command };
|