Skip to content

feat: streaming responses, inactivity timeout, and per-project permission levels#1

Merged
vinicius1209 merged 1 commit intomainfrom
feature/streaming-response
Mar 11, 2026
Merged

feat: streaming responses, inactivity timeout, and per-project permission levels#1
vinicius1209 merged 1 commit intomainfrom
feature/streaming-response

Conversation

@vinicius1209
Copy link
Copy Markdown
Owner

Summary

  • Streaming responses: Real-time message delivery to Telegram via chatStream() — Claude uses stream-json, Gemini uses stdout streaming. Both adapters support buffered chunk callbacks with configurable minChunkSize.
  • Inactivity timeout: Replaces the hard wall-clock timeout that was killing long-running agent tasks (e.g., spec-driven /feature workflows). The process now stays alive as long as it produces output, and is only killed after inactivity_timeout seconds (default 300s) of silence. A hard stream_timeout (default 3600s) acts as a safety net.
  • Per-project permission levels: New permission_level config (readonly, read-write, full) with adapter-aware tool mapping. Claude gets --dangerously-skip-permissions and Gemini gets --yolo when needed. Supports advanced allowed_tools and skip_permissions overrides per project.
  • Setup wizard: New step 5/5 in devbridge init asks permission level per project.
  • Log rotation: Auto-rotates at 10MB, keeps 5 archived files.
  • Router refactored: Extracted streaming/non-streaming helpers, eliminated code duplication in SESSION_EXPIRED recovery path.
  • Docs updated: configuration.md, security.md, adapters.md, README.md — all reflect the new features.

Permission Levels

Level Claude Tools Gemini Tools Permission Bypass
readonly (default) Read,Glob,Grep ReadFileTool,GlobTool,GrepTool No
read-write + Write,Edit,MultiEdit + WriteFileTool,EditTool Yes
full + Bash,Agent,WebFetch,WebSearch,NotebookEdit + ShellTool,WebFetchTool,WebSearchTool Yes

Config Example

{
  "projects": {
    "my-app": {
      "path": "/path/to/project",
      "adapter": "claude",
      "permission_level": "full"
    }
  },
  "defaults": {
    "stream_timeout": 3600,
    "inactivity_timeout": 300
  }
}

Test plan

  • All 287 tests passing (36 test files)
  • ESLint clean (0 errors, 0 warnings)
  • Manual test: send a long-running /feature prompt via Telegram and verify no timeout while Claude is actively working
  • Manual test: verify readonly project blocks write operations
  • Manual test: verify full project allows file creation without permission prompts
  • Manual test: verify devbridge init wizard asks permission level per project

…sion levels

Streaming responses:
- Add chatStream() to CLIAdapter interface (optional, backwards-compatible)
- Claude adapter streams via --output-format stream-json with incremental parsing
- Gemini adapter streams via stdout with delta calculation
- spawnCLIStreaming utility with buffered onChunk callbacks and minChunkSize

Inactivity timeout (replaces hard wall-clock timeout):
- Process is killed only if no stdout/stderr output for inactivity_timeout seconds (default: 300s)
- Timer resets on every data event, allowing long-running agent tasks to complete
- Hard stream_timeout (default: 3600s) acts as safety net for runaway processes
- Fixes timeout issues with complex agent workflows (e.g., spec-driven development)

Per-project permission levels:
- New permission_level field: "readonly" (default), "read-write", "full"
- Adapter-aware tool mapping via src/adapters/permissions.ts:
  - Claude: Read,Glob,Grep -> +Write,Edit,MultiEdit -> +Bash,Agent,WebFetch...
  - Gemini: ReadFileTool,GlobTool,GrepTool -> +WriteFileTool,EditTool -> +ShellTool...
- Full mode passes --dangerously-skip-permissions (Claude) / --yolo (Gemini)
- Advanced overrides: allowed_tools and skip_permissions per project
- Setup wizard (devbridge init) now asks permission level per project (step 5/5)

Other improvements:
- Log rotation: auto-rotates at 10MB, keeps 5 archived files
- Router refactored: extracted sendWithStreaming/sendWithoutStreaming helpers
- Improved observability: message duration, response length, user info in logs
- Updated docs: configuration.md, security.md, adapters.md, README.md
@vinicius1209 vinicius1209 merged commit f89b07f into main Mar 11, 2026
3 checks passed
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