dsh-bili-scroll
c1overzz
DSH 插件:每天替你刷一轮 B站,读字幕挑出值得的、写一份日报,值得的 @ 你
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:McKayGONG/dsh-safe-restart
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
A macOS-only DSH host plugin that safely restarts the DSH process from inside
an Agent session. It terminates only the exact DSH listener process through a
detached helper, lets the browser reconnect through DSH's native
ConnectionController (no manual refresh), resumes the original persisted
session, and starts exactly one automatic continuation turn to verify the
restart and continue the interrupted task.
The plugin registers a single Agent tool, restart_dsh. There is no Web
button and no settings UI.
restart_dsh — schedules a safe restart of the current
DSH host, bound to the invoking Agent's current session.0.1.0-rc.8 — the recovery coordinator relies on host
internals that are still moving in the rc cycle (agent/created,
ctx.agents.resume setup, installModelSelection). End-to-end restart +
auto-continuation was verified on 0.1.0-rc.8 (standalone profile, macOS).
The declared range is >=0.1.0-rc.8 <0.2.0; anything outside it is untested
and may need adapter work.
After any DSH upgrade, re-verify: pnpm test, then one real
restart_dsh round — confirm PID change, HTTP 200, journal consumed, and a
continuation turn whose turn/end reason is completed (not error).restart_dsh({
"continue_after_restart": true, // boolean, default true
"continuation": "optional instruction" // string, optional, max 2000 chars
})
| Field | Type | Default | Meaning |
|---|---|---|---|
continue_after_restart |
boolean | true |
Whether to deliver one automatic continuation turn after recovery. Set false for a pure restart with no continuation. |
continuation |
string (optional) | — | Task-specific instruction for the single continuation turn (max 2000 chars). When omitted, the default instruction is: "Verify that DSH recovered successfully, then continue the pre-restart task using the current session and durable workspace state." |
The target session is always the invoking Agent's current session; a caller cannot name another session. The tool returns:
{ "restartId": "<uuid>", "scheduled": true, "continueAfterRestart": true }
Install from the plugin repository root:
dsh plugin --profile standalone add /path/to/dsh-safe-restart
The plugin activates on the next DSH start — restart_dsh is not loaded
until then. Use an already-validated external restart path (e.g. a codex /
safe-restart script that stops and relaunches DSH and verifies HTTP 200) for
that one activation restart, then verify http://127.0.0.1:<port> returns
HTTP 200 before continuing.
Ask the Agent to call restart_dsh. With the default
continue_after_restart: true, what the user sees is:
ConnectionController — no manual refresh.[restartId: <uuid>], verifying recovery and continuing the task.A restart with "continue_after_restart": false performs the same safe
restart and browser recovery but adds no continuation turn.
killall — the helper terminates only the recorded PID, and only
after verifying its exact command line against the launch identity recorded
at schedule time (the current Node executable plus the DSH entry argument).
An unrelated or unknown process is never touched.restart_dsh while a record is in flight
is rejected (restart already active).restart in cooldown).restartId is executed at most once; a record that
is not scheduled is refused, and a failed restart is never retried.consumed transition is detected
and consumed without re-delivering. An ambiguous window becomes
delivery-uncertain instead of a blind retry.All durable state lives under ~/.dsh/storages/dsh-safe-restart/:
| Path | Purpose |
|---|---|
active.json |
The single in-flight restart record (atomic writes: temp file → fsync → rename). |
.lock |
Exclusive restart lock, created with open(..., 'wx'); one active restart at a time. |
history/<restartId>.json |
Terminal records, archived when a record reaches a terminal phase. |
restart.log |
Timestamped, non-secret lifecycle lines: restartId, old/new PID, port-release result, HTTP result, terminal phase. |
| Phase | Meaning |
|---|---|
scheduled |
The tool request was persisted; the detached helper has not claimed it yet. |
restarting |
The helper validated and terminated the old PID, spawned the replacement, and is waiting for health. |
ready |
The new host answered HTTP 200; newPid and readyAt are set. Waiting for the resumed session's Agent. |
delivering |
The continuation message was created and handed to the Agent; awaiting durable confirmation. |
consumed |
Terminal: exactly one continuation delivered (or, for continueAfterRestart=false, none) and archived. |
failed |
Terminal: the restart failed with a bounded, non-secret error message; never retried. |
delivery-uncertain |
Terminal: the continuation window was ambiguous (e.g. the host died between delivering and confirmation). Not blindly redelivered. |
failed record — check restart.log and the record's error field
(e.g. PID validation failure, port not released, health timeout). The record
is already archived; no action is required for future restarts.
delivery-uncertain record — the continuation may or may not have been
delivered. Check the session's durable log for the marker
[restartId: <uuid>]:
Stale lockless scheduled record — if the helper crashed before it
could claim the record (or the claim failed), a scheduled record with no
helper running and no lock can be left behind. Recovery polls it for a
bounded window and then deliberately leaves it for inspection. It blocks new
restarts (restart already active).
Ready but no Agent (blocks subsequent restarts) — if a record reaches
ready but the matching session's Agent never reappears (for example the
session was deleted or the browser tab was never reopened), active.json
stays in ready and every later restart_dsh is rejected until the
record is resolved.
Remedy (manual, after inspection):
~/.dsh/storages/dsh-safe-restart/active.json — note its
restartId and phase — and the latest lines of
~/.dsh/storages/dsh-safe-restart/restart.log to see what happened.[restartId: <restartId>] already exists in
the session's durable log, the continuation was delivered; archive the
record as consumed: move active.json to
history/<restartId>.json with "phase": "consumed" and remove
active.json."failed" or
"delivery-uncertain"), then remove active.json.~/.dsh/storages/dsh-safe-restart/.lock — it records the owning
restartId. Remove the lock only when its restartId matches the
archived record; never delete a lock owned by a different restart.history/<restartId>.json and restart.log in place — they are
the audit trail. The next restart_dsh is then allowed again.scripts/verify-real-restart.mjs is an external, read-only evidence collector
that runs outside the DSH process (plain Node ESM, zero dependencies). It
never performs a restart and never touches the live listener. It reads the
journal and probes the HTTP endpoint, then reports one JSON object:
{
"oldPid": 111, // replaced DSH PID, from the selected record
"newPid": 222, // healthy replacement PID (null when unknown)
"pidChanged": true, // newPid is set and differs from oldPid
"http200": true, // live GET http://127.0.0.1:<port>/ returned 200
"phase": "consumed", // lifecycle phase of the selected record
"continuationCount": 1 // consumed records that delivered a continuation
}
node scripts/verify-real-restart.mjs --check-latest # latest history record, default port 3081
node scripts/verify-real-restart.mjs --journal /path/to/journal --port 3000
node scripts/verify-real-restart.mjs --journal /tmp/fixture --port 0 --dry-run # detection only, no HTTP
--dry-run prints the detection logic (listener PID via lsof -ti tcp:<port>
and a journal contents summary) without probing HTTP, so it can be exercised
without a live restart. It exits nonzero on malformed journal JSON, an
unusable listener detection, or unexpected errors. continuationCount counts
consumed records whose continueAfterRestart is true — per the design each
such record delivered exactly one continuation turn; pure-restart records
(false) delivered none and are not counted.
Remove the plugin with the remove counterpart of the install command, e.g.:
dsh plugin --profile standalone remove dsh-safe-restart
then restart DSH once so the tool is dropped. If you also want to remove the
durable state, delete ~/.dsh/storages/dsh-safe-restart/ after confirming no
restart is in flight (no active.json).
If the browser tab was closed during the restart, simply reopen it: DSH's native reconnect restores the same persisted session (same preset, model, and history). The continuation is delivered exactly once regardless of how many times the tab reconnects.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: 无有效分类标签。