@curviate/cli 0.47.0 → 0.49.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/CHANGELOG.md +231 -1
- package/README.md +136 -88
- package/dist/{account-RFJ63QYL.js → account-2BH2Q6VG.js} +41 -31
- package/dist/chunk-3RCW7URJ.js +41 -0
- package/dist/{chunk-UJOTQPL6.js → chunk-5ZGTU4VD.js} +47 -14
- package/dist/chunk-D2S5OCYU.js +38 -0
- package/dist/{chunk-HOQ7EUHJ.js → chunk-FDJMAF7D.js} +1 -0
- package/dist/{chunk-ERBYEC5P.js → chunk-JYKYD57J.js} +1 -1
- package/dist/chunk-MGB6FE4A.js +58 -0
- package/dist/chunk-NNV2OYEF.js +23 -0
- package/dist/{chunk-76SWLAZ6.js → chunk-RXWODUWA.js} +43 -1
- package/dist/{chunk-V3MVOVQT.js → chunk-SA2QHAXG.js} +8 -1
- package/dist/chunk-TEAWYLPO.js +1493 -0
- package/dist/{chunk-PD2I5TYC.js → chunk-V7FJWTZW.js} +3 -3
- package/dist/{chunk-TC4ZPUWI.js → chunk-Y7MZZRYR.js} +21 -80
- package/dist/{chunk-FXYK2GTO.js → chunk-Z7OQSWBD.js} +38 -33
- package/dist/chunk-ZYURL5VK.js +83 -0
- package/dist/cli.js +79 -98
- package/dist/{comment-MCXE7B7V.js → comment-MRDPDA33.js} +29 -24
- package/dist/{company-EUUN372H.js → company-2AEHSGHA.js} +57 -52
- package/dist/{config-K4G3VSBA.js → config-NRBKHXES.js} +13 -5
- package/dist/{connect-2AL7XVJO.js → connect-4XEBV5V3.js} +42 -38
- package/dist/core-RGU2SCBN.js +46 -0
- package/dist/{doctor-WPYI7X2T.js → doctor-BZ4DA7DV.js} +9 -5
- package/dist/document-RKHRWXNT.js +27 -0
- package/dist/{draft-G65DVXT7.js → draft-C5N6EOO5.js} +27 -22
- package/dist/enrollment-BNQOUKI7.js +472 -0
- package/dist/examples-NIMSIXMV.js +53 -0
- package/dist/{exit-codes-AW6KHDDN.js → exit-codes-TLMKTLRI.js} +1 -1
- package/dist/{feed-HV24WME4.js → feed-DFUU7SUJ.js} +15 -11
- package/dist/{group-HADXNVJW.js → group-CSD2OWOZ.js} +17 -13
- package/dist/{inbox-G3EE54OB.js → inbox-SNSPWI7J.js} +23 -19
- package/dist/{inboxes-237XOBTP.js → inboxes-RIRHPS4H.js} +18 -14
- package/dist/{job-LIN6RWD7.js → job-6PNXXZNF.js} +31 -27
- package/dist/{login-OHAHNBRW.js → login-Y7JBAHCW.js} +10 -5
- package/dist/{message-U2O2JQSW.js → message-2IK4MBBG.js} +10 -8
- package/dist/motion-7ATUXO6R.js +946 -0
- package/dist/{notification-3VG32LWM.js → notification-VYK5NDEB.js} +19 -15
- package/dist/{post-ECDK2KJL.js → post-AN6T2OJF.js} +35 -30
- package/dist/{profile-JOHS6SDW.js → profile-UQY64642.js} +46 -42
- package/dist/{recruiter-7VXEIXN3.js → recruiter-OY4RN5HH.js} +122 -119
- package/dist/{sales-nav-K4BMBH7R.js → sales-nav-KLODLYMW.js} +36 -30
- package/dist/{search-C2UYO6PI.js → search-NWP5S6CF.js} +68 -58
- package/dist/{setup-GYEZFDEN.js → setup-YPPFLH2N.js} +14 -9
- package/dist/{webhook-KCOQOH7D.js → webhook-OHKBL3YS.js} +51 -55
- package/package.json +2 -2
- package/dist/chunk-KJ24DIAJ.js +0 -60
- package/dist/examples-IJL3A6SZ.js +0 -18
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
readablePage
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SA2QHAXG.js";
|
|
5
5
|
import {
|
|
6
6
|
getExitCode
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-RXWODUWA.js";
|
|
8
8
|
import {
|
|
9
9
|
assertNoStdinPlaceholder
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ZYURL5VK.js";
|
|
11
11
|
|
|
12
12
|
// src/lib/path-safety.ts
|
|
13
13
|
var UNSAFE_CHARS = /[\u0000-\u0020\u007F/\\?#%]/;
|
|
@@ -1,78 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// src/lib/stdin.ts
|
|
4
|
-
var STDIN_SENTINEL = "__curviate_stdin__";
|
|
5
|
-
async function defaultReadStdin() {
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
const chunks = [];
|
|
8
|
-
process.stdin.on("data", (chunk) => {
|
|
9
|
-
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
10
|
-
});
|
|
11
|
-
process.stdin.on("end", () => {
|
|
12
|
-
const full = Buffer.concat(chunks).toString("utf8");
|
|
13
|
-
resolve(full.replace(/\n+$/, ""));
|
|
14
|
-
});
|
|
15
|
-
process.stdin.on("error", reject);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
function isStdinToken(value) {
|
|
19
|
-
return value === "-" || value === STDIN_SENTINEL;
|
|
20
|
-
}
|
|
21
|
-
function declaresStdinArg(def) {
|
|
22
|
-
return def?.stdinArg === true;
|
|
23
|
-
}
|
|
24
|
-
function restoreLiteralDashes(args, argsDef) {
|
|
25
|
-
const declaring = /* @__PURE__ */ new Set();
|
|
26
|
-
const positionalNames = [];
|
|
27
|
-
for (const [name, def] of Object.entries(argsDef)) {
|
|
28
|
-
if (def?.type === "positional") positionalNames.push(name);
|
|
29
|
-
if (!declaresStdinArg(def)) continue;
|
|
30
|
-
declaring.add(name);
|
|
31
|
-
const alias = def.alias;
|
|
32
|
-
if (typeof alias === "string") declaring.add(alias);
|
|
33
|
-
else if (Array.isArray(alias)) for (const a of alias) declaring.add(a);
|
|
34
|
-
}
|
|
35
|
-
const put = (value) => {
|
|
36
|
-
if (value === STDIN_SENTINEL) return "-";
|
|
37
|
-
if (Array.isArray(value)) return value.map((e) => e === STDIN_SENTINEL ? "-" : e);
|
|
38
|
-
return value;
|
|
39
|
-
};
|
|
40
|
-
for (const key of Object.keys(args)) {
|
|
41
|
-
if (key === "_" || declaring.has(key)) continue;
|
|
42
|
-
args[key] = put(args[key]);
|
|
43
|
-
}
|
|
44
|
-
const rest = args["_"];
|
|
45
|
-
if (Array.isArray(rest)) {
|
|
46
|
-
for (let i = 0; i < rest.length; i++) {
|
|
47
|
-
const name = positionalNames[i];
|
|
48
|
-
if (name !== void 0 && declaring.has(name)) continue;
|
|
49
|
-
if (rest[i] === STDIN_SENTINEL) rest[i] = "-";
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function assertNoStdinPlaceholder(where, values) {
|
|
54
|
-
if (!values.some((v) => typeof v === "string" && v.includes(STDIN_SENTINEL))) return;
|
|
55
|
-
process.stderr.write(
|
|
56
|
-
`error: refusing to continue. ${where} contains "${STDIN_SENTINEL}", the internal placeholder the CLI substitutes for a bare "-" while it parses arguments.
|
|
57
|
-
`
|
|
58
|
-
);
|
|
59
|
-
process.stderr.write(
|
|
60
|
-
`hint: that placeholder means "read this value from stdin" and must never leave the process. Check the value you supplied, including environment variables such as CURVIATE_ACCOUNT and CURVIATE_API_KEY. If you did not supply it yourself, this is a bug in the CLI. Nothing was sent or written.
|
|
61
|
-
`
|
|
62
|
-
);
|
|
63
|
-
process.exit(1);
|
|
64
|
-
}
|
|
65
|
-
async function resolveTextOrStdin(rawText, out, readStdin) {
|
|
66
|
-
if (!isStdinToken(rawText)) return rawText;
|
|
67
|
-
const reader = readStdin ?? defaultReadStdin;
|
|
68
|
-
const text = await reader();
|
|
69
|
-
if (!text) {
|
|
70
|
-
out.stderr.write("error: stdin: empty input\n");
|
|
71
|
-
process.exit(2);
|
|
72
|
-
}
|
|
73
|
-
return text;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
3
|
// src/lib/global-flags.ts
|
|
77
4
|
var GLOBAL_FLAGS = {
|
|
78
5
|
// Auth / config
|
|
@@ -189,6 +116,21 @@ function readOnly(flags) {
|
|
|
189
116
|
delete rest.preview;
|
|
190
117
|
return rest;
|
|
191
118
|
}
|
|
119
|
+
var writeKind = "read";
|
|
120
|
+
var recheck = "";
|
|
121
|
+
var poll = false;
|
|
122
|
+
var setWriteKind = (v, recheckWith = "", command = "") => void (writeKind = v, recheck = recheckWith, poll = command !== "" && recheckWith.startsWith(`${command} `));
|
|
123
|
+
var isPoll = () => poll;
|
|
124
|
+
var getWriteKind = () => writeKind;
|
|
125
|
+
var getRecheck = () => recheck;
|
|
126
|
+
var STATE_WRITES = {
|
|
127
|
+
"curviate account checkpoint solve": "curviate account checkpoint poll <account_id>",
|
|
128
|
+
"curviate account checkpoint poll": "curviate account checkpoint poll <account_id>",
|
|
129
|
+
"curviate account checkpoint request": "curviate account checkpoint poll <account_id>",
|
|
130
|
+
"curviate account connect-session poll": "curviate account connect-session poll --session <session_id>",
|
|
131
|
+
// Its answer says whether the Step was resumed, and what to wait for.
|
|
132
|
+
"curviate enrollment retry": "curviate enrollment get <enrollment_id>"
|
|
133
|
+
};
|
|
192
134
|
|
|
193
135
|
// src/lib/beta.ts
|
|
194
136
|
var BETA_CONSENT_HEADER = "X-Curviate-Beta";
|
|
@@ -257,12 +199,6 @@ function betaOverrideHeader() {
|
|
|
257
199
|
}
|
|
258
200
|
|
|
259
201
|
export {
|
|
260
|
-
STDIN_SENTINEL,
|
|
261
|
-
defaultReadStdin,
|
|
262
|
-
isStdinToken,
|
|
263
|
-
restoreLiteralDashes,
|
|
264
|
-
assertNoStdinPlaceholder,
|
|
265
|
-
resolveTextOrStdin,
|
|
266
202
|
parseBetaFlag,
|
|
267
203
|
setBetaOverride,
|
|
268
204
|
betaOverrideHeader,
|
|
@@ -271,5 +207,10 @@ export {
|
|
|
271
207
|
WRITE_FLAGS,
|
|
272
208
|
READ_SINGLE_FLAGS,
|
|
273
209
|
WRITE_SINGLE_FLAGS,
|
|
274
|
-
readOnly
|
|
210
|
+
readOnly,
|
|
211
|
+
setWriteKind,
|
|
212
|
+
isPoll,
|
|
213
|
+
getWriteKind,
|
|
214
|
+
getRecheck,
|
|
215
|
+
STATE_WRITES
|
|
275
216
|
};
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
BinaryOutputError,
|
|
4
|
-
writeBinaryOutput
|
|
5
|
-
} from "./chunk-UWO2D4HW.js";
|
|
6
|
-
import {
|
|
7
|
-
looksLikeCommandWord,
|
|
8
|
-
nearestSubcommand
|
|
9
|
-
} from "./chunk-HOQ7EUHJ.js";
|
|
10
2
|
import {
|
|
11
3
|
AttachError,
|
|
12
4
|
readAttachment,
|
|
13
5
|
toAttachmentPayload
|
|
14
6
|
} from "./chunk-5I6JJJIV.js";
|
|
7
|
+
import {
|
|
8
|
+
BinaryOutputError,
|
|
9
|
+
writeBinaryOutput
|
|
10
|
+
} from "./chunk-UWO2D4HW.js";
|
|
15
11
|
import {
|
|
16
12
|
normalizeChatId,
|
|
17
13
|
resolveIdentifier
|
|
18
14
|
} from "./chunk-UEAX6KUB.js";
|
|
19
15
|
import {
|
|
20
16
|
requireAccount
|
|
21
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-V7FJWTZW.js";
|
|
22
18
|
import {
|
|
23
19
|
buildPreviewOutput
|
|
24
20
|
} from "./chunk-TCUYH5GO.js";
|
|
@@ -29,17 +25,26 @@ import {
|
|
|
29
25
|
renderSuccess,
|
|
30
26
|
renderUnexpectedError,
|
|
31
27
|
resolveEffectiveConfig
|
|
32
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-SA2QHAXG.js";
|
|
33
29
|
import {
|
|
34
30
|
createClient,
|
|
35
31
|
downloadBinary
|
|
36
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-5ZGTU4VD.js";
|
|
37
33
|
import {
|
|
38
34
|
READ_SINGLE_FLAGS,
|
|
39
35
|
WRITE_FLAGS,
|
|
40
|
-
readOnly
|
|
36
|
+
readOnly
|
|
37
|
+
} from "./chunk-Y7MZZRYR.js";
|
|
38
|
+
import {
|
|
39
|
+
DESCRIPTIONS
|
|
40
|
+
} from "./chunk-D2S5OCYU.js";
|
|
41
|
+
import {
|
|
42
|
+
looksLikeCommandWord,
|
|
43
|
+
nearestSubcommand
|
|
44
|
+
} from "./chunk-FDJMAF7D.js";
|
|
45
|
+
import {
|
|
41
46
|
resolveTextOrStdin
|
|
42
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-ZYURL5VK.js";
|
|
43
48
|
|
|
44
49
|
// src/commands/message.ts
|
|
45
50
|
import { defineCommand } from "citty";
|
|
@@ -105,7 +110,7 @@ var MEMBER_PROVIDER_ID_RE = /^A[CDE][A-Za-z0-9_-]{4,}$/;
|
|
|
105
110
|
async function handleSdkError(err, outOpts, out) {
|
|
106
111
|
const { CurviateError } = await import("@curviate/sdk");
|
|
107
112
|
if (err instanceof CurviateError) {
|
|
108
|
-
const { getExitCode } = await import("./exit-codes-
|
|
113
|
+
const { getExitCode } = await import("./exit-codes-TLMKTLRI.js");
|
|
109
114
|
renderError(err, outOpts, out);
|
|
110
115
|
process.exit(getExitCode(err));
|
|
111
116
|
}
|
|
@@ -302,7 +307,7 @@ async function runMessageReact(client, flags, out) {
|
|
|
302
307
|
const messageId = flags.messageId ?? "";
|
|
303
308
|
const reaction = flags.emoji ?? flags.emojiAlias ?? "";
|
|
304
309
|
if (!reaction) {
|
|
305
|
-
out.stderr.write("error: a reaction is required. Pass it as `message react <chat_id> <message_id> <emoji>` (or --emoji <e>).\n");
|
|
310
|
+
out.stderr.write("error: a reaction is required. Pass it as `curviate core message react <chat_id> <message_id> <emoji>` (or --emoji <e>).\n");
|
|
306
311
|
process.exit(2);
|
|
307
312
|
return;
|
|
308
313
|
}
|
|
@@ -417,7 +422,7 @@ var messageNewCommand = defineCommand({
|
|
|
417
422
|
name: "new",
|
|
418
423
|
description: "Start a new chat with one or more members.",
|
|
419
424
|
examples: [
|
|
420
|
-
'curviate message new --to janesmith "Hi Jane, enjoyed your post on agent evals."'
|
|
425
|
+
'curviate core message new --to janesmith "Hi Jane, enjoyed your post on agent evals."'
|
|
421
426
|
]
|
|
422
427
|
},
|
|
423
428
|
args: {
|
|
@@ -458,7 +463,7 @@ var messageGetCommand = defineCommand({
|
|
|
458
463
|
name: "get",
|
|
459
464
|
description: "Get a message by ID.",
|
|
460
465
|
examples: [
|
|
461
|
-
"curviate message get 2-YTQ3ODU3Njgt MSG_ID"
|
|
466
|
+
"curviate core message get 2-YTQ3ODU3Njgt MSG_ID"
|
|
462
467
|
]
|
|
463
468
|
},
|
|
464
469
|
args: {
|
|
@@ -490,7 +495,7 @@ var messageEditCommand = defineCommand({
|
|
|
490
495
|
name: "edit",
|
|
491
496
|
description: "Edit a message (within the allowed window).",
|
|
492
497
|
examples: [
|
|
493
|
-
'curviate message edit 2-YTQ3ODU3Njgt MSG_ID "Thanks, that makes sense to me."'
|
|
498
|
+
'curviate core message edit 2-YTQ3ODU3Njgt MSG_ID "Thanks, that makes sense to me."'
|
|
494
499
|
]
|
|
495
500
|
},
|
|
496
501
|
args: {
|
|
@@ -523,7 +528,7 @@ var messageDeleteCommand = defineCommand({
|
|
|
523
528
|
name: "delete",
|
|
524
529
|
description: "Delete a message.",
|
|
525
530
|
examples: [
|
|
526
|
-
"curviate message delete 2-YTQ3ODU3Njgt MSG_ID"
|
|
531
|
+
"curviate core message delete 2-YTQ3ODU3Njgt MSG_ID"
|
|
527
532
|
]
|
|
528
533
|
},
|
|
529
534
|
args: {
|
|
@@ -555,7 +560,7 @@ var messageReactCommand = defineCommand({
|
|
|
555
560
|
name: "react",
|
|
556
561
|
description: "Add an emoji reaction to a message.",
|
|
557
562
|
examples: [
|
|
558
|
-
"curviate message react 2-YTQ3ODU3Njgt MSG_ID \u{1F44D}"
|
|
563
|
+
"curviate core message react 2-YTQ3ODU3Njgt MSG_ID \u{1F44D}"
|
|
559
564
|
],
|
|
560
565
|
requires: [
|
|
561
566
|
"The reaction: the <emoji> argument or --emoji."
|
|
@@ -596,7 +601,7 @@ var messageAttachmentCommand = defineCommand({
|
|
|
596
601
|
name: "attachment",
|
|
597
602
|
description: "Download a message attachment.",
|
|
598
603
|
examples: [
|
|
599
|
-
"curviate message attachment 2-YTQ3ODU3Njgt MSG_ID ATTACHMENT_ID -o attachment.pdf"
|
|
604
|
+
"curviate core message attachment 2-YTQ3ODU3Njgt MSG_ID ATTACHMENT_ID -o attachment.pdf"
|
|
600
605
|
]
|
|
601
606
|
},
|
|
602
607
|
args: {
|
|
@@ -635,7 +640,7 @@ var messageInMailCommand = defineCommand({
|
|
|
635
640
|
name: "inmail",
|
|
636
641
|
description: "Send an InMail to a member.",
|
|
637
642
|
examples: [
|
|
638
|
-
'curviate message inmail --to janesmith --subject "Agent tooling" "Hi Jane, a quick question about your eval setup."'
|
|
643
|
+
'curviate core message inmail --to janesmith --subject "Agent tooling" "Hi Jane, a quick question about your eval setup."'
|
|
639
644
|
]
|
|
640
645
|
},
|
|
641
646
|
args: {
|
|
@@ -670,9 +675,9 @@ var messageInMailCommand = defineCommand({
|
|
|
670
675
|
var messageSendCommand = defineCommand({
|
|
671
676
|
meta: {
|
|
672
677
|
name: "send",
|
|
673
|
-
description: 'Send a message to an existing chat. Pass a COMPANY_ chat id (from `inboxes chats`) to send as that company page instead of yourself, no separate flag needed. The output shows the acting identity: a company-page send prints "Sent as <name> (company page)", a personal send prints nothing new. See also: `inboxes chats` (discover a COMPANY_ chat id) and the Reply as a company page guide.',
|
|
678
|
+
description: 'Send a message to an existing chat. Pass a COMPANY_ chat id (from `curviate core inboxes chats`) to send as that company page instead of yourself, no separate flag needed. The output shows the acting identity: a company-page send prints "Sent as <name> (company page)", a personal send prints nothing new. See also: `curviate core inboxes chats` (discover a COMPANY_ chat id) and the Reply as a company page guide.',
|
|
674
679
|
examples: [
|
|
675
|
-
'curviate message send 2-YTQ3ODU3Njgt "Thanks, that makes sense."'
|
|
680
|
+
'curviate core message send 2-YTQ3ODU3Njgt "Thanks, that makes sense."'
|
|
676
681
|
]
|
|
677
682
|
},
|
|
678
683
|
args: {
|
|
@@ -708,7 +713,7 @@ var messageInMailBalanceCommand = defineCommand({
|
|
|
708
713
|
name: "inmail-balance",
|
|
709
714
|
description: "Get InMail credit balance.",
|
|
710
715
|
examples: [
|
|
711
|
-
"curviate message inmail-balance"
|
|
716
|
+
"curviate core message inmail-balance"
|
|
712
717
|
]
|
|
713
718
|
},
|
|
714
719
|
args: {
|
|
@@ -744,22 +749,22 @@ var MESSAGE_SUBCOMMANDS = [
|
|
|
744
749
|
"inmail",
|
|
745
750
|
"inmail-balance"
|
|
746
751
|
];
|
|
747
|
-
var MESSAGE_USAGE = 'Usage: curviate message new --to <attendee> "<text>" [--subject <s>] [--attach <file>...]\n curviate message send <chat_id> "<text>" [--attach <file>...]\n curviate message <chat_id> "<text>" [--attach <file>...]\n curviate message get <chat_id> <message_id>\n curviate message edit <chat_id> <message_id> "<text>"\n curviate message delete <chat_id> <message_id>\n curviate message react <chat_id> <message_id> <emoji>\n curviate message attachment <chat_id> <message_id> <attachment_id> [-o <file>]\n curviate message inmail --to <id> --subject <s> "<text>"\n curviate message inmail-balance\n';
|
|
752
|
+
var MESSAGE_USAGE = 'Usage: curviate core message new --to <attendee> "<text>" [--subject <s>] [--attach <file>...]\n curviate core message send <chat_id> "<text>" [--attach <file>...]\n curviate core message <chat_id> "<text>" [--attach <file>...]\n curviate core message get <chat_id> <message_id>\n curviate core message edit <chat_id> <message_id> "<text>"\n curviate core message delete <chat_id> <message_id>\n curviate core message react <chat_id> <message_id> <emoji>\n curviate core message attachment <chat_id> <message_id> <attachment_id> [-o <file>]\n curviate core message inmail --to <id> --subject <s> "<text>"\n curviate core message inmail-balance\n';
|
|
748
753
|
function guardBareMessageForm(chatId, out) {
|
|
749
754
|
if (!looksLikeCommandWord(chatId)) return;
|
|
750
755
|
const suggestion = nearestSubcommand(chatId, [...MESSAGE_SUBCOMMANDS]);
|
|
751
756
|
out.stderr.write(
|
|
752
|
-
`error: \`${chatId}\` is not a curviate message subcommand, and it is not a chat id (a chat id looks like 2-... or COMPANY_..., or a linkedin.com/messaging/thread/... URL).
|
|
757
|
+
`error: \`${chatId}\` is not a curviate core message subcommand, and it is not a chat id (a chat id looks like 2-... or COMPANY_..., or a linkedin.com/messaging/thread/... URL).
|
|
753
758
|
`
|
|
754
759
|
);
|
|
755
760
|
if (suggestion) {
|
|
756
|
-
out.stderr.write(`hint: did you mean \`curviate message ${suggestion}\`?
|
|
761
|
+
out.stderr.write(`hint: did you mean \`curviate core message ${suggestion}\`?
|
|
757
762
|
`);
|
|
758
763
|
} else if (chatId === "search") {
|
|
759
|
-
out.stderr.write("hint: to search your messages, use `curviate inbox search`.\n");
|
|
764
|
+
out.stderr.write("hint: to search your messages, use `curviate core inbox search`.\n");
|
|
760
765
|
}
|
|
761
766
|
out.stderr.write(
|
|
762
|
-
`hint: to send to a chat id this check does not recognise, name the action explicitly: curviate message send <chat_id> "<text>".
|
|
767
|
+
`hint: to send to a chat id this check does not recognise, name the action explicitly: curviate core message send <chat_id> "<text>".
|
|
763
768
|
`
|
|
764
769
|
);
|
|
765
770
|
out.stderr.write(MESSAGE_USAGE);
|
|
@@ -768,10 +773,10 @@ function guardBareMessageForm(chatId, out) {
|
|
|
768
773
|
var messageCommand = defineCommand({
|
|
769
774
|
meta: {
|
|
770
775
|
name: "message",
|
|
771
|
-
description:
|
|
776
|
+
description: DESCRIPTIONS.message,
|
|
772
777
|
examples: [
|
|
773
|
-
'curviate message 2-YTQ3ODU3Njgt "Thanks, that makes sense."',
|
|
774
|
-
'curviate message 2-YTQ3ODU3Njgt "See the attached brief." --attach brief.pdf'
|
|
778
|
+
'curviate core message 2-YTQ3ODU3Njgt "Thanks, that makes sense."',
|
|
779
|
+
'curviate core message 2-YTQ3ODU3Njgt "See the attached brief." --attach brief.pdf'
|
|
775
780
|
]
|
|
776
781
|
},
|
|
777
782
|
args: {
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/lib/stdin.ts
|
|
4
|
+
var STDIN_SENTINEL = "__curviate_stdin__";
|
|
5
|
+
async function defaultReadStdin() {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const chunks = [];
|
|
8
|
+
process.stdin.on("data", (chunk) => {
|
|
9
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
10
|
+
});
|
|
11
|
+
process.stdin.on("end", () => {
|
|
12
|
+
const full = Buffer.concat(chunks).toString("utf8");
|
|
13
|
+
resolve(full.replace(/\n+$/, ""));
|
|
14
|
+
});
|
|
15
|
+
process.stdin.on("error", reject);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function isStdinToken(value) {
|
|
19
|
+
return value === "-" || value === STDIN_SENTINEL;
|
|
20
|
+
}
|
|
21
|
+
function declaresStdinArg(def) {
|
|
22
|
+
return def?.stdinArg === true;
|
|
23
|
+
}
|
|
24
|
+
function restoreLiteralDashes(args, argsDef) {
|
|
25
|
+
const declaring = /* @__PURE__ */ new Set();
|
|
26
|
+
const positionalNames = [];
|
|
27
|
+
for (const [name, def] of Object.entries(argsDef)) {
|
|
28
|
+
if (def?.type === "positional") positionalNames.push(name);
|
|
29
|
+
if (!declaresStdinArg(def)) continue;
|
|
30
|
+
declaring.add(name);
|
|
31
|
+
const alias = def.alias;
|
|
32
|
+
if (typeof alias === "string") declaring.add(alias);
|
|
33
|
+
else if (Array.isArray(alias)) for (const a of alias) declaring.add(a);
|
|
34
|
+
}
|
|
35
|
+
const put = (value) => {
|
|
36
|
+
if (value === STDIN_SENTINEL) return "-";
|
|
37
|
+
if (Array.isArray(value)) return value.map((e) => e === STDIN_SENTINEL ? "-" : e);
|
|
38
|
+
return value;
|
|
39
|
+
};
|
|
40
|
+
for (const key of Object.keys(args)) {
|
|
41
|
+
if (key === "_" || declaring.has(key)) continue;
|
|
42
|
+
args[key] = put(args[key]);
|
|
43
|
+
}
|
|
44
|
+
const rest = args["_"];
|
|
45
|
+
if (Array.isArray(rest)) {
|
|
46
|
+
for (let i = 0; i < rest.length; i++) {
|
|
47
|
+
const name = positionalNames[i];
|
|
48
|
+
if (name !== void 0 && declaring.has(name)) continue;
|
|
49
|
+
if (rest[i] === STDIN_SENTINEL) rest[i] = "-";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function assertNoStdinPlaceholder(where, values) {
|
|
54
|
+
if (!values.some((v) => typeof v === "string" && v.includes(STDIN_SENTINEL))) return;
|
|
55
|
+
process.stderr.write(
|
|
56
|
+
`error: refusing to continue. ${where} contains "${STDIN_SENTINEL}", the internal placeholder the CLI substitutes for a bare "-" while it parses arguments.
|
|
57
|
+
`
|
|
58
|
+
);
|
|
59
|
+
process.stderr.write(
|
|
60
|
+
`hint: that placeholder means "read this value from stdin" and must never leave the process. Check the value you supplied, including environment variables such as CURVIATE_ACCOUNT and CURVIATE_API_KEY. If you did not supply it yourself, this is a bug in the CLI. Nothing was sent or written.
|
|
61
|
+
`
|
|
62
|
+
);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
async function resolveTextOrStdin(rawText, out, readStdin) {
|
|
66
|
+
if (!isStdinToken(rawText)) return rawText;
|
|
67
|
+
const reader = readStdin ?? defaultReadStdin;
|
|
68
|
+
const text = await reader();
|
|
69
|
+
if (!text) {
|
|
70
|
+
out.stderr.write("error: stdin: empty input\n");
|
|
71
|
+
process.exit(2);
|
|
72
|
+
}
|
|
73
|
+
return text;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
STDIN_SENTINEL,
|
|
78
|
+
defaultReadStdin,
|
|
79
|
+
isStdinToken,
|
|
80
|
+
restoreLiteralDashes,
|
|
81
|
+
assertNoStdinPlaceholder,
|
|
82
|
+
resolveTextOrStdin
|
|
83
|
+
};
|