@1claw/cli 0.36.6 → 0.37.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.
- package/README.md +66 -1
- package/dist/bundled-templates/registry.yaml +62 -0
- package/dist/bundled-templates/templates/agentkit/Dockerfile +28 -0
- package/dist/bundled-templates/templates/agentkit/README.md +36 -0
- package/dist/bundled-templates/templates/agentkit/agent.py +83 -0
- package/dist/bundled-templates/templates/agentkit/entrypoint.sh +34 -0
- package/dist/bundled-templates/templates/agentkit/requirements.txt +5 -0
- package/dist/bundled-templates/templates/agentkit/template.yaml +24 -0
- package/dist/bundled-templates/templates/agno/Dockerfile +28 -0
- package/dist/bundled-templates/templates/agno/README.md +36 -0
- package/dist/bundled-templates/templates/agno/agent.py +86 -0
- package/dist/bundled-templates/templates/agno/entrypoint.sh +34 -0
- package/dist/bundled-templates/templates/agno/requirements.txt +2 -0
- package/dist/bundled-templates/templates/agno/template.yaml +24 -0
- package/dist/bundled-templates/templates/coder/Dockerfile +28 -0
- package/dist/bundled-templates/templates/coder/README.md +36 -0
- package/dist/bundled-templates/templates/coder/agent.py +119 -0
- package/dist/bundled-templates/templates/coder/entrypoint.sh +34 -0
- package/dist/bundled-templates/templates/coder/requirements.txt +4 -0
- package/dist/bundled-templates/templates/coder/template.yaml +24 -0
- package/dist/bundled-templates/templates/crewai/Dockerfile +28 -0
- package/dist/bundled-templates/templates/crewai/README.md +29 -0
- package/dist/bundled-templates/templates/crewai/agent.py +109 -0
- package/dist/bundled-templates/templates/crewai/entrypoint.sh +34 -0
- package/dist/bundled-templates/templates/crewai/requirements.txt +3 -0
- package/dist/bundled-templates/templates/crewai/template.yaml +24 -0
- package/dist/bundled-templates/templates/elizaos/Dockerfile +31 -0
- package/dist/bundled-templates/templates/elizaos/README.md +36 -0
- package/dist/bundled-templates/templates/elizaos/agent.ts +100 -0
- package/dist/bundled-templates/templates/elizaos/entrypoint.sh +34 -0
- package/dist/bundled-templates/templates/elizaos/package.json +18 -0
- package/dist/bundled-templates/templates/elizaos/template.yaml +25 -0
- package/dist/bundled-templates/templates/elizaos/tsconfig.json +12 -0
- package/dist/bundled-templates/templates/langchain/Dockerfile +28 -0
- package/dist/bundled-templates/templates/langchain/README.md +37 -0
- package/dist/bundled-templates/templates/langchain/agent.py +115 -0
- package/dist/bundled-templates/templates/langchain/entrypoint.sh +36 -0
- package/dist/bundled-templates/templates/langchain/requirements.txt +4 -0
- package/dist/bundled-templates/templates/langchain/template.yaml +24 -0
- package/dist/bundled-templates/templates/llamaindex/Dockerfile +28 -0
- package/dist/bundled-templates/templates/llamaindex/README.md +36 -0
- package/dist/bundled-templates/templates/llamaindex/agent.py +97 -0
- package/dist/bundled-templates/templates/llamaindex/entrypoint.sh +34 -0
- package/dist/bundled-templates/templates/llamaindex/requirements.txt +3 -0
- package/dist/bundled-templates/templates/llamaindex/template.yaml +24 -0
- package/dist/bundled-templates/templates/mastra/Dockerfile +31 -0
- package/dist/bundled-templates/templates/mastra/README.md +31 -0
- package/dist/bundled-templates/templates/mastra/agent.ts +112 -0
- package/dist/bundled-templates/templates/mastra/entrypoint.sh +34 -0
- package/dist/bundled-templates/templates/mastra/package.json +17 -0
- package/dist/bundled-templates/templates/mastra/template.yaml +25 -0
- package/dist/bundled-templates/templates/mastra/tsconfig.json +12 -0
- package/dist/bundled-templates/templates/openai-agents/Dockerfile +28 -0
- package/dist/bundled-templates/templates/openai-agents/README.md +29 -0
- package/dist/bundled-templates/templates/openai-agents/agent.py +98 -0
- package/dist/bundled-templates/templates/openai-agents/entrypoint.sh +34 -0
- package/dist/bundled-templates/templates/openai-agents/requirements.txt +3 -0
- package/dist/bundled-templates/templates/openai-agents/template.yaml +24 -0
- package/dist/bundled-templates/templates/pydantic-ai/Dockerfile +28 -0
- package/dist/bundled-templates/templates/pydantic-ai/README.md +36 -0
- package/dist/bundled-templates/templates/pydantic-ai/agent.py +110 -0
- package/dist/bundled-templates/templates/pydantic-ai/entrypoint.sh +34 -0
- package/dist/bundled-templates/templates/pydantic-ai/requirements.txt +2 -0
- package/dist/bundled-templates/templates/pydantic-ai/template.yaml +24 -0
- package/dist/bundled-templates/templates/smolagents/Dockerfile +28 -0
- package/dist/bundled-templates/templates/smolagents/README.md +36 -0
- package/dist/bundled-templates/templates/smolagents/agent.py +97 -0
- package/dist/bundled-templates/templates/smolagents/entrypoint.sh +34 -0
- package/dist/bundled-templates/templates/smolagents/requirements.txt +2 -0
- package/dist/bundled-templates/templates/smolagents/template.yaml +24 -0
- package/dist/bundled-templates/templates/typescript-sdk/Dockerfile +31 -0
- package/dist/bundled-templates/templates/typescript-sdk/README.md +29 -0
- package/dist/bundled-templates/templates/typescript-sdk/agent.ts +130 -0
- package/dist/bundled-templates/templates/typescript-sdk/entrypoint.sh +34 -0
- package/dist/bundled-templates/templates/typescript-sdk/package.json +17 -0
- package/dist/bundled-templates/templates/typescript-sdk/template.yaml +25 -0
- package/dist/bundled-templates/templates/typescript-sdk/tsconfig.json +12 -0
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +10 -255
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/spawn.d.ts +3 -0
- package/dist/src/commands/spawn.d.ts.map +1 -0
- package/dist/src/commands/spawn.js +408 -0
- package/dist/src/commands/spawn.js.map +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/container-config.d.ts +3 -1
- package/dist/src/lib/container-config.d.ts.map +1 -1
- package/dist/src/lib/container-config.js +3 -2
- package/dist/src/lib/container-config.js.map +1 -1
- package/dist/src/lib/module-deprecation.d.ts +8 -0
- package/dist/src/lib/module-deprecation.d.ts.map +1 -0
- package/dist/src/lib/module-deprecation.js +15 -0
- package/dist/src/lib/module-deprecation.js.map +1 -0
- package/dist/src/lib/paths.d.ts +12 -0
- package/dist/src/lib/paths.d.ts.map +1 -1
- package/dist/src/lib/paths.js +42 -1
- package/dist/src/lib/paths.js.map +1 -1
- package/dist/src/lib/provisioning.d.ts +30 -0
- package/dist/src/lib/provisioning.d.ts.map +1 -0
- package/dist/src/lib/provisioning.js +256 -0
- package/dist/src/lib/provisioning.js.map +1 -0
- package/dist/src/registry.yaml +62 -0
- package/dist/src/templates/agentkit/Dockerfile +34 -0
- package/dist/src/templates/agentkit/README.md +36 -0
- package/dist/src/templates/agentkit/agent.py +83 -0
- package/dist/src/templates/agentkit/entrypoint.sh +34 -0
- package/dist/src/templates/agentkit/requirements.txt +5 -0
- package/dist/src/templates/agentkit/template.yaml +24 -0
- package/dist/src/templates/agno/Dockerfile +34 -0
- package/dist/src/templates/agno/README.md +36 -0
- package/dist/src/templates/agno/agent.py +86 -0
- package/dist/src/templates/agno/entrypoint.sh +34 -0
- package/dist/src/templates/agno/requirements.txt +2 -0
- package/dist/src/templates/agno/template.yaml +24 -0
- package/dist/src/templates/coder/Dockerfile +34 -0
- package/dist/src/templates/coder/README.md +36 -0
- package/dist/src/templates/coder/agent.py +119 -0
- package/dist/src/templates/coder/entrypoint.sh +34 -0
- package/dist/src/templates/coder/requirements.txt +4 -0
- package/dist/src/templates/coder/template.yaml +24 -0
- package/dist/src/templates/crewai/Dockerfile +34 -0
- package/dist/src/templates/crewai/README.md +29 -0
- package/dist/src/templates/crewai/agent.py +109 -0
- package/dist/src/templates/crewai/entrypoint.sh +34 -0
- package/dist/src/templates/crewai/requirements.txt +3 -0
- package/dist/src/templates/crewai/template.yaml +24 -0
- package/dist/src/templates/elizaos/Dockerfile +31 -0
- package/dist/src/templates/elizaos/README.md +36 -0
- package/dist/src/templates/elizaos/agent.ts +100 -0
- package/dist/src/templates/elizaos/entrypoint.sh +34 -0
- package/dist/src/templates/elizaos/package.json +18 -0
- package/dist/src/templates/elizaos/template.yaml +25 -0
- package/dist/src/templates/elizaos/tsconfig.json +12 -0
- package/dist/src/templates/fetcher.d.ts +20 -0
- package/dist/src/templates/fetcher.d.ts.map +1 -0
- package/dist/src/templates/fetcher.js +189 -0
- package/dist/src/templates/fetcher.js.map +1 -0
- package/dist/src/templates/langchain/Dockerfile +34 -0
- package/dist/src/templates/langchain/README.md +37 -0
- package/dist/src/templates/langchain/agent.py +115 -0
- package/dist/src/templates/langchain/entrypoint.sh +36 -0
- package/dist/src/templates/langchain/requirements.txt +4 -0
- package/dist/src/templates/langchain/template.yaml +24 -0
- package/dist/src/templates/llamaindex/Dockerfile +34 -0
- package/dist/src/templates/llamaindex/README.md +36 -0
- package/dist/src/templates/llamaindex/agent.py +97 -0
- package/dist/src/templates/llamaindex/entrypoint.sh +34 -0
- package/dist/src/templates/llamaindex/requirements.txt +3 -0
- package/dist/src/templates/llamaindex/template.yaml +24 -0
- package/dist/src/templates/mastra/Dockerfile +31 -0
- package/dist/src/templates/mastra/README.md +31 -0
- package/dist/src/templates/mastra/agent.ts +112 -0
- package/dist/src/templates/mastra/entrypoint.sh +34 -0
- package/dist/src/templates/mastra/package.json +17 -0
- package/dist/src/templates/mastra/template.yaml +25 -0
- package/dist/src/templates/mastra/tsconfig.json +12 -0
- package/dist/src/templates/openai-agents/Dockerfile +34 -0
- package/dist/src/templates/openai-agents/README.md +29 -0
- package/dist/src/templates/openai-agents/agent.py +98 -0
- package/dist/src/templates/openai-agents/entrypoint.sh +34 -0
- package/dist/src/templates/openai-agents/requirements.txt +3 -0
- package/dist/src/templates/openai-agents/template.yaml +24 -0
- package/dist/src/templates/pydantic-ai/Dockerfile +34 -0
- package/dist/src/templates/pydantic-ai/README.md +36 -0
- package/dist/src/templates/pydantic-ai/agent.py +110 -0
- package/dist/src/templates/pydantic-ai/entrypoint.sh +34 -0
- package/dist/src/templates/pydantic-ai/requirements.txt +2 -0
- package/dist/src/templates/pydantic-ai/template.yaml +24 -0
- package/dist/src/templates/registry.d.ts +48 -0
- package/dist/src/templates/registry.d.ts.map +1 -0
- package/dist/src/templates/registry.js +168 -0
- package/dist/src/templates/registry.js.map +1 -0
- package/dist/src/templates/smolagents/Dockerfile +34 -0
- package/dist/src/templates/smolagents/README.md +36 -0
- package/dist/src/templates/smolagents/agent.py +97 -0
- package/dist/src/templates/smolagents/entrypoint.sh +34 -0
- package/dist/src/templates/smolagents/requirements.txt +2 -0
- package/dist/src/templates/smolagents/template.yaml +24 -0
- package/dist/src/templates/typescript-sdk/Dockerfile +31 -0
- package/dist/src/templates/typescript-sdk/README.md +29 -0
- package/dist/src/templates/typescript-sdk/agent.ts +130 -0
- package/dist/src/templates/typescript-sdk/entrypoint.sh +34 -0
- package/dist/src/templates/typescript-sdk/package.json +17 -0
- package/dist/src/templates/typescript-sdk/template.yaml +25 -0
- package/dist/src/templates/typescript-sdk/tsconfig.json +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""
|
|
2
|
+
HuggingFace smolagents agent pre-wired with 1Claw MCP for secrets and signing.
|
|
3
|
+
|
|
4
|
+
LLM calls are routed through Shroud when ONECLAW_LLM_VIA_SHROUD is set.
|
|
5
|
+
The container never sees raw API keys — they are injected by the host daemon.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
from flask import Flask, request, jsonify
|
|
10
|
+
from smolagents import CodeAgent, tool, OpenAIServerModel
|
|
11
|
+
|
|
12
|
+
app = Flask(__name__)
|
|
13
|
+
|
|
14
|
+
SHROUD_URL = os.environ.get("ONECLAW_SHROUD_URL", "https://shroud.1claw.xyz")
|
|
15
|
+
LLM_VIA_SHROUD = os.environ.get("ONECLAW_LLM_VIA_SHROUD", "").lower() == "true"
|
|
16
|
+
MODEL = os.environ.get("ONECLAW_SHROUD_MODEL", "gpt-4o-mini")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@tool
|
|
20
|
+
def hello_world(name: str) -> str:
|
|
21
|
+
"""Say hello to someone.
|
|
22
|
+
Args:
|
|
23
|
+
name: the person to greet
|
|
24
|
+
"""
|
|
25
|
+
return f"Hello, {name}! I'm a smolagents agent running inside 1Claw."
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@tool
|
|
29
|
+
def list_env_vars() -> str:
|
|
30
|
+
"""List 1Claw-related environment variables (values redacted)."""
|
|
31
|
+
prefix = "ONECLAW_"
|
|
32
|
+
vars_list = [k for k in sorted(os.environ) if k.startswith(prefix)]
|
|
33
|
+
return "\n".join(f" {k}=***" for k in vars_list) if vars_list else "No ONECLAW_* vars set."
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def create_agent():
|
|
37
|
+
"""Build the smolagents CodeAgent. Returns None if no LLM."""
|
|
38
|
+
if not LLM_VIA_SHROUD:
|
|
39
|
+
return None
|
|
40
|
+
|
|
41
|
+
model = OpenAIServerModel(
|
|
42
|
+
model_id=MODEL,
|
|
43
|
+
api_base=f"{SHROUD_URL}/v1",
|
|
44
|
+
api_key="shroud-injected",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
return CodeAgent(
|
|
48
|
+
tools=[hello_world, list_env_vars],
|
|
49
|
+
model=model,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
agent = create_agent()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@app.route("/health")
|
|
57
|
+
def health():
|
|
58
|
+
return jsonify({"status": "ok", "framework": "smolagents", "llm_wired": LLM_VIA_SHROUD})
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@app.route("/chat", methods=["POST"])
|
|
62
|
+
def chat():
|
|
63
|
+
data = request.get_json(silent=True) or {}
|
|
64
|
+
message = data.get("message", "").strip()
|
|
65
|
+
if not message:
|
|
66
|
+
return jsonify({"error": "No message provided"}), 400
|
|
67
|
+
|
|
68
|
+
if not agent:
|
|
69
|
+
return jsonify({
|
|
70
|
+
"response": "No LLM configured. Use --llm-api-key or enable Token Billing.",
|
|
71
|
+
"framework": "smolagents",
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
try:
|
|
75
|
+
result = agent.run(message)
|
|
76
|
+
return jsonify({"response": str(result), "framework": "smolagents"})
|
|
77
|
+
except Exception as e:
|
|
78
|
+
return jsonify({"error": str(e)}), 500
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@app.route("/")
|
|
82
|
+
def index():
|
|
83
|
+
return """<!DOCTYPE html>
|
|
84
|
+
<html><head><title>1Claw smolagents Agent</title></head>
|
|
85
|
+
<body style="font-family:system-ui;max-width:600px;margin:40px auto;padding:0 20px">
|
|
86
|
+
<h1>1Claw HuggingFace smolagents</h1>
|
|
87
|
+
<p>Send messages via <code>POST /chat</code> with <code>{"message": "..."}</code></p>
|
|
88
|
+
<p>Health: <a href="/health">/health</a></p>
|
|
89
|
+
<p style="color:#666;font-size:0.9em">
|
|
90
|
+
Credentials stay in the host daemon — this container never sees secret values.
|
|
91
|
+
</p></body></html>"""
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
if __name__ == "__main__":
|
|
95
|
+
port = int(os.environ.get("CHAT_UI_PORT", "3000"))
|
|
96
|
+
print(f"smolagents agent listening on http://0.0.0.0:{port}")
|
|
97
|
+
app.run(host="0.0.0.0", port=port)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
DAEMON_SOCKET="${ONECLAW_DAEMON_SOCKET:-/run/1claw/daemon.sock}"
|
|
5
|
+
CHAT_UI_PORT="${CHAT_UI_PORT:-3000}"
|
|
6
|
+
|
|
7
|
+
echo "─────────────────────────────────────────────"
|
|
8
|
+
echo " 1Claw smolagents Agent"
|
|
9
|
+
echo " Framework: smolagents"
|
|
10
|
+
echo " Agent ID: ${ONECLAW_AGENT_ID:-not set}"
|
|
11
|
+
|
|
12
|
+
if [ -S "$DAEMON_SOCKET" ]; then
|
|
13
|
+
echo " Mode: ${ONECLAW_MODE:-cloud} (daemon socket)"
|
|
14
|
+
echo " Socket: $DAEMON_SOCKET"
|
|
15
|
+
else
|
|
16
|
+
echo " Mode: standalone (no daemon socket)"
|
|
17
|
+
fi
|
|
18
|
+
echo "─────────────────────────────────────────────"
|
|
19
|
+
|
|
20
|
+
if [ "$ONECLAW_LLM_VIA_SHROUD" = "true" ]; then
|
|
21
|
+
export OPENAI_BASE_URL="${ONECLAW_SHROUD_URL}/v1"
|
|
22
|
+
echo "LLM routed through Shroud: ${ONECLAW_SHROUD_PROVIDER}/${ONECLAW_SHROUD_MODEL}"
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
if [ -S "$DAEMON_SOCKET" ]; then
|
|
26
|
+
if command -v 1claw-mcp >/dev/null 2>&1; then
|
|
27
|
+
ONECLAW_LOCAL_VAULT=true ONECLAW_DAEMON_SOCKET="$DAEMON_SOCKET" \
|
|
28
|
+
1claw-mcp --local 2>/tmp/mcp.log &
|
|
29
|
+
echo "MCP server started in background."
|
|
30
|
+
fi
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
echo "Ready: http://0.0.0.0:${CHAT_UI_PORT}"
|
|
34
|
+
exec python agent.py
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: smolagents
|
|
2
|
+
display_name: "HuggingFace smolagents"
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
description: "HuggingFace lightweight agents with 1Claw secrets"
|
|
5
|
+
author: 1Claw
|
|
6
|
+
language: python
|
|
7
|
+
homepage: https://huggingface.co/docs/smolagents
|
|
8
|
+
|
|
9
|
+
docker:
|
|
10
|
+
base_image: python:3.12-slim
|
|
11
|
+
context_files:
|
|
12
|
+
- Dockerfile
|
|
13
|
+
- requirements.txt
|
|
14
|
+
- agent.py
|
|
15
|
+
- entrypoint.sh
|
|
16
|
+
env:
|
|
17
|
+
ONECLAW_FRAMEWORK: smolagents
|
|
18
|
+
health_endpoint: /health
|
|
19
|
+
health_port: 3000
|
|
20
|
+
|
|
21
|
+
post_spawn_message: |
|
|
22
|
+
Edit agent.py to add custom tools and change the agent type.
|
|
23
|
+
Your 1Claw MCP server is available at the daemon socket.
|
|
24
|
+
LLM calls are routed through Shroud for inspection and redaction.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
FROM node:22-slim
|
|
2
|
+
|
|
3
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
4
|
+
curl tini && \
|
|
5
|
+
rm -rf /var/lib/apt/lists/*
|
|
6
|
+
|
|
7
|
+
WORKDIR /app
|
|
8
|
+
|
|
9
|
+
COPY package.json tsconfig.json ./
|
|
10
|
+
RUN npm install --omit=dev 2>/dev/null || npm install
|
|
11
|
+
|
|
12
|
+
RUN npm install -g @1claw/mcp@latest 2>/dev/null || \
|
|
13
|
+
echo "WARN: @1claw/mcp install deferred to runtime"
|
|
14
|
+
|
|
15
|
+
COPY agent.ts .
|
|
16
|
+
COPY entrypoint.sh .
|
|
17
|
+
RUN chmod +x entrypoint.sh
|
|
18
|
+
|
|
19
|
+
RUN mkdir -p /run/1claw
|
|
20
|
+
|
|
21
|
+
ENV NODE_ENV=production
|
|
22
|
+
ENV ONECLAW_DAEMON_SOCKET=/run/1claw/daemon.sock
|
|
23
|
+
ENV ONECLAW_FRAMEWORK=typescript-sdk
|
|
24
|
+
|
|
25
|
+
EXPOSE 3000
|
|
26
|
+
|
|
27
|
+
HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=5 \
|
|
28
|
+
CMD curl -sf http://localhost:3000/health || exit 1
|
|
29
|
+
|
|
30
|
+
ENTRYPOINT ["tini", "--"]
|
|
31
|
+
CMD ["./entrypoint.sh"]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# 1Claw TypeScript SDK Agent Template
|
|
2
|
+
|
|
3
|
+
Plain TypeScript agent using [@1claw/sdk](https://www.npmjs.com/package/@1claw/sdk) for vault access, multi-chain signing, and Vercel AI SDK for LLM interaction through Shroud.
|
|
4
|
+
|
|
5
|
+
## Quick start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
1claw spawn typescript-sdk --agent-key ocv_YOUR_KEY
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What's included
|
|
12
|
+
|
|
13
|
+
- `agent.ts` — TypeScript agent with `@1claw/sdk` client, AI SDK tool calling, and `/chat` + `/health` endpoints
|
|
14
|
+
- `Dockerfile` — Node 22 slim image with `@1claw/mcp` for vault access
|
|
15
|
+
- `entrypoint.sh` — Daemon socket detection, Shroud wiring, MCP server startup
|
|
16
|
+
|
|
17
|
+
## LLM authentication
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Bring your own key (stored in vault, routed through Shroud)
|
|
21
|
+
1claw spawn typescript-sdk --agent-key ocv_YOUR_KEY --llm-api-key sk-...
|
|
22
|
+
|
|
23
|
+
# Use 1Claw Token Billing (no provider key needed)
|
|
24
|
+
1claw spawn typescript-sdk --agent-key ocv_YOUR_KEY
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Customization
|
|
28
|
+
|
|
29
|
+
Edit `agent.ts` to add tools, integrate with your own services, or use additional @1claw/sdk features like `signIntent()`, `submitTransaction()`, or `leaseBankrKey()`.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain TypeScript agent using @1claw/sdk for vault access and signing,
|
|
3
|
+
* with Vercel AI SDK for LLM interaction through Shroud.
|
|
4
|
+
*
|
|
5
|
+
* LLM calls are routed through Shroud when ONECLAW_LLM_VIA_SHROUD is set.
|
|
6
|
+
* The container never sees raw API keys — they are injected by the host daemon.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { createServer } from "node:http";
|
|
10
|
+
import { OneclawClient } from "@1claw/sdk";
|
|
11
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
12
|
+
import { generateText, tool } from "ai";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
|
|
15
|
+
const SHROUD_URL = process.env.ONECLAW_SHROUD_URL ?? "https://shroud.1claw.xyz";
|
|
16
|
+
const LLM_VIA_SHROUD = process.env.ONECLAW_LLM_VIA_SHROUD === "true";
|
|
17
|
+
const MODEL = process.env.ONECLAW_SHROUD_MODEL ?? "gpt-4o-mini";
|
|
18
|
+
const PORT = parseInt(process.env.CHAT_UI_PORT ?? "3000", 10);
|
|
19
|
+
|
|
20
|
+
const conversationHistory: { role: "user" | "assistant"; content: string }[] = [];
|
|
21
|
+
|
|
22
|
+
const claw = new OneclawClient({
|
|
23
|
+
apiKey: process.env.ONECLAW_AGENT_API_KEY,
|
|
24
|
+
agentId: process.env.ONECLAW_AGENT_ID,
|
|
25
|
+
baseUrl: process.env.ONECLAW_BASE_URL ?? "https://api.1claw.xyz",
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const openai = LLM_VIA_SHROUD
|
|
29
|
+
? createOpenAI({ baseURL: `${SHROUD_URL}/v1`, apiKey: "shroud-injected" })
|
|
30
|
+
: null;
|
|
31
|
+
|
|
32
|
+
const listSecretsTool = tool({
|
|
33
|
+
description: "List secrets in the 1Claw vault (names only, no values)",
|
|
34
|
+
parameters: z.object({ prefix: z.string().optional().describe("Path prefix filter") }),
|
|
35
|
+
execute: async ({ prefix }) => {
|
|
36
|
+
try {
|
|
37
|
+
const vaultId = process.env.ONECLAW_VAULT_ID;
|
|
38
|
+
if (!vaultId) return "No vault configured.";
|
|
39
|
+
const resp = await claw.secrets.list(vaultId, prefix);
|
|
40
|
+
const secrets = (resp as any).data?.secrets ?? [];
|
|
41
|
+
return secrets.length
|
|
42
|
+
? secrets.map((s: any) => ` ${s.path} (${s.type ?? "generic"})`).join("\n")
|
|
43
|
+
: "No secrets found.";
|
|
44
|
+
} catch (e: any) {
|
|
45
|
+
return `Error: ${e.message}`;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const envTool = tool({
|
|
51
|
+
description: "List 1Claw-related environment variables (values redacted)",
|
|
52
|
+
parameters: z.object({}),
|
|
53
|
+
execute: async () => {
|
|
54
|
+
const vars = Object.keys(process.env)
|
|
55
|
+
.filter((k) => k.startsWith("ONECLAW_"))
|
|
56
|
+
.sort()
|
|
57
|
+
.map((k) => ` ${k}=***`);
|
|
58
|
+
return vars.length ? vars.join("\n") : "No ONECLAW_* vars set.";
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
async function handleChat(message: string): Promise<string> {
|
|
63
|
+
if (!openai) {
|
|
64
|
+
return "No LLM configured. Use --llm-api-key or enable Token Billing.";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
conversationHistory.push({ role: "user", content: message });
|
|
68
|
+
|
|
69
|
+
const { text } = await generateText({
|
|
70
|
+
model: openai(MODEL),
|
|
71
|
+
system:
|
|
72
|
+
"You are a helpful AI agent running inside a secure 1Claw container. " +
|
|
73
|
+
"You have access to the 1Claw SDK for vault secrets and multi-chain signing. " +
|
|
74
|
+
"Be helpful and concise.",
|
|
75
|
+
messages: conversationHistory,
|
|
76
|
+
tools: { listSecrets: listSecretsTool, env: envTool },
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
conversationHistory.push({ role: "assistant", content: text });
|
|
80
|
+
return text;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const server = createServer(async (req, res) => {
|
|
84
|
+
if (req.url === "/health" && req.method === "GET") {
|
|
85
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
86
|
+
res.end(
|
|
87
|
+
JSON.stringify({ status: "ok", framework: "typescript-sdk", llm_wired: LLM_VIA_SHROUD }),
|
|
88
|
+
);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (req.url === "/chat" && req.method === "POST") {
|
|
93
|
+
const chunks: Buffer[] = [];
|
|
94
|
+
for await (const chunk of req) chunks.push(chunk as Buffer);
|
|
95
|
+
const body = JSON.parse(Buffer.concat(chunks).toString());
|
|
96
|
+
const message = (body.message ?? "").trim();
|
|
97
|
+
|
|
98
|
+
if (!message) {
|
|
99
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
100
|
+
res.end(JSON.stringify({ error: "No message provided" }));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
const response = await handleChat(message);
|
|
106
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
107
|
+
res.end(JSON.stringify({ response, framework: "typescript-sdk" }));
|
|
108
|
+
} catch (e: any) {
|
|
109
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
110
|
+
res.end(JSON.stringify({ error: e.message }));
|
|
111
|
+
}
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
116
|
+
res.end(`<!DOCTYPE html>
|
|
117
|
+
<html><head><title>1Claw TypeScript Agent</title></head>
|
|
118
|
+
<body style="font-family:system-ui;max-width:600px;margin:40px auto;padding:0 20px">
|
|
119
|
+
<h1>1Claw TypeScript Agent</h1>
|
|
120
|
+
<p>Send messages via <code>POST /chat</code> with <code>{"message": "..."}</code></p>
|
|
121
|
+
<p>Health: <a href="/health">/health</a></p>
|
|
122
|
+
<p style="color:#666;font-size:0.9em">
|
|
123
|
+
Uses @1claw/sdk for vault access and multi-chain signing.
|
|
124
|
+
Credentials stay in the host daemon — this container never sees secret values.
|
|
125
|
+
</p></body></html>`);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
server.listen(PORT, "0.0.0.0", () => {
|
|
129
|
+
console.log(`TypeScript SDK agent listening on http://0.0.0.0:${PORT}`);
|
|
130
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
DAEMON_SOCKET="${ONECLAW_DAEMON_SOCKET:-/run/1claw/daemon.sock}"
|
|
5
|
+
CHAT_UI_PORT="${CHAT_UI_PORT:-3000}"
|
|
6
|
+
|
|
7
|
+
echo "─────────────────────────────────────────────"
|
|
8
|
+
echo " 1Claw TypeScript SDK Agent"
|
|
9
|
+
echo " Framework: @1claw/sdk (TypeScript)"
|
|
10
|
+
echo " Agent ID: ${ONECLAW_AGENT_ID:-not set}"
|
|
11
|
+
|
|
12
|
+
if [ -S "$DAEMON_SOCKET" ]; then
|
|
13
|
+
echo " Mode: ${ONECLAW_MODE:-cloud} (daemon socket)"
|
|
14
|
+
echo " Socket: $DAEMON_SOCKET"
|
|
15
|
+
else
|
|
16
|
+
echo " Mode: standalone (no daemon socket)"
|
|
17
|
+
fi
|
|
18
|
+
echo "─────────────────────────────────────────────"
|
|
19
|
+
|
|
20
|
+
if [ "$ONECLAW_LLM_VIA_SHROUD" = "true" ]; then
|
|
21
|
+
export OPENAI_BASE_URL="${ONECLAW_SHROUD_URL}/v1"
|
|
22
|
+
echo "LLM routed through Shroud: ${ONECLAW_SHROUD_PROVIDER}/${ONECLAW_SHROUD_MODEL}"
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
if [ -S "$DAEMON_SOCKET" ]; then
|
|
26
|
+
if command -v 1claw-mcp >/dev/null 2>&1; then
|
|
27
|
+
ONECLAW_LOCAL_VAULT=true ONECLAW_DAEMON_SOCKET="$DAEMON_SOCKET" \
|
|
28
|
+
1claw-mcp --local 2>/tmp/mcp.log &
|
|
29
|
+
echo "MCP server started in background."
|
|
30
|
+
fi
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
echo "Ready: http://0.0.0.0:${CHAT_UI_PORT}"
|
|
34
|
+
exec npx tsx agent.ts
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "1claw-typescript-agent",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "tsx agent.ts",
|
|
8
|
+
"dev": "tsx watch agent.ts"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@1claw/sdk": "latest",
|
|
12
|
+
"@ai-sdk/openai": "^1.0.0",
|
|
13
|
+
"ai": "^4.0.0",
|
|
14
|
+
"tsx": "^4.19.0",
|
|
15
|
+
"typescript": "^5.7.0"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: typescript-sdk
|
|
2
|
+
display_name: "TypeScript SDK"
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
description: "Plain TypeScript agent using @1claw/sdk with Shroud LLM routing"
|
|
5
|
+
author: 1Claw
|
|
6
|
+
language: node
|
|
7
|
+
homepage: https://docs.1claw.xyz
|
|
8
|
+
|
|
9
|
+
docker:
|
|
10
|
+
base_image: node:22-slim
|
|
11
|
+
context_files:
|
|
12
|
+
- Dockerfile
|
|
13
|
+
- package.json
|
|
14
|
+
- tsconfig.json
|
|
15
|
+
- agent.ts
|
|
16
|
+
- entrypoint.sh
|
|
17
|
+
env:
|
|
18
|
+
ONECLAW_FRAMEWORK: typescript-sdk
|
|
19
|
+
health_endpoint: /health
|
|
20
|
+
health_port: 3000
|
|
21
|
+
|
|
22
|
+
post_spawn_message: |
|
|
23
|
+
Edit agent.ts to customize your TypeScript agent.
|
|
24
|
+
The @1claw/sdk client is pre-configured for vault access and signing.
|
|
25
|
+
LLM calls are routed through Shroud for inspection and redaction.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoEpC,eAAO,MAAM,WAAW,SA0ClB,CAAC"}
|