@lmzhen/dsh-evolution-adapter 0.0.0 → 0.59.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 (58) hide show
  1. package/README.md +19 -0
  2. package/lib/index.js +12 -0
  3. package/lib/llm-9Y3qyl1T.js +304 -0
  4. package/lib/ports.js +2 -0
  5. package/lib/review-child.js +117 -0
  6. package/lib/service.js +50 -0
  7. package/lib/types/agents.d.ts +9 -0
  8. package/lib/types/agents.js +26 -0
  9. package/lib/types/commands.d.ts +9 -0
  10. package/lib/types/commands.js +9 -0
  11. package/lib/types/connection.d.ts +9 -0
  12. package/lib/types/connection.js +27 -0
  13. package/lib/types/index.d.ts +18 -0
  14. package/lib/types/index.js +10 -0
  15. package/lib/types/llm.d.ts +12 -0
  16. package/lib/types/llm.js +67 -0
  17. package/lib/types/platformView.d.ts +10 -0
  18. package/lib/types/platformView.js +29 -0
  19. package/lib/types/ports.d.ts +40 -0
  20. package/lib/types/ports.js +24 -0
  21. package/lib/types/presets.d.ts +9 -0
  22. package/lib/types/presets.js +31 -0
  23. package/lib/types/profileContext.d.ts +9 -0
  24. package/lib/types/profileContext.js +14 -0
  25. package/lib/types/projections.d.ts +9 -0
  26. package/lib/types/projections.js +34 -0
  27. package/lib/types/review-child.d.ts +45 -0
  28. package/lib/types/review-child.js +117 -0
  29. package/lib/types/service.d.ts +24 -0
  30. package/lib/types/service.js +63 -0
  31. package/lib/types/settings.d.ts +9 -0
  32. package/lib/types/settings.js +14 -0
  33. package/lib/types/skills.d.ts +9 -0
  34. package/lib/types/skills.js +9 -0
  35. package/lib/types/storageDomain.d.ts +9 -0
  36. package/lib/types/storageDomain.js +9 -0
  37. package/lib/types/subagents.d.ts +9 -0
  38. package/lib/types/subagents.js +17 -0
  39. package/lib/types/systemPrompt.d.ts +9 -0
  40. package/lib/types/systemPrompt.js +13 -0
  41. package/lib/types/tools.d.ts +15 -0
  42. package/lib/types/tools.js +24 -0
  43. package/lib/types/userQuestions.d.ts +9 -0
  44. package/lib/types/userQuestions.js +9 -0
  45. package/lib/types/values.d.ts +25 -0
  46. package/lib/types/values.js +15 -0
  47. package/lib/types/workingDirectory.d.ts +9 -0
  48. package/lib/types/workingDirectory.js +9 -0
  49. package/lib/values.js +8 -0
  50. package/locale/de.json +6 -0
  51. package/locale/en.json +6 -0
  52. package/locale/es.json +6 -0
  53. package/locale/fr.json +6 -0
  54. package/locale/ja.json +6 -0
  55. package/locale/pt.json +6 -0
  56. package/locale/ru.json +6 -0
  57. package/locale/zh.json +6 -0
  58. package/package.json +59 -3
