@parall/cli 1.57.2 → 1.58.1
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/dist/commands/approvals.d.ts.map +1 -1
- package/dist/commands/approvals.js +6 -4
- package/dist/commands/comments.d.ts.map +1 -1
- package/dist/commands/comments.js +11 -4
- package/dist/commands/files.d.ts +1 -1
- package/dist/commands/files.d.ts.map +1 -1
- package/dist/commands/files.js +3 -26
- package/dist/commands/tasks.d.ts +2 -0
- package/dist/commands/tasks.d.ts.map +1 -1
- package/dist/commands/tasks.js +17 -8
- package/dist/commands/watch.d.ts +12 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +166 -0
- package/dist/commands/wechat.d.ts +1 -1
- package/dist/commands/wechat.d.ts.map +1 -1
- package/dist/commands/wechat.js +19 -0
- package/dist/commands/wiki.d.ts.map +1 -1
- package/dist/commands/wiki.js +9 -4
- package/dist/index.js +2 -0
- package/dist/lib/download-attachment.d.ts +13 -0
- package/dist/lib/download-attachment.d.ts.map +1 -0
- package/dist/lib/download-attachment.js +22 -0
- package/dist/lib/text-input.d.ts +53 -19
- package/dist/lib/text-input.d.ts.map +1 -1
- package/dist/lib/text-input.js +84 -27
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../../src/commands/approvals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../../src/commands/approvals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,QAwIxD"}
|
|
@@ -10,7 +10,7 @@ export function registerApprovalCommands(program) {
|
|
|
10
10
|
.requiredOption('--chat <chatId>', 'Chat to post the approval card in (e.g. prll://cht_456)')
|
|
11
11
|
.requiredOption('--title <title>', 'Human-readable title for the request')
|
|
12
12
|
.option('--reason <text>', 'Why this action is needed')
|
|
13
|
-
.option('--payload <json>', 'Frozen action payload as a JSON object')
|
|
13
|
+
.option('--payload <json>', 'Frozen action payload as a JSON object (run `parall approvals actions` for the exact keys an action expects)')
|
|
14
14
|
.action(async (opts) => {
|
|
15
15
|
try {
|
|
16
16
|
const { client, orgId } = resolveCredentials();
|
|
@@ -118,12 +118,14 @@ export function registerApprovalCommands(program) {
|
|
|
118
118
|
});
|
|
119
119
|
approvals
|
|
120
120
|
.command('actions')
|
|
121
|
-
.description('List
|
|
121
|
+
.description('List approvable action types and the payload contract each one expects')
|
|
122
122
|
.action(async () => {
|
|
123
123
|
try {
|
|
124
124
|
const { client } = resolveCredentials();
|
|
125
|
-
const
|
|
126
|
-
|
|
125
|
+
const catalog = await client.getApprovableActionCatalog();
|
|
126
|
+
// `actions` keeps the full name list; `contracts` documents payloads
|
|
127
|
+
// for the actions that publish one (older servers publish none).
|
|
128
|
+
printJson({ actions: catalog.data, contracts: catalog.contracts ?? {} });
|
|
127
129
|
}
|
|
128
130
|
catch (err) {
|
|
129
131
|
printError(err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../src/commands/comments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../src/commands/comments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4BpC;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GACzB;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAMpD;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,QA4HvD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveCredentials } from '../lib/client.js';
|
|
2
2
|
import { printError, printJson, printRefHint, stripPrllScheme } from '../lib/output.js';
|
|
3
|
+
import { BODY_FILE_OPTION_DESC, BODY_OPTION_DESC, resolveCommentBody } from '../lib/text-input.js';
|
|
3
4
|
function stripUndefined(obj) {
|
|
4
5
|
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined));
|
|
5
6
|
}
|
|
@@ -54,14 +55,18 @@ export function registerCommentCommands(program) {
|
|
|
54
55
|
.description('Add a comment to a prll:// target. Inline wiki anchors must pin a revision: ' +
|
|
55
56
|
'prll://wik_x/path.md?rev=<full_commit_sha>#h=<anchor>')
|
|
56
57
|
.requiredOption('--target <uri>', 'Target prll:// URI (task / wiki page / changeset / inline anchor)')
|
|
57
|
-
.
|
|
58
|
+
.option('--body <text>', BODY_OPTION_DESC)
|
|
59
|
+
.option('--body-file <path>', BODY_FILE_OPTION_DESC)
|
|
58
60
|
.option('--parent <id>', 'Parent comment ID (task comments only — threaded reply)')
|
|
59
61
|
.action(async (opts) => {
|
|
60
62
|
try {
|
|
63
|
+
// Grammar first: a body-flag error is a parameter error even when
|
|
64
|
+
// credentials are absent, and it must never reach the wire.
|
|
65
|
+
const body = resolveCommentBody(opts);
|
|
61
66
|
const { client, orgId } = resolveCredentials();
|
|
62
67
|
const result = await client.createComment(orgId, {
|
|
63
68
|
target_uri: normalizeTarget(opts.target),
|
|
64
|
-
body
|
|
69
|
+
body,
|
|
65
70
|
parent_id: opts.parent ? stripPrllScheme(opts.parent) : undefined,
|
|
66
71
|
});
|
|
67
72
|
printJson(result);
|
|
@@ -119,12 +124,14 @@ export function registerCommentCommands(program) {
|
|
|
119
124
|
.command('update')
|
|
120
125
|
.description('Update a comment (author only)')
|
|
121
126
|
.argument('<commentId>', 'Comment ID')
|
|
122
|
-
.
|
|
127
|
+
.option('--body <text>', BODY_OPTION_DESC)
|
|
128
|
+
.option('--body-file <path>', BODY_FILE_OPTION_DESC)
|
|
123
129
|
.action(async (commentId, opts) => {
|
|
124
130
|
try {
|
|
131
|
+
const body = resolveCommentBody(opts);
|
|
125
132
|
const { client, orgId } = resolveCredentials();
|
|
126
133
|
const result = await client.updateComment(orgId, stripPrllScheme(commentId), {
|
|
127
|
-
body
|
|
134
|
+
body,
|
|
128
135
|
});
|
|
129
136
|
printJson(result);
|
|
130
137
|
}
|
package/dist/commands/files.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/commands/files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/commands/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,QAsCpD"}
|
package/dist/commands/files.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import * as fs from 'node:fs';
|
|
2
|
-
import * as path from 'node:path';
|
|
3
1
|
import { resolveCredentials } from '../lib/client.js';
|
|
4
|
-
import {
|
|
2
|
+
import { downloadAttachment } from '../lib/download-attachment.js';
|
|
3
|
+
import { printError, printJson, stripPrllScheme } from '../lib/output.js';
|
|
5
4
|
import { uploadFile } from '../lib/upload.js';
|
|
6
5
|
export function registerFileCommands(program) {
|
|
7
6
|
const files = program.command('files').description('Upload and download files');
|
|
@@ -33,29 +32,7 @@ export function registerFileCommands(program) {
|
|
|
33
32
|
try {
|
|
34
33
|
const { client } = resolveCredentials();
|
|
35
34
|
const id = stripPrllScheme(attachmentId);
|
|
36
|
-
|
|
37
|
-
// Download the file
|
|
38
|
-
const res = await fetch(fileInfo.url);
|
|
39
|
-
if (!res.ok) {
|
|
40
|
-
throw new Error(`Download failed: ${res.status} ${res.statusText}`);
|
|
41
|
-
}
|
|
42
|
-
const buffer = Buffer.from(await res.arrayBuffer());
|
|
43
|
-
// Sanitize server-provided filename to prevent path traversal
|
|
44
|
-
const safeName = path.basename(fileInfo.file_name || id);
|
|
45
|
-
// Determine output path
|
|
46
|
-
const outputPath = opts.output ? path.resolve(opts.output) : path.resolve(safeName);
|
|
47
|
-
// If output is a directory, write file inside it
|
|
48
|
-
let finalPath = outputPath;
|
|
49
|
-
if (fs.existsSync(outputPath) && fs.statSync(outputPath).isDirectory()) {
|
|
50
|
-
finalPath = path.join(outputPath, safeName);
|
|
51
|
-
}
|
|
52
|
-
fs.writeFileSync(finalPath, buffer);
|
|
53
|
-
printJson({
|
|
54
|
-
path: finalPath,
|
|
55
|
-
file_name: fileInfo.file_name,
|
|
56
|
-
file_size: fileInfo.file_size,
|
|
57
|
-
mime_type: fileInfo.mime_type,
|
|
58
|
-
});
|
|
35
|
+
printJson(await downloadAttachment(client, id, opts.output));
|
|
59
36
|
}
|
|
60
37
|
catch (err) {
|
|
61
38
|
printError(err);
|
package/dist/commands/tasks.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
export declare function buildCreateTaskData(opts: {
|
|
4
4
|
title: string;
|
|
5
5
|
description?: string;
|
|
6
|
+
descriptionFile?: string;
|
|
6
7
|
status?: string;
|
|
7
8
|
priority?: string;
|
|
8
9
|
assigneeId?: string;
|
|
@@ -29,6 +30,7 @@ export declare function buildUpdateTaskData(opts: {
|
|
|
29
30
|
priority?: string;
|
|
30
31
|
assigneeId?: string;
|
|
31
32
|
description?: string;
|
|
33
|
+
descriptionFile?: string;
|
|
32
34
|
parentId?: string;
|
|
33
35
|
sortOrder?: string;
|
|
34
36
|
placement?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/commands/tasks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/commands/tasks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyEpC,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;;;;;;;;;;;GAaA;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;;YAS0B,iBAAiB,CAAC,QAAQ,CAAC;cACvB,iBAAiB,CAAC,UAAU,CAAC;;;;;;;;GAS3D;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,QAiZpD"}
|
package/dist/commands/tasks.js
CHANGED
|
@@ -2,6 +2,7 @@ import { ApiError } from '@parall/sdk';
|
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { resolveCredentials, resolveTypedDispatchBinding } from '../lib/client.js';
|
|
4
4
|
import { printJson, printError, printRefHint, stripPrllScheme } from '../lib/output.js';
|
|
5
|
+
import { BODY_FILE_OPTION_DESC, BODY_OPTION_DESC, DESCRIPTION_FILE_OPTION_DESC, DESCRIPTION_OPTION_DESC, resolveCommentBody, resolveTaskDescription, } from '../lib/text-input.js';
|
|
5
6
|
function stripUndefined(obj) {
|
|
6
7
|
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined));
|
|
7
8
|
}
|
|
@@ -63,7 +64,7 @@ function resolveSortOrder(value) {
|
|
|
63
64
|
export function buildCreateTaskData(opts) {
|
|
64
65
|
return stripUndefined({
|
|
65
66
|
title: opts.title,
|
|
66
|
-
description: opts
|
|
67
|
+
description: resolveTaskDescription(opts),
|
|
67
68
|
status: opts.status,
|
|
68
69
|
priority: opts.priority,
|
|
69
70
|
assignee_id: opts.assigneeId ? stripPrllScheme(opts.assigneeId) : undefined,
|
|
@@ -86,7 +87,7 @@ export function buildUpdateTaskData(opts) {
|
|
|
86
87
|
status: opts.status,
|
|
87
88
|
priority: opts.priority,
|
|
88
89
|
assignee_id: opts.assigneeId ? stripPrllScheme(opts.assigneeId) : undefined,
|
|
89
|
-
description: opts
|
|
90
|
+
description: resolveTaskDescription(opts),
|
|
90
91
|
parent_id: opts.parentId ? stripPrllScheme(opts.parentId) : undefined,
|
|
91
92
|
sort_order: resolveSortOrder(opts.sortOrder),
|
|
92
93
|
placement: resolvePlacement(opts.placement),
|
|
@@ -133,7 +134,8 @@ export function registerTaskCommands(program) {
|
|
|
133
134
|
.command('create')
|
|
134
135
|
.description('Create a new task')
|
|
135
136
|
.requiredOption('--title <title>', 'Task title')
|
|
136
|
-
.option('--description <text>',
|
|
137
|
+
.option('--description <text>', DESCRIPTION_OPTION_DESC)
|
|
138
|
+
.option('--description-file <path>', DESCRIPTION_FILE_OPTION_DESC)
|
|
137
139
|
.option('--status <status>', 'Task status')
|
|
138
140
|
.option('--priority <priority>', 'Task priority')
|
|
139
141
|
.option('--assignee-id <id>', 'Assignee user ID')
|
|
@@ -197,7 +199,8 @@ export function registerTaskCommands(program) {
|
|
|
197
199
|
.option('--status <status>', 'Task status')
|
|
198
200
|
.option('--priority <priority>', 'Task priority')
|
|
199
201
|
.option('--assignee-id <id>', 'Assignee user ID')
|
|
200
|
-
.option('--description <text>',
|
|
202
|
+
.option('--description <text>', DESCRIPTION_OPTION_DESC)
|
|
203
|
+
.option('--description-file <path>', DESCRIPTION_FILE_OPTION_DESC)
|
|
201
204
|
.option('--parent-id <id>', 'Parent task ID')
|
|
202
205
|
.option('--sort-order <n>', 'Explicit sort_order value — only for pinpoint insertion relative to cards you can see; to append to a status column use --placement end')
|
|
203
206
|
.option('--placement <where>', 'Ordering intent — only "end" is accepted: appends the task to the end of its status column, position resolved by the server (mutually exclusive with --sort-order)')
|
|
@@ -321,14 +324,18 @@ export function registerTaskCommands(program) {
|
|
|
321
324
|
.command('add')
|
|
322
325
|
.description('Add a comment to a task')
|
|
323
326
|
.argument('<taskId>', 'Task ID')
|
|
324
|
-
.
|
|
327
|
+
.option('--body <text>', BODY_OPTION_DESC)
|
|
328
|
+
.option('--body-file <path>', BODY_FILE_OPTION_DESC)
|
|
325
329
|
.action(async (taskId, opts) => {
|
|
326
330
|
try {
|
|
331
|
+
// Grammar first: a body-flag error is a parameter error even when
|
|
332
|
+
// credentials are absent, and it must never reach the wire.
|
|
333
|
+
const body = resolveCommentBody(opts);
|
|
327
334
|
const { client, orgId } = resolveCredentials();
|
|
328
335
|
const { COMMENT_TARGET } = await import('@parall/sdk');
|
|
329
336
|
const result = await client.createComment(orgId, {
|
|
330
337
|
target_uri: COMMENT_TARGET.task(stripPrllScheme(taskId)),
|
|
331
|
-
body
|
|
338
|
+
body,
|
|
332
339
|
});
|
|
333
340
|
printJson(result);
|
|
334
341
|
printRefHint(result.id);
|
|
@@ -341,12 +348,14 @@ export function registerTaskCommands(program) {
|
|
|
341
348
|
.command('update')
|
|
342
349
|
.description('Update a task comment')
|
|
343
350
|
.argument('<commentId>', 'Comment ID')
|
|
344
|
-
.
|
|
351
|
+
.option('--body <text>', BODY_OPTION_DESC)
|
|
352
|
+
.option('--body-file <path>', BODY_FILE_OPTION_DESC)
|
|
345
353
|
.action(async (commentId, opts) => {
|
|
346
354
|
try {
|
|
355
|
+
const body = resolveCommentBody(opts);
|
|
347
356
|
const { client, orgId } = resolveCredentials();
|
|
348
357
|
const result = await client.updateComment(orgId, stripPrllScheme(commentId), {
|
|
349
|
-
body
|
|
358
|
+
body,
|
|
350
359
|
});
|
|
351
360
|
printJson(result);
|
|
352
361
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SetWatchLevelRequest } from '@parall/sdk';
|
|
2
|
+
import type { Command } from 'commander';
|
|
3
|
+
export declare function normalizeTargetUri(input: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Parse `all | mentions [until <when>]` into a request body. `until`
|
|
6
|
+
* accepts an RFC 3339 time, `tomorrow` (09:00 local next day), or a relative
|
|
7
|
+
* duration such as `2h`, `90m`, `1d`. Throws on anything else.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseLevelArgs(args: readonly string[], now?: Date): Pick<SetWatchLevelRequest, 'level' | 'until'>;
|
|
10
|
+
export declare function parseUntil(input: string, now: Date): Date;
|
|
11
|
+
export declare function registerWatchCommands(program: Command): void;
|
|
12
|
+
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/commands/watch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBzC,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,GAAG,GAAE,IAAiB,GACrB,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,OAAO,CAAC,CAe/C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI,CAiBzD;AAKD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuG5D"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { resolveCredentials } from '../lib/client.js';
|
|
2
|
+
import { printError, printJson } from '../lib/output.js';
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// `parall watch` — what the agent receives from each channel and thread
|
|
5
|
+
// (agent-attention-design §4.1 / §4.5). Two values:
|
|
6
|
+
// all every message
|
|
7
|
+
// mentions only what addresses you (@, @all/@allagent, a person's DM, …)
|
|
8
|
+
// and a temporary flip: `<value> until <time>` receives <value> until then
|
|
9
|
+
// and goes back to the other value. `--catch-up` on `mentions until` asks
|
|
10
|
+
// for one wake when the mute lapses with unread activity.
|
|
11
|
+
// Targets: a chat (cht_) or a thread root (msg_). Threads are watched on
|
|
12
|
+
// first use; chats need membership; a DM with a person has no setting.
|
|
13
|
+
// Tasks carry no setting: `parall watch <task>` / `parall unwatch <task>`.
|
|
14
|
+
// A temporary setting needs the runtime contract — older runtimes get 422
|
|
15
|
+
// RUNTIME_CONTRACT_REQUIRED.
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
const LEVELS = ['all', 'mentions'];
|
|
18
|
+
export function normalizeTargetUri(input) {
|
|
19
|
+
const trimmed = input.trim();
|
|
20
|
+
return trimmed.startsWith('prll://') ? trimmed : `prll://${trimmed}`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Parse `all | mentions [until <when>]` into a request body. `until`
|
|
24
|
+
* accepts an RFC 3339 time, `tomorrow` (09:00 local next day), or a relative
|
|
25
|
+
* duration such as `2h`, `90m`, `1d`. Throws on anything else.
|
|
26
|
+
*/
|
|
27
|
+
export function parseLevelArgs(args, now = new Date()) {
|
|
28
|
+
const [head, ...rest] = args.map((a) => a.trim()).filter(Boolean);
|
|
29
|
+
if (!head)
|
|
30
|
+
throw new Error('value required: all | mentions [until <time>]');
|
|
31
|
+
const word = head.toLowerCase();
|
|
32
|
+
if (!LEVELS.includes(word)) {
|
|
33
|
+
throw new Error(`unknown value "${args.join(' ')}": use all | mentions [until <time>]`);
|
|
34
|
+
}
|
|
35
|
+
const level = word;
|
|
36
|
+
if (rest.length === 0)
|
|
37
|
+
return { level };
|
|
38
|
+
if (rest[0]?.toLowerCase() !== 'until') {
|
|
39
|
+
throw new Error(`unknown value "${args.join(' ')}": use all | mentions [until <time>]`);
|
|
40
|
+
}
|
|
41
|
+
const when = rest.slice(1).join(' ');
|
|
42
|
+
if (!when)
|
|
43
|
+
throw new Error('until needs a time: tomorrow | 2h | 90m | 1d | RFC 3339');
|
|
44
|
+
return { level, until: parseUntil(when, now).toISOString() };
|
|
45
|
+
}
|
|
46
|
+
export function parseUntil(input, now) {
|
|
47
|
+
const s = input.trim().toLowerCase();
|
|
48
|
+
if (s === 'tomorrow') {
|
|
49
|
+
// Local calendar: the next local day at 09:00.
|
|
50
|
+
return new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 9, 0, 0);
|
|
51
|
+
}
|
|
52
|
+
const rel = /^(\d+)\s*(m|h|d)$/.exec(s);
|
|
53
|
+
if (rel) {
|
|
54
|
+
const n = Number(rel[1]);
|
|
55
|
+
if (n <= 0)
|
|
56
|
+
throw new Error('duration must be a positive number of minutes / hours / days');
|
|
57
|
+
const ms = rel[2] === 'm' ? 60_000 : rel[2] === 'h' ? 3_600_000 : 86_400_000;
|
|
58
|
+
return new Date(now.getTime() + n * ms);
|
|
59
|
+
}
|
|
60
|
+
const abs = new Date(input.trim());
|
|
61
|
+
if (Number.isNaN(abs.getTime()))
|
|
62
|
+
throw new Error(`cannot parse time "${input}"`);
|
|
63
|
+
if (abs.getTime() <= now.getTime())
|
|
64
|
+
throw new Error(`"${input}" is in the past`);
|
|
65
|
+
return abs;
|
|
66
|
+
}
|
|
67
|
+
const UNWATCH_HINT = "You left this thread: replies, being the root author or being @'d will not re-follow it; an @ still reaches you as a single message. Reply here or run `parall watch <thread>` to follow it again.";
|
|
68
|
+
export function registerWatchCommands(program) {
|
|
69
|
+
const watch = program
|
|
70
|
+
.command('watch')
|
|
71
|
+
.description('What you receive from each channel and thread: all | mentions [until <time>]')
|
|
72
|
+
.argument('[target]', 'prll:// thread root or task to follow')
|
|
73
|
+
.option('--until <time>', 'follow a thread only until then (tomorrow | 2h | RFC 3339)')
|
|
74
|
+
.action(async (target, opts, cmd) => {
|
|
75
|
+
if (!target) {
|
|
76
|
+
cmd.help();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const uri = normalizeTargetUri(target);
|
|
81
|
+
const id = uri.slice('prll://'.length);
|
|
82
|
+
const { client, orgId } = resolveCredentials();
|
|
83
|
+
if (id.startsWith('tsk_')) {
|
|
84
|
+
if (opts.until)
|
|
85
|
+
throw new Error('tasks carry no setting: `parall watch <task>` follows it for good');
|
|
86
|
+
await client.watchTask(orgId, id);
|
|
87
|
+
printJson({ ok: true });
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (!id.startsWith('msg_')) {
|
|
91
|
+
throw new Error('watch takes a thread root (msg_) or a task (tsk_); for a chat use `parall watch set <chat> all|mentions`');
|
|
92
|
+
}
|
|
93
|
+
const body = { target_uri: uri, level: 'all' };
|
|
94
|
+
if (opts.until)
|
|
95
|
+
body.until = parseUntil(opts.until, new Date()).toISOString();
|
|
96
|
+
printJson(await client.setWatchLevel(orgId, body));
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
printError(err);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
watch
|
|
103
|
+
.command('list')
|
|
104
|
+
.description('List every channel and thread you watch with what you receive there')
|
|
105
|
+
.action(async () => {
|
|
106
|
+
try {
|
|
107
|
+
const { client, orgId } = resolveCredentials();
|
|
108
|
+
printJson({ data: await client.listWatches(orgId) });
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
printError(err);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
watch
|
|
115
|
+
.command('set')
|
|
116
|
+
.description('Set what you receive on a chat or thread root: all | mentions [until <time>]')
|
|
117
|
+
.argument('<target>', 'prll:// URI (cht_ / msg_ root)')
|
|
118
|
+
.argument('<value...>', 'all | mentions [until tomorrow|2h|RFC3339]')
|
|
119
|
+
.option('--catch-up', 'with `mentions until`: one wake when the mute lapses with unread activity')
|
|
120
|
+
.action(async (target, value, opts) => {
|
|
121
|
+
try {
|
|
122
|
+
const uri = normalizeTargetUri(target);
|
|
123
|
+
if (uri.slice('prll://'.length).startsWith('tsk_')) {
|
|
124
|
+
throw new Error('tasks carry no setting: use `parall watch <task>` / `parall unwatch <task>`');
|
|
125
|
+
}
|
|
126
|
+
const parsed = parseLevelArgs(value);
|
|
127
|
+
const body = { target_uri: uri, ...parsed };
|
|
128
|
+
if (opts.catchUp) {
|
|
129
|
+
if (parsed.level !== 'mentions' || !parsed.until) {
|
|
130
|
+
throw new Error('--catch-up only applies to `mentions until <time>`');
|
|
131
|
+
}
|
|
132
|
+
body.catch_up = true;
|
|
133
|
+
}
|
|
134
|
+
const { client, orgId } = resolveCredentials();
|
|
135
|
+
printJson(await client.setWatchLevel(orgId, body));
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
printError(err);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
program
|
|
142
|
+
.command('unwatch')
|
|
143
|
+
.description('Leave a thread or task (alias of messages unwatch / tasks unwatch)')
|
|
144
|
+
.argument('<target>', 'prll:// URI (msg_ root or tsk_)')
|
|
145
|
+
.action(async (target) => {
|
|
146
|
+
try {
|
|
147
|
+
const uri = normalizeTargetUri(target);
|
|
148
|
+
const id = uri.slice('prll://'.length);
|
|
149
|
+
const { client, orgId } = resolveCredentials();
|
|
150
|
+
if (id.startsWith('tsk_')) {
|
|
151
|
+
await client.unwatchTask(orgId, id);
|
|
152
|
+
printJson({ ok: true });
|
|
153
|
+
}
|
|
154
|
+
else if (id.startsWith('msg_')) {
|
|
155
|
+
await client.unwatchThread(id);
|
|
156
|
+
printJson({ ok: true, hint: UNWATCH_HINT });
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
throw new Error('unwatch takes a thread root (msg_) or a task (tsk_); for a chat use `parall watch set <chat> mentions`');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
printError(err);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wechat.d.ts","sourceRoot":"","sources":["../../src/commands/wechat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"wechat.d.ts","sourceRoot":"","sources":["../../src/commands/wechat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,QA6LtD"}
|
package/dist/commands/wechat.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolveCredentials } from '../lib/client.js';
|
|
2
|
+
import { downloadAttachment } from '../lib/download-attachment.js';
|
|
2
3
|
import { printError, printJson } from '../lib/output.js';
|
|
3
4
|
import { resolveMessageText, TEXT_FILE_OPTION_DESC, TEXT_OPTION_DESC } from '../lib/text-input.js';
|
|
4
5
|
/**
|
|
@@ -80,6 +81,24 @@ export function registerWechatCommands(program) {
|
|
|
80
81
|
printError(err);
|
|
81
82
|
}
|
|
82
83
|
});
|
|
84
|
+
const media = wechat
|
|
85
|
+
.command('media')
|
|
86
|
+
.description('Fetch WeChat media only when needed; the first successful fetch is cached');
|
|
87
|
+
media
|
|
88
|
+
.command('download')
|
|
89
|
+
.description('Download an image or completed file by external WeChat message id')
|
|
90
|
+
.requiredOption('--message <id>', 'External message id shown in the inbound event or history')
|
|
91
|
+
.option('-o, --output <path>', 'Output file path (default: ./{original_filename})')
|
|
92
|
+
.action(async (opts) => {
|
|
93
|
+
try {
|
|
94
|
+
const { client, orgId } = resolveCredentials();
|
|
95
|
+
const attachment = await client.materializeWechatMedia(orgId, opts.message);
|
|
96
|
+
printJson(await downloadAttachment(client, attachment.id, opts.output));
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
printError(err);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
83
102
|
wechat
|
|
84
103
|
.command('contacts')
|
|
85
104
|
.description('List the account address book with display names: friends, saved groups, followed official accounts')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wiki.d.ts","sourceRoot":"","sources":["../../src/commands/wiki.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"wiki.d.ts","sourceRoot":"","sources":["../../src/commands/wiki.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0BpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,QAs/BpD"}
|
package/dist/commands/wiki.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { promises as fs } from 'node:fs';
|
|
2
2
|
import { resolveCredentials, resolveRuntimeContext } from '../lib/client.js';
|
|
3
3
|
import { printError, printJson } from '../lib/output.js';
|
|
4
|
+
import { BODY_FILE_OPTION_DESC, BODY_OPTION_DESC, resolveCommentBody } from '../lib/text-input.js';
|
|
4
5
|
import { deleteWikiFile, downloadWikiFile, uploadWikiFile } from '../lib/wiki-files.js';
|
|
5
6
|
import { getAfcsDiff, getAfcsStatus, getWikiBlob, getWikiChangesetDetail, getWikiChangesetDiff, getWikiLog, getWikiOutline, getWikiSection, getWikiTree, listWikiChangesets, queryWiki, requestWikiAccess, resetWikiWorkspace, listWikis, proposeWikiChangeset, searchWiki, syncAllMounts, watchMounts, } from '../lib/wiki.js';
|
|
6
7
|
export function registerWikiCommands(program) {
|
|
@@ -792,9 +793,11 @@ export function registerWikiCommands(program) {
|
|
|
792
793
|
.argument('[wiki]', 'Wiki ID or slug')
|
|
793
794
|
.requiredOption('--target-type <type>', 'Target type (changeset or page)')
|
|
794
795
|
.requiredOption('--target-id <id>', 'Target ID (changeset ID or page path)')
|
|
795
|
-
.
|
|
796
|
+
.option('--body <text>', BODY_OPTION_DESC)
|
|
797
|
+
.option('--body-file <path>', BODY_FILE_OPTION_DESC)
|
|
796
798
|
.action(async (wikiRef, opts) => {
|
|
797
799
|
try {
|
|
800
|
+
const body = resolveCommentBody(opts);
|
|
798
801
|
const ctx = resolveCredentials();
|
|
799
802
|
const { resolveWikiRefOrDefault } = await import('../lib/wiki.js');
|
|
800
803
|
const { COMMENT_TARGET } = await import('@parall/sdk');
|
|
@@ -807,7 +810,7 @@ export function registerWikiCommands(program) {
|
|
|
807
810
|
: COMMENT_TARGET.wikiPage(w.id, opts.targetId);
|
|
808
811
|
const result = await ctx.client.createComment(ctx.orgId, {
|
|
809
812
|
target_uri: targetUri,
|
|
810
|
-
body
|
|
813
|
+
body,
|
|
811
814
|
});
|
|
812
815
|
printJson(result);
|
|
813
816
|
}
|
|
@@ -819,11 +822,13 @@ export function registerWikiCommands(program) {
|
|
|
819
822
|
.command('update')
|
|
820
823
|
.description('Update a wiki comment')
|
|
821
824
|
.argument('<commentId>', 'Comment ID')
|
|
822
|
-
.
|
|
825
|
+
.option('--body <text>', BODY_OPTION_DESC)
|
|
826
|
+
.option('--body-file <path>', BODY_FILE_OPTION_DESC)
|
|
823
827
|
.action(async (commentId, opts) => {
|
|
824
828
|
try {
|
|
829
|
+
const body = resolveCommentBody(opts);
|
|
825
830
|
const ctx = resolveCredentials();
|
|
826
|
-
const result = await ctx.client.updateComment(ctx.orgId, commentId, { body
|
|
831
|
+
const result = await ctx.client.updateComment(ctx.orgId, commentId, { body });
|
|
827
832
|
printJson(result);
|
|
828
833
|
}
|
|
829
834
|
catch (err) {
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import { registerMachineCommands } from './commands/machines.js';
|
|
|
24
24
|
import { registerClipCommands } from './commands/clip.js';
|
|
25
25
|
import { registerSlackCommands } from './commands/slack.js';
|
|
26
26
|
import { registerWechatCommands } from './commands/wechat.js';
|
|
27
|
+
import { registerWatchCommands } from './commands/watch.js';
|
|
27
28
|
import { createUpdateNotifier } from './lib/update-check.js';
|
|
28
29
|
const require = createRequire(import.meta.url);
|
|
29
30
|
const pkg = require('../package.json');
|
|
@@ -37,6 +38,7 @@ registerApprovalCommands(program);
|
|
|
37
38
|
registerChatCommands(program);
|
|
38
39
|
registerDMCommands(program);
|
|
39
40
|
registerMessageCommands(program);
|
|
41
|
+
registerWatchCommands(program);
|
|
40
42
|
registerTaskCommands(program);
|
|
41
43
|
registerCommentCommands(program);
|
|
42
44
|
registerProjectCommands(program);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FileUrlResponse } from '@parall/sdk';
|
|
2
|
+
interface AttachmentDownloaderClient {
|
|
3
|
+
getFileUrl(attachmentId: string): Promise<FileUrlResponse>;
|
|
4
|
+
}
|
|
5
|
+
export interface DownloadedAttachment {
|
|
6
|
+
path: string;
|
|
7
|
+
file_name: string;
|
|
8
|
+
file_size: number;
|
|
9
|
+
mime_type: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function downloadAttachment(client: AttachmentDownloaderClient, attachmentId: string, output?: string): Promise<DownloadedAttachment>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=download-attachment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download-attachment.d.ts","sourceRoot":"","sources":["../../src/lib/download-attachment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,UAAU,0BAA0B;IAClC,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CAoB/B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
export async function downloadAttachment(client, attachmentId, output) {
|
|
4
|
+
const fileInfo = await client.getFileUrl(attachmentId);
|
|
5
|
+
const response = await fetch(fileInfo.url);
|
|
6
|
+
if (!response.ok) {
|
|
7
|
+
throw new Error(`Download failed: ${response.status} ${response.statusText}`);
|
|
8
|
+
}
|
|
9
|
+
const buffer = Buffer.from(await response.arrayBuffer());
|
|
10
|
+
const safeName = path.basename(fileInfo.file_name || attachmentId);
|
|
11
|
+
const outputPath = output ? path.resolve(output) : path.resolve(safeName);
|
|
12
|
+
const finalPath = fs.existsSync(outputPath) && fs.statSync(outputPath).isDirectory()
|
|
13
|
+
? path.join(outputPath, safeName)
|
|
14
|
+
: outputPath;
|
|
15
|
+
fs.writeFileSync(finalPath, buffer);
|
|
16
|
+
return {
|
|
17
|
+
path: finalPath,
|
|
18
|
+
file_name: fileInfo.file_name,
|
|
19
|
+
file_size: fileInfo.file_size,
|
|
20
|
+
mime_type: fileInfo.mime_type,
|
|
21
|
+
};
|
|
22
|
+
}
|
package/dist/lib/text-input.d.ts
CHANGED
|
@@ -1,38 +1,72 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
export declare
|
|
1
|
+
export declare function inlineTextOptionDesc(noun: string): string;
|
|
2
|
+
export declare function fileTextOptionDesc(noun: string): string;
|
|
3
|
+
export declare const TEXT_OPTION_DESC: string;
|
|
4
|
+
export declare const TEXT_FILE_OPTION_DESC: string;
|
|
5
|
+
export declare const BODY_OPTION_DESC: string;
|
|
6
|
+
export declare const BODY_FILE_OPTION_DESC: string;
|
|
7
|
+
export declare const DESCRIPTION_OPTION_DESC: string;
|
|
8
|
+
export declare const DESCRIPTION_FILE_OPTION_DESC: string;
|
|
3
9
|
export declare const NO_BODY_ERROR = "Provide --text, --text-file, --file, or --attachment";
|
|
10
|
+
/** One inline/file flag pair and the values commander parsed for it. */
|
|
11
|
+
export interface TextInputSpec {
|
|
12
|
+
/** Inline flag, e.g. `--body`. */
|
|
13
|
+
flag: string;
|
|
14
|
+
/** File flag, e.g. `--body-file`. */
|
|
15
|
+
fileFlag: string;
|
|
16
|
+
value?: string;
|
|
17
|
+
fileValue?: string;
|
|
18
|
+
}
|
|
4
19
|
/**
|
|
5
|
-
* Resolve
|
|
6
|
-
* options shared by `messages send` and `dm`.
|
|
20
|
+
* Resolve free text from a mutually-exclusive inline / file flag pair.
|
|
7
21
|
*
|
|
8
22
|
* Agents build these commands with an LLM and run them through a shell, so any
|
|
9
|
-
* body passed as a double-quoted
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
23
|
+
* body passed as a double-quoted inline argument is mangled by shell expansion
|
|
24
|
+
* *before* the CLI ever sees it: `$1,000` becomes `,000`, `$USER` expands, and
|
|
25
|
+
* `` `cmd` `` / `$(cmd)` execute. Single quotes are no better — they break on
|
|
26
|
+
* the apostrophes that fill natural-language replies. The file flag sidesteps
|
|
27
|
+
* the shell entirely: the body comes from a file the agent wrote (raw bytes, no
|
|
28
|
+
* shell) or from stdin via a quoted heredoc (`<<'EOF'`, which disables all
|
|
29
|
+
* expansion). `-` means stdin.
|
|
30
|
+
*
|
|
31
|
+
* A bare `-` given to the INLINE flag is refused rather than forwarded: it is
|
|
32
|
+
* the stdin idiom mis-addressed to the wrong flag (`--body - <<'EOF'` posted a
|
|
33
|
+
* literal "-" comment while the heredoc was silently dropped), and a lone dash
|
|
34
|
+
* is never a real message. The error names the file flag so the caller can
|
|
35
|
+
* self-correct in one step.
|
|
16
36
|
*
|
|
17
37
|
* A single trailing newline — the structural newline a heredoc or editor appends
|
|
18
38
|
* — is stripped so a one-line reply doesn't arrive with a dangling blank line;
|
|
19
39
|
* this mirrors how `$(...)` command substitution trims trailing newlines, and
|
|
20
40
|
* leading/interior whitespace is preserved untouched.
|
|
21
41
|
*
|
|
22
|
-
* Returns `undefined` when neither
|
|
23
|
-
*
|
|
24
|
-
*
|
|
42
|
+
* Returns `undefined` when neither flag is set. Throws on conflicting flags, a
|
|
43
|
+
* bare `-` inline value, or an unreadable file; callers funnel that into
|
|
44
|
+
* `printError` before any credential resolution or request.
|
|
25
45
|
*/
|
|
46
|
+
export declare function resolveTextInput(spec: TextInputSpec): string | undefined;
|
|
47
|
+
/** `resolveTextInput` for flags where the text is mandatory. */
|
|
48
|
+
export declare function requireTextInput(spec: TextInputSpec): string;
|
|
49
|
+
/** Message body from `--text` / `--text-file` (`messages send`, `dm`, channel sends). */
|
|
26
50
|
export declare function resolveMessageText(opts: {
|
|
27
51
|
text?: string;
|
|
28
52
|
textFile?: string;
|
|
29
53
|
}): string | undefined;
|
|
54
|
+
/** Comment body from `--body` / `--body-file` (every `comments add|update` verb). */
|
|
55
|
+
export declare function resolveCommentBody(opts: {
|
|
56
|
+
body?: string;
|
|
57
|
+
bodyFile?: string;
|
|
58
|
+
}): string;
|
|
59
|
+
/** Task description from `--description` / `--description-file` (`tasks create|update`). */
|
|
60
|
+
export declare function resolveTaskDescription(opts: {
|
|
61
|
+
description?: string;
|
|
62
|
+
descriptionFile?: string;
|
|
63
|
+
}): string | undefined;
|
|
30
64
|
/**
|
|
31
|
-
* Read the payload of a file-input flag (`--text-file`, `--
|
|
32
|
-
* path or stdin (`-`). Shared so every such flag keeps
|
|
33
|
-
* guarantees: stdin drains a pipe/heredoc synchronously, an
|
|
34
|
-
* refused instead of hanging the dispatch, and a read
|
|
35
|
-
* underlying reason under the flag's own name.
|
|
65
|
+
* Read the payload of a file-input flag (`--text-file`, `--body-file`,
|
|
66
|
+
* `--args-file`) from a path or stdin (`-`). Shared so every such flag keeps
|
|
67
|
+
* the same three guarantees: stdin drains a pipe/heredoc synchronously, an
|
|
68
|
+
* interactive TTY is refused instead of hanging the dispatch, and a read
|
|
69
|
+
* failure surfaces its underlying reason under the flag's own name.
|
|
36
70
|
*/
|
|
37
71
|
export declare function readTextFileArg(flag: string, value: string): string;
|
|
38
72
|
//# sourceMappingURL=text-input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-input.d.ts","sourceRoot":"","sources":["../../src/lib/text-input.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"text-input.d.ts","sourceRoot":"","sources":["../../src/lib/text-input.ts"],"names":[],"mappings":"AAQA,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD;AACD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,eAAO,MAAM,gBAAgB,QAAuC,CAAC;AACrE,eAAO,MAAM,qBAAqB,QAAqC,CAAC;AACxE,eAAO,MAAM,gBAAgB,QAAuC,CAAC;AACrE,eAAO,MAAM,qBAAqB,QAAqC,CAAC;AACxE,eAAO,MAAM,uBAAuB,QAA2C,CAAC;AAChF,eAAO,MAAM,4BAA4B,QAAyC,CAAC;AACnF,eAAO,MAAM,aAAa,yDAAyD,CAAC;AAEpF,wEAAwE;AACxE,MAAM,WAAW,aAAa;IAC5B,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAcxE;AAED,gEAAgE;AAChE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAM5D;AAED,yFAAyF;AACzF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,SAAS,CAOjG;AAED,qFAAqF;AACrF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAOrF;AAED,4FAA4F;AAC5F,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,MAAM,GAAG,SAAS,CAOrB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAsBnE"}
|
package/dist/lib/text-input.js
CHANGED
|
@@ -1,47 +1,104 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
|
-
// Shared option help + validation copy for
|
|
4
|
-
//
|
|
3
|
+
// Shared option help + validation copy for every free-text flag pair
|
|
4
|
+
// (`--text`/`--text-file`, `--body`/`--body-file`, `--description`/
|
|
5
|
+
// `--description-file`), so `messages send`, `dm`, the comment verbs and
|
|
6
|
+
// `tasks create/update` stay in lockstep. commander's --help prints these
|
|
5
7
|
// verbatim (no markdown), so keep them backtick-free.
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
+
export function inlineTextOptionDesc(noun) {
|
|
9
|
+
return `${noun} (shell-safe only for short literals with no $, backtick, or quote)`;
|
|
10
|
+
}
|
|
11
|
+
export function fileTextOptionDesc(noun) {
|
|
12
|
+
return `Read ${noun} from a file ('-' = stdin) — shell-safe channel for content with $, backticks, or quotes`;
|
|
13
|
+
}
|
|
14
|
+
export const TEXT_OPTION_DESC = inlineTextOptionDesc('Message text');
|
|
15
|
+
export const TEXT_FILE_OPTION_DESC = fileTextOptionDesc('message text');
|
|
16
|
+
export const BODY_OPTION_DESC = inlineTextOptionDesc('Comment body');
|
|
17
|
+
export const BODY_FILE_OPTION_DESC = fileTextOptionDesc('comment body');
|
|
18
|
+
export const DESCRIPTION_OPTION_DESC = inlineTextOptionDesc('Task description');
|
|
19
|
+
export const DESCRIPTION_FILE_OPTION_DESC = fileTextOptionDesc('task description');
|
|
8
20
|
export const NO_BODY_ERROR = 'Provide --text, --text-file, --file, or --attachment';
|
|
9
21
|
/**
|
|
10
|
-
* Resolve
|
|
11
|
-
* options shared by `messages send` and `dm`.
|
|
22
|
+
* Resolve free text from a mutually-exclusive inline / file flag pair.
|
|
12
23
|
*
|
|
13
24
|
* Agents build these commands with an LLM and run them through a shell, so any
|
|
14
|
-
* body passed as a double-quoted
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
25
|
+
* body passed as a double-quoted inline argument is mangled by shell expansion
|
|
26
|
+
* *before* the CLI ever sees it: `$1,000` becomes `,000`, `$USER` expands, and
|
|
27
|
+
* `` `cmd` `` / `$(cmd)` execute. Single quotes are no better — they break on
|
|
28
|
+
* the apostrophes that fill natural-language replies. The file flag sidesteps
|
|
29
|
+
* the shell entirely: the body comes from a file the agent wrote (raw bytes, no
|
|
30
|
+
* shell) or from stdin via a quoted heredoc (`<<'EOF'`, which disables all
|
|
31
|
+
* expansion). `-` means stdin.
|
|
32
|
+
*
|
|
33
|
+
* A bare `-` given to the INLINE flag is refused rather than forwarded: it is
|
|
34
|
+
* the stdin idiom mis-addressed to the wrong flag (`--body - <<'EOF'` posted a
|
|
35
|
+
* literal "-" comment while the heredoc was silently dropped), and a lone dash
|
|
36
|
+
* is never a real message. The error names the file flag so the caller can
|
|
37
|
+
* self-correct in one step.
|
|
21
38
|
*
|
|
22
39
|
* A single trailing newline — the structural newline a heredoc or editor appends
|
|
23
40
|
* — is stripped so a one-line reply doesn't arrive with a dangling blank line;
|
|
24
41
|
* this mirrors how `$(...)` command substitution trims trailing newlines, and
|
|
25
42
|
* leading/interior whitespace is preserved untouched.
|
|
26
43
|
*
|
|
27
|
-
* Returns `undefined` when neither
|
|
28
|
-
*
|
|
29
|
-
*
|
|
44
|
+
* Returns `undefined` when neither flag is set. Throws on conflicting flags, a
|
|
45
|
+
* bare `-` inline value, or an unreadable file; callers funnel that into
|
|
46
|
+
* `printError` before any credential resolution or request.
|
|
30
47
|
*/
|
|
31
|
-
export function
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
export function resolveTextInput(spec) {
|
|
49
|
+
const { flag, fileFlag, value, fileValue } = spec;
|
|
50
|
+
if (value !== undefined && fileValue !== undefined) {
|
|
51
|
+
throw new Error(`${flag} and ${fileFlag} are mutually exclusive`);
|
|
52
|
+
}
|
|
53
|
+
if (fileValue !== undefined) {
|
|
54
|
+
return readTextFileArg(fileFlag, fileValue).replace(/\r?\n$/, '');
|
|
55
|
+
}
|
|
56
|
+
if (value === '-') {
|
|
57
|
+
throw new Error(`${flag} - is the literal string "-", not stdin; to read from stdin use ${fileFlag} - (a pipe or a quoted heredoc <<'EOF')`);
|
|
34
58
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
/** `resolveTextInput` for flags where the text is mandatory. */
|
|
62
|
+
export function requireTextInput(spec) {
|
|
63
|
+
const text = resolveTextInput(spec);
|
|
64
|
+
if (text === undefined) {
|
|
65
|
+
throw new Error(`Provide ${spec.flag} or ${spec.fileFlag}`);
|
|
66
|
+
}
|
|
67
|
+
return text;
|
|
68
|
+
}
|
|
69
|
+
/** Message body from `--text` / `--text-file` (`messages send`, `dm`, channel sends). */
|
|
70
|
+
export function resolveMessageText(opts) {
|
|
71
|
+
return resolveTextInput({
|
|
72
|
+
flag: '--text',
|
|
73
|
+
fileFlag: '--text-file',
|
|
74
|
+
value: opts.text,
|
|
75
|
+
fileValue: opts.textFile,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/** Comment body from `--body` / `--body-file` (every `comments add|update` verb). */
|
|
79
|
+
export function resolveCommentBody(opts) {
|
|
80
|
+
return requireTextInput({
|
|
81
|
+
flag: '--body',
|
|
82
|
+
fileFlag: '--body-file',
|
|
83
|
+
value: opts.body,
|
|
84
|
+
fileValue: opts.bodyFile,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/** Task description from `--description` / `--description-file` (`tasks create|update`). */
|
|
88
|
+
export function resolveTaskDescription(opts) {
|
|
89
|
+
return resolveTextInput({
|
|
90
|
+
flag: '--description',
|
|
91
|
+
fileFlag: '--description-file',
|
|
92
|
+
value: opts.description,
|
|
93
|
+
fileValue: opts.descriptionFile,
|
|
94
|
+
});
|
|
38
95
|
}
|
|
39
96
|
/**
|
|
40
|
-
* Read the payload of a file-input flag (`--text-file`, `--
|
|
41
|
-
* path or stdin (`-`). Shared so every such flag keeps
|
|
42
|
-
* guarantees: stdin drains a pipe/heredoc synchronously, an
|
|
43
|
-
* refused instead of hanging the dispatch, and a read
|
|
44
|
-
* underlying reason under the flag's own name.
|
|
97
|
+
* Read the payload of a file-input flag (`--text-file`, `--body-file`,
|
|
98
|
+
* `--args-file`) from a path or stdin (`-`). Shared so every such flag keeps
|
|
99
|
+
* the same three guarantees: stdin drains a pipe/heredoc synchronously, an
|
|
100
|
+
* interactive TTY is refused instead of hanging the dispatch, and a read
|
|
101
|
+
* failure surfaces its underlying reason under the flag's own name.
|
|
45
102
|
*/
|
|
46
103
|
export function readTextFileArg(flag, value) {
|
|
47
104
|
if (value === '-') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parall/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.58.1",
|
|
4
4
|
"description": "CLI client for Parall — universal agent & human access to Parall API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"diff": "^8.0.3",
|
|
37
37
|
"js-yaml": "^4.1.0",
|
|
38
38
|
"zod": "^4.3.6",
|
|
39
|
-
"@parall/agent-core": "1.
|
|
40
|
-
"@parall/sdk": "1.
|
|
39
|
+
"@parall/agent-core": "1.58.1",
|
|
40
|
+
"@parall/sdk": "1.58.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/js-yaml": "^4.0.9",
|
|
44
44
|
"@types/node": "^22.0.0",
|
|
45
45
|
"typescript": "^5.7.0",
|
|
46
|
-
"@parall/agent-core": "1.
|
|
46
|
+
"@parall/agent-core": "1.58.1"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsc",
|