dsh-loop-engine-allinone 0.0.0-stage → 0.4.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.
Files changed (143) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/CONTRIBUTING.md +78 -0
  3. package/LICENSE +23 -0
  4. package/NOTICE +45 -0
  5. package/README.md +223 -2
  6. package/README.zh.md +179 -0
  7. package/SECURITY.md +39 -0
  8. package/cordis.patch.yml +3 -0
  9. package/lib/client.js +2166 -0
  10. package/lib/index.js +11621 -0
  11. package/lib/invariant.js +453 -0
  12. package/lib/types/agent-preset-ids.d.ts +276 -0
  13. package/lib/types/client/LoopEngineBadge.d.ts +71 -0
  14. package/lib/types/client/LoopEngineComposerSelect.d.ts +126 -0
  15. package/lib/types/client/LoopEngineSection.d.ts +35 -0
  16. package/lib/types/client/engine-marks.d.ts +87 -0
  17. package/lib/types/client/index.d.ts +39 -0
  18. package/lib/types/client/locales.d.ts +182 -0
  19. package/lib/types/client/reload.d.ts +135 -0
  20. package/lib/types/client/session-engine.d.ts +508 -0
  21. package/lib/types/client/store.d.ts +103 -0
  22. package/lib/types/client/turn-status.d.ts +234 -0
  23. package/lib/types/client/use-session-engine.d.ts +74 -0
  24. package/lib/types/commands.d.ts +77 -0
  25. package/lib/types/compat.d.ts +25 -0
  26. package/lib/types/driver-acp/agent.d.ts +289 -0
  27. package/lib/types/driver-acp/approval.d.ts +27 -0
  28. package/lib/types/driver-acp/capabilities.d.ts +200 -0
  29. package/lib/types/driver-acp/client.d.ts +297 -0
  30. package/lib/types/driver-acp/executable.d.ts +53 -0
  31. package/lib/types/driver-acp/mapping.d.ts +76 -0
  32. package/lib/types/driver-acp/profile.d.ts +126 -0
  33. package/lib/types/driver-acp/runtime.d.ts +45 -0
  34. package/lib/types/driver-acp/subprocess.d.ts +19 -0
  35. package/lib/types/driver-acp/terminal.d.ts +98 -0
  36. package/lib/types/driver-acp/transport.d.ts +43 -0
  37. package/lib/types/driver-acp/types.d.ts +152 -0
  38. package/lib/types/driver-cli/capability.d.ts +42 -0
  39. package/lib/types/driver-cli/cli-agent.d.ts +258 -0
  40. package/lib/types/driver-cli/cli-loop.d.ts +46 -0
  41. package/lib/types/driver-cli/flatten.d.ts +35 -0
  42. package/lib/types/driver-cli/frames.d.ts +128 -0
  43. package/lib/types/driver-cli/ndjson.d.ts +106 -0
  44. package/lib/types/driver-cli/session-sink.d.ts +333 -0
  45. package/lib/types/driver-cli/stream-json.d.ts +61 -0
  46. package/lib/types/driver-cli/text.d.ts +66 -0
  47. package/lib/types/driver-cli/transport.d.ts +84 -0
  48. package/lib/types/driver-core/agents-md-skill-provider.d.ts +72 -0
  49. package/lib/types/driver-core/assistant-stream.d.ts +68 -0
  50. package/lib/types/driver-core/context-files.d.ts +62 -0
  51. package/lib/types/driver-core/host-servers.d.ts +119 -0
  52. package/lib/types/driver-core/hosted-engine-runtime.d.ts +190 -0
  53. package/lib/types/driver-core/hosted-tool-vocabulary.d.ts +78 -0
  54. package/lib/types/driver-core/idle-child.d.ts +57 -0
  55. package/lib/types/driver-core/image-access.d.ts +25 -0
  56. package/lib/types/driver-core/inbox.d.ts +104 -0
  57. package/lib/types/driver-core/model-handover.d.ts +134 -0
  58. package/lib/types/driver-core/ownership.d.ts +41 -0
  59. package/lib/types/driver-core/permission-knobs.d.ts +26 -0
  60. package/lib/types/driver-core/prompt.d.ts +64 -0
  61. package/lib/types/driver-core/session-lifetime.d.ts +62 -0
  62. package/lib/types/driver-core/session-model.d.ts +128 -0
  63. package/lib/types/driver-core/skill-inject.d.ts +59 -0
  64. package/lib/types/driver-core/step-close.d.ts +49 -0
  65. package/lib/types/driver-core/step-images.d.ts +62 -0
  66. package/lib/types/driver-core/step-tools.d.ts +43 -0
  67. package/lib/types/driver-core/system-head.d.ts +43 -0
  68. package/lib/types/engine-agy/agent.d.ts +67 -0
  69. package/lib/types/engine-agy/frames.d.ts +90 -0
  70. package/lib/types/engine-agy/loop.d.ts +64 -0
  71. package/lib/types/engine-agy/process.d.ts +173 -0
  72. package/lib/types/engine-claude/agent.d.ts +186 -0
  73. package/lib/types/engine-claude/loop.d.ts +73 -0
  74. package/lib/types/engine-claude/mapping.d.ts +108 -0
  75. package/lib/types/engine-claude/permission.d.ts +41 -0
  76. package/lib/types/engine-claude/process.d.ts +59 -0
  77. package/lib/types/engine-claude/sdk.d.ts +67 -0
  78. package/lib/types/engine-claude/types.d.ts +28 -0
  79. package/lib/types/engine-codex/agent.d.ts +216 -0
  80. package/lib/types/engine-codex/appserver/client.d.ts +80 -0
  81. package/lib/types/engine-codex/appserver/mapping.d.ts +67 -0
  82. package/lib/types/engine-codex/appserver/thread.d.ts +66 -0
  83. package/lib/types/engine-codex/appserver/types.d.ts +225 -0
  84. package/lib/types/engine-codex/loop.d.ts +75 -0
  85. package/lib/types/engine-codex/model-handover.d.ts +56 -0
  86. package/lib/types/engine-codex/permission.d.ts +126 -0
  87. package/lib/types/engine-codex/skills.d.ts +28 -0
  88. package/lib/types/engine-codex/types.d.ts +36 -0
  89. package/lib/types/engine-drivers.d.ts +132 -0
  90. package/lib/types/engine-grok/agent.d.ts +24 -0
  91. package/lib/types/engine-grok/loop.d.ts +61 -0
  92. package/lib/types/engine-grok/process.d.ts +46 -0
  93. package/lib/types/engine-grok/profile.d.ts +82 -0
  94. package/lib/types/engine-hermes/agent.d.ts +47 -0
  95. package/lib/types/engine-hermes/loop.d.ts +56 -0
  96. package/lib/types/engine-hermes/process.d.ts +92 -0
  97. package/lib/types/engine-kimi/acp/client.d.ts +123 -0
  98. package/lib/types/engine-kimi/acp/mapping.d.ts +73 -0
  99. package/lib/types/engine-kimi/acp/types.d.ts +143 -0
  100. package/lib/types/engine-kimi/agent.d.ts +24 -0
  101. package/lib/types/engine-kimi/commands.d.ts +44 -0
  102. package/lib/types/engine-kimi/loop.d.ts +62 -0
  103. package/lib/types/engine-kimi/model-handover.d.ts +32 -0
  104. package/lib/types/engine-kimi/permission.d.ts +28 -0
  105. package/lib/types/engine-kimi/process.d.ts +47 -0
  106. package/lib/types/engine-kimi/profile.d.ts +19 -0
  107. package/lib/types/engine-kimi/skills.d.ts +52 -0
  108. package/lib/types/engine-kimi/types.d.ts +25 -0
  109. package/lib/types/engine-minimaxcode/agent.d.ts +24 -0
  110. package/lib/types/engine-minimaxcode/loop.d.ts +83 -0
  111. package/lib/types/engine-minimaxcode/process.d.ts +53 -0
  112. package/lib/types/engine-minimaxcode/profile.d.ts +72 -0
  113. package/lib/types/engine-of-session.d.ts +97 -0
  114. package/lib/types/engine-pi/agent.d.ts +230 -0
  115. package/lib/types/engine-pi/loop.d.ts +72 -0
  116. package/lib/types/engine-pi/model-handover.d.ts +84 -0
  117. package/lib/types/engine-pi/permission.d.ts +47 -0
  118. package/lib/types/engine-pi/rpc/client.d.ts +107 -0
  119. package/lib/types/engine-pi/rpc/mapping.d.ts +37 -0
  120. package/lib/types/engine-pi/rpc/types.d.ts +249 -0
  121. package/lib/types/engine-pi/skills.d.ts +47 -0
  122. package/lib/types/engine-pi/types.d.ts +36 -0
  123. package/lib/types/engine-qoderclicn/agent.d.ts +59 -0
  124. package/lib/types/engine-qoderclicn/loop.d.ts +51 -0
  125. package/lib/types/engine-qoderclicn/process.d.ts +113 -0
  126. package/lib/types/engine-registry.d.ts +584 -0
  127. package/lib/types/engine-remote.d.ts +192 -0
  128. package/lib/types/engine-surface.d.ts +36 -0
  129. package/lib/types/engine-zcode/agent.d.ts +50 -0
  130. package/lib/types/engine-zcode/loop.d.ts +47 -0
  131. package/lib/types/engine-zcode/process.d.ts +111 -0
  132. package/lib/types/index.d.ts +205 -0
  133. package/lib/types/invariant.d.ts +26 -0
  134. package/lib/types/model-selection-reset.d.ts +271 -0
  135. package/lib/types/namespace.d.ts +25 -0
  136. package/lib/types/patch-manager.d.ts +104 -0
  137. package/lib/types/preset.d.ts +254 -0
  138. package/lib/types/provider-route.d.ts +245 -0
  139. package/lib/types/router-loop.d.ts +458 -0
  140. package/lib/types/session-engine-store.d.ts +138 -0
  141. package/lib/types/settings.d.ts +60 -0
  142. package/lib/types/skills.d.ts +85 -0
  143. package/package.json +152 -6
