返回目录
模型与 MCP 插件

dsh-free-llm

luisrinaldi/dsh-free-llm

Use the AI coding CLIs you already have (OpenCode free models, Grok Build, OpenAI Codex) as model providers in DeepSeek Harness, with a local usage and quota dashboard. Zero dependencies.

Stars
1
Forks
0
Issues
0
更新
8 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:luisrinaldi/dsh-free-llm

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-free-llm

Use the AI coding CLIs you already have (including OpenCode's free models) as model providers inside DeepSeek Harness. No extra API keys, no proxy server: every turn is answered by a CLI installed on your own machine, under its own login, and a local dashboard shows what each one has used.

CI License: MIT Node Dependencies

🇪🇸 Leer en español

Route CLI How a turn runs
opencode OpenCode opencode run --model <m> --format json — opencode/*-free models need no account
grok Grok Build (xAI) grok -p <prompt> -m <m> --output-format streaming-json
codex OpenAI Codex codex app-server --listen stdio:// (streamed JSON-RPC)

Contents

Why use it

  • Free models out of the box. OpenCode's *-free models (for example opencode/deepseek-v4.1-flash-free) work without an account.
  • Reuse subscriptions you already pay for. Codex and Grok run with the login you already have in their CLIs; this plugin never sees your password or token.
  • One picker. All three appear as route groups in the DSH model picker.
  • Know what you spend. A charted dashboard shows tokens, cost and the real Codex 5-hour and weekly limits, read from the CLIs' own records.
  • Zero dependencies. Only Node.js built-ins; nothing to audit but two files.

Quick start

Requirements: Node.js 20.11+ and a DeepSeek Harness profile. The peer packages @deepseek-ai/cordis and @deepseek-ai/dsh-llm come from the harness.

  1. Add the plugin to your profile. In the profile's package.json (for example ~/.dsh/profiles/<name>/package.json):

    {
      "dependencies": { "dsh-free-llm": "git+https://github.com/luisrinaldi/dsh-free-llm.git#v1.0.1" },
      "dsh": { "profile": { "bundles": ["dsh-free-llm"] } }
    }

    Pinning a tag (#v1.0.1) means you only get new code when you change it. Use the git+https form: npm resolves the github: shorthand over SSH, which fails on machines without a GitHub key.

  2. Install the CLIs you want (any subset):

    npm install -g @opencode/cli     # OpenCode — free models, no account needed
    npm install -g @openai/codex     # Codex — then: codex login --device-auth
    # Grok Build: follow xAI's instructions — then: grok login --device-auth

    If you skip this step, the plugin installs a missing CLI the first time you use it (or press Install CLI on the plugin page).

  3. Restart the profile. The routes appear in the model picker, and the plugin page appears under Plugins → Free LLM · OpenCode, Grok, Codex and Settings → Free LLM usage.

See docs/MOUNTING.md for a local checkout (junction/symlink) or a plain file insert.

Do not mount it next to another plugin that registers the same opencode, grok or codex routes in the same profile.

Security defaults

This plugin starts other programs on your machine, so its defaults are conservative. Read SECURITY.md for the full model.

Behaviour Default Change it with
Install a missing CLI the first time a route needs it (official npm packages or the official x.ai installer, into ~/.dsh/clis) On autoInstall: false
Install a CLI from the plugin page (Install CLI button, this machine only) On —
Check for or install plugin updates on a timer Off autoUpdate: 'check' or 'apply'
Codex sandbox read-only providers.codex.sandbox: workspace-write
Dashboard from another machine Refused dashboardToken (16+ characters)
Setup and update actions from another machine or through a proxy/tunnel Always refused —

Other guarantees:

  • Prompts never pass through a shell. On Windows, npm .cmd shims are resolved to their real target instead of being handed to cmd.exe.
  • The usage ledger stores counts only — never prompt or reply text.
  • Temporary prompt and image files are created with mode 0600 and removed after the turn.
  • Update checks only ever read this repository (luisrinaldi/dsh-free-llm).

Features

  • Streaming. Text deltas are forwarded as each CLI emits them.
  • Session workspaces. Turns run in the DSH session workspace and forward the session's system instructions (opt out with includeSystemPrompt: false).
  • Harness tools. Offered DSH tools can be requested through a validated JSON relay; the harness runs them under its own permission rules and returns the results on the next turn. This depends on the model following the protocol — it is not native MCP forwarding. Disable with toolBridge: false.
  • Image attachments. Delivered as real bytes: Codex --image, OpenCode --file, Grok ACP image blocks. PNG, JPEG, WebP and GIF; up to 8 images of 20 MiB each (OpenCode: one image per request). Vision needs a capable model.
  • Model limits. Context and output limits come from each CLI's own catalog; you can pin them per model.
  • Sign-in helpers. provider_signin / provider_signin_status tools and the plugin page show the CLI's real device URL and code, then poll until you approve in the browser. Existing logins are reused.
  • Managed installs. Install CLI puts OpenCode and Codex (official npm packages) and Grok (official x.ai installer) under ~/.dsh/clis — nothing is installed globally. Installs are deduplicated, time-limited and verified with --version.

Configuration

The bundle mounts the entry with defaults. A profile cordis.patch.yml overrides it by id (a replacement config must restate every field it keeps):

- id: free-llm
  config:
    cwd: '/path/to/agent/workspace'
    usageFile: '/path/to/.dsh/free-llm-usage.json'
    providers:
      opencode:
        models: [opencode/deepseek-v4.1-flash-free]
      codex: {}
      grok: {}
    # Optional budget gauges (the CLIs publish no quota for Grok/OpenCode):
    plan:
      grok:
        monthlyBudgetUsd: 20
        resetDay: 1
        weeklyPremium: { usedPercent: 1, resetAt: '2026-10-23T15:13:00Z' }
      opencode:
        monthlyBudgetTokens: 100000000
        resetDay: 1

Routes and models

Option Meaning
cwd Fallback workspace for calls without a session. Session turns use the session's own workspace; a missing one fails explicitly. providers.<id>.cwd overrides it per route.
providers.<id> false or { enabled: false } drops a route. Also bin, defaultModel, displayName, contextWindow.
providers.<id>.models Explicit model list. Entries are a model id or { id, name?, contextWindow?, maxOutputTokens? }; a configured entry wins over any CLI cache and is labelled configured for this model.
providers.opencode.contextWindowCap Caps OpenCode context (default 500,000). With preserveFreeContext: true (default), *-free models of 1M+ tokens keep their native context. modelInfoArgs: false disables catalog lookup.
providers.codex.sandbox read-only (default) or workspace-write. The CLI's own policy can still refuse; the plugin never bypasses it.
providers.codex.appServer false uses the older exec --json transport. liveQuota: false disables live quota requests; appServerArgs overrides the launch arguments.
timeoutMs Per-turn timeout.
includeSystemPrompt Forward system/developer instructions (default true).
toolBridge JSON harness-tool relay (default on); false disables it.

Installation and sign-in

Option Meaning
autoInstall Install a missing CLI on its first model turn or sign-in request (default true). false leaves installation to the Install CLI button or to you.
cliInstallDir Absolute managed-install directory (default ~/.dsh/clis).
installTimeoutMs Installer timeout (default 5 minutes).
providers.<id>.installCommand Trusted operator setting { bin, args, binPath, binArgs? } for offline or custom installers. HTTP callers can never supply commands.
signInTtlMs How long a device-code sign-in waits for you (default 10 minutes).

Dashboard, usage and updates

Option Meaning
usageFile Usage ledger (default ~/.dsh/free-llm-usage.json). Writes are locked and merged, so profiles can share it.
dashboardToken Required for dashboard reads from another machine; 16+ characters. Sent as ?token=, an x-free-llm-token header, or the free_llm_token cookie.
plan.<route> Optional monthlyBudgetUsd, monthlyBudgetTokens, resetDay (1–28) gauges; plan.grok.weeklyPremium copies grok.com's weekly limit.
grokUsageDir Grok session stores (default ~/.grok/sessions).
codexUsageDir Codex rollouts (default ~/.codex/sessions).
codexModelsCache Codex model catalog (default ~/.codex/models_cache.json).
opencodeStats.args Arguments for opencode stats (default stats --json --all --models --cost).
autoUpdate false (default), 'check' or 'apply'.
updateIntervalMs Timer for autoUpdate (default 24 h, minimum 1 min).
updateSource Where the version check reads package.json (default this repository's main).
updateInstall { method: 'npm' \| 'git', dir, spec } when the plugin cannot detect how it was installed.

Dashboard and usage data

Endpoints on the harness's own web server:

Endpoint Purpose
GET /free-llm/usage · GET /free-llm/usage.json Charted page / JSON. ?days= or ?hours= (or the 5h · 7d · 30d · 90d · all buttons) set the window; ?force=1 rereads the CLI sources.
GET /free-llm/setup.json · POST /free-llm/setup Host-only install, sign-in, status and cancel actions.
GET /free-llm/update.json · POST /free-llm/update Host-only update check and install (needs the action token).

The page shows every route and model with its limits, daily tokens per CLI, an activity heatmap, token mix, cost by model, per-model tables, live Codex 5-hour and weekly limits (with recorded snapshots as a fallback) and, when you configure plan, used-vs-budget gauges. An update installs with `npm install

` or `git pull --ff-only`, then reports `restartRequired`: **restart the profile to load the new code**.

Two independent views answer different questions:

  • This harness — turns recorded by this DSH instance (the ledger).
  • CLI-recorded — what each CLI records itself, including sessions started outside DSH:
    • Grok sums ~/.grok/sessions/<workspace>/<sessionId>/usage.json (cost in ticks of 1e-10 USD). Until the CLI has run a session, the view is "unavailable", not zero.
    • OpenCode runs opencode stats --json --all --models --cost (cached). --days takes whole days, so sub-day windows are served at one day and the page says so.
    • Codex reads the newest token_count event of ~/.codex/sessions/<yyyy>/<mm>/<dd>/rollout-*.jsonl and queries account/rateLimits/read through the installed CLI without starting an inference turn.

A figure a CLI does not report is shown as a dash, never as zero. Codex cost is always a dash. The two views can split the same total differently (Grok counts cached input inside input tokens; the turn event reports it separately), but both add up to the same total.

What each CLI can and cannot report

  • Grok — model catalog from ~/.grok/models_cache.json; real per-session tokens and cost; no subscription quota (grok.com's weekly premium limit is behind a private RPC), so the weekly gauge uses plan.grok.weeklyPremium or a ~/.grok/subscription.json snapshot.
  • Codex — its own usage and real subscription limits (5-hour and weekly percentages and reset times) plus the context window. It has no model listing command, so the route reads Codex's own catalog.
  • OpenCode — model ids, native limits via opencode api GET /api/model, and usage via opencode stats. opencode/*-free needs no account; magpie/* needs an authenticated OpenCode account.

Troubleshooting

Symptom Fix
free-llm: <cli> is not installed and autoInstall is false … Press Install CLI on the plugin page, install the CLI yourself, or remove autoInstall: false.
A CLI install fails Check that Node/npm (and, for Grok on macOS/Linux, bash plus curl or wget) are available and that the machine has internet access.
The turn answers with a device code The CLI is signed out: open the URL, enter the code, and retry.
Cannot launch the Windows shim … Set providers.<id>.bin to the real executable.
Dashboard returns 403 from another machine Configure dashboardToken (16+ characters) and pass it as ?token=.
Install/update buttons are refused They only work on the machine running DSH, without proxies or tunnels.
A CLI view says "unavailable" That CLI has not recorded any session yet on this machine.

Development

npm test        # every test/*.test.mjs in its own process

The suite has no dependencies and makes no network calls: it drives stub CLIs (test/stubs/stub-cli.mjs) that emit the CLIs' real JSON shapes and builds synthetic Codex rollouts. Every test mount uses its own scratch ledger, so a test run never touches a live profile. CI runs the syntax check and the suite on Node 20, 22 and 24, on Linux and Windows.

Optional probes, not part of npm test: node test/_descendants.mjs checks child-process cleanup on the current OS; node test/_codex-live-probe.mjs asks a real, signed-in Codex CLI for its quota without starting an inference turn.

License

MIT.

This project is not affiliated with DeepSeek, OpenAI, xAI or OpenCode. Their names are used only to describe compatibility.

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度高

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: llm、free-llm、deepseek-harness。