DeepSeek Harness 插件

meltartica/dsh-mistral-vibe

Star 数 ★ 2 下载量(近 30 天) 1,992 分类 模型与账号接入 收录于 2026-12-01 npm dsh-mistral-vibe

在 DeepSeek Harness 里接入 Mistral Vibe:实时模型目录、按模型映射到 reasoning_effort 的思考档位,以及显示账户月度额度余量的 composer 胶囊。其 HTTP 路由未做 DSH 权限校验,浏览器中打开的任意网页都可能直接调用。

安装

# npm 包(预构建)

dsh plugin --profile web add dsh-mistral-vibe

# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)

dsh plugin --profile web add github:meltartica/dsh-mistral-vibe

装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。

README

该插件的 README 只有英文版本。

Mistral on the La Plateforme API as a DeepSeek Harness provider route: the Vibe model catalogue, thinking levels mapped onto reasoning_effort, reasoning streamed back as a thinking block, and a settings page of its own.

Self-contained by design: no imports from @deepseek-ai/* or pi-ai, no install-time dependencies. The two schema helpers it needs are vendored under vendor/.

What it does

  • Two ways to authenticate. A key, or a Mistral account: the route runs the official client's own sign-in (same client id, PKCE public client, loopback callback) and then sends the account's ID token as the bearer, with the organization headers the API requires. Nothing about the flow is invented here.
  • Two routes, two credentials. mistral-vibe sends the Vibe Code key; mistral-vibe-studio sends a Studio key and never borrows the other one, so it spends the API allowance on purpose. With no Studio key it advertises no models and stays out of the picker. When the Vibe allowance is spent, a turn is retried once on the Studio key instead of failing — the two keys debit different buckets, so the turn still finishes.
  • Thinking levels per model, limited to what the model publishes: off goes out as reasoning_effort: "none", the rest verbatim. A model with no ladder gets no level control and is never sent an unsupported effort.
  • Reasoning as a block. {type: "thinking"} chunks in delta.content become reasoning-delta, so the harness renders thinking instead of inlining it.
  • The catalogue is models.dev, read field by field rather than guessed from ids: type for chattability, modalities.input for the modality list, limit.* for the windows, reasoning_options for the levels, status to drop a retired id. It is the only source that names a model and states what it takes, so one read gives the whole list — no aliasing pass, no merge against a snapshot, no key required.
  • /v1/models only for a custom endpoint. A gateway or a local server is asked directly, because models.dev describes Mistral's own ids and knows nothing about what that host serves.
  • A settings page at Settings → Mistral Vibe: both credentials with an eye toggle, the endpoint, and the model list with ladder, modality and window per row.
  • A live allowance meter left of the composer, drawn from GET /v1/billing/budget: the bucket this route debits, with both buckets and the reset date under the cursor. When the read fails it says why instead of disappearing.
  • A prompt cache that survives images. Downscaling, x-affinity session pinning and a one-decision-per-batch image offload keep an image-bearing transcript inside Mistral's prefix cache instead of missing it on every step.
  • Secrets stay out of the row file. A saved key goes to the credential store and the YAML keeps only the reference; the page receives hasKey booleans, never a value.

Install

Requires DeepSeek Harness with the dsh CLI.

# from a directory containing this repo, or the bare name once published;
# <name> is the profile you boot, e.g. `web`
dsh plugin --profile <name> add ./dsh-mistral-vibe
dsh --profile <name>

Then open Settings → Models, pick Mistral Vibe, and paste a Vibe Code API key. The package is not built: lib/ is the shipped source, so a profile loads exactly what is in the repo. A tarball works too (npm run pack writes dsh-mistral-vibe-<v>.tgz):

dsh plugin --profile <name> add ./dsh-mistral-vibe-<version>.tgz

Settings

Settings → Mistral Vibe owns every field. The same row is editable in cordis.patch.yml if you prefer text.

field default meaning
displayName Mistral Vibe the label the picker shows
baseURL https://api.mistral.ai/v1 chat and model-list endpoint
apiKey — Vibe Code key, sent as Authorization: Bearer
studioApiKey — Studio key: authenticates the second route and reads the budget
apiKeyEnv MISTRAL_API_KEY credential-store name consulted when the row is empty
authMode apiKey apiKey sends a key; oidc sends a signed-in account's ID token
oidcIssuer https://auth.mistral.ai issuer, and the key under which the client registration is found
oidcClientId 829da7e7-…-8cca609c76d4 the registration the official CLI uses; a public client, no secret
oidcAudience https://api.mistral.ai the audience the ID token is minted for
oidcScope openid offline_access email profile requested scope
oidcPort 8766 loopback port for the sign-in callback
oidcOrganizationId "" organization to send; empty, or no workspace chosen, means discover it from /v1/users/me/workspaces
oidcWorkspaceId "" workspace to send; the page only offers this when the account has more than one
userAgent vibe User-Agent a Mistral-bound request names: vibe (the official client, newest known release), a pinned vibe@3.2.0 / vibe-plain@… / vibe-cli@…, default for the harness one, or any product token. The release list is checked once a day
credentialCommand "" shell command whose first output line is the bearer to send, re-read once a minute
vibeAttribution true send metadata.call_source: "vibe_code" so a completion draws on the Vibe allowance instead of the API one; only sent to Mistral's own hosts
disabledModels [] ids hidden from the picker, still listed on the page
modelsJson "" the stored model list, written by Fetch available models
maxRequestBytes 2500000 largest body sent; older turns are dropped to fit, because the gateway answers 503 near 5 MB
sendAffinity true send x-affinity: <session id> so one Session keeps one backend instance, which is where its prompt cache lives
imageMaxEdge 1024 longest edge an image is downscaled to; derived from the request, with no knob on the page — a smaller source is never upscaled
imageMaxBytesKb 768 byte budget for one request image
offloadSeenImages false retire images the model has already answered on, so they stop occupying the cached prefix
imageKeepBatches 3 how many of the newest image batches keep their pixels when offloadSeenImages is on
bypassRewrite true send x-bili-passthrough: 1 so an in-process rewriter relays the body verbatim

Both keys are role("secret") and volatile(). hasKey counts a key in the credential store or in the environment under apiKeyEnv, so a key exported in a shell reads as configured. If the credential store exists but refuses a write, saving fails loudly — a key is never written into cordis.patch.yml as a fallback.

Signing in with a Mistral account

Mistral's own client offers two ways in, and this route now offers both. Set authMode: oidc (or press Mistral account on the settings page) and Sign in with Mistral: the browser opens Mistral's sign-in page, comes back to a loopback port, and the route sends the resulting ID token as the bearer from then on. No key is stored.

Every piece of that is the official client's, read from mistralai/mistral-vibe v3.2.0:

piece value where it comes from
client id 829da7e7-628f-4795-829a-8cca609c76d4 vibe/setup/auth/_oidc_config.py
issuer / audience https://auth.mistral.ai / https://api.mistral.ai same
redirect http://127.0.0.1:8766/callback same
scope openid offline_access email profile same
proof PKCE S256, public client, no secret _oidc_client.py
bearer the ID token, not the access token _oidc_runtime.py:oidc_headers
tenant headers x-external-organization-id, optional x-external-workspace-id same
tenant lookup GET {audience}/v1/users/me/workspaces _oidc_tenant.py

Three consequences worth knowing:

  • The CLI hides sign-in behind VIBE_CLI_OIDC_ENABLED. That is a local switch in vibe/utils/oidc_marker.py, not a server rule: the API accepts an ID token either way, which is why this route does not need the variable set.
  • The organization is required by the API, so it is discovered at sign-in and sent on every call. An account with several workspaces gets a Workspace picker in the advanced block, and the organization follows whichever one is chosen; one workspace is not a choice, so the row stays hidden. If the lookup itself is refused (the token lacks see_org_inference_usage), set oidcOrganizationId by hand; the sign-in still stores the session.
  • The host opens exactly one tab and the page opens none: two tabs on one state token is a failed sign-in. Before opening anything, the authorize URL is fetched once, so a revoked registration arrives as the service's own words in the page's alert instead of a dead tab reading invalid_client. While a sign-in is in flight the page asks the status route every two seconds and flips to the account on its own.
  • The refresh token is what makes the sign-in persist. Opening the page the next day renews the ID token from the stored refresh token, and only a renewal that the issuer refuses marks the session expired.
  • The token's claims are read for exp, sub, email and nonce, but its signature is not verified locally: the API is the verifier, and the browser's answer already arrived on a loopback port that only this process was listening on. The nonce and state are compared before the session is stored.

A signed-in account and a key are mutually exclusive on this route — authMode decides. The Studio route keeps its own key, always.

Route surface

route effect
GET /mistral-vibe/config the row as the page needs it, plus build — no key values
POST /mistral-vibe/config save keys, baseURL, displayName, disabledModels, credentialCommand, vibeAttribution, userAgent, sendAffinity, imageMaxEdge, imageMaxBytesKb, offloadSeenImages, imageKeepBatches, maxRequestBytes, bypassRewrite, authMode, oidcIssuer, oidcClientId, oidcAudience, oidcScope, oidcPort, oidcOrganizationId, oidcWorkspaceId
POST /mistral-vibe/discover read the catalogue (models.dev, or GET /v1/models for a custom endpoint) and save it; answers {source, hasCredential, added, models, persisted}
GET /mistral-vibe/quota both monthly buckets from GET /v1/billing/budget, cached 5 min per endpoint and credential
GET /mistral-vibe/user-agents the User-Agent choices and when the release list was last checked; POST forces a check
GET /mistral-vibe/auth which mechanism is selected, and what the stored session says about itself
POST /mistral-vibe/auth/login start a sign-in and answer {url, redirectUri, opened}, so the page knows whether a tab opened
POST /mistral-vibe/auth/signout forget the session, revoking the refresh token when the issuer can

Every route answers DSH's admission first: ctx.connection.requestRejection(request) decides the Host/Origin allow-list and the browser session, so a request the rest of the Host would refuse is refused here too, with Connection's own status. A composition with no Connection service serves a loopback peer and nothing else. The manifest says so — engines.dsh: >= 0.2.2-0.

All seven answer any caller that admission lets through, and none is a token check: the page is served by the same web server, so an exposed GUI needs no extra setup. No route returns credential material.

Thinking levels

A level is sent only when the model publishes one:

model levels wire
deepseek-v4-1-flash-1017 off, low, high, max none, low, high, max
mistral-large-4 low, medium, high verbatim
mistral-medium-2604 off, high none, high
codestral-2508, ministral-*, voxtral-* none no reasoning_effort

An id models.dev does not know keeps "levels unknown": no level control, no reasoning_effort on the wire.

Fetching the model list

Refresh reads the catalogue and saves it. On a Mistral endpoint that read is models.dev, which needs no credential; on a custom endpoint it is GET /v1/models with the draft key. What lands in the store:

  • every chat model in the provider's lobe, with its name, modality list, windows and thinking ladder;
  • no embedding, speech or transcription record, and no status: "deprecated" id;
  • the hidden rows ticked off, so one can be restored without a fetch.

If models.dev cannot be reached the page keeps the list it already shows and the button answers "Offline"; if the list cannot be written (read-only profile), the page says so instead of silently dropping the result.

Images and the prompt cache

Mistral's cache only serves a request whose beginning repeats byte-for-byte, so two things matter more than they look:

  • Size. A 3 MB screenshot becomes a ~4 MB base64 payload, and every step that carries it misses the cache. Images are downscaled to imageMaxEdge (1024px) and imageMaxBytesKb (768 KB) before sending; a smaller source is never upscaled.
  • Stability. An over-budget transcript is not rewritten here. The route reports how many image occurrences must go (IMAGE_OFFLOAD_REQUIRED, offloadImages), the harness records one durable image/offload decision and retries, so the transcript changes once per batch instead of once per turn. The 21st image therefore retires four old ones, not one.
  • Instance. x-affinity: <session id> pins every request of one Session to the backend instance holding its prefix, and is only sent to Mistral's own hosts.

offloadSeenImages goes further and retires images the model has already answered on, keeping the newest imageKeepBatches batches as pixels. It is off by default because it rewrites history; turn it on when a long visual Session spends its prompt on stale screenshots.

Allowances and the credential

Mistral keeps two monthly allowances on one account — Vibe Code and Studio/API — and decides which one a completion draws on from one body field, metadata.call_source. The official Vibe CLI sends "vibe_code" on every completion; a request without it is charged to the API allowance even on a plan that pays for Vibe. This route sends the same field by default (vibeAttribution, only to Mistral's own hosts), which is what keeps a turn on the Vibe allowance.

Measured on 2026-12-01 against a live account, one variable per probe:

request vibe_budget api_budget
no metadata 7.908555618666667% → unchanged 95.89572817333334% → 95.89576117333333%
metadata.call_source: "vibe_code" 7.908555618666667% → 7.908558118666667% unchanged

The model, the stream flag, the headers and the User-Agent were varied the same way and never moved the charge. So there is no header to spoof and no key to swap: the body names the caller, and that is the whole mechanism. An empty call_source is a 422, which is why the field is sent with the CLI's own value and never to a base URL that is not Mistral's.

The pill names the bucket the setting asks for: Vibe with attribution on (the default), API with vibeAttribution: false, and — once Mistral has refused a call — whichever bucket that refusal named, until the setting changes or six hours pass. Composer occupants are handed no props, so it cannot see which provider the model picker is on. Both buckets and the reset date are under the cursor.

A spent allowance still falls back. Measured on 2026-11-30 with both keys on one EDU account: the key in the row answered 402 billing_vibe_budget_exhausted for every model, while a Studio key answered 200 and moved api_budget. Same account, same endpoint, same body. So a 402 on the Vibe route retries once on the Studio key (before anything is streamed, so the retry cannot duplicate output), and the pill follows the bucket that served.

The credential still matters for a different reason. Vibe's own harness never resolves a key: its host hands it a minted, expiring token. credentialCommand is how one reaches this route if you have one:

# cordis.patch.yml, in the llm-mistral-vibe row
credentialCommand: vibe auth print-token      # whatever prints a usable bearer

The first non-empty line of stdout is used, cached for 60 s, and ignored when it cannot be an HTTP header value. If the command fails, the stored key is used, so a bad command degrades instead of breaking the turn.

Development

npm test                 # host + contract + client suites, offline
npm run test:host        # adapter, discovery, settings, wire encoding
npm run test:contract    # the emitted stream, through the harness's own assembler
npm run test:client      # the browser half, rendered against a React stub
npm run check            # node --check both halves, the suites, then the audit
npm run audit:harness    # this adapter through the installed harness's own validators
npm run sync:models      # rewrite MODEL_CATALOGUE from models.dev
npm run probe            # live /v1/models read with the stored key (gateway path)
npm run stamp            # rewrite the BUILD stamp in lib/index.js
lib/index.js       host half: adapter, catalogue, discovery, HTTP surface
lib/client.js      browser half: the settings page and its composer pill
vendor/            schemastery + cosmokit, vendored as ESM
locale/            en/zh titles for the settings entry
scripts/           sync-models, audit-harness, stamp-build, live-check
test/              host.test.mjs, contract.test.mjs, client.test.mjs

The suites need no network and no key: the host suite runs the real adapter against a local SSE server, and the models.dev read is pointed at a stub through MISTRAL_MODELS_DEV_URL. npm run audit:harness imports the harness's real LlmRuntime and BlockAssembler (from %LOCALAPPDATA%\Programs\DSH NEXT\… or DSH_LLM_PATH) and feeds this adapter through them, so the checks are the harness's own code: catalogue validation, per-model metadata, the retired-alias echo, ladder defaults, both provider ids, and a streamed reply built into a message. It prints SKIP and exits 0 when no harness is installed.

Session-safety invariants

A stream that is wrong here does not fail a turn — it writes a session log that later refuses to load.

rule this route
a tool-call id must be unique for the whole session a 9-character hash of the provider id plus a serial that never resets, so call_1/call_2 per response cannot repeat across turns
tool/call must echo the advertised name and arguments byte for byte the block-end carries the same accumulated values the deltas streamed, {} when nothing arrived
only text, reasoning and tool-call blocks no other block type is ever started
chunk types are closed, argumentsDelta is a string, indexes are non-negative integers enforced by the contract test, chunk by chunk
usage precedes finish, nothing follows it the generator yields usage then finish, last
each call gets its own block a missing or reused index allocates a fresh slot instead of merging

npm run test:contract runs the emitted stream through the harness's real AssistantStreamAccumulator and BlockAssembler and applies these rules. It is the only check that would have caught a chatcmplt-style corruption before it reached a log.

Which build is running

A host keeps an applied plugin in memory: re-applying the entry writes applied to the operation log but does not re-import the file, so a fix can be on disk and still not run. BUILD makes that observable — it is the hash of lib/index.js without its stamp line, logged on mount, returned by GET /mistral-vibe/config, and printed under the model list. "host build unknown" means the host still serves a module loaded before the field existed; restart DeepSeek Harness to pick the file up.

Notes / limitations

  • A dropped connection is retried; a refusal is not. Node reports every socket problem as TypeError: fetch failed with the real code on cause, so the route reads the cause: ECONNRESET, ETIMEDOUT, EAI_AGAIN, UND_ERR_SOCKET and friends re-send the identical body up to four times with 400 ms → 1.2 s → 3 s between, and give up with the code named. A DNS miss (ENOTFOUND), a certificate error, an abort, or any answer from the API — 4xx, 402, 422 — is never re-sent, because re-sending an answer cannot improve it. Nothing has streamed at that point, so a retry cannot duplicate a chunk. Connecting and headers are capped at 45 s per attempt; a long generation is not, and unref()ed timers mean a waiting retry never keeps the host alive.
  • The allowance is readable, the spend is derived. GET /v1/billing/budget answers usage_percentage and initial_budget per bucket; the spent figure is computed from those, because the endpoint has no amount field. It needs the key's see_org_inference_usage permission — a 403 leaves a muted "allowance —" pill whose tooltip names the missing permission, rather than inventing a number. /v1/billing/subscription answers a plan name and nothing else; /v1/billing/usage is 404 no Route matched.
  • A spent allowance says which one. A 402 carries Mistral's own type — {"message":"Vibe budget exhausted.","type":"billing_vibe_budget_exhausted","code":"2304"} — so the turn fails with that sentence plus where to read the reset, not with "lack of credit". With a Studio key configured the turn does not fail at all: it is retried on that credential and finishes on the API allowance.
  • Rate-limit headers are captured, but Mistral sends none. No ratelimit-* header appears on a 200, 401 or 402 from Mistral, so the capture is dormant: the local refusal only acts when something in front of the API adds those headers. Then they are read per credential, and a reading expires after ten minutes — a zeroed budget whose reset cannot be parsed would otherwise refuse every call forever, since a refused call never sends the request that would refresh the reading.
  • Replay is sanitised. Every request is rebuilt from the fields Mistral declares: role, content, and tool_calls with id/type/function. Reasoning replays the way Vibe replays it — {"type":"thinking","thinking":[{"type":"text",…}]} chunks inside content, gated on the model declaring a ladder — never as a sibling reasoning_content, which Mistral answers with a body-wide 422 extra_forbidden.
  • An in-process request rewriter is asked to stay out of the way. billion-context injects a blank reasoning_content into any assistant turn carrying tool_calls when the model id matches /deepseek/i, which is every deepseek-v4-1-flash-1017 turn that used a tool, and Mistral rejects the field. Every request therefore carries x-bili-passthrough: 1, bili's verbatim-relay marker; Mistral ignores unknown headers. Set bypassRewrite: false to stop sending it behind a gateway that rejects unknown headers, at the cost of bili doing no folding on this route.
  • Tool-call ids are hashed, never truncated. Harness ids share a long prefix (chatcmpltool…), so the first nine alphanumerics were chatcmplt for every call and the log refused to load.
  • Alias ids still resolve. mistral-medium-latest is not a row of its own; a session that selected it resolves to mistral-medium-2604 with that entry's limits.

License

MIT © Meltartica — see LICENSE.

内容来自项目 README(GitHub)↗

链接

同类插件

查看整个分类 →

社区评论

评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。