package/CHANGELOG.md ADDED
@@ -0,0 +1,119 @@
1
+ # Changelog
2
+
3
+ All notable changes to this fork. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
5
+ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ Nothing yet.
10
+
11
+ ## [0.4.1]
12
+
13
+ ### Added
14
+
15
+ - A language switch in both READMEs (`English · 简体中文`). GitHub only renders
16
+ `README.md`, so the pair is linked rather than auto-detected.
17
+
18
+ ### Fixed
19
+
20
+ - `README.zh.md` was a translation of the UPSTREAM plugin: four hosted engines, no
21
+ registry chapter, nothing about grok/minimaxcode or the ACP capability bridges. It
22
+ is rewritten from the English README section by section (same nine sections, same
23
+ order).
24
+ - `tsconfig.json` no longer extends a `../deepseek-harness/` checkout that only
25
+ exists in the author's working tree, and `vitest.config.ts` applies its harness
26
+ aliases only when that checkout is present. Before this, a fresh clone could not
27
+ run `node build.mjs` (TS5083) or `vitest run` (32 suites could not resolve
28
+ `@deepseek-ai/cordis`).
29
+
30
+ ## [0.4.0]
31
+
32
+ ### Added
33
+
34
+ - **Grok Build (`grok`)** — ACP engine over `grok agent stdio`.
35
+ - `session/new` refuses an unauthenticated client, so the driver answers ACP's
36
+ `authenticate` with the method id `initialize` published, retries once, and
37
+ otherwise reports the registry's login hint instead of a raw JSON-RPC error.
38
+ - Model selection is `session/set_config_option` with a **bare value**; the
39
+ `{ value }` wrapper the vendor's documentation shows is rejected `-32602`.
40
+ (Measured after signing in; the earlier "documented spelling first, fall back"
41
+ guess was wrong and is gone.)
42
+ - The model catalog is read from the signed-in agent's own
43
+ `initialize._meta.modelState` (`grok-4.7`), not from the unauthenticated
44
+ `grok models` command, which reports ids this surface refuses.
45
+ - Declares `images: false`: `promptCapabilities.image` is false, and sending an
46
+ image block would reject the whole prompt.
47
+ - **MiniMax Code (`minimaxcode`)** — ACP engine over `mcode acp`, aimed at the
48
+ M Plan **subscription** rather than an API key (`mcode login`, then
49
+ `mcode provider use token-plan`; the plugin never logs in and never reads the
50
+ credential).
51
+ - Resolves the npm package entrypoint, and launches a Windows `.cmd` shim
52
+ through the command interpreter — `spawn('mcode')` fails `ENOENT` and
53
+ `spawn('mcode.cmd')` throws `EINVAL`, both measured.
54
+ - Region travels as `MAVIS_REGION` (measured as the variable this surface
55
+ honours; `MCODE_REGION` is inert here), with the `cn|en` value domain the CLI
56
+ validates — not the login flag's `cn|global`.
57
+ - States `permissionMode` on every opened session rather than inheriting
58
+ whatever the CLI last persisted, because that default can be Full access.
59
+ - **ACP client-side capabilities** (`driver-acp/capabilities.ts`,
60
+ `driver-acp/terminal.ts`) — the other half of ACP, and what makes a
61
+ tool-using ACP engine actually work.
62
+ - `terminal/create` and its lifecycle, plus `fs/read_text_file`.
63
+ - The terminal bridge routes through the harness's own `shell` service, i.e. the
64
+ same executor dsh's `bash` tool uses, so an engine's command gets the same
65
+ sandbox, timeout policy and output caps. With no shell service it **refuses**
66
+ rather than falling back to an unconfined spawn.
67
+ - The announced `clientCapabilities` is derived from the implemented handlers, so
68
+ a declared capability is always an implemented one; a filesystem **write** is
69
+ never announced.
70
+ - `capabilities.acpProtocolVersion` — the version announced at `initialize` is
71
+ registry data now, not a constant in the shared client.
72
+ - `EngineDescriptor.region` — an engine whose CLI scopes accounts by region
73
+ declares the knob, the environment variable and the accepted values.
74
+ - `scripts/probe/acp-handshake.mjs` and `scripts/probe/smoke-acp.ts` — dump an ACP
75
+ engine's frames, or drive one through the plugin's own profile.
76
+ - `CONTRIBUTING.md`, `SECURITY.md`, this changelog.
77
+
78
+ ### Changed
79
+
80
+ - **`engine-kimi/acp/` → `driver-acp/`**, and `KimiAgent`'s turn/step machine
81
+ generalised into `AcpEngineAgent`. Kimi keeps its class names and constructor
82
+ shapes; its entire suite passes unchanged, which is the regression pin for the
83
+ move.
84
+ - An ACP engine is now a **profile** (argv, protocol version, model dialect,
85
+ session handshake, endpoint handover) plus four small files. Adding the fourth
86
+ one does not touch shared code.
87
+ - Tool vocabulary: MiniMax Code's measured `bash` call is a **declared identity**
88
+ (a table row meaning "read and found to agree"), and grok deliberately has no
89
+ row — its only measured tool runs through the client-side terminal bridge, and
90
+ renaming it to dsh's `bash` would dress a failing call up as a working one.
91
+
92
+ ### Fixed
93
+
94
+ - `smoke-acp.ts <engine>` skipped the engine name as if it were `--bin`'s value
95
+ when `--bin` was absent, so `smoke-acp.ts grok` silently ran minimaxcode.
96
+ - grok's `authenticate` sat outside its `try`, so a failure there (which is what a
97
+ signed-out host produces, since the call starts the vendor's browser sign-in)
98
+ surfaced "process exited unexpectedly" instead of an actionable hint.
99
+ - `.gitignore` now covers a stray CLI home directory: a relative `GROK_HOME` once
100
+ made an engine write its whole state dir — `auth.json` included — into this repo.
101
+
102
+ ### Known limitations
103
+
104
+ - **grok's tools need the harness shell service.** Its shell tools run through the
105
+ client-side terminal bridge; a composition without `ctx.shell` refuses them
106
+ rather than running them unconfined. Grok's reasoning and conversation work
107
+ either way.
108
+ - **`claudeBin` cannot unload the bundled SDK.** Pointing it at an external binary
109
+ changes what executes, but `@anthropic-ai/claude-agent-sdk` is a value import in
110
+ `engine-claude/agent.ts`, so the package stays required. `codexBin` and `piBin`
111
+ CAN fully unbind their bundled copies.
112
+ - **Bundled engines have no runtime updater** by design: their version is this
113
+ package's dependency pin, so upgrading means changing the dependency, not
114
+ rewriting it in place.
115
+
116
+ ## [0.3.0] and earlier
117
+
118
+ The upstream plugin's history. See
119
+ [`kuun993/dsh-loop-engine`](https://github.com/kuun993/dsh-loop-engine).
@@ -0,0 +1,78 @@
1
+ # Contributing
2
+
3
+ Thanks for looking. This is a fork, and it stays useful only if it is easy to
4
+ extend — so the most valuable contribution is **another engine**, not another
5
+ refactor.
6
+
7
+ ## Before you start
8
+
9
+ - Read [`docs/engine-registry.md`](docs/engine-registry.md). It is the "add an
10
+ engine" recipe, and it records the traps that cost real time.
11
+ - **Probe first.** An engine's wire protocol is recorded from real frames before a
12
+ driver is written for it. A guessed frame shape produces a driver that looks
13
+ finished and silently answers nothing. `scripts/probe/` is that record.
14
+ - Never guess a capability. `capabilities` describes what the DRIVER was verified
15
+ to do, not what the vendor's documentation claims. `images: false` for an engine
16
+ that turns out to accept images is a bug; `images: true` for one that rejects
17
+ them is a broken turn.
18
+
19
+ ## Adding an engine
20
+
21
+ The full recipe is [`docs/engine-registry.md`](docs/engine-registry.md) §2. In
22
+ short, for an ACP engine (three of them share one skeleton, so this is four small
23
+ files):
24
+
25
+ 1. add the id to `HOSTED_ENGINE_IDS` (append only — ids are persisted);
26
+ 2. add its `ENGINE_REGISTRY` row (TypeScript refuses a missing one);
27
+ 3. write `src/engine-<id>/{process,profile,agent,loop}.ts`;
28
+ 4. add its driver factory to `src/engine-drivers.ts`;
29
+ 5. add its copy to `src/client/locales.ts` and its mark to
30
+ `src/client/engine-marks.ts`.
31
+
32
+ Then:
33
+
34
+ ```sh
35
+ node node_modules/typescript/bin/tsc -p tsconfig.build.json --noEmit
36
+ node node_modules/vitest/vitest.mjs run
37
+ node build.mjs
38
+ ```
39
+
40
+ All three must pass. The suite is the contract: a new engine that lands without
41
+ tests is a new engine nobody can safely change later.
42
+
43
+ ## What a pull request needs
44
+
45
+ - **A probe artifact.** Frames dumped from the real CLI, in the PR body (not
46
+ necessarily committed — they can be large). Without it a protocol claim is a
47
+ guess.
48
+ - **A driver smoke result**, when the CLI can run on your machine:
49
+ `node node_modules/tsx/dist/cli.mjs scripts/probe/smoke-driver.ts <engine>` for
50
+ the CLI-family drivers, or `smoke-acp.ts <engine>` for an ACP one.
51
+ - **Tests for the behaviour you changed**, not just for the happy path. The
52
+ failures this codebase has actually shipped were mostly "no error, wrong data"
53
+ (a stream that never reached the durable log, a tool call split across two
54
+ messages, a config value that looked right and did nothing).
55
+ - **An honest UNKNOWN.** If something could not be measured on your machine, say
56
+ so in the docs rather than filling it in. A documented gap is worth more than a
57
+ plausible invention.
58
+
59
+ ## Style
60
+
61
+ - Comments explain **why**, and they cite the measurement or the failure that
62
+ produced the rule. "This is load-bearing because X failed" beats "this is
63
+ important".
64
+ - Every module starts with a `@module` tag and a paragraph on what it is for.
65
+ - Do not reformat code you are not changing. Diffs should be readable.
66
+
67
+ ## Reporting a bug
68
+
69
+ Include: the engine, its version (`<cli> --version`), the harness line
70
+ (0.1.5 / 0.1.7 / 0.2.0), the profile, and what you expected vs what happened. If
71
+ the bug is protocol-shaped, the probe output is the single most useful thing you
72
+ can attach.
73
+
74
+ ## Security
75
+
76
+ Engine credentials are the engines' own business: this plugin never reads, writes
77
+ or refreshes them, and a profile should never contain one. If you find a path where
78
+ that is not true, treat it as a security report — see [SECURITY.md](SECURITY.md).
package/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kuun993 (original author, https://github.com/kuun993/dsh-loop-engine)
4
+
5
+ Copyright (c) 2026 dsh-loop-engine-allinone fork contributors
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,45 @@
1
+ dsh-loop-engine-allinone
2
+ ========================
3
+
4
+ This project is a fork of **dsh-loop-engine** by kuun993:
5
+
6
+ https://github.com/kuun993/dsh-loop-engine
7
+
8
+ The original work is MIT-licensed. Its copyright notice is preserved in the
9
+ `LICENSE` file, alongside this fork's own.
10
+
11
+ ## What the fork adds
12
+
13
+ The upstream plugin already switches the agent loop engine per session. This fork
14
+ contributes an ARCHITECTURE and the engines it made cheap to add:
15
+
16
+ - **A single data-driven engine registry** (`src/engine-registry.ts`). The engine
17
+ roster, its capability declarations, its model catalogs and its display copy are
18
+ declared once; the settings schema, the preset ids, the driver dispatch and the
19
+ browser half all derive from that table. Upstream restated the roster in five
20
+ places, so adding an engine meant finding all five.
21
+ - **A pluggable driver layer**: `driver-cli/` for line-delimited CLI protocols and
22
+ `driver-acp/` for the Agent Client Protocol. An ACP engine is a profile plus four
23
+ small files, and adding the fourth does not touch shared code.
24
+ - **Six additional engines**: Antigravity, ZCode, Qoder CN, Hermes, Grok Build and
25
+ MiniMax Code.
26
+ - **Client-side ACP capabilities** (`terminal/*`, `fs/read_text_file`), routed
27
+ through the harness's own shell and filesystem services, which is what lets an
28
+ engine that drives its tools through the client actually use them.
29
+
30
+ ## What the fork does NOT change
31
+
32
+ The four original engines' protocol code is untouched. `kimi` was migrated onto the
33
+ shared ACP skeleton without a behavior change, and its unchanged test suite is the
34
+ regression pin for that move.
35
+
36
+ ## Third-party artwork
37
+
38
+ The engine marks in `src/client/engine-marks.ts` are traced or measured from each
39
+ vendor's own published artwork, and remain the trademarks of their respective
40
+ owners. They are used here only to identify the engine a user selected.
41
+
42
+ ## Modifications
43
+
44
+ Modifications made by this fork are licensed under the same MIT terms as the
45
+ original. See `LICENSE`.
package/README.md CHANGED
@@ -1,3 +1,224 @@
1
- # Temporary Holding Version
1
+ # dsh-loop-engine-allinone
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **English** · [简体中文](README.zh.md)
4
+
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
+ [![Harness: 0.1.5 / 0.1.7 / 0.2.0](https://img.shields.io/badge/harness-0.1.5%20%7C%200.1.7%20%7C%200.2.0-6f42c1)](#version-compatibility)
7
+
8
+ Pick **dsh web**'s agent loop engine **per session** — the built-in `in-process` loop (the default), or one of the hosted engines `claude-code` / `codex` / `pi` / `kimi` / `agy` / `zcode` / `qoderclicn` / `hermes` / `grok` / `minimaxcode`. Sessions are independent: one chat can run Codex while another runs Kimi. Any open, idle session can move engines — between two hosted engines the handover is **in place**, and a move involving `in-process` **reloads the page** (the `dsh web` process never restarts). Nothing in the main repository changes.
9
+
10
+ > **A fork of [`kuun993/dsh-loop-engine`](https://github.com/kuun993/dsh-loop-engine).**
11
+ > The upstream plugin already switched engines per session. This fork's contribution
12
+ > is an **architecture** — a single data-driven engine registry plus a pluggable
13
+ > driver layer — and the six engines that architecture made cheap to add.
14
+ >
15
+ > | | upstream | this fork |
16
+ > |---|---|---|
17
+ > | engine roster | hardcoded in five places | **one registry table**; everything else derives |
18
+ > | adding an engine | edit five files | **one registry row + one driver** |
19
+ > | engines | 4 | **10** |
20
+ > | ACP engines | 1 (kimi) | **3** (kimi, grok, minimaxcode) sharing one skeleton |
21
+ > | external-CLI drivers | per-engine | `driver-cli/` + `driver-acp/` |
22
+ >
23
+ > The four original engines' protocol code is untouched. `kimi` was migrated onto
24
+ > the shared ACP skeleton **without a behavior change**, and its unchanged test
25
+ > suite is the regression pin.
26
+ >
27
+ > Two things worth knowing before you add an engine:
28
+ > - [`docs/engine-registry.md`](docs/engine-registry.md) §2 step 6 is the **entire**
29
+ > recipe for an ACP engine: a profile plus four small files.
30
+ > - **Probe first.** Every protocol claim in this repository came from real frames
31
+ > (`scripts/probe/`), never from a specification. See [CONTRIBUTING.md](CONTRIBUTING.md).
32
+
33
+ ## Engine marks
34
+
35
+ Every engine has its own mark in the engine picker and its own colour + glyph on
36
+ the chat's turn-status row; **only `in-process` carries the DeepSeek fish**.
37
+
38
+ The three engines this fork added as external CLIs are **traced or measured from
39
+ the vendors' own artwork found on this machine** — Antigravity's arch, ZCode's
40
+ knocked-out `Z` (written out from measured spans, because its straight edges
41
+ defeat a raster trace), and Qoder's green disc with the white crescent between its
42
+ two forms. Kimi's mark was rebuilt from its app tile: a bold `K` plus the brand's
43
+ blue dot, which rides an `accent` subpath because one path can only be filled one
44
+ way.
45
+
46
+ Hermes is the exception worth knowing about: that vendor's mark is a detailed
47
+ character portrait rather than a glyph, so its mark is the portrait's own line art.
48
+
49
+ The two ACP engines this fork added are traced from the artwork the user supplied:
50
+ **Grok Build**'s black ring-and-slash (its slash tips are ~1px diagonals, which is
51
+ why that trace is 8-connected — a 4-connected contour lops the tips off), and
52
+ **MiniMax Code**'s white blob on the brand's blue tile, whose gradient is why its
53
+ mask rule is "the darkest channel is still high" rather than a luminance
54
+ threshold. Grok's vendor-published ACP icon is the same mark drawn about one pixel
55
+ bolder; the comparison is recorded in the fork's probe report.
56
+ Marks live in [`src/client/engine-marks.ts`](src/client/engine-marks.ts) as data
57
+ rather than JSX, so a test can assert that every registered engine has one.
58
+
59
+ Both tables are exhaustive over the hosted roster and pinned by tests — the
60
+ failure this prevents is real: when four engines were first added, every one of
61
+ them fell through the mark switch's `default` arm and rendered the DeepSeek fish
62
+ beside its name.
63
+
64
+ ## Engine registry
65
+
66
+ Every engine-shaped decision derives from ONE table,
67
+ [`src/engine-registry.ts`](src/engine-registry.ts): the id roster, the settings
68
+ schema's union, the authored preset ids and display names, the browser half's
69
+ option list and copy keys, and the driver dispatch
70
+ ([`src/engine-drivers.ts`](src/engine-drivers.ts)). Both tables are total over
71
+ the hosted ids, so a half-added engine fails the build rather than shipping an
72
+ engine that mounts but cannot be selected.
73
+
74
+ Each row declares what the surfaces need to know: human-readable label, source
75
+ repo, whether the engine is an npm-bundled dependency or an external CLI, the key
76
+ its executable override reads, its version/update argv, its login hint, its
77
+ credential paths, and its **capabilities** (`streaming`, wire `protocol`,
78
+ `sessionResume`, `permissionModes`, `images`, `reasoningLevels`). Capabilities are
79
+ declarations, not discoveries: a surface never promises more than the engine was
80
+ verified to do, and a driver asked for something outside its declaration refuses
81
+ with the user's next action rather than degrading silently.
82
+
83
+ New engines implement one method. `src/driver-cli/` supplies the rest: the
84
+ turn/step lifecycle (`cli-agent.ts`), the durable-log writer
85
+ (`session-sink.ts` — where the session format's "refuse to load" rules are
86
+ enforced in one place), the subprocess transport, and four protocol skeletons
87
+ (`ndjson`, `stream-json` for the Claude-Code dialect, `text`, plus the existing
88
+ engines' ACP and JSON-RPC drivers as their templates).
89
+
90
+ ## Install
91
+
92
+ ```sh
93
+ # From this repository (the npm package name `dsh-loop-engine-allinone` belongs to
94
+ # upstream, so installing from git names the fork explicitly):
95
+ dsh plugin --profile web add yaliklinty/dsh-loop-engine-allinone
96
+
97
+ # From a local checkout:
98
+ dsh plugin --profile web add /path/to/dsh-loop-engine-allinone
99
+ ```
100
+
101
+ Boot `dsh web` once (the router retries for a bounded window while the base bundle still holds the agent-factory slot), then open **Settings → Loop engine**.
102
+
103
+ **Install notes**
104
+
105
+ - The install rewrites one **engine-agnostic** managed block in the profile's `cordis.patch.yml`; every other byte you wrote there is preserved. Upgrading from an older release needs no hand edit.
106
+ - **Installing into any profile but `web`** — the Desktop app's `desktop`, a `headless` deployment, a renamed profile — needs `profile: <name>` in the composition entry for that profile:
107
+ ```yaml
108
+ - id: loop-engine
109
+ config:
110
+ profile: desktop
111
+ ```
112
+ `profile` defaults to `web`, so without it the plugin writes its managed block into `<home>/profiles/web/cordis.patch.yml` while the running profile never reads it: the plugin mounts, but the base `agent-loop` row is never disabled, so its router cannot take the factory slot and no hosted engine is reachable. (Found by installing into the Desktop app.)
113
+ - **Uninstall** is `dsh plugin --profile web remove dsh-loop-engine-allinone` **plus deleting that managed block** — the block outlives the plugin, and while it is present the profile has no agent factory, so no session can be created.
114
+ - **pnpm 10+** may block dependency build scripts (`ERR_PNPM_IGNORED_BUILDS`, naming `esbuild`, `@google/genai`, `protobufjs`). Run `pnpm approve-builds` (or add an `allowBuilds` entry) and retry; only the installing project can grant this.
115
+ - **Booting the harness from its source checkout** additionally needs the profile's harness peers bridged with `file:` shims — otherwise session resume fails with `agent-presets: refusing to compose an unscoped context`. Steps in [docs/source-checkout.md](docs/source-checkout.md).
116
+
117
+ ## Requirements
118
+
119
+ | Engine | Needs, on the host |
120
+ |---|---|
121
+ | Claude Code | the Claude Code CLI installed and logged in (or none: the SDK ships a bundled binary) |
122
+ | Codex | `codex login`, or a `CODEX_API_KEY` environment entry |
123
+ | Pi | whatever `pi` expects (its own `~/.pi/agent/auth.json`, or the provider's API-key variable) |
124
+ | Kimi Code | the `kimi` CLI installed and logged in, on `PATH` (or pinned via `bins.kimiBin`) |
125
+ | Antigravity | the `agy` CLI installed and signed in to Google |
126
+ | ZCode | the ZCode CLI and a live GLM Coding Plan subscription |
127
+ | Qoder CN | the `qoderclicn` CLI installed and signed in |
128
+ | Hermes Agent | the `hermes` CLI installed and signed in; it reads its own `HERMES_HOME`, which the child inherits |
129
+ | Grok Build | the `grok` CLI installed (`~/.grok/bin/grok.exe`, or `npx @xai-official/grok@<pinned> agent stdio`) and signed in once through `grok` / `grok login` — its ACP server refuses `session/new` until it has an account |
130
+ | MiniMax Code | `npm i -g @minimax-ai/code`, then `mcode login --region cn\|global` and `mcode provider use token-plan` to spend the M Plan allowance instead of an API key |
131
+
132
+ ## Usage
133
+
134
+ - **New session** — pick the engine on the preset chip beside the workspace picker, or keep the deployment's default (`standard`) for the in-process loop. A child agent inherits its parent's engine.
135
+ - **Settings → Loop engine** sets the default for **new** sessions. It lands immediately; running sessions are unaffected. **In-process** restores whatever default the plugin replaced.
136
+ - **Move a session you are in** with the composer's engine selector (enable *Show the engine selector in the chat page*).
137
+ - Hosted → hosted: in place, applies on the spot.
138
+ - Anything involving `in-process`: the composer asks first, then the page reloads and reopens the same session (scroll position and unsent draft are lost; the record is not).
139
+ - A mid-turn session is refused, and a subagent's session cannot be moved.
140
+ - **The header chip** beside the preset label names the engine the session on screen actually runs; *Show the engine badge in the conversation header* turns it off (and the header keeps no trace of the plugin).
141
+ - **Models** — two kinds of group, on purpose.
142
+ - **An engine that declares its own catalog gets a group of its own**, named by the engine (today: `Antigravity`, `Grok Build`, `MiniMax Code`), holding `default` plus the models that engine's own subscription includes. Picking one hands that id to the engine — `agy --model gemini-3.8-flash-low`, or a `session/set_config_option` for the ACP engines — so you choose among the models you actually pay for instead of accepting "the engine decides". `default` still means exactly that.
143
+ - **Every other engine shares the `external` group** with its single `default`. That is not a leftover: the model catalog is built per Host *generation*, not per session, so a group per engine would put eight identical `default` rows in every session's menu. A group only earns its place by carrying models the others do not.
144
+ - Picking a **real dsh model** still hands it to the engine together with its endpoint and credential; whether the engine can serve it is the engine's business, and a refusal is reported rather than swallowed. A pick belonging to a *different* engine's group is refused with the mismatch named, never silently ignored.
145
+ - The catalog is **declared in the engine registry**, not probed at boot — this plugin starts no external process when the harness boots. A deployment whose subscription changed updates [`src/engine-registry.ts`](src/engine-registry.ts)'s `models` row; a stale id then fails loudly at the engine, which is the honest outcome.
146
+ - `in-process` sessions use dsh's models normally.
147
+ - **`bins`** (composition entry, optional) — per-engine executable overrides, keyed by each engine's registry `binConfigKey`. Pointing a **bundled** engine at an external CLI is how it is unbound: `claudeBin` reaches the SDK's own `pathToClaudeCodeExecutable`, while `codexBin` / `piBin` replace the entrypoint those drivers launch. Not setting one keeps the bundled copy and its argv byte for byte:
148
+ ```yaml
149
+ - id: loop-engine
150
+ config:
151
+ bins:
152
+ claudeBin: 'D:/tools/claude.exe'
153
+ kimiBin: 'D:/tools/kimi.exe'
154
+ qoderclicnBin: 'D:/tools/qoderclicn.exe'
155
+ grokBin: 'C:/Users/me/.grok/bin/grok.exe'
156
+ minimaxcodeBin: 'D:/Programs/npm-global/node_modules/@minimax-ai/code/cli.js'
157
+ ```
158
+ An npm-installed CLI needs no pin (the resolver finds the package entrypoint, and
159
+ a Windows `.cmd` shim is launched through `cmd.exe` — node refuses a `.cmd`
160
+ directly), but a pin is the way to choose among several installs.
161
+ - **`regions`** (composition entry, optional) — per-engine account **region**
162
+ overrides, keyed by each registry row's `region.configKey`. Today only MiniMax
163
+ Code declares one (`regions.mcodeRegion`, default `cn`), because its login
164
+ endpoint AND its stored credentials are region-scoped:
165
+ ```yaml
166
+ - id: loop-engine
167
+ config:
168
+ regions:
169
+ mcodeRegion: 'en' # this engine's spelling of the non-China account
170
+ ```
171
+ The value is spelled into the child's environment as the variable that engine's
172
+ CLI actually reads (`MAVIS_REGION` — measured, and NOT `MCODE_REGION`, which is
173
+ inert on the `mcode acp` path). An unknown value, or a `region` that contradicts
174
+ the same variable in `env`, fails the engine's construction loud rather than
175
+ pointing the child at an account nobody chose.
176
+ - **`childIdleMs`** (composition entry, milliseconds, default `0` = off) — Kimi and Codex keep **one child process per session** across steps; this closes it after that much idle time and respawns it on the next step. Only the child is closed, so nothing reloads. Pi and Claude Code spawn per step and are unaffected.
177
+ - **`engineContextWindow`** (composition entry, tokens, default `262144`) — the context window dsh assumes for the shared hosted route. It is what dsh's auto-compaction measures a hosted session against (it fires at 80% of this by default), because a hosted engine reports no capacity of its own. Set it to the **smallest** window among the engines you run.
178
+ - **`summarizerProvider` / `summarizerModel`** (composition entry, **set together or not at all**) — the real dsh model a hosted session's **compaction** summarizes through, e.g. `deepseek-official` / `deepseek-flash`. Compaction is dsh's own (its preset keeps the `compaction` group), but the summarizing *call* is an ordinary llm request, and a hosted session's routed model is the plugin's placeholder route — so without this pair a hosted session can never be folded down: every attempt logs a warning and the turn continues. The pair only serves that call; the engine still answers every user turn itself. Composing just one of the two (or an empty string) is refused at boot, not silently ignored.
179
+ - **dsh's own commands** (`/export`, `/feedback`, `/permission`) keep working under a hosted engine. Its preset is a copy of `standard` with the dsh-native rows an external engine replaces stripped out (dsh's `/plan`, the goal tool and `/goal`, the skill rows). dsh's **compaction is kept**: it is what keeps the session log — and so the transcript replayed to the engine on every step — bounded, which an engine's own per-turn compaction cannot do (a fresh engine session is opened per step, so the engine's shrink is discarded while the log keeps growing). Configure `summarizerProvider` / `summarizerModel` (above) or its summarizing call has no model to run on.
180
+
181
+ ## Version compatibility
182
+
183
+ One release serves the **0.1.5 line** (`>=0.1.5-rc.1 <0.1.6-0`), the **0.1.7 line** (`>=0.1.7-rc.1 <0.1.8-0`) and the **0.2.0 line** (`>=0.2.0-rc.1 <0.2.1-0`): the plugin detects the running generation at load and takes the matching code path. Those union ranges are what it declares in `peerDependencies`, and a harness outside them fails loudly at boot or session resume.
184
+
185
+ Read the version as `<harness line>-rcN`, where **`rcN` is this plugin's own release counter for that line** — not the harness's `rc` number. Within a covered line a new harness `rc` needs no plugin release unless an API surface moved; [docs/compatibility.md](docs/compatibility.md) §1 lists those surfaces and the diff command that decides it.
186
+
187
+ | Plugin | Harness |
188
+ |---|---|
189
+ | `0.2.0-rc1` | `0.2.0-rc.1`, `0.2.0-rc.2` |
190
+ | `0.1.7-rc1` … `0.1.7-rc5` | `0.1.7-rc.1`, `0.1.7-rc.2` |
191
+ | `0.1.5-rc3` … `0.1.5-rc5` | `0.1.5-rc.2` |
192
+ | `0.1.5-rc1` / `0.1.5-rc2` | `0.1.5-rc.1` |
193
+ | `1.0.0-rc8` … `1.0.0-rc15` | `0.1.2-rc.1` |
194
+ | `1.0.0-rc7` and earlier | `0.1.1-rc.2` |
195
+
196
+ `0.2.0-rc1` is the first release that serves three lines at once, and the first one published after the harness started enforcing a peer-range gate at boot: the plugin is still mounted alongside an incompatible one, but a harness outside the ranges above is now skipped by dsh itself rather than failing later.
197
+
198
+ ## Known limitations
199
+
200
+ - **It replaces the harness's agent factory.** One facade serves every session, so the plugin promises to stay out of the way: any session it cannot answer for — including sessions with nothing to do with hosted engines — degrades to the `in-process` loop instead of failing to open. See [docs/per-session-engine.md](docs/per-session-engine.md) §6.
201
+ - **The engine record is a sidecar**, `$DSH_HOME/.loop-engine/engines.json`, not part of the session log: changing machine or `DSH_HOME` loses it and the session falls back to its preset. See §5.5.
202
+ - **Moving a session involving `in-process` reloads the page** — the harness loop neither hands over a live session nor adopts one it did not create. See §5.2/§5.4.
203
+ - **Sessions that already ran a turn** can still move, but only while idle, and the move rebuilds that session's agent. See §5.
204
+ - **Old sessions with the legacy preset id `loop-engine`** read as "legacy hosted engine" until rebuilt once. See §7.
205
+ - **Same-engine sessions share that CLI's own auth directory**, with no lock added by the plugin. See §6.
206
+ - **Switching back to `in-process` leaves the shared `external` group in the model menu** (the catalog is not scoped per session).
207
+
208
+ ## Where the details live
209
+
210
+ - [docs/per-session-engine.md](docs/per-session-engine.md) — the full user-visible behavior (§ numbers above refer to it).
211
+ - [docs/architecture.md](docs/architecture.md) — plugin core: the single factory slot, the managed block, routing, the provider route.
212
+ - [docs/compatibility.md](docs/compatibility.md) — **start here when the harness upgrades**: every generation-dependent code site and the checklist for the next generation.
213
+ - [docs/driver-core.md](docs/driver-core.md) — the shared driver infrastructure.
214
+ - [docs/engine-claude.md](docs/engine-claude.md) · [engine-codex](docs/engine-codex.md) · [engine-kimi](docs/engine-kimi.md) · [engine-pi](docs/engine-pi.md) — per-engine internals. The ACP engines (`kimi` / `grok` / `minimaxcode`) share `driver-acp/`, whose per-engine surface is documented in [docs/engine-registry.md](docs/engine-registry.md) §2 step 6.
215
+ - `scripts/probe/acp-handshake.mjs` · `scripts/probe/smoke-acp.ts` — dump a real ACP engine's frames, or drive one through the plugin's OWN profile (`node node_modules/tsx/dist/cli.mjs scripts/probe/smoke-acp.ts minimaxcode`).
216
+ - [docs/source-checkout.md](docs/source-checkout.md) — the `file:` shims a source-launched harness needs.
217
+ - [docs/optimization-backlog.md](docs/optimization-backlog.md) — known issues and the optimization list.
218
+ - [docs/proposals/](docs/proposals/) — main-repo proposals.
219
+
220
+ ## License
221
+
222
+ MIT — see [LICENSE](LICENSE) for the full text. The upstream author's copyright
223
+ notice is preserved there beside this fork's own; [NOTICE](NOTICE) records what the
224
+ fork adds and what it deliberately leaves untouched.