@lmzhen/dsh-evolution-core 0.49.0 → 0.50.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 (93) hide show
  1. package/lib/authority-plugin.js +2 -1
  2. package/lib/citations-CZKTUGQF.js +198 -0
  3. package/lib/composition/index.js +2 -2
  4. package/lib/{composition-Cqjbho0t.js → composition-DA8XPfMc.js} +1 -1
  5. package/lib/connection-DAJy7Xjm.js +28 -0
  6. package/lib/{ensure-CAjLGd9f.js → ensure-Bx4ksgJk.js} +15 -5
  7. package/lib/errors.js +2 -0
  8. package/lib/extract-plan-Bru3c9ec.js +271 -0
  9. package/lib/extract.js +240 -0
  10. package/lib/http-routes.js +27 -7
  11. package/lib/index.js +41 -800
  12. package/lib/{numeric-D8js3sqC.js → limits-C9jfvxBl.js} +1 -43
  13. package/lib/{mutation-authority-l57R626O.js → mutation-authority-DQfpXs1O.js} +2 -54
  14. package/lib/numeric-Dc53KQoe.js +43 -0
  15. package/lib/platform/index.js +4 -3
  16. package/lib/platform-DyHnHUmQ.js +251 -0
  17. package/lib/policy.js +3 -2
  18. package/lib/quality-WAU6YatF.js +554 -0
  19. package/lib/restrictor.js +1 -1
  20. package/lib/result.js +33 -0
  21. package/lib/runtime/plugin.js +97 -43
  22. package/lib/{session-projection-DSXnUNZG.js → session-projection-ByNxQi9O.js} +2 -198
  23. package/lib/skill-health-Bl-MdXZ4.js +1409 -0
  24. package/lib/skills.js +7 -4
  25. package/lib/state-store-Jpa-iYIZ.js +54 -0
  26. package/lib/subagent/index.js +214 -176
  27. package/lib/{tools-DzcNFex2.js → tools-BrUswg8v.js} +3 -1
  28. package/lib/types/composition/ensure.js +21 -7
  29. package/lib/types/extract-plan.d.ts +2 -0
  30. package/lib/types/extract.d.ts +12 -0
  31. package/lib/types/extract.js +12 -0
  32. package/lib/types/http-routes.js +32 -9
  33. package/lib/types/index.d.ts +0 -3
  34. package/lib/types/index.js +0 -3
  35. package/lib/types/opt-in.js +4 -3
  36. package/lib/types/params.js +2 -1
  37. package/lib/types/platform/agents.d.ts +32 -0
  38. package/lib/types/platform/agents.js +26 -0
  39. package/lib/types/platform/commands.d.ts +14 -0
  40. package/lib/types/platform/commands.js +9 -0
  41. package/lib/types/platform/connection.d.ts +26 -0
  42. package/lib/types/platform/connection.js +27 -0
  43. package/lib/types/platform/index.d.ts +26 -0
  44. package/lib/types/platform/index.js +13 -0
  45. package/lib/types/platform/llm.d.ts +3 -1
  46. package/lib/types/platform/llm.js +1 -0
  47. package/lib/types/platform/platformView.d.ts +21 -0
  48. package/lib/types/platform/platformView.js +29 -0
  49. package/lib/types/platform/profileContext.d.ts +16 -0
  50. package/lib/types/platform/profileContext.js +14 -0
  51. package/lib/types/platform/sessionQuery.d.ts +14 -0
  52. package/lib/types/platform/sessionQuery.js +9 -0
  53. package/lib/types/platform/settings.d.ts +22 -0
  54. package/lib/types/platform/settings.js +14 -0
  55. package/lib/types/platform/skills.d.ts +16 -0
  56. package/lib/types/platform/skills.js +9 -0
  57. package/lib/types/platform/storageDomain.d.ts +13 -0
  58. package/lib/types/platform/storageDomain.js +9 -0
  59. package/lib/types/platform/subagents.d.ts +25 -0
  60. package/lib/types/platform/subagents.js +17 -0
  61. package/lib/types/platform/systemPrompt.d.ts +16 -0
  62. package/lib/types/platform/systemPrompt.js +13 -0
  63. package/lib/types/platform/tools.d.ts +4 -0
  64. package/lib/types/platform/tools.js +2 -0
  65. package/lib/types/platform/userQuestions.d.ts +33 -0
  66. package/lib/types/platform/userQuestions.js +9 -0
  67. package/lib/types/platform/workingDirectory.d.ts +14 -0
  68. package/lib/types/platform/workingDirectory.js +9 -0
  69. package/lib/types/platform-line.generated.d.ts +5 -5
  70. package/lib/types/platform-line.generated.js +5 -5
  71. package/lib/types/platform-services.js +3 -0
  72. package/lib/types/result.d.ts +35 -0
  73. package/lib/types/result.js +25 -0
  74. package/lib/types/runtime/llm.d.ts +2 -2
  75. package/lib/types/runtime/llm.js +5 -8
  76. package/lib/types/runtime/platform.d.ts +37 -4
  77. package/lib/types/runtime/platform.js +40 -5
  78. package/lib/types/runtime/projections.d.ts +9 -4
  79. package/lib/types/runtime/projections.js +64 -28
  80. package/lib/types/subagent/channel.d.ts +1 -3
  81. package/lib/types/subagent/channel.js +2 -332
  82. package/lib/types/subagent/index.d.ts +2 -0
  83. package/lib/types/subagent/index.js +2 -0
  84. package/lib/types/subagent/kernel.d.ts +4 -0
  85. package/lib/types/subagent/kernel.js +234 -0
  86. package/lib/types/subagent/readiness.js +5 -7
  87. package/lib/types/subagent/run.d.ts +53 -0
  88. package/lib/types/subagent/run.js +125 -0
  89. package/lib/types/subagent/types.d.ts +2 -2
  90. package/lib/usage-DdjIBAkm.js +1252 -0
  91. package/package.json +37 -25
  92. package/lib/platform-Cc9cNt5j.js +0 -111
  93. package/lib/skill-health-DP8z9TPf.js +0 -2923
