@lmzhen/dsh-evolution-adapter 0.0.0-stage → 0.58.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.
Files changed (55) hide show
  1. package/README.md +14 -2
  2. package/lib/index.js +12 -0
  3. package/lib/llm-C8dh3Tqa.js +303 -0
  4. package/lib/ports.js +2 -0
  5. package/lib/service.js +50 -0
  6. package/lib/types/agents.d.ts +9 -0
  7. package/lib/types/agents.js +26 -0
  8. package/lib/types/commands.d.ts +9 -0
  9. package/lib/types/commands.js +9 -0
  10. package/lib/types/connection.d.ts +9 -0
  11. package/lib/types/connection.js +27 -0
  12. package/lib/types/index.d.ts +18 -0
  13. package/lib/types/index.js +10 -0
  14. package/lib/types/llm.d.ts +12 -0
  15. package/lib/types/llm.js +67 -0
  16. package/lib/types/platformView.d.ts +10 -0
  17. package/lib/types/platformView.js +29 -0
  18. package/lib/types/ports.d.ts +40 -0
  19. package/lib/types/ports.js +24 -0
  20. package/lib/types/presets.d.ts +9 -0
  21. package/lib/types/presets.js +31 -0
  22. package/lib/types/profileContext.d.ts +9 -0
  23. package/lib/types/profileContext.js +14 -0
  24. package/lib/types/projections.d.ts +9 -0
  25. package/lib/types/projections.js +34 -0
  26. package/lib/types/service.d.ts +24 -0
  27. package/lib/types/service.js +63 -0
  28. package/lib/types/settings.d.ts +9 -0
  29. package/lib/types/settings.js +14 -0
  30. package/lib/types/skills.d.ts +9 -0
  31. package/lib/types/skills.js +9 -0
  32. package/lib/types/storageDomain.d.ts +9 -0
  33. package/lib/types/storageDomain.js +9 -0
  34. package/lib/types/subagents.d.ts +9 -0
  35. package/lib/types/subagents.js +17 -0
  36. package/lib/types/systemPrompt.d.ts +9 -0
  37. package/lib/types/systemPrompt.js +13 -0
  38. package/lib/types/tools.d.ts +15 -0
  39. package/lib/types/tools.js +23 -0
  40. package/lib/types/userQuestions.d.ts +9 -0
  41. package/lib/types/userQuestions.js +9 -0
  42. package/lib/types/values.d.ts +25 -0
  43. package/lib/types/values.js +15 -0
  44. package/lib/types/workingDirectory.d.ts +9 -0
  45. package/lib/types/workingDirectory.js +9 -0
  46. package/lib/values.js +8 -0
  47. package/locale/de.json +6 -0
  48. package/locale/en.json +6 -0
  49. package/locale/es.json +6 -0
  50. package/locale/fr.json +6 -0
  51. package/locale/ja.json +6 -0
  52. package/locale/pt.json +6 -0
  53. package/locale/ru.json +6 -0
  54. package/locale/zh.json +6 -0
  55. package/package.json +59 -4
package/README.md CHANGED
@@ -1,3 +1,15 @@
1
- # Temporary Holding Version
1
+ # `@lmzhen/dsh-evolution-adapter`
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
+ The only host-facing package in the dsh-evolution family.
4
+
5
+ It owns:
6
+
7
+ - the platform port implementations (`agents`, `tools`, `llm`, `settings`,
8
+ `storageDomain`, `projections`, `connection`, `presets`, and the rest);
9
+ - the `evolutionPlatform` service, which exposes one live port table;
10
+ - the platform runtime helper values (`defineTool`, `createUserMessage`,
11
+ `escapeText`, `SessionId`, `withFileLock`, ...).
12
+
13
+ Feature packages must not import `@deepseek-ai/dsh-*`; they import contract
14
+ types and adapter helpers. The adapter is also the place where a real host API
15
+ shape difference is normalized; business code never branches on a DSH version.
package/lib/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import { _ as pluginManagerPort, a as toolsPort, b as commandsPort, c as userQuestionsPort, d as connectionPort, f as storageDomainPort, g as pluginInventoryPort, h as configEditorPort, i as registerEvolutionTool, l as subagentsPort, m as workingDirectoryPort, n as llmPort, o as projectionPort, p as skillsPort, r as modelRoute, s as presetsPort, t as EvolutionLlmError, u as systemPromptPort, v as profileContextPort, x as agentsPort, y as settingsPort } from "./llm-C8dh3Tqa.js";
2
+ import { EvolutionPlatform } from "./service.js";
3
+ import "./ports.js";
4
+ import { BlockAssembler, DomainError, SessionId, createToolResultMessage, createUserMessage, defineDomain, defineTool, domainTable, escapeText, scopeOf, withFileLock } from "./values.js";
5
+ //#region lib/types/index.js
6
+ const name = "evolution-adapter";
7
+ /** Mount the one host platform service; bundle row order places this before core/runtime. */
8
+ async function apply(ctx) {
9
+ await ctx.plugin(EvolutionPlatform);
10
+ }
11
+ //#endregion
12
+ export { BlockAssembler, DomainError, EvolutionLlmError, EvolutionPlatform, SessionId, agentsPort, apply, commandsPort, configEditorPort, connectionPort, createToolResultMessage, createUserMessage, defineDomain, defineTool, domainTable, escapeText, llmPort, modelRoute, name, pluginInventoryPort, pluginManagerPort, presetsPort, profileContextPort, projectionPort, registerEvolutionTool, scopeOf, settingsPort, skillsPort, storageDomainPort, subagentsPort, systemPromptPort, toolsPort, userQuestionsPort, withFileLock, workingDirectoryPort };
@@ -0,0 +1,303 @@
1
+ import { EvolutionLlmError, EvolutionLlmError as EvolutionLlmError$1 } from "@lmzhen/dsh-evolution-platform-contract";
2
+ import { err, ok } from "@lmzhen/dsh-evolution-platform-contract/result";
3
+ //#region lib/types/agents.js
4
+ const asIdentity = (value) => {
5
+ if (value === null || typeof value !== "object") return void 0;
6
+ return typeof value.id === "string" ? value : void 0;
7
+ };
8
+ /** Resolve the agents port; undefined means the host has no agents service. */
9
+ function agentsPort(ctx) {
10
+ const agents = ctx.get("agents");
11
+ if (agents === void 0) return void 0;
12
+ if (typeof agents.get !== "function" && typeof agents.list !== "function") return void 0;
13
+ const get = typeof agents.get === "function" ? agents.get.bind(agents) : void 0;
14
+ const list = typeof agents.list === "function" ? agents.list.bind(agents) : void 0;
15
+ return {
16
+ get: (id) => get === void 0 ? void 0 : asIdentity(get(id)),
17
+ list: () => list === void 0 ? [] : list().map(asIdentity).filter((agent) => agent !== void 0),
18
+ isRoot: (agent) => {
19
+ const live = get === void 0 ? void 0 : asIdentity(get(agent.id));
20
+ return live !== void 0 && live === agent && live.session?.header?.origin !== "subagent";
21
+ }
22
+ };
23
+ }
24
+ //#endregion
25
+ //#region lib/types/commands.js
26
+ /** Resolve the commands port; undefined means the host has no commands service. */
27
+ function commandsPort(ctx) {
28
+ const service = ctx.get("commands");
29
+ if (service === void 0 || typeof service.register !== "function") return void 0;
30
+ return { register: (definition) => service.register(definition) };
31
+ }
32
+ //#endregion
33
+ //#region lib/types/settings.js
34
+ /** Resolve the settings port; undefined means the host has no settings service. */
35
+ function settingsPort(ctx) {
36
+ const service = ctx.get("settings");
37
+ if (service === void 0) return void 0;
38
+ if (typeof service.configure !== "function" && typeof service.describe !== "function") return void 0;
39
+ return {
40
+ ...typeof service.configure === "function" ? { configure: (options, owner) => service.configure(options, owner) } : {},
41
+ ...typeof service.describe === "function" ? { describe: (options) => service.describe(options) } : {}
42
+ };
43
+ }
44
+ //#endregion
45
+ //#region lib/types/profileContext.js
46
+ /** Resolve the profile-context port; undefined means no profile is mounted. */
47
+ function profileContextPort(ctx) {
48
+ const service = ctx.get("profileContext");
49
+ if (service === void 0 || typeof service.dir !== "string" || service.dir === "") return void 0;
50
+ return {
51
+ name: typeof service.name === "string" ? service.name : "",
52
+ dir: service.dir,
53
+ ...typeof service.patchPath === "string" && service.patchPath !== "" ? { patchPath: service.patchPath } : {},
54
+ ...Array.isArray(service.startedBundles) ? { startedBundles: service.startedBundles } : {}
55
+ };
56
+ }
57
+ //#endregion
58
+ //#region lib/types/platformView.js
59
+ function pluginManagerPort(ctx) {
60
+ const service = ctx.get("pluginManager");
61
+ if (service === void 0) return void 0;
62
+ return {
63
+ ...typeof service.listBundles === "function" ? { listBundles: () => service.listBundles() } : {},
64
+ ...typeof service.listPlugins === "function" ? { listPlugins: () => service.listPlugins() } : {}
65
+ };
66
+ }
67
+ function pluginInventoryPort(ctx) {
68
+ const service = ctx.get("pluginInventory");
69
+ if (service === void 0) return void 0;
70
+ return { ...typeof service.list === "function" ? { list: () => service.list() } : {} };
71
+ }
72
+ function configEditorPort(ctx) {
73
+ const service = ctx.get("configEditor");
74
+ if (service === void 0) return void 0;
75
+ return { ...typeof service.configuration === "function" ? { configuration: () => service.configuration() } : {} };
76
+ }
77
+ //#endregion
78
+ //#region lib/types/workingDirectory.js
79
+ /** Resolve the working-directory port; undefined means the host has no such service. */
80
+ function workingDirectoryPort(ctx) {
81
+ const service = ctx.get("workingDirectory");
82
+ if (service === void 0 || typeof service.ensure !== "function") return void 0;
83
+ return { ensure: (agent, signal) => service.ensure(agent, signal) };
84
+ }
85
+ //#endregion
86
+ //#region lib/types/skills.js
87
+ /** Resolve the skills port; undefined means the host has no skills service. */
88
+ function skillsPort(ctx) {
89
+ const service = ctx.get("skills");
90
+ if (service === void 0 || typeof service.list !== "function") return void 0;
91
+ return { list: (options) => service.list(options) };
92
+ }
93
+ //#endregion
94
+ //#region lib/types/storageDomain.js
95
+ /** Resolve the storage-domain port; undefined means the host has no provider. */
96
+ function storageDomainPort(ctx) {
97
+ const service = ctx.get("storageDomain");
98
+ if (service === void 0 || typeof service.open !== "function") return void 0;
99
+ return { open: (spec) => service.open(spec) };
100
+ }
101
+ //#endregion
102
+ //#region lib/types/connection.js
103
+ const REGISTER_REQUIRED = "connection.fetch.register() is required to register family host routes (platform >= 0.2.2-rc.1); no fallback admission path exists";
104
+ /** Resolve the connection port; undefined means the host has no connection service. */
105
+ function connectionPort(ctx) {
106
+ const connection = ctx.get("connection");
107
+ if (connection === void 0) return void 0;
108
+ const register = (route) => {
109
+ if (connection.fetch === void 0 || typeof connection.fetch.register !== "function") throw new Error(REGISTER_REQUIRED);
110
+ return connection.fetch.register.call(connection.fetch, route);
111
+ };
112
+ return {
113
+ allowsRemoteAuthorities: connection.allowsRemoteAuthorities === true,
114
+ register,
115
+ tryRegister: (route) => {
116
+ try {
117
+ return ok(register(route));
118
+ } catch (error) {
119
+ return err({
120
+ code: "E-325",
121
+ message: error instanceof Error ? error.message : String(error)
122
+ });
123
+ }
124
+ }
125
+ };
126
+ }
127
+ //#endregion
128
+ //#region lib/types/systemPrompt.js
129
+ /** Resolve the system-prompt port; undefined means the host has no such service. */
130
+ function systemPromptPort(ctx) {
131
+ const service = ctx.get("systemPrompt");
132
+ if (service === void 0 || typeof service.section !== "function" || typeof service.variable !== "function") return void 0;
133
+ return {
134
+ section: (section) => service.section(section),
135
+ variable: (name, provider) => service.variable(name, provider),
136
+ ...typeof service.context === "function" ? { context: (context) => service.context(context) } : {}
137
+ };
138
+ }
139
+ //#endregion
140
+ //#region lib/types/subagents.js
141
+ /** Resolve the subagents port; undefined means the host has no subagents service. */
142
+ function subagentsPort(ctx) {
143
+ const subagents = ctx.get("subagents");
144
+ if (subagents === void 0 || typeof subagents.getProvider !== "function" || typeof subagents.startActivation !== "function") return void 0;
145
+ return {
146
+ getProvider: (name) => subagents.getProvider(name),
147
+ start: (spec) => subagents.startActivation(spec),
148
+ ...typeof subagents.sendMessage === "function" ? { sendMessage: (sender, targetId, content, options) => subagents.sendMessage(sender, targetId, content, options) } : {}
149
+ };
150
+ }
151
+ //#endregion
152
+ //#region lib/types/userQuestions.js
153
+ /** Resolve the user-questions port; undefined means the host has no such service. */
154
+ function userQuestionsPort(ctx) {
155
+ const service = ctx.get("userQuestions");
156
+ if (service === void 0 || typeof service.ask !== "function") return void 0;
157
+ return { ask: (request) => service.ask(request) };
158
+ }
159
+ //#endregion
160
+ //#region lib/types/presets.js
161
+ /** Resolve the preset registry facade; undefined when the host has no agentPresets service. */
162
+ function presetsPort(ctx) {
163
+ const registry = ctx.get("agentPresets");
164
+ if (registry === void 0) return void 0;
165
+ return {
166
+ readDocument: (id) => {
167
+ if (registry.readDocument === void 0) throw new Error("agentPresets service has no readDocument()");
168
+ return registry.readDocument(id);
169
+ },
170
+ register: (definition) => {
171
+ if (registry.register === void 0) throw new Error("agentPresets service has no register()");
172
+ return registry.register(definition);
173
+ },
174
+ resolve: (id) => {
175
+ if (registry.resolve === void 0) throw new Error("agentPresets service has no resolve()");
176
+ return registry.resolve(id);
177
+ },
178
+ mount: (target, id) => {
179
+ if (registry.mount === void 0) throw new Error("agentPresets service has no mount()");
180
+ return registry.mount(target, id);
181
+ },
182
+ composedPreset: (target) => registry.composedPreset?.(target)
183
+ };
184
+ }
185
+ //#endregion
186
+ //#region lib/types/projections.js
187
+ const isHandle = (value) => value !== null && typeof value === "object" && typeof value.stateOf === "function" && typeof value.dispose === "function";
188
+ /** Resolve the projection port; undefined means the host has no projection registry. */
189
+ function projectionPort(ctx) {
190
+ const registry = ctx.get("sessionProjections");
191
+ if (registry === void 0) return void 0;
192
+ let shape = "unrecognised";
193
+ let reason = "sessionProjections.register has not answered yet";
194
+ return {
195
+ get shape() {
196
+ return shape;
197
+ },
198
+ get reason() {
199
+ return shape === "unrecognised" ? reason : void 0;
200
+ },
201
+ async register(definition) {
202
+ const resolved = await registry.register(definition);
203
+ if (isHandle(resolved)) {
204
+ shape = "handle";
205
+ reason = void 0;
206
+ return {
207
+ stateOf: (session) => resolved.stateOf(session),
208
+ dispose: () => resolved.dispose()
209
+ };
210
+ }
211
+ shape = "unrecognised";
212
+ reason = "sessionProjections.register returned " + (resolved === null ? "null" : typeof resolved) + " without a projection handle";
213
+ return {
214
+ stateOf: () => void 0,
215
+ dispose: async () => {}
216
+ };
217
+ }
218
+ };
219
+ }
220
+ //#endregion
221
+ //#region lib/types/tools.js
222
+ /**
223
+ * Resolve the tools port from a context; undefined means the host has no tools service.
224
+ * platform-declaration anchor: tools is declared in core PLATFORM_SERVICE_PROBES.
225
+ */
226
+ function toolsPort(ctx) {
227
+ const tools = ctx.get("tools");
228
+ if (tools === void 0) return void 0;
229
+ return {
230
+ register: (definition) => tools.register(definition),
231
+ guard: (guard) => tools.guard(guard),
232
+ restrict: (filter) => tools.restrict(filter),
233
+ get: (name, scope) => tools.get(name, scope),
234
+ ...typeof tools.execute === "function" ? { execute: (input) => tools.execute(input) } : {}
235
+ };
236
+ }
237
+ /** Register one family tool through the port; a missing service yields a no-op disposer. */
238
+ function registerEvolutionTool(ctx, definition) {
239
+ return toolsPort(ctx)?.register(definition) ?? (() => {});
240
+ }
241
+ //#endregion
242
+ //#region lib/types/llm.js
243
+ function toOptions(request) {
244
+ return {
245
+ provider: request.provider,
246
+ model: request.model,
247
+ messages: request.messages,
248
+ ...request.maxTokens === void 0 ? {} : { maxTokens: request.maxTokens },
249
+ ...request.temperature === void 0 ? {} : { temperature: request.temperature },
250
+ ...request.signal === void 0 ? {} : { signal: request.signal },
251
+ purpose: request.purpose
252
+ };
253
+ }
254
+ /** Resolve the LLM port; undefined means the host has no llm service. */
255
+ function llmPort(ctx) {
256
+ const llm = ctx.get("llm");
257
+ if (llm === void 0) return void 0;
258
+ const port = {
259
+ async *stream(request) {
260
+ const options = toOptions(request);
261
+ if (llm.stream === void 0) throw new EvolutionLlmError("transport", "llm service has no stream()");
262
+ yield* llm.stream(options);
263
+ },
264
+ ...llm.stream === void 0 ? {} : { streamRaw: (options) => llm.stream(options) },
265
+ async completeText(request) {
266
+ let text = "";
267
+ for await (const chunk of port.stream(request)) {
268
+ const frame = chunk;
269
+ if (frame.type === "text-delta" || frame.type === "text") text += typeof frame.text === "string" ? frame.text : "";
270
+ if (frame.type === "finish" && frame.reason?.kind === "error") {
271
+ const failure = frame.reason.failure;
272
+ const message = failure?.message;
273
+ throw new EvolutionLlmError(failure?.code === "CONTENT_REFUSED" ? "content-refused" : "transport", "model call failed: " + (typeof message === "string" ? message : "unknown"));
274
+ }
275
+ }
276
+ return text;
277
+ }
278
+ };
279
+ return port;
280
+ }
281
+ /** Resolve the model route: agent-owned selection first, deployment default second. */
282
+ function modelRoute(ctx, agent, session) {
283
+ const owned = agent?.model?.current?.();
284
+ if (owned !== void 0) return {
285
+ provider: owned.provider,
286
+ model: owned.model
287
+ };
288
+ if (session !== void 0) {
289
+ const value = ctx.get("sessionProjections")?.snapshot?.(session, ["modelSelection"])?.values?.modelSelection;
290
+ const chosen = value?.next ?? value?.lastUsed;
291
+ if (chosen !== void 0 && chosen !== null) return {
292
+ provider: chosen.provider,
293
+ model: chosen.model
294
+ };
295
+ }
296
+ const fallback = ctx.get("agentDefaultModel")?.currentSelection?.();
297
+ return fallback === void 0 ? void 0 : {
298
+ provider: fallback.provider,
299
+ model: fallback.model
300
+ };
301
+ }
302
+ //#endregion
303
+ export { pluginManagerPort as _, toolsPort as a, commandsPort as b, userQuestionsPort as c, connectionPort as d, storageDomainPort as f, pluginInventoryPort as g, configEditorPort as h, registerEvolutionTool as i, subagentsPort as l, workingDirectoryPort as m, llmPort as n, projectionPort as o, skillsPort as p, modelRoute as r, presetsPort as s, EvolutionLlmError$1 as t, systemPromptPort as u, profileContextPort as v, agentsPort as x, settingsPort as y };
package/lib/ports.js ADDED
@@ -0,0 +1,2 @@
1
+ import { _ as pluginManagerPort, a as toolsPort, b as commandsPort, c as userQuestionsPort, d as connectionPort, f as storageDomainPort, g as pluginInventoryPort, h as configEditorPort, i as registerEvolutionTool, l as subagentsPort, m as workingDirectoryPort, n as llmPort, o as projectionPort, p as skillsPort, r as modelRoute, s as presetsPort, t as EvolutionLlmError, u as systemPromptPort, v as profileContextPort, x as agentsPort, y as settingsPort } from "./llm-C8dh3Tqa.js";
2
+ export { EvolutionLlmError, agentsPort, commandsPort, configEditorPort, connectionPort, llmPort, modelRoute, pluginInventoryPort, pluginManagerPort, presetsPort, profileContextPort, projectionPort, registerEvolutionTool, settingsPort, skillsPort, storageDomainPort, subagentsPort, systemPromptPort, toolsPort, userQuestionsPort, workingDirectoryPort };
package/lib/service.js ADDED
@@ -0,0 +1,50 @@
1
+ import { _ as pluginManagerPort, a as toolsPort, b as commandsPort, c as userQuestionsPort, d as connectionPort, f as storageDomainPort, g as pluginInventoryPort, h as configEditorPort, l as subagentsPort, m as workingDirectoryPort, n as llmPort, o as projectionPort, p as skillsPort, s as presetsPort, u as systemPromptPort, v as profileContextPort, x as agentsPort, y as settingsPort } from "./llm-C8dh3Tqa.js";
2
+ import { Service } from "@deepseek-ai/cordis";
3
+ import { CONTRACT } from "@lmzhen/dsh-evolution-platform-contract";
4
+ //#region lib/types/service.js
5
+ /**
6
+ * The family's host capability service: one place that resolves the platform
7
+ * ports and reports which halves are available.
8
+ */
9
+ /** Domain service owning the host port table. */
10
+ var EvolutionPlatform = class extends Service {
11
+ static inject = [];
12
+ /** The family-facing contract generation this adapter implements. */
13
+ contract = CONTRACT;
14
+ constructor(ctx) {
15
+ super(ctx, "evolutionPlatform");
16
+ }
17
+ /**
18
+ * Resolve the host ports now. Consumers read this one table; they never fall
19
+ * back to a direct platform import (the second resolution D7 removed).
20
+ * Deliberately uncached: `ctx.get` is the capability lifecycle.
21
+ */
22
+ get ports() {
23
+ return {
24
+ agents: agentsPort(this.ctx),
25
+ connection: connectionPort(this.ctx),
26
+ settings: settingsPort(this.ctx),
27
+ storageDomain: storageDomainPort(this.ctx),
28
+ workingDirectory: workingDirectoryPort(this.ctx),
29
+ pluginManager: pluginManagerPort(this.ctx),
30
+ pluginInventory: pluginInventoryPort(this.ctx),
31
+ configEditor: configEditorPort(this.ctx),
32
+ profileContext: profileContextPort(this.ctx),
33
+ skills: skillsPort(this.ctx),
34
+ commands: commandsPort(this.ctx),
35
+ systemPrompt: systemPromptPort(this.ctx),
36
+ subagents: subagentsPort(this.ctx),
37
+ userQuestions: userQuestionsPort(this.ctx),
38
+ projections: projectionPort(this.ctx),
39
+ llm: llmPort(this.ctx),
40
+ tools: toolsPort(this.ctx),
41
+ presets: presetsPort(this.ctx)
42
+ };
43
+ }
44
+ /** Whether an exact live root agent is available for this id. */
45
+ isRootAgent(agent) {
46
+ return this.ports.agents?.isRoot(agent) === true;
47
+ }
48
+ };
49
+ //#endregion
50
+ export { EvolutionPlatform };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The agents implementation half of the family's platform boundary.
3
+ */
4
+ import type { Context } from '@deepseek-ai/cordis';
5
+ import type { AgentsPort } from '@lmzhen/dsh-evolution-platform-contract';
6
+ export type { AgentIdentity, AgentsPort } from '@lmzhen/dsh-evolution-platform-contract';
7
+ /** Resolve the agents port; undefined means the host has no agents service. */
8
+ export declare function agentsPort(ctx: Context): AgentsPort | undefined;
9
+ //# sourceMappingURL=agents.d.ts.map
@@ -0,0 +1,26 @@
1
+ const asIdentity = (value) => {
2
+ if (value === null || typeof value !== 'object')
3
+ return undefined;
4
+ const id = value.id;
5
+ return typeof id === 'string' ? value : undefined;
6
+ };
7
+ /** Resolve the agents port; undefined means the host has no agents service. */
8
+ export function agentsPort(ctx) {
9
+ // platform-declaration anchor: agents is declared in core PLATFORM_SERVICE_PROBES.
10
+ const agents = ctx.get('agents');
11
+ if (agents === undefined)
12
+ return undefined;
13
+ if (typeof agents.get !== 'function' && typeof agents.list !== 'function')
14
+ return undefined;
15
+ const get = typeof agents.get === 'function' ? agents.get.bind(agents) : undefined;
16
+ const list = typeof agents.list === 'function' ? agents.list.bind(agents) : undefined;
17
+ return {
18
+ get: (id) => get === undefined ? undefined : asIdentity(get(id)),
19
+ list: () => list === undefined ? [] : list().map(asIdentity).filter((agent) => agent !== undefined),
20
+ isRoot: (agent) => {
21
+ const live = get === undefined ? undefined : asIdentity(get(agent.id));
22
+ return live !== undefined && live === agent && live.session?.header?.origin !== 'subagent';
23
+ },
24
+ };
25
+ }
26
+ //# sourceMappingURL=agents.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The commands implementation half of the family's platform boundary.
3
+ */
4
+ import type { Context } from '@deepseek-ai/cordis';
5
+ import type { CommandsPort } from '@lmzhen/dsh-evolution-platform-contract';
6
+ export type { CommandsPort } from '@lmzhen/dsh-evolution-platform-contract';
7
+ /** Resolve the commands port; undefined means the host has no commands service. */
8
+ export declare function commandsPort(ctx: Context): CommandsPort | undefined;
9
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1,9 @@
1
+ /** Resolve the commands port; undefined means the host has no commands service. */
2
+ export function commandsPort(ctx) {
3
+ // platform-declaration anchor: commands is declared in core PLATFORM_SERVICE_PROBES.
4
+ const service = ctx.get('commands');
5
+ if (service === undefined || typeof service.register !== 'function')
6
+ return undefined;
7
+ return { register: (definition) => service.register(definition) };
8
+ }
9
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The connection implementation half of the family's platform boundary.
3
+ */
4
+ import type { Context } from '@deepseek-ai/cordis';
5
+ import type { ConnectionPort } from '@lmzhen/dsh-evolution-platform-contract';
6
+ export type { ConnectionPort, ConnectionRegisterResult, ConnectionRoute } from '@lmzhen/dsh-evolution-platform-contract';
7
+ /** Resolve the connection port; undefined means the host has no connection service. */
8
+ export declare function connectionPort(ctx: Context): ConnectionPort | undefined;
9
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1,27 @@
1
+ import { err, ok } from '@lmzhen/dsh-evolution-platform-contract/result';
2
+ const REGISTER_REQUIRED = 'connection.fetch.register() is required to register family host routes (platform >= 0.2.2-rc.1); no fallback admission path exists';
3
+ /** Resolve the connection port; undefined means the host has no connection service. */
4
+ export function connectionPort(ctx) {
5
+ // platform-declaration anchor: connection is declared in core PLATFORM_SERVICE_PROBES.
6
+ const connection = ctx.get('connection');
7
+ if (connection === undefined)
8
+ return undefined;
9
+ const register = (route) => {
10
+ if (connection.fetch === undefined || typeof connection.fetch.register !== 'function')
11
+ throw new Error(REGISTER_REQUIRED);
12
+ return connection.fetch.register.call(connection.fetch, route);
13
+ };
14
+ return {
15
+ allowsRemoteAuthorities: connection.allowsRemoteAuthorities === true,
16
+ register,
17
+ tryRegister: (route) => {
18
+ try {
19
+ return ok(register(route));
20
+ }
21
+ catch (error) {
22
+ return err({ code: 'E-325', message: error instanceof Error ? error.message : String(error) });
23
+ }
24
+ },
25
+ };
26
+ }
27
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Full adapter entry.
3
+ *
4
+ * - `./ports` is the composition-safe port surface.
5
+ * - `./values` carries host-provided runtime helper values.
6
+ * - `./service` is the Cordis `evolutionPlatform` service.
7
+ *
8
+ * Feature packages should use the narrow entries (`./ports`, `./values`) and
9
+ * not this umbrella unless they need the service.
10
+ */
11
+ import type { Context } from '@deepseek-ai/cordis';
12
+ export * from './ports.ts';
13
+ export * from './values.ts';
14
+ export * from './service.ts';
15
+ export declare const name = "evolution-adapter";
16
+ /** Mount the one host platform service; bundle row order places this before core/runtime. */
17
+ export declare function apply(ctx: Context): Promise<void>;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { EvolutionPlatform } from "./service.js";
2
+ export * from "./ports.js";
3
+ export * from "./values.js";
4
+ export * from "./service.js";
5
+ export const name = 'evolution-adapter';
6
+ /** Mount the one host platform service; bundle row order places this before core/runtime. */
7
+ export async function apply(ctx) {
8
+ await ctx.plugin(EvolutionPlatform);
9
+ }
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The LLM implementation half of the family's platform boundary.
3
+ */
4
+ import type { Context } from '@deepseek-ai/cordis';
5
+ import type { LlmPort, ModelRoute } from '@lmzhen/dsh-evolution-platform-contract';
6
+ export { EvolutionLlmError } from '@lmzhen/dsh-evolution-platform-contract';
7
+ export type { EvolutionLlmFailureKind, EvolutionLlmPurpose, EvolutionLlmRequest, LlmPort, ModelRoute, } from '@lmzhen/dsh-evolution-platform-contract';
8
+ /** Resolve the LLM port; undefined means the host has no llm service. */
9
+ export declare function llmPort(ctx: Context): LlmPort | undefined;
10
+ /** Resolve the model route: agent-owned selection first, deployment default second. */
11
+ export declare function modelRoute(ctx: Context, agent?: unknown, session?: unknown): ModelRoute | undefined;
12
+ //# sourceMappingURL=llm.d.ts.map
@@ -0,0 +1,67 @@
1
+ import { EvolutionLlmError } from '@lmzhen/dsh-evolution-platform-contract';
2
+ export { EvolutionLlmError } from '@lmzhen/dsh-evolution-platform-contract';
3
+ function toOptions(request) {
4
+ return {
5
+ provider: request.provider,
6
+ model: request.model,
7
+ messages: request.messages,
8
+ ...(request.maxTokens === undefined ? {} : { maxTokens: request.maxTokens }),
9
+ ...(request.temperature === undefined ? {} : { temperature: request.temperature }),
10
+ ...(request.signal === undefined ? {} : { signal: request.signal }),
11
+ purpose: request.purpose,
12
+ };
13
+ }
14
+ /** Resolve the LLM port; undefined means the host has no llm service. */
15
+ export function llmPort(ctx) {
16
+ // platform-declaration anchor: llm is declared in core PLATFORM_SERVICE_PROBES.
17
+ const llm = ctx.get('llm');
18
+ if (llm === undefined)
19
+ return undefined;
20
+ const port = {
21
+ async *stream(request) {
22
+ const options = toOptions(request);
23
+ if (llm.stream === undefined)
24
+ throw new EvolutionLlmError('transport', 'llm service has no stream()');
25
+ yield* llm.stream(options);
26
+ },
27
+ ...(llm.stream === undefined ? {} : { streamRaw: (options) => llm.stream(options) }),
28
+ async completeText(request) {
29
+ let text = '';
30
+ for await (const chunk of port.stream(request)) {
31
+ const frame = chunk;
32
+ if (frame.type === 'text-delta' || frame.type === 'text')
33
+ text += typeof frame.text === 'string' ? frame.text : '';
34
+ if (frame.type === 'finish' && frame.reason?.kind === 'error') {
35
+ const failure = frame.reason.failure;
36
+ const message = failure?.message;
37
+ // rc5 delivers a refusal as an in-band finish(error) chunk, not as a thrown LlmError.
38
+ // Preserve the decided code at the seam so callers do not retry it as transport.
39
+ const kind = failure?.code === 'CONTENT_REFUSED' ? 'content-refused' : 'transport';
40
+ throw new EvolutionLlmError(kind, 'model call failed: ' + (typeof message === 'string' ? message : 'unknown'));
41
+ }
42
+ }
43
+ return text;
44
+ },
45
+ };
46
+ return port;
47
+ }
48
+ /** Resolve the model route: agent-owned selection first, deployment default second. */
49
+ export function modelRoute(ctx, agent, session) {
50
+ const owned = agent?.model?.current?.();
51
+ if (owned !== undefined)
52
+ return { provider: owned.provider, model: owned.model };
53
+ // `sessionProjections.snapshot()` returns the projection's VIEW, not its state: the platform's
54
+ // modelSelection view is `{ lastUsed, next }` where `next` is already `pending ?? lastUsed`
55
+ // (packages/core/agent/src/model-selection.ts, viewSchema/view). Reading the state field `pending` here would
56
+ // always be undefined and silently pin auxiliary calls to `lastUsed`.
57
+ if (session !== undefined) {
58
+ const registry = ctx.get('sessionProjections');
59
+ const value = registry?.snapshot?.(session, ['modelSelection'])?.values?.modelSelection;
60
+ const chosen = value?.next ?? value?.lastUsed;
61
+ if (chosen !== undefined && chosen !== null)
62
+ return { provider: chosen.provider, model: chosen.model };
63
+ }
64
+ const fallback = ctx.get('agentDefaultModel')?.currentSelection?.();
65
+ return fallback === undefined ? undefined : { provider: fallback.provider, model: fallback.model };
66
+ }
67
+ //# sourceMappingURL=llm.js.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The remaining read-only platform surfaces the doctor's platform view uses.
3
+ */
4
+ import type { Context } from '@deepseek-ai/cordis';
5
+ import type { ConfigEditorPort, PluginInventoryPort, PluginManagerPort } from '@lmzhen/dsh-evolution-platform-contract';
6
+ export type { ConfigEditorPort, PluginInventoryPort, PluginManagerPort, } from '@lmzhen/dsh-evolution-platform-contract';
7
+ export declare function pluginManagerPort(ctx: Context): PluginManagerPort | undefined;
8
+ export declare function pluginInventoryPort(ctx: Context): PluginInventoryPort | undefined;
9
+ export declare function configEditorPort(ctx: Context): ConfigEditorPort | undefined;
10
+ //# sourceMappingURL=platformView.d.ts.map
@@ -0,0 +1,29 @@
1
+ export function pluginManagerPort(ctx) {
2
+ // platform-declaration anchor: pluginManager is declared in core PLATFORM_SERVICE_PROBES.
3
+ const service = ctx.get('pluginManager');
4
+ if (service === undefined)
5
+ return undefined;
6
+ return {
7
+ ...(typeof service.listBundles === 'function' ? { listBundles: () => service.listBundles() } : {}),
8
+ ...(typeof service.listPlugins === 'function' ? { listPlugins: () => service.listPlugins() } : {}),
9
+ };
10
+ }
11
+ export function pluginInventoryPort(ctx) {
12
+ // platform-declaration anchor: pluginInventory is declared in core PLATFORM_SERVICE_PROBES.
13
+ const service = ctx.get('pluginInventory');
14
+ if (service === undefined)
15
+ return undefined;
16
+ return {
17
+ ...(typeof service.list === 'function' ? { list: () => service.list() } : {}),
18
+ };
19
+ }
20
+ export function configEditorPort(ctx) {
21
+ // platform-declaration anchor: configEditor is declared in core PLATFORM_SERVICE_PROBES.
22
+ const service = ctx.get('configEditor');
23
+ if (service === undefined)
24
+ return undefined;
25
+ return {
26
+ ...(typeof service.configuration === 'function' ? { configuration: () => service.configuration() } : {}),
27
+ };
28
+ }
29
+ //# sourceMappingURL=platformView.js.map