ats-daemon 1.0.0 → 1.0.1

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.
@@ -0,0 +1,230 @@
1
+ FROM node:20-slim
2
+
3
+ # =============================================================================
4
+ # Verbose Output Environment Variables
5
+ # =============================================================================
6
+ # These environment variables enable detailed logging from AI providers
7
+ # for metrics extraction. The orchestrator parses this output to collect
8
+ # token usage, tool calls, and other metrics.
9
+
10
+ # cursor-agent: Use stream-json format for structured output
11
+ # This is passed as a command-line flag, but we set an env var as a hint
12
+ ENV CURSOR_OUTPUT_FORMAT=stream-json
13
+
14
+ # Anthropic Claude CLI: Enable debug logging
15
+ # Outputs detailed API request/response information
16
+ ENV ANTHROPIC_LOG_LEVEL=debug
17
+ ENV ANTHROPIC_DEBUG=1
18
+
19
+ # OpenAI: Enable debug logging
20
+ # Outputs API calls with usage information
21
+ ENV OPENAI_LOG=debug
22
+
23
+ # Google Gemini: Enable debug logging (via Python logging)
24
+ # The SDK respects standard Python logging levels
25
+ ENV GOOGLE_LOG_LEVEL=debug
26
+
27
+ # LangChain/LangGraph: Enable verbose mode
28
+ # These are common agentic framework settings
29
+ ENV LANGCHAIN_VERBOSE=true
30
+ ENV LANGCHAIN_TRACING_V2=false
31
+
32
+ # AutoGPT: Enable verbose mode
33
+ ENV AUTOGPT_VERBOSE=true
34
+ ENV LOG_LEVEL=DEBUG
35
+
36
+ # CrewAI: Enable verbose mode
37
+ ENV CREWAI_VERBOSE=true
38
+
39
+ # Generic verbose flag for custom agents
40
+ ENV RALPH_VERBOSE=1
41
+
42
+ # =============================================================================
43
+ # System Dependencies
44
+ # =============================================================================
45
+
46
+ # Install system dependencies
47
+ # Using Debian-based image for glibc compatibility with cursor-agent
48
+ RUN apt-get update && apt-get install -y --no-install-recommends \
49
+ git \
50
+ bash \
51
+ curl \
52
+ openssh-client \
53
+ jq \
54
+ python3 \
55
+ python3-pip \
56
+ python3-venv \
57
+ ca-certificates \
58
+ && rm -rf /var/lib/apt/lists/*
59
+
60
+ # Install Claude CLI (claude-code)
61
+ # This is the official Anthropic coding assistant CLI
62
+ # Falls back to mock if package not available
63
+ RUN npm install -g @anthropic-ai/claude-code 2>/dev/null || \
64
+ npm install -g claude-cli 2>/dev/null || \
65
+ echo "Claude CLI package not found, will use mock"
66
+
67
+ # Install OpenAI CLI via Python package
68
+ # This provides the openai command for API interactions
69
+ # Using --break-system-packages for Debian 12+ compatibility
70
+ RUN pip3 install --break-system-packages openai 2>/dev/null || \
71
+ pip3 install openai 2>/dev/null || \
72
+ echo "OpenAI package not found, will use mock"
73
+
74
+ # Verify Claude CLI is installed - fail build if not available
75
+ # No mocks: we require the real CLI for actual AI work
76
+ RUN command -v claude || (echo "ERROR: Claude CLI not installed" && exit 1)
77
+
78
+ # Install cursor-agent using official installer
79
+ # This is Cursor IDE's CLI tool for AI-assisted coding
80
+ # The installer sets up cursor-agent in ~/.local/bin
81
+ RUN curl https://cursor.com/install -fsS | bash && \
82
+ echo "Cursor agent installed successfully" || \
83
+ echo "cursor-agent installer failed, cursor mode will not be available"
84
+
85
+ # Note: cursor-agent is installed to /usr/local/bin for all users
86
+ # No need to modify PATH as /usr/local/bin is already in default PATH
87
+
88
+ # Copy cursor-agent to global location for all users to access
89
+ # The installer puts the binary in ~/.local/share/cursor-agent/versions/<version>/
90
+ # We copy the entire directory and create symlinks to /usr/local/bin
91
+ RUN if [ -d /root/.local/share/cursor-agent ]; then \
92
+ cp -r /root/.local/share/cursor-agent /usr/local/share/cursor-agent && \
93
+ chmod -R a+rx /usr/local/share/cursor-agent && \
94
+ CURSOR_VERSION=$(ls /usr/local/share/cursor-agent/versions/ | head -1) && \
95
+ ln -sf /usr/local/share/cursor-agent/versions/${CURSOR_VERSION}/cursor-agent /usr/local/bin/cursor-agent && \
96
+ ln -sf /usr/local/share/cursor-agent/versions/${CURSOR_VERSION}/cursor-agent /usr/local/bin/agent && \
97
+ ln -sf /usr/local/share/cursor-agent/versions/${CURSOR_VERSION}/cursor-agent /usr/local/bin/cursor && \
98
+ echo "Installed cursor-agent globally from ${CURSOR_VERSION}"; \
99
+ else \
100
+ echo "cursor-agent not found, skipping copy"; \
101
+ fi
102
+
103
+ # Verify cursor-agent works (should work as any user now)
104
+ RUN cursor-agent --version && echo "cursor-agent verification passed"
105
+
106
+ # Create non-root user for Claude CLI compatibility
107
+ # Claude Code CLI refuses to run with --dangerously-skip-permissions as root
108
+ # Using Debian-style user creation
109
+ RUN groupadd -r ralph && useradd -r -g ralph -m -s /bin/bash ralph
110
+
111
+ # Create working directories with proper ownership
112
+ RUN mkdir -p /ralph/scripts /ralph/files /ralph/output && \
113
+ chown -R ralph:ralph /ralph
114
+
115
+ # Configure git user (required for commits) - do this as root first
116
+ RUN git config --global user.email "ralph@testing-suite" && \
117
+ git config --global user.name "Ralph Testing Suite" && \
118
+ git config --global init.defaultBranch main
119
+
120
+ # Copy global git config to ralph user's home
121
+ RUN cp /root/.gitconfig /home/ralph/.gitconfig && \
122
+ chown ralph:ralph /home/ralph/.gitconfig
123
+
124
+ # Create Claude CLI config directory for non-root user
125
+ # Claude Code stores settings in ~/.claude
126
+ RUN mkdir -p /home/ralph/.claude && \
127
+ chown -R ralph:ralph /home/ralph/.claude
128
+
129
+ # Create claude wrapper that adds --dangerously-skip-permissions by default
130
+ # This is needed because Claude CLI prompts for permissions interactively otherwise
131
+ RUN REAL_CLAUDE=$(which claude) && \
132
+ mv "$REAL_CLAUDE" /usr/local/bin/claude-real && \
133
+ printf '#!/bin/bash\n\
134
+ # Claude wrapper for non-interactive containers\n\
135
+ # Automatically adds --dangerously-skip-permissions flag\n\
136
+ \n\
137
+ # Check if flag is already present\n\
138
+ HAS_SKIP_PERMS=false\n\
139
+ for arg in "$@"; do\n\
140
+ if [[ "$arg" == "--dangerously-skip-permissions" ]]; then\n\
141
+ HAS_SKIP_PERMS=true\n\
142
+ break\n\
143
+ fi\n\
144
+ done\n\
145
+ \n\
146
+ # Add the flag if not already present\n\
147
+ if [ "$HAS_SKIP_PERMS" = false ]; then\n\
148
+ exec /usr/local/bin/claude-real --dangerously-skip-permissions "$@"\n\
149
+ else\n\
150
+ exec /usr/local/bin/claude-real "$@"\n\
151
+ fi\n' > /usr/local/bin/claude && \
152
+ chmod +x /usr/local/bin/claude
153
+
154
+ # Copy ai-exec wrapper script
155
+ # Provides unified interface for AI CLI calls regardless of provider
156
+ COPY ai-exec /usr/local/bin/ai-exec
157
+ RUN chmod +x /usr/local/bin/ai-exec
158
+
159
+ # Copy validate-config script
160
+ # Validates container configuration before AI calls
161
+ COPY validate-config /usr/local/bin/validate-config
162
+ RUN chmod +x /usr/local/bin/validate-config
163
+
164
+ # Copy CLI wrapper scripts
165
+ # These wrappers output standardized RALPH_USAGE: JSON for metrics extraction:
166
+ # - cursor-wrapper.sh: Estimates tokens from duration (cursor-agent has NO token output)
167
+ # - gemini-wrapper.sh: Standardizes Gemini CLI token output
168
+ COPY wrappers/ /usr/local/lib/ralph-wrappers/
169
+ RUN chmod +x /usr/local/lib/ralph-wrappers/*.sh
170
+
171
+ # Copy entrypoint script
172
+ COPY entrypoint.sh /usr/local/bin/entrypoint.sh
173
+ RUN chmod +x /usr/local/bin/entrypoint.sh
174
+
175
+ # Copy healthcheck script
176
+ COPY healthcheck.sh /usr/local/bin/healthcheck.sh
177
+ RUN chmod +x /usr/local/bin/healthcheck.sh
178
+
179
+ # ============================================================================
180
+ # Verbose Output Environment Variables
181
+ # ============================================================================
182
+ # Enable verbose/debug logging for all providers to ensure metrics extraction.
183
+ # These env vars enable logging of API responses, token usage, and tool calls.
184
+
185
+ # cursor-agent: No env var needed, uses --output-format stream-json flag
186
+ # Set a marker for scripts to know verbose mode is expected
187
+ ENV RALPH_VERBOSE_MODE=true
188
+
189
+ # Anthropic SDK: Enable debug logging for Python/TypeScript SDKs
190
+ # Python: Triggers logging.DEBUG level for anthropic package
191
+ # TypeScript: Can be used by wrapper scripts
192
+ ENV ANTHROPIC_LOG_LEVEL=debug
193
+
194
+ # OpenAI SDK: Enable debug logging
195
+ # Python: openai.log = "debug" equivalent
196
+ ENV OPENAI_LOG=debug
197
+ # TypeScript: DEBUG namespace for openai
198
+ ENV DEBUG=openai:*
199
+
200
+ # Google Gemini: No special env var needed, usageMetadata always included
201
+ # Set marker for consistency
202
+ ENV GOOGLE_VERBOSE=true
203
+
204
+ # LangChain framework: Enable verbose output for chains/agents
205
+ ENV LANGCHAIN_VERBOSE=true
206
+ ENV LANGCHAIN_DEBUG=true
207
+
208
+ # AutoGPT framework: Enable debug logging
209
+ ENV LOG_LEVEL=DEBUG
210
+ ENV VERBOSE=true
211
+ ENV LOG_FORMAT=json
212
+
213
+ # CrewAI framework: Enable verbose output
214
+ ENV CREWAI_VERBOSE=true
215
+
216
+ # General Python logging: Set to DEBUG for all AI SDK debug output
217
+ ENV PYTHONUNBUFFERED=1
218
+
219
+ # ============================================================================
220
+
221
+ # Health check - verify claude, cursor-agent, git, and working directory
222
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
223
+ CMD /usr/local/bin/healthcheck.sh
224
+
225
+ # Switch to non-root user for Claude CLI compatibility
226
+ USER ralph
227
+
228
+ WORKDIR /ralph/output
229
+
230
+ ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]