Skip to content

fix: convert send_message skill from TS to plain Node.js#195

Merged
jlia0 merged 1 commit intomainfrom
fix/send-message-script
Mar 12, 2026
Merged

fix: convert send_message skill from TS to plain Node.js#195
jlia0 merged 1 commit intomainfrom
fix/send-message-script

Conversation

@jlia0
Copy link
Copy Markdown
Collaborator

@jlia0 jlia0 commented Mar 12, 2026

Summary

  • Converted send_message.ts to send_message.js (plain Node.js) to fix ts-node compilation failure caused by missing @types/node
  • Updated send-message.sh wrapper to invoke node directly instead of npx ts-node
  • Removed tsconfig.json as it's no longer needed

Test plan

  • node send_message.js list-targets runs without errors
  • bash send-message.sh list-targets runs without errors
  • Verify send command works end-to-end with a live API

🤖 Generated with Claude Code

ts-node compilation was failing because @types/node wasn't installed.
Converted to plain JS to eliminate the ts-node and @types/node
dependency entirely. Removed tsconfig.json as it's no longer needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 12, 2026

Greptile Summary

This PR converts the send_message skill from TypeScript (requiring ts-node and @types/node) to plain CommonJS Node.js, resolving a compilation failure due to a missing @types/node dependency. The shell wrapper is updated to invoke node directly, and the now-unnecessary tsconfig.json is removed.

  • Conversion from import/TypeScript to require()/CommonJS is correct; all TypeScript-specific constructs (type annotations, interfaces) are properly removed
  • os module is correctly promoted from an inline require('os').homedir() call to a top-level const os = require('os')
  • send-message.sh correctly drops the npx ts-node --project tsconfig.json invocation in favour of plain node
  • tsconfig.json deletion is appropriate — no TypeScript artefacts remain
  • The fetch global used in sendMessage() requires Node.js ≥ 18; this was already the case in the TypeScript version, but worth keeping in mind if the deployment environment has not been validated against this requirement
  • main() is called without a .catch() handler, which leaves async errors as unhandled promise rejections (see inline comment)

Confidence Score: 4/5

  • Safe to merge; this is a straightforward TS-to-JS conversion with no behavioural changes.
  • The conversion is mechanically correct and removes an external build-time dependency. The only issue found is a missing .catch() on the top-level main() call, which is a minor best-practice gap that does not affect normal successful execution.
  • .agents/skills/send-user-message/scripts/send_message.js — add .catch() on the main() invocation at line 177.

Important Files Changed

Filename Overview
.agents/skills/send-user-message/scripts/send_message.js TypeScript converted cleanly to CommonJS plain JS; types/interfaces removed, imports converted to require(). Minor: main() is called without a .catch() handler, leaving async errors as unhandled promise rejections.
.agents/skills/send-user-message/scripts/send-message.sh Wrapper updated from npx ts-node --project tsconfig.json send_message.ts to node send_message.js; change is correct and straightforward.
.agents/skills/send-user-message/scripts/tsconfig.json Deleted as expected — no longer needed since the TypeScript source has been converted to plain JS.

Sequence Diagram

sequenceDiagram
    participant Agent
    participant send-message.sh
    participant send_message.js
    participant TinyClaw API

    Agent->>send-message.sh: bash send-message.sh send --channel telegram ...
    send-message.sh->>send_message.js: exec node send_message.js send ...
    send_message.js->>send_message.js: parseArgs(argv)
    send_message.js->>send_message.js: validate required args & channel
    send_message.js->>TinyClaw API: POST /api/responses (fetch)
    TinyClaw API-->>send_message.js: { ok, messageId }
    send_message.js-->>Agent: console.log("Message queued: ...")
Loading

Comments Outside Diff (1)

  1. .agents/skills/send-user-message/scripts/send_message.js, line 177 (link)

    Unhandled promise rejection on main() call

    main() is an async function but is invoked without a .catch() handler. If sendMessage() throws (e.g., fetch rejects due to a network error or the API is unreachable), the rejection propagates to main() and becomes an unhandled promise rejection. While Node.js 15+ will still exit with a non-zero code, the error output may be less clean than a direct console.error call, and it silently misbehaves on older Node versions.

Last reviewed commit: 9012398

@jlia0 jlia0 merged commit 8e4b3ec into main Mar 12, 2026
1 check passed
@jlia0 jlia0 deleted the fix/send-message-script branch March 12, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant