@parall/cli 1.58.2 → 1.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../../src/commands/slack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,QA4IrD"}
1
+ {"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../../src/commands/slack.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,QA8NrD"}
@@ -1,3 +1,5 @@
1
+ import * as fs from 'node:fs';
2
+ import * as path from 'node:path';
1
3
  import { resolveCredentials } from '../lib/client.js';
2
4
  import { printError, printJson } from '../lib/output.js';
3
5
  import { resolveMessageText, TEXT_FILE_OPTION_DESC, TEXT_OPTION_DESC } from '../lib/text-input.js';
@@ -24,13 +26,36 @@ export function registerSlackCommands(program) {
24
26
  .option('--text <text>', TEXT_OPTION_DESC)
25
27
  .option('--text-file <path>', TEXT_FILE_OPTION_DESC)
26
28
  .option('--reply-to <messageId>', 'Inbound message id you are answering ({channel}:{ts}, thread children {channel}:{root}#{ts}); REQUIRED in channels (reply lands in its thread). In DMs pass it too: a thread-child id lands the reply in that thread, a bare id keeps the main flow — the session never forks either way')
29
+ .option('--file <path>', 'Attach a local file: it posts into the addressed conversation/thread with --text as the comment')
27
30
  .action(async (opts) => {
28
31
  try {
29
32
  const text = resolveMessageText(opts);
33
+ const { client, orgId } = resolveCredentials();
34
+ if (opts.file) {
35
+ const filePath = path.resolve(opts.file);
36
+ // Pre-check before reading: the server caps files at 100MB, so an
37
+ // oversize input must fail here instead of exhausting CLI memory.
38
+ const stat = fs.statSync(filePath);
39
+ if (!stat.isFile()) {
40
+ throw new Error(`--file must be a regular file: ${filePath}`);
41
+ }
42
+ if (stat.size > 100 * 1024 * 1024) {
43
+ throw new Error(`--file exceeds the 100MB slack file limit (${stat.size} bytes)`);
44
+ }
45
+ const content = fs.readFileSync(filePath);
46
+ const sent = await client.sendSlackFile(orgId, {
47
+ conversationId: opts.channel,
48
+ fileName: path.basename(filePath),
49
+ content: new Blob([content]),
50
+ ...(opts.replyTo ? { replyTo: opts.replyTo } : {}),
51
+ ...(text ? { text } : {}),
52
+ });
53
+ printJson(sent);
54
+ return;
55
+ }
30
56
  if (text === undefined || text === '') {
31
- throw new Error('Provide --text or --text-file');
57
+ throw new Error('Provide --text, --text-file or --file');
32
58
  }
33
- const { client, orgId } = resolveCredentials();
34
59
  const sent = await client.sendChannelMessage(orgId, {
35
60
  channel_type: 'slack',
36
61
  conversation_id: opts.channel,
@@ -43,6 +68,51 @@ export function registerSlackCommands(program) {
43
68
  printError(err);
44
69
  }
45
70
  });
71
+ slack
72
+ .command('file')
73
+ .description('Download an inbound Slack file attachment into the working directory')
74
+ .requiredOption('--id <fileId>', 'Slack file id from the inbound attachment placeholder (e.g. F0123ABCD)')
75
+ .option('-o, --output <path>', 'Output file path (default: ./{original_filename})')
76
+ .option('--force', 'Overwrite an existing file at the output path')
77
+ .action(async (opts) => {
78
+ try {
79
+ const { client, orgId } = resolveCredentials();
80
+ const file = await client.downloadSlackFile(orgId, opts.id);
81
+ const safeName = path.basename(file.fileName || opts.id);
82
+ const outputPath = opts.output ? path.resolve(opts.output) : path.resolve(safeName);
83
+ const finalPath = fs.existsSync(outputPath) && fs.statSync(outputPath).isDirectory()
84
+ ? path.join(outputPath, safeName)
85
+ : outputPath;
86
+ // The sender controls the file name — refuse to clobber an existing
87
+ // file unless the caller explicitly asked to, and never follow a
88
+ // symlink even then (a same-named link would redirect the write to
89
+ // its target).
90
+ let existing;
91
+ try {
92
+ existing = fs.lstatSync(finalPath);
93
+ }
94
+ catch {
95
+ existing = undefined;
96
+ }
97
+ if (existing?.isSymbolicLink()) {
98
+ throw new Error(`Refusing to write through a symlink: ${finalPath} — pass -o <path>`);
99
+ }
100
+ fs.writeFileSync(finalPath, Buffer.from(file.data), { flag: opts.force ? 'w' : 'wx' });
101
+ printJson({
102
+ path: finalPath,
103
+ file_name: safeName,
104
+ file_size: file.data.byteLength,
105
+ mime_type: file.mimeType,
106
+ });
107
+ }
108
+ catch (err) {
109
+ if (err?.code === 'EEXIST') {
110
+ printError(new Error('Output file already exists — pass --force to overwrite, or -o <path>'));
111
+ return;
112
+ }
113
+ printError(err);
114
+ }
115
+ });
46
116
  // Read verbs: workspace visibility as the bot sees it. Authorization is
47
117
  // the bot's own Slack permissions (invite it to a channel to read that
48
118
  // channel's history) — reads are not limited to seen conversations.
@@ -1 +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"}
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;AAuBzC,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,CA4G5D"}
@@ -8,8 +8,10 @@ import { printError, printJson } from '../lib/output.js';
8
8
  // and a temporary flip: `<value> until <time>` receives <value> until then
9
9
  // and goes back to the other value. `--catch-up` on `mentions until` asks
10
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.
11
+ // Targets: a chat (cht_), a thread root (msg_) or an external IM
12
+ // conversation root (chv_ — a Slack/Feishu group the agent's bound channel
13
+ // sees; thread rows inherit). Threads are watched on first use; chats need
14
+ // membership; a DM with a person (in-app or external) has no setting.
13
15
  // Tasks carry no setting: `parall watch <task>` / `parall unwatch <task>`.
14
16
  // A temporary setting needs the runtime contract — older runtimes get 422
15
17
  // RUNTIME_CONTRACT_REQUIRED.
@@ -88,7 +90,7 @@ export function registerWatchCommands(program) {
88
90
  return;
89
91
  }
90
92
  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`');
93
+ throw new Error('watch takes a thread root (msg_) or a task (tsk_); for a chat or external conversation use `parall watch set <target> all|mentions`');
92
94
  }
93
95
  const body = { target_uri: uri, level: 'all' };
94
96
  if (opts.until)
@@ -113,8 +115,8 @@ export function registerWatchCommands(program) {
113
115
  });
114
116
  watch
115
117
  .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
+ .description('Set what you receive on a chat, thread root or external conversation: all | mentions [until <time>]')
119
+ .argument('<target>', 'prll:// URI: chat (cht_), thread root (msg_) or external conversation (chv_)')
118
120
  .argument('<value...>', 'all | mentions [until tomorrow|2h|RFC3339]')
119
121
  .option('--catch-up', 'with `mentions until`: one wake when the mute lapses with unread activity')
120
122
  .action(async (target, value, opts) => {
@@ -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;AA0BpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,QAs/BpD"}
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,QA4/BpD"}
@@ -231,6 +231,10 @@ export function registerWikiCommands(program) {
231
231
  process.stderr.write(`${verb} changeset ${result.changeset.id} (${result.status})\n`);
232
232
  }
233
233
  process.stderr.write(`Changed files: ${result.changed_paths.join(', ')}\n`);
234
+ if (result.stale_recovery) {
235
+ const moved = result.stale_recovery.stale_paths.join(', ') || 'server check';
236
+ process.stderr.write(`Server had moved since your last sync (${moved}); re-synced and re-proposed automatically.\n`);
237
+ }
234
238
  process.stderr.write(`Next: ${result.next_action}\n`);
235
239
  printJson(result);
236
240
  }
@@ -0,0 +1,67 @@
1
+ import { type MarkdownFile, type ParallContext, type ReadableWiki, type WikiContentSource, type WikiNodeSection, type WikiQueryDocument, type WikiQuerySectionResult, type WikiSearchResult } from './wiki-shared.js';
2
+ type CachedNodeSection = WikiNodeSection & {
3
+ content: string;
4
+ };
5
+ type IndexedNode = {
6
+ section: CachedNodeSection;
7
+ content: string;
8
+ lowerPath: string;
9
+ lowerTitle: string;
10
+ lowerBody: string;
11
+ lowerJoined: string;
12
+ termFreq: Map<string, number>;
13
+ docLen: number;
14
+ };
15
+ type MarkdownFileDescriptor = {
16
+ path: string;
17
+ size: number;
18
+ mtime_ms: number;
19
+ };
20
+ type LocalNodeSectionFileArtifact = MarkdownFileDescriptor & {
21
+ nodes: CachedNodeSection[];
22
+ };
23
+ type LocalNodeSectionArtifact = {
24
+ version: number;
25
+ generated_at: string;
26
+ wiki_id: string;
27
+ wiki_slug: string;
28
+ wiki_name: string;
29
+ file_count: number;
30
+ files: LocalNodeSectionFileArtifact[];
31
+ };
32
+ type LoadedNodeSectionSet = {
33
+ kind: WikiContentSource;
34
+ generatedAt: string;
35
+ fileCount: number;
36
+ sections: CachedNodeSection[];
37
+ };
38
+ export declare function loadWikiNodeSections(ctx: ParallContext, wiki: ReadableWiki, options?: {
39
+ ref?: string;
40
+ pathPrefix?: string;
41
+ }): Promise<LoadedNodeSectionSet>;
42
+ export declare function tryLoadLocalNodeSections(ctx: ParallContext, wiki: ReadableWiki, pathPrefix?: string): Promise<LocalNodeSectionArtifact | null>;
43
+ export declare function findLocalNodeSection(artifact: LocalNodeSectionArtifact, nodeId: string): CachedNodeSection | undefined;
44
+ export declare function stripNodeSectionContent(section: CachedNodeSection): WikiNodeSection;
45
+ export declare function buildIndexNodes(sections: CachedNodeSection[]): IndexedNode[];
46
+ export declare function parseMarkdownFile(wiki: ReadableWiki, file: MarkdownFile): CachedNodeSection[];
47
+ export declare function scoreNodes(nodes: IndexedNode[], query: string, options: {
48
+ limit?: number;
49
+ includeContent?: boolean;
50
+ source: 'local_mount' | 'api';
51
+ }): WikiSearchResult[];
52
+ export declare function planWikiQuery(sections: CachedNodeSection[], query: string, options: {
53
+ limit?: number;
54
+ includeContent?: boolean;
55
+ source: WikiContentSource;
56
+ }): {
57
+ documents: WikiQueryDocument[];
58
+ sections: WikiQuerySectionResult[];
59
+ };
60
+ export declare function detectFrontMatterEnd(lines: string[]): number;
61
+ export declare function parseNodeId(nodeId: string): {
62
+ path: string;
63
+ kind: 'doc' | 'preface' | 'line';
64
+ line?: number;
65
+ };
66
+ export {};
67
+ //# sourceMappingURL=wiki-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wiki-index.d.ts","sourceRoot":"","sources":["../../src/lib/wiki-index.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EAWtB,MAAM,kBAAkB,CAAC;AAE1B,KAAK,iBAAiB,GAAG,eAAe,GAAG;IACzC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAqBF,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,4BAA4B,GAAG,sBAAsB,GAAG;IAC3D,KAAK,EAAE,iBAAiB,EAAE,CAAC;CAC5B,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAG9B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM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