Skip to content

Add input detection before message injection#10

Merged
khaliqgant merged 11 commits intoclaude/detect-input-text-C6nFkfrom
claude/fix-pr-comments-ZLyFU
Dec 21, 2025
Merged

Add input detection before message injection#10
khaliqgant merged 11 commits intoclaude/detect-input-text-C6nFkfrom
claude/fix-pr-comments-ZLyFU

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

  • Add isInputClear() to detect empty input buffer via prompt pattern matching
  • Add getCursorX() to get cursor position for stability detection
  • Add waitForClearInput() loop-wait mechanism that polls until input is clear
  • Integrate input detection into injectNextMessage() - waits for clear input
    before injecting, falls back to forceful clear only on timeout
  • Add configurable inputWaitTimeoutMs and inputWaitPollMs options
  • Add dev:local, dev:unlink, dev:rebuild npm scripts for local development

claude and others added 11 commits December 20, 2025 12:20
Design document for storing task conversations and agent reasoning
as first-class artifacts. Covers storage architecture, capture
mechanisms, retrospectives, and how trajectories help with code
review, bug diagnosis, and institutional memory.
- Add TaskReference abstraction (works with Beads, Linear, Jira, GitHub, or standalone)
- Define universal .trajectory file format (JSON primary, Markdown generated)
- Add TaskSourceAdapter interface for pluggable task systems
- Show multiple reading experiences: Notion-style pages, Linear-style timelines, Git integration, CLI
- Update storage to support file system, SQLite, PostgreSQL, S3
- Revise migration path to prioritize format and adapters
Link to tweet and Pragmatic Engineer article on agent trajectories.
Include related observations on why trajectory capture matters:
more code faster, parallel agent work, bug diagnosis needs.
Add comprehensive "Notion for Agents" section:
- Knowledge workspace concept (decisions, patterns, knowledge base)
- Data model for AgentWorkspace, DecisionLog, PatternLibrary
- Population strategies (automatic, agent contribution, human curation)
- Query interface with contextual suggestions
- Flywheel effect for continuous improvement

Add claude-mem integration section:
- Comparison table (observation layer vs task layer)
- Agent Memory Stack diagram showing complementary roles
- Integration strategies (shared storage, cross-query, hooks)
- Export/import between formats
Add "Architecture: Separate Providers in a Stack" section showing:
- Each layer is an independent project (agent-relay, claude-mem,
  agent-trajectories, agent-workspace)
- Projects can be used alone or composed together
- Integration points between layers
- Why separate projects (independent adoption, different maintainers,
  cleaner dependencies)
- agent-relay as the communication substrate
- Remove agent-workspace as separate Layer 4
- Show workspace as nested feature within agent-trajectories
- Add project structure showing workspace/ as opt-in module
- Explain why combined: flywheel effect, simpler UX, derived data

Stack is now 3 separate providers:
1. agent-relay (messaging)
2. claude-mem (observations)
3. agent-trajectories (narratives + workspace)
Export StoredMessage, MessageQuery, StorageAdapter, and StorageConfig
types so agent-trajectories can import messages from agent-relay.

Example usage:
  import { StoredMessage, MessageQuery } from 'agent-relay';
Comprehensive guide covering:
- Phase 0: Current state (agent-relay, claude-mem)
- Phase 1: Installing claude-mem
- Phase 2: Creating agent-trajectories project structure
- Phase 3: agent-relay integration (import messages)
- Phase 4: claude-mem integration (import observations)
- Phase 5: Hook integration (combined hooks config)
- Phase 6: Complete setup and workflow

Includes code examples, data flow diagrams, and setup checklist.
- Add named constants for cursor stability detection:
  - STABLE_CURSOR_THRESHOLD (3) for poll count before assuming clear
  - MAX_PROMPT_CURSOR_POSITION (4) for typical prompt cursor position
- Add constants for log truncation lengths:
  - DEBUG_LOG_TRUNCATE_LENGTH (40) for debug log messages
  - RELAY_LOG_TRUNCATE_LENGTH (50) for relay command logs
- Use Math.min for safe substring operations in all log truncations
- Add comprehensive unit tests for constants and truncation logic
@khaliqgant khaliqgant changed the base branch from main to claude/detect-input-text-C6nFk December 21, 2025 11:37
@khaliqgant khaliqgant merged commit 6262bdc into claude/detect-input-text-C6nFk Dec 21, 2025
6 checks passed
khaliqgant added a commit that referenced this pull request Feb 3, 2026
…tart

Three bug fixes reported during MCP testing:

1. **Spawn race condition fix** (Bug #10): Added spawningAgents mutex to
   prevent concurrent spawn requests for the same agent from both passing
   the activeWorkers.has() check before either completes.

2. **SIGKILL diagnostics** (Bug #7, #10): Added gatherSigkillDiagnostics()
   to capture memory usage, process count, and OOM killer messages when
   exit code 137 or SIGKILL is detected. This helps diagnose resource
   exhaustion issues.

3. **Orphan cleanup** (Bug #8, #9): Added cleanupOrphanedWorkers() that
   runs on spawner startup to kill relay-pty processes from a previous
   daemon run. This ensures a clean slate after daemon restarts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

2 participants