@aaronjmars/openroutercli 0.1.4 → 0.2.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.
@@ -1,7 +1,6 @@
1
- import { stdin } from 'node:process';
2
- import { parseArgs, authFromValues } from '../args.js';
3
- import { api } from '../api.js';
4
- import { outln, pricePerMillion, printResult, table } from '../output.js';
1
+ import { parseArgs, authFromValues, numberOption, readStdinIfPiped } from "../args.js";
2
+ import { api } from "../api.js";
3
+ import { outln, pricePerMillion, printResult, table } from "../output.js";
5
4
 
6
5
  const HELP = `Usage: openrouter embed [text...] [options]
7
6
  openrouter embed models
@@ -17,74 +16,76 @@ Options:
17
16
  --provider <json> Provider routing as JSON
18
17
  `;
19
18
 
20
- async function readStdinIfPiped() {
21
- if (stdin.isTTY) return null;
22
- let data = '';
23
- for await (const chunk of stdin) data += chunk;
24
- return data.trim() || null;
25
- }
26
-
27
19
  export async function embedCommand(argv) {
28
- if (argv[0] === 'models') {
20
+ if (argv[0] === "models") {
29
21
  const { values } = parseArgs(argv.slice(1), {});
30
- const data = await api('GET', '/embeddings/models', {
22
+ if (values.help) {
23
+ process.stdout.write(HELP);
24
+ return 0;
25
+ }
26
+ const data = await api("GET", "/embeddings/models", {
31
27
  auth: authFromValues(values),
32
- requireAuth: false
28
+ requireAuth: false,
33
29
  });
34
30
  printResult(data, () => {
35
31
  const rows = data.data || [];
36
32
  table(rows, [
37
- { label: 'id', value: (m) => m.id },
38
- { label: 'context', value: (m) => m.context_length ?? '' },
33
+ { label: "id", value: (m) => m.id },
34
+ { label: "context", value: (m) => m.context_length ?? "" },
39
35
  {
40
- label: '$/M tokens',
41
- value: (m) => pricePerMillion((m.pricing || {}).prompt)
36
+ label: "$/M tokens",
37
+ value: (m) => pricePerMillion((m.pricing || {}).prompt),
42
38
  },
43
- { label: 'name', value: (m) => m.name || '' }
39
+ { label: "name", value: (m) => m.name || "" },
44
40
  ]);
45
41
  });
46
42
  return 0;
47
43
  }
48
44
 
49
45
  const { values, positionals } = parseArgs(argv, {
50
- model: { type: 'string', short: 'm' },
51
- input: { type: 'string', short: 'i', multiple: true },
52
- 'input-type': { type: 'string' },
53
- dimensions: { type: 'string' },
54
- encoding: { type: 'string' },
55
- provider: { type: 'string' }
46
+ model: { type: "string", short: "m" },
47
+ input: { type: "string", short: "i", multiple: true },
48
+ "input-type": { type: "string" },
49
+ dimensions: { type: "string" },
50
+ encoding: { type: "string" },
51
+ provider: { type: "string" },
56
52
  });
57
53
  if (values.help) {
58
54
  process.stdout.write(HELP);
59
55
  return 0;
60
56
  }
61
- if (!values.model) throw new Error('--model is required');
57
+ if (!values.model) throw new Error("--model is required");
62
58
 
63
59
  const inputs = [...(values.input || []), ...positionals];
64
60
  const piped = await readStdinIfPiped();
65
61
  if (piped) inputs.push(piped);
66
- if (!inputs.length) throw new Error('No input. Pass text, use --input, or pipe stdin.');
62
+ if (!inputs.length) throw new Error("No input. Pass text, use --input, or pipe stdin.");
67
63
 
68
64
  const body = {
69
65
  model: values.model,
70
- input: inputs.length === 1 ? inputs[0] : inputs
66
+ input: inputs.length === 1 ? inputs[0] : inputs,
71
67
  };
72
- if (values['input-type']) body.input_type = values['input-type'];
73
- if (values.dimensions) body.dimensions = Number(values.dimensions);
68
+ if (values["input-type"]) body.input_type = values["input-type"];
69
+ if (values.dimensions) body.dimensions = numberOption(values.dimensions, "--dimensions");
74
70
  if (values.encoding) body.encoding_format = values.encoding;
75
71
  if (values.provider) body.provider = JSON.parse(values.provider);
76
72
 
77
- const data = await api('POST', '/embeddings', {
73
+ const data = await api("POST", "/embeddings", {
78
74
  auth: authFromValues(values),
79
- body
75
+ body,
80
76
  });
81
77
  printResult(data, () => {
82
78
  const arr = data.data || [];
83
79
  for (const e of arr) {
84
80
  const v = e.embedding;
85
81
  if (Array.isArray(v))
86
- outln(`[${v.length}d] ${v.slice(0, 4).map((x) => x.toFixed(5)).join(', ')}, ...`);
87
- else outln(String(v).slice(0, 80) + '...');
82
+ outln(
83
+ `[${v.length}d] ${v
84
+ .slice(0, 4)
85
+ .map((x) => x.toFixed(5))
86
+ .join(", ")}, ...`,
87
+ );
88
+ else outln(String(v).slice(0, 80) + "...");
88
89
  }
89
90
  });
90
91
  return 0;
@@ -0,0 +1,102 @@
1
+ import { parseArgs, authFromValues } from "../args.js";
2
+ import { api } from "../api.js";
3
+ import { outln, printResult, table, writeBinaryOutput } from "../output.js";
4
+
5
+ const HELP = `Usage: openrouter files <subcommand> [options]
6
+
7
+ Manage files stored on OpenRouter (backing store for file/PDF inputs).
8
+
9
+ Subcommands:
10
+ list List uploaded files
11
+ get <id> Get one file's metadata
12
+ upload <path> [options] Upload a file (multipart)
13
+ download <id> [-o file] Download file content
14
+ delete <id> Delete a file
15
+
16
+ upload options:
17
+ --purpose <p> Purpose tag for the file (e.g. assistants, user_data)
18
+ `;
19
+
20
+ export async function filesCommand(argv) {
21
+ const sub = argv[0];
22
+ const rest = argv.slice(1);
23
+ if (!sub || sub === "help" || sub === "-h" || sub === "--help") {
24
+ process.stdout.write(HELP);
25
+ return sub ? 0 : 1;
26
+ }
27
+ if (rest.includes("-h") || rest.includes("--help")) {
28
+ process.stdout.write(HELP);
29
+ return 0;
30
+ }
31
+
32
+ if (sub === "list") {
33
+ const { values } = parseArgs(rest, {});
34
+ const data = await api("GET", "/files", { auth: authFromValues(values) });
35
+ printResult(data, () => {
36
+ const rows = data.data || [];
37
+ table(rows, [
38
+ { label: "id", value: (f) => f.id || "" },
39
+ { label: "filename", value: (f) => f.filename || f.name || "" },
40
+ { label: "bytes", value: (f) => f.bytes ?? f.size ?? "" },
41
+ { label: "purpose", value: (f) => f.purpose || "" },
42
+ ]);
43
+ });
44
+ return 0;
45
+ }
46
+
47
+ if (sub === "get") {
48
+ const { values, positionals } = parseArgs(rest, {});
49
+ if (!positionals[0]) throw new Error("id required");
50
+ const data = await api("GET", `/files/${encodeURIComponent(positionals[0])}`, {
51
+ auth: authFromValues(values),
52
+ });
53
+ printResult(data);
54
+ return 0;
55
+ }
56
+
57
+ if (sub === "upload") {
58
+ const { values, positionals } = parseArgs(rest, {
59
+ purpose: { type: "string" },
60
+ });
61
+ const path = positionals[0];
62
+ if (!path) throw new Error("path required");
63
+ const { readFile } = await import("node:fs/promises");
64
+ const buf = await readFile(path);
65
+ const filename = path.split("/").pop() || "file";
66
+ const form = new FormData();
67
+ form.append("file", new Blob([buf]), filename);
68
+ if (values.purpose) form.append("purpose", values.purpose);
69
+ const data = await api("POST", "/files", {
70
+ auth: authFromValues(values),
71
+ body: form,
72
+ });
73
+ printResult(data);
74
+ return 0;
75
+ }
76
+
77
+ if (sub === "download") {
78
+ const { values, positionals } = parseArgs(rest, {
79
+ out: { type: "string", short: "o" },
80
+ });
81
+ if (!positionals[0]) throw new Error("id required");
82
+ const bytes = await api("GET", `/files/${encodeURIComponent(positionals[0])}/content`, {
83
+ auth: authFromValues(values),
84
+ binary: true,
85
+ });
86
+ const out = values.out || positionals[0];
87
+ await writeBinaryOutput(bytes, out);
88
+ return 0;
89
+ }
90
+
91
+ if (sub === "delete") {
92
+ const { values, positionals } = parseArgs(rest, {});
93
+ if (!positionals[0]) throw new Error("id required");
94
+ const data = await api("DELETE", `/files/${encodeURIComponent(positionals[0])}`, {
95
+ auth: authFromValues(values),
96
+ });
97
+ printResult(data, () => outln("deleted"));
98
+ return 0;
99
+ }
100
+
101
+ throw new Error(`Unknown files subcommand: ${sub}`);
102
+ }
@@ -1,29 +1,29 @@
1
- import { parseArgs, authFromValues } from '../args.js';
2
- import { api } from '../api.js';
3
- import { c, outln, printResult } from '../output.js';
1
+ import { parseArgs, authFromValues } from "../args.js";
2
+ import { api } from "../api.js";
3
+ import { c, outln, printResult } from "../output.js";
4
4
 
5
5
  export async function generationCommand(argv) {
6
6
  const { values, positionals } = parseArgs(argv, {
7
- content: { type: 'boolean' }
7
+ content: { type: "boolean" },
8
8
  });
9
9
  if (values.help || !positionals[0]) {
10
10
  process.stdout.write(
11
- 'Usage: openrouter generation <id> [--content]\n\nFetch metadata for a generation. With --content, fetch the input/output content.\n'
11
+ "Usage: openrouter generation <id> [--content]\n\nFetch metadata for a generation. With --content, fetch the input/output content.\n",
12
12
  );
13
13
  return values.help ? 0 : 1;
14
14
  }
15
15
  const id = positionals[0];
16
- const path = values.content ? '/generation/content' : '/generation';
17
- const data = await api('GET', path, {
16
+ const path = values.content ? "/generation/content" : "/generation";
17
+ const data = await api("GET", path, {
18
18
  auth: authFromValues(values),
19
- query: { id }
19
+ query: { id },
20
20
  });
21
21
  printResult(data, () => {
22
22
  const d = data.data || data;
23
23
  outln(c.bold(`generation ${id}`));
24
24
  for (const [k, v] of Object.entries(d)) {
25
- const display = typeof v === 'string' && v.length > 200 ? v.slice(0, 200) + '...' : v;
26
- outln(` ${k}: ${typeof display === 'object' ? JSON.stringify(display) : display}`);
25
+ const display = typeof v === "string" && v.length > 200 ? v.slice(0, 200) + "..." : v;
26
+ outln(` ${k}: ${typeof display === "object" ? JSON.stringify(display) : display}`);
27
27
  }
28
28
  });
29
29
  return 0;
@@ -1,13 +1,19 @@
1
- import { parseArgs, authFromValues, PAGINATION_OPTIONS, paginationQuery, numberOption } from '../args.js';
2
- import { api } from '../api.js';
3
- import { outln, printResult, table } from '../output.js';
1
+ import {
2
+ parseArgs,
3
+ authFromValues,
4
+ PAGINATION_OPTIONS,
5
+ paginationQuery,
6
+ numberOption,
7
+ } from "../args.js";
8
+ import { api } from "../api.js";
9
+ import { outln, printResult, table } from "../output.js";
4
10
 
5
11
  const HELP = `Usage: openrouter guardrails <subcommand> [options]
6
12
 
7
13
  Manage guardrails (requires a management key).
8
14
 
9
15
  Subcommands:
10
- list List guardrails
16
+ list [--offset <n>] [--limit <n>] List guardrails
11
17
  get <id> Get one
12
18
  create <name> [options] Create
13
19
  update <id> [options] Update
@@ -21,6 +27,7 @@ Subcommands:
21
27
  member-assignments <id> List member assignments for a guardrail
22
28
 
23
29
  create / update options:
30
+ --name <name> (update only)
24
31
  --description <text>
25
32
  --limit-usd <n>
26
33
  --reset-interval <p> daily | weekly | monthly | null
@@ -29,189 +36,210 @@ create / update options:
29
36
  --ignored-models <csv>
30
37
  --allowed-providers <csv>
31
38
  --ignored-providers <csv>
39
+ --include-byok / --no-include-byok Count BYOK spend toward the budget
32
40
  --workspace <uuid> (create only)
33
41
  `;
34
42
 
35
43
  function csv(v) {
36
44
  if (v == null) return undefined;
37
- if (v === '') return null;
38
- return v.split(',').map((s) => s.trim()).filter(Boolean);
45
+ if (v === "") return null;
46
+ return v
47
+ .split(",")
48
+ .map((s) => s.trim())
49
+ .filter(Boolean);
39
50
  }
40
51
 
41
52
  function buildBody(values) {
42
53
  const body = {};
43
54
  if (values.description !== undefined) body.description = values.description;
44
- if (values['limit-usd'] !== undefined) body.limit_usd = numberOption(values['limit-usd'], '--limit-usd');
45
- if (values['reset-interval'] !== undefined) {
46
- body.reset_interval = values['reset-interval'] === 'null' ? null : values['reset-interval'];
55
+ if (values["limit-usd"] !== undefined)
56
+ body.limit_usd = numberOption(values["limit-usd"], "--limit-usd");
57
+ if (values["reset-interval"] !== undefined) {
58
+ body.reset_interval = values["reset-interval"] === "null" ? null : values["reset-interval"];
47
59
  }
48
- if (values['enforce-zdr']) body.enforce_zdr = true;
49
- if (values['no-zdr']) body.enforce_zdr = false;
50
- if (values['allowed-models'] !== undefined) body.allowed_models = csv(values['allowed-models']);
51
- if (values['ignored-models'] !== undefined) body.ignored_models = csv(values['ignored-models']);
52
- if (values['allowed-providers'] !== undefined) body.allowed_providers = csv(values['allowed-providers']);
53
- if (values['ignored-providers'] !== undefined) body.ignored_providers = csv(values['ignored-providers']);
60
+ if (values["enforce-zdr"]) body.enforce_zdr = true;
61
+ if (values["no-zdr"]) body.enforce_zdr = false;
62
+ if (values["allowed-models"] !== undefined) body.allowed_models = csv(values["allowed-models"]);
63
+ if (values["ignored-models"] !== undefined) body.ignored_models = csv(values["ignored-models"]);
64
+ if (values["allowed-providers"] !== undefined)
65
+ body.allowed_providers = csv(values["allowed-providers"]);
66
+ if (values["ignored-providers"] !== undefined)
67
+ body.ignored_providers = csv(values["ignored-providers"]);
68
+ if (values["include-byok"]) body.include_byok_in_budgets = true;
69
+ if (values["no-include-byok"]) body.include_byok_in_budgets = false;
54
70
  return body;
55
71
  }
56
72
 
57
73
  const COMMON_FIELDS = {
58
- description: { type: 'string' },
59
- 'limit-usd': { type: 'string' },
60
- 'reset-interval': { type: 'string' },
61
- 'enforce-zdr': { type: 'boolean' },
62
- 'no-zdr': { type: 'boolean' },
63
- 'allowed-models': { type: 'string' },
64
- 'ignored-models': { type: 'string' },
65
- 'allowed-providers': { type: 'string' },
66
- 'ignored-providers': { type: 'string' }
74
+ description: { type: "string" },
75
+ "limit-usd": { type: "string" },
76
+ "reset-interval": { type: "string" },
77
+ "enforce-zdr": { type: "boolean" },
78
+ "no-zdr": { type: "boolean" },
79
+ "allowed-models": { type: "string" },
80
+ "ignored-models": { type: "string" },
81
+ "allowed-providers": { type: "string" },
82
+ "ignored-providers": { type: "string" },
83
+ "include-byok": { type: "boolean" },
84
+ "no-include-byok": { type: "boolean" },
67
85
  };
68
86
 
69
87
  export async function guardrailsCommand(argv) {
70
88
  const sub = argv[0];
71
89
  const rest = argv.slice(1);
72
- if (!sub || sub === 'help' || sub === '-h' || sub === '--help') {
90
+ if (!sub || sub === "help" || sub === "-h" || sub === "--help") {
73
91
  process.stdout.write(HELP);
74
92
  return sub ? 0 : 1;
75
93
  }
76
94
 
77
- const auth = (v) => authFromValues(v);
95
+ if (rest.includes("-h") || rest.includes("--help")) {
96
+ process.stdout.write(HELP);
97
+ return 0;
98
+ }
78
99
 
79
- if (sub === 'list') {
100
+ if (sub === "list") {
80
101
  const { values } = parseArgs(rest, PAGINATION_OPTIONS);
81
102
  const query = paginationQuery(values);
82
- const data = await api('GET', '/guardrails', {
83
- auth: auth(values),
103
+ const data = await api("GET", "/guardrails", {
104
+ auth: authFromValues(values),
84
105
  requiresManagement: true,
85
- query
106
+ query,
86
107
  });
87
108
  printResult(data, () => {
88
109
  const rows = data.data || [];
89
110
  table(rows, [
90
- { label: 'id', value: (g) => g.id },
91
- { label: 'name', value: (g) => g.name },
92
- { label: 'limit_usd', value: (g) => g.limit_usd ?? '' },
93
- { label: 'reset', value: (g) => g.reset_interval ?? '' },
94
- { label: 'zdr', value: (g) => (g.enforce_zdr ? 'yes' : '') }
111
+ { label: "id", value: (g) => g.id },
112
+ { label: "name", value: (g) => g.name },
113
+ { label: "limit_usd", value: (g) => g.limit_usd ?? "" },
114
+ { label: "reset", value: (g) => g.reset_interval ?? "" },
115
+ { label: "zdr", value: (g) => (g.enforce_zdr ? "yes" : "") },
95
116
  ]);
96
117
  });
97
118
  return 0;
98
119
  }
99
120
 
100
- if (sub === 'get') {
121
+ if (sub === "get") {
101
122
  const { values, positionals } = parseArgs(rest, {});
102
- if (!positionals[0]) throw new Error('id required');
103
- const data = await api('GET', `/guardrails/${encodeURIComponent(positionals[0])}`, {
104
- auth: auth(values),
105
- requiresManagement: true
123
+ if (!positionals[0]) throw new Error("id required");
124
+ const data = await api("GET", `/guardrails/${encodeURIComponent(positionals[0])}`, {
125
+ auth: authFromValues(values),
126
+ requiresManagement: true,
106
127
  });
107
128
  printResult(data);
108
129
  return 0;
109
130
  }
110
131
 
111
- if (sub === 'create') {
132
+ if (sub === "create") {
112
133
  const { values, positionals } = parseArgs(rest, {
113
134
  ...COMMON_FIELDS,
114
- workspace: { type: 'string' }
135
+ workspace: { type: "string" },
115
136
  });
116
137
  const name = positionals[0];
117
- if (!name) throw new Error('name required');
138
+ if (!name) throw new Error("name required");
118
139
  const body = { name, ...buildBody(values) };
119
140
  if (values.workspace) body.workspace_id = values.workspace;
120
- const data = await api('POST', '/guardrails', {
121
- auth: auth(values),
141
+ const data = await api("POST", "/guardrails", {
142
+ auth: authFromValues(values),
122
143
  requiresManagement: true,
123
- body
144
+ body,
124
145
  });
125
146
  printResult(data);
126
147
  return 0;
127
148
  }
128
149
 
129
- if (sub === 'update') {
150
+ if (sub === "update") {
130
151
  const { values, positionals } = parseArgs(rest, {
131
152
  ...COMMON_FIELDS,
132
- name: { type: 'string' }
153
+ name: { type: "string" },
133
154
  });
134
- if (!positionals[0]) throw new Error('id required');
155
+ if (!positionals[0]) throw new Error("id required");
135
156
  const body = buildBody(values);
136
157
  if (values.name) body.name = values.name;
137
- const data = await api('PATCH', `/guardrails/${encodeURIComponent(positionals[0])}`, {
138
- auth: auth(values),
158
+ const data = await api("PATCH", `/guardrails/${encodeURIComponent(positionals[0])}`, {
159
+ auth: authFromValues(values),
139
160
  requiresManagement: true,
140
- body
161
+ body,
141
162
  });
142
163
  printResult(data);
143
164
  return 0;
144
165
  }
145
166
 
146
- if (sub === 'delete') {
167
+ if (sub === "delete") {
147
168
  const { values, positionals } = parseArgs(rest, {});
148
- if (!positionals[0]) throw new Error('id required');
149
- const data = await api('DELETE', `/guardrails/${encodeURIComponent(positionals[0])}`, {
150
- auth: auth(values),
151
- requiresManagement: true
169
+ if (!positionals[0]) throw new Error("id required");
170
+ const data = await api("DELETE", `/guardrails/${encodeURIComponent(positionals[0])}`, {
171
+ auth: authFromValues(values),
172
+ requiresManagement: true,
152
173
  });
153
- printResult(data, () => outln('deleted'));
174
+ printResult(data, () => outln("deleted"));
154
175
  return 0;
155
176
  }
156
177
 
157
- if (sub === 'assignments') {
178
+ if (sub === "assignments") {
158
179
  const { values } = parseArgs(rest, {
159
- keys: { type: 'boolean' },
160
- members: { type: 'boolean' }
180
+ keys: { type: "boolean" },
181
+ members: { type: "boolean" },
161
182
  });
162
- const path = values.members ? '/guardrails/assignments/members' : '/guardrails/assignments/keys';
163
- const data = await api('GET', path, {
164
- auth: auth(values),
165
- requiresManagement: true
183
+ if (values.keys && values.members) {
184
+ throw new Error("Pass only one of --keys or --members.");
185
+ }
186
+ const path = values.members
187
+ ? "/guardrails/assignments/members"
188
+ : "/guardrails/assignments/keys";
189
+ const data = await api("GET", path, {
190
+ auth: authFromValues(values),
191
+ requiresManagement: true,
166
192
  });
167
193
  printResult(data);
168
194
  return 0;
169
195
  }
170
196
 
171
- if (sub === 'key-assignments' || sub === 'member-assignments') {
197
+ if (sub === "key-assignments" || sub === "member-assignments") {
172
198
  const { values, positionals } = parseArgs(rest, {});
173
- if (!positionals[0]) throw new Error('id required');
199
+ if (!positionals[0]) throw new Error("id required");
174
200
  const path =
175
- sub === 'key-assignments'
201
+ sub === "key-assignments"
176
202
  ? `/guardrails/${encodeURIComponent(positionals[0])}/assignments/keys`
177
203
  : `/guardrails/${encodeURIComponent(positionals[0])}/assignments/members`;
178
- const data = await api('GET', path, {
179
- auth: auth(values),
180
- requiresManagement: true
204
+ const data = await api("GET", path, {
205
+ auth: authFromValues(values),
206
+ requiresManagement: true,
181
207
  });
182
208
  printResult(data);
183
209
  return 0;
184
210
  }
185
211
 
186
- if (sub === 'assign-key' || sub === 'unassign-key') {
212
+ if (sub === "assign-key" || sub === "unassign-key") {
187
213
  const { values, positionals } = parseArgs(rest, {});
188
- if (positionals.length < 2) throw new Error('Usage: <id> <hash>...');
214
+ if (positionals.length < 2) throw new Error("Usage: <id> <hash>...");
189
215
  const id = positionals[0];
190
216
  const hashes = positionals.slice(1);
191
- const path = sub === 'assign-key'
192
- ? `/guardrails/${encodeURIComponent(id)}/assignments/keys`
193
- : `/guardrails/${encodeURIComponent(id)}/assignments/keys/remove`;
194
- const data = await api('POST', path, {
195
- auth: auth(values),
217
+ const path =
218
+ sub === "assign-key"
219
+ ? `/guardrails/${encodeURIComponent(id)}/assignments/keys`
220
+ : `/guardrails/${encodeURIComponent(id)}/assignments/keys/remove`;
221
+ const data = await api("POST", path, {
222
+ auth: authFromValues(values),
196
223
  requiresManagement: true,
197
- body: { key_hashes: hashes }
224
+ body: { key_hashes: hashes },
198
225
  });
199
226
  printResult(data);
200
227
  return 0;
201
228
  }
202
229
 
203
- if (sub === 'assign-member' || sub === 'unassign-member') {
230
+ if (sub === "assign-member" || sub === "unassign-member") {
204
231
  const { values, positionals } = parseArgs(rest, {});
205
- if (positionals.length < 2) throw new Error('Usage: <id> <user_id>...');
232
+ if (positionals.length < 2) throw new Error("Usage: <id> <user_id>...");
206
233
  const id = positionals[0];
207
234
  const userIds = positionals.slice(1);
208
- const path = sub === 'assign-member'
209
- ? `/guardrails/${encodeURIComponent(id)}/assignments/members`
210
- : `/guardrails/${encodeURIComponent(id)}/assignments/members/remove`;
211
- const data = await api('POST', path, {
212
- auth: auth(values),
235
+ const path =
236
+ sub === "assign-member"
237
+ ? `/guardrails/${encodeURIComponent(id)}/assignments/members`
238
+ : `/guardrails/${encodeURIComponent(id)}/assignments/members/remove`;
239
+ const data = await api("POST", path, {
240
+ auth: authFromValues(values),
213
241
  requiresManagement: true,
214
- body: { user_ids: userIds }
242
+ body: { user_ids: userIds },
215
243
  });
216
244
  printResult(data);
217
245
  return 0;