@curviate/cli 0.1.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.
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ resolveIdentifier
4
+ } from "./chunk-BNUTM6KD.js";
5
+ import {
6
+ createClient,
7
+ renderError,
8
+ renderSuccess,
9
+ renderUnexpectedError,
10
+ resolveEffectiveConfig
11
+ } from "./chunk-2NCPJJPC.js";
12
+ import {
13
+ GLOBAL_FLAGS
14
+ } from "./chunk-6JNCLLNY.js";
15
+
16
+ // src/commands/company.ts
17
+ import { defineCommand } from "citty";
18
+ function buildOutputStreams() {
19
+ return {
20
+ stdout: { write: (s) => process.stdout.write(s) },
21
+ stderr: { write: (s) => process.stderr.write(s) }
22
+ };
23
+ }
24
+ async function runCompanyGet(client, flags, out) {
25
+ if (flags.preview) {
26
+ out.stderr.write("error: --preview is only valid on write commands (mutations). Reads just run.\n");
27
+ process.exit(2);
28
+ }
29
+ if (flags.all) {
30
+ out.stderr.write("error: --all is not supported on non-paginated commands.\n");
31
+ process.exit(2);
32
+ }
33
+ const rawId = flags.id ?? "";
34
+ const resolvedId = resolveIdentifier(rawId);
35
+ const outOpts = {
36
+ json: (flags.json ?? false) || !process.stdout.isTTY,
37
+ isTTY: process.stdout.isTTY ?? false,
38
+ fields: flags.fields
39
+ };
40
+ try {
41
+ const getCompany = flags.account ? client.account(flags.account).profiles.getCompany.bind(client.account(flags.account).profiles) : client.profiles.getCompany.bind(client.profiles);
42
+ const result = await getCompany(resolvedId);
43
+ renderSuccess(result, outOpts, out);
44
+ } catch (err) {
45
+ const { CurviateError } = await import("@curviate/sdk");
46
+ if (err instanceof CurviateError) {
47
+ const { getExitCode } = await import("./exit-codes-NFIR57ZA.js");
48
+ renderError(err, outOpts, out);
49
+ process.exit(getExitCode(err.code));
50
+ }
51
+ renderUnexpectedError(err, out);
52
+ process.exit(1);
53
+ }
54
+ }
55
+ var companyCommand = defineCommand({
56
+ meta: { name: "company", description: "Fetch a company profile by URL or slug." },
57
+ args: {
58
+ ...GLOBAL_FLAGS,
59
+ id: { type: "positional", description: "Company identifier (URL, slug, or native id)." }
60
+ },
61
+ async run({ args }) {
62
+ const flags = args;
63
+ const cfg = await resolveEffectiveConfig({
64
+ apiKey: flags["api-key"],
65
+ baseUrl: flags["base-url"],
66
+ timeout: flags.timeout,
67
+ account: flags.account,
68
+ profile: flags.profile
69
+ });
70
+ if (!cfg.apiKey) {
71
+ process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
72
+ process.exit(3);
73
+ }
74
+ const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
75
+ const out = buildOutputStreams();
76
+ await runCompanyGet(client, { ...flags, account: flags.account ?? cfg.account }, out);
77
+ }
78
+ });
79
+ export {
80
+ companyCommand,
81
+ runCompanyGet
82
+ };
@@ -0,0 +1,262 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ GLOBAL_FLAGS,
4
+ getConfigPath,
5
+ readConfig,
6
+ removeProfile,
7
+ renameProfile,
8
+ setActiveProfile,
9
+ updateProfileField
10
+ } from "./chunk-6JNCLLNY.js";
11
+
12
+ // src/commands/config.ts
13
+ import { defineCommand } from "citty";
14
+ function redactKey(key) {
15
+ if (!key) return "<unset>";
16
+ if (key.length <= 8) return "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
17
+ return key.slice(0, 8) + "\u2022\u2022\u2022\u2022" + key.slice(-4);
18
+ }
19
+ var configCommand = defineCommand({
20
+ meta: {
21
+ name: "config",
22
+ description: "Manage CLI profiles and settings."
23
+ },
24
+ subCommands: {
25
+ list: defineCommand({
26
+ meta: { name: "list", description: "List all profiles (keys redacted)." },
27
+ args: { ...GLOBAL_FLAGS },
28
+ async run({ args }) {
29
+ const cfg = await readConfig();
30
+ if (!cfg) {
31
+ process.stderr.write("No config file found. Run `curviate login` to create one.\n");
32
+ return;
33
+ }
34
+ const json = args.json ?? !process.stdout.isTTY;
35
+ if (json) {
36
+ const redacted = {};
37
+ for (const [name, profile] of Object.entries(cfg.profiles)) {
38
+ if (!profile) continue;
39
+ redacted[name] = {
40
+ ...profile,
41
+ apiKey: redactKey(profile.apiKey),
42
+ ...name === cfg.active ? { active: true } : {}
43
+ };
44
+ }
45
+ process.stdout.write(JSON.stringify({ active: cfg.active, profiles: redacted }) + "\n");
46
+ } else {
47
+ for (const [name, profile] of Object.entries(cfg.profiles)) {
48
+ if (!profile) continue;
49
+ const marker = name === cfg.active ? " (active)" : "";
50
+ process.stdout.write(`${name}${marker}
51
+ `);
52
+ process.stdout.write(` apiKey: ${redactKey(profile.apiKey)}
53
+ `);
54
+ if (profile.account) process.stdout.write(` account: ${profile.account}
55
+ `);
56
+ if (profile.baseUrl) process.stdout.write(` baseUrl: ${profile.baseUrl}
57
+ `);
58
+ if (profile.timeout) process.stdout.write(` timeout: ${profile.timeout}
59
+ `);
60
+ }
61
+ }
62
+ }
63
+ }),
64
+ path: defineCommand({
65
+ meta: { name: "path", description: "Print the config file path." },
66
+ async run() {
67
+ process.stdout.write(getConfigPath() + "\n");
68
+ }
69
+ }),
70
+ use: defineCommand({
71
+ meta: { name: "use", description: "Set the active profile." },
72
+ args: {
73
+ name: { type: "positional", description: "Profile name to activate." }
74
+ },
75
+ async run({ args }) {
76
+ const name = args.name;
77
+ try {
78
+ await setActiveProfile(name);
79
+ process.stderr.write(`Switched to profile "${name}".
80
+ `);
81
+ } catch (err) {
82
+ process.stderr.write(
83
+ `error: ${err instanceof Error ? err.message : "unknown error"}
84
+ `
85
+ );
86
+ process.exit(2);
87
+ }
88
+ }
89
+ }),
90
+ rename: defineCommand({
91
+ meta: { name: "rename", description: "Rename a profile." },
92
+ args: {
93
+ old: { type: "positional", description: "Current profile name." },
94
+ new: { type: "positional", description: "New profile name." }
95
+ },
96
+ async run({ args }) {
97
+ const oldName = args.old;
98
+ const newName = args.new;
99
+ try {
100
+ await renameProfile(oldName, newName);
101
+ process.stderr.write(`Renamed profile "${oldName}" to "${newName}".
102
+ `);
103
+ } catch (err) {
104
+ process.stderr.write(
105
+ `error: ${err instanceof Error ? err.message : "unknown error"}
106
+ `
107
+ );
108
+ process.exit(2);
109
+ }
110
+ }
111
+ }),
112
+ "set-account": defineCommand({
113
+ meta: {
114
+ name: "set-account",
115
+ description: "Set the default account on a profile."
116
+ },
117
+ args: {
118
+ ...GLOBAL_FLAGS,
119
+ account: {
120
+ type: "positional",
121
+ description: "Account id to set as default."
122
+ }
123
+ },
124
+ async run({ args }) {
125
+ const cfg = await readConfig();
126
+ if (!cfg) {
127
+ process.stderr.write("No config file. Run `curviate login` first.\n");
128
+ process.exit(2);
129
+ }
130
+ const profileName = args.profile ?? cfg.active;
131
+ const account = args.account;
132
+ try {
133
+ await updateProfileField(profileName, "account", account);
134
+ process.stderr.write(`Set account "${account}" on profile "${profileName}".
135
+ `);
136
+ } catch (err) {
137
+ process.stderr.write(
138
+ `error: ${err instanceof Error ? err.message : "unknown error"}
139
+ `
140
+ );
141
+ process.exit(2);
142
+ }
143
+ }
144
+ }),
145
+ "set-base-url": defineCommand({
146
+ meta: {
147
+ name: "set-base-url",
148
+ description: "Set or clear the base URL on a profile."
149
+ },
150
+ args: {
151
+ ...GLOBAL_FLAGS,
152
+ url: {
153
+ type: "positional",
154
+ description: 'Base URL to set, or "" to clear.',
155
+ required: false
156
+ },
157
+ reset: {
158
+ type: "boolean",
159
+ description: "Clear the base URL (reset to SDK default).",
160
+ default: false
161
+ }
162
+ },
163
+ async run({ args }) {
164
+ const cfg = await readConfig();
165
+ if (!cfg) {
166
+ process.stderr.write("No config file. Run `curviate login` first.\n");
167
+ process.exit(2);
168
+ }
169
+ const profileName = args.profile ?? cfg.active;
170
+ const reset = args.reset;
171
+ const url = reset ? void 0 : args.url ?? "";
172
+ try {
173
+ await updateProfileField(
174
+ profileName,
175
+ "baseUrl",
176
+ url === "" ? void 0 : url
177
+ );
178
+ if (url === void 0 || url === "") {
179
+ process.stderr.write(
180
+ `Cleared baseUrl on profile "${profileName}" \u2014 using API default.
181
+ `
182
+ );
183
+ } else {
184
+ process.stderr.write(
185
+ `Set baseUrl to "${url}" on profile "${profileName}".
186
+ `
187
+ );
188
+ }
189
+ } catch (err) {
190
+ process.stderr.write(
191
+ `error: ${err instanceof Error ? err.message : "unknown error"}
192
+ `
193
+ );
194
+ process.exit(2);
195
+ }
196
+ }
197
+ }),
198
+ reset: defineCommand({
199
+ meta: {
200
+ name: "reset",
201
+ description: "Remove the config file (or a single profile)."
202
+ },
203
+ args: {
204
+ ...GLOBAL_FLAGS,
205
+ profile: {
206
+ type: "string",
207
+ description: "Remove only this profile instead of the whole file."
208
+ },
209
+ yes: {
210
+ type: "boolean",
211
+ description: "Skip the confirmation prompt.",
212
+ default: false
213
+ }
214
+ },
215
+ async run({ args }) {
216
+ const profileName = args.profile;
217
+ const yes = args.yes;
218
+ if (!yes && process.stdin.isTTY) {
219
+ const target = profileName ? `profile "${profileName}"` : "the entire config file";
220
+ process.stderr.write(`Remove ${target}? [y/N] `);
221
+ const answer = await new Promise((resolve) => {
222
+ process.stdin.setEncoding("utf8");
223
+ process.stdin.once("data", (chunk) => {
224
+ resolve(chunk.trim().toLowerCase());
225
+ });
226
+ });
227
+ if (answer !== "y" && answer !== "yes") {
228
+ process.stderr.write("Aborted.\n");
229
+ return;
230
+ }
231
+ }
232
+ if (profileName) {
233
+ await removeProfile(profileName);
234
+ process.stderr.write(`Removed profile "${profileName}".
235
+ `);
236
+ } else {
237
+ const { unlink } = await import("fs/promises");
238
+ try {
239
+ await unlink(getConfigPath());
240
+ process.stderr.write("Config file removed.\n");
241
+ } catch (err) {
242
+ const e = err;
243
+ if (e.code !== "ENOENT") {
244
+ process.stderr.write(`error: could not remove config file: ${e.message}
245
+ `);
246
+ process.exit(1);
247
+ }
248
+ process.stderr.write("No config file to remove.\n");
249
+ }
250
+ }
251
+ }
252
+ })
253
+ },
254
+ async run() {
255
+ process.stderr.write(
256
+ "Usage: curviate config <subcommand>\n list List all profiles (keys redacted)\n path Print config file path\n use <name> Set active profile\n rename <old> <new>\n set-account <acc>\n set-base-url [<url>] [--reset]\n reset [--profile <name>] [--yes]\n"
257
+ );
258
+ }
259
+ });
260
+ export {
261
+ configCommand
262
+ };
@@ -0,0 +1,348 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ buildPreviewOutput
4
+ } from "./chunk-R3VLWLVV.js";
5
+ import {
6
+ resolveIdentifier
7
+ } from "./chunk-BNUTM6KD.js";
8
+ import {
9
+ streamAll
10
+ } from "./chunk-SND3NHCT.js";
11
+ import {
12
+ createClient,
13
+ renderError,
14
+ renderSuccess,
15
+ renderUnexpectedError,
16
+ resolveEffectiveConfig
17
+ } from "./chunk-2NCPJJPC.js";
18
+ import {
19
+ GLOBAL_FLAGS
20
+ } from "./chunk-6JNCLLNY.js";
21
+
22
+ // src/commands/connect.ts
23
+ import { defineCommand } from "citty";
24
+ function buildOutputStreams() {
25
+ return {
26
+ stdout: { write: (s) => process.stdout.write(s) },
27
+ stderr: { write: (s) => process.stderr.write(s) }
28
+ };
29
+ }
30
+ function requireAccount(account, out) {
31
+ if (!account) {
32
+ out.stderr.write("error: --account is required for this command. Set it via --account, CURVIATE_ACCOUNT, or `curviate config set-account`.\n");
33
+ process.exit(2);
34
+ }
35
+ return account;
36
+ }
37
+ function rejectPreviewOnRead(preview, out) {
38
+ if (preview) {
39
+ out.stderr.write("error: --preview is only valid on write commands (mutations). Reads just run.\n");
40
+ process.exit(2);
41
+ }
42
+ }
43
+ function resolveOutputOpts(flags) {
44
+ return {
45
+ json: (flags.json ?? false) || !process.stdout.isTTY,
46
+ isTTY: process.stdout.isTTY ?? false,
47
+ fields: flags.fields
48
+ };
49
+ }
50
+ async function runConnectSend(client, flags, out) {
51
+ const accountId = requireAccount(flags.account, out);
52
+ const rawId = flags.id ?? "";
53
+ const resolvedId = resolveIdentifier(rawId);
54
+ const body = { recipient_identifier: resolvedId };
55
+ if (flags.note) body["message"] = flags.note;
56
+ if (flags.preview) {
57
+ const preview = buildPreviewOutput({
58
+ method: "invites.send",
59
+ args: { id: resolvedId },
60
+ body,
61
+ account: accountId
62
+ });
63
+ out.stdout.write(JSON.stringify(preview) + "\n");
64
+ return;
65
+ }
66
+ const ns = client.account(accountId);
67
+ const outOpts = resolveOutputOpts(flags);
68
+ try {
69
+ const result = await ns.invites.send(body);
70
+ renderSuccess(result, outOpts, out);
71
+ } catch (err) {
72
+ const { CurviateError } = await import("@curviate/sdk");
73
+ if (err instanceof CurviateError) {
74
+ const { getExitCode } = await import("./exit-codes-NFIR57ZA.js");
75
+ renderError(err, outOpts, out);
76
+ process.exit(getExitCode(err.code));
77
+ }
78
+ renderUnexpectedError(err, out);
79
+ process.exit(1);
80
+ }
81
+ }
82
+ async function runConnectSent(client, flags, out) {
83
+ rejectPreviewOnRead(flags.preview, out);
84
+ const accountId = requireAccount(flags.account, out);
85
+ const ns = client.account(accountId);
86
+ const outOpts = resolveOutputOpts(flags);
87
+ const all = flags.all ?? false;
88
+ const maxPages = flags["max-pages"] ? parseInt(flags["max-pages"], 10) : 100;
89
+ const limit = flags.limit ? parseInt(flags.limit, 10) : void 0;
90
+ const cursor = flags.cursor;
91
+ const params = {};
92
+ if (limit !== void 0) params["limit"] = limit;
93
+ if (cursor) params["cursor"] = cursor;
94
+ try {
95
+ if (all) {
96
+ const fn = (p) => ns.invites.listSent(p);
97
+ for await (const item of streamAll(fn, params, {
98
+ maxPages,
99
+ onTruncated: (msg) => out.stderr.write(msg + "\n")
100
+ })) {
101
+ out.stdout.write(JSON.stringify(item) + "\n");
102
+ }
103
+ } else {
104
+ const result = await ns.invites.listSent(params);
105
+ renderSuccess(result, outOpts, out);
106
+ }
107
+ } catch (err) {
108
+ const { CurviateError } = await import("@curviate/sdk");
109
+ if (err instanceof CurviateError) {
110
+ const { getExitCode } = await import("./exit-codes-NFIR57ZA.js");
111
+ renderError(err, outOpts, out);
112
+ process.exit(getExitCode(err.code));
113
+ }
114
+ renderUnexpectedError(err, out);
115
+ process.exit(1);
116
+ }
117
+ }
118
+ async function runConnectReceived(client, flags, out) {
119
+ rejectPreviewOnRead(flags.preview, out);
120
+ const accountId = requireAccount(flags.account, out);
121
+ const ns = client.account(accountId);
122
+ const outOpts = resolveOutputOpts(flags);
123
+ const all = flags.all ?? false;
124
+ const maxPages = flags["max-pages"] ? parseInt(flags["max-pages"], 10) : 100;
125
+ const limit = flags.limit ? parseInt(flags.limit, 10) : void 0;
126
+ const cursor = flags.cursor;
127
+ const params = {};
128
+ if (limit !== void 0) params["limit"] = limit;
129
+ if (cursor) params["cursor"] = cursor;
130
+ try {
131
+ if (all) {
132
+ const fn = (p) => ns.invites.listReceived(p);
133
+ for await (const item of streamAll(fn, params, {
134
+ maxPages,
135
+ onTruncated: (msg) => out.stderr.write(msg + "\n")
136
+ })) {
137
+ out.stdout.write(JSON.stringify(item) + "\n");
138
+ }
139
+ } else {
140
+ const result = await ns.invites.listReceived(params);
141
+ renderSuccess(result, outOpts, out);
142
+ }
143
+ } catch (err) {
144
+ const { CurviateError } = await import("@curviate/sdk");
145
+ if (err instanceof CurviateError) {
146
+ const { getExitCode } = await import("./exit-codes-NFIR57ZA.js");
147
+ renderError(err, outOpts, out);
148
+ process.exit(getExitCode(err.code));
149
+ }
150
+ renderUnexpectedError(err, out);
151
+ process.exit(1);
152
+ }
153
+ }
154
+ async function runConnectRespond(client, flags, out) {
155
+ const accountId = requireAccount(flags.account, out);
156
+ const invitationId = flags.id ?? "";
157
+ const action = flags.action ?? "";
158
+ if (flags.preview) {
159
+ const preview = buildPreviewOutput({
160
+ method: "invites.respond",
161
+ args: { invitation_id: invitationId },
162
+ body: { action },
163
+ account: accountId
164
+ });
165
+ out.stdout.write(JSON.stringify(preview) + "\n");
166
+ return;
167
+ }
168
+ const ns = client.account(accountId);
169
+ const outOpts = resolveOutputOpts(flags);
170
+ try {
171
+ const result = await ns.invites.respond(invitationId, { action });
172
+ renderSuccess(result, outOpts, out);
173
+ } catch (err) {
174
+ const { CurviateError } = await import("@curviate/sdk");
175
+ if (err instanceof CurviateError) {
176
+ const { getExitCode } = await import("./exit-codes-NFIR57ZA.js");
177
+ renderError(err, outOpts, out);
178
+ process.exit(getExitCode(err.code));
179
+ }
180
+ renderUnexpectedError(err, out);
181
+ process.exit(1);
182
+ }
183
+ }
184
+ async function runConnectCancel(client, flags, out) {
185
+ const accountId = requireAccount(flags.account, out);
186
+ const invitationId = flags.id ?? "";
187
+ if (flags.preview) {
188
+ const preview = buildPreviewOutput({
189
+ method: "invites.cancel",
190
+ args: { invitation_id: invitationId },
191
+ body: {},
192
+ account: accountId
193
+ });
194
+ out.stdout.write(JSON.stringify(preview) + "\n");
195
+ return;
196
+ }
197
+ const ns = client.account(accountId);
198
+ const outOpts = resolveOutputOpts(flags);
199
+ try {
200
+ const result = await ns.invites.cancel(invitationId);
201
+ renderSuccess(result, outOpts, out);
202
+ } catch (err) {
203
+ const { CurviateError } = await import("@curviate/sdk");
204
+ if (err instanceof CurviateError) {
205
+ const { getExitCode } = await import("./exit-codes-NFIR57ZA.js");
206
+ renderError(err, outOpts, out);
207
+ process.exit(getExitCode(err.code));
208
+ }
209
+ renderUnexpectedError(err, out);
210
+ process.exit(1);
211
+ }
212
+ }
213
+ var connectSentCommand = defineCommand({
214
+ meta: { name: "sent", description: "List sent connection invitations." },
215
+ args: { ...GLOBAL_FLAGS },
216
+ async run({ args }) {
217
+ const flags = args;
218
+ const cfg = await resolveEffectiveConfig({
219
+ apiKey: flags["api-key"],
220
+ baseUrl: flags["base-url"],
221
+ timeout: flags.timeout,
222
+ account: flags.account,
223
+ profile: flags.profile
224
+ });
225
+ if (!cfg.apiKey) {
226
+ process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
227
+ process.exit(3);
228
+ }
229
+ const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
230
+ const out = buildOutputStreams();
231
+ await runConnectSent(client, { ...flags, account: flags.account ?? cfg.account }, out);
232
+ }
233
+ });
234
+ var connectReceivedCommand = defineCommand({
235
+ meta: { name: "received", description: "List received connection invitations." },
236
+ args: { ...GLOBAL_FLAGS },
237
+ async run({ args }) {
238
+ const flags = args;
239
+ const cfg = await resolveEffectiveConfig({
240
+ apiKey: flags["api-key"],
241
+ baseUrl: flags["base-url"],
242
+ timeout: flags.timeout,
243
+ account: flags.account,
244
+ profile: flags.profile
245
+ });
246
+ if (!cfg.apiKey) {
247
+ process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
248
+ process.exit(3);
249
+ }
250
+ const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
251
+ const out = buildOutputStreams();
252
+ await runConnectReceived(client, { ...flags, account: flags.account ?? cfg.account }, out);
253
+ }
254
+ });
255
+ var connectRespondCommand = defineCommand({
256
+ meta: { name: "respond", description: "Accept or decline a received invitation." },
257
+ args: {
258
+ ...GLOBAL_FLAGS,
259
+ id: { type: "positional", description: "Invitation id to respond to." },
260
+ action: { type: "string", description: "Response action: accept or decline.", required: true }
261
+ },
262
+ async run({ args }) {
263
+ const flags = args;
264
+ const cfg = await resolveEffectiveConfig({
265
+ apiKey: flags["api-key"],
266
+ baseUrl: flags["base-url"],
267
+ timeout: flags.timeout,
268
+ account: flags.account,
269
+ profile: flags.profile
270
+ });
271
+ if (!cfg.apiKey) {
272
+ process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
273
+ process.exit(3);
274
+ }
275
+ const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
276
+ const out = buildOutputStreams();
277
+ await runConnectRespond(client, { ...flags, account: flags.account ?? cfg.account }, out);
278
+ }
279
+ });
280
+ var connectCancelCommand = defineCommand({
281
+ meta: { name: "cancel", description: "Cancel a sent invitation." },
282
+ args: {
283
+ ...GLOBAL_FLAGS,
284
+ id: { type: "positional", description: "Invitation id to cancel." }
285
+ },
286
+ async run({ args }) {
287
+ const flags = args;
288
+ const cfg = await resolveEffectiveConfig({
289
+ apiKey: flags["api-key"],
290
+ baseUrl: flags["base-url"],
291
+ timeout: flags.timeout,
292
+ account: flags.account,
293
+ profile: flags.profile
294
+ });
295
+ if (!cfg.apiKey) {
296
+ process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
297
+ process.exit(3);
298
+ }
299
+ const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
300
+ const out = buildOutputStreams();
301
+ await runConnectCancel(client, { ...flags, account: flags.account ?? cfg.account }, out);
302
+ }
303
+ });
304
+ var connectCommand = defineCommand({
305
+ meta: { name: "connect", description: "Send or manage connection invitations." },
306
+ args: {
307
+ ...GLOBAL_FLAGS,
308
+ id: { type: "positional", description: "Member identifier (URL, slug, or URN).", required: false },
309
+ note: { type: "string", description: "Optional invitation note (\u2264300 characters)." }
310
+ },
311
+ subCommands: {
312
+ sent: connectSentCommand,
313
+ received: connectReceivedCommand,
314
+ respond: connectRespondCommand,
315
+ cancel: connectCancelCommand
316
+ },
317
+ async run({ args }) {
318
+ const flags = args;
319
+ if (!flags.id) {
320
+ process.stderr.write(
321
+ "Usage: curviate connect <id> [--note <text>]\n curviate connect sent\n curviate connect received\n curviate connect respond <invitation_id> --action accept|decline\n curviate connect cancel <invitation_id>\n"
322
+ );
323
+ return;
324
+ }
325
+ const cfg = await resolveEffectiveConfig({
326
+ apiKey: flags["api-key"],
327
+ baseUrl: flags["base-url"],
328
+ timeout: flags.timeout,
329
+ account: flags.account,
330
+ profile: flags.profile
331
+ });
332
+ if (!cfg.apiKey) {
333
+ process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
334
+ process.exit(3);
335
+ }
336
+ const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
337
+ const out = buildOutputStreams();
338
+ await runConnectSend(client, { ...flags, account: flags.account ?? cfg.account }, out);
339
+ }
340
+ });
341
+ export {
342
+ connectCommand,
343
+ runConnectCancel,
344
+ runConnectReceived,
345
+ runConnectRespond,
346
+ runConnectSend,
347
+ runConnectSent
348
+ };