dsh-loop-engine-allinone 0.0.0-stage → 0.4.0
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 +100 -0
- package/CONTRIBUTING.md +78 -0
- package/LICENSE +23 -0
- package/NOTICE +45 -0
- package/README.md +221 -2
- package/README.zh.md +89 -0
- package/SECURITY.md +39 -0
- package/cordis.patch.yml +3 -0
- package/lib/client.js +2166 -0
- package/lib/index.js +11621 -0
- package/lib/invariant.js +453 -0
- package/lib/types/agent-preset-ids.d.ts +276 -0
- package/lib/types/client/LoopEngineBadge.d.ts +71 -0
- package/lib/types/client/LoopEngineComposerSelect.d.ts +126 -0
- package/lib/types/client/LoopEngineSection.d.ts +35 -0
- package/lib/types/client/engine-marks.d.ts +87 -0
- package/lib/types/client/index.d.ts +39 -0
- package/lib/types/client/locales.d.ts +182 -0
- package/lib/types/client/reload.d.ts +135 -0
- package/lib/types/client/session-engine.d.ts +508 -0
- package/lib/types/client/store.d.ts +103 -0
- package/lib/types/client/turn-status.d.ts +234 -0
- package/lib/types/client/use-session-engine.d.ts +74 -0
- package/lib/types/commands.d.ts +77 -0
- package/lib/types/compat.d.ts +25 -0
- package/lib/types/driver-acp/agent.d.ts +289 -0
- package/lib/types/driver-acp/approval.d.ts +27 -0
- package/lib/types/driver-acp/capabilities.d.ts +200 -0
- package/lib/types/driver-acp/client.d.ts +297 -0
- package/lib/types/driver-acp/executable.d.ts +53 -0
- package/lib/types/driver-acp/mapping.d.ts +76 -0
- package/lib/types/driver-acp/profile.d.ts +126 -0
- package/lib/types/driver-acp/runtime.d.ts +45 -0
- package/lib/types/driver-acp/subprocess.d.ts +19 -0
- package/lib/types/driver-acp/terminal.d.ts +98 -0
- package/lib/types/driver-acp/transport.d.ts +43 -0
- package/lib/types/driver-acp/types.d.ts +152 -0
- package/lib/types/driver-cli/capability.d.ts +42 -0
- package/lib/types/driver-cli/cli-agent.d.ts +258 -0
- package/lib/types/driver-cli/cli-loop.d.ts +46 -0
- package/lib/types/driver-cli/flatten.d.ts +35 -0
- package/lib/types/driver-cli/frames.d.ts +128 -0
- package/lib/types/driver-cli/ndjson.d.ts +106 -0
- package/lib/types/driver-cli/session-sink.d.ts +333 -0
- package/lib/types/driver-cli/stream-json.d.ts +61 -0
- package/lib/types/driver-cli/text.d.ts +66 -0
- package/lib/types/driver-cli/transport.d.ts +84 -0
- package/lib/types/driver-core/agents-md-skill-provider.d.ts +72 -0
- package/lib/types/driver-core/assistant-stream.d.ts +68 -0
- package/lib/types/driver-core/context-files.d.ts +62 -0
- package/lib/types/driver-core/host-servers.d.ts +119 -0
- package/lib/types/driver-core/hosted-engine-runtime.d.ts +190 -0
- package/lib/types/driver-core/hosted-tool-vocabulary.d.ts +78 -0
- package/lib/types/driver-core/idle-child.d.ts +57 -0
- package/lib/types/driver-core/image-access.d.ts +25 -0
- package/lib/types/driver-core/inbox.d.ts +104 -0
- package/lib/types/driver-core/model-handover.d.ts +134 -0
- package/lib/types/driver-core/ownership.d.ts +41 -0
- package/lib/types/driver-core/permission-knobs.d.ts +26 -0
- package/lib/types/driver-core/prompt.d.ts +64 -0
- package/lib/types/driver-core/session-lifetime.d.ts +62 -0
- package/lib/types/driver-core/session-model.d.ts +128 -0
- package/lib/types/driver-core/skill-inject.d.ts +59 -0
- package/lib/types/driver-core/step-close.d.ts +49 -0
- package/lib/types/driver-core/step-images.d.ts +62 -0
- package/lib/types/driver-core/step-tools.d.ts +43 -0
- package/lib/types/driver-core/system-head.d.ts +43 -0
- package/lib/types/engine-agy/agent.d.ts +67 -0
- package/lib/types/engine-agy/frames.d.ts +90 -0
- package/lib/types/engine-agy/loop.d.ts +64 -0
- package/lib/types/engine-agy/process.d.ts +173 -0
- package/lib/types/engine-claude/agent.d.ts +186 -0
- package/lib/types/engine-claude/loop.d.ts +73 -0
- package/lib/types/engine-claude/mapping.d.ts +108 -0
- package/lib/types/engine-claude/permission.d.ts +41 -0
- package/lib/types/engine-claude/process.d.ts +59 -0
- package/lib/types/engine-claude/sdk.d.ts +67 -0
- package/lib/types/engine-claude/types.d.ts +28 -0
- package/lib/types/engine-codex/agent.d.ts +216 -0
- package/lib/types/engine-codex/appserver/client.d.ts +80 -0
- package/lib/types/engine-codex/appserver/mapping.d.ts +67 -0
- package/lib/types/engine-codex/appserver/thread.d.ts +66 -0
- package/lib/types/engine-codex/appserver/types.d.ts +225 -0
- package/lib/types/engine-codex/loop.d.ts +75 -0
- package/lib/types/engine-codex/model-handover.d.ts +56 -0
- package/lib/types/engine-codex/permission.d.ts +126 -0
- package/lib/types/engine-codex/skills.d.ts +28 -0
- package/lib/types/engine-codex/types.d.ts +36 -0
- package/lib/types/engine-drivers.d.ts +132 -0
- package/lib/types/engine-grok/agent.d.ts +24 -0
- package/lib/types/engine-grok/loop.d.ts +61 -0
- package/lib/types/engine-grok/process.d.ts +46 -0
- package/lib/types/engine-grok/profile.d.ts +82 -0
- package/lib/types/engine-hermes/agent.d.ts +47 -0
- package/lib/types/engine-hermes/loop.d.ts +56 -0
- package/lib/types/engine-hermes/process.d.ts +92 -0
- package/lib/types/engine-kimi/acp/client.d.ts +123 -0
- package/lib/types/engine-kimi/acp/mapping.d.ts +73 -0
- package/lib/types/engine-kimi/acp/types.d.ts +143 -0
- package/lib/types/engine-kimi/agent.d.ts +24 -0
- package/lib/types/engine-kimi/commands.d.ts +44 -0
- package/lib/types/engine-kimi/loop.d.ts +62 -0
- package/lib/types/engine-kimi/model-handover.d.ts +32 -0
- package/lib/types/engine-kimi/permission.d.ts +28 -0
- package/lib/types/engine-kimi/process.d.ts +47 -0
- package/lib/types/engine-kimi/profile.d.ts +19 -0
- package/lib/types/engine-kimi/skills.d.ts +52 -0
- package/lib/types/engine-kimi/types.d.ts +25 -0
- package/lib/types/engine-minimaxcode/agent.d.ts +24 -0
- package/lib/types/engine-minimaxcode/loop.d.ts +83 -0
- package/lib/types/engine-minimaxcode/process.d.ts +53 -0
- package/lib/types/engine-minimaxcode/profile.d.ts +72 -0
- package/lib/types/engine-of-session.d.ts +97 -0
- package/lib/types/engine-pi/agent.d.ts +230 -0
- package/lib/types/engine-pi/loop.d.ts +72 -0
- package/lib/types/engine-pi/model-handover.d.ts +84 -0
- package/lib/types/engine-pi/permission.d.ts +47 -0
- package/lib/types/engine-pi/rpc/client.d.ts +107 -0
- package/lib/types/engine-pi/rpc/mapping.d.ts +37 -0
- package/lib/types/engine-pi/rpc/types.d.ts +249 -0
- package/lib/types/engine-pi/skills.d.ts +47 -0
- package/lib/types/engine-pi/types.d.ts +36 -0
- package/lib/types/engine-qoderclicn/agent.d.ts +59 -0
- package/lib/types/engine-qoderclicn/loop.d.ts +51 -0
- package/lib/types/engine-qoderclicn/process.d.ts +113 -0
- package/lib/types/engine-registry.d.ts +584 -0
- package/lib/types/engine-remote.d.ts +192 -0
- package/lib/types/engine-surface.d.ts +36 -0
- package/lib/types/engine-zcode/agent.d.ts +50 -0
- package/lib/types/engine-zcode/loop.d.ts +47 -0
- package/lib/types/engine-zcode/process.d.ts +111 -0
- package/lib/types/index.d.ts +205 -0
- package/lib/types/invariant.d.ts +26 -0
- package/lib/types/model-selection-reset.d.ts +271 -0
- package/lib/types/namespace.d.ts +25 -0
- package/lib/types/patch-manager.d.ts +104 -0
- package/lib/types/preset.d.ts +254 -0
- package/lib/types/provider-route.d.ts +245 -0
- package/lib/types/router-loop.d.ts +458 -0
- package/lib/types/session-engine-store.d.ts +138 -0
- package/lib/types/settings.d.ts +60 -0
- package/lib/types/skills.d.ts +85 -0
- package/package.json +150 -4
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hosted-engine agent presets: one managed copy of the deployment's `standard`
|
|
3
|
+
* preset per hosted engine, with the dsh-native command and skill rows
|
|
4
|
+
* stripped.
|
|
5
|
+
*
|
|
6
|
+
* A hosted engine (Claude Code, Codex, Pi, Kimi) owns its session's command
|
|
7
|
+
* and skill surface: the plugin bridges the engine's own slash commands and
|
|
8
|
+
* skill providers into the session (see `engine-surface.ts`), and the
|
|
9
|
+
* dsh-native equivalents would only duplicate or mislead — dsh `/plan` is
|
|
10
|
+
* advisory prompt text an external engine never assembles, and dsh skills
|
|
11
|
+
* would sit next to the engine's own catalog. Those rows live inside the
|
|
12
|
+
* agent-preset composition, which a profile patch cannot otherwise reach, so
|
|
13
|
+
* the plugin authors a stripped copy of that composition per engine. The
|
|
14
|
+
* compaction group is deliberately NOT stripped: it is what keeps the SESSION
|
|
15
|
+
* LOG bounded, and a hosted engine's own per-turn compaction cannot stand in
|
|
16
|
+
* for it (see {@link STRIPPED_ROWS}).
|
|
17
|
+
*
|
|
18
|
+
* The copy is also where the deployment's summarization model is written
|
|
19
|
+
* ({@link applySummarizerTarget}): compaction summarizes through an ordinary
|
|
20
|
+
* llm call, and a hosted session's routed model is this plugin's placeholder
|
|
21
|
+
* route, so without a real dsh model named at
|
|
22
|
+
* `compaction-basic.config.summarizationProvider` / `summarizationModel` the
|
|
23
|
+
* group can never shrink anything. A profile patch cannot reach that nested
|
|
24
|
+
* row (a row's `config` is replaced whole), which leaves the composition the
|
|
25
|
+
* plugin authors as the one carrier.
|
|
26
|
+
*
|
|
27
|
+
* WHICH mechanism carries that copy is the running harness generation's
|
|
28
|
+
* business, and the two share everything but the carrier:
|
|
29
|
+
*
|
|
30
|
+
* - the 0.1.5 line reads presets from a DIRECTORY per preset under the user
|
|
31
|
+
* preset root (`$DSH_HOME/.agent-presets/<id>`), so there it is two files
|
|
32
|
+
* per engine ({@link ensureEnginePresets});
|
|
33
|
+
* - the 0.1.7 line replaced that with composed plugin rows: a preset is one
|
|
34
|
+
* `@deepseek-ai/dsh-agent-preset` row whose `config.plugins` list IS the
|
|
35
|
+
* composition, declared wherever a composition is declared. Nothing reads
|
|
36
|
+
* `.agent-presets` any more, so there it is four `insert` rows in the
|
|
37
|
+
* profile patch the plugin already manages
|
|
38
|
+
* ({@link ensureEnginePresetRows}). The rows mirror the shipped shape
|
|
39
|
+
* (`packages/bundle/web-app/presets/standard.patch.yml` in the harness),
|
|
40
|
+
* with this plugin's own id, order, and stripped composition.
|
|
41
|
+
*
|
|
42
|
+
* Both mechanisms regenerate from the current `standard` composition on every
|
|
43
|
+
* boot: text on disk is never authoritative, so a harness upgrade that changes
|
|
44
|
+
* `standard` flows through. Neither re-parses YAML — the strip is a line
|
|
45
|
+
* transform that preserves everything it does not drop byte for byte, comments
|
|
46
|
+
* included, and the row form only re-indents that text.
|
|
47
|
+
*
|
|
48
|
+
* The preset id is ALSO the per-session engine selector: the harness resolves
|
|
49
|
+
* one preset per session and hands its id to the agent factory at create time
|
|
50
|
+
* (`CreateAgentOptions.meta.agentPreset`), which is the only per-session
|
|
51
|
+
* channel that reaches agent creation. One preset per engine is therefore what
|
|
52
|
+
* makes "session A on Codex, session B on Kimi, concurrently" expressible in a
|
|
53
|
+
* harness that admits exactly one AgentFactory.
|
|
54
|
+
*
|
|
55
|
+
* @module dsh-loop-engine-allinone/preset
|
|
56
|
+
*/
|
|
57
|
+
export { HOSTED_PRESET_PREFIX, SOURCE_PRESET_ID, engineOfPreset, enginePresetId, hostedEngineOf, sessionEngineOf, } from './agent-preset-ids.ts';
|
|
58
|
+
export type { SessionEngine } from './agent-preset-ids.ts';
|
|
59
|
+
/** Harness-home-relative directory of locally authored presets (mirrors `USER_PRESET_DIR` in `dsh-agent-presets`). */
|
|
60
|
+
export declare const USER_PRESET_DIR = ".agent-presets";
|
|
61
|
+
/** The composition file that makes a directory a preset. */
|
|
62
|
+
export declare const COMPOSITION_FILE = "agent.cordis.yml";
|
|
63
|
+
/** The display-metadata file beside a preset's composition. */
|
|
64
|
+
export declare const METADATA_FILE = "preset.yml";
|
|
65
|
+
/** Every preset id this plugin owns, whether or not it is currently authored. */
|
|
66
|
+
export declare const HOSTED_PRESET_IDS: readonly string[];
|
|
67
|
+
/**
|
|
68
|
+
* Top-level rows stripped from the source preset for hosted engines:
|
|
69
|
+
* - `skill-filesystem` / `tool-skill`: the dsh skill surface — each engine
|
|
70
|
+
* registers its own skill provider in the session's agent scope;
|
|
71
|
+
* - `tool-goal` / `command-goal`: dsh's goal mode. The model-facing tool only
|
|
72
|
+
* works while an in-process loop drives the session, and the human command
|
|
73
|
+
* would sit in the menu with nothing behind it — no hosted engine here
|
|
74
|
+
* implements `/goal`, so there is nothing for it to hand over to. The
|
|
75
|
+
* `command-goal` row lives HERE, in the preset layer, because that is where
|
|
76
|
+
* the human command is registered; disabling the host-plane row from the
|
|
77
|
+
* profile patch does not reach it (`standard` carries its own row);
|
|
78
|
+
* - `planning`: dsh plan mode — its only model-visible effect is a system
|
|
79
|
+
* prompt section an external engine never assembles.
|
|
80
|
+
*
|
|
81
|
+
* The `compaction` group is KEPT, and must stay kept: it is what bounds the
|
|
82
|
+
* SESSION LOG, which every hosted step replays in full as its engine prompt
|
|
83
|
+
* (`src/driver-core/prompt.ts`). A hosted engine's own compaction cannot stand
|
|
84
|
+
* in for it — the engine's context is thrown away, because the driver opens a
|
|
85
|
+
* fresh engine session per step (`session/new` for Kimi, a new thread / query
|
|
86
|
+
* for the others), so its shrink lasts one step while the log keeps growing and
|
|
87
|
+
* each later step replays everything again. Measured on a real 33-turn Kimi
|
|
88
|
+
* session: ~3.3 MB replayed per step (tool results 2.0 MB + tool-call lines
|
|
89
|
+
* 1.19 MB), which the Kimi CLI auto-compacted from ~918k tokens down to ~47k at
|
|
90
|
+
* the start of every turn — and discarded. Keeping this group is what lets dsh
|
|
91
|
+
* write its own durable checkpoints instead. The route needs a declared
|
|
92
|
+
* capacity for that to fire: see `DEFAULT_ENGINE_CONTEXT_WINDOW`
|
|
93
|
+
* (`src/provider-route.ts`) and the `engineContextWindow` Config field
|
|
94
|
+
* (`src/index.ts`).
|
|
95
|
+
*/
|
|
96
|
+
export declare const STRIPPED_ROWS: readonly ["skill-filesystem", "tool-skill", "tool-goal", "command-goal", "planning"];
|
|
97
|
+
/**
|
|
98
|
+
* Begin marker of the plugin-managed preset-rows region inside a profile patch
|
|
99
|
+
* file. The region is what registers the hosted engines' presets on the 0.1.7
|
|
100
|
+
* line, where a preset is a composed row rather than a directory.
|
|
101
|
+
*
|
|
102
|
+
* Deliberately NOT the managed block's marker: the two regions are located and
|
|
103
|
+
* rewritten independently, so editing one never rewrites the other's bytes.
|
|
104
|
+
*/
|
|
105
|
+
export declare const PRESET_ROWS_BEGIN = "# -- dsh-loop-engine presets --";
|
|
106
|
+
/** End marker of the plugin-managed preset-rows region inside a profile patch file. */
|
|
107
|
+
export declare const PRESET_ROWS_END = "# -- /dsh-loop-engine presets --";
|
|
108
|
+
/**
|
|
109
|
+
* Roster order of every preset this plugin authors. The shipped presets occupy
|
|
110
|
+
* 1..4 (`standard` 1, `ptc` 2, `minimal` 3, `cordis` 4), and the roster sorts
|
|
111
|
+
* by order and then by id, so one constant past that range puts every managed
|
|
112
|
+
* preset after every shipped one — the deployment's own presets stay at the top
|
|
113
|
+
* of the picker and the engines' copies trail it, which is also where the
|
|
114
|
+
* order they are listed in (selection order) is readable.
|
|
115
|
+
*/
|
|
116
|
+
export declare const ENGINE_PRESET_ORDER = 100;
|
|
117
|
+
/**
|
|
118
|
+
* Entry id of the harness plugin whose `config` names the dsh model a hosted
|
|
119
|
+
* session's compaction summarizes through
|
|
120
|
+
* (`@deepseek-ai/dsh-compaction-basic`, a child of the `compaction` group).
|
|
121
|
+
* See {@link applySummarizerTarget} for why the plugin writes it.
|
|
122
|
+
*/
|
|
123
|
+
export declare const SUMMARIZER_ENTRY_ID = "compaction-basic";
|
|
124
|
+
/**
|
|
125
|
+
* The dsh model a hosted session's compaction summarizes through: a real dsh
|
|
126
|
+
* provider route and an exact model id on it, never this plugin's placeholder
|
|
127
|
+
* route.
|
|
128
|
+
*
|
|
129
|
+
* The pair exists because compaction summarizes by making an ordinary llm call
|
|
130
|
+
* (`packages/compaction/compaction-basic/src/summarizer.ts` `resolveTarget`),
|
|
131
|
+
* and a hosted session's routed model is this plugin's own placeholder
|
|
132
|
+
* (`external/default`), whose `stream()` fails loud
|
|
133
|
+
* (`src/provider-route.ts`). See {@link applySummarizerTarget}.
|
|
134
|
+
*/
|
|
135
|
+
export interface SummarizerTarget {
|
|
136
|
+
/** Dsh provider route the summarization request is sent to. */
|
|
137
|
+
readonly provider: string;
|
|
138
|
+
/** Exact model id on that route. */
|
|
139
|
+
readonly model: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The managed preset-rows region: one preset row per hosted engine, bracketed
|
|
143
|
+
* by the markers that make it locatable and rewritable.
|
|
144
|
+
* @param composition - the source `standard` composition.
|
|
145
|
+
* @param target - the summarization model to write into every copy, or
|
|
146
|
+
* undefined to leave the copies exactly as the strip left them.
|
|
147
|
+
* @returns the region's text, ending in a newline.
|
|
148
|
+
*/
|
|
149
|
+
export declare function renderPresetRows(composition: string, target?: SummarizerTarget): string;
|
|
150
|
+
/**
|
|
151
|
+
* Produce the next patch-file text carrying the preset-rows region, preserving
|
|
152
|
+
* every byte outside that span — including the managed block, which is located
|
|
153
|
+
* by its own markers. Appends the region when absent and replaces it when
|
|
154
|
+
* present, so an unchanged composition leaves the text byte for byte identical.
|
|
155
|
+
*
|
|
156
|
+
* The region is a root-level collection like the managed block, so a leftover
|
|
157
|
+
* seed `[]` is dropped with it: two root collections in one document is YAML
|
|
158
|
+
* the harness rejects, and the profile would stop booting.
|
|
159
|
+
* @param text - current patch-file text.
|
|
160
|
+
* @param composition - the source `standard` composition.
|
|
161
|
+
* @param target - the summarization model to write into every copy, or
|
|
162
|
+
* undefined to leave the copies exactly as the strip left them.
|
|
163
|
+
* @returns the rewritten patch-file text.
|
|
164
|
+
*/
|
|
165
|
+
export declare function applyEnginePresetRows(text: string, composition: string, target?: SummarizerTarget): string;
|
|
166
|
+
/**
|
|
167
|
+
* Remove top-level entries by id from a preset composition, preserving every
|
|
168
|
+
* other byte. Each entry owns the comment/blank run directly above its opener
|
|
169
|
+
* — that run is the entry's section heading and drops with it — except the
|
|
170
|
+
* run above the FIRST entry, which is the file header and stays. Entries
|
|
171
|
+
* without an `id` opener are always kept: the transform touches only what it
|
|
172
|
+
* can name.
|
|
173
|
+
* @param text - the source composition.
|
|
174
|
+
* @param ids - top-level row ids to strip.
|
|
175
|
+
* @returns the stripped composition.
|
|
176
|
+
*/
|
|
177
|
+
export declare function stripPresetRows(text: string, ids?: readonly string[]): string;
|
|
178
|
+
/**
|
|
179
|
+
* Name the dsh model a hosted session's compaction summarizes through, inside
|
|
180
|
+
* the composition this plugin authors.
|
|
181
|
+
*
|
|
182
|
+
* Compaction summarizes by making an ordinary llm call, and it resolves that
|
|
183
|
+
* call's target from `config.summarizationProvider` / `config.summarizationModel`
|
|
184
|
+
* when both are set — otherwise from the agent's routed model
|
|
185
|
+
* (`packages/compaction/compaction-basic/src/summarizer.ts` `resolveTarget`).
|
|
186
|
+
* For a hosted session the routed model IS this plugin's placeholder route
|
|
187
|
+
* (`external/default`), whose `stream()` fails loud by design, so without this
|
|
188
|
+
* pair every compaction attempt there dies with `HOSTED_ENGINE_ROUTE` — caught
|
|
189
|
+
* by the `agent/pre-step` listener as a warning, so the turn continues but the
|
|
190
|
+
* session log never shrinks.
|
|
191
|
+
*
|
|
192
|
+
* The plugin writes the pair HERE because there is nowhere else to write it: a
|
|
193
|
+
* profile-patch row replaces the whole `config` of the row it names, and the
|
|
194
|
+
* patch index only descends into a `group: true` row's `config` array — a
|
|
195
|
+
* preset's entries live in `config.plugins`, a plain field, so naming the pair
|
|
196
|
+
* from the profile means re-declaring the entire `standard` composition. The
|
|
197
|
+
* composition the plugin authors itself is therefore the one place a
|
|
198
|
+
* deployment-side value can reach a nested row.
|
|
199
|
+
*
|
|
200
|
+
* The two keys land in `entryId`'s own `config:` mapping: an existing `config:`
|
|
201
|
+
* block is merged into (never duplicated, and without emitting a key the entry
|
|
202
|
+
* already carries), and a missing one is appended after the entry's last key at
|
|
203
|
+
* the entry's own indentation. Text without the entry, and any call with an
|
|
204
|
+
* undefined target, comes back byte for byte unchanged.
|
|
205
|
+
* @param text - the composition text (typically the stripped `standard`).
|
|
206
|
+
* @param target - the summarization model to write, or undefined to do nothing.
|
|
207
|
+
* @param entryId - id of the entry whose `config` receives the pair.
|
|
208
|
+
* @returns the composition text carrying the pair under `entryId`.
|
|
209
|
+
*/
|
|
210
|
+
export declare function applySummarizerTarget(text: string, target: SummarizerTarget | undefined, entryId?: string): string;
|
|
211
|
+
/** Minimal read seam over the host's preset roster, per harness generation. */
|
|
212
|
+
export interface PresetCompositionSource {
|
|
213
|
+
/** 0.1.5 line: read one preset's composition text; throws when the id is unknown. */
|
|
214
|
+
read?(id: string): Promise<string>;
|
|
215
|
+
/** 0.1.7 line: read one preset's document; `content` is the composition text. */
|
|
216
|
+
readDocument?(id: string): Promise<{
|
|
217
|
+
readonly content: string;
|
|
218
|
+
}>;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Regenerate every hosted engine's preset under the dsh home's user preset root
|
|
222
|
+
* from the roster's `standard` preset. Idempotent: an up-to-date directory is
|
|
223
|
+
* untouched, so no standing mount sees a spurious file-stamp change.
|
|
224
|
+
* @param dshHome - the resolved harness home.
|
|
225
|
+
* @param source - the roster's composition reader.
|
|
226
|
+
* @param target - the summarization model to write into every copy, or
|
|
227
|
+
* undefined to leave the copies exactly as the strip left them.
|
|
228
|
+
* @returns whether any file was written.
|
|
229
|
+
* @throws when the source preset cannot be read or the writes fail.
|
|
230
|
+
*/
|
|
231
|
+
export declare function ensureEnginePresets(dshHome: string, source: PresetCompositionSource, target?: SummarizerTarget): Promise<boolean>;
|
|
232
|
+
/**
|
|
233
|
+
* Regenerate every hosted engine's preset as an `insert` row in the profile
|
|
234
|
+
* patch the plugin already manages, from the roster's `standard` preset.
|
|
235
|
+
*
|
|
236
|
+
* This is the 0.1.7 mechanism: a preset there is a composed plugin row, and the
|
|
237
|
+
* user preset root is not read at all — so a preset written as a directory
|
|
238
|
+
* would simply never register, leaving the roster without the id every hosted
|
|
239
|
+
* session records. The rows go in the profile's own `cordis.patch.yml` because
|
|
240
|
+
* that is the one composition layer the plugin owns: it is already the file the
|
|
241
|
+
* managed block lives in, it is applied after the bundle's own preset rows, and
|
|
242
|
+
* a rewrite of it is what the harness's live patch reload picks up.
|
|
243
|
+
*
|
|
244
|
+
* Idempotent: an up-to-date region is left byte for byte alone, so a rewrite
|
|
245
|
+
* that changes nothing does not touch the file's stamp.
|
|
246
|
+
* @param patchPath - absolute path of the profile's patch file.
|
|
247
|
+
* @param source - the roster's composition reader.
|
|
248
|
+
* @param target - the summarization model to write into every copy, or
|
|
249
|
+
* undefined to leave the copies exactly as the strip left them.
|
|
250
|
+
* @returns whether the patch file was written.
|
|
251
|
+
* @throws when the source preset cannot be read or the write fails.
|
|
252
|
+
*/
|
|
253
|
+
export declare function ensureEnginePresetRows(patchPath: string, source: PresetCompositionSource, target?: SummarizerTarget): Promise<boolean>;
|
|
254
|
+
//# sourceMappingURL=preset.d.ts.map
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hosted-engine provider route placeholder.
|
|
3
|
+
*
|
|
4
|
+
* Every hosted engine logs its sessions' request/header with ONE shared provider
|
|
5
|
+
* label ({@link HOSTED_ROUTE_LABEL}, `external`) rather than a model endpoint the
|
|
6
|
+
* harness llm registry serves — the engine owns its model natively. The web
|
|
7
|
+
* host derives a session's model selection from that header and refuses a turn
|
|
8
|
+
* whose provider no registered adapter serves, so without a placeholder route
|
|
9
|
+
* the SECOND prompt of every hosted session fails with `model-unavailable`.
|
|
10
|
+
*
|
|
11
|
+
* One label for every hosted engine, because the browser model catalog is built
|
|
12
|
+
* per Host GENERATION and does not require (or vary by) a Session
|
|
13
|
+
* (`packages/api/session-controller/src/catalog.ts`). A per-engine label would
|
|
14
|
+
* therefore show one provider group per engine in every session's menu at once —
|
|
15
|
+
* four identical `default` entries — so they are collapsed into this one route.
|
|
16
|
+
*
|
|
17
|
+
* Serving the label is only half of it. The model menu renders the session's
|
|
18
|
+
* selection through the catalog, and a provider group that advertises no models
|
|
19
|
+
* is dropped (`packages/api/session-controller/src/catalog.ts`, non-empty
|
|
20
|
+
* groups only) — leaving the seat to show the raw `provider/model` string, i.e.
|
|
21
|
+
* a model that does not exist to any adapter. So the placeholder advertises
|
|
22
|
+
* exactly ONE entry, {@link HOSTED_DEFAULT_MODEL}:
|
|
23
|
+
* `{ provider: HOSTED_ROUTE_LABEL, id: 'default', name: 'default' }`. The id is
|
|
24
|
+
* the same string every engine logs as its model label, which is what makes the
|
|
25
|
+
* seat resolve the session's `(provider, model)` to this entry and render the
|
|
26
|
+
* engine's own word for "whatever it decides" instead of a composite string
|
|
27
|
+
* (see {@link HOSTED_DEFAULT_MODEL} for the host-side mechanism).
|
|
28
|
+
*
|
|
29
|
+
* The entry is not a model this plugin can serve: {@link HostedEngineRouteAdapter.stream}
|
|
30
|
+
* fails loud, because a real model call reaching one of these routes means a
|
|
31
|
+
* session the harness loop drives was handed an engine label — a wiring bug,
|
|
32
|
+
* not a request. Two things keep that from happening: a session switched back
|
|
33
|
+
* to `in-process` has the deployment default written into its log
|
|
34
|
+
* (`model-selection-reset.ts`), and a session BUILT on `in-process` whose
|
|
35
|
+
* selection is one of these labels has it replaced by the same authority before
|
|
36
|
+
* the host installs it (same module, `guardFor`).
|
|
37
|
+
*
|
|
38
|
+
* @module dsh-loop-engine-allinone/provider-route
|
|
39
|
+
*/
|
|
40
|
+
import type { GenerateOptions, LlmModelInfo, LlmProviderInfo, LlmResolvedModelInfo, ModelModality, StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
41
|
+
import { LlmAdapter } from '@deepseek-ai/dsh-llm';
|
|
42
|
+
import { type EngineModel } from './engine-registry.ts';
|
|
43
|
+
import type { HostedEngineId } from './settings.ts';
|
|
44
|
+
/**
|
|
45
|
+
* Context window this plugin declares for the hosted route when a deployment
|
|
46
|
+
* pins none: 262144 tokens (256 Ki).
|
|
47
|
+
*
|
|
48
|
+
* The number exists because dsh's own auto-compaction sizes its pressure
|
|
49
|
+
* threshold from the routed model's declared capacity
|
|
50
|
+
* (`packages/compaction/compaction-basic/src/config.ts` `resolveCompactSpec` —
|
|
51
|
+
* `contextWindow * thresholdRatio`, ratio defaulting to `0.8`). A hosted engine
|
|
52
|
+
* reports no capacity at all: its model lives inside its own child process, so
|
|
53
|
+
* the placeholder route is the only place dsh can read one. 256 Ki is the round
|
|
54
|
+
* window the hosted CLIs in use expose; a deployment whose engine window is
|
|
55
|
+
* smaller, or whose engines differ, should set `engineContextWindow` to the
|
|
56
|
+
* smallest window in use (see `src/index.ts`).
|
|
57
|
+
*/
|
|
58
|
+
export declare const DEFAULT_ENGINE_CONTEXT_WINDOW = 262144;
|
|
59
|
+
/**
|
|
60
|
+
* The input modalities this route's single entry declares: text AND image.
|
|
61
|
+
*
|
|
62
|
+
* Every hosted engine is handed the images of the step's own messages —
|
|
63
|
+
* `pi`/`kimi` as bytes over their RPC/ACP channels, `codex` as a `localImage`
|
|
64
|
+
* path the app-server opens itself, `claude-code` as base64 blocks appended to
|
|
65
|
+
* the prompt's streaming input message (the prompt's image placeholder still
|
|
66
|
+
* names the readable path; see `docs/driver-core.md` §2 and
|
|
67
|
+
* `docs/engine-claude.md` §9.1). The capability
|
|
68
|
+
* therefore belongs to the route, which is what the host asks about; which
|
|
69
|
+
* shape of handover an engine gets is that engine's business, not the session's.
|
|
70
|
+
*/
|
|
71
|
+
export declare const HOSTED_MODEL_MODALITIES: readonly ModelModality[];
|
|
72
|
+
/**
|
|
73
|
+
* The provider route label one hosted engine logs into its sessions'
|
|
74
|
+
* request/header.
|
|
75
|
+
*
|
|
76
|
+
* **Two kinds of label, on purpose.**
|
|
77
|
+
*
|
|
78
|
+
* An engine that declares its own model catalog (`descriptor.models`,
|
|
79
|
+
* `engine-registry.ts`) gets a route of ITS OWN, named by its engine id. The
|
|
80
|
+
* model menu then shows a group per such engine — `agy` holding
|
|
81
|
+
* `default` plus Gemini/Claude ids — and picking one passes that id to the
|
|
82
|
+
* engine.
|
|
83
|
+
*
|
|
84
|
+
* Every other engine keeps the shared {@link HOSTED_ROUTE_LABEL} (`external`)
|
|
85
|
+
* with its single `default`. That is not a leftover: the browser model catalog
|
|
86
|
+
* is built per Host GENERATION rather than per session
|
|
87
|
+
* (`packages/api/session-controller/src/catalog.ts`), so a group per engine
|
|
88
|
+
* would put eight identical `default` rows in every session's menu — the exact
|
|
89
|
+
* noise the shared label exists to avoid. A group only earns its place in that
|
|
90
|
+
* menu by carrying models the others do not.
|
|
91
|
+
*
|
|
92
|
+
* Both kinds stay registered, so a session logged either way keeps resolving.
|
|
93
|
+
* @param engine - the hosted engine whose route label is asked for.
|
|
94
|
+
* @returns that engine's route label.
|
|
95
|
+
*/
|
|
96
|
+
export declare function hostedRouteLabelOf(engine: HostedEngineId): string;
|
|
97
|
+
/**
|
|
98
|
+
* The hosted engine whose own route a provider label names, if any.
|
|
99
|
+
*
|
|
100
|
+
* The inverse of the per-engine half of {@link hostedRouteLabelOf}, for the
|
|
101
|
+
* places that must attribute a selection to an engine — chiefly the refusal a
|
|
102
|
+
* driver owes when a session picks a model belonging to a DIFFERENT engine.
|
|
103
|
+
* @param provider - a provider label from a selection.
|
|
104
|
+
* @returns the engine that label belongs to, or undefined for the shared route
|
|
105
|
+
* and for anything that is not one of this plugin's routes.
|
|
106
|
+
*/
|
|
107
|
+
export declare function hostedEngineOfRouteLabel(provider: string): HostedEngineId | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Whether a provider is one of this plugin's hosted engine route labels — a
|
|
110
|
+
* label some hosted engine logs (now, or in an earlier build), which no adapter
|
|
111
|
+
* serves a real model on.
|
|
112
|
+
*
|
|
113
|
+
* The OLD four per-engine labels are members on purpose, even though only
|
|
114
|
+
* {@link HOSTED_ROUTE_LABEL} is registered. A pre-existing session's header
|
|
115
|
+
* still names one of them; treating only the current label as hosted would let
|
|
116
|
+
* such a session keep the stale selection, and the host — which finds no
|
|
117
|
+
* adapter serving `kimi` any more — would refuse its next turn
|
|
118
|
+
* (`model-unavailable`). Membership here is what lets `model-selection-reset`
|
|
119
|
+
* rewrite the seat to `external/default` (or the deployment default) first.
|
|
120
|
+
* @param provider - the provider of any selection, header, or default.
|
|
121
|
+
* @returns whether that provider is a hosted engine's route label.
|
|
122
|
+
*/
|
|
123
|
+
export declare function isHostedProviderRoute(provider: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Placeholder adapter serving the one hosted engine provider route label.
|
|
126
|
+
*
|
|
127
|
+
* It advertises the single menu entry ({@link HOSTED_DEFAULT_MODEL}) so the
|
|
128
|
+
* model seat can name the session's selection, carries the route's display name
|
|
129
|
+
* ({@link HOSTED_ROUTE_NAME}) so the catalog's provider group is labelled
|
|
130
|
+
* `external`, and {@link stream} fails loud: a call reaching it means a real model
|
|
131
|
+
* query was routed to an engine that owns its model natively — a wiring bug, not
|
|
132
|
+
* a request to serve.
|
|
133
|
+
*
|
|
134
|
+
* It also DECLARES a context window for the route ({@link resolveModel}): the
|
|
135
|
+
* window is what dsh's auto-compaction measures its pressure threshold against,
|
|
136
|
+
* and a hosted engine reports no capacity of its own, so without one the hosted
|
|
137
|
+
* session never compacts.
|
|
138
|
+
*/
|
|
139
|
+
export declare class HostedEngineRouteAdapter extends LlmAdapter {
|
|
140
|
+
/**
|
|
141
|
+
* Capacity this route declares, normalized at construction.
|
|
142
|
+
*
|
|
143
|
+
* A deployment knob rather than a constant because the engines' real windows
|
|
144
|
+
* differ; the adapter only guarantees the value the registry's validation
|
|
145
|
+
* accepts (a positive integer), so a non-positive or non-integer wire value
|
|
146
|
+
* cannot reach the compaction path as a nonsense window.
|
|
147
|
+
*/
|
|
148
|
+
private readonly contextWindow;
|
|
149
|
+
/**
|
|
150
|
+
* @param contextWindow - declared context capacity in tokens. A value that is
|
|
151
|
+
* not a positive integer (absent included) falls back to
|
|
152
|
+
* {@link DEFAULT_ENGINE_CONTEXT_WINDOW}.
|
|
153
|
+
*/
|
|
154
|
+
/**
|
|
155
|
+
* The provider label this adapter was registered for, echoed by every method
|
|
156
|
+
* (the registry rejects an identity mismatch).
|
|
157
|
+
*/
|
|
158
|
+
private readonly label;
|
|
159
|
+
/**
|
|
160
|
+
* The engine-native models this route advertises, beyond `default`.
|
|
161
|
+
*
|
|
162
|
+
* Empty for the shared `external` route: an engine with no declared catalog
|
|
163
|
+
* has nothing to add to "the engine decides".
|
|
164
|
+
*/
|
|
165
|
+
private readonly models;
|
|
166
|
+
/**
|
|
167
|
+
* The name this route's group shows in the model menu.
|
|
168
|
+
*
|
|
169
|
+
* A separate field from {@link label}: the label is the WIRE value (the engine
|
|
170
|
+
* id, which the registry compares against the registration), while this is what
|
|
171
|
+
* a human reads. Conflating them would put `agy` in the menu instead of
|
|
172
|
+
* `Antigravity`.
|
|
173
|
+
*/
|
|
174
|
+
private readonly displayName;
|
|
175
|
+
/**
|
|
176
|
+
* @param contextWindow - declared context capacity in tokens.
|
|
177
|
+
* @param label - the provider label this adapter serves (a wire value).
|
|
178
|
+
* @param models - the engine-native models to advertise beside `default`.
|
|
179
|
+
* @param displayName - the group name shown in the model menu.
|
|
180
|
+
*/
|
|
181
|
+
constructor(contextWindow?: number, label?: string, models?: readonly EngineModel[], displayName?: string);
|
|
182
|
+
/**
|
|
183
|
+
* Name the route's one entry.
|
|
184
|
+
*
|
|
185
|
+
* `id` must equal the provider the adapter was registered for (the registry
|
|
186
|
+
* rejects a mismatch — `packages/llm/llm/src/index.ts` `prepareRoutes`), so it
|
|
187
|
+
* is echoed back; `name` is the one localized string the catalog carries.
|
|
188
|
+
* @param provider - the route this adapter is registered for.
|
|
189
|
+
* @returns the route's display metadata.
|
|
190
|
+
*/
|
|
191
|
+
providerInfo(provider: string): LlmProviderInfo;
|
|
192
|
+
/**
|
|
193
|
+
* Advertise the route's single entry.
|
|
194
|
+
*
|
|
195
|
+
* The id is the model label the engine logs, so the picker resolves a hosted
|
|
196
|
+
* session's selection to this entry (and highlights its row) rather than
|
|
197
|
+
* falling through to the raw composite string; the name is the same word,
|
|
198
|
+
* rendered as-is.
|
|
199
|
+
*
|
|
200
|
+
* {@link HOSTED_MODEL_MODALITIES} is declared, not left absent, because the
|
|
201
|
+
* host reads it as a capability: `packages/api/session-controller/src/commands.ts`
|
|
202
|
+
* refuses a prompt carrying an image when the session's model declares
|
|
203
|
+
* modalities that exclude `image`, and `LlmModelInfo` documents an absent
|
|
204
|
+
* field as UNKNOWN. A hosted session's fate for an attached image therefore
|
|
205
|
+
* has to be something this plugin SAYS, not something a missing field happens
|
|
206
|
+
* to allow — while a field this plugin omits, or the harness stops treating
|
|
207
|
+
* as unknown, silently turns every hosted session image-blind.
|
|
208
|
+
*
|
|
209
|
+
* No capacity is declared here, because `LlmModelInfo` (the catalog shape this
|
|
210
|
+
* method returns) has no context field at all; the window rides
|
|
211
|
+
* {@link resolveModel}, the shape the harness asks about capacity through.
|
|
212
|
+
* @returns the one entry this route advertises.
|
|
213
|
+
*/
|
|
214
|
+
listModels(provider: string): Promise<readonly LlmModelInfo[]>;
|
|
215
|
+
/**
|
|
216
|
+
* Resolve the route's one entry for the exact model label asked about, with
|
|
217
|
+
* the context window dsh needs to size auto-compaction.
|
|
218
|
+
*
|
|
219
|
+
* The capacity rides HERE rather than on {@link listModels}' entry because the
|
|
220
|
+
* two are different harness concepts: `LlmModelInfo` — what the catalog and
|
|
221
|
+
* the model menu read — has no capacity field, while `LlmResolvedModelInfo` —
|
|
222
|
+
* what `ctx.llm.resolveModelInfo` returns — carries the optional
|
|
223
|
+
* `context: { contextWindow }`. dsh's compaction pressure path calls the
|
|
224
|
+
* latter for the session's latest routed model
|
|
225
|
+
* (`packages/compaction/compaction-basic/src/index.ts` `compactIfNeeded`) and
|
|
226
|
+
* throws `TargetPressureConfigError` — swallowed into a one-time warning, so
|
|
227
|
+
* compaction simply never fires — when it comes back without a window. A
|
|
228
|
+
* hosted session's log therefore only stays bounded because this method
|
|
229
|
+
* answers with one.
|
|
230
|
+
*
|
|
231
|
+
* `provider` and `id` are echoed exactly as asked: `normalizeModelInfo`
|
|
232
|
+
* (`packages/llm/llm/src/index.ts`) rejects a result whose identity does not
|
|
233
|
+
* match the query, and the model label a hosted session logged is the engine's
|
|
234
|
+
* own word (`default`, or whatever a deployment pinned in `config.model`), not
|
|
235
|
+
* always {@link HOSTED_DEFAULT_MODEL}. `name` is the same string, matching the
|
|
236
|
+
* advertised entry, since `LlmModelInfo.name` is rendered verbatim.
|
|
237
|
+
* @param provider - the route this adapter is registered for.
|
|
238
|
+
* @param model - the exact model label the session's `request/header` logged.
|
|
239
|
+
* @param _signal - unused; resolution is synchronous.
|
|
240
|
+
* @returns the route's entry with its declared context window.
|
|
241
|
+
*/
|
|
242
|
+
resolveModel(provider: string, model: string, _signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
|
|
243
|
+
stream(_options: GenerateOptions): AsyncIterable<StreamChunk>;
|
|
244
|
+
}
|
|
245
|
+
//# sourceMappingURL=provider-route.d.ts.map
|