@khorsheed/dsh-ankh-guard 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.en.md +9 -4
- package/README.i18n.yaml +2 -2
- package/README.md +9 -4
- package/lib/cli.js +1 -1
- package/lib/client.js +104 -17
- package/lib/index.js +94 -12
- package/lib/preflight-runner.js +13 -2
- package/lib/{restart-context-DUyExi9O.js → restart-context-DlaDZWKq.js} +11 -6
- package/lib/types/browser-handoff.d.ts +6 -0
- package/lib/types/browser-handoff.js +39 -0
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/index.js +108 -24
- package/lib/types/index.d.ts +34 -8
- package/lib/types/index.js +70 -15
- package/lib/types/preflight-runner.d.ts +1 -1
- package/lib/types/preflight-runner.js +34 -7
- package/lib/types/restart-context.js +11 -6
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +14 -20
- package/lib/processes-BjZgJjQr.js +0 -344
- package/lib/restart-context-D6nISh28.js +0 -1245
- package/lib/state-4f7yny39.js +0 -286
- package/lib/test-seam-DnvLWTeO.js +0 -119
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# 变更记录
|
|
2
2
|
|
|
3
|
+
## 0.3.1(2026-09-26)
|
|
4
|
+
|
|
5
|
+
适配宿主 rc.1 线并实证 0.1.5/0.1.7 双线可用(0.1.5-rc.1 全量 boot 实证,2026-09-25;0.1.7-rc.1 为 3080 生产验证线)。
|
|
6
|
+
|
|
7
|
+
- **修复 0.1.5 上 boot 即死**:preset 派生对宿主 preset-registry 包的导入从顶层静态导入改为运行期双名探测(0.1.7-rc.1 把官方包从 `dsh-agent-presets` 改名为 `dsh-agent-preset-registry`,0.1.5 宿主只装旧名,静态导入在模块解析期就炸穿整个 loader 树);两个名字都装不上时按既定「无 preset 回落部署默认预设」降级,不再抛错
|
|
8
|
+
- rc.1 适配波:中断续跑消息的 source 改为 V4 生产者归属 kind(退役的 `plugin` 外壳在 rc.1 持久层写入即抛);preflight 执行器按宿主代际探测组合解析面(三代际→四代际);`agent/created` 监听在 0.1.6 串行模式下保持 fire-and-forget
|
|
9
|
+
- 插件清单展示元数据(`locale/*.json`):rc.1 宿主插件页的卡面标题/描述中文化
|
|
10
|
+
- 修复 boot 代际刷新过早:代际通道此前只凭「boot id 变了」就回 `ready/reload`,而 Web-server 座位与兄弟行共用——端口刚监听时 `/api` 路由 owner 可能还没挂上,被刷新的页面于是向半挂载的宿主发出第一次、也是唯一一次会话列表拉取,左侧列表只剩重启时被召回的那个会话(重新手动刷新才恢复)。现在代际回答先等新进程的 Loader 树结算(与 web-app 放行浏览器用的是同一信号);就绪前的 poll 回 `waiting` 且**不下发 boot id**,标签页保持陈旧 id 持续重询,就绪即刷;无 Loader 的裸组合仍视为就绪。宿主侧新增「就绪前不回 reload、就绪后仍一次性刷新」单测,客户端侧新增「held 响应不消费代际判定」单测
|
|
11
|
+
|
|
12
|
+
## 0.3.0(2026-09-11)
|
|
13
|
+
|
|
14
|
+
适配宿主 0.1.5 线。
|
|
15
|
+
|
|
16
|
+
- **BREAKING**:minHost 前移至 `0.1.5-rc.1`;宿主 `0.1.2-rc.1` ~ `0.1.4.x` 的用户请停留在 0.2.x 线(末版 `0.2.0`)
|
|
17
|
+
- 冷读(用户输入停靠探测与 resume preset 推导)改走 0.1.5 的 handle 制 `sessionPersistence`(`open(id, 'read')` → `read` → `close`,与其他宿主面一样按调用探测);0.1.5 已移除的一次性 `inspect` 会让重启 resume 静默降级
|
|
18
|
+
- 生命周期漂移 lane 的通过计数改为环境感知:缺少部署 profile / 工具链缓存时合理跳过的绊线测试不再被硬编码期望数误伤(修 CI 红)
|
|
19
|
+
- 开发基线随仓内 pin 对齐官方 `0.1.5-rc.1` / cordis `4.0.2`(单实例 cordis 终结 4.0.1/4.0.2 图分裂);peer 范围保持宽松
|
|
20
|
+
|
|
3
21
|
## 0.2.0(2026-09-10)
|
|
4
22
|
|
|
5
23
|
- **BREAKING**:minHost 前移至 `0.1.2-rc.1`;宿主 `0.1.0-rc.6` ~ `0.1.1-rc.2` 的用户请停留在 0.1.x 线(末版 `0.1.1`)
|
package/README.en.md
CHANGED
|
@@ -184,7 +184,7 @@ dsh-ankh-guard restart \
|
|
|
184
184
|
|
|
185
185
|
Mounted as a cordis plugin (base bundle), the same surface is available as the `selfRestartGuard` service for in-app gates. Config: `maxAgeMinutes` (default 10), `stateDir`, `repoDir`, `reportRestartContext` (default `followup`), `fallbackGraceMs` (default 300000).
|
|
186
186
|
|
|
187
|
-
Beyond the verify/record/canary gates, the service exposes `requestRestart({ start, profile, initiator })` — the in-process restart trigger for UI-grade callers (e.g. the mode switcher): `initiator` is required (the requesting session's real id) and the port comes from the launch record. With no live watchdog it drives `restart`; supervised instances drive the `reconfigure` transactional cutover (the only safe way to change the launch command under a watchdog). The credential/preflight/marker/lock gate chain is the CLI's own, refusals return a structured `{ accepted, stage, reason }` and never stop the instance. On the browser side, beside the cutover receipt channel there is a boot-generation channel: after an ordinary restart or a crash respawn, open tabs notice the process's boot id changed over the handoff long-poll and reload once to pick up the new bundle;
|
|
187
|
+
Beyond the verify/record/canary gates, the service exposes `requestRestart({ start, profile, initiator })` — the in-process restart trigger for UI-grade callers (e.g. the mode switcher): `initiator` is required (the requesting session's real id) and the port comes from the launch record. With no live watchdog it drives `restart`; supervised instances drive the `reconfigure` transactional cutover (the only safe way to change the launch command under a watchdog). The credential/preflight/marker/lock gate chain is the CLI's own, refusals return a structured `{ accepted, stage, reason }` and never stop the instance. On the browser side, beside the cutover receipt channel there is a boot-generation channel: after an ordinary restart or a crash respawn, open tabs notice the process's boot id changed over the handoff long-poll and reload once to pick up the new bundle — before reloading it waits for the successor's composition to settle (the Web-server seat is shared, so `/api`'s route owner can still be mounting while the port already answers; until the Loader settles the poll is answered `waiting` with no boot id, the tab keeps asking with its stale id and reloads the moment the tree is up); visible sustained failures (~5 s) show a non-blocking connection banner with Retry; only confirmed cutovers use the restart overlay. Background/offline time does not count as failure. Returning to the foreground or online immediately resets backoff and restarts polling; stalled requests time out after 35 s and stale responses cannot trigger a reload.
|
|
188
188
|
|
|
189
189
|
## Model Experience
|
|
190
190
|
|
|
@@ -196,11 +196,12 @@ None.
|
|
|
196
196
|
|
|
197
197
|
## Compatibility
|
|
198
198
|
|
|
199
|
-
- npm release line (`@deepseek-ai/dsh@0.1.
|
|
199
|
+
- npm release line (`@deepseek-ai/dsh@0.1.5-rc.1`): supported — 0.1.5-rc.1 full-line boot-verified (42 packages including capture, 2026-09-25) — with two designed degrades. The composition-preflight gate runs through the standalone `preflight-runner` (composing through the published `@deepseek-ai/dsh-app-boot` primitives with a drift tripwire, since 0.1.5-rc.1 still does not export `composeProfile`) wherever a dsh app layout resolves — `--harness-root`, the durable launch spec, `DSH_HARNESS`, or the default checkout. On a pure npm deployment with no harness checkout the gate reports a notice and proceeds instead. The original-tab bridge feature-probes the optional WebServer/connection authentication seams; hosts without token auth naturally take the existing-cookie path. Cold reads (the parked probe and the preset derivation) ride the 0.1.5 handle-based sessionPersistence (`open(id, 'read')` → `read` → `close`; the one-shot `inspect` is gone). Every other capability is intact on the npm line. minHost stays 0.1.5-rc.1 — older hosts stay on the previous release line.
|
|
200
200
|
- Historical verification: a live npm-host 0.1.1-rc.2 → 0.1.2-alpha.4 isolated cutover passed (transition preflight removed a v3 whole-unit projection cache with an old-schema record from a home copy, live apply quarantined the old file, and target completed Token URL → 303 → cookie 200, the ownership stability window, and canary at zero retries; the old file remained byte-exact in the cutover directory. An untransitioned control over the same home failed on the missing Alpha.4 record fields, demonstrating that acceptance covered the real schema break).
|
|
201
|
-
- source line (deepseek-harness master, fork or upstream): ✅ (verifiedHost: 0.1.
|
|
201
|
+
- source line (deepseek-harness master, fork or upstream): ✅ (verifiedHost: 0.1.7-rc.1) — the gate runs through the standalone `preflight-runner` (resolves the published `@deepseek-ai/dsh-app-boot` etc. from the live checkout), so no fork patch is required.
|
|
202
|
+
- Dual-line evidence: the 0.1.5 boot passes end-to-end through three compat layers — the [preset-registry dual-name probe](../../.agents/notes/implemented/bug-fix/2026-09-25-preset-registry-dual-name-probe.md), [dual-shape typert codecs](../../.agents/notes/implemented/bug-fix/2026-09-25-typert-codec-dual-shape.md), and [typert faces carrying zod@4](../../.agents/notes/implemented/bug-fix/2026-09-25-typert-faces-carry-zod-v4.md).
|
|
202
203
|
|
|
203
|
-
**Version line mapping**: 0.2.0
|
|
204
|
+
**Version line mapping**: the first release after 0.2.0 supports host `0.1.5-rc.1` and later; hosts on `0.1.2-rc.1` stay on `0.2.0`, hosts on `0.1.0-rc.6` ~ `0.1.1-rc.2` stay on the 0.1.x release line (last release `0.1.1`).
|
|
204
205
|
|
|
205
206
|
## Known Limitations and Deferred Work
|
|
206
207
|
|
|
@@ -214,6 +215,10 @@ None.
|
|
|
214
215
|
- **`restart`/`supervise` discover the listener via `lsof`** (macOS/Linux with lsof); the guard prefers absolute system paths, while other platforms need `--pid`.
|
|
215
216
|
- **Kills are per-pid identity with a descendant sweep, never per process group** — the instance is not setsid'd, so `restart`, `schedule-exit`'s exit agent, and watchdog cleanup target recorded child/listener identities. Cutover forced paths `SIGSTOP` first, then revalidate a Linux boot/start-tick token or macOS `proc_pidinfo` microsecond start time; a mismatch is only resumed and refused. Descendants are likewise frozen and their parentage rechecked while walking `pgrep -P`. Ordinary non-cutover port recovery retains a bounded listener-cleanup escape hatch; cutovers never select or kill a process by port.
|
|
216
217
|
|
|
218
|
+
## Test concurrency
|
|
219
|
+
|
|
220
|
+
Process integration tests run up to 4 shards concurrently by default; the unit lane caps at 2. On constrained machines, use `DSH_TEST_MAX_WORKERS=1 pnpm --filter @khorsheed/dsh-ankh-guard test` to schedule every shard serially. The same variable applies to the repository-wide `pnpm gate`. This only reduces scheduling concurrency: it does not omit tests, extend assertion deadlines, or change production restart behavior. Invalid values retain the defaults.
|
|
221
|
+
|
|
217
222
|
## Changelog
|
|
218
223
|
|
|
219
224
|
See [CHANGELOG.md](CHANGELOG.md).
|
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# last confirmed-consistent state. Both languages carry equal authority; after
|
|
3
3
|
# editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/ankh-guard/README.en.md
|
|
5
|
-
packages/ankh-guard/README.en.md:
|
|
6
|
-
packages/ankh-guard/README.md:
|
|
5
|
+
packages/ankh-guard/README.en.md: 551302cb33397c2c0e363d86de2a9fd66d52185a
|
|
6
|
+
packages/ankh-guard/README.md: 7bd89a16642978a8ded951d2248b2a51887c294c
|
package/README.md
CHANGED
|
@@ -183,7 +183,7 @@ dsh-ankh-guard restart \
|
|
|
183
183
|
|
|
184
184
|
以 cordis 插件挂载(base bundle)后,同一套能力以 `selfRestartGuard` 服务的形式供应用内闸门使用。配置:`maxAgeMinutes`(默认 10)、`stateDir`、`repoDir`、`reportRestartContext`(默认 `followup`)、`fallbackGraceMs`(默认 300000)。
|
|
185
185
|
|
|
186
|
-
除 verify/record/canary 等闸门外,服务还暴露 `requestRestart({ start, profile, initiator })`——UI 级调用方(如 mode-switcher)的进程内重启触发缝:`initiator` 必填(发起会话的真实 id),端口从 launch 记录自知;无活 watchdog 走 `restart`,受监督走 `reconfigure` 事务 cutover(受监督下唯一安全的换命令通道),凭证/preflight/marker/lock 全套闸门与 CLI 同源,拒绝返回结构化 `{ accepted, stage, reason }` 且绝不停机。浏览器侧,除 cutover receipt 通道外还有 boot 代际通道:普通重启或崩溃救回后,打开的标签页经 handoff 长轮询发现进程 boot id 已变,自动全页刷新一次拿到新 bundle
|
|
186
|
+
除 verify/record/canary 等闸门外,服务还暴露 `requestRestart({ start, profile, initiator })`——UI 级调用方(如 mode-switcher)的进程内重启触发缝:`initiator` 必填(发起会话的真实 id),端口从 launch 记录自知;无活 watchdog 走 `restart`,受监督走 `reconfigure` 事务 cutover(受监督下唯一安全的换命令通道),凭证/preflight/marker/lock 全套闸门与 CLI 同源,拒绝返回结构化 `{ accepted, stage, reason }` 且绝不停机。浏览器侧,除 cutover receipt 通道外还有 boot 代际通道:普通重启或崩溃救回后,打开的标签页经 handoff 长轮询发现进程 boot id 已变,自动全页刷新一次拿到新 bundle;刷新前会等新进程的组合挂载完成(Web-server 座位与兄弟行共用,端口刚应答时 `/api` 路由 owner 可能还没挂上;Loader 结算前一律回 `waiting` 且不下发 boot id,标签页保持陈旧 id 继续问,就绪即刷);仅前台持续失败约 5 秒后显示带重试按钮的轻量连接提示;只有确认的 cutover 使用重启遮罩。后台或离线时间不计入失败时长;回前台或恢复联网立即清除退避并重新轮询;挂起的请求在 35 秒后超时,过期响应不能触发刷新。
|
|
187
187
|
|
|
188
188
|
## Model Experience
|
|
189
189
|
|
|
@@ -195,11 +195,12 @@ dsh-ankh-guard restart \
|
|
|
195
195
|
|
|
196
196
|
## Compatibility
|
|
197
197
|
|
|
198
|
-
- npm 发布线(`@deepseek-ai/dsh@0.1.
|
|
198
|
+
- npm 发布线(`@deepseek-ai/dsh@0.1.5-rc.1`):支持——0.1.5-rc.1 全量 boot 实证通过(42 包含 capture,2026-09-25)——带两处设计内降级。composition-preflight 门禁通过独立的 `preflight-runner` 运行(0.1.5-rc.1 仍未导出 `composeProfile`,runner 改经已发布的 `@deepseek-ai/dsh-app-boot` 原语组装,带漂移绊线测试),只要能解析到 dsh app 布局——`--harness-root`、耐久 launch spec、`DSH_HARNESS` 或默认检出路径——就完整运行。没有 harness 检出的纯 npm 部署下门禁退化为提示后放行。原标签页桥会探测可选 WebServer/connection 认证 seam,不使用 token 认证的宿主自然走现有 Cookie 路径;冷读(停靠探测与 preset 推导)走 0.1.5 的 handle 制 sessionPersistence(`open(id, 'read')` → `read` → `close`,一次性 `inspect` 已移除)。其余能力在 npm 线上完整。minHost 保持 0.1.5-rc.1,旧宿主请停留在旧发布线。
|
|
199
199
|
- 历史验证:npm host 的 0.1.1-rc.2 → 0.1.2-alpha.4 隔离切换已通过(transition preflight 在 home 副本上移开带旧 schema record 的 v3 whole-unit projection cache,live apply 隔离旧文件,target 以零重试完成 Token URL → 303 → Cookie 200、ownership 稳定窗口与 canary;旧文件逐字节保留在 cutover 目录。相同 home 的无 transition 对照因缺少 Alpha.4 record 字段而拒绝,证明验收覆盖了真实 schema 断裂面)。
|
|
200
|
-
- 源码线(deepseek-harness master,fork 或上游):✅(verifiedHost: 0.1.
|
|
200
|
+
- 源码线(deepseek-harness master,fork 或上游):✅(verifiedHost: 0.1.7-rc.1)——门禁通过独立的 `preflight-runner` 运行(从在线 checkout 解析已发布的 `@deepseek-ai/dsh-app-boot` 等),不再需要 fork 补丁。
|
|
201
|
+
- 双线证据:0.1.5 的 boot 经三层兼容修复端到端通过——[preset-registry 双名探测](../../.agents/notes/implemented/bug-fix/2026-09-25-preset-registry-dual-name-probe.md)、[typert codec 双形状](../../.agents/notes/implemented/bug-fix/2026-09-25-typert-codec-dual-shape.md)、[face 自带 zod@4](../../.agents/notes/implemented/bug-fix/2026-09-25-typert-faces-carry-zod-v4.md)。
|
|
201
202
|
|
|
202
|
-
**版本线对照**:0.2.0
|
|
203
|
+
**版本线对照**:0.2.0 之后的首个发布起支持宿主 `0.1.5-rc.1` 及以后;宿主 `0.1.2-rc.1` 请停留在 `0.2.0`,宿主 `0.1.0-rc.6` ~ `0.1.1-rc.2` 请停留在 0.1.x 发布线(末版 `0.1.1`)。
|
|
203
204
|
|
|
204
205
|
## Known Limitations and Deferred Work
|
|
205
206
|
|
|
@@ -213,6 +214,10 @@ dsh-ankh-guard restart \
|
|
|
213
214
|
- **`restart`/`supervise` 通过 `lsof` 发现监听者**(macOS / 带 lsof 的 Linux);guard 优先使用系统绝对路径,其他平台需用 `--pid`。
|
|
214
215
|
- **杀进程一律按单 pid identity + 后代回收,从不按进程组**——实例不是 setsid 的,所以 `restart`、`schedule-exit` 的退出代理和 watchdog 清理都针对已记录的 child/listener;cutover 强制路径先 `SIGSTOP`,再用 Linux boot/start-tick 或 macOS `proc_pidinfo` 微秒启动时间复核 identity,不匹配就只 `SIGCONT` 并拒绝,然后才沿 `pgrep -P` 冻结、复核亲缘并回收后代。普通非 cutover 端口恢复仍有受限的 listener 清理兜底;cutover 禁止凭端口选择或杀进程。
|
|
215
216
|
|
|
217
|
+
## 测试并发
|
|
218
|
+
|
|
219
|
+
进程集成测试默认并行运行 4 个分片,unit lane 上限为 2。资源紧张时可用 `DSH_TEST_MAX_WORKERS=1 pnpm --filter @khorsheed/dsh-ankh-guard test` 串行调度全部分片;全仓 `pnpm gate` 也可使用这个环境变量。只降低调度并发,不减少测试、延长断言期限或改变生产重启行为;无效值保留默认值。
|
|
220
|
+
|
|
216
221
|
## 变更记录
|
|
217
222
|
|
|
218
223
|
见 [CHANGELOG.md](CHANGELOG.md)。
|
package/lib/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { i as resolveStateDir, n as isDirectInvocation, r as resolveRepoDir, t as SRC_ARTIFACT_PATTERN } from "./defaults-CduvOcGq.js";
|
|
3
|
-
import { A as writeStableLaunchSpec, C as prepareLaunchCutover, D as selectedLaunchSpec, E as recordCutoverEvent, F as workingTreeChanges, M as currentHead, N as isWorkingTreeClean, O as summarizeLaunchState, P as resetToCheckpoint, T as readLaunchState, _ as writeRestartOutcome, b as activeCutover, c as readInstanceLaunch, f as writeAdoptionRecord, h as writeInstanceLaunchAsSupervisor, j as commitCheckpoint, k as writeCutoverControl, p as writeCompositionRecovery, u as readSkillRegistration, w as readCutoverReceipt, x as commandSha256, y as writeUnexpectedExitRecord } from "./restart-context-
|
|
3
|
+
import { A as writeStableLaunchSpec, C as prepareLaunchCutover, D as selectedLaunchSpec, E as recordCutoverEvent, F as workingTreeChanges, M as currentHead, N as isWorkingTreeClean, O as summarizeLaunchState, P as resetToCheckpoint, T as readLaunchState, _ as writeRestartOutcome, b as activeCutover, c as readInstanceLaunch, f as writeAdoptionRecord, h as writeInstanceLaunchAsSupervisor, j as commitCheckpoint, k as writeCutoverControl, p as writeCompositionRecovery, u as readSkillRegistration, w as readCutoverReceipt, x as commandSha256, y as writeUnexpectedExitRecord } from "./restart-context-DlaDZWKq.js";
|
|
4
4
|
import { _ as processIdentity, c as appendTestLifecycleEvent, d as registerTestProcess, f as discoverLaunchCommand, h as killPidTree, l as appendTestLifecycleEventForProcess, m as findPidOnPort, n as TEST_PROCESS_ROLE_ENV, p as findOwnedListener, r as TEST_PROCESS_TEMP_ROOT_ENV, t as TEST_PROCESS_PORT_ENV, u as registerCurrentTestProcess, v as processIdentityMatches } from "./test-seam-dwvaKjRp.js";
|
|
5
5
|
import { a as setProvenDeployment, c as lastGoodBootRevision, d as pidAlive, f as stateFile, i as setCheckpoint, l as livePidIn, n as loadState, r as recordCredential, s as verifyCredential, t as clearCredential, u as liveWatchdogPid } from "./state-CZMypGkB.js";
|
|
6
6
|
import { execFileSync, spawn } from "node:child_process";
|
package/lib/client.js
CHANGED
|
@@ -13,8 +13,9 @@ window.__ModuleLoader__.load({
|
|
|
13
13
|
const ACTIVE_RETRY_MS = 250;
|
|
14
14
|
const ERROR_RETRY_MIN_MS = 1e3;
|
|
15
15
|
const ERROR_RETRY_MAX_MS = 3e4;
|
|
16
|
-
/** Sustained-failure threshold for the
|
|
17
|
-
const
|
|
16
|
+
/** Sustained-failure threshold for the connection notice; transient blips never show it. */
|
|
17
|
+
const DISCONNECTED_NOTICE_MS = 5e3;
|
|
18
|
+
const REQUEST_TIMEOUT_MS = 35e3;
|
|
18
19
|
/** No Cordis services are needed; this is a same-origin browser lifecycle observer. */
|
|
19
20
|
const inject = [];
|
|
20
21
|
function encodeBase64Url(bytes) {
|
|
@@ -80,16 +81,17 @@ window.__ModuleLoader__.load({
|
|
|
80
81
|
writePending(pending);
|
|
81
82
|
return pending;
|
|
82
83
|
}
|
|
83
|
-
function waitingOverlay(kind = "restarting") {
|
|
84
|
+
function waitingOverlay(kind = "restarting", retry) {
|
|
84
85
|
const existing = document.getElementById("ankh-guard-browser-handoff");
|
|
85
|
-
if (existing
|
|
86
|
+
if (existing?.dataset.kind === "restarting" && kind === "disconnected") return existing;
|
|
87
|
+
const element = existing ?? document.createElement("div");
|
|
86
88
|
const zh = navigator.language.toLowerCase().startsWith("zh");
|
|
87
|
-
const element = document.createElement("div");
|
|
88
89
|
element.id = "ankh-guard-browser-handoff";
|
|
90
|
+
element.dataset.kind = kind;
|
|
89
91
|
element.setAttribute("role", "status");
|
|
90
92
|
element.setAttribute("aria-live", "polite");
|
|
91
|
-
element.textContent = kind === "disconnected" ? zh ? "
|
|
92
|
-
element.style.cssText = [
|
|
93
|
+
element.textContent = kind === "disconnected" ? zh ? "连接暂时中断,正在重试…" : "Connection interrupted; retrying…" : zh ? "dsh 正在重启;此标签页会自动恢复。" : "dsh is restarting; this tab will recover automatically.";
|
|
94
|
+
element.style.cssText = kind === "restarting" ? [
|
|
93
95
|
"position:fixed",
|
|
94
96
|
"inset:0",
|
|
95
97
|
"z-index:2147483647",
|
|
@@ -100,20 +102,48 @@ window.__ModuleLoader__.load({
|
|
|
100
102
|
"color:#fff",
|
|
101
103
|
"font:500 16px/1.5 system-ui,sans-serif",
|
|
102
104
|
"text-align:center"
|
|
105
|
+
].join(";") : [
|
|
106
|
+
"position:fixed",
|
|
107
|
+
"top:calc(env(safe-area-inset-top,0px) + 12px)",
|
|
108
|
+
"left:12px",
|
|
109
|
+
"right:12px",
|
|
110
|
+
"max-width:520px",
|
|
111
|
+
"margin:0 auto",
|
|
112
|
+
"box-sizing:border-box",
|
|
113
|
+
"z-index:2147483647",
|
|
114
|
+
"display:flex",
|
|
115
|
+
"align-items:center",
|
|
116
|
+
"justify-content:space-between",
|
|
117
|
+
"gap:12px",
|
|
118
|
+
"padding:12px 16px",
|
|
119
|
+
"border:1px solid var(--dsw-alias-border-l2,#8885)",
|
|
120
|
+
"border-radius:16px",
|
|
121
|
+
"background:var(--dsw-alias-bg-base,#fff)",
|
|
122
|
+
"color:var(--dsw-alias-label-primary,#181a20)",
|
|
123
|
+
"box-shadow:0 4px 24px #0002",
|
|
124
|
+
"font:400 15px/1.5 system-ui,sans-serif"
|
|
103
125
|
].join(";");
|
|
104
|
-
|
|
126
|
+
if (kind === "disconnected" && retry) {
|
|
127
|
+
const button = document.createElement("button");
|
|
128
|
+
button.textContent = zh ? "重试" : "Retry";
|
|
129
|
+
button.style.cssText = "flex:none;border:0;background:transparent;color:var(--dsw-alias-state-business-primary,#4d6bfe);font:inherit;min-height:36px;cursor:pointer";
|
|
130
|
+
button.onclick = retry;
|
|
131
|
+
element.append(button);
|
|
132
|
+
}
|
|
133
|
+
if (!existing) (document.body ?? document.documentElement).append(element);
|
|
105
134
|
return element;
|
|
106
135
|
}
|
|
107
|
-
async function post(body) {
|
|
136
|
+
async function post(body, signal) {
|
|
108
137
|
return fetch(ROUTE, {
|
|
109
138
|
method: "POST",
|
|
139
|
+
signal,
|
|
110
140
|
credentials: "same-origin",
|
|
111
141
|
cache: "no-store",
|
|
112
142
|
headers: { "content-type": "application/json" },
|
|
113
143
|
body: JSON.stringify(body)
|
|
114
144
|
});
|
|
115
145
|
}
|
|
116
|
-
async function acknowledge(pending) {
|
|
146
|
+
async function acknowledge(pending, signal) {
|
|
117
147
|
return (await post({
|
|
118
148
|
version: 1,
|
|
119
149
|
operation: "ack",
|
|
@@ -121,7 +151,7 @@ window.__ModuleLoader__.load({
|
|
|
121
151
|
channel: pending.channel,
|
|
122
152
|
authentication: pending.authentication,
|
|
123
153
|
...pending.capability !== void 0 ? { capability: pending.capability } : {}
|
|
124
|
-
})).status === 204;
|
|
154
|
+
}, signal)).status === 204;
|
|
125
155
|
}
|
|
126
156
|
/** Install the polling/reload loop for this tab's lifetime. */
|
|
127
157
|
function apply(_ctx) {
|
|
@@ -131,21 +161,61 @@ window.__ModuleLoader__.load({
|
|
|
131
161
|
let cap;
|
|
132
162
|
let errorRetryMs = ERROR_RETRY_MIN_MS;
|
|
133
163
|
let firstFailureAt;
|
|
164
|
+
let request;
|
|
165
|
+
let lastWakeAt = -Infinity;
|
|
166
|
+
const foreground = () => document.visibilityState !== "hidden" && navigator.onLine !== false;
|
|
167
|
+
const clearConnectionNotice = () => {
|
|
168
|
+
const notice = document.getElementById("ankh-guard-browser-handoff");
|
|
169
|
+
if (notice?.dataset.kind === "disconnected") notice.remove();
|
|
170
|
+
};
|
|
171
|
+
const pause = () => {
|
|
172
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
173
|
+
timer = void 0;
|
|
174
|
+
const previous = request;
|
|
175
|
+
request = void 0;
|
|
176
|
+
previous?.abort();
|
|
177
|
+
firstFailureAt = void 0;
|
|
178
|
+
errorRetryMs = ERROR_RETRY_MIN_MS;
|
|
179
|
+
clearConnectionNotice();
|
|
180
|
+
};
|
|
181
|
+
const wake = () => {
|
|
182
|
+
if (disposed || !foreground() || Date.now() - lastWakeAt < 500) return;
|
|
183
|
+
lastWakeAt = Date.now();
|
|
184
|
+
pause();
|
|
185
|
+
schedule();
|
|
186
|
+
};
|
|
187
|
+
const visibility = () => {
|
|
188
|
+
if (!foreground()) {
|
|
189
|
+
lastWakeAt = -Infinity;
|
|
190
|
+
pause();
|
|
191
|
+
} else wake();
|
|
192
|
+
};
|
|
193
|
+
const page = (event) => {
|
|
194
|
+
if (event.persisted) wake();
|
|
195
|
+
};
|
|
134
196
|
const noteDisconnected = () => {
|
|
135
197
|
firstFailureAt ??= Date.now();
|
|
136
|
-
if (Date.now() - firstFailureAt >=
|
|
198
|
+
if (Date.now() - firstFailureAt >= DISCONNECTED_NOTICE_MS) waitingOverlay("disconnected", wake);
|
|
137
199
|
};
|
|
138
200
|
const schedule = (delayMs = 0) => {
|
|
139
|
-
if (
|
|
201
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
202
|
+
if (!disposed && foreground()) timer = setTimeout(() => {
|
|
203
|
+
timer = void 0;
|
|
140
204
|
tick();
|
|
141
205
|
}, delayMs);
|
|
142
206
|
};
|
|
143
207
|
const tick = async () => {
|
|
144
|
-
if (disposed) return;
|
|
208
|
+
if (disposed || !foreground() || request) return;
|
|
209
|
+
const current = new AbortController();
|
|
210
|
+
request = current;
|
|
211
|
+
const stale = () => disposed || request !== current || !foreground();
|
|
212
|
+
const deadline = setTimeout(() => current.abort(), REQUEST_TIMEOUT_MS);
|
|
145
213
|
try {
|
|
146
214
|
if (pending !== null) {
|
|
147
215
|
waitingOverlay();
|
|
148
|
-
|
|
216
|
+
const acknowledged = await acknowledge(pending, current.signal);
|
|
217
|
+
if (stale()) return;
|
|
218
|
+
if (acknowledged) {
|
|
149
219
|
const returnPath = pending.returnPath;
|
|
150
220
|
const originalTab = pending.channel === "original-tab";
|
|
151
221
|
sessionStorage.removeItem(PENDING_KEY);
|
|
@@ -169,7 +239,8 @@ window.__ModuleLoader__.load({
|
|
|
169
239
|
operation: "poll",
|
|
170
240
|
capability: tabCapability,
|
|
171
241
|
...knownBootId === null ? {} : { knownBootId }
|
|
172
|
-
});
|
|
242
|
+
}, current.signal);
|
|
243
|
+
if (stale()) return;
|
|
173
244
|
if (!response.ok) {
|
|
174
245
|
noteDisconnected();
|
|
175
246
|
schedule(errorRetryMs);
|
|
@@ -179,6 +250,7 @@ window.__ModuleLoader__.load({
|
|
|
179
250
|
errorRetryMs = ERROR_RETRY_MIN_MS;
|
|
180
251
|
firstFailureAt = void 0;
|
|
181
252
|
const result = await response.json();
|
|
253
|
+
if (stale()) return;
|
|
182
254
|
if (typeof result.bootId === "string") sessionStorage.setItem(BOOT_ID_KEY, result.bootId);
|
|
183
255
|
if (result.state === "idle") {
|
|
184
256
|
document.getElementById("ankh-guard-browser-handoff")?.remove();
|
|
@@ -232,17 +304,32 @@ window.__ModuleLoader__.load({
|
|
|
232
304
|
return;
|
|
233
305
|
}
|
|
234
306
|
} catch {
|
|
307
|
+
if (stale()) return;
|
|
235
308
|
noteDisconnected();
|
|
236
309
|
schedule(errorRetryMs);
|
|
237
310
|
errorRetryMs = Math.min(errorRetryMs * 2, ERROR_RETRY_MAX_MS);
|
|
238
311
|
return;
|
|
312
|
+
} finally {
|
|
313
|
+
clearTimeout(deadline);
|
|
314
|
+
if (request === current) request = void 0;
|
|
239
315
|
}
|
|
240
316
|
schedule(ACTIVE_RETRY_MS);
|
|
241
317
|
};
|
|
318
|
+
document.addEventListener("visibilitychange", visibility);
|
|
319
|
+
window.addEventListener("online", wake);
|
|
320
|
+
window.addEventListener("offline", visibility);
|
|
321
|
+
window.addEventListener("pageshow", page);
|
|
322
|
+
window.addEventListener("dsh-mobile-foreground", wake);
|
|
242
323
|
tick();
|
|
243
324
|
return () => {
|
|
244
325
|
disposed = true;
|
|
245
|
-
|
|
326
|
+
pause();
|
|
327
|
+
document.removeEventListener("visibilitychange", visibility);
|
|
328
|
+
window.removeEventListener("online", wake);
|
|
329
|
+
window.removeEventListener("offline", visibility);
|
|
330
|
+
window.removeEventListener("pageshow", page);
|
|
331
|
+
window.removeEventListener("dsh-mobile-foreground", wake);
|
|
332
|
+
document.getElementById("ankh-guard-browser-handoff")?.remove();
|
|
246
333
|
};
|
|
247
334
|
}
|
|
248
335
|
//#endregion
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as resolveStateDir, r as resolveRepoDir, t as SRC_ARTIFACT_PATTERN } from "./defaults-CduvOcGq.js";
|
|
2
|
-
import { M as currentHead, N as isWorkingTreeClean, P as resetToCheckpoint, S as cutoverBlocksWake, a as interruptedSnapshotFile, b as activeCutover, c as readInstanceLaunch, d as restartContextText, g as writeInterruptedSnapshot, i as continueInterruptedText, j as commitCheckpoint, l as readInterruptedSnapshot, m as writeInstanceLaunch, n as buildLaunchCommand, o as isParkedOnUserInput, r as continueAndReportText, s as pendingRestartRecord, t as acknowledgeRestartRecord, v as writeSkillRegistration, w as readCutoverReceipt } from "./restart-context-
|
|
2
|
+
import { M as currentHead, N as isWorkingTreeClean, P as resetToCheckpoint, S as cutoverBlocksWake, a as interruptedSnapshotFile, b as activeCutover, c as readInstanceLaunch, d as restartContextText, g as writeInterruptedSnapshot, i as continueInterruptedText, j as commitCheckpoint, l as readInterruptedSnapshot, m as writeInstanceLaunch, n as buildLaunchCommand, o as isParkedOnUserInput, r as continueAndReportText, s as pendingRestartRecord, t as acknowledgeRestartRecord, v as writeSkillRegistration, w as readCutoverReceipt } from "./restart-context-DlaDZWKq.js";
|
|
3
3
|
import { _ as processIdentity, g as listeningPortsForPid, v as processIdentityMatches } from "./test-seam-dwvaKjRp.js";
|
|
4
4
|
import { f as stateFile, i as setCheckpoint, n as loadState, r as recordCredential, s as verifyCredential, t as clearCredential, u as liveWatchdogPid } from "./state-CZMypGkB.js";
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
@@ -11,7 +11,6 @@ import { dirname, join, resolve, sep } from "node:path";
|
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import z from "@deepseek-ai/schemastery";
|
|
13
13
|
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
14
|
-
import * as agentPresetsHost from "@deepseek-ai/dsh-agent-presets";
|
|
15
14
|
//#region lib/types/browser-handoff.js
|
|
16
15
|
/**
|
|
17
16
|
* Browser handoff bridge for launch cutovers.
|
|
@@ -31,6 +30,14 @@ import * as agentPresetsHost from "@deepseek-ai/dsh-agent-presets";
|
|
|
31
30
|
* means the process it knew is gone — answer ready/reload. A cutover receipt
|
|
32
31
|
* always wins over the generation check: during a cutover the old tab's known
|
|
33
32
|
* id is already stale, and the receipt protocol owns the pacing.
|
|
33
|
+
*
|
|
34
|
+
* The generation answer waits for the successor's composition to settle. The
|
|
35
|
+
* shared Web-server seat answers as soon as it listens — well before sibling
|
|
36
|
+
* rows mount — and a page that loads then calls into a half-mounted /api
|
|
37
|
+
* surface (the Web app gates its own browser handoff on the same Loader
|
|
38
|
+
* settlement for that reason). Until then the poll is answered `waiting`
|
|
39
|
+
* WITHOUT the boot id: teaching the tab the successor's id would consume its
|
|
40
|
+
* one-shot generation check and strand it on an unusable page.
|
|
34
41
|
*/
|
|
35
42
|
const BROWSER_HANDOFF_ROUTE = "/_ankh-guard/browser-handoff";
|
|
36
43
|
const CAPABILITY_PATTERN = /^[A-Za-z0-9_-]{43}$/;
|
|
@@ -278,6 +285,10 @@ function createBrowserHandoffHandler(dependencies) {
|
|
|
278
285
|
});
|
|
279
286
|
};
|
|
280
287
|
if (bootId !== void 0 && message.knownBootId !== void 0 && message.knownBootId !== bootId && activeCutover(dependencies.stateDir) === null) {
|
|
288
|
+
if (dependencies.applicationReady?.() === false) {
|
|
289
|
+
json(res, 200, { state: "waiting" });
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
281
292
|
respond(200, {
|
|
282
293
|
state: "ready",
|
|
283
294
|
action: "reload",
|
|
@@ -448,7 +459,8 @@ function registerBrowserHandoff(ctx, stateDir) {
|
|
|
448
459
|
if (webServer === void 0) return;
|
|
449
460
|
const handler = createBrowserHandoffHandler({
|
|
450
461
|
stateDir,
|
|
451
|
-
connectionProvider: () => webCtx.get("connection")
|
|
462
|
+
connectionProvider: () => webCtx.get("connection"),
|
|
463
|
+
applicationReady: applicationReadyProbe(webCtx)
|
|
452
464
|
});
|
|
453
465
|
webCtx.effect(() => webServer.register({
|
|
454
466
|
kind: "exact",
|
|
@@ -457,6 +469,30 @@ function registerBrowserHandoff(ctx, stateDir) {
|
|
|
457
469
|
}), "ankh-guard: browser handoff route");
|
|
458
470
|
});
|
|
459
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* Build the generation channel's readiness probe from the Loader tree.
|
|
474
|
+
*
|
|
475
|
+
* The Web-server seat is shared: it answers as soon as it listens, while
|
|
476
|
+
* sibling rows — including the /api route owner a reloaded page immediately
|
|
477
|
+
* calls into — are still mounting. The Web app gates its own URL line and
|
|
478
|
+
* browser handoff on this exact settlement, so the guard's automatic reload
|
|
479
|
+
* must wait for it too. A composition without a Loader is already complete.
|
|
480
|
+
*
|
|
481
|
+
* Only settlement counts as ready: a failed tree leaves the tab on its old
|
|
482
|
+
* page (the watchdog's crash recovery owns that outcome), and the next healthy
|
|
483
|
+
* process answers the still-stale poll.
|
|
484
|
+
* @param ctx - context owning the Loader service.
|
|
485
|
+
* @returns probe consulted by every boot-generation poll.
|
|
486
|
+
*/
|
|
487
|
+
function applicationReadyProbe(ctx) {
|
|
488
|
+
const settled = ctx.get("loader")?.await();
|
|
489
|
+
if (settled === void 0) return () => true;
|
|
490
|
+
let ready = false;
|
|
491
|
+
settled.then(() => {
|
|
492
|
+
ready = true;
|
|
493
|
+
}, () => {});
|
|
494
|
+
return () => ready;
|
|
495
|
+
}
|
|
460
496
|
//#endregion
|
|
461
497
|
//#region lib/types/restart-request.js
|
|
462
498
|
/**
|
|
@@ -628,6 +664,29 @@ async function requestRestart(request, context) {
|
|
|
628
664
|
}
|
|
629
665
|
//#endregion
|
|
630
666
|
//#region lib/types/index.js
|
|
667
|
+
let presetRegistryProbe;
|
|
668
|
+
/**
|
|
669
|
+
* Resolve the preset-registry module by name. The 0.1.7-rc.1 host renamed
|
|
670
|
+
* `@deepseek-ai/dsh-agent-presets` to `@deepseek-ai/dsh-agent-preset-registry`
|
|
671
|
+
* (the resolve/mount/livePresetMounts/agentPresetProjectionDefinition API
|
|
672
|
+
* carried over); 0.1.5/0.1.6 hosts install only the old name, and a host
|
|
673
|
+
* without preset composition installs neither — `null`, and the derivation
|
|
674
|
+
* then receives `{}`, the established no-preset degrade (the resume falls
|
|
675
|
+
* back to the deployment's default preset). A STATIC import of either name is
|
|
676
|
+
* a module-resolution failure at load on hosts installing only the other —
|
|
677
|
+
* pack-dist strips `dependencies`, so the specifier resolves against the
|
|
678
|
+
* host's install tree. Both specifiers stay static string literals so tsdown
|
|
679
|
+
* externalizes them and tsc type-checks them.
|
|
680
|
+
* @returns the module namespace, or null when neither name resolves.
|
|
681
|
+
*/
|
|
682
|
+
function loadPresetRegistry() {
|
|
683
|
+
presetRegistryProbe ??= import("@deepseek-ai/dsh-agent-preset-registry").catch(() => import("@deepseek-ai/dsh-agent-presets")).catch(() => null);
|
|
684
|
+
return presetRegistryProbe;
|
|
685
|
+
}
|
|
686
|
+
/** Test seam: drop the cached probe so a mocked resolution path re-runs. */
|
|
687
|
+
function resetPresetRegistryProbeForTest() {
|
|
688
|
+
presetRegistryProbe = void 0;
|
|
689
|
+
}
|
|
631
690
|
/**
|
|
632
691
|
* Which preset a session actually runs, newest selection winning. The rc host
|
|
633
692
|
* exports `resolveSessionPreset` for exactly this fold; the 0.1.2 host
|
|
@@ -649,6 +708,25 @@ function deriveSessionPreset(host, session) {
|
|
|
649
708
|
}
|
|
650
709
|
return host.resolveSessionPreset?.(session);
|
|
651
710
|
}
|
|
711
|
+
/** Probe the session-persistence service's cold-read face. */
|
|
712
|
+
function probeColdReader(ctx) {
|
|
713
|
+
const service = ctx.get("sessionPersistence");
|
|
714
|
+
if (service === void 0 || service === null) return void 0;
|
|
715
|
+
return typeof service.open === "function" ? service : void 0;
|
|
716
|
+
}
|
|
717
|
+
/** Read one persisted session's header and full log through a read handle. */
|
|
718
|
+
async function readColdLog(persistence, id) {
|
|
719
|
+
const handle = await persistence.open(id, "read");
|
|
720
|
+
try {
|
|
721
|
+
const cold = await handle.read(0);
|
|
722
|
+
return {
|
|
723
|
+
meta: handle.header,
|
|
724
|
+
events: cold.events
|
|
725
|
+
};
|
|
726
|
+
} finally {
|
|
727
|
+
await handle.close();
|
|
728
|
+
}
|
|
729
|
+
}
|
|
652
730
|
const Config = z.object({
|
|
653
731
|
maxAgeMinutes: z.natural().min(1).default(10),
|
|
654
732
|
stateDir: z.string().default(""),
|
|
@@ -769,7 +847,7 @@ function apply(ctx, config) {
|
|
|
769
847
|
text
|
|
770
848
|
}],
|
|
771
849
|
source: {
|
|
772
|
-
kind: "
|
|
850
|
+
kind: "ankh-guard",
|
|
773
851
|
plugin: name,
|
|
774
852
|
form: "snapshot",
|
|
775
853
|
sections: [{
|
|
@@ -789,9 +867,9 @@ function apply(ctx, config) {
|
|
|
789
867
|
if (probe === void 0) {
|
|
790
868
|
probe = (async () => {
|
|
791
869
|
try {
|
|
792
|
-
const persistence = ctx
|
|
870
|
+
const persistence = probeColdReader(ctx);
|
|
793
871
|
if (persistence === void 0) return false;
|
|
794
|
-
const { events } = await persistence
|
|
872
|
+
const { events } = await readColdLog(persistence, id);
|
|
795
873
|
return isParkedOnUserInput(events);
|
|
796
874
|
} catch {
|
|
797
875
|
return false;
|
|
@@ -812,7 +890,11 @@ function apply(ctx, config) {
|
|
|
812
890
|
if (cutoverBlocksWake(stateDir)) return;
|
|
813
891
|
const id = agent.id;
|
|
814
892
|
const exitAt = pendingContinue.get(id);
|
|
815
|
-
|
|
893
|
+
let record = followupReport ? pendingRestartRecord(stateDir) : null;
|
|
894
|
+
if (record !== null && record.initiator === void 0 && record.unexpected !== true && record.compositionRecovered !== true && record.error === void 0) {
|
|
895
|
+
acknowledgeRestartRecord(stateDir, record, Date.now());
|
|
896
|
+
record = null;
|
|
897
|
+
}
|
|
816
898
|
const owesReport = record !== null && (record.initiator === void 0 || id === record.initiator);
|
|
817
899
|
if (exitAt !== void 0) {
|
|
818
900
|
(async () => {
|
|
@@ -876,10 +958,10 @@ function apply(ctx, config) {
|
|
|
876
958
|
if (selection?.model !== void 0) agentOptions.model = selection.model;
|
|
877
959
|
let setup;
|
|
878
960
|
const presets = ctx.get("agentPresets");
|
|
879
|
-
const persistence = ctx
|
|
961
|
+
const persistence = probeColdReader(ctx);
|
|
880
962
|
if (presets !== void 0 && persistence !== void 0) {
|
|
881
|
-
const inspected = await persistence
|
|
882
|
-
const presetId = deriveSessionPreset(
|
|
963
|
+
const inspected = await readColdLog(persistence, id);
|
|
964
|
+
const presetId = deriveSessionPreset(await loadPresetRegistry() ?? {}, {
|
|
883
965
|
header: inspected.meta,
|
|
884
966
|
events: inspected.events
|
|
885
967
|
});
|
|
@@ -965,7 +1047,7 @@ function apply(ctx, config) {
|
|
|
965
1047
|
text
|
|
966
1048
|
}],
|
|
967
1049
|
source: {
|
|
968
|
-
kind: "
|
|
1050
|
+
kind: "ankh-guard",
|
|
969
1051
|
plugin: name,
|
|
970
1052
|
form: "snapshot",
|
|
971
1053
|
sections: [{
|
|
@@ -1043,4 +1125,4 @@ function apply(ctx, config) {
|
|
|
1043
1125
|
})();
|
|
1044
1126
|
}
|
|
1045
1127
|
//#endregion
|
|
1046
|
-
export { Config, apply, deriveSessionPreset, inject, name };
|
|
1128
|
+
export { Config, apply, deriveSessionPreset, inject, loadPresetRegistry, name, resetPresetRegistryProbeForTest };
|
package/lib/preflight-runner.js
CHANGED
|
@@ -121,7 +121,7 @@ var PreflightInfraError = class extends Error {};
|
|
|
121
121
|
* bundle layers in `dsh.profile.bundles` order, the profile user layer, the
|
|
122
122
|
* home-level user layer, `--patch` overlays, the agent-presets roots overlay
|
|
123
123
|
* (rc host line only; the 0.1.2 line's preset package self-ships its root),
|
|
124
|
-
* then the telemetry switch.
|
|
124
|
+
* then the telemetry switch. Three host API generations are mirrored and
|
|
125
125
|
* feature-detected per run — see the `hostLine` branch below. Exported so
|
|
126
126
|
* the drift tripwire can compare this assembly against the launcher's own
|
|
127
127
|
* dump without booting anything.
|
|
@@ -147,13 +147,15 @@ async function composePreflightPatches(profile, patchFiles, root, home, binding
|
|
|
147
147
|
}
|
|
148
148
|
const composeEntries = appBoot.composeEntries;
|
|
149
149
|
const healProfilesModuleFallback = appBoot.healProfilesModuleFallback;
|
|
150
|
+
const createProfileResolutionGeneration = appBoot.createProfileResolutionGeneration;
|
|
151
|
+
const createRuntimeResolution = appBoot.createRuntimeResolution;
|
|
150
152
|
const loadOptionalPatches = appBoot.loadOptionalPatches;
|
|
151
153
|
const loadOverlayPatches = appBoot.loadOverlayPatches;
|
|
152
154
|
const loadProfile = appBoot.loadProfile;
|
|
153
155
|
const resolveDshHome = homePaths.resolveDshHome;
|
|
154
156
|
const anchor = binding.installAnchor;
|
|
155
157
|
const resolvedHome = resolveDshHome(home);
|
|
156
|
-
const hostLine = "DEFAULT_PROFILE_PATCH_RELOAD" in appBoot ? "0.1.2" : "rc";
|
|
158
|
+
const hostLine = "createRuntimeResolution" in appBoot ? "0.1.7" : "createProfileResolutionGeneration" in appBoot ? "0.1.6" : "DEFAULT_PROFILE_PATCH_RELOAD" in appBoot ? "0.1.2" : "rc";
|
|
157
159
|
if (hostLine === "rc") healProfilesModuleFallback(anchor, resolvedHome);
|
|
158
160
|
const composed = loadProfile(NAME, profile, anchor, resolvedHome, { userLayer: true });
|
|
159
161
|
writeFileSync(join(composed.dir, PROFILE_ROOT_FILENAME), PROFILE_ROOT_CONFIG);
|
|
@@ -162,6 +164,15 @@ async function composePreflightPatches(profile, patchFiles, root, home, binding
|
|
|
162
164
|
profile: composed,
|
|
163
165
|
home: resolvedHome
|
|
164
166
|
});
|
|
167
|
+
else if (hostLine === "0.1.6") await createProfileResolutionGeneration({
|
|
168
|
+
installAnchor: anchor,
|
|
169
|
+
profile: composed,
|
|
170
|
+
home: resolvedHome
|
|
171
|
+
});
|
|
172
|
+
else if (hostLine === "0.1.7") await createRuntimeResolution({
|
|
173
|
+
installAnchor: anchor,
|
|
174
|
+
profile: composed
|
|
175
|
+
});
|
|
165
176
|
const homePatches = loadOptionalPatches(NAME, join(resolvedHome, HOME_PATCH_FILENAME)) ?? [];
|
|
166
177
|
const overlays = patchFiles.flatMap((file) => loadOverlayPatches(NAME, resolve(file)));
|
|
167
178
|
const bundlePatches = composed.layers.flatMap((layer) => layer.patches);
|
|
@@ -902,12 +902,17 @@ function activeCutover(stateDir) {
|
|
|
902
902
|
* Restart-record context injection and interrupted-session continuity. After
|
|
903
903
|
* a scheduled restart, the FULL report waits for the initiating session's
|
|
904
904
|
* root agent, whenever it resumes (session restore is lazy, so no other
|
|
905
|
-
* session is ever woken for reporting)
|
|
906
|
-
*
|
|
907
|
-
*
|
|
908
|
-
*
|
|
909
|
-
*
|
|
910
|
-
*
|
|
905
|
+
* session is ever woken for reporting). A record without an initiator splits
|
|
906
|
+
* by kind: one carrying diagnostics someone must hear about (an unplanned
|
|
907
|
+
* recovery, a composition rollback, a failed restart) is claimed by the
|
|
908
|
+
* first root agent created, while a bare planned outcome — the restart was
|
|
909
|
+
* driven from outside the host and the operator's terminal already has the
|
|
910
|
+
* announcement — is settled without waking anyone. Separately, a snapshot
|
|
911
|
+
* written at SIGTERM time (`interrupted-sessions.json`) records which root
|
|
912
|
+
* sessions had a live turn when the process stopped, so the next restart
|
|
913
|
+
* boot can resume those sessions and queue a "continue" turn. Pure logic
|
|
914
|
+
* reads the durable files; the plugin wires them into `agent/created` and
|
|
915
|
+
* `agent.followup`.
|
|
911
916
|
*/
|
|
912
917
|
/** Absolute path of the restart record inside a state directory. */
|
|
913
918
|
function restartRecordFile(stateDir) {
|
|
@@ -41,6 +41,12 @@ interface BrowserHandoffDependencies {
|
|
|
41
41
|
connection?: ConnectionSlice;
|
|
42
42
|
/** Resolve lazily because WebServer can activate before the optional connection service. */
|
|
43
43
|
connectionProvider?: () => ConnectionSlice | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the serving composition has finished mounting, consulted only by
|
|
46
|
+
* the boot-generation channel. Omitted means ready — a hand-built tree
|
|
47
|
+
* without a Loader is already complete.
|
|
48
|
+
*/
|
|
49
|
+
applicationReady?: () => boolean;
|
|
44
50
|
/** Test seams; production defaults turn idle polling into a held request. */
|
|
45
51
|
longPollMs?: number;
|
|
46
52
|
longPollIntervalMs?: number;
|