269 Commits

Author SHA1 Message Date
0xmrpeter
2a5fab1bff feat(speech): enhance speech module with system message handling and configuration updates
- Added support for system messages in Discord and Telegram adapters, allowing for better integration of speech functionalities.
- Updated configuration schemas to include speech settings for STT and TTS providers, with environment variable overrides for easier setup.
- Enhanced session processing to transcribe audio attachments when agents lack audio capabilities, improving user experience.
- Introduced comprehensive tests for the new speech features, ensuring reliability and functionality across the system.
2026-03-23 22:29:28 +07:00
0xmrpeter
de9893f4c9 Merge branch 'develop' of github.com:Open-ACP/OpenACP into feat/speech-module 2026-03-23 21:41:35 +07:00
Peter Parker
8639966e1d
Feature/cost tracking budget planning (#29)
* docs: add cost tracking & budget limits design spec

New feature spec for session-level usage tracking with JSON file
persistence, configurable monthly budget warnings, and Telegram
/usage command for on-demand reporting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: add cost tracking & budget limits implementation plan

8-task TDD plan covering UsageStore, UsageBudget, config schema,
core wiring, formatting helpers, and /usage Telegram command.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(core): implement session cost tracking & budget limits

- Add UsageStore with JSON persistence, calendar-month queries, and retention cleanup
- Add UsageBudget with threshold checking, de-duplication, and injectable date provider
- Add UsageSchema to config (derived UsageConfig type as single source of truth)
- Wire usage event tracking and budget warnings into OpenACPCore
- Add /usage Telegram command with formatUsageReport helper
- Add 25 tests covering store, budget, and formatting
- Update implementation plan per review feedback (#1-6)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address review feedback on cost tracking implementation

🔴 Must fix:
- destroy() now calls flushSync() before cleanup to prevent data loss

🟡 Should fix:
- usageStore/usageBudget marked readonly to prevent accidental reassignment
- Replace inline import type with top-level import in formatting.ts

â„šī¸ Nits:
- Rename usage-command.test.ts → usage-formatting.test.ts (tests formatUsageReport, not command)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: peter <peter@lab3.asia>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 18:12:12 +07:00
lngdao
f112941079
fix(tunnel): scope /tunnels to current session + update README (#45)
- /tunnels in session topic now shows only that session's tunnels
- /tunnels in assistant topic shows all tunnels
- README: move tunnel from nav heading to features section with link
2026-03-23 17:54:54 +07:00
Peter Parker
0ca7f35d0f
feat(telegram): /archive command for session topics (#44)
* docs: add /clear session topic design spec and implementation plan

- Design spec covers topic recreation approach, confirmation flow, error handling
- Implementation plan with 6 TDD tasks: store update, topic helpers, adapter method, command expansion, tests, verification
- Extends existing /clear (assistant-only) to work in session topics

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: update /archive spec and plan per review feedback

- Rename /clear → /archive (user-friendly, aligns with Gmail/Slack patterns)
- Separate from existing /clear (assistant-only stays untouched)
- Add core archiveSession() + API endpoint (POST /sessions/:id/archive)
- Add assistant guidance when /archive used in wrong topic
- Use patchRecord() instead of new updatePlatformData method
- Fix: setupMenuCallbacks alias, chatId access, missing vi import in tests
- Fix: handleArchiveConfirm tests for success/cancel/error paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: address review feedback on /archive spec and plan

1. Fix API response type: use newThreadId (string) consistently
2. Add try/catch for orphan recovery between topic delete and create
3. Spread existing platform data in patchRecord to preserve skillMsgId
4. Add session.archiving flag to buffer events during transition
5. Rewrite core tests with full mock flow (adapter delegation, error paths)
6. Add explicit escapeHtml import line in session.ts
7. Strip existing 🔄 prefix to prevent emoji stacking on repeated archives

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: implement /archive command for session topics

- Add archiveSession() to OpenACPCore with validation and error handling
- Add archiveSessionTopic() to ChannelAdapter base (no-op default)
- Implement Telegram adapter: topic delete → create → rewire with orphan recovery
- Add /archive command with confirmation flow (ar: callback prefix)
- Add POST /api/sessions/:id/archive endpoint
- Strip 🔄 prefix on repeated archives to prevent emoji stacking
- Spread existing platform data in patchRecord to preserve skillMsgId
- 13 tests covering command, confirm, cancel, error, and core integration

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(test): fix setup-integration timeout by mocking cloudflared download

- Mock ensureCloudflared to avoid real network download during test
- Increase test timeout to 15s for setup wizard flow

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address 4 review findings on /archive implementation

1. Add session.archiving flag to Session class, set during topic
   recreation, guard sendMessage to drop events during transition
2. Fix skillMsgId cleanup: use delete instead of undefined assignment
3. Add /archive to handleHelp text in menu.ts
4. Guard non-active sessions (finished/cancelled/error) in handleArchive
   with early return instead of showing doomed confirmation dialog

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: peter <peter@lab3.asia>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 17:48:20 +07:00
0xmrpeter
9b81d2cc67 chore: release v0.6.0
- Full Discord adapter: forum channels, streaming, permissions, activity tracking, media support
- Discord interactive setup and doctor health check
- Channel selection in CLI config editor and onboarding
- Security: file-based token auth for API server, XML/systemd injection escaping
- Fix: wait for process exit before removing PID file
- Comprehensive documentation for CLI, daemon, API, and Discord setup

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v0.6.0
2026-03-23 17:41:45 +07:00
Mr.Peter
04e9d33da7
Merge pull request #34 from dylan-112/develop
fix: critical security and reliability fixes (issue #21)
2026-03-23 17:38:58 +07:00
dylan
dcefe3f80f docs: add Discord setup guide and onboarding instructions
- Create detailed discord-setup.md with step-by-step bot creation, permissions, and troubleshooting
- Show quick setup steps and link to guide during Discord onboarding wizard
- Add Discord Setup link in getting-started.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 5fd77a225732
2026-03-23 17:05:48 +07:00
0xmrpeter
0fccd7ce1c chore: release v0.5.3
- Dynamic tunnel registry: multi-port tunnels with per-port cloudflared process
- Telegram /tunnel commands and CLI tunnel add/list/stop subcommands
- Agent tunnel skill for Claude (expose port, share app, preview on phone)
- Fix command handling: strip leading slashes to prevent agent subprocess hangs
- Fix session resumption: allow resuming cancelled sessions
- Prompt queue abort functionality
- Tunnel API backward compat and keyboard refresh fixes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v0.5.3
2026-03-23 17:04:16 +07:00
0xmrpeter
5a3c32ce41 feat(speech): implement speech module with STT/TTS capabilities
- Added a new speech module to OpenACP, featuring a pluggable architecture for Speech-to-Text (STT) and Text-to-Speech (TTS) functionalities.
- Created interfaces for STT and TTS providers, along with a SpeechService orchestrator to manage provider interactions.
- Integrated Groq Whisper as the default STT provider, allowing for automatic transcription of voice messages.
- Updated configuration schemas to support speech settings and added environment variable overrides.
- Enhanced session processing to utilize the new speech capabilities, ensuring seamless integration with existing message flows.
- Included comprehensive tests for the SpeechService and its providers to ensure reliability and functionality.
2026-03-23 17:02:13 +07:00
Mr.Peter
b6c7c17882
Merge pull request #43 from lngdao/feat/tunnel-port-registry
feat(tunnel): dynamic port registry with CLI, Telegram commands, and agent skill
2026-03-23 17:01:10 +07:00
lngdao
421d74b678 fix(tunnel): address PR #43 review — API compat, keyboard refresh, naming
- Keep GET /api/tunnel returning { enabled, url, provider } for backward
  compat. New list endpoint at GET /api/tunnel/list.
- Re-attach inline keyboard after stop callback so remaining tunnels
  keep their Stop buttons.
- Remove unnecessary (config as any) cast for maxUserTunnels.
- Skip system entries in restore() to prevent double-registration.
- Rename stopAll() → shutdown() (kills everything including system).
  Add stopAllUser() for user-facing operations.
2026-03-23 16:40:16 +07:00
0xmrpeter
31e707c238 fix(telegram): improve command handling and session management
- Added text processing to strip leading slashes from unrecognized commands in the Telegram adapter to prevent agent subprocesses from hanging.
- Updated session cancellation messages for clarity, changing "Cancel session command" to "Abort prompt command" and adjusting user feedback for session status.
- Modified session resumption logic to allow resuming cancelled sessions while preventing errors from being resumed.
- Implemented abort functionality in the prompt queue to handle ongoing processes more gracefully.
2026-03-23 16:01:17 +07:00
dylan
963ae0dece fix(discord): address PR #34 review issues
- Fix session storage: use `platform.threadId` instead of `topicId` for Discord
- Fix private field access: use getForumChannel(), getGuildId(), getGuild() accessors
- Fix error path: archive+lock orphaned threads instead of permanent delete
- Fix cleanup: read both threadId and topicId for backward compat with old records
- Add getGuild() public accessor for commands that need the Guild object
- Add debug/info logging for incoming attachments and processing results
- Filter unsupported image MIME types in agent-instance prompt
- Update README roadmap: Discord adapter status ✅ → 🚧

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 718e9f65637b
2026-03-23 15:13:36 +07:00
dylan
5b1b38c54b feat(discord): add outgoing attachment support
Handle 'attachment' case in sendMessage() — sends agent-generated
files, images, and audio to Discord threads. 25MB size limit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: f8074d7879ae
2026-03-23 14:53:40 +07:00
dylan
f5270e9df8 fix(docs): correct outdated docs and remove unwanted husky hooks
- Replace fabricated `openacp runtime` commands with actual `openacp api`
- Update getting-started.md setup wizard to reflect current flow (channel selection, Discord support, run mode step)
- Remove Entire CLI husky hooks (commit-msg, post-commit, pre-push, prepare-commit-msg) that were added without request

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 11997f530f30
2026-03-23 14:53:16 +07:00
dylan
5dca72de1d feat(discord): add incoming media support
Extract attachments from Discord messages, download files, convert
voice messages (OGG→WAV), save via FileService, route to agent.
Supports multiple attachments per message with parallel downloads.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 452041c47940
2026-03-23 14:51:39 +07:00
dylan
1f0a70d62f feat(discord): add media helper functions with tests
classifyAttachmentType, buildFallbackText, isAttachmentTooLarge, downloadDiscordAttachment

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 50f750997aa8
2026-03-23 14:48:44 +07:00
lngdao
144ae497bc feat(tunnel): dynamic port registry with CLI, Telegram commands, and agent skill
Tunnel Registry:
- Multi-port registry: each port gets its own cloudflared process + URL
- Two entry types: system (file viewer, hidden) and user (managed)
- Persistence to ~/.openacp/tunnels.json with debounced writes
- Restore tunnels on restart (re-spawn with new URLs)
- Max concurrent user tunnels (default: 5, configurable)
- Race condition handling for stop during spawn
- Provider-per-entry from TunnelProvider abstraction

Telegram:
- /tunnel <port> [label] — create tunnel
- /tunnels — list with inline Stop buttons
- /tunnel stop <port> — stop tunnel
- Session destroy auto-stops user tunnels with notification

CLI:
- openacp tunnel add/list/stop/stop-all subcommands
- Calls daemon API endpoints

Daemon API:
- POST /api/tunnel — create tunnel
- GET /api/tunnel — list user tunnels
- DELETE /api/tunnel/:port — stop tunnel
- DELETE /api/tunnel — stop all user tunnels

Agent Integration:
- Tunnel skill installed via openacp integrate claude
- ~/.claude/skills/openacp-tunnel/SKILL.md
- Broad trigger: "expose port", "share app", "preview on phone", etc.
- Product guide updated with tunnel CLI docs

Config:
- Added tunnel.maxUserTunnels (default: 5)
2026-03-23 14:47:37 +07:00
dylan
adc2057d30 docs: add Discord media support implementation plan
4-task plan: media helpers + tests, incoming media handling,
outgoing attachment support, full verification.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: dcddb00f7cd9
2026-03-23 14:45:32 +07:00
dylan
bf41b47859 docs: add Discord media support design spec
Spec for adding file, image, and audio support to Discord adapter,
matching Telegram adapter's v0.5.2 capabilities.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: aa9a2339bc1a
2026-03-23 14:40:03 +07:00
dylan
9b0ab085e3 docs: update README with Discord adapter support
Add Discord as a supported channel alongside Telegram throughout the
README: prerequisites, setup wizard, usage commands, and session transfer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: acbb57bda5a2
2026-03-23 14:19:38 +07:00
dylan
477c45cccc chore: remove accidentally staged worktree dirs
Entire-Checkpoint: 1281ebb0a57c
2026-03-23 14:18:46 +07:00
dylan
a5d463c3a9 merge: sync upstream/develop into develop
Resolves conflicts in package.json (keep both discord.js and
fastest-levenshtein) and pnpm-lock.yaml (regenerated).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: d7e8e9299f36
2026-03-23 14:18:29 +07:00
dylan
1e0e164e5c Merge branch 'worktree-discord-adapter' into develop 2026-03-23 14:15:35 +07:00
dylan
f71aa5a82a feat(config): streamline Discord setup with combined token+guild flow
Discord config editor now asks for bot token and guild ID together,
validates both against the Discord API (including guild membership check),
and auto-enables on success. Clears old channel IDs to force recreation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 14:15:23 +07:00
dylan
f6438f1382 Merge branch 'worktree-discord-adapter' into develop 2026-03-23 14:03:29 +07:00
dylan
4658388ffe fix(discord): fallback to text channel with threads when Community mode is disabled
Forum channels require Community mode. Instead of throwing an error,
now falls back to a regular text channel with threads for sessions.
- ensureForums: create GuildForum if Community enabled, GuildText otherwise
- createSessionThread: handle both Forum posts and Text channel threads
- setupAssistant: reuse createSessionThread for consistent thread creation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 14:03:23 +07:00
dylan
7ceff64f59 Merge branch 'worktree-discord-adapter' into develop 2026-03-23 13:54:14 +07:00
dylan
160224748f fix(discord): address PR review issues #4-9
- #6: Normalize userId to string in allowedUserIds check (supports both
  Telegram numeric IDs and Discord snowflake strings)
- #9: Validate guild has Community mode before creating forum channel,
  throw helpful error message if not enabled
- #4/#5: Wire discord.js REST rateLimited event to DiscordSendQueue.onRateLimited()
  to drop queued text edits when rate limited
- #7: Archive + lock threads instead of permanently deleting them,
  preserving conversation history

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 13:54:08 +07:00
dylan
5f5eafd914 Merge branch 'worktree-discord-adapter' into develop 2026-03-23 13:47:29 +07:00
dylan
49c7e80605 fix(discord): reuse existing channels on restart, handle deleted channels gracefully
- ensureForums: fetch existing forum/notification channels by saved ID before creating new ones
- setupAssistant: verify assistant thread exists and unarchive if needed
- Gracefully recreate channels if saved IDs point to deleted channels
- Log "Reusing existing..." on restart for clarity

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 13:47:22 +07:00
0xmrpeter
bae30700c5 chore: release v0.5.2
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v0.5.2
2026-03-23 13:37:06 +07:00
0xmrpeter
d595a91cf6 feat: add file, image, and audio support via adapters
- Add FileService for saving/resolving files in ~/.openacp/files/<sessionId>/
- Support OGG→WAV voice conversion using ogg-opus-decoder + node-wav
- Extend ACP prompt to send image/audio as base64 when agent supports it,
  fallback to file path when not
- Handle agent→user image/audio content events via SessionBridge
- Telegram adapter: incoming photo, document, voice, audio, video_note handlers
- Telegram adapter: outgoing attachment sending (photo/voice/document)
- Add Attachment type, extend IncomingMessage/OutgoingMessage/AgentEvent
- Log agent prompt capabilities on init for debugging
- Fix agent-installer test to match version-stripping behavior

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 13:34:58 +07:00
dylan
bee030f7f0 Merge branch 'worktree-discord-adapter' into develop 2026-03-23 13:31:47 +07:00
dylan
ebebe88735 fix: add enable/disable toggle for channels in config editor
- Add enable/disable toggle for both Telegram and Discord in config editor
- Auto-set enabled=true when bot token is configured
- Show enabled status in channel settings display
- Fix Discord not starting because config was missing enabled=true

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 13:31:31 +07:00
dylan
8e4241f006 Merge branch 'worktree-discord-adapter' into develop 2026-03-23 11:47:21 +07:00
dylan
5c3e84f3b0 feat: add channel selection to CLI config editor and onboarding
- Add "Channels" parent menu in config editor (choose Telegram/Discord inside)
- Add editDiscord() function for editing Discord bot token and guild ID
- Make setup step numbering dynamic based on channel selection
- Update hardcoded Telegram references to be channel-agnostic
- Update product guide to mention both Telegram and Discord

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 11:34:07 +07:00
dylan
64e64e57a9 Merge branch 'worktree-fix-critical-issues-21' into develop 2026-03-23 11:23:35 +07:00
dylan
193ffe325a fix: address PR #34 review feedback
- stopDaemon: handle EPERM on initial check by cleaning stale PID file
- stopDaemon: return stopped:false when process survives SIGKILL
- escapeSystemdValue: escape $ to prevent systemd variable expansion
- api-server: warn when secret file has insecure permissions (like SSH)
- api-server: explicit utf-8 encoding in Buffer.from for timingSafeEqual

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 11:22:57 +07:00
0xmrpeter
df9150a67c Merge branch 'develop'
# Conflicts:
#	src/adapters/telegram/commands/agents.ts
#	src/cli/commands.ts
2026-03-23 11:21:04 +07:00
0xmrpeter
cc8cc53c30 chore: release v0.5.1
- Generic bi-directional handoff for all agents (not just Claude)
- CLI typo suggestions with fuzzy matching
- Per-agent setup instructions shown after install
- Fix ACP flag stripping and base args in agents run
- Comprehensive test coverage (+410 test cases across 22 new test files)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v0.5.1
2026-03-23 11:20:02 +07:00
dylan
031d0fbefc fix(test): update setup integration test for channel selection step
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 11:15:59 +07:00
dylan
51f995816e feat(discord): add Discord to interactive setup flow
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 11:13:24 +07:00
dylan
85090ed1bb feat(discord): add Discord doctor health check
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 11:12:17 +07:00
dylan
9095ad73aa feat(discord): integrate Discord adapter in main.ts, fix channel-aware platform storage
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 11:11:14 +07:00
dylan
1d7fcec8c4 feat(discord): add main DiscordAdapter class
Implements DiscordAdapter wiring all leaf modules together: send queue,
tool tracker, draft manager, activity tracker, skill command manager,
permission handler, forums, assistant, and slash command routing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 11:08:47 +07:00
dylan
248342fd84 feat(discord): add assistant session management
Implements Task 11: spawnAssistant, buildWelcomeMessage, buildAssistantSystemPrompt,
and handleAssistantMessage for Discord-specific assistant sessions with full
system prompt including current state, action playbook, and product guide.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 11:04:44 +07:00
Mr.Peter
0ccf54e896
Merge pull request #39 from vincentlab3/fix/36-setup-claude-agent
fix(setup): show Claude in agent selection list during onboarding
2026-03-23 11:03:52 +07:00
dylan
05f0c287c3 feat(discord): add slash commands and interaction routing
Implements Task 10: complete Discord slash command infrastructure with
SLASH_COMMANDS array, central router, and all command handlers (new-session,
session, admin, menu, agents, doctor, integrate, settings).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 11:02:58 +07:00