claude-message 0.2.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/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # claude-message
2
+
3
+ `claude-message` wraps `claude -p --output-format json` and uses `agent-message`
4
+ as its transport layer.
5
+
6
+ Install:
7
+
8
+ ```bash
9
+ npm install -g agent-message claude-message
10
+ ```
11
+
12
+ `claude-message` expects both `agent-message` and the `claude` CLI to already
13
+ be available on your `PATH`.
14
+
15
+ Behavior:
16
+
17
+ 1. Starts a fresh `agent-{chatId}` account with a generated password.
18
+ 2. Sends the `--to` user a startup message with the generated credentials.
19
+ 3. Reuses the Claude `session_id` for the DM session and resumes later turns.
20
+ 4. Watches `agent-message` DMs for plain-text requests, adds a `👀` reaction to
21
+ each accepted inbound DM, and posts Claude's JSON result back as
22
+ `json_render`.
23
+ 5. After a successful turn completion, replaces the inbound `👀` reaction with
24
+ `✅`.
25
+
26
+ Example:
27
+
28
+ ```bash
29
+ claude-message --to jay --model sonnet --permission-mode accept-edits
30
+ ```
31
+
32
+ Build from the repo root:
33
+
34
+ ```bash
35
+ make claude-message-build
36
+ ./claude-message/target/debug/claude-message --to jay --model sonnet
37
+ ```
38
+
39
+ Useful flags:
40
+
41
+ - `--to jay`
42
+ - `--cwd /path/to/worktree`
43
+ - `--model sonnet`
44
+ - `--permission-mode accept-edits`
45
+ - `--allowed-tools Read,Edit`
46
+ - `--bare`
47
+
48
+ Notes:
49
+
50
+ - `claude-message` always passes `--dangerously-skip-permissions` to Claude.
51
+ - The wrapper therefore does not pause for Claude permission approvals.
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { accessSync, constants, existsSync } from 'node:fs'
4
+ import { delimiter, dirname, join, resolve } from 'node:path'
5
+ import process from 'node:process'
6
+ import { spawnSync } from 'node:child_process'
7
+ import { fileURLToPath } from 'node:url'
8
+
9
+ const scriptDir = dirname(fileURLToPath(import.meta.url))
10
+ const packageRoot = resolve(scriptDir, '..', '..')
11
+ const runtimeBinDir = resolve(packageRoot, 'npm', 'runtime', 'bin')
12
+
13
+ function resolveBinaryPath() {
14
+ if (process.platform !== 'darwin') {
15
+ throw new Error(`unsupported platform: ${process.platform}. This package currently supports macOS only.`)
16
+ }
17
+
18
+ if (process.arch === 'arm64') {
19
+ return join(runtimeBinDir, 'claude-message-darwin-arm64')
20
+ }
21
+ if (process.arch === 'x64') {
22
+ return join(runtimeBinDir, 'claude-message-darwin-amd64')
23
+ }
24
+
25
+ throw new Error(`unsupported architecture: ${process.arch}. Expected arm64 or x64 on macOS.`)
26
+ }
27
+
28
+ function findOnPath(command) {
29
+ const pathValue = process.env.PATH ?? ''
30
+ for (const entry of pathValue.split(delimiter)) {
31
+ if (!entry) {
32
+ continue
33
+ }
34
+ const candidate = join(entry, command)
35
+ try {
36
+ accessSync(candidate, constants.X_OK)
37
+ return candidate
38
+ } catch {}
39
+ }
40
+ return null
41
+ }
42
+
43
+ function requireCommand(command, installHint) {
44
+ if (findOnPath(command)) {
45
+ return
46
+ }
47
+ console.error(`${command} was not found on PATH. ${installHint}`)
48
+ process.exit(1)
49
+ }
50
+
51
+ const binaryPath = resolveBinaryPath()
52
+ if (!existsSync(binaryPath)) {
53
+ console.error(`packaged claude-message binary is missing at ${binaryPath}. Reinstall the package or rebuild the npm bundle.`)
54
+ process.exit(1)
55
+ }
56
+
57
+ requireCommand('agent-message', 'Install it first with `npm install -g agent-message`.')
58
+ requireCommand('claude', 'Install the Claude CLI before running claude-message.')
59
+
60
+ const child = spawnSync(binaryPath, process.argv.slice(2), {
61
+ stdio: 'inherit',
62
+ cwd: process.cwd(),
63
+ env: process.env,
64
+ })
65
+
66
+ if (child.error) {
67
+ console.error(child.error.message)
68
+ process.exit(1)
69
+ }
70
+
71
+ process.exit(child.status ?? 0)
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "claude-message",
3
+ "version": "0.2.0",
4
+ "description": "Claude wrapper for agent-message on macOS",
5
+ "type": "module",
6
+ "bin": {
7
+ "claude-message": "./npm/bin/claude-message.mjs"
8
+ },
9
+ "files": [
10
+ "README.md",
11
+ "npm/bin",
12
+ "npm/runtime"
13
+ ],
14
+ "scripts": {
15
+ "prepare:npm-bundle": "node ./scripts/prepare-npm-bundle.mjs",
16
+ "prepack": "node ./scripts/prepare-npm-bundle.mjs",
17
+ "pack:dry-run": "npm pack --dry-run"
18
+ },
19
+ "engines": {
20
+ "node": ">=18"
21
+ },
22
+ "os": [
23
+ "darwin"
24
+ ],
25
+ "cpu": [
26
+ "arm64",
27
+ "x64"
28
+ ],
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/siisee11/agent-message.git",
32
+ "directory": "claude-message"
33
+ }
34
+ }