327 Commits

Author SHA1 Message Date
0xmrpeter
2e3dc31762 feat: per-provider TTS voice config, duplex fix, auto-resume for commands
- Remove global speech.tts.voice, move to per-provider config
- Add edge-tts voice selector with 19 popular voices (10 languages)
- Fix sendVoice duplex error: add baseFetchConfig duplex for Node.js 20+
- Add core.getOrResumeSession() for command handlers to lazy-resume
- Rename /voice to /text_to_speech throughout
2026-03-24 13:54:24 +07:00
0xmrpeter
2db01891aa feat: complete TTS integration (core registration, session pipeline, config)
- Register EdgeTTS provider in core startup and hot-reload
- Add voiceMode + TTS prompt injection to Session
- Add post-response TTS pipeline (accumulate, parse, synthesize, emit)
- Add TTS provider and voice to config registry for settings UI
- Fix test configs to include voice default
2026-03-24 11:41:24 +07:00
0xmrpeter
53f1fbb05f feat(speech): add edge-tts provider using msedge-tts
- Install msedge-tts dependency (MIT, TypeScript)
- Implement EdgeTTS provider with lazy-loaded dynamic import
- Default voice: en-US-AriaNeural, configurable per-provider or globally
- Add comprehensive tests with mocked msedge-tts
2026-03-24 11:41:13 +07:00
0xmrpeter
70a31a7eda feat(telegram): strip [TTS] block from text after sending voice message 2026-03-24 11:36:34 +07:00
0xmrpeter
836d1ba9f2 feat(telegram): add voice toggle button, /voice command, combined session keyboard 2026-03-24 11:34:20 +07:00
0xmrpeter
dcdf1d1ae8 feat: add voice field to TTS config schema
Add optional voice field to both the Zod SpeechSchema (config.ts)
and the SpeechServiceConfig interface (types.ts) to support
voice selection for TTS providers.
2026-03-24 11:23:30 +07:00
0xmrpeter
aa68722966 feat: make SpeechProviderConfig.apiKey optional for TTS
TTS providers like edge-tts don't require an API key. Updated
isTTSAvailable() to check provider registration instead of apiKey,
and updated synthesize() to remove the apiKey guard. STT methods
remain unchanged and still require apiKey.
2026-03-24 11:23:18 +07:00
Mr.Peter
fe1822e986
Merge pull request #46 from Open-ACP/refactor/codebase-cleanup
refactor: codebase cleanup โ€” type safety, architecture decomposition, 274 new tests
2026-03-24 09:33:01 +07:00
0xmrpeter
409b29f7a0 test: add comprehensive test coverage (274 new tests)
- Session state machine: all valid/invalid transitions, events
- Session bridge: image/audio content, permissions, EventBus, auto-disconnect
- Prompt queue: serial guarantee, FIFO, abort, error recovery
- Permission gate: timeout, idempotency, overwrite, cleanup
- Security guard: boundary values, numeric userId, combined checks
- Session store: TTL cleanup, corrupt files, concurrent ops
- Session manager: patchRecord, cancelSession, destroyAll, thread lookup
- Usage budget: exact boundaries, de-duplication, month reset
- Typed emitter: pause/resume, passthrough filter, clearBuffer
- Session factory: usage tracking, budget warnings, tunnel cleanup
- Core orchestrator: security flow, lazy resume, archive, adopt
- Update CLAUDE.md with testing conventions
2026-03-24 08:50:09 +07:00
0xmrpeter
f7453808b8 refactor: fix remaining any/unknown casts across codebase 2026-03-24 01:04:14 +07:00
0xmrpeter
6e898c6bff refactor: replace Record<string, any> with Record<string, unknown> in config 2026-03-24 00:59:28 +07:00
0xmrpeter
96a32505f7 refactor: replace adapter: any with DiscordAdapter type in all Discord command files
- Add `import type { DiscordAdapter }` to all command files
- Replace all `adapter: any` parameters with `adapter: DiscordAdapter`
- Remove unnecessary `(interaction as any).deferred/replied` casts
- Fix menu.ts to use `adapter.respawnAssistant()` instead of non-existent `adapter.assistant.respawn()`
- Change `core` from protected to public readonly in ChannelAdapter base class
2026-03-24 00:58:40 +07:00
0xmrpeter
81c116e143 refactor: fix type casts in Telegram adapter
Replace unsafe `as never as` and `as any` casts with proper metadata
type interfaces (ToolCallMetadata, ToolUpdateMetadata, PlanMetadata,
UsageMetadata). Make TelegramChannelConfig extend ChannelConfig to
eliminate the constructor cast.
2026-03-24 00:58:17 +07:00
0xmrpeter
c29dd3af48 docs: add codebase refactor spec and implementation plan 2026-03-24 00:42:33 +07:00
0xmrpeter
f096de1ac0 refactor: Discord adapter adopts MessageDispatcher
Replace the switch statement in DiscordAdapter.sendMessage() with the
dispatchMessage/MessageHandlers pattern, matching the Telegram adapter.
Extract a getOrCreateTracker helper and define DiscordMessageCtx interface.
2026-03-24 00:41:29 +07:00
0xmrpeter
88150a7e30 refactor: split API server into route modules 2026-03-24 00:38:51 +07:00
0xmrpeter
55a339f636 refactor: move permission auto-approve to SessionBridge 2026-03-24 00:38:42 +07:00
0xmrpeter
cd1a6e9fb1 refactor: add API Router and middleware 2026-03-24 00:33:32 +07:00
0xmrpeter
942a96fb55 refactor: extract SessionFactory from Core 2026-03-24 00:33:25 +07:00
0xmrpeter
249ed77de3 refactor: add shared MessageDispatcher and adapter interfaces 2026-03-24 00:28:44 +07:00
0xmrpeter
d7227ae373 refactor: extract SecurityGuard from Core
Move the inline security checks (allowedUserIds + maxConcurrentSessions)
from OpenACPCore.handleMessage() into a dedicated SecurityGuard class,
improving separation of concerns and testability.
2026-03-24 00:28:11 +07:00
0xmrpeter
5578c6e170 refactor: subscribe to AgentInstance events via .on() in SessionBridge
Replace direct onSessionUpdate callback assignment with
agentInstance.on('agent_event', handler) and proper cleanup
via .off() in disconnect().
2026-03-24 00:25:05 +07:00
0xmrpeter
43d0d961d9 refactor: make AgentInstance extend TypedEmitter and emit events
Replace the onSessionUpdate callback property with TypedEmitter's
emit('agent_event', event) pattern. Update autoName in session.ts
to use pause/resume instead of swapping the callback. Update test
mocks to use TypedEmitter instances.
2026-03-24 00:24:57 +07:00
Mr.Peter
7f26931af3
Merge pull request #40 from rex-qa-bot/feat/ui-dashboard-backend
feat: embedded UI dashboard with SSE, auth, and 6 pages
2026-03-23 23:02:06 +07:00
Leo Agent
47b7a063d9 merge: resolve conflicts with upstream/develop
Keep both sides: our EventBus/SSEManager/StaticServer/auth/security additions
and upstream's speech module (SpeechService, GroqSTT, SpeechSchema) additions.
- config.ts: add speech schema alongside integrations field
- core.ts: add speech.* hot-reload handler alongside logging.level handler
- index.ts: add SpeechService/GroqSTT exports + speech type exports
- api-server.ts: add intermediate object creation for new config paths (speech)
- test files: add speech config to mock config objects

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 20b626ae9a6b
2026-03-23 22:53:23 +07:00
Leo Agent
9f4bc19c91 fix(security): block prototype pollution, enforce config scope, redact arrays
- Block __proto__/constructor/prototype in PATCH /api/config paths
- Enforce safe-fields scope โ€” reject sensitive config fields with 403
- Traverse arrays in redactConfig to redact nested sensitive keys

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: e171d45f994c
2026-03-23 22:45:27 +07:00
Leo Agent
2a1a368da7 test: add security test cases for auth, path traversal, prototype pollution, and body limits
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 8998a8faa45e
2026-03-23 22:41:54 +07:00
0xmrpeter
392780712c chore: release v0.6.1
- Speech-to-text: send voice messages, agent receives transcribed text (Groq Whisper)
- Session cost tracking with monthly budget limits and /usage command
- /archive command to recreate session topics with clean slate
- /tunnels scoped to current session in session topics

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v0.6.1
2026-03-23 22:39:34 +07:00
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
Leo Agent
35530d5d29 fix: address round 4 review โ€” readBody 413 without double-response, restrict query-param auth to SSE, error handling, cache headers, auth detection
Entire-Checkpoint: 88ff4abcc502
2026-03-23 22:21:52 +07:00
Leo Agent
7da4b721ea fix(ui): show error feedback on DashboardPage restart failure
Entire-Checkpoint: fa2a40cfc38c
2026-03-23 21:50:02 +07:00
Leo Agent
07c6e7e185 merge: resolve conflicts with upstream/develop (usage tracking feature)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 21:42:36 +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
Leo Agent
ce145a6267 fix: readBody returns 413 on oversized payload, remove redundant regex in StaticServer, fix ConfigPage deps and restart error handling
Entire-Checkpoint: b86e99ee3c42
2026-03-23 21:33:02 +07:00
Leo Agent
f743ee0523 fix: SSEManager uses off() instead of removeAllListeners, broadcast checks writable, TopicsPage cleanup error handling
Entire-Checkpoint: e93cd6d45bd8
2026-03-23 18:43:12 +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
Leo Agent
de39fca1eb feat(ui): add auth login flow with file-based token support
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 17:52:11 +07:00
Leo Agent
556025bb1b merge upstream/develop: adopt file-based auth, keep UI dashboard features
Resolve conflicts between upstream's file-based API authentication (PR #34)
and our UI dashboard backend features. Key decisions:
- Use upstream's loadOrCreateSecret() + authenticate() with file-based secret
- Drop our checkAuth() + api.token config approach
- Add query param support to authenticate() for SSE EventSource
- Exempt non-/api/ routes (static files) from auth
- Keep SSEManager, StaticServer, permission endpoint, extended list response
- Remove api.token from config schema
- Update tests to use file-based auth pattern

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 17:49:43 +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
Leo Agent
945cecf407 merge: resolve conflict with upstream/develop (tunnel management endpoints)
Entire-Checkpoint: 7f4d7ec163cd
2026-03-23 17:07:10 +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
Leo Agent
8b0863f6d4 merge: resolve conflict with upstream/develop
Entire-Checkpoint: 807ef9bbad32
2026-03-23 16:59:51 +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