Skip to content

feat: add /upload-trace command to upload session trace to Hugging Face#2648

Merged
gavrielc merged 1 commit into
mainfrom
share-session-command
May 31, 2026
Merged

feat: add /upload-trace command to upload session trace to Hugging Face#2648
gavrielc merged 1 commit into
mainfrom
share-session-command

Conversation

@gavrielc
Copy link
Copy Markdown
Collaborator

@gavrielc gavrielc commented May 30, 2026

Type of Change

  • Feature skill - adds a channel or integration (source code changes + SKILL.md)
  • Utility skill - adds a standalone tool (code files in .claude/skills/<name>/, no source changes)
  • Operational/container skill - adds a workflow or agent skill (SKILL.md only, no source changes)
  • Fix - bug fix or security fix to source code
  • Simplification - reduces or simplifies source code
  • Documentation - docs, README, or CONTRIBUTING changes only

Note: none of the boxes fit cleanly — this is a deliberate source-level feature added by the maintainer. CONTRIBUTING normally routes features to skills; this one lives in the runner because it's a deterministic, zero-token command (like /clear).

Description

What — A runner-handled /upload-trace slash command (admin-gated, like /clear) that uploads the current session's Claude Code transcript to the user's own private {hf_user}/nanoclaw-traces dataset, viewable in the HF Agent Trace Viewer. Private by default.

Why — Lets users browse, share, and debug their own runs in the HF trace viewer. The agent-runner already emits Claude Code JSONL natively, so it's a near-free addition — no format conversion needed.

How it works — The runner intercepts /upload-trace in the poll loop (same path as /clear), so there's no LLM turn and no token cost. uploadTrace() locates the newest ~/.claude/projects/*/*.jsonl, idempotently creates the private dataset, and pushes the file via the Hub commit API. Auth rides the OneCLI gateway: curl goes out through the injected HTTPS_PROXY, which adds the user's HF token — no credential ever touches agent code. A missing/unassigned token returns clear setup instructions instead of failing silently. The command is admin-gated host-side in command-gate.ts.

How it was testedbun test (container): a dedicated upload-trace.test.ts with unit coverage for isUploadTraceCommand and an integration test of the runner-handled path. All pass; container + host typecheck clean. Verified live end-to-end: /upload-trace from Telegram uploaded the session to a private HF dataset and returned the trace's blob link.

Usage — Send /upload-trace from an owner/admin chat. On success it replies Uploaded → https://huggingface.co/datasets/<user>/nanoclaw-traces/blob/main/sessions/<id>.jsonl.

🤖 Generated with Claude Code

@gavrielc gavrielc requested a review from gabi-simons as a code owner May 30, 2026 07:36
@github-actions github-actions Bot added the follows-guidelines PR was created using the current contributing template label May 30, 2026
Adds a runner-handled /upload-trace slash command (admin-gated, like /clear)
that uploads the current session's Claude Code transcript to the user's own
private {hf_user}/nanoclaw-traces dataset, browsable in the HF Agent Trace
Viewer. The transcript is already in the format the viewer auto-detects, so
the command just locates the newest one and pushes it via the Hub commit API.

Auth is handled by the OneCLI gateway: curl goes out through the injected
HTTPS_PROXY, which adds the user's HF token — no credential ever touches
agent code. A missing/unassigned token yields a clear setup message.

- container/agent-runner/src/upload-trace.ts: isUploadTraceCommand() + uploadTrace()
- poll-loop.ts: recognize and handle /upload-trace in the runner
- command-gate.ts: admin-gate /upload-trace on the host
- upload-trace.test.ts: unit + integration coverage for the command

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gavrielc gavrielc force-pushed the share-session-command branch from 75eae0f to 729cd8d Compare May 30, 2026 07:42
@gavrielc gavrielc changed the title feat: add /share command to upload session trace to Hugging Face feat: add /upload-trace command to upload session trace to Hugging Face May 30, 2026
@gavrielc
Copy link
Copy Markdown
Collaborator Author

Screenshot 2026-05-30 at 10 45 02

@gavrielc gavrielc merged commit 8cb4ed2 into main May 31, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

follows-guidelines PR was created using the current contributing template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant