* feat(dsh): add Environment tab with local Python detection
Adds a read-only Environment tab to the ReMe Memory settings card so
users can see why the ReMe service is unreachable before touching a
terminal:
- discover local Python interpreters via the PEP 514 registry, py
launcher, PATH and conda (base + named envs), then verify every
candidate by actually running it
- classify origins (conda base/env, python.org, Microsoft Store, venv,
system PATH), drop Store alias stubs, and suggest a preferred
interpreter (Python >= 3.11, named conda envs first)
- expose detection to the browser through a new remeEnv host gateway
(TypertRemoteService) and render it with a connection health check
- config gains optional authToken and pythonPath fields with unchanged
defaults; existing memory settings keep their behavior
Parsing is fixture-tested against real tool output on Windows (GBK
codepages, localized reg labels, missing py launcher) and Linux.
* feat(dsh): check and install reme-ai from the Environment tab
- check reme-ai version, the [core] AgentScope import and the reme CLI
for the selected interpreter; an outdated install is flagged instead
of treated as ready
- one-click pip install of reme-ai[core] as a Host job: per-job log file,
2s log-tail polling, cancel, and running-job restore after a page
reload; the optional mirror overrides pip only for that run
- interpreter detection now probes reme-ai per environment, so the
suggestion prefers a named conda env with a usable reme (an outdated
reme no longer outranks a ready environment)
- fix: DSH exposes these Remote methods in SRC mode, which parses the
method source; every method takes one plain `input` identifier
parameter (no defaults or destructuring) and the client sends
`{ args: { input } }`
* feat(dsh): manage ReMe .env settings from the Environment tab
- read the workspace .env as a masked projection: non-secret values are
editable, API keys return only •••• plus their last four characters
- merge edits into the existing file, preserving comments, ordering and
unknown variables; validate the effective file so an untouched real
key still satisfies the LLM requirement
- require a non-empty EMBEDDING_API_KEY (EMPTY placeholder fills in on
first save), because ReMe 0.4.0.x aborts startup without one
- test the configured LLM endpoint from inside the workspace with the
selected interpreter, classifying 401/404/network failures
- add the remeWorkspaceDir setting (empty means ~/.reme) consumed by
the .env editor and later service management
Real-machine check: masked read leaks no secret, temp-workspace write
is idempotent and rejects an empty embedding key, and the LLM probe
against the local ~/.reme/.env returned HTTP 200.
* feat(dsh): start and stop the local ReMe service
- service status combines a direct /health_check probe with port probing:
running (managed or foreign), port conflict, or stopped
- start composes `reme start` with an absolute workspace_dir and
service.host/port, runs it detached inside the workspace (so ReMe's
.env discovery works), injects UTF-8 and NO_PROXY, disables the rich
logo, and only passes jobs.dream_cron.enabled=false on reme >= 0.4.1
- the plugin records the PID and launch arguments in service.json, so
stop can tree-kill the managed process; foreign instances are shown
but not touched
- serviceLog exposes the workspace log tail for start-failure diagnosis
- optional autoStart setting starts a stopped local service when DSH
boots, using the selected interpreter (or the detected suggestion)
Real-machine check: started ReMe 0.4.0.9 on port 2334 in a temp
workspace, observed running/managed with the recorded PID, then
stopped it and confirmed the port was released.
* docs(dsh): document the environment management tab
Describe the five Environment sections, the .env and EMBEDDING_API_KEY
contracts, local service control semantics, and the optional authToken
field in both READMEs.
* fix(dsh): mount the environment gateway under its own service key
TypertRemoteService registers itself under the constructor key, so
`super(ctx, remeEnv)` collided with the already-provided `remeEnv`
manager: the gateway plugin failed activation (its async rejection was
logged only), leaving every /api/remeEnv/* call with HTTP 404.
Register the service as `remeEnvGateway` and keep the wire namespace
`remeEnv`, which is what the client calls. Add a real-cordis regression
test that mounts the gateway inside the same isolated realm and asserts
the binding, the namespace, and the SRC-parsed `input` parameter.
Also show the interpreter hint on detection failure so an empty list
never leaves the tab without guidance.
* feat(dsh): restructure the environment tab for scanability
The environment tab rendered as one flat column: five identical headings,
every detected interpreter in one long list, and the whole .env form
always expanded. That reads like prose and grows without bound on
machines with dozens of conda environments.
- Lead with a status hero (endpoint, service/Python/ReMe chips, retest and
rescan) so the current state is readable at a glance.
- Turn the four remaining groups into numbered cards with a status pill in
the header, so setup order and per-step state are obvious.
- Show only the interpreter in use, then reveal the rest on demand:
search box, six rows per page, and a show-all toggle.
- Collapse the .env editor behind a summary line (path + model).
- Explain the "recommended" marker through a tooltip; the flag now also
distinguishes an outdated reme-ai (amber) from a current one.
- Expose versionOk on the detection probe so the client can tone the tag
without importing host-only modules.
- Add a react-test-renderer suite covering the hero, card count, collapsed
list, pagination and interpreter selection.
* docs(dsh): format README tables with prettier
Table column padding in both READMEs did not match prettier's output, so the plugin CI format check failed. Content is unchanged.
* test(dsh): stub the health probe in the environment tab test
The tab renders a hero from /health_check on mount. The test asserted the ready state, which only held while a local ReMe service was running, so it failed on CI runners. Replace global fetch with a canned health response for the duration of each test.
* chore(dsh): target DSH 0.2.2-alpha.2
Add the current DSH release to the peer ranges and to the package
compatibility matrix (cordis 4.0.6-alpha.1, loader 1.0.7-alpha.1,
schemastery 3.18.6-alpha.1), which needs Node 24.9 or newer.
The packaged-plugin check now launches the npm CLI through node using
the npm_execpath npm exports, so it also runs on Windows where npm is
npm.cmd and execFile cannot start it.
* refactor(dsh): collect environment management under src/environment
Move the Host modules out of src/pyenv and the tab out of src/client so
the feature has one boundary:
src/environment/types.ts browser-safe RPC contract
src/environment/host/*.ts detection, install, service, workspace
src/environment/client/* the Environment tab
src/environment/host/gateway remeEnv RPC surface
src/environment/host/manager the operations the gateway exposes
The cross-boundary shapes (detection, reme-ai check, install job, .env
summary, service state) now live in one browser-safe module instead of
being pulled from Host modules that import node built-ins; Host-only
shapes stay beside the code that owns them. src/index.ts registers the
gateway and manager, src/client/index.tsx mounts the tab. The wire
namespace, method names and service keys are unchanged.
* refactor(dsh): split the environment tab into per-section modules
The tab was one 2,213-line component with 27 state hooks. It is now one
module per step, and each step owns the asynchronous state it shows:
client/tab.tsx layout, hero, the settings reads
client/python.tsx usePython + the interpreter section
client/dependency.tsx useDependency + the reme-ai section
client/workspace.tsx useWorkspace + the .env section
client/service.tsx useService/useHealth + the service section
client/presentation shared badges, tags and field frames
client/rpc.ts the remeEnv calls and their response guards
client/locales.ts the tab's copy
client/styles.ts the tab's CSS
The .env controls now come from one field table, and the stylesheet split
keeps the tab's CSS next to the tab.
State is keyed where the review asked for it: install progress carries the
job id it polls and cancels, workspace drafts and in-flight saves carry the
workspace they were typed for, and a check result only shows for the
interpreter it belongs to. Drafts also distinguish untouched fields from
explicit clears, so emptying a non-secret field now clears it on disk. The
memory settings draft parser no longer carries the environment fields
through, since saving only writes this page's FIELDS list.
* fix(dsh): probe from the Host and bound every process lifetime
Local now means the DSH Host everywhere. The tab no longer fetches the
service URL from the browser: the hero reads the same Host probe the
service card uses, and a remote endpoint is probed through a new
remeEnv/health method, so a browser on another machine cannot disagree
with the Host. The wire namespace, method parameter convention and
service keys are unchanged.
Process lifetimes are explicit and documented in the manager. Python
probes and reme-ai checks stay bounded one-shot commands. pip installs
live in the manager's registry, keep the interpreter locked between a
cancel request and the actual exit, and are stopped by dispose() when
the plugin unloads. The ReMe service stays detached on purpose: it must
outlive DSH, so it is not handed to DSH's subprocess provider, which
kills its children on Host exit; it is stopped only through the
ownership-checked adapter in service.ts.
That adapter now verifies identity before reporting or stopping a
service: the recorded endpoint must match, the pid must be alive, and
its image must still be Python or reme, which protects against pid
reuse. A launch is recorded only after the OS acknowledged the spawn,
and a spawn failure returns an error instead of an unhandled event.
Starts are serialized and re-check the phase inside the lock, so two
requests cannot spawn two services. Health answers are validated, so a
generic HTTP server answering 200 with '{}' is no longer reported as a
running ReMe service, and authToken now rides the Authorization header
of both the client requests and the Host probe.
.env merging rewrites every occurrence of a key (parsing keeps the last
one), keeps the file's line ending, and validates the merged file rather
than just the submitted values.
* docs(dsh): move environment setup into dedicated guides
The two READMEs keep a short introduction to the Environment tab and link
to docs/environment.md / docs/environment_ZH.md, which now carry the
setup and troubleshooting detail: Python and conda discovery plus the
recommendation rule, dependency installation, .env validation and
clearing, connection testing, the detached service lifetime, platform
support and the failure modes of each step.
The version lists include 0.2.2-alpha.2 and note that current DSH needs
Node 24.9 or newer. The package now ships docs/ as well, so the guide
travels with the published plugin.
* fix(dsh): resolve interpreter paths with their own platform semantics
The interpreter helpers mixed simulated-platform knowledge with the host's
node:path, so Windows fixtures only resolved on Windows: on macOS and
Linux condaRootFromPath, pathContains, pythonPrefix, classifyOrigin,
remeCliPath and the pip path check all fell back to POSIX semantics and
nine tests failed.
Paths now carry their flavor: pathOf() picks win32 or posix from the value
itself, and the functions that already know the simulated platform use it
explicitly. Behaviour on Windows is unchanged; the same fixtures now
resolve identically on every host, which the new tests assert for both
flavors.
* refactor(dsh): stage the settings card with DSH's form model
The memory settings card carried its own draft state machine: a Draft
object, a parser that re-validated every field, a hand-written diff into
path operations, and its own revision fence. DSH ships exactly that as
SettingsFormModel, exported by the primitives package this plugin already
depends on and injects since 0.1.7-rc.2.
The card now builds the model once, reads shell()/field() while rendering
and hands every edit to actions(), so what is left is the controls plus
one field-spec table in settings-specs.ts. The revision fence, the
dirty/invalid/saving/failed states, keeping drafts after a refused save,
and clearing only the fields the user layer carries all come from the
model.
The one visible change: reset now stages clears for the fields the user
layer actually overrides, which is what that control always meant.
Tests: settings-specs.test.mjs covers every spec on its own, and the card
test runs DSH's real SettingsFormModel (evaluated from the installed
primitives bundle, which cannot be imported in Node because it loads CSS
modules and icons). The packaged-plugin check exercises that against all
six supported DSH releases.
* test(dsh): pin the plugin lifetime that stops install jobs
dispose() on the manager stops running installs, but nothing tied that to
the plugin's own lifetime: a change to the registration could have left
pip running after the plugin unloads. Mount the plugin, replace the
provided manager's dispose with a counter, run the envLifetime cleanup and
assert it is called once.
* fix(dsh): harden environment management from review
- wire the package mirror into installs
- wait for service exit, escalate to SIGKILL, keep the record on failure
- fail closed on ownership and clear dead service records
- clear the start lock on failure and reject overlapping starts
- bound probes, make config writes atomic, scope auth tokens
- fix docs and add regression tests
* fix(dsh): verify service identity before touching a recorded pid
- require command-line evidence for owned service processes
- discard unprovable stale records instead of blocking startup
- identify and stop our own unhealthy conflict; serialize stop with start
- reject IPv6 loopback endpoints
- rotate oversized logs and fix tailing multibyte cuts
- add tests for env writes, client failures and real spawner
* fix(dsh): finish the environment review follow-ups
- match escaped wrapper command lines when proving service ownership
- reset aborted LLM probes and consume stopped/conflict start signals
- abort start polling on endpoint switch and guard stale service state
- force --force-reinstall for Reinstall; localize start/stop reasons
- validate rendered RPC fields, prune install logs and polish UI states
* fix(dsh): address the environment review on 603ea41
* fix(dsh): close the stale-service and probe follow-ups
* fix(dsh): let an unverifiable service record be forgotten
* fix(dsh): close the install, record and LLM probe follow-ups
- re-check reme-ai after a successful install, so the dependency card and
Start follow the install instead of waiting for a manual Check
- bind every install answer to the interpreter that asked for it and to a
request generation, and restore the running job of the selected
interpreter rather than the globally latest one
- let the Host name the record that blocked a start or a stop, and aim the
confirmed Forget at that record, pinned by its pid so a record that
changed meanwhile is refused instead of dropped
- probe the LLM with the protocol of the selected backend, including the
providers whose credentials ignore LLM_BASE_URL
- extract the manager's service queue and its common start-failure result
- supply the timer globals in the settings test harness so the React
cleanup runs cleanly
* fix(dsh): align the LLM probe and the record recovery with ReMe
- probe the providers whose credentials ignore LLM_BASE_URL with their own
endpoint, so a stale value in the .env cannot report a working
configuration as broken
- build the request URL the way the provider's own SDK builds it, so a base
that already carries the version suffix fails in the probe exactly as it
fails in the service
- withdraw the Forget offer when the record changed instead of re-aiming
it at a record the user never saw, and name the process in the
confirmation
- compare interpreter paths with one shared key on both sides, so a job the
Host restored is not dropped again by the tab
- never poll an installation without a job id
* fix(dsh): probe xAI on its own endpoint and wait for a saved backend
- give xAI its own protocol: its credential carries an api host instead of
a base URL, so the probe no longer demands LLM_BASE_URL for a
configuration ReMe accepts
- say that the xAI probe is a REST-level approximation of the gRPC SDK
ReMe uses for that provider
- hold the LLM test back while the chosen backend is not saved, because the
probe reads the .env on disk
* chore: ignore the local CodeGraph index
The index is machine-local and rebuildable, so it must not show up as an
untracked file in every checkout.
* fix(dsh): gate the LLM test on every unsaved probe setting
- compare the model, the base URL and a typed key against the saved .env,
so the test never runs against a configuration the user did not put on
disk
- resolve an empty backend to the default on both sides, so picking the
default in the form is not treated as a change
- broaden the probe guard against a rewritten base URL
* fix(dsh): hold the install lock until the exit and keep pending .env edits
Addresses the four P2 findings of the review on c499cc0e.
Install lifecycle (host/install.ts)
- One shared termination path serves cancel() and dispose(): a graceful
signal first, then a force-kill after a bounded grace. No timer settles a
job any more - only an observed exit does - so a termination that could
not be confirmed stays visible as running/cancelling and keeps the
interpreter locked instead of reporting a completed cancellation.
- dispose() escalates without a grace period, so a pip that ignored
SIGTERM cannot outlive the Host.
- start() reuses runningFor(), so the lock is one lookup.
.env form (client/workspace.tsx, env-fields.ts)
- A save clears only the edits it submitted; a value typed while the save
was in flight keeps its newer value, and the saved message says that
edits are still pending.
- An emptied secret draft no longer travels: "leave blank to keep" holds
even after a replacement was typed and cleared, so the stored credential
survives and the other changes are saved. An emptied non-secret is still
an explicit clear.
- The managed keys, their secret flags and their update rules now live in
one browser-safe module that the Host and the tab both derive from; the
Host applies the same rules, so an older client cannot clear a secret.
Simplification
- The settings card reads the form model through model.bind() and
useSyncExternalStore, and shell.saving replaces the separate busy state
and the manual publish() calls.
- The Host health probe goes through ReMeClient, keeping its three-second
timeout and its localized codes, and now requires a parsable health
report instead of accepting health: {}.
- One predicate (environment/dependency.ts) decides what an interpreter can
host, so the Start button and the Host's start gate agree; the loopback
endpoint rules are shared too.
Tests: 247 plugin tests pass, plus the six-version package matrix.
* fix(dsh): keep a cancelled install locked until its process group is empty
The observed exit of the pip leader did not prove that its managed process group had exited: a build child that ignored the graceful signal could outlive it while the job was already reported as cancelled and the interpreter lock was released.
- The install child now reports whether its process group still holds a process (process.kill(-pid, 0) on POSIX; Windows starts no group and keeps using taskkill /T).
- When a cancelled leader exits while the group is still populated, the group is force-killed and the job stays running/cancelling until the group is empty. Only then does it settle as cancelled, so a second installation cannot race a build child that is still running.
- The wait is bounded; a group that never empties keeps the job unconfirmed and locked instead of reporting a cancellation that did not happen.
- Regression tests cover a leader that exits before its child and a group that never empties.
* fix(dsh): scope the workspace .env state to its directory
Switching workspaces aborted an in-flight probe but kept completed state: a save message and a successful LLM test from workspace A stayed on screen while the card showed workspace B (and named B's .env path).
- WorkspaceSection now owns useWorkspace; the tab mounts it with the workspace directory as its React key, so a switch disposes the previous drafts, read, save message and probe result instead of invalidating each one.
- Removed the repeated directory markers and stale-answer checks (Draft.dir, EnvState.entriesFor, latestDir); the section state simply belongs to one directory.
- Kept the pending-save protection (a save clears only the edits it carried, through the draft mirror) and made unmount cleanup explicit: the probe is aborted and a save that settles after unmount writes no state.
- Regression coverage drives the real section across a switch after a completed save and a successful probe, and the tab tests cover the draft and in-flight probe cases.
* fix(dsh): only offer local startup for root-path endpoints
parseLocalEndpoint accepted http://127.0.0.1:2333/reme, but the launch command configures only service.host and service.port: the started service answers at the origin root, so the subsequent health check at /reme/health_check would 404 and the launch would end in a conflict or a startup timeout.
- Reject a loopback endpoint whose path is not the origin root.
- A prefixed gateway URL is therefore not a manageable local service; it falls back to the remote health probe at its own path, which keeps connection testing (regression covered in the tab tests).
- The settings validator still accepts such a URL, so an existing gateway configuration keeps being probed.
* refactor(dsh): derive the settings and .env field definitions
Two pairs of definitions described the same fields and were kept aligned by hand.
Settings fields
- SETTINGS_SPECS is now the one definition: an internal const array checked against SettingsFieldSpec with 'as const satisfies', with generic helpers that keep every field name a string literal.
- SettingField and SETTING_FIELDS are derived from it, so the exported field-name union stays closed without a second hand-written list or an alignment test; SettingsFormModel receives a mutable copy, and the format/parse behaviour is unchanged.
.env fields
- The 'empty draft' rule of every managed key is derived from its secret flag, so EnvEmptyRule and the per-row setting are gone. A blank secret still means 'leave blank to keep'; a blank non-secret is still an explicit clear.
- disabledValue, storedState, the unknown-key passthrough and the shared Host/Client update function are unchanged.
* docs(dsh): describe the process-group, workspace and root-path rules
- A cancellation keeps the interpreter locked until the whole managed process group exits, and an unload watches the group too.
- The draft, the save message and the LLM-test result belong to their workspace; switching disposes them.
- Local startup is only offered for a loopback endpoint at the origin root; a prefixed gateway URL is health-probed as a remote one.
* fix(dsh): keep a legacy prefixed service record identifiable
Restricting local startup to root-path endpoints made the ownership check reject records written by an older version: commandMatches() reused parseLocalEndpoint() only to read the port, so a prefixed endpoint threw and a live, plugin-started process was reported as foreign. Start refused to launch it and Stop refused to own it, turning the record into an orphan.
- commandMatches() now reads the recorded port with a lenient parser instead of the launch rule, so a prefixed legacy record stays owned. Stop can then signal the recorded pid and clear the record once it exited.
- Regression test: a prefixed legacy record is recognized as owned, Stop is accepted, and the record is dropped after the exit.
* fix(dsh): explain why a prefixed endpoint is not managed locally
The remote notice said only that the URL is not local, which reads like a misconfiguration for a gateway mounted under a path prefix on the same machine. It now states that only the connection is probed and that a path-prefixed gateway cannot be managed locally.
* docs(dsh): note the process-group signalling limits
Record why a group that never empties stays unconfirmed, and that the group-id liveness probe counts an unreaped zombie and can take one extra poll; a pathological pid reuse around the leader's exit is inherent to signalling a process group.
* fix(dsh): replace a same-origin leftover service instead of refusing the start
After local startup was restricted to root-path endpoints, a service recorded by an older version under a same-origin path prefix (e.g. http://127.0.0.1:2334/reme) could not be reached from the tab: the prefixed endpoint hides the service card, and a start from the root endpoint was refused with 'stop it from that endpoint first', which the UI cannot do.
- serviceOriginKey() canonicalizes protocol/host/port (folded loopback aliases and default ports) without the path, next to the existing full endpoint key.
- A start now stops a provably owned record whose endpoint shares the origin of the requested one and continues; the launch configures only host and port, so both endpoints name the same local process. A record for another origin is still refused as before, with ownership/pid/image/command evidence unchanged.
- Manager-level regression: a leftover /reme record is stopped, the new launch is spawned, and its pid replaces the old record.
* docs(dsh): tighten the prefixed-endpoint notice and the group-poll note
- The remote notice now says 'not a loopback URL at the origin root', which reads as a rule rather than a misconfiguration.
- The install poll note states that an unreaped zombie keeps the group non-empty until it is reaped, instead of implying a single extra poll.
* fix(dsh): only replace a same-origin service when the request can launch
The same-origin replacement was symmetric: a request for a prefixed endpoint (which buildStartCommand refuses anyway) stopped a live root-path service under the same origin first, then failed to start anything. With autoStart enabled and a prefixed endpoint configured, every DSH start would kill the healthy detached service.
- The replacement branch now requires the requested endpoint to be launchable (a root-path loopback endpoint), the same rule buildStartCommand applies; otherwise the start is refused with the previous other-endpoint-running result and the service is left running.
- Regression: a prefixed request against a live same-origin root record must not killTree, must not spawn, and must leave the record intact.
* refactor(dsh): drop the unused derived settings field list
SETTING_FIELDS had no consumer once the field list was derived from SETTING_SPEC_DEFS; keeping the array around left a second list that looked like it still needed syncing. The closed SettingField union stays derived from the one table, and SettingsFormModel still receives a mutable copy of SETTINGS_SPECS.
* fix(dsh): skip auto-start for an endpoint that cannot launch
With autoStart enabled and a path-prefixed endpoint configured, DSH startup asked for a start that buildStartCommand must refuse, logging a warning on every start. autoStart now checks the same launchability rule first and returns without probing or starting, so a remote or prefixed endpoint is left to connection probing.
- Regression: auto-start does not probe a prefixed endpoint and spawns nothing, while a root-path endpoint still auto-starts.
* fix(dsh): adopt a same-origin leftover service record instead of orphaning it
A record left by an older version under a path prefix of the same origin
(`/reme`) describes the service the endpoint on screen talks to: the launch
configures only host and port. The record was nevertheless judged foreign,
because the ownership check compares the full endpoint key while the
same-origin replacement compares the origin.
The Host now re-keys such a record to the endpoint on screen, so the tab can
stop it and a start can replace it. The conflict branch falls back to the
same guard when the record could not be re-keyed. The adoption compares and
writes the record without yielding, so a launch that records its own pid
while the ownership probe runs is never overwritten.
* docs(dsh): describe how a leftover same-origin record is adopted
* docs(dsh): Fix markdown autolink over-capture
* test(dsh): cover the conflict fallback when the leftover cannot be re-keyed
The re-keying of a same-origin leftover is a write to the state file. When
that write fails, the record keeps naming the old endpoint and the conflict
branch has to fall back to the same guard, or the port stays occupied by our
own service and the tab has no way out.
* docs(dsh): keep the example endpoint out of the GUI's link renderer
The Web GUI renders a code span whose content is exactly an http(s) URL as a
clickable link inside the code chip, so the leftover endpoint example became
a link. The example is now written without its scheme, which no renderer
linkifies, and the space added by 2fc90233 (outside the code span, so it never
had any effect) is dropped again.
The guarantee is also narrowed to what the code does: a leftover record is
re-keyed when it can be proven to be this plugin's service.
* test(dsh): keep the user docs free of linkified code spans
* docs(dsh): state what the leftover record actually gets
The docs case claimed the package does not ship the docs; it does (the
package manifest lists "docs" in "files", there is no .npmignore and the
directory is not git-ignored), so the check runs in the packed install and
the comment was the opposite of the fact.
The service lifetime also promised that Start replaces a leftover, but a
healthy one is only observed: Start reports it as already running and
replaces nothing. The wording now says so, and a case pins it.
* fix(dsh): write the default backend when the selection is cleared
The backend selection is the one managed key with a default. Clearing it
wrote an empty value, and an empty value is not the default: ReMe applies
"${LLM_BACKEND:-openai}" only when the variable is absent, so the service
started with no backend at all and refused to run - while the plugin's own
probe resolved the same empty value to openai and reported a working
configuration.
The cleared selection now writes the default out, and the probe reports an
explicitly empty backend as an incomplete configuration instead of testing a
configuration the service cannot use. A file without the key keeps the
default, and an unknown backend name stays probed tolerantly: the list of
backends here is a snapshot, and ReMe may know more.
* fix(dsh): keep the recovery for an unverified service record
A recorded process that holds the port but whose identity cannot be read
left the tab with no action at all: no Stop (the process is not ours to
signal), no Start (a conflict disables it) and no Forget (nothing had
refused yet, so no record was ever named).
The record now travels with the status, so the card can offer "Forget this
record", and a start names the same record as an unverified one. The process
is still never signalled: an unreadable identity is no proof. A conflict
caused by an unrelated process stays a plain conflict, with no record to
name.
* docs(dsh): describe the cleared backend and the unverified record
The service lifetime now says what a conflict with an unreadable recorded
process offers, and the environment section says what clearing the backend
selection writes and what the probe reports for an explicitly empty one.
* refactor(dsh): decide the recorded service in one place
The manager read the service record and decided its ownership in three
places, and the "launchable" wrapper only repeated the shared endpoint
predicate.
One inspection now answers it: the record, whether its process is alive, and
what can be proven about it. The start path reads that verdict and acts on
it, so the same-origin replacement, the unverified record and the plain port
conflict cannot drift apart. The private launchable() wrapper is gone - the
shared isLocalEndpoint() says the same thing.
* fix(dsh): keep the saved backends and the probe in step with ReMe
Two ways the plugin could write or read a backend the service cannot use:
The embedding backend was left out of the default rule, because this
repository's own configuration has its embedding components commented out.
That only holds for the version in this repository: ReMe 0.4.0.x - the
oldest the plugin supports - declares as_embedding with
"backend: ${EMBEDDING_BACKEND:-openai}" and instantiates it, so an
explicitly empty value names no backend and the service refuses to start,
exactly like the LLM backend did. EMBEDDING_BACKEND now writes its default
out as well.
A known backend written in the wrong case was folded to the default before
the probe ran, so the probe tested a configuration ReMe's case-sensitive
registry refuses ("Unregistered backend 'OpenAI'"). The probe now reports
the spelling to use and sends no request. A name the plugin has never heard
of is still probed tolerantly: its list is a snapshot, and ReMe may know
more than the plugin does.
* fix(dsh): read the protocol table by its own entries
The LLM protocol table is a plain object literal, so it inherits from
Object.prototype: `LLM_PROTOCOLS["constructor"]` and `["__proto__"]`
answered with the inherited members instead of `undefined`. A backend
named that way was therefore not treated as an unknown name: the probe
built a malformed request from `Object` and failed with a generic
"no result", while the upper-case spellings were reported as known
backends written in the wrong case, naming a spelling ReMe refuses too.
Both readers of the table now consult its own entries only, through one
helper, so "what the plugin knows" has a single answer: such a name is
probed tolerantly like any other unknown name, and a name that really is
a known backend in the wrong case is still refused with the spelling to
use.
* fix(dsh): finish environment lifecycle and readiness safeguards
* fix(dsh): close startup races and validate env updates
---------
Co-authored-by: jinli.yl <jinli.yl@alibaba-inc.com>
20 KiB
环境管理
Environment(环境管理) 标签页用于在本机完成 ReMe 的准备工作:找到运行 DSH 那台机器上的 Python、把
reme-ai[core] 装进该解释器、写入 workspace 的 .env、并启动或停止本地 ReMe 服务——这些原本需要在多个终端里完成。
入口:插件 → ReMe Bundle → reme-memory → 配置 → 环境管理。
该标签页只管理根路径上的回环地址(http://127.0.0.1:… 或 http://localhost:…)。其他服务地址——远程主机,或挂在
路径前缀下的网关——只显示该地址是否可用,并隐藏本地步骤。
页面上的所有结果都来自 DSH Host,而不是浏览器:Python 探测、文件读写、LLM 探测、服务健康检查都在 Host 上执行。因此即使 浏览器在另一台机器上,看到的也是 Host 的真实环境,顶部概览与服务卡片不会给出不一致的结论。
每一步做什么
| 分组 | 能力 |
|---|---|
| 本地 Python | 探测 PEP 514 注册表、py 启动器、PATH 与 conda(base 与命名环境),标注来源和 reme-ai 状态,选择结果写入 pythonPath |
| ReMe 依赖 | 针对所选解释器检查 reme-ai 版本、[core] 附加依赖与 reme CLI;可选用软件源安装或升级 reme-ai[core],显示实时日志并支持取消 |
| ReMe 参数 | 编辑 workspace 的 .env;密钥只存在该文件中,界面仅显示掩码。保存要求 EMBEDDING_API_KEY 非空(关闭向量检索时用 EMPTY)。提供 LLM 连通性测试 |
| 服务控制 | 启动/停止本地 ReMe 服务,显示 PID、版本与日志;启动时注入 UTF-8 与 NO_PROXY、设置 enable_logo=false,并在 workspace 内运行以保证 .env 能被发现 |
顶部的概览区用三个标签(服务、Python、ReMe)概括同一份状态,并显示服务地址、探测时间与两个刷新操作。
Python 探测
ReMe 需要 Python 3.11 或更新版本。标签页在 Host 上探测下列来源,只保留能通过验证片段(上报 sys.executable、
版本号与 base prefix 的 -c 探测)的解释器:
- Windows:PEP 514 注册表项(
HKLM/HKCU)、py启动器列表、PATH、conda env list。 - macOS / Linux:
PATH(which -a)、常见的/usr/bin、/usr/local、Homebrew(/opt/homebrew)、~/.pyenv/shims与~/.local/bin路径,以及conda env list。
WindowsApps 下的 Microsoft Store 占位符会被跳过,因为它们只是别名而不是解释器。装有 conda 时,命名环境会同时出现在
conda env list 与环境列表中,conda 根目录单独上报。
探测结果缓存 60 秒,点击概览区的重新探测会重新执行。推荐解释器按以下顺序选出:
- 已安装受支持
reme-ai的命名 conda 环境(排除base)。 - 其他已安装受支持
reme-ai的解释器。 - 任意命名 conda 环境(可直接安装 ReMe)。
- 第一个可用解释器。
把鼠标悬停在推荐标签上可以看命中的是哪条规则。选择其它解释器只会写入 pythonPath;保持未选择则一直跟随推荐。列表默认
显示 6 行并可展开,支持按版本、来源、路径筛选。
ReMe 依赖
检查会向所选解释器询问三件事,并以指标形式展示:
reme-ai元数据版本(importlib.metadata.version("reme-ai")),以及是否达到本集成要求的最低版本。[core]附加依赖:import agentscope是否可用。受支持的 ReMe 版本在加载 CLI 时就会导入 AgentScope,因此缺失时 无法启动服务;请安装或重装reme-ai[core]。remeCLI:解释器旁的命令行入口,或启动时回退使用的 Python 包装。
安装 reme-ai[core] 执行 python -m pip install reme-ai[core],可附加软件源(PyPI、清华、阿里云)。升级追加
-U;重装追加 --force-reinstall,否则 pip 会把“存在但已损坏”的安装报成 “already satisfied”。首次使用需要下载较大的
依赖,视网络情况通常 5–20 分钟。
安装是 Host 侧的任务:
- 关闭配置页后仍在运行;重新打开标签页会为同一个解释器恢复进度。Host 按解释器查找正在运行的任务,所以两个解释器同时安装时, 各自看到的是自己的进度。
- 进度按任务 ID 轮询,为另一个解释器发起的安装不会顶替当前显示;安装的响应也绑定在发起它的解释器上,切换解释器后迟到的响应会被丢弃。
- 安装成功后会自动重新检测
reme-ai(同一个解释器),依赖卡片与启动服务按钮随之更新,无需手动点“检测”。 - 取消会同时终止 pip 及其构建子进程,且在整个受管进程组真正退出前该解释器保持占用:pip 先退出而构建子进程 仍在时,会对进程组强制结束并等待组清空。若连这一步也无法确认,任务仍保持“正在取消”状态、该解释器依然被占用—— 在第一个安装还没有交代清楚之前,不允许第二个安装开始。页面会继续显示该任务,而不是把它报告成一次已完成的取消。
- 日志写入
$DSH_HOME/reme-memory/install-<job>.log,页面直接显示尾部。每次安装都会新建文件,目录只保留最近 20 个;长期运行的服务日志超过 5 MB 后轮转为service.log.1。 - 插件卸载时,仍在运行的安装走同一条终止路径:先发优雅信号,再强制结束,并对受管进程组持续确认,因此忽略
SIGTERM的 pip 或比 pip 活得更久的构建子进程都不会活得比 Host 更久。
Workspace .env
ReMe 在服务启动时读取 workspace 目录下的 .env;标签页从不把密钥写进 DSH 设置。
| 分组 | 键 |
|---|---|
| LLM | LLM_BACKEND、LLM_MODEL_NAME、LLM_API_KEY、LLM_BASE_URL |
| Embedding | EMBEDDING_BACKEND、EMBEDDING_MODEL_NAME、EMBEDDING_API_KEY、EMBEDDING_BASE_URL |
- workspace 目录默认
~/.reme,必须是绝对路径;修改后会重新读取它指向的.env。 - API Key 是只写的:Host 只返回掩码(末四位),留空表示保留已存的值。没有编辑过的键不会被重写。
- 清空密钥字段并保存会保留已存的密钥——即便先输入过替代值再清空也是如此:凭据无法通过清空输入框来删除, 因此留空始终表示“保留已存的值”。清空非密钥字段并保存即表示删除该值。只有编辑过的字段会被写入, 文件其余部分的注释、未知键与顺序保持不变。
- 两个后端选择是带默认值的非密钥字段:清空后会写入默认值(
LLM_BACKEND=openai、EMBEDDING_BACKEND=openai), 而不是空值。ReMe 只在变量不存在时才应用${LLM_BACKEND:-openai}与${EMBEDDING_BACKEND:-openai}, 空值等于没有指定任何后端,服务将无法启动。 - 保存只清除本次提交的那部分编辑,更晚的编辑会被保留:保存进行中再改动其它字段时,那份文本不会丢失,页面也会 提示仍有未保存的改动。
- 保存时会校验合并后的整份文件,而不只是本次输入:ReMe 0.4.0.x 会无条件实例化 embedding 组件,因此即使不使用向量检索
EMBEDDING_API_KEY也必须非空(EMPTY是文档化的占位值)。重复出现的键会在每一处被改写,文件原有的换行风格也会保留。 - 写入是原子且仅属主可读写的(POSIX 上为 0600);旧文件会保留为
.env.bak,因此一次失败的保存不会丢掉其它键。 - 测试 LLM 连接在 workspace 内、用所选解释器发送一次只需 1 个 token 的请求,并对
401/403(密钥)、404(模型名或 Base URL)与网络错误给出提示。请求按.env里的LLM_BACKEND选择协议:openai、dashscope、deepseek、moonshot走 OpenAI 兼容的/chat/completions(Bearer 认证),anthropic走/v1/messages(x-api-key),gemini走/v1beta/models/<model>:generateContent(x-goog-api-key),ollama走/api/chat(本地服务无需密钥),xai走api.x.ai上 OpenAI 兼容的/chat/completions。 - Base URL 的来源与 ReMe 自身的凭据保持一致:
LLM_BASE_URL只对 OpenAI 兼容族与 Anthropic 生效,Gemini、Ollama 与 xAI 自带地址、并不读取该变量。因此.env里残留的旧值不会把探测引到服务根本不会访问的主机,ReMe 能接受的 配置也不会被报成故障。Base URL 的拼接方式与服务商 SDK 完全一致,因此已经带版本后缀的地址在探测与服务中都会 同样失败。 - ReMe 通过 gRPC SDK 连接 xAI,因此 xAI 的探测只是该通道在 REST 层面的近似。
- 探测读取的是磁盘上的
.env,所以只在表单里改过配置而未保存时不会发起测试;等待期间按钮会给出提示。 - 若
.env把LLM_BACKEND设为空值,探测会报告配置不完整(LLM config incomplete (LLM_BACKEND))并且不发送 任何请求:此时 ReMe 启动时并没有任何后端,探测不能去测试服务根本无法使用的配置。若.env里没有这个键, 探测会与 ReMe 一样使用默认后端。 - 已知后端名写错了大小写(如
LLM_BACKEND=OpenAI)会被报告为无效,并给出正确写法:ReMe 的后端注册表区分大小写, 会拒绝这个名字。而插件从未听说过的后端名仍被宽容地探测——这里的列表只是一份快照,ReMe 可能认识得更多。这条规则与名字 长什么样无关:只有插件确实认识的后端才会被判定为大小写写错。 - 草稿、保存提示与 LLM 测试结果都属于产生它们的 workspace:切换 workspace 会随旧区块一并丢弃,因此为某个 workspace 输入的密钥、或属于它的一次成功提示,都不会被带到另一个。
连接测试
概览区的测试连接让 Host 对配置的服务地址执行 POST /health_check。健康响应必须包含可解析的 ReMe 健康报告——版本、
健康标记与各组件明细——所以只回 200 与 {} 的普通 HTTP 服务不会被当成运行中的 ReMe。Host 复用插件其余部分使用的
同一个 ReMe 客户端,因此请求、鉴权与三秒超时都与服务本身被调用时一致。设置里填了 authToken 时,Host 会以
Authorization: Bearer 发送,且只作用于该服务地址。
服务生命周期
在这里启动服务等价于在终端执行 reme start,但有一点是刻意的差异:服务会比 DSH 活得更久。关闭 DSH 不会停止它,停止
它是在标签页里的一次显式操作。
因此本插件没有把服务交给 DSH 的本地子进程提供方——后者会在 Host 退出时终止它托管的进程。插件自带一个小型服务适配器:
- 启动在操作系统确认 spawn 之后才记录到
$DSH_HOME/reme-memory/service.json(pid、地址、workspace、命令行、启动时间), 所以解释器缺失时不会留下残留状态。 - 只有记录与当前地址一致、pid 仍存活、进程映像仍是 Python 或
reme,且命令行仍包含记录的workspace_dir与service.port时,服务才被判定为“由本插件托管”并给出停止按钮。命令行能排除大多数 pid 复用(更长的 workspace 路径、另一个端口都不会命中),但无法区分“用户照抄同一命令行手工启动”的同一服务。2333 端口上的记录绝不会 声称管理 2444 端口上的服务。 - 证据读不到时(
tasklist/ps输出本地化、权限不足等)归属保持“未证明”:启动与停止都不会碰进程、也不会丢弃记录—— 停止会拒绝,启动会返回错误。丢弃记录会让一个仍在运行的进程变成标签页再也停不掉的孤儿;此时卡片会给出忘记这条记录, 它只删除service.json、绝不向进程发信号,由用户自行确认后续处理。Host 会在结果里指明挡住操作的是哪一条记录, 忘记针对的正是那条记录(可能是另一个端口上的记录,而不是当前显示的地址),并带上它的 pid:记录在此期间被换掉时, Host 会拒绝而不是静默丢弃新记录。 - 服务占用端口但健康检查失败时显示为“端口被占用”;若能证明是本插件启动的,标签页仍给出停止按钮。
- 占用端口的是已记录但身份无法验证的进程时情况不同:该进程绝不会被发信号,因此标签页改为给出忘记这条记录。 这条记录随状态一起返回,所以出路不依赖被“端口被占用”状态禁用的启动按钮。
- 旧版本遗留在同一源(origin)某个路径前缀下(例如
127.0.0.1:2333/reme)的记录,描述的是同一个本地服务—— 启动只配置 host 与端口。只要能证明它是本插件启动的,这种记录就会被重新登记到当前显示的地址,随后与其他启动 一样被管理:给出停止按钮,启动在它尚未健康时替换它。它不会再被当成标签页无从处理的外部进程,否则用户 只能自己去杀进程。 - 停止会树杀记录的进程(POSIX 上按进程组、Windows 上为
taskkill /T /F),等待其退出,必要时升级(POSIX:SIGTERM后SIGKILL;Windows:再次强制taskkill),并在 pid 及 POSIX 进程组真正消失之后才清除记录。 父进程先退出时,仍会强制结束存活的子进程。无法确认进程组已清空就保留记录;后续无法验证身份的进程组不会再次被发信号。 别处启动的服务不受影响,只会被观察。 - 记录中的进程仍存活但从未就绪时,显示为上次启动未就绪,并同时给出停止与启动:停止负责清记录,启动则让 Host 停掉可证明归属的旧启动、或丢弃已证明属于外部的记录。只有本标签页发起的启动仍在进行时才会显示“启动中”。
- 启动是串行化的:两个请求不会拉起两个服务,后到的请求会观察已在进行的启动。替换“一直没有就绪”的旧记录时,只有 归属被证明才会杀掉它;证明不了就保留记录并报错,不会静默丢弃。停止旧服务前会先检查所选解释器的启动依赖。 在操作系统确认启动之前,状态查询不会清除启动标记。探测或启动过程中出现更新的服务记录时,会保留新记录, 并在报告失败前停止尚未登记的新子进程;读取记录失败会中止操作,不会按“没有记录”继续启动。
- 自动启动(
autoStart,默认关闭)会在 DSH 启动时把尚未运行的服务拉起;被拒绝的启动会记入 DSH Host 日志。
Python 探测与 pip 安装都是有界的 Host 操作;服务是唯一需要比 DSH 活得更久的进程。
平台支持
| 方面 | 说明 |
|---|---|
| DSH | 0.1.7-rc.2、0.2.0-rc.2、0.2.1-alpha.2、0.2.1-alpha.4、0.2.1-rc.2、0.2.2-alpha.2 |
| Node.js | ^22.19.0 或 >=24.0.0;当前 DSH 需要 Node 24.9 以上,兼容矩阵以 Node 24.16 验证 |
| Windows | 在 Windows 11 + Miniconda 上实测:注册表/PATH/conda 探测、tasklist/taskkill 身份校验与停止、PYTHONUTF8/PYTHONIOENCODING 保证 pip 输出不乱码 |
| macOS/Linux | 探测、分离启动、身份查询与停止均有运行真实子进程的单元测试覆盖;真机验证程度仍低于 Windows |
常见问题
未检测到可用的 Python。 安装 Miniconda 或任意 Python 3.11+,再点重新探测。Store 占位符会被过滤,请安装真实的发行版 而不是 Store 别名。
所选解释器不在列表里。 标签页会用“不在探测结果中”标注它,但仍然使用它。重新探测,或改选探测到的解释器。
保存 .env 时读取失败。 只有文件不存在才按首次保存处理;权限或 I/O 错误会中止保存,不会替换原文件或备份。变量名须以字母或下划线开头,其余只接受字母、数字和下划线;值必须是单行字符串;无效更新不会改动原文件或备份。
安装失败。 先看日志尾部:缺少 wheel、代理配置过期或网络受限通常都能看出来,可以换一个软件源。conda 环境里 pip 也可
用,但独立环境更能避免与其它项目的依赖冲突。
保存 .env 被拒绝。 保存后的文件中 LLM_API_KEY 与 EMBEDDING_API_KEY 都必须非空;关闭向量检索时 embedding 用
EMPTY。清空密钥字段不会写入文件,已存的密钥会被保留;而一个根本没有存过的必需键仍会让保存失败,文件保持原样。
服务显示“端口被占用”。 该端口被其它程序占用。请在服务地址(记忆设置)中换一个端口,或停止占用它的程序。
服务迟迟未就绪。 启动会轮询 120 秒;如果端口有响应但 /health_check 一直不通过,卡片会切到“端口被占用”状态,停止按钮
始终可用。用查看日志(workspace 下的 service.log)看启动过程——缺少 reme-ai、.env 不合法、端口冲突都会体现在那里。
服务显示“上次启动未就绪”。 本插件记录的进程仍存活,但一直没有通过 /health_check(例如启动途中 DSH 被关闭)。点停止
清掉它后重新启动。若 pid 已被其它程序复用,这条记录可证明属于外部:点启动会丢弃记录并拉起新服务。若完全无法验证身份,
点忘记这条记录——它只删除本插件的记录,不会碰进程。
服务显示为外部启动。 它不是由本插件启动的,因此只被观察而不被管理。若希望在标签页里管理,先在它自己的终端里停止,再从 这里启动。
停止按钮不可用。 运行中的服务不属于当前服务地址,或记录已丢失。从标签页重新启动一次即可纳入管理。
LLM 测试失败。 结果会区分 401/403(密钥)、404(模型名或 Base URL)与网络错误。探测读取的是 workspace 的
.env,所以请先保存再测试;探测协议也取自其中的 LLM_BACKEND:原生后端(Anthropic、Gemini、Ollama)用自己的协议
探测,不会被当成 OpenAI 兼容接口。
代码位置
integrations/dsh/src/environment/
├── types.ts 浏览器安全的共享 RPC 类型
├── env-fields.ts 受管的 `.env` 键及其更新规则
├── dependency.ts 一个解释器能承载什么
├── endpoint-rules.ts 哪些服务地址可以作为本地服务管理
├── host/ 探测、安装、服务适配器、manager、gateway
└── client/ 标签页:每个步骤一个模块,以及文案与样式
只有 Host 模块会接触进程与文件;客户端只负责渲染 Host 返回的结果。