@curviate/cli 0.47.0 → 0.48.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 +174 -1
- package/README.md +101 -87
- package/dist/{account-RFJ63QYL.js → account-WKQHMM7P.js} +39 -29
- package/dist/chunk-AYKKXGTR.js +1141 -0
- package/dist/{chunk-TC4ZPUWI.js → chunk-CVMSQ3OF.js} +19 -80
- package/dist/{chunk-HOQ7EUHJ.js → chunk-FDJMAF7D.js} +1 -0
- package/dist/chunk-GQKC6E5K.js +36 -0
- package/dist/{chunk-V3MVOVQT.js → chunk-MKGVNDMJ.js} +8 -1
- package/dist/chunk-NNV2OYEF.js +23 -0
- package/dist/{chunk-UJOTQPL6.js → chunk-OHXYFICP.js} +47 -14
- package/dist/{chunk-PD2I5TYC.js → chunk-Q63IIPL2.js} +2 -2
- package/dist/chunk-TSOIZBBU.js +41 -0
- package/dist/{chunk-ERBYEC5P.js → chunk-Y7K4UBFC.js} +1 -1
- package/dist/{chunk-FXYK2GTO.js → chunk-YFXLXION.js} +37 -32
- package/dist/chunk-ZYURL5VK.js +83 -0
- package/dist/cli.js +76 -97
- package/dist/{comment-MCXE7B7V.js → comment-7IQ6ZOJF.js} +27 -22
- package/dist/{company-EUUN372H.js → company-RD7RDGSA.js} +55 -50
- package/dist/{config-K4G3VSBA.js → config-EYBNYRGK.js} +13 -5
- package/dist/{connect-2AL7XVJO.js → connect-HVXT67A6.js} +35 -31
- package/dist/core-6XYGUNAY.js +46 -0
- package/dist/{doctor-WPYI7X2T.js → doctor-HUXQERLQ.js} +8 -4
- package/dist/document-AUUCGST2.js +27 -0
- package/dist/{draft-G65DVXT7.js → draft-DFO22K6Q.js} +26 -21
- package/dist/examples-64YT5V5K.js +53 -0
- package/dist/{feed-HV24WME4.js → feed-JWP6ANPI.js} +13 -9
- package/dist/{group-HADXNVJW.js → group-SIQFJEZV.js} +15 -11
- package/dist/{inbox-G3EE54OB.js → inbox-MMIMCA5O.js} +21 -17
- package/dist/{inboxes-237XOBTP.js → inboxes-RND3D4C7.js} +16 -12
- package/dist/{job-LIN6RWD7.js → job-ACFKBLFK.js} +29 -25
- package/dist/{login-OHAHNBRW.js → login-ZOB5KVKQ.js} +10 -5
- package/dist/{message-U2O2JQSW.js → message-OFK6UVXR.js} +9 -7
- package/dist/{notification-3VG32LWM.js → notification-KKGAZU7M.js} +17 -13
- package/dist/{post-ECDK2KJL.js → post-A5SBCFB2.js} +33 -28
- package/dist/{profile-JOHS6SDW.js → profile-4SOOQZ4K.js} +45 -41
- package/dist/{recruiter-7VXEIXN3.js → recruiter-YN73STDP.js} +123 -120
- package/dist/{sales-nav-K4BMBH7R.js → sales-nav-JXF5RY2K.js} +38 -32
- package/dist/{search-C2UYO6PI.js → search-JAL242A2.js} +58 -48
- package/dist/{setup-GYEZFDEN.js → setup-WICWH4JG.js} +13 -8
- package/dist/{webhook-KCOQOH7D.js → webhook-UGKVYWBC.js} +34 -36
- package/package.json +1 -1
- package/dist/chunk-KJ24DIAJ.js +0 -60
- package/dist/examples-IJL3A6SZ.js +0 -18
|
@@ -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,19 @@ 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
|
+
};
|
|
192
132
|
|
|
193
133
|
// src/lib/beta.ts
|
|
194
134
|
var BETA_CONSENT_HEADER = "X-Curviate-Beta";
|
|
@@ -257,12 +197,6 @@ function betaOverrideHeader() {
|
|
|
257
197
|
}
|
|
258
198
|
|
|
259
199
|
export {
|
|
260
|
-
STDIN_SENTINEL,
|
|
261
|
-
defaultReadStdin,
|
|
262
|
-
isStdinToken,
|
|
263
|
-
restoreLiteralDashes,
|
|
264
|
-
assertNoStdinPlaceholder,
|
|
265
|
-
resolveTextOrStdin,
|
|
266
200
|
parseBetaFlag,
|
|
267
201
|
setBetaOverride,
|
|
268
202
|
betaOverrideHeader,
|
|
@@ -271,5 +205,10 @@ export {
|
|
|
271
205
|
WRITE_FLAGS,
|
|
272
206
|
READ_SINGLE_FLAGS,
|
|
273
207
|
WRITE_SINGLE_FLAGS,
|
|
274
|
-
readOnly
|
|
208
|
+
readOnly,
|
|
209
|
+
setWriteKind,
|
|
210
|
+
isPoll,
|
|
211
|
+
getWriteKind,
|
|
212
|
+
getRecheck,
|
|
213
|
+
STATE_WRITES
|
|
275
214
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/commands/descriptions.ts
|
|
4
|
+
var DESCRIPTIONS = {
|
|
5
|
+
setup: "Connect this machine to your workspace: opens the dashboard, takes the code it shows you, and saves an API key.",
|
|
6
|
+
doctor: "Check that this machine can call the API: config, credential source, workspace, reachability and connected accounts.",
|
|
7
|
+
login: "Save an API key to a local profile. Run `curviate core profile me` to verify.",
|
|
8
|
+
config: "Manage CLI profiles and settings.",
|
|
9
|
+
account: "LinkedIn account connection management.",
|
|
10
|
+
webhook: "Webhook management and signature verification.",
|
|
11
|
+
core: "Curviate core: LinkedIn building blocks. Each command runs one action now, from one Account, and counts against that Account's budgets. Nothing is queued, paced or retried for you, except a Draft scheduled with `--schedule-at`, which Curviate publishes at that time (`curviate core draft create`).",
|
|
12
|
+
profile: "LinkedIn profile operations.",
|
|
13
|
+
company: "Fetch a company profile by URL, slug, or numeric id, and its sub-resources.",
|
|
14
|
+
job: "Classic LinkedIn job-posting operations.",
|
|
15
|
+
connect: "Send or manage connection invitations. Connection requests may take 10-30 seconds to appear in the recipient's received list (LinkedIn propagation delay).",
|
|
16
|
+
search: "Search people, companies, posts, and jobs. Also runs a pasted search URL directly.",
|
|
17
|
+
inbox: "Read LinkedIn message inbox.",
|
|
18
|
+
inboxes: "Discover LinkedIn inboxes (personal + company pages) and list their conversations. Beta. See also: `curviate core inbox` (the account's own message-thread inbox), `curviate core message send` (reply to a chat).",
|
|
19
|
+
message: "Send and manage LinkedIn messages. A COMPANY_ chat id (from `curviate core inboxes chats`) sends as that company page instead of yourself; see `curviate core message send --help`.",
|
|
20
|
+
post: "Create and manage LinkedIn posts.",
|
|
21
|
+
comment: "Comment-thread operations (list, add, reply, edit, delete, react).",
|
|
22
|
+
"sales-nav": "Beta. Sales Navigator operations. Needs the LinkedIn account's own Sales Navigator subscription; no Curviate add-on. Beta operations can require consent: a human enables beta in Settings, or pass --beta for this call.",
|
|
23
|
+
recruiter: "Beta. LinkedIn Recruiter operations. Needs the LinkedIn account's own Recruiter subscription; no Curviate add-on. Beta operations can require consent: a human enables beta in Settings, or pass --beta for this call.",
|
|
24
|
+
group: "Read LinkedIn groups: your own membership list, one group's detail, and its member roster.",
|
|
25
|
+
feed: "Read the connected account's LinkedIn home feed as agent-actionable posts.",
|
|
26
|
+
notification: "Read and act on LinkedIn notification cards.",
|
|
27
|
+
draft: "Drafts and scheduled posts."
|
|
28
|
+
};
|
|
29
|
+
function lazy(name, load) {
|
|
30
|
+
return Object.assign(load, { description: DESCRIPTIONS[name] });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
DESCRIPTIONS,
|
|
35
|
+
lazy
|
|
36
|
+
};
|
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
isPlainObject,
|
|
4
4
|
profileValue,
|
|
5
5
|
readConfigFile
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OHXYFICP.js";
|
|
7
|
+
import {
|
|
8
|
+
isStdinToken
|
|
9
|
+
} from "./chunk-ZYURL5VK.js";
|
|
7
10
|
|
|
8
11
|
// src/lib/output.ts
|
|
9
12
|
function isJsonMode(opts) {
|
|
@@ -380,6 +383,10 @@ var DEFAULT_TIMEOUT_MS = 3e4;
|
|
|
380
383
|
async function resolveEffectiveConfig(flags) {
|
|
381
384
|
const file = await readConfigFile();
|
|
382
385
|
const fromProfile = (field) => profileValue(file, flags.profile, field);
|
|
386
|
+
if (isStdinToken(flags.apiKey)) {
|
|
387
|
+
process.stderr.write("error: --api-key - reads stdin only on `curviate login`. Set CURVIATE_API_KEY, or save the key with `curviate login --api-key -`.\n");
|
|
388
|
+
process.exit(2);
|
|
389
|
+
}
|
|
383
390
|
const profileKey = flags.apiKey === void 0 && process.env["CURVIATE_API_KEY"] === void 0 ? fromProfile("apiKey") : void 0;
|
|
384
391
|
const apiKey = flags.apiKey ?? process.env["CURVIATE_API_KEY"] ?? profileKey;
|
|
385
392
|
const apiKeySource = flags.apiKey !== void 0 ? "flag" : process.env["CURVIATE_API_KEY"] !== void 0 ? "env" : profileKey !== void 0 ? "profile" : "none";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/lib/int-flag.ts
|
|
4
|
+
function intFlag(flag, raw, min = 1, max = Number.MAX_SAFE_INTEGER) {
|
|
5
|
+
const n = /^\d+$/.test(raw) ? Number(raw) : NaN;
|
|
6
|
+
if (n >= min && n <= max) return n;
|
|
7
|
+
const range = max === Number.MAX_SAFE_INTEGER ? `${min} or more` : `from ${min} to ${max}`;
|
|
8
|
+
process.stderr.write(`error: --${flag} must be a whole number, ${range}.
|
|
9
|
+
`);
|
|
10
|
+
process.exit(2);
|
|
11
|
+
}
|
|
12
|
+
function intListFlag(flag, raw, min = 1, max = Number.MAX_SAFE_INTEGER) {
|
|
13
|
+
const n = raw.split(",").map((s) => s.trim()).map((s) => /^\d+$/.test(s) ? Number(s) : NaN);
|
|
14
|
+
if (n.length > 0 && n.every((x) => x >= min && x <= max)) return n;
|
|
15
|
+
process.stderr.write(`error: --${flag} takes comma-separated whole numbers, each from ${min} to ${max}.
|
|
16
|
+
`);
|
|
17
|
+
process.exit(2);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
intFlag,
|
|
22
|
+
intListFlag
|
|
23
|
+
};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
betaOverrideHeader,
|
|
4
|
+
getRecheck,
|
|
5
|
+
getWriteKind,
|
|
6
|
+
isPoll
|
|
7
|
+
} from "./chunk-CVMSQ3OF.js";
|
|
8
|
+
import {
|
|
9
|
+
assertNoStdinPlaceholder
|
|
10
|
+
} from "./chunk-ZYURL5VK.js";
|
|
6
11
|
|
|
7
12
|
// src/lib/config.ts
|
|
8
13
|
import {
|
|
@@ -219,7 +224,8 @@ var guardedFetch = async (input, init) => {
|
|
|
219
224
|
typeof merged?.body === "string" ? merged.body : void 0
|
|
220
225
|
]);
|
|
221
226
|
const res = await fetch(input, merged);
|
|
222
|
-
|
|
227
|
+
const method = (merged?.method ?? (input instanceof Request ? input.method : "GET")).toUpperCase();
|
|
228
|
+
return downloading.getStore() && res.ok ? asOpaqueBytes(res) : platformFaultIfUnreadable(res, getWriteKind() === "state" ? "state" : method === "GET" ? "read" : getWriteKind());
|
|
223
229
|
};
|
|
224
230
|
var downloading = new AsyncLocalStorage();
|
|
225
231
|
function downloadBinary(call) {
|
|
@@ -230,7 +236,7 @@ function asOpaqueBytes(res) {
|
|
|
230
236
|
headers.set("content-type", "application/octet-stream");
|
|
231
237
|
return new Response(res.body, { status: res.status, statusText: res.statusText, headers });
|
|
232
238
|
}
|
|
233
|
-
async function platformFaultIfUnreadable(res) {
|
|
239
|
+
async function platformFaultIfUnreadable(res, kind) {
|
|
234
240
|
const text = res.status === 204 ? "" : await res.clone().text();
|
|
235
241
|
let parsed = true;
|
|
236
242
|
let env = null;
|
|
@@ -239,30 +245,57 @@ async function platformFaultIfUnreadable(res) {
|
|
|
239
245
|
} catch {
|
|
240
246
|
parsed = false;
|
|
241
247
|
}
|
|
248
|
+
if (res.ok && kind === "write") return acceptedWrite(res, text, parsed ? env : void 0);
|
|
249
|
+
if (res.ok && kind === "state" && !(env !== null && typeof env === "object" && !Array.isArray(env) && Object.keys(env).length > 0)) {
|
|
250
|
+
return fault(res, `The API answered ${res.status} without a readable body. The request may have been applied: check with \`${getRecheck()}\` before sending it again.`, false);
|
|
251
|
+
}
|
|
242
252
|
if (res.status >= 500) {
|
|
243
253
|
if (typeof env?.code === "string") return res;
|
|
244
254
|
} else if (!res.ok || parsed) {
|
|
245
255
|
return res;
|
|
246
256
|
} else if (text === "") {
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
return new Response(null, { status: res.status, statusText: res.statusText, headers
|
|
257
|
+
const headers = new Headers(res.headers);
|
|
258
|
+
headers.delete("content-type");
|
|
259
|
+
return new Response(null, { status: res.status, statusText: res.statusText, headers });
|
|
250
260
|
}
|
|
261
|
+
if (kind !== "read" && !isPoll()) {
|
|
262
|
+
const check = kind === "state" ? `check with \`${getRecheck()}\`` : "read the current state";
|
|
263
|
+
return fault(res, `The API answered ${res.status} without a readable body. The request may have been applied: ${check} before sending it again.`, false);
|
|
264
|
+
}
|
|
265
|
+
return fault(res, `The API answered ${res.status} without a readable body.`, true);
|
|
266
|
+
}
|
|
267
|
+
function fault(res, message, retryLikely) {
|
|
251
268
|
const headers = new Headers(res.headers);
|
|
252
269
|
headers.set("content-type", "application/json");
|
|
253
270
|
headers.delete("content-length");
|
|
254
271
|
headers.delete("content-encoding");
|
|
255
272
|
return new Response(
|
|
256
|
-
JSON.stringify({
|
|
257
|
-
code: "PLATFORM_ERROR",
|
|
258
|
-
message: `The API answered ${res.status} without a readable body.`,
|
|
259
|
-
user_fixable: false,
|
|
260
|
-
retry_likely_to_succeed: true
|
|
261
|
-
}),
|
|
273
|
+
JSON.stringify({ code: "PLATFORM_ERROR", message, user_fixable: false, retry_likely_to_succeed: retryLikely }),
|
|
262
274
|
// A 2xx has to become an error status for the SDK to decode it as one.
|
|
263
275
|
{ status: res.status >= 500 ? res.status : 502, statusText: res.statusText, headers }
|
|
264
276
|
);
|
|
265
277
|
}
|
|
278
|
+
function acceptedWrite(res, text, body) {
|
|
279
|
+
if (res.status === 204 || text === "") {
|
|
280
|
+
if (res.status !== 204) process.stderr.write(`warning: the API accepted this write (HTTP ${res.status}) with an empty body. The write happened: do not retry it.
|
|
281
|
+
`);
|
|
282
|
+
const headers2 = new Headers(res.headers);
|
|
283
|
+
headers2.delete("content-type");
|
|
284
|
+
return new Response(null, { status: res.status, statusText: res.statusText, headers: headers2 });
|
|
285
|
+
}
|
|
286
|
+
const expected = body !== null && typeof body === "object" && !Array.isArray(body) && "object" in body;
|
|
287
|
+
if (!expected) {
|
|
288
|
+
const what = body === void 0 ? "a body that is not JSON" : "a body of an unexpected shape";
|
|
289
|
+
process.stderr.write(`warning: the API accepted this write (HTTP ${res.status}) with ${what}. The write happened: do not retry it.
|
|
290
|
+
`);
|
|
291
|
+
}
|
|
292
|
+
if (body !== void 0) return res;
|
|
293
|
+
const headers = new Headers(res.headers);
|
|
294
|
+
headers.set("content-type", "application/json");
|
|
295
|
+
headers.delete("content-length");
|
|
296
|
+
headers.delete("content-encoding");
|
|
297
|
+
return new Response("{}", { status: res.status, statusText: res.statusText, headers });
|
|
298
|
+
}
|
|
266
299
|
function usage(message) {
|
|
267
300
|
return new CurviateError2({ code: "INVALID_REQUEST", message, userFixable: true, retryLikelyToSucceed: false });
|
|
268
301
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
readablePage
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MKGVNDMJ.js";
|
|
5
5
|
import {
|
|
6
6
|
getExitCode
|
|
7
7
|
} from "./chunk-76SWLAZ6.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/\\?#%]/;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
parseDocument,
|
|
4
|
+
readFileFlag,
|
|
5
|
+
readStdinCapped
|
|
6
|
+
} from "./chunk-AYKKXGTR.js";
|
|
7
|
+
import {
|
|
8
|
+
isStdinToken
|
|
9
|
+
} from "./chunk-ZYURL5VK.js";
|
|
10
|
+
|
|
11
|
+
// src/lib/search-filters.ts
|
|
12
|
+
var DEFAULT_FILTER_READERS = { readStdin: () => readStdinCapped("filters") };
|
|
13
|
+
async function assembleFilters(flags, readers = DEFAULT_FILTER_READERS) {
|
|
14
|
+
let raw;
|
|
15
|
+
let source;
|
|
16
|
+
if (flags["filters-file"] !== void 0) {
|
|
17
|
+
source = "--filters-file";
|
|
18
|
+
raw = await readFileFlag("filters-file", flags["filters-file"], { readStdin: readers === DEFAULT_FILTER_READERS ? void 0 : readers.readStdin, others: { filters: flags.filters } });
|
|
19
|
+
} else if (isStdinToken(flags.filters)) {
|
|
20
|
+
source = "--filters - (stdin)";
|
|
21
|
+
raw = await readers.readStdin();
|
|
22
|
+
} else if (flags.filters !== void 0) {
|
|
23
|
+
source = "--filters";
|
|
24
|
+
raw = flags.filters;
|
|
25
|
+
}
|
|
26
|
+
if (raw === void 0) return { body: {} };
|
|
27
|
+
const parsed = parseDocument(source === "--filters-file" ? "filters-file" : "filters", raw);
|
|
28
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
29
|
+
return { error: `${source} must be a JSON object` };
|
|
30
|
+
}
|
|
31
|
+
return { body: parsed };
|
|
32
|
+
}
|
|
33
|
+
function splitCsv(value) {
|
|
34
|
+
return value.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
DEFAULT_FILTER_READERS,
|
|
39
|
+
assembleFilters,
|
|
40
|
+
splitCsv
|
|
41
|
+
};
|
|
@@ -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-Q63IIPL2.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-MKGVNDMJ.js";
|
|
33
29
|
import {
|
|
34
30
|
createClient,
|
|
35
31
|
downloadBinary
|
|
36
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-OHXYFICP.js";
|
|
37
33
|
import {
|
|
38
34
|
READ_SINGLE_FLAGS,
|
|
39
35
|
WRITE_FLAGS,
|
|
40
|
-
readOnly
|
|
36
|
+
readOnly
|
|
37
|
+
} from "./chunk-CVMSQ3OF.js";
|
|
38
|
+
import {
|
|
39
|
+
DESCRIPTIONS
|
|
40
|
+
} from "./chunk-GQKC6E5K.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";
|
|
@@ -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
|
+
};
|