@@ -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
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The system-prompt half of the family's host platform boundary.
3
+ *
4
+ * The family registers one optional guidance section and its live variable; a
5
+ * host without system-prompt keeps booting, so the port is optional.
6
+ */
7
+ import type { Context } from '@deepseek-ai/cordis';
8
+ import type { PromptContext, PromptSection } from '@deepseek-ai/dsh-system-prompt';
9
+ export interface SystemPromptPort {
10
+ section(section: PromptSection): () => void;
11
+ variable(name: string, provider: (context: unknown) => string | undefined): () => void;
12
+ context?(context: PromptContext): () => void;
13
+ }
14
+ /** Resolve the system-prompt port; undefined means the host has no such service. */
15
+ export declare function systemPromptPort(ctx: Context): SystemPromptPort | undefined;
16
+ //# sourceMappingURL=systemPrompt.d.ts.map
@@ -0,0 +1,13 @@
1
+ /** Resolve the system-prompt port; undefined means the host has no such service. */
2
+ export function systemPromptPort(ctx) {
3
+ // platform-declaration anchor: systemPrompt is declared in core PLATFORM_SERVICE_PROBES.
4
+ const service = ctx.get('systemPrompt');
5
+ if (service === undefined || typeof service.section !== 'function' || typeof service.variable !== 'function')
6
+ return undefined;
7
+ return {
8
+ section: (section) => service.section(section),
9
+ variable: (name, provider) => service.variable(name, provider),
10
+ ...(typeof service.context === 'function' ? { context: (context) => service.context(context) } : {}),
11
+ };
12
+ }
13
+ //# sourceMappingURL=systemPrompt.js.map
@@ -12,6 +12,10 @@ export interface ToolsPort {
12
12
  register(definition: ToolDefinition): () => void;
13
13
  guard(guard: ToolGuard): () => void;
14
14
  restrict(filter: ToolRestriction): () => void;
15
+ /** The visible tool under this scope, or undefined; the opt-in probe reads this. */
16
+ get(name: string, scope?: unknown): unknown;
17
+ /** Raw execute for callers that own the platform call shape (review aux path). */
18
+ execute?<T = unknown>(input: unknown): Promise<T>;
15
19
  }
