Lines 1-62typescript
1import { execFile } from 'child_process'
2import { rmSync } from 'fs'
HighChild Process
Package source references child process execution.
src/reply/post.tsView on unpkg · L1 3import type { Platform } from '../index.js'
4import { createClawstrTempHome } from '../index.js'
5import { parseClawstrReplyResult } from './clawstr.js'
6import type { ReplierApiKeys, ReplyPostResult } from './types.js'
8async function replyOnMoltx(parentExternalId: string, content: string, apiKey: string): Promise<ReplyPostResult> {
9 const res = await fetch('https://moltx.io/v1/posts', {
11 headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
12 body: JSON.stringify({ type: 'reply', parent_id: parentExternalId, content }),
14 if (!res.ok) throw new Error(`Moltx reply API ${res.status}: ${await res.text()}`)
15 const raw = await res.json()
16 const wrapper = raw as { data?: { post?: { id?: string }; id?: string }; id?: string }
17 const externalId = wrapper?.data?.post?.id || wrapper?.data?.id || wrapper?.id || ''
19 throw new Error(`Moltx reply API returned no reply id: ${JSON.stringify(raw).slice(0, 200)}`)
21 return { externalId, url: externalId ? `https://moltx.io/post/${externalId}` : undefined }
24async function replyOnMoltbook(postExternalId: string, commentExternalId: string, content: string, apiKey: string): Promise<ReplyPostResult> {
25 const res = await fetch(`https://www.moltbook.com/api/v1/posts/${postExternalId}/comments`, {
27 headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
28 body: JSON.stringify({ content, parent_id: commentExternalId }),
30 if (!res.ok) throw new Error(`Moltbook reply API ${res.status}: ${await res.text()}`)
31 const raw = await res.json()
32 const wrapper = raw as { comment?: { id?: string }; id?: string }
33 const externalId = wrapper?.comment?.id || wrapper?.id || ''
35 throw new Error(`Moltbook reply API returned no reply id: ${JSON.stringify(raw).slice(0, 200)}`)
37 return { externalId, url: externalId ? `https://www.moltbook.com/comment/${externalId}` : undefined }
40async function replyOnClawstr(noteExternalId: string, content: string, secretKey: string): Promise<ReplyPostResult> {
41 const tmpHome = createClawstrTempHome(secretKey)
42 return new Promise((resolve, reject) => {
43 execFile('npx', ['-y', '@clawstr/cli@latest', 'reply', noteExternalId, content], { timeout: 60_000, env: { ...process.env, HOME: tmpHome } }, (error, stdout, stderr) => {
44 try { rmSync(tmpHome, { recursive: true, force: true }) } catch { /* ignore */ }
HighCommand Output Exfiltration
Source combines command execution, command-output handling, and outbound requests; review data flow before blocking.
src/reply/post.tsView on unpkg · L27 HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
src/reply/post.tsView on unpkg · L36 HighRuntime Package Install
Package source invokes a package manager install command at runtime.
src/reply/post.tsView on unpkg · L42 46 reject(new Error(`Clawstr reply CLI failed: ${error.message}${stderr ? ` stderr: ${stderr}` : ''}`))
50 resolve(parseClawstrReplyResult(stdout, stderr))
51 } catch (parseError) {
52 reject(parseError instanceof Error ? parseError : new Error(String(parseError)))
58export async function postReplyOnPlatform(
60 parentPostExternalId: string,
61 parentReplyExternalId: string,