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
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Package-owned invariant companion for the loop engine selection.
3
+ *
4
+ * The plugin's owned relationship is the patch-manager round trip: applying the
5
+ * managed block must be a fixed point, the block must be the one that frees the
6
+ * single AgentFactory slot for the router, a legacy block naming a single engine
7
+ * must be migrated to the engine-agnostic form while still being readable as a
8
+ * legacy pin, and a comment-only layer must be re-seeded to a loadable
9
+ * top-level array rather than left as `null`. The companion asserts those
10
+ * against the pure transform, binding the writer's inverse to the reader
11
+ * directly.
12
+ *
13
+ * @module dsh-loop-engine-allinone/invariant
14
+ */
15
+ import type { Context } from '@deepseek-ai/cordis';
16
+ /** Cordis companion plugin name. */
17
+ export declare const name = "loop-engine-invariant";
18
+ /** Services required before the companion can register. */
19
+ export declare const inject: string[];
20
+ /**
21
+ * Register the loop-engine invariant contribution.
22
+ * @param ctx - Cordis context carrying the invariant service.
23
+ * @returns the installed registration's disposer after setup succeeds.
24
+ */
25
+ export declare const apply: (ctx: Context) => Promise<() => void>;
26
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1,271 @@
1
+ /**
2
+ * Keep a session's model selection on the seat the engine driving it owns.
3
+ *
4
+ * A session's model selection FOLLOWS ITS ENGINE, in both directions:
5
+ *
6
+ * - a HOSTED engine owns its model natively, and logs the one shared provider
7
+ * label (`external`, {@link HOSTED_ROUTE_LABEL}) into the session's
8
+ * `request/header`; the host derives the session's selection from the latest
9
+ * header (`packages/api/session-controller/src/agent.ts`, `selectionFor`), so
10
+ * a session a hosted engine drives selects `external`. That label is served
11
+ * only by this plugin's placeholder route (`provider-route.ts`), which
12
+ * advertises exactly one entry under it — {@link HOSTED_DEFAULT_MODEL}. So
13
+ * the seat of a hosted session is `external/default`, and this module is what
14
+ * puts that in the log BEFORE the engine's first request would. (A session
15
+ * whose log still carries an EARLIER build's per-engine label —
16
+ * `claude-code` / `codex` / `pi` / `kimi` — is recognized as hosted too,
17
+ * {@link isHostedProviderRoute}, and rewritten to `external/default` on its
18
+ * next build or switch: no adapter serves those labels any more, so leaving
19
+ * one in place would fail the host's own route check with
20
+ * `model-unavailable`.)
21
+ * - the HARNESS LOOP (`in-process`) DOES call a real model, so it must select
22
+ * something a real adapter serves, and the only selection this plugin can name
23
+ * honestly is the deployment's own default:
24
+ * `agentDefaultModel.currentSelection()`, the value the host's
25
+ * `agentOptions()` gives every session it creates without one
26
+ * (`packages/core/agent-default-model/src/index.ts`,
27
+ * `packages/api/session-controller/src/agent.ts`). That default can name one of
28
+ * these routes ITSELF — `session.selectModel` saves whatever the model menu
29
+ * submitted as the deployment default, and the menu carries the hosted route
30
+ * as an entry — so the deployment's COMPOSED default model (the settings
31
+ * descriptor's `base` layer, what `packages/bundle/base/cordis.patch.yml`
32
+ * configures) is what this plugin names instead, and says so once. See
33
+ * {@link defaultSelection}.
34
+ *
35
+ * The write is the harness's own `model/selection` event: log-only, already a
36
+ * known session event type (`packages/core/session/src/known-event-types.ts`),
37
+ * and exactly what the host's own model picker appends
38
+ * (`ApiSessionAgentController.selectForNextRequest`). That is what makes it the
39
+ * one way a plugin can say "this session's next build selects X" without owning
40
+ * the host's in-memory selection: the event folds into the `modelSelection`
41
+ * projection, and the selection the host installs for the session's next agent
42
+ * reads it back (`selectionFor` prefers the projection's `pending` over the
43
+ * logged header).
44
+ *
45
+ * TWO triggers ask for it, and both answer through the same write:
46
+ *
47
+ * - {@link ModelSelectionReset.resetFor} — a session SWITCHED to another
48
+ * engine. The host reads a session's selection from its log and the change is
49
+ * about to land on that session's next build, so the write has to happen at
50
+ * the switch rather than at the next request.
51
+ * - {@link ModelSelectionReset.guardFor} — a session being BUILT. The router
52
+ * wraps the caller's `setup` for it, which is the one moment the plugin holds
53
+ * the session before the host installs the selection for it
54
+ * (`composeAgent`'s `setup` → `installSelection`), so the write still lands
55
+ * before the first request — and it is what gives a NEW session on a hosted
56
+ * engine its seat. For the harness loop this trigger also settles a defect the
57
+ * build path owns: `session.selectModel` saves the pick it was given as the
58
+ * DEPLOYMENT default (`packages/api/session-controller/src/commands.ts`
59
+ * `selectModel` → `AgentDefaultModelConfig.saveSelection`), that default is
60
+ * the selection of every session with nothing in its log, and the menu now
61
+ * carries the hosted route as an entry — so ONE pick made while a hosted
62
+ * session was open would otherwise hand every session built on the harness
63
+ * loop a route no adapter serves.
64
+ *
65
+ * THREE judgements keep those writes honest, and both triggers share them
66
+ * ({@link ModelSelectionReset.appendSeat}):
67
+ *
68
+ * - a REAL model selection is never overwritten. The test is the provider
69
+ * ({@link isHostedProviderRoute}): only a label some hosted engine logs is a
70
+ * seat this module owns. An explicit pick — the model menu's own event, which
71
+ * also becomes the deployment default — survives every engine change, which is
72
+ * what the browser half's model notice tells the user: under a hosted engine a
73
+ * dsh model is inert, not forbidden.
74
+ * - a session that already selects the target (provider and model) is left
75
+ * alone, so repeated switches never grow the log.
76
+ * - an engine SWITCH has nothing to write for a session whose log names no
77
+ * selection at all: there is no seat to rewrite, and naming a session's first
78
+ * seat is the BUILD trigger's job ({@link ModelSelectionReset.guardFor}), not
79
+ * a switch's. Such a session still selects the deployment default — the host's
80
+ * own fallback — so nothing is broken while the seat shows it.
81
+ *
82
+ * A deployment that composes no `agentDefaultModel` service, or one whose
83
+ * service cannot name a usable selection, is not an error here: the trigger is
84
+ * either the user's own action or a session about to run, and neither must fail
85
+ * over a selection this plugin cannot name. The write is skipped with ONE
86
+ * warning, and the session keeps whatever its log records.
87
+ *
88
+ * @module dsh-loop-engine-allinone/model-selection-reset
89
+ */
90
+ import type { Context } from '@deepseek-ai/cordis';
91
+ import type { Session } from '@deepseek-ai/dsh-session';
92
+ import type { SessionModelSelection } from './driver-core/host-servers.ts';
93
+ import type { LoopEngineId } from './settings.ts';
94
+ declare module '@deepseek-ai/dsh-session/types' {
95
+ interface SessionEventMap {
96
+ /**
97
+ * Complete validated model selection requested for subsequent prompt
98
+ * assembly. Log-only: it never enters derived model history.
99
+ */
100
+ 'model/selection': {
101
+ /** Registered provider route. */
102
+ readonly provider: string;
103
+ /** Provider-owned model id. */
104
+ readonly model: string;
105
+ /** Adapter-owned reasoning effort, or provider/default behavior when absent. */
106
+ readonly reasoningEffort?: string;
107
+ };
108
+ }
109
+ }
110
+ /** The host's `agentDefaultModel` service (`packages/core/agent-default-model`), as this read needs it. */
111
+ export interface AgentDefaultModelService {
112
+ /**
113
+ * The selection the host gives an Agent created without one. Read live on
114
+ * every call, because the settings layer it reads may change at any time.
115
+ * @returns the deployment's default provider, model, and optional effort.
116
+ */
117
+ currentSelection(): SessionModelSelection;
118
+ }
119
+ /**
120
+ * Keeps a session's model selection on the seat the engine driving it owns — the
121
+ * shared `external/default` of a hosted engine, or a real model for the harness
122
+ * loop.
123
+ *
124
+ * One instance per router: the "cannot name a default" and "the default itself
125
+ * names a hosted route" warnings are each owed once per process, not once per
126
+ * session.
127
+ */
128
+ export declare class ModelSelectionReset {
129
+ private readonly ctx;
130
+ private readonly warn;
131
+ /** Whether the one warning this deployment is owed has been reported. */
132
+ private warned;
133
+ /** Whether the one report that the deployment default names a hosted route has been made. */
134
+ private reportedHostedDefault;
135
+ /**
136
+ * @param ctx - context carrying the host's default-model service, its settings
137
+ * (for the configured default), and the session-projection registry.
138
+ * @param warn - diagnostic sink, used at most once per problem.
139
+ */
140
+ constructor(ctx: Context, warn: (message: string) => void);
141
+ /**
142
+ * Give one session the selection the engine it is being SWITCHED TO owns,
143
+ * unless its log already names a real model of its own.
144
+ *
145
+ * The switch trigger. A session whose log names no selection at all is left
146
+ * alone: a switch rewrites a seat an engine already put there, and naming a
147
+ * session's first seat belongs to the build of a session being created
148
+ * ({@link guardFor}) rather than to a change of engine.
149
+ * @param session - the live Session the engine switch is being recorded for.
150
+ * @param engine - the engine the session is being moved to.
151
+ * @returns whether a `model/selection` event was appended.
152
+ */
153
+ resetFor(session: Session, engine: LoopEngineId): boolean;
154
+ /**
155
+ * Give one session the selection the engine BUILDING it owns, inside the
156
+ * router's wrapped `setup` — before the caller's own setup installs the
157
+ * session's selection — so a selection written here is the one the host reads
158
+ * back for the agent being built.
159
+ *
160
+ * The harness loop's own build keeps its narrower precondition: it makes real
161
+ * model calls, so it is the one build that must not be left selecting a
162
+ * placeholder route, and a session whose own log already names a real model
163
+ * needs nothing written for it. A hosted engine is being given its seat here,
164
+ * which is what a new session on it starts from.
165
+ * @param session - the session whose agent is being composed.
166
+ * @param engine - the engine composing it.
167
+ * @returns whether a `model/selection` event was appended.
168
+ */
169
+ guardFor(session: Session, engine: LoopEngineId): boolean;
170
+ /**
171
+ * Whether the selection this session's next request would use names one of
172
+ * the hosted engines' provider routes — a label this plugin serves as a
173
+ * placeholder and cannot answer a real model call on.
174
+ *
175
+ * The read is the host's own (`selectionFor`): a pending selection, else the
176
+ * logged header, else the deployment's default. A session with nothing in its
177
+ * log is therefore judged on the deployment default — the value the model menu
178
+ * can write a hosted label into — and that default is read AS IT IS, never as
179
+ * {@link defaultSelection} would substitute it: the substitution only exists
180
+ * once it is written into the session, so judging the substitute would skip
181
+ * the write that makes it real.
182
+ * @param session - the session whose selection is being judged.
183
+ * @returns whether that selection names a hosted engine route.
184
+ */
185
+ private selectsHostedRoute;
186
+ /**
187
+ * Append the selection one engine's seat carries, by the judgements both
188
+ * triggers share.
189
+ *
190
+ * A real model selection is never overwritten — the provider is the test,
191
+ * because only a label some hosted engine logs is a seat this module owns — and
192
+ * a session that already selects the target route is left alone. Provider and
193
+ * model are the comparison: a reasoning effort the target carries is not a
194
+ * reason to log a second event for a session that already selects the same
195
+ * route, and re-appending would only grow the log on every switch.
196
+ * @param session - the session whose selection is being written.
197
+ * @param engine - the engine whose seat the session should select.
198
+ * @returns whether a `model/selection` event was appended.
199
+ */
200
+ private appendSeat;
201
+ /**
202
+ * The selection one engine's seat carries: a hosted engine's shared
203
+ * `external/default`, or — for the harness loop — the deployment's default,
204
+ * with the substitution {@link defaultSelection} documents.
205
+ * @param engine - the engine a session runs, or is being moved to.
206
+ * @returns the selection to write, or undefined when this process cannot name
207
+ * one for that engine.
208
+ */
209
+ private seatOf;
210
+ /**
211
+ * The selection the host will use for this session, by the host's own read —
212
+ * the shared read in `driver-core/session-model.ts` (`currentSelection`),
213
+ * which the hosted drivers also use to resolve the model they hand over.
214
+ * @param session - the session whose selection is being read.
215
+ * @returns the current selection, or undefined when the log records none.
216
+ */
217
+ private currentSelection;
218
+ /**
219
+ * The selection the deployment's own `agentDefaultModel` service answers, or
220
+ * undefined when this process cannot read one (reported once).
221
+ *
222
+ * Read twice for two different questions — as the selection a session with
223
+ * nothing in its log would use ({@link selectsHostedRoute}), and as the value
224
+ * this plugin restores ({@link defaultSelection}) — so the substitution below
225
+ * never hides the fact that the saved default itself is unusable.
226
+ * @returns the validated default, or undefined when it cannot be named.
227
+ */
228
+ private deploymentDefault;
229
+ /**
230
+ * The selection this plugin restores: the deployment's default, or — when that
231
+ * default names a hosted engine ROUTE — the model the deployment's own
232
+ * composition declares instead.
233
+ *
234
+ * The route case is not hypothetical: `session.selectModel` saves whatever the
235
+ * model menu submitted as the deployment default, and the menu carries the
236
+ * hosted route as an entry, so one pick made while a hosted session was open
237
+ * puts a label there that no adapter serves a real model on — handing it to a
238
+ * session the harness loop drives would fail that session's first request
239
+ * loud. The composed default is a real model the deployment itself asked for,
240
+ * so nothing is guessed on its behalf.
241
+ * @returns the restored selection, or undefined to skip the write.
242
+ */
243
+ private defaultSelection;
244
+ /**
245
+ * The model the DEPLOYMENT's own composition declares as its default, read
246
+ * from the settings descriptor's `base` layer — the value a saved (user-layer)
247
+ * default overrode.
248
+ *
249
+ * This is what replaces a default that names a hosted route, and it is read
250
+ * live because the composition is what the deployment itself configured:
251
+ * `packages/bundle/base/cordis.patch.yml` gives the `agent-default-model` row
252
+ * a real provider and model, and only the user layer can hold a pick made from
253
+ * the model menu.
254
+ * @returns the configured default, or undefined when this deployment composes
255
+ * no default-model section, cannot enumerate settings, configured no usable
256
+ * provider/model, or configured a hosted route there too.
257
+ */
258
+ private configuredDefault;
259
+ /** Read the host session-projection registry, structurally. */
260
+ private projections;
261
+ /**
262
+ * Report the one thing this read could not answer, once per plugin lifetime.
263
+ *
264
+ * Repeated triggers must not repeat it: a deployment without the service would
265
+ * otherwise log a line per session built for as long as it runs.
266
+ * @param problem - what this process cannot read, with the reason.
267
+ * @returns undefined, so callers can `return this.unavailable(…)` to skip.
268
+ */
269
+ private unavailable;
270
+ }
271
+ //# sourceMappingURL=model-selection-reset.d.ts.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Loop engine namespace literals: the strings both halves agree on, in a
3
+ * module with no runtime imports so the browser bundle can import them without
4
+ * dragging `dsh-settings` (a host-side service) into the client artifact.
5
+ * @module dsh-loop-engine-allinone/namespace
6
+ */
7
+ /**
8
+ * Settings namespace carrying the deployment's selected agent loop engine on
9
+ * the 0.1.7 line.
10
+ *
11
+ * Profile-backed settings are addressed by the composing entry id, so this
12
+ * literal is the plugin's own profile entry id: the shipped `cordis.patch.yml`
13
+ * inserts the entry as `loop-engine`, and the browser half passes the same
14
+ * string to `ctx.configForms.get(...)`. A deployment that renames the entry id
15
+ * must change this literal with it.
16
+ */
17
+ export declare const LOOP_ENGINE_SETTINGS_NAMESPACE_LITERAL = "loop-engine";
18
+ /**
19
+ * Settings namespace carrying the same selection on the 0.1.5 line, where a
20
+ * settings section is addressed by the namespace a provider registers rather
21
+ * than by a composing entry id. This is the literal the pre-rewrite plugin
22
+ * shipped; it is stable across the whole 0.1.5 line.
23
+ */
24
+ export declare const LEGACY_LOOP_ENGINE_SETTINGS_NAMESPACE_LITERAL = "agent-loop-engine";
25
+ //# sourceMappingURL=namespace.d.ts.map
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Managed-block editing for a profile's `cordis.patch.yml`.
3
+ *
4
+ * The plugin owns one contiguous block inside the user's patch file, delimited
5
+ * by a begin/end marker pair, and rewrites only that span — everything else the
6
+ * user wrote (other patches, their comments) survives byte for byte. The block
7
+ * is what hands the process-wide AgentFactory slot to this plugin's router: it
8
+ * disables the base bundle's `agent-loop` row, because the harness admits
9
+ * exactly one AgentFactory and the router (which extends the harness loop, and
10
+ * therefore serves `in-process` sessions too) registers itself as that one.
11
+ *
12
+ * # -- dsh-loop-engine managed block --
13
+ * - id: agent-loop
14
+ * disabled: true
15
+ * - id: command-goal
16
+ * disabled: true
17
+ * # -- /dsh-loop-engine managed block --
18
+ *
19
+ * The block names no engine. Which engine a session runs is a PER-SESSION
20
+ * decision carried by its agent preset, so it cannot live in a process-wide
21
+ * configuration file; the block's only job is to free the slot for the router.
22
+ * The `command-goal` row goes down with the loop: it is the host-plane copy of
23
+ * dsh's goal command, and a goal service nothing drives has no business being
24
+ * mounted for a profile whose loop is decided per session. The remaining
25
+ * dsh-native commands (`/export`, `/feedback`, `/permission`) are
26
+ * engine-agnostic session and settings controls that keep working under every
27
+ * engine. Per-session command surfaces are the preset's business — a hosted
28
+ * session joins an engine preset that strips `command-goal` itself, which is the
29
+ * only place that reaches the preset-layer registration.
30
+ *
31
+ * Blocks written before the plugin routed per session carried the single
32
+ * engine's id in the begin marker (`# -- dsh-loop-engine managed block:
33
+ * claude-code --`). {@link legacyBlockEngineOf} reads that form so an upgrade
34
+ * can carry the pinned engine into the settings seed before the block is
35
+ * rewritten to the engine-agnostic form; a legacy block is otherwise treated as
36
+ * a present block by {@link hasManagedBlock}.
37
+ *
38
+ * All functions here are pure string transforms — file I/O and durability live
39
+ * in the plugin's apply.
40
+ *
41
+ * @module dsh-loop-engine-allinone/patch-manager
42
+ */
43
+ import type { LoopEngineId } from './settings.ts';
44
+ /** Begin marker of the plugin-managed span inside a profile patch file. */
45
+ export declare const MANAGED_BLOCK_BEGIN = "# -- dsh-loop-engine managed block --";
46
+ /**
47
+ * Begin-marker prefix of the pre-routing block form, which named the one engine
48
+ * the profile was pinned to.
49
+ */
50
+ export declare const LEGACY_MANAGED_BLOCK_BEGIN = "# -- dsh-loop-engine managed block: ";
51
+ /** End marker of the plugin-managed span inside a profile patch file. */
52
+ export declare const MANAGED_BLOCK_END = "# -- /dsh-loop-engine managed block --";
53
+ /** The loader patch that frees the single AgentFactory slot for the router. */
54
+ export declare function renderManagedBlock(): string;
55
+ /**
56
+ * Whether a patch-file text contains the LEGACY managed block span, which
57
+ * named the single engine the profile used to be pinned to.
58
+ */
59
+ export declare function hasLegacyManagedBlock(text: string): boolean;
60
+ /**
61
+ * Whether a patch-file text contains the managed block span, in either the
62
+ * current or the legacy form.
63
+ */
64
+ export declare function hasManagedBlock(text: string): boolean;
65
+ /**
66
+ * The engine a LEGACY managed block pinned the profile to, when the block has
67
+ * that form and names an engine this build knows. `undefined` covers the
68
+ * current engine-agnostic block, no block at all, and a legacy block naming an
69
+ * engine this build does not recognize.
70
+ */
71
+ export declare function legacyBlockEngineOf(text: string): LoopEngineId | undefined;
72
+ /** Normalize a file so a managed span sits on its own lines with a blank separator. */
73
+ export declare function ensureTrailingNewline(text: string): string;
74
+ /**
75
+ * The profile seed template (`cordis.patch.yml` on a fresh profile) is a lone
76
+ * root-level empty flow sequence `[]`. The plugin's managed block is itself a
77
+ * root-level block sequence of loader entries, so a block coexisting with a
78
+ * surviving `[]` is TWO root collections in one document — YAML the harness
79
+ * rejects with "end of the stream or a document separator is expected", and the
80
+ * web app then fails to boot. Remove a whole-line root `[]` placeholder so the
81
+ * managed block is the sole top-level collection. Anchored to column 0 so an
82
+ * indented `[]` that is a real value inside an entry's nested config is never
83
+ * touched.
84
+ *
85
+ * Shared with the preset-rows region (`./preset.ts`): both regions are
86
+ * root-level collections appended to the same file, so either one can be the
87
+ * first thing that meets a surviving seed.
88
+ * @param text - the patch-file text.
89
+ * @returns the text without a whole-line root `[]` placeholder.
90
+ */
91
+ export declare function dropSeedPlaceholder(text: string): string;
92
+ /**
93
+ * Produce the next patch-file text carrying the managed block, preserving every
94
+ * byte outside the managed span. Appends the span when absent and replaces it
95
+ * when present — including a legacy span, which is rewritten to the current
96
+ * form. The managed block is a root-level collection, so a leftover seed `[]`
97
+ * is dropped with it, leaving the file a single valid top-level array the
98
+ * harness can boot: the block's own `- id: agent-loop` is a column-0 entry, so
99
+ * a file carrying it never needs a re-seed.
100
+ * @param text - current patch-file text.
101
+ * @returns the rewritten patch-file text.
102
+ */
103
+ export declare function applyManagedBlock(text: string): string;
104
+ //# sourceMappingURL=patch-manager.d.ts.map