@mcp-abap-adt/llm-agent 5.1.1 → 5.1.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-abap-adt/llm-agent",
3
- "version": "5.1.1",
3
+ "version": "5.1.2",
4
4
  "description": "Core components for building Smart LLM agents, plus a default MCP-orchestrated OpenAI-compatible server implementation.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -105,7 +105,8 @@
105
105
  "typescript": "^6.0.2"
106
106
  },
107
107
  "bin": {
108
- "llm-agent": "./dist/smart-agent/cli.js"
108
+ "llm-agent": "./dist/smart-agent/cli.js",
109
+ "claude-via-agent": "./tools/claude-via-agent.sh"
109
110
  },
110
111
  "license": "MIT",
111
112
  "author": "Oleksii Kyslytsia <oleksij.kyslytsja@gmail.com>",
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env bash
2
+ # Launch Claude CLI through llm-agent SmartServer.
3
+ #
4
+ # Usage:
5
+ # ./tools/claude-via-agent.sh # auto-selects pipeline by LLM_PROVIDER
6
+ # ./tools/claude-via-agent.sh --config pipelines/deepseek.yaml # explicit pipeline
7
+ #
8
+ # All credentials in .env:
9
+ # LLM_PROVIDER — selects pipeline: pipelines/<provider>.yaml
10
+ # DEEPSEEK_API_KEY — for deepseek pipeline
11
+ # AICORE_SERVICE_KEY — for sap-ai-core pipeline (JSON)
12
+ # MCP_ENDPOINT — MCP server URL (optional)
13
+ # PORT — llm-agent port (default: 4004)
14
+
15
+ set -euo pipefail
16
+
17
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18
+ PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
19
+
20
+ PORT="${PORT:-4004}"
21
+ AGENT_PID=""
22
+ AGENT_STARTED_BY_US=false
23
+
24
+ # Select pipeline config: explicit --config, or by LLM_PROVIDER from env/.env
25
+ CONFIG=""
26
+ if [[ "${1:-}" == "--config" && -n "${2:-}" ]]; then
27
+ CONFIG="$2"
28
+ shift 2
29
+ else
30
+ # Read LLM_PROVIDER from .env if not in env
31
+ PROVIDER="${LLM_PROVIDER:-}"
32
+ if [[ -z "$PROVIDER" && -f "$PROJECT_DIR/.env" ]]; then
33
+ PROVIDER=$(grep "^LLM_PROVIDER=" "$PROJECT_DIR/.env" 2>/dev/null | cut -d= -f2)
34
+ fi
35
+ if [[ -n "$PROVIDER" && -f "$PROJECT_DIR/pipelines/${PROVIDER}.yaml" ]]; then
36
+ CONFIG="pipelines/${PROVIDER}.yaml"
37
+ fi
38
+ fi
39
+
40
+ cleanup() {
41
+ if [[ "$AGENT_STARTED_BY_US" == true && -n "$AGENT_PID" ]]; then
42
+ kill "$AGENT_PID" 2>/dev/null || true
43
+ wait "$AGENT_PID" 2>/dev/null || true
44
+ echo "llm-agent stopped."
45
+ fi
46
+ }
47
+ trap cleanup EXIT INT TERM
48
+
49
+ # Check if llm-agent is already running on this port
50
+ if curl -sf "http://localhost:$PORT/health" >/dev/null 2>&1 || \
51
+ curl -sf "http://localhost:$PORT/v1/models" >/dev/null 2>&1; then
52
+ echo "llm-agent already running on port $PORT, reusing..."
53
+ else
54
+ echo "Starting llm-agent on port $PORT..."
55
+ [[ -n "$CONFIG" ]] && echo "Pipeline: $CONFIG"
56
+ cd "$PROJECT_DIR"
57
+
58
+ if [[ -n "$CONFIG" ]]; then
59
+ npx llm-agent --config "$CONFIG" &
60
+ else
61
+ npx llm-agent &
62
+ fi
63
+ AGENT_PID=$!
64
+ AGENT_STARTED_BY_US=true
65
+
66
+ for i in $(seq 1 30); do
67
+ if curl -sf "http://localhost:$PORT/health" >/dev/null 2>&1 || \
68
+ curl -sf "http://localhost:$PORT/v1/models" >/dev/null 2>&1; then
69
+ break
70
+ fi
71
+ if ! kill -0 "$AGENT_PID" 2>/dev/null; then
72
+ echo "Error: llm-agent failed to start" >&2
73
+ exit 1
74
+ fi
75
+ sleep 1
76
+ done
77
+
78
+ if ! kill -0 "$AGENT_PID" 2>/dev/null; then
79
+ echo "Error: llm-agent exited unexpectedly" >&2
80
+ exit 1
81
+ fi
82
+ fi
83
+
84
+ echo "llm-agent ready. Launching Claude CLI..."
85
+ echo ""
86
+
87
+ # Claude CLI auth: if logged into claude.ai, do not set ANTHROPIC_API_KEY (conflicts).
88
+ CLAUDE_AUTH_FILE="${HOME}/.claude/.credentials.json"
89
+ if [[ -f "$CLAUDE_AUTH_FILE" ]] && grep -q "accessToken" "$CLAUDE_AUTH_FILE" 2>/dev/null; then
90
+ unset ANTHROPIC_API_KEY 2>/dev/null || true
91
+ else
92
+ export ANTHROPIC_API_KEY="${ANTHROPIC_API_KEY:-placeholder}"
93
+ fi
94
+
95
+ ANTHROPIC_BASE_URL="http://localhost:$PORT" \
96
+ claude "$@"