16
20
  /**
17
21
  * Resolve the tools port from a context; undefined means the host has no tools service.
@@ -12,6 +12,8 @@ export function toolsPort(ctx) {
12
12
  register: (definition) => tools.register(definition),
13
13
  guard: (guard) => tools.guard(guard),
14
14
  restrict: (filter) => tools.restrict(filter),
15
+ get: (name, scope) => tools.get(name, scope),
16
+ ...(typeof tools.execute === 'function' ? { execute: (input) => tools.execute(input) } : {}),
15
17
  };
16
18
  }
17
19
  /** Register one family tool through the port; a missing service yields a no-op disposer. */
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The human-question half of the family's host platform boundary.
3
+ *
4
+ * `ask` is the only face the skill-write confirmation gate needs; the platform
5
+ * owns live-root admission and delivery. The port returns the bare answer shape
6
+ * so feature code does not import the user-questions package.
7
+ */
8
+ import type { Context } from '@deepseek-ai/cordis';
9
+ export interface UserQuestionOption {
10
+ readonly label: string;
11
+ }
12
+ export interface UserQuestion {
13
+ readonly id: string;
14
+ readonly header?: string;
15
+ readonly question: string;
16
+ readonly options?: readonly UserQuestionOption[];
17
+ }
18
+ export interface AskedQuestions {
19
+ readonly answers: readonly {
20
+ readonly id: string;
21
+ readonly selected: readonly string[];
22
+ }[];
23
+ }
24
+ export interface UserQuestionsPort {
25
+ ask(request: {
26
+ readonly questions: readonly UserQuestion[];
27
+ readonly agent?: unknown;
28
+ readonly signal?: AbortSignal;
29
+ }): Promise<AskedQuestions>;
30
+ }
31
+ /** Resolve the user-questions port; undefined means the host has no such service. */
32
+ export declare function userQuestionsPort(ctx: Context): UserQuestionsPort | undefined;
33
+ //# sourceMappingURL=userQuestions.d.ts.map
@@ -0,0 +1,9 @@
1
+ /** Resolve the user-questions port; undefined means the host has no such service. */
2
+ export function userQuestionsPort(ctx) {
3
+ // platform-declaration anchor: userQuestions is declared in core PLATFORM_SERVICE_PROBES.
4
+ const service = ctx.get('userQuestions');
5
+ if (service === undefined || typeof service.ask !== 'function')
6
+ return undefined;
7
+ return { ask: (request) => service.ask(request) };
8
+ }
9
+ //# sourceMappingURL=userQuestions.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The working-directory half of the family's host platform boundary.
3
+ *
4
+ * The platform resolves the session's cwd; the family only asks, keeping the
5
+ * scope/cwd policy in one host seam.
6
+ */
7
+ import type { Context } from '@deepseek-ai/cordis';
8
+ import type { Agent } from '@deepseek-ai/dsh-agent';
9
+ export interface WorkingDirectoryPort {
10
+ ensure(agent: Agent, signal?: AbortSignal): Promise<string>;
11
+ }
12
+ /** Resolve the working-directory port; undefined means the host has no such service. */
13
+ export declare function workingDirectoryPort(ctx: Context): WorkingDirectoryPort | undefined;
14
+ //# sourceMappingURL=workingDirectory.d.ts.map
@@ -0,0 +1,9 @@
1
+ /** Resolve the working-directory port; undefined means the host has no such service. */
2
+ export function workingDirectoryPort(ctx) {
3
+ // platform-declaration anchor: workingDirectory is declared in core PLATFORM_SERVICE_PROBES.
4
+ const service = ctx.get('workingDirectory');
5
+ if (service === undefined || typeof service.ensure !== 'function')
6
+ return undefined;
7
+ return { ensure: (agent, signal) => service.ensure(agent, signal) };
8
+ }
9
+ //# sourceMappingURL=workingDirectory.js.map
@@ -1,10 +1,10 @@
1
1
  /** The frozen platform line this release targets (peers/engines/anchors derived from version+floor). */
2
2
  export declare const PLATFORM_LINE: {
3
- readonly version: "0.2.2-rc.1";
4
- readonly floor: "0.2.2-rc.0";
3
+ readonly version: "0.2.2-rc.3";
4
+ readonly floor: "0.2.2-rc.3";
5
5
  readonly previousAnchor: "0.2.1-rc.2";
6
- readonly peersRange: "^0.2.2-rc.0";
7
- readonly enginesRange: ">=0.2.2-rc.0 <0.2.3-0";
8
- readonly upstreamRef: "dsh-v0.2.2-rc.1";
6
+ readonly peersRange: "^0.2.2-rc.3";
7
+ readonly enginesRange: ">=0.2.2-rc.3 <0.2.3-0";
8
+ readonly upstreamRef: "dsh-v0.2.2-rc.3";
9
9
  };
10
10
  //# sourceMappingURL=platform-line.generated.d.ts.map
@@ -2,11 +2,11 @@
2
2
  // Regenerate with: node packages/scripts/gen-platform-line.mjs
3
3
  /** The frozen platform line this release targets (peers/engines/anchors derived from version+floor). */
4
4
  export const PLATFORM_LINE = {
5
- version: '0.2.2-rc.1',
6
- floor: '0.2.2-rc.0',
5
+ version: '0.2.2-rc.3',
6
+ floor: '0.2.2-rc.3',
7
7
  previousAnchor: '0.2.1-rc.2',
8
- peersRange: '^0.2.2-rc.0',
9
- enginesRange: '>=0.2.2-rc.0 <0.2.3-0',
10
- upstreamRef: 'dsh-v0.2.2-rc.1',
8
+ peersRange: '^0.2.2-rc.3',
9
+ enginesRange: '>=0.2.2-rc.3 <0.2.3-0',
10
+ upstreamRef: 'dsh-v0.2.2-rc.3',
11
11
  };