@@ -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
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Host platform ports.
3
+ *
4
+ * This entry is safe to import at composition time: every module here uses
5
+ * platform types only, and resolves the live host service through `ctx.get`
6
+ * when a feature calls it. No host runtime value is imported here.
7
+ */
8
+ export { commandsPort } from './commands.ts';
9
+ export type { CommandsPort } from './commands.ts';
10
+ export { profileContextPort } from './profileContext.ts';
11
+ export type { ProfileContextPort } from './profileContext.ts';
12
+ export { pluginManagerPort, pluginInventoryPort, configEditorPort } from './platformView.ts';
13
+ export type { PluginManagerPort, PluginInventoryPort, ConfigEditorPort } from './platformView.ts';
14
+ export { workingDirectoryPort } from './workingDirectory.ts';
15
+ export type { WorkingDirectoryPort } from './workingDirectory.ts';
16
+ export { skillsPort } from './skills.ts';
17
+ export type { SkillsPort } from './skills.ts';
18
+ export { storageDomainPort } from './storageDomain.ts';
19
+ export type { StorageDomainPort } from './storageDomain.ts';
20
+ export { settingsPort } from './settings.ts';
21
+ export type { SettingsPort } from './settings.ts';
22
+ export { connectionPort } from './connection.ts';
23
+ export type { ConnectionPort, ConnectionRoute } from './connection.ts';
24
+ export { systemPromptPort } from './systemPrompt.ts';
25
+ export type { SystemPromptPort } from './systemPrompt.ts';
26
+ export { agentsPort } from './agents.ts';
27
+ export type { AgentIdentity, AgentsPort } from './agents.ts';
28
+ export { subagentsPort } from './subagents.ts';
29
+ export type { SubagentActivationPort, SubagentSendOptions, SubagentsPort } from './subagents.ts';
30
+ export { userQuestionsPort } from './userQuestions.ts';
31
+ export type { AskedQuestions, UserQuestion, UserQuestionOption, UserQuestionsPort } from './userQuestions.ts';
32
+ export { presetsPort } from './presets.ts';
33
+ export type { PresetDefinitionLike, PresetDocument, PresetsPort } from './presets.ts';
34
+ export { projectionPort } from './projections.ts';
35
+ export type { EvolutionProjectionDefinition, ProjectionHandleLike, ProjectionPort } from './projections.ts';
36
+ export { EvolutionLlmError, llmPort, modelRoute } from './llm.ts';
37
+ export type { EvolutionLlmFailureKind, EvolutionLlmPurpose, EvolutionLlmRequest, LlmPort, ModelRoute } from './llm.ts';
38
+ export { registerEvolutionTool, toolsPort } from './tools.ts';
39
+ export type { ToolsPort } from './tools.ts';
40
+ //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Host platform ports.
3
+ *
4
+ * This entry is safe to import at composition time: every module here uses
5
+ * platform types only, and resolves the live host service through `ctx.get`
6
+ * when a feature calls it. No host runtime value is imported here.
7
+ */
8
+ export { commandsPort } from "./commands.js";
9
+ export { profileContextPort } from "./profileContext.js";
10
+ export { pluginManagerPort, pluginInventoryPort, configEditorPort } from "./platformView.js";
11
+ export { workingDirectoryPort } from "./workingDirectory.js";
12
+ export { skillsPort } from "./skills.js";
13
+ export { storageDomainPort } from "./storageDomain.js";
14
+ export { settingsPort } from "./settings.js";
15
+ export { connectionPort } from "./connection.js";
16
+ export { systemPromptPort } from "./systemPrompt.js";
17
+ export { agentsPort } from "./agents.js";
18
+ export { subagentsPort } from "./subagents.js";
19
+ export { userQuestionsPort } from "./userQuestions.js";
20
+ export { presetsPort } from "./presets.js";
21
+ export { projectionPort } from "./projections.js";
22
+ export { EvolutionLlmError, llmPort, modelRoute } from "./llm.js";
23
+ export { registerEvolutionTool, toolsPort } from "./tools.js";
24
+ //# sourceMappingURL=ports.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The agent-preset implementation half of the family's platform boundary.
3
+ */
4
+ import type { Context } from '@deepseek-ai/cordis';
5
+ import type { PresetsPort } from '@lmzhen/dsh-evolution-platform-contract';
6
+ export type { PresetDefinitionLike, PresetDocument, PresetsPort } from '@lmzhen/dsh-evolution-platform-contract';
7
+ /** Resolve the preset registry facade; undefined when the host has no agentPresets service. */
8
+ export declare function presetsPort(ctx: Context): PresetsPort | undefined;
9
+ //# sourceMappingURL=presets.d.ts.map
@@ -0,0 +1,31 @@
1
+ /** Resolve the preset registry facade; undefined when the host has no agentPresets service. */
2
+ export function presetsPort(ctx) {
3
+ // platform-declaration anchor: agentPresets is declared in core PLATFORM_SERVICE_PROBES.
4
+ const registry = ctx.get('agentPresets');
5
+ if (registry === undefined)
6
+ return undefined;
7
+ return {
8
+ readDocument: (id) => {
9
+ if (registry.readDocument === undefined)
10
+ throw new Error('agentPresets service has no readDocument()');
11
+ return registry.readDocument(id);
12
+ },
13
+ register: (definition) => {
14
+ if (registry.register === undefined)
15
+ throw new Error('agentPresets service has no register()');
16
+ return registry.register(definition);
17
+ },
18
+ resolve: (id) => {
19
+ if (registry.resolve === undefined)
20
+ throw new Error('agentPresets service has no resolve()');
21
+ return registry.resolve(id);
22
+ },
23
+ mount: (target, id) => {
24
+ if (registry.mount === undefined)
25
+ throw new Error('agentPresets service has no mount()');
26
+ return registry.mount(target, id);
27
+ },
28
+ composedPreset: (target) => registry.composedPreset?.(target),
29
+ };
30
+ }
31
+ //# sourceMappingURL=presets.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The profile-context implementation half of the family's platform boundary.
3
+ */
4
+ import type { Context } from '@deepseek-ai/cordis';
5
+ import type { ProfileContextPort } from '@lmzhen/dsh-evolution-platform-contract';
6
+ export type { ProfileContextPort } from '@lmzhen/dsh-evolution-platform-contract';
7
+ /** Resolve the profile-context port; undefined means no profile is mounted. */
8
+ export declare function profileContextPort(ctx: Context): ProfileContextPort | undefined;
9
+ //# sourceMappingURL=profileContext.d.ts.map
@@ -0,0 +1,14 @@
1
+ /** Resolve the profile-context port; undefined means no profile is mounted. */
2
+ export function profileContextPort(ctx) {
3
+ // platform-declaration anchor: profileContext is declared in core PLATFORM_SERVICE_PROBES.
4
+ const service = ctx.get('profileContext');
5
+ if (service === undefined || typeof service.dir !== 'string' || service.dir === '')
6
+ return undefined;
7
+ return {
8
+ name: typeof service.name === 'string' ? service.name : '',
9
+ dir: service.dir,
10
+ ...(typeof service.patchPath === 'string' && service.patchPath !== '' ? { patchPath: service.patchPath } : {}),
11
+ ...(Array.isArray(service.startedBundles) ? { startedBundles: service.startedBundles } : {}),
12
+ };
13
+ }
14
+ //# sourceMappingURL=profileContext.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The session-projection implementation half of the family's platform boundary.
3
+ */
4
+ import type { Context } from '@deepseek-ai/cordis';
5
+ import type { ProjectionPort } from '@lmzhen/dsh-evolution-platform-contract';
6
+ export type { EvolutionProjectionDefinition, ProjectionHandleLike, ProjectionPort, ProjectionPortShape, } from '@lmzhen/dsh-evolution-platform-contract';
7
+ /** Resolve the projection port; undefined means the host has no projection registry. */
8
+ export declare function projectionPort(ctx: Context): ProjectionPort | undefined;
9
+ //# sourceMappingURL=projections.d.ts.map
@@ -0,0 +1,34 @@
1
+ const isHandle = (value) => value !== null && typeof value === 'object'
2
+ && typeof value.stateOf === 'function'
3
+ && typeof value.dispose === 'function';
4
+ /** Resolve the projection port; undefined means the host has no projection registry. */
5
+ export function projectionPort(ctx) {
6
+ // platform-declaration anchor: sessionProjections is declared in core PLATFORM_SERVICE_PROBES.
7
+ const registry = ctx.get('sessionProjections');
8
+ if (registry === undefined)
9
+ return undefined;
10
+ let shape = 'unrecognised';
11
+ let reason = 'sessionProjections.register has not answered yet';
12
+ return {
13
+ get shape() { return shape; },
14
+ get reason() { return shape === 'unrecognised' ? reason : undefined; },
15
+ async register(definition) {
16
+ const resolved = await registry.register(definition);
17
+ if (isHandle(resolved)) {
18
+ shape = 'handle';
19
+ reason = undefined;
20
+ return {
21
+ stateOf: (session) => resolved.stateOf(session),
22
+ dispose: () => resolved.dispose(),
23
+ };
24
+ }
25
+ // Keep reads empty, but say so through `shape`/`reason` instead of pretending the
26
+ // units have no data.
27
+ shape = 'unrecognised';
28
+ reason = 'sessionProjections.register returned ' + (resolved === null ? 'null' : typeof resolved)
29
+ + ' without a projection handle';
30
+ return { stateOf: () => undefined, dispose: async () => { } };
31
+ },
32
+ };
33
+ }
34
+ //# sourceMappingURL=projections.js.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Detached review child agent.
3
+ *
4
+ * PTC's `run_code` appends its nested `tool/ptc-dispatch*` frames to
5
+ * `exec.agent.session`. A background review must never write those frames to the
6
+ * parent Session, so the review executor calls the model with a child agent whose
7
+ * `session` is a real, live Session created through the public Session store. The
8
+ * child object is also the scope key of a real scoped context, so the platform's
9
+ * executor selection can attach a PTC executor to this child without touching the
10
+ * parent. This Session is detached from the parent lineage, but is live in the
11
+ * SessionStore so platform tools can resolve its working directory and approval
12
+ * context; the parent Session's seq is therefore untouched.
13
+ *
14
+ * The PTC executor is a platform-provided optional capability, not a family
15
+ * dependency. It is loaded through a runtime probe, never through a declared
16
+ * peer, so one family artifact can remain valid across the declared cohort while
17
+ * a host without PTC mode fails with an explicit unavailable error.
18
+ *
19
+ * @module @lmzhen/dsh-evolution-adapter/review-child
20
+ */
21
+ import { Session } from '@deepseek-ai/dsh-session';
22
+ /** The platform PTC executor is absent or not compatible with this host. */
23
+ export declare class PtcExecutorUnavailableError extends Error {
24
+ readonly code = "PTC_UNAVAILABLE";
25
+ constructor(reason: string);
26
+ }
27
+ export interface ReviewChildAgent {
28
+ /** Parent-shaped agent whose `session` is the detached child. */
29
+ readonly agent: unknown;
30
+ /** The detached Session; exposed for tests and diagnostics. */
31
+ readonly session: Session;
32
+ /** Drop the review child scope, its executor, and the scope-owned child Session. */
33
+ dispose(): Promise<void>;
34
+ }
35
+ export interface ReviewChildOptions {
36
+ /** Mount the PTC tool executor in the child scope (required for PTC programs). */
37
+ readonly ptc?: boolean;
38
+ }
39
+ /**
40
+ * Create a detached review child agent.
41
+ * @param parent - the live parent agent; only its `session` is replaced.
42
+ * @param taskId - review task identity used in the child Session id.
43
+ */
44
+ export declare function createReviewChildAgent(parent: unknown, taskId: string, options?: ReviewChildOptions): Promise<ReviewChildAgent>;
45
+ //# sourceMappingURL=review-child.d.ts.map
@@ -0,0 +1,117 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ /**
10
+ * Detached review child agent.
11
+ *
12
+ * PTC's `run_code` appends its nested `tool/ptc-dispatch*` frames to
13
+ * `exec.agent.session`. A background review must never write those frames to the
14
+ * parent Session, so the review executor calls the model with a child agent whose
15
+ * `session` is a real, live Session created through the public Session store. The
16
+ * child object is also the scope key of a real scoped context, so the platform's
17
+ * executor selection can attach a PTC executor to this child without touching the
18
+ * parent. This Session is detached from the parent lineage, but is live in the
19
+ * SessionStore so platform tools can resolve its working directory and approval
20
+ * context; the parent Session's seq is therefore untouched.
21
+ *
22
+ * The PTC executor is a platform-provided optional capability, not a family
23
+ * dependency. It is loaded through a runtime probe, never through a declared
24
+ * peer, so one family artifact can remain valid across the declared cohort while
25
+ * a host without PTC mode fails with an explicit unavailable error.
26
+ *
27
+ * @module @lmzhen/dsh-evolution-adapter/review-child
28
+ */
29
+ import { Session, SessionId } from '@deepseek-ai/dsh-session';
30
+ import { createScope } from '@deepseek-ai/dsh-scope';
31
+ /** The platform PTC executor is absent or not compatible with this host. */
32
+ export class PtcExecutorUnavailableError extends Error {
33
+ code = 'PTC_UNAVAILABLE';
34
+ constructor(reason) {
35
+ super('PTC executor unavailable: ' + reason);
36
+ this.name = 'PtcExecutorUnavailableError';
37
+ }
38
+ }
39
+ let nextChild = 0;
40
+ /**
41
+ * Probe the platform's optional PTC executor without declaring a family peer.
42
+ * Shape checks fail closed: a host may ship an older/newer package, but an
43
+ * incompatible export must surface as PTC_UNAVAILABLE, not as a generic startup
44
+ * crash. The version is intentionally not inferred from the package name.
45
+ */
46
+ async function loadPtcExecutor() {
47
+ const specifier = '@deepseek-ai/dsh-tool-executor-ptc';
48
+ let module;
49
+ try {
50
+ module = await import(__rewriteRelativeImportExtension(/* @vite-ignore */ specifier));
51
+ }
52
+ catch {
53
+ throw new PtcExecutorUnavailableError('platform package @deepseek-ai/dsh-tool-executor-ptc is not installed');
54
+ }
55
+ if (typeof module.apply !== 'function') {
56
+ throw new PtcExecutorUnavailableError('@deepseek-ai/dsh-tool-executor-ptc has no apply() export');
57
+ }
58
+ if (module.inject !== undefined && (!Array.isArray(module.inject) || !module.inject.every(item => typeof item === 'string'))) {
59
+ throw new PtcExecutorUnavailableError('@deepseek-ai/dsh-tool-executor-ptc has an incompatible inject export');
60
+ }
61
+ return module;
62
+ }
63
+ /**
64
+ * Create a detached review child agent.
65
+ * @param parent - the live parent agent; only its `session` is replaced.
66
+ * @param taskId - review task identity used in the child Session id.
67
+ */
68
+ export async function createReviewChildAgent(parent, taskId, options = {}) {
69
+ const safe = taskId.replace(/[^A-Za-z0-9_.:-]/g, '_');
70
+ const childId = SessionId(`review-child:${safe}:${nextChild++}`);
71
+ const parentSession = parent.session;
72
+ const parentCtx = parent.ctx;
73
+ const cwd = typeof parentSession?.header?.cwd === 'string' ? parentSession.header.cwd : undefined;
74
+ // Object.create keeps the parent's Agent prototype and identity-independent
75
+ // fields while making this object the exact scope key used by tools.execute.
76
+ const agent = Object.create(parent);
77
+ let scope;
78
+ let child;
79
+ try {
80
+ if (parentCtx !== undefined && typeof parentCtx.plugin === 'function') {
81
+ scope = createScope(parentCtx, agent, { parent: parent });
82
+ Object.defineProperty(agent, 'ctx', { value: scope.ctx, enumerable: true, configurable: false });
83
+ }
84
+ // A scope-owned Session is removed with the scope on success or failure.
85
+ // The capture plugin gets `sessions` through Cordis injection; the scope's
86
+ // own ctx is not guaranteed to hold that service without an inject list.
87
+ if (scope !== undefined) {
88
+ const capture = Object.assign((inner) => {
89
+ child = inner.sessions.create(childId, cwd === undefined ? undefined : { meta: { cwd } });
90
+ }, { inject: ['sessions'] });
91
+ await scope.ctx.plugin(capture, {});
92
+ }
93
+ else {
94
+ child = parentCtx?.sessions?.create(childId, cwd === undefined ? undefined : { meta: { cwd } }) ?? Session.create(childId);
95
+ }
96
+ if (child === undefined)
97
+ throw new PtcExecutorUnavailableError('the platform has no session store for the child scope');
98
+ Object.defineProperty(agent, 'session', { value: child, enumerable: true, configurable: false });
99
+ Object.defineProperty(agent, 'id', { value: child.id, enumerable: true, configurable: false });
100
+ if (options.ptc === true) {
101
+ if (scope === undefined)
102
+ throw new PtcExecutorUnavailableError('the parent has no scoped context');
103
+ const plugin = await loadPtcExecutor();
104
+ await scope.ctx.plugin(plugin, {});
105
+ }
106
+ return {
107
+ agent,
108
+ session: child,
109
+ async dispose() { await scope?.dispose(); },
110
+ };
111
+ }
112
+ catch (error) {
113
+ await scope?.dispose().catch(() => { });
114
+ throw error;
115
+ }
116
+ }
117
+ //# sourceMappingURL=review-child.js.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The family's host capability service: one place that resolves the platform
3
+ * ports and reports which halves are available.
4
+ */
5
+ import { Service } from '@deepseek-ai/cordis';
6
+ import type { Context } from '@deepseek-ai/cordis';
7
+ import type { AgentIdentity, HostPlatformPorts } from '@lmzhen/dsh-evolution-platform-contract';
8
+ export type { HostPlatformPorts } from '@lmzhen/dsh-evolution-platform-contract';
9
+ /** Domain service owning the host port table. */
10
+ export declare class EvolutionPlatform extends Service {
11
+ static inject: never[];
12
+ /** The family-facing contract generation this adapter implements. */
13
+ readonly contract: 1;
14
+ constructor(ctx: Context);
15
+ /**
16
+ * Resolve the host ports now. Consumers read this one table; they never fall
17
+ * back to a direct platform import (the second resolution D7 removed).
18
+ * Deliberately uncached: `ctx.get` is the capability lifecycle.
19
+ */
20
+ get ports(): HostPlatformPorts;
21
+ /** Whether an exact live root agent is available for this id. */
22
+ isRootAgent(agent: AgentIdentity): boolean;
23
+ }
24
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The family's host capability service: one place that resolves the platform
3
+ * ports and reports which halves are available.
4
+ */
5
+ import { Service } from '@deepseek-ai/cordis';
6
+ import { CONTRACT } from '@lmzhen/dsh-evolution-platform-contract';
7
+ import { agentsPort } from "./agents.js";
8
+ import { commandsPort } from "./commands.js";
9
+ import { settingsPort } from "./settings.js";
10
+ import { profileContextPort } from "./profileContext.js";
11
+ import { pluginManagerPort, pluginInventoryPort, configEditorPort } from "./platformView.js";
12
+ import { workingDirectoryPort } from "./workingDirectory.js";
13
+ import { skillsPort } from "./skills.js";
14
+ import { storageDomainPort } from "./storageDomain.js";
15
+ import { connectionPort } from "./connection.js";
16
+ import { systemPromptPort } from "./systemPrompt.js";
17
+ import { subagentsPort } from "./subagents.js";
18
+ import { userQuestionsPort } from "./userQuestions.js";
19
+ import { presetsPort } from "./presets.js";
20
+ import { projectionPort } from "./projections.js";
21
+ import { toolsPort } from "./tools.js";
22
+ import { llmPort } from "./llm.js";
23
+ /** Domain service owning the host port table. */
24
+ export class EvolutionPlatform extends Service {
25
+ static inject = [];
26
+ /** The family-facing contract generation this adapter implements. */
27
+ contract = CONTRACT;
28
+ constructor(ctx) {
29
+ super(ctx, 'evolutionPlatform');
30
+ }
31
+ /**
32
+ * Resolve the host ports now. Consumers read this one table; they never fall
33
+ * back to a direct platform import (the second resolution D7 removed).
34
+ * Deliberately uncached: `ctx.get` is the capability lifecycle.
35
+ */
36
+ get ports() {
37
+ return {
38
+ agents: agentsPort(this.ctx),
39
+ connection: connectionPort(this.ctx),
40
+ settings: settingsPort(this.ctx),
41
+ storageDomain: storageDomainPort(this.ctx),
42
+ workingDirectory: workingDirectoryPort(this.ctx),
43
+ pluginManager: pluginManagerPort(this.ctx),
44
+ pluginInventory: pluginInventoryPort(this.ctx),
45
+ configEditor: configEditorPort(this.ctx),
46
+ profileContext: profileContextPort(this.ctx),
47
+ skills: skillsPort(this.ctx),
48
+ commands: commandsPort(this.ctx),
49
+ systemPrompt: systemPromptPort(this.ctx),
50
+ subagents: subagentsPort(this.ctx),
51
+ userQuestions: userQuestionsPort(this.ctx),
52
+ projections: projectionPort(this.ctx),
53
+ llm: llmPort(this.ctx),
54
+ tools: toolsPort(this.ctx),
55
+ presets: presetsPort(this.ctx),
56
+ };
57
+ }
58
+ /** Whether an exact live root agent is available for this id. */
59
+ isRootAgent(agent) {
60
+ return this.ports.agents?.isRoot(agent) === true;
61
+ }
62
+ }
63
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The settings implementation half of the family's platform boundary.
3
+ */
4
+ import type { Context } from '@deepseek-ai/cordis';
5
+ import type { SettingsPort } from '@lmzhen/dsh-evolution-platform-contract';
6
+ export type { SettingsPort } from '@lmzhen/dsh-evolution-platform-contract';
7
+ /** Resolve the settings port; undefined means the host has no settings service. */
8
+ export declare function settingsPort(ctx: Context): SettingsPort | undefined;
9
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1,14 @@
1
+ /** Resolve the settings port; undefined means the host has no settings service. */
2
+ export function settingsPort(ctx) {
3
+ // platform-declaration anchor: settings is declared in core PLATFORM_SERVICE_PROBES.
4
+ const service = ctx.get('settings');
5
+ if (service === undefined)
6
+ return undefined;
7
+ if (typeof service.configure !== 'function' && typeof service.describe !== 'function')
8
+ return undefined;
9
+ return {
10
+ ...(typeof service.configure === 'function' ? { configure: (options, owner) => service.configure(options, owner) } : {}),
11
+ ...(typeof service.describe === 'function' ? { describe: (options) => service.describe(options) } : {}),
12
+ };
13
+ }
14
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The skills implementation half of the family's platform boundary.
3
+ */
4
+ import type { Context } from '@deepseek-ai/cordis';
5
+ import type { SkillsPort } from '@lmzhen/dsh-evolution-platform-contract';
6
+ export type { SkillsPort } from '@lmzhen/dsh-evolution-platform-contract';
7
+ /** Resolve the skills port; undefined means the host has no skills service. */
8
+ export declare function skillsPort(ctx: Context): SkillsPort | undefined;
9
+ //# sourceMappingURL=skills.d.ts.map
@@ -0,0 +1,9 @@
1
+ /** Resolve the skills port; undefined means the host has no skills service. */
2
+ export function skillsPort(ctx) {
3
+ // platform-declaration anchor: skills is declared in core PLATFORM_SERVICE_PROBES.
4
+ const service = ctx.get('skills');
5
+ if (service === undefined || typeof service.list !== 'function')
6
+ return undefined;
7
+ return { list: (options) => service.list(options) };
8
+ }
9
+ //# sourceMappingURL=skills.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The storage-domain implementation half of the family's platform boundary.
3
+ */
4
+ import type { Context } from '@deepseek-ai/cordis';
5
+ import type { StorageDomainPort } from '@lmzhen/dsh-evolution-platform-contract';
6
+ export type { StorageDomainPort } from '@lmzhen/dsh-evolution-platform-contract';
7
+ /** Resolve the storage-domain port; undefined means the host has no provider. */
8
+ export declare function storageDomainPort(ctx: Context): StorageDomainPort | undefined;
9
+ //# sourceMappingURL=storageDomain.d.ts.map
@@ -0,0 +1,9 @@
1
+ /** Resolve the storage-domain port; undefined means the host has no provider. */
2
+ export function storageDomainPort(ctx) {
3
+ // platform-declaration anchor: storageDomain is declared in core PLATFORM_SERVICE_PROBES.
4
+ const service = ctx.get('storageDomain');
5
+ if (service === undefined || typeof service.open !== 'function')
6
+ return undefined;
7
+ return { open: (spec) => service.open(spec) };
8
+ }
9
+ //# sourceMappingURL=storageDomain.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The subagents implementation half of the family's platform boundary.
3
+ */
4
+ import type { Context } from '@deepseek-ai/cordis';
5
+ import type { SubagentsPort } from '@lmzhen/dsh-evolution-platform-contract';
6
+ export type { SubagentActivationPort, SubagentSendOptions, SubagentsPort, } from '@lmzhen/dsh-evolution-platform-contract';
7
+ /** Resolve the subagents port; undefined means the host has no subagents service. */
8
+ export declare function subagentsPort(ctx: Context): SubagentsPort | undefined;
9
+ //# sourceMappingURL=subagents.d.ts.map
@@ -0,0 +1,17 @@
1
+ /** Resolve the subagents port; undefined means the host has no subagents service. */
2
+ export function subagentsPort(ctx) {
3
+ // platform-declaration anchor: subagents is declared in core PLATFORM_SERVICE_PROBES.
4
+ const subagents = ctx.get('subagents');
5
+ if (subagents === undefined
6
+ || typeof subagents.getProvider !== 'function'
7
+ || typeof subagents.startActivation !== 'function')
8
+ return undefined;
9
+ return {
10
+ getProvider: (name) => subagents.getProvider(name),
11
+ start: (spec) => subagents.startActivation(spec),
12
+ ...(typeof subagents.sendMessage === 'function'
13
+ ? { sendMessage: (sender, targetId, content, options) => subagents.sendMessage(sender, targetId, content, options) }
14
+ : {}),
15
+ };
16
+ }
17
+ //# sourceMappingURL=subagents.js.map