12
12
  //# sourceMappingURL=platform-line.generated.js.map
@@ -18,6 +18,7 @@ export const PLATFORM_SERVICE_PROBES = Object.freeze([
18
18
  { service: 'agents', feature: 'review and curator subagent wake-ups', side: 'host' },
19
19
  { service: 'approval', feature: 'the platform approval policy the approval row shadows', side: 'host' },
20
20
  { service: 'commands', feature: 'the /skill-domain confirmation command surface', side: 'host' },
21
+ { service: 'connection', feature: 'the platform exact-route carrier for family host routes', side: 'host' },
21
22
  { service: 'configEditor', feature: 'the params view inherited-vs-override column', side: 'host' },
22
23
  { service: 'configForms', feature: 'the platform config-form seat the settings page renders through', side: 'client' },
23
24
  { service: 'evolutionApproval', feature: 'pending writes: list, approve and reject from the command surface', side: 'host' },
@@ -43,8 +44,10 @@ export const PLATFORM_SERVICE_PROBES = Object.freeze([
43
44
  { service: 'skillUsage', feature: 'usage counters feeding the curator and the review planner', side: 'host' },
44
45
  { service: 'skills', feature: 'the platform skill catalog the skill tool writes through', side: 'host' },
45
46
  { service: 'storageDomain', feature: 'the storage-domain state provider', side: 'host' },
47
+ { service: 'subagents', feature: 'the review/curator subagent execution kernel', side: 'host' },
46
48
  { service: 'systemPrompt', feature: 'the protected-skills prompt variable', side: 'host' },
47
49
  { service: 'tools', feature: 'tool registration and the guard seam', side: 'host' },
50
+ { service: 'userQuestions', feature: 'the owner confirmation prompt behind skill writes', side: 'host' },
48
51
  { service: 'workingDirectory', feature: 'the cwd used for skill snapshots and per-view policy files', side: 'host' },
49
52
  ]);
50
53
  /**
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The family's Result/error vocabulary for new boundaries.
3
+ *
4
+ * Existing surfaces keep their structured `{ ok, message }` policy; this module
5
+ * is the typed seam for code that wants an explicit success/failure value
6
+ * without throwing through a domain boundary.
7
+ */
8
+ export type FamilyErrorCode = 'E-301' | 'E-302' | 'E-303' | 'E-304' | 'E-305' | 'E-306' | 'E-307' | 'E-308' | 'E-309' | 'E-310' | 'E-311' | 'E-312' | 'E-313' | 'E-314' | 'E-315' | 'E-316' | 'E-317' | 'E-318' | 'E-319' | 'E-320' | 'E-321' | 'E-322' | 'E-323' | 'E-324' | 'E-325' | 'E-326';
9
+ export interface FamilyError {
10
+ readonly code: FamilyErrorCode;
11
+ readonly message: string;
12
+ readonly cause?: unknown;
13
+ }
14
+ export type Result<T, E = FamilyError> = {
15
+ readonly ok: true;
16
+ readonly value: T;
17
+ } | {
18
+ readonly ok: false;
19
+ readonly error: E;
20
+ };
21
+ export declare function ok<T>(value: T): Result<T, never>;
22
+ export declare function err<E>(error: E): Result<never, E>;
23
+ export declare function isOk<T, E>(result: Result<T, E>): result is {
24
+ readonly ok: true;
25
+ readonly value: T;
26
+ };
27
+ export declare function isErr<T, E>(result: Result<T, E>): result is {
28
+ readonly ok: false;
29
+ readonly error: E;
30
+ };
31
+ /** The value, or the supplied fallback when the result is an error. */
32
+ export declare function unwrapOr<T, E>(result: Result<T, E>, fallback: T): T;
33
+ /** Coerce a caught value into the family error shape. */
34
+ export declare function familyError(code: FamilyErrorCode, cause: unknown): FamilyError;
35
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1,25 @@
1
+ export function ok(value) {
2
+ return { ok: true, value };
3
+ }
4
+ export function err(error) {
5
+ return { ok: false, error };
6
+ }
7
+ export function isOk(result) {
8
+ return result.ok;
9
+ }
10
+ export function isErr(result) {
11
+ return !result.ok;
12
+ }
13
+ /** The value, or the supplied fallback when the result is an error. */
14
+ export function unwrapOr(result, fallback) {
15
+ return result.ok ? result.value : fallback;
16
+ }
17
+ /** Coerce a caught value into the family error shape. */
18
+ export function familyError(code, cause) {
19
+ return {
20
+ code,
21
+ message: cause instanceof Error ? cause.message : String(cause),
22
+ ...(cause === undefined ? {} : { cause }),
23
+ };
24
+ }
25
+ //# sourceMappingURL=result.js.map
@@ -19,9 +19,9 @@ export interface EvolutionLlmInput {
19
19
  /** Domain service for every auxiliary LLM request in the family. */
20
20
  export declare class EvolutionLlm extends Service {
21
21
  static inject: never[];
22
- private port;
23
22
  constructor(ctx: Context);
24
- protected [Service.init](): void;
23
+ /** Resolve the port per call so a late-mounted llm service is usable. */
24
+ private port;
25
25
  /** Whether the platform llm service is mounted. */
26
26
  available(): boolean;
27
27
  /** One assembled text response. */
@@ -7,18 +7,15 @@ import { EvolutionLlmError, modelRoute } from "../platform/index.js";
7
7
  /** Domain service for every auxiliary LLM request in the family. */
8
8
  export class EvolutionLlm extends Service {
9
9
  static inject = [];
10
- port;
11
10
  constructor(ctx) {
12
11
  super(ctx, 'evolutionLlm');
13
12
  }
14
- [Service.init]() {
15
- const platform = this.ctx.get('evolutionPlatform');
16
- this.port = platform?.ports.llm;
17
- if (this.port === undefined)
18
- this.ctx.logger.warn('evolution-core-runtime: llm service unavailable; model calls fail with llm-unavailable');
13
+ /** Resolve the port per call so a late-mounted llm service is usable. */
14
+ port() {
15
+ return this.ctx.get('evolutionPlatform')?.ports.llm;
19
16
  }
20
17
  /** Whether the platform llm service is mounted. */
21
- available() { return this.port !== undefined; }
18
+ available() { return this.port() !== undefined; }
22
19
  /** One assembled text response. */
23
20
  async text(input) {
24
21
  const prepared = this.prepare(input);
@@ -40,7 +37,7 @@ export class EvolutionLlm extends Service {
40
37
  }
41
38
  }
42
39
  prepare(input) {
43
- const port = this.port;
40
+ const port = this.port();
44
41
  if (port === undefined)
45
42
  throw new EvolutionLlmError('model-unavailable', 'llm-unavailable: no llm service is mounted');
46
43
  const route = input.route ?? modelRoute(this.ctx, input.agent, input.session);
@@ -2,15 +2,47 @@
2
2
  * The family's host capability service: one place that resolves the platform
3
3
  * ports and reports which halves are available. Feature code reads ports from
4
4
  * this service; the port modules remain the only @deepseek-ai/dsh-* importers.
5
+ *
6
+ * The table is resolved on every read. A missing optional service is not a
7
+ * permanent capability loss: it may mount after this service initializes, and
8
+ * the next read must see it.
5
9
  */
6
10
  import { Service } from '@deepseek-ai/cordis';
7
11
  import type { Context } from '@deepseek-ai/cordis';
12
+ import type { AgentIdentity, AgentsPort } from '../platform/agents.ts';
13
+ import type { CommandsPort } from '../platform/commands.ts';
14
+ import type { ProfileContextPort } from '../platform/profileContext.ts';
15
+ import type { PluginManagerPort, PluginInventoryPort, ConfigEditorPort } from '../platform/platformView.ts';
16
+ import type { WorkingDirectoryPort } from '../platform/workingDirectory.ts';
17
+ import type { SkillsPort } from '../platform/skills.ts';
18
+ import type { SessionQueryPort } from '../platform/sessionQuery.ts';
19
+ import type { SettingsPort } from '../platform/settings.ts';
20
+ import type { StorageDomainPort } from '../platform/storageDomain.ts';
21
+ import type { ConnectionPort } from '../platform/connection.ts';
22
+ import type { SystemPromptPort } from '../platform/systemPrompt.ts';
23
+ import type { SubagentsPort } from '../platform/subagents.ts';
24
+ import type { UserQuestionsPort } from '../platform/userQuestions.ts';
8
25
  import type { LlmPort } from '../platform/llm.ts';
9
26
  import type { PresetsPort } from '../platform/presets.ts';
10
27
  import type { ProjectionPort } from '../platform/projections.ts';
11
28
  import type { ToolsPort } from '../platform/tools.ts';
12
29
  /** Resolved host ports and their availability. */
13
30
  export interface HostPlatformPorts {
31
+ readonly agents: AgentsPort | undefined;
32
+ readonly connection: ConnectionPort | undefined;
33
+ readonly settings: SettingsPort | undefined;
34
+ readonly storageDomain: StorageDomainPort | undefined;
35
+ readonly workingDirectory: WorkingDirectoryPort | undefined;
36
+ readonly pluginManager: PluginManagerPort | undefined;
37
+ readonly pluginInventory: PluginInventoryPort | undefined;
38
+ readonly configEditor: ConfigEditorPort | undefined;
39
+ readonly profileContext: ProfileContextPort | undefined;
40
+ readonly skills: SkillsPort | undefined;
41
+ readonly sessionQuery: SessionQueryPort | undefined;
42
+ readonly commands: CommandsPort | undefined;
43
+ readonly systemPrompt: SystemPromptPort | undefined;
44
+ readonly subagents: SubagentsPort | undefined;
45
+ readonly userQuestions: UserQuestionsPort | undefined;
14
46
  readonly projections: ProjectionPort | undefined;
15
47
  readonly llm: LlmPort | undefined;
16
48
  readonly tools: ToolsPort | undefined;
@@ -19,13 +51,14 @@ export interface HostPlatformPorts {
19
51
  /** Domain service owning the host port table. */
20
52
  export declare class EvolutionPlatform extends Service {
21
53
  static inject: never[];
22
- private resolved;
23
54
  constructor(ctx: Context);
24
55
  /**
25
- * Resolve the host ports on first use and keep that answer for the service
26
- * lifetime. Consumers read this one table; they never fall back to a direct
27
- * platform import (the second resolution D7 removed).
56
+ * Resolve the host ports now. Consumers read this one table; they never fall
57
+ * back to a direct platform import (the second resolution D7 removed).
58
+ * Deliberately uncached: `ctx.get` is the capability lifecycle.
28
59
  */
29
60
  get ports(): HostPlatformPorts;
61
+ /** Whether an exact live root agent is available for this id. */
62
+ isRootAgent(agent: AgentIdentity): boolean;
30
63
  }
31
64
  //# sourceMappingURL=platform.d.ts.map
@@ -2,8 +2,25 @@
2
2
  * The family's host capability service: one place that resolves the platform
3
3
  * ports and reports which halves are available. Feature code reads ports from
4
4
  * this service; the port modules remain the only @deepseek-ai/dsh-* importers.
5
+ *
6
+ * The table is resolved on every read. A missing optional service is not a
7
+ * permanent capability loss: it may mount after this service initializes, and
8
+ * the next read must see it.
5
9
  */
6
10
  import { Service } from '@deepseek-ai/cordis';
11
+ import { agentsPort } from "../platform/agents.js";
12
+ import { commandsPort } from "../platform/commands.js";
13
+ import { settingsPort } from "../platform/settings.js";
14
+ import { profileContextPort } from "../platform/profileContext.js";
15
+ import { pluginManagerPort, pluginInventoryPort, configEditorPort } from "../platform/platformView.js";
16
+ import { workingDirectoryPort } from "../platform/workingDirectory.js";
17
+ import { skillsPort } from "../platform/skills.js";
18
+ import { sessionQueryPort } from "../platform/sessionQuery.js";
19
+ import { storageDomainPort } from "../platform/storageDomain.js";
20
+ import { connectionPort } from "../platform/connection.js";
21
+ import { systemPromptPort } from "../platform/systemPrompt.js";
22
+ import { subagentsPort } from "../platform/subagents.js";
23
+ import { userQuestionsPort } from "../platform/userQuestions.js";
7
24
  import { presetsPort } from "../platform/presets.js";
8
25
  import { projectionPort } from "../platform/projections.js";
9
26
  import { toolsPort } from "../platform/tools.js";
@@ -11,22 +28,40 @@ import { llmPort } from "../platform/llm.js";
11
28
  /** Domain service owning the host port table. */
12
29
  export class EvolutionPlatform extends Service {
13
30
  static inject = [];
14
- resolved;
15
31
  constructor(ctx) {
16
32
  super(ctx, 'evolutionPlatform');
17
33
  }
18
34
  /**
19
- * Resolve the host ports on first use and keep that answer for the service
20
- * lifetime. Consumers read this one table; they never fall back to a direct
21
- * platform import (the second resolution D7 removed).
35
+ * Resolve the host ports now. Consumers read this one table; they never fall
36
+ * back to a direct platform import (the second resolution D7 removed).
37
+ * Deliberately uncached: `ctx.get` is the capability lifecycle.
22
38
  */
23
39
  get ports() {
24
- return this.resolved ??= {
40
+ return {
41
+ agents: agentsPort(this.ctx),
42
+ connection: connectionPort(this.ctx),
43
+ settings: settingsPort(this.ctx),
44
+ storageDomain: storageDomainPort(this.ctx),
45
+ workingDirectory: workingDirectoryPort(this.ctx),
46
+ pluginManager: pluginManagerPort(this.ctx),
47
+ pluginInventory: pluginInventoryPort(this.ctx),
48
+ configEditor: configEditorPort(this.ctx),
49
+ profileContext: profileContextPort(this.ctx),
50
+ skills: skillsPort(this.ctx),
51
+ sessionQuery: sessionQueryPort(this.ctx),
52
+ commands: commandsPort(this.ctx),
53
+ systemPrompt: systemPromptPort(this.ctx),
54
+ subagents: subagentsPort(this.ctx),
55
+ userQuestions: userQuestionsPort(this.ctx),
25
56
  projections: projectionPort(this.ctx),
26
57
  llm: llmPort(this.ctx),
27
58
  tools: toolsPort(this.ctx),
28
59
  presets: presetsPort(this.ctx),
29
60
  };
30
61
  }
62
+ /** Whether an exact live root agent is available for this id. */
63
+ isRootAgent(agent) {
64
+ return this.ports.agents?.isRoot(agent) === true;
65
+ }
31
66
  }
32
67
  //# sourceMappingURL=platform.js.map
@@ -1,8 +1,8 @@
1
1
  /**
2
- * The family's projection runtime: register the five host-only units once and
3
- * expose typed reads to the pure readers. Missing registry or a registration
4
- * failure degrades to undefined (the existing fail-open posture), never throws
5
- * into the host.
2
+ * The family's projection runtime: register the five host-only units and expose
3
+ * typed reads to the pure readers. Registration follows the projection service
4
+ * lifecycle: if `sessionProjections` mounts later (or is replaced), the units
5
+ * attach then; a missing registry is not a permanent capability loss.
6
6
  */
7
7
  import { Service } from '@deepseek-ai/cordis';
8
8
  import type { Context } from '@deepseek-ai/cordis';
@@ -13,6 +13,7 @@ export declare class EvolutionProjections extends Service {
13
13
  static inject: never[];
14
14
  private handles;
15
15
  private degradedReason;
16
+ private generation;
16
17
  constructor(ctx: Context);
17
18
  protected [Service.init](): Promise<void>;
18
19
  /** Whether the five units are registered and readable. */
@@ -24,6 +25,10 @@ export declare class EvolutionProjections extends Service {
24
25
  reads(session: Session): EvolutionReadsState | undefined;
25
26
  history(session: Session): EvolutionProjectionHistoryState | undefined;
26
27
  signals(session: Session): EvolutionSignalsState | undefined;
28
+ private attach;
29
+ private detach;
30
+ private detachHandles;
31
+ private disposePartial;
27
32
  private markDegraded;
28
33
  }
29
34
  //# sourceMappingURL=projections.d.ts.map
@@ -1,8 +1,8 @@
1
1
  /**
2
- * The family's projection runtime: register the five host-only units once and
3
- * expose typed reads to the pure readers. Missing registry or a registration
4
- * failure degrades to undefined (the existing fail-open posture), never throws
5
- * into the host.
2
+ * The family's projection runtime: register the five host-only units and expose
3
+ * typed reads to the pure readers. Registration follows the projection service
4
+ * lifecycle: if `sessionProjections` mounts later (or is replaced), the units
5
+ * attach then; a missing registry is not a permanent capability loss.
6
6
  */
7
7
  import { Service } from '@deepseek-ai/cordis';
8
8
  import { evolutionActivityProjection, evolutionEvidenceProjection, evolutionProjectionHistoryProjection, evolutionReadsProjection, evolutionSignalsProjection, } from "../session-projection.js";
@@ -11,11 +11,41 @@ export class EvolutionProjections extends Service {
11
11
  static inject = [];
12
12
  handles;
13
13
  degradedReason;
14
+ generation = 0;
14
15
  constructor(ctx) {
15
16
  super(ctx, 'evolutionProjections');
16
17
  }
17
18
  async [Service.init]() {
18
- const platform = this.ctx.get('evolutionPlatform');
19
+ // Normal compositions mount the registry before this service: attach now so
20
+ // the first reader observes registered units, exactly like the previous
21
+ // awaited init. Only a missing registry takes the lifecycle path.
22
+ // platform-declaration anchor: sessionProjections is declared in core PLATFORM_SERVICE_PROBES.
23
+ if (this.ctx.get('sessionProjections') !== undefined) {
24
+ await this.attach(this.ctx);
25
+ return;
26
+ }
27
+ this.ctx.inject(['evolutionPlatform', 'sessionProjections'], (scope) => {
28
+ void this.attach(scope);
29
+ return () => { void this.detach(); };
30
+ });
31
+ }
32
+ /** Whether the five units are registered and readable. */
33
+ status() {
34
+ return this.handles === undefined ? 'degraded' : 'ready';
35
+ }
36
+ /** Why the service is degraded; undefined while ready. */
37
+ reason() {
38
+ return this.handles === undefined ? this.degradedReason : undefined;
39
+ }
40
+ activity(session) { return this.handles?.activity.stateOf(session); }
41
+ evidence(session) { return this.handles?.evidence.stateOf(session); }
42
+ reads(session) { return this.handles?.reads.stateOf(session); }
43
+ history(session) { return this.handles?.history.stateOf(session); }
44
+ signals(session) { return this.handles?.signals.stateOf(session); }
45
+ async attach(scope) {
46
+ const generation = ++this.generation;
47
+ await this.detachHandles();
48
+ const platform = scope.get('evolutionPlatform');
19
49
  const port = platform?.ports.projections;
20
50
  if (port === undefined) {
21
51
  this.markDegraded('sessionProjections service unavailable');
@@ -28,43 +58,49 @@ export class EvolutionProjections extends Service {
28
58
  partial.reads = await port.register(evolutionReadsProjection);
29
59
  partial.history = await port.register(evolutionProjectionHistoryProjection);
30
60
  partial.signals = await port.register(evolutionSignalsProjection);
61
+ if (generation !== this.generation) {
62
+ await this.disposePartial(partial);
63
+ return;
64
+ }
31
65
  if (port.shape === 'unrecognised') {
32
66
  // A registered service whose reads are silently empty is DEGRADED, not "no projection data":
33
67
  // roll the registrations back and say why (audit 06-P1).
34
- for (const handle of Object.values(partial).reverse()) {
35
- try {
36
- await handle.dispose();
37
- }
38
- catch { /* best-effort rollback */ }
39
- }
68
+ await this.disposePartial(partial);
40
69
  this.markDegraded('projection port shape not recognised: ' + (port.reason ?? 'no reason reported'));
41
70
  return;
42
71
  }
43
72
  this.handles = partial;
73
+ this.degradedReason = undefined;
44
74
  }
45
75
  catch (error) {
46
- for (const handle of Object.values(partial).reverse()) {
47
- try {
48
- await handle.dispose();
49
- }
50
- catch { /* best-effort rollback; keep the original failure */ }
51
- }
76
+ await this.disposePartial(partial);
52
77
  this.markDegraded('projection registration failed: ' + (error instanceof Error ? error.message : String(error)));
53
78
  }
54
79
  }
55
- /** Whether the five units are registered and readable. */
56
- status() {
57
- return this.handles === undefined ? 'degraded' : 'ready';
80
+ async detach() {
81
+ this.generation += 1;
82
+ await this.detachHandles();
58
83
  }
59
- /** Why the service is degraded; undefined while ready. */
60
- reason() {
61
- return this.handles === undefined ? this.degradedReason : undefined;
84
+ async detachHandles() {
85
+ const handles = this.handles;
86
+ this.handles = undefined;
87
+ if (handles === undefined)
88
+ return;
89
+ for (const handle of Object.values(handles).reverse()) {
90
+ try {
91
+ await handle.dispose();
92
+ }
93
+ catch { /* best-effort teardown */ }
94
+ }
95
+ }
96
+ async disposePartial(partial) {
97
+ for (const handle of Object.values(partial).reverse()) {
98
+ try {
99
+ await handle.dispose();
100
+ }
101
+ catch { /* best-effort rollback */ }
102
+ }
62
103
  }
63
- activity(session) { return this.handles?.activity.stateOf(session); }
64
- evidence(session) { return this.handles?.evidence.stateOf(session); }
65
- reads(session) { return this.handles?.reads.stateOf(session); }
66
- history(session) { return this.handles?.history.stateOf(session); }
67
- signals(session) { return this.handles?.signals.stateOf(session); }
68
104
  markDegraded(reason) {
69
105
  this.degradedReason = reason;
70
106
  this.ctx.logger.warn('evolution-core-runtime: %s; projection reads degrade to undefined', reason);
@@ -1,4 +1,2 @@
1
- import type { Context } from '@deepseek-ai/cordis';
2
- import type { SubagentChannel } from './types.ts';
3
- export declare function createSubagentChannel(ctx: Context): SubagentChannel;
1
+ export { createSubagentKernel as createSubagentChannel } from './kernel.ts';
4
2
  //# sourceMappingURL=channel.d.ts.map