@lmzhen/dsh-evolution-core 0.37.1 → 0.38.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 (47) hide show
  1. package/README.md +3 -1
  2. package/lib/composition/index.js +2 -2
  3. package/lib/{composition-DckDtQTR.js → composition-dy0gJWDd.js} +1 -1
  4. package/lib/{ensure-CLF9YeBD.js → ensure-B4fjEI0w.js} +3 -10
  5. package/lib/index.js +28 -1296
  6. package/lib/platform/index.js +4 -0
  7. package/lib/platform-Be-_wSVz.js +113 -0
  8. package/lib/presets-C8vuCuNA.js +27 -0
  9. package/lib/restrictor.js +7 -7
  10. package/lib/runtime/plugin.js +197 -0
  11. package/lib/session-projection-CXUNPkq9.js +1250 -0
  12. package/lib/subagent/index.js +1 -1
  13. package/lib/tools-DzcNFex2.js +20 -0
  14. package/lib/types/composition/ensure.js +3 -13
  15. package/lib/types/opt-in.d.ts +1 -1
  16. package/lib/types/opt-in.js +1 -1
  17. package/lib/types/platform/index.d.ts +21 -0
  18. package/lib/types/platform/index.js +12 -0
  19. package/lib/types/platform/llm.d.ts +46 -0
  20. package/lib/types/platform/llm.js +75 -0
  21. package/lib/types/platform/presets.d.ts +31 -0
  22. package/lib/types/platform/presets.js +31 -0
  23. package/lib/types/platform/projections.d.ts +30 -0
  24. package/lib/types/platform/projections.js +31 -0
  25. package/lib/types/platform/tools.d.ts +23 -0
  26. package/lib/types/platform/tools.js +21 -0
  27. package/lib/types/platform-line.generated.d.ts +6 -6
  28. package/lib/types/platform-line.generated.js +6 -6
  29. package/lib/types/platform-services.d.ts +1 -1
  30. package/lib/types/platform-services.js +4 -1
  31. package/lib/types/restrictor.js +7 -9
  32. package/lib/types/runtime/llm.d.ts +34 -0
  33. package/lib/types/runtime/llm.js +71 -0
  34. package/lib/types/runtime/platform.d.ts +35 -0
  35. package/lib/types/runtime/platform.js +38 -0
  36. package/lib/types/runtime/plugin.d.ts +10 -0
  37. package/lib/types/runtime/plugin.js +11 -0
  38. package/lib/types/runtime/projections.d.ts +29 -0
  39. package/lib/types/runtime/projections.js +62 -0
  40. package/lib/types/scope.d.ts +1 -1
  41. package/lib/types/session-projection.d.ts +26 -53
  42. package/lib/types/session-projection.js +22 -58
  43. package/lib/types/skill-reads.js +3 -3
  44. package/lib/types/subagent/types.d.ts +1 -1
  45. package/lib/types/tool-dispatch.d.ts +2 -2
  46. package/lib/types/tool-dispatch.js +3 -3
  47. package/package.json +30 -16
@@ -1,4 +1,4 @@
1
- import { h as restrictedPresetId, n as ensureRestrictedPreset, r as restrictedPresetState } from "../ensure-CLF9YeBD.js";
1
+ import { h as restrictedPresetId, n as ensureRestrictedPreset, r as restrictedPresetState } from "../ensure-B4fjEI0w.js";
2
2
  //#region lib/types/subagent/readiness.js
3
3
  function serviceOf$1(ctx, name) {
4
4
  return ctx.get(name);
@@ -0,0 +1,20 @@
1
+ //#region lib/types/platform/tools.js
2
+ /**
3
+ * Resolve the tools port from a context; undefined means the host has no tools service.
4
+ * platform-declaration anchor: tools is declared in core PLATFORM_SERVICE_PROBES.
5
+ */
6
+ function toolsPort(ctx) {
7
+ const tools = ctx.get("tools");
8
+ if (tools === void 0) return void 0;
9
+ return {
10
+ register: (definition) => tools.register(definition),
11
+ guard: (guard) => tools.guard(guard),
12
+ restrict: (filter) => tools.restrict(filter)
13
+ };
14
+ }
15
+ /** Register one family tool through the port; a missing service yields a no-op disposer. */
16
+ function registerEvolutionTool(ctx, definition) {
17
+ return toolsPort(ctx)?.register(definition) ?? (() => {});
18
+ }
19
+ //#endregion
20
+ export { toolsPort as n, registerEvolutionTool as t };
@@ -1,3 +1,4 @@
1
+ import { presetsPort } from "../platform/presets.js";
1
2
  import { normalizeAllow } from "./preset-ids.js";
2
3
  import { composeRestrictedPresetDefinition, } from "./restricted-preset.js";
3
4
  const SLOTS = new WeakMap();
@@ -14,22 +15,11 @@ function slotFor(ctx, kind) {
14
15
  }
15
16
  return slot;
16
17
  }
17
- function registryOf(ctx) {
18
- const candidate = ctx.get('agentPresets');
19
- if (candidate === undefined)
20
- return undefined;
21
- if (typeof candidate.readDocument !== 'function' || typeof candidate.register !== 'function')
22
- return undefined;
23
- return candidate;
24
- }
25
18
  function installReleaseEffect(ctx, slot) {
26
19
  if (slot.effectInstalled === true)
27
20
  return;
28
- const effect = ctx.effect;
29
- if (effect === undefined)
30
- return;
31
21
  slot.effectInstalled = true;
32
- effect.call(ctx, () => () => { void releaseRestrictedPreset(ctx, undefined, slot); }, 'evolution-restricted-preset');
22
+ ctx.effect(() => () => { void releaseRestrictedPreset(ctx, undefined, slot); }, 'evolution-restricted-preset');
33
23
  }
34
24
  async function releaseRestrictedPreset(ctx, kind, explicitSlot) {
35
25
  const slot = explicitSlot ?? (kind === undefined ? undefined : slotFor(ctx, kind));
@@ -56,7 +46,7 @@ export async function ensureRestrictedPreset(ctx, req) {
56
46
  slot.state = { kind: 'failed', code: 'E-324', reason: 'allow set is empty' };
57
47
  return slot.state;
58
48
  }
59
- const registry = registryOf(ctx);
49
+ const registry = presetsPort(ctx);
60
50
  if (registry === undefined) {
61
51
  slot.state = { kind: 'failed', code: 'E-324', reason: 'agentPresets service unavailable or incomplete' };
62
52
  return slot.state;
@@ -69,7 +69,7 @@ export declare function scopedProbeReport(): ScopedProbeReport;
69
69
  * Does this session's scope see the family's model tools?
70
70
  *
71
71
  * The scope is the live agent's — the platform's own addressing for "what does
72
- * this session see" (`tools.get(name, scope)`, packages/core/tools/src/index.ts:1194).
72
+ * this session see" (`tools.get(name, scope)`, packages/core/tools/src/index.ts:239).
73
73
  * A session with no live agent (a finished or cold session) has no scope to ask
74
74
  * in, so it resolves to false; the consumers this gate serves only run for live
75
75
  * agents.
@@ -37,7 +37,7 @@ export function scopedProbeReport() {
37
37
  * Does this session's scope see the family's model tools?
38
38
  *
39
39
  * The scope is the live agent's — the platform's own addressing for "what does
40
- * this session see" (`tools.get(name, scope)`, packages/core/tools/src/index.ts:1194).
40
+ * this session see" (`tools.get(name, scope)`, packages/core/tools/src/index.ts:239).
41
41
  * A session with no live agent (a finished or cold session) has no scope to ask
42
42
  * in, so it resolves to false; the consumers this gate serves only run for live
43
43
  * agents.
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Host platform boundary for the evolution family (G1a).
3
+ *
4
+ * Feature packages import platform tool values/types from this subpath only;
5
+ * the platform-boundary gate keeps @deepseek-ai/dsh-* imports inside core/platform.
6
+ */
7
+ export { defineTool } from '@deepseek-ai/dsh-tools';
8
+ export type { ObjectJsonSchema, ToolDefinition, ToolGuard, ToolRestriction, } from '@deepseek-ai/dsh-tools';
9
+ export type { CommandInvocation, CommandResult } from '@deepseek-ai/dsh-commands';
10
+ export type { StreamChunk } from '@deepseek-ai/dsh-llm';
11
+ export type { Session, SessionEvent } from '@deepseek-ai/dsh-session';
12
+ export type { PromptContext, PromptSection } from '@deepseek-ai/dsh-system-prompt';
13
+ export { presetsPort } from './presets.ts';
14
+ export type { PresetDefinitionLike, PresetDocument, PresetsPort } from './presets.ts';
15
+ export { projectionPort } from './projections.ts';
16
+ export type { EvolutionProjectionDefinition, ProjectionHandleLike, ProjectionPort } from './projections.ts';
17
+ export { EvolutionLlmError, llmPort, modelRoute } from './llm.ts';
18
+ export type { EvolutionLlmFailureKind, EvolutionLlmPurpose, EvolutionLlmRequest, LlmPort, ModelRoute } from './llm.ts';
19
+ export { registerEvolutionTool, toolsPort } from './tools.ts';
20
+ export type { ToolsPort } from './tools.ts';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Host platform boundary for the evolution family (G1a).
3
+ *
4
+ * Feature packages import platform tool values/types from this subpath only;
5
+ * the platform-boundary gate keeps @deepseek-ai/dsh-* imports inside core/platform.
6
+ */
7
+ export { defineTool } from '@deepseek-ai/dsh-tools';
8
+ export { presetsPort } from "./presets.js";
9
+ export { projectionPort } from "./projections.js";
10
+ export { EvolutionLlmError, llmPort, modelRoute } from "./llm.js";
11
+ export { registerEvolutionTool, toolsPort } from "./tools.js";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The LLM half of the family's host platform boundary.
3
+ *
4
+ * Features pass a family request (route, messages, purpose); this module owns
5
+ * the platform GenerateOptions cast, prepareCall fallback, and text assembly.
6
+ * The purpose cast is the only compatibility point between the 0.2.1 fixed
7
+ * union and 0.2.2's declaration-merge map.
8
+ */
9
+ import type { StreamChunk, UserMessage } from '@deepseek-ai/dsh-llm';
10
+ import type { Context } from '@deepseek-ai/cordis';
11
+ export type EvolutionLlmFailureKind = 'model-unavailable' | 'no-route' | 'timeout' | 'cancelled' | 'transport';
12
+ /** Typed auxiliary-LLM failure; callers may map these without parsing messages. */
13
+ export declare class EvolutionLlmError extends Error {
14
+ readonly kind: EvolutionLlmFailureKind;
15
+ constructor(kind: EvolutionLlmFailureKind, message: string, cause?: unknown);
16
+ }
17
+ export type EvolutionLlmPurpose = 'evolution-curator' | 'evolution-merge-engine' | 'evolution-skill-discovery';
18
+ declare module '@deepseek-ai/dsh-llm/types' {
19
+ interface LlmRequestPurposeMap {
20
+ 'evolution-curator': true;
21
+ 'evolution-merge-engine': true;
22
+ 'evolution-skill-discovery': true;
23
+ }
24
+ }
25
+ export interface ModelRoute {
26
+ readonly provider: string;
27
+ readonly model: string;
28
+ }
29
+ export interface EvolutionLlmRequest {
30
+ readonly provider: string;
31
+ readonly model: string;
32
+ readonly purpose: EvolutionLlmPurpose;
33
+ readonly messages: readonly UserMessage[];
34
+ readonly maxTokens?: number;
35
+ readonly temperature?: number;
36
+ readonly signal?: AbortSignal;
37
+ }
38
+ export interface LlmPort {
39
+ stream(request: EvolutionLlmRequest): AsyncIterable<StreamChunk>;
40
+ completeText(request: EvolutionLlmRequest): Promise<string>;
41
+ }
42
+ /** Resolve the LLM port; undefined means the host has no llm service. */
43
+ export declare function llmPort(ctx: Context): LlmPort | undefined;
44
+ /** Resolve the model route: agent-owned selection first, deployment default second. */
45
+ export declare function modelRoute(ctx: Context, agent?: unknown, session?: unknown): ModelRoute | undefined;
46
+ //# sourceMappingURL=llm.d.ts.map
@@ -0,0 +1,75 @@
1
+ /** Typed auxiliary-LLM failure; callers may map these without parsing messages. */
2
+ export class EvolutionLlmError extends Error {
3
+ kind;
4
+ constructor(kind, message, cause) {
5
+ super(message);
6
+ this.name = 'EvolutionLlmError';
7
+ this.kind = kind;
8
+ if (cause !== undefined)
9
+ this.cause = cause;
10
+ }
11
+ }
12
+ function toOptions(request) {
13
+ return {
14
+ provider: request.provider,
15
+ model: request.model,
16
+ messages: request.messages,
17
+ ...(request.maxTokens === undefined ? {} : { maxTokens: request.maxTokens }),
18
+ ...(request.temperature === undefined ? {} : { temperature: request.temperature }),
19
+ ...(request.signal === undefined ? {} : { signal: request.signal }),
20
+ purpose: request.purpose,
21
+ };
22
+ }
23
+ /** Resolve the LLM port; undefined means the host has no llm service. */
24
+ export function llmPort(ctx) {
25
+ // platform-declaration anchor: llm is declared in core PLATFORM_SERVICE_PROBES.
26
+ const llm = ctx.get('llm');
27
+ if (llm === undefined)
28
+ return undefined;
29
+ const port = {
30
+ async *stream(request) {
31
+ const options = toOptions(request);
32
+ if (llm.stream !== undefined) {
33
+ yield* llm.stream(options);
34
+ return;
35
+ }
36
+ if (llm.prepareCall !== undefined) {
37
+ const call = await llm.prepareCall(options, request.signal);
38
+ yield* call.stream({ ...call.config, messages: request.messages, ...(request.signal === undefined ? {} : { signal: request.signal }) });
39
+ return;
40
+ }
41
+ throw new EvolutionLlmError('transport', 'llm service has neither stream nor prepareCall');
42
+ },
43
+ async completeText(request) {
44
+ let text = '';
45
+ for await (const chunk of port.stream(request)) {
46
+ const frame = chunk;
47
+ if (frame.type === 'text-delta' || frame.type === 'text')
48
+ text += typeof frame.text === 'string' ? frame.text : '';
49
+ if (frame.type === 'finish' && frame.reason?.kind === 'error') {
50
+ const message = frame.reason.failure?.message;
51
+ throw new EvolutionLlmError('transport', 'model call failed: ' + (typeof message === 'string' ? message : 'unknown'));
52
+ }
53
+ }
54
+ return text;
55
+ },
56
+ };
57
+ return port;
58
+ }
59
+ /** Resolve the model route: agent-owned selection first, deployment default second. */
60
+ export function modelRoute(ctx, agent, session) {
61
+ const owned = agent?.model?.current?.();
62
+ if (owned !== undefined)
63
+ return { provider: owned.provider, model: owned.model };
64
+ // 0.2.2 modelSelection is client-visible: snapshot() returns lastUsed/next.
65
+ if (session !== undefined) {
66
+ const registry = ctx.get('sessionProjections');
67
+ const value = registry?.snapshot?.(session, ['modelSelection'])?.values?.modelSelection;
68
+ const chosen = value?.next ?? value?.lastUsed;
69
+ if (chosen !== undefined && chosen !== null)
70
+ return { provider: chosen.provider, model: chosen.model };
71
+ }
72
+ const fallback = ctx.get('agentDefaultModel')?.currentSelection?.();
73
+ return fallback === undefined ? undefined : { provider: fallback.provider, model: fallback.model };
74
+ }
75
+ //# sourceMappingURL=llm.js.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The agent-preset half of the family's host platform boundary.
3
+ *
4
+ * Restricted presets need the registry's document/register face; the review
5
+ * branch needs resolve/mount; the restrictor needs composedPreset. The
6
+ * platform service is optional, so every method is reached through one facade.
7
+ */
8
+ import type { Context } from '@deepseek-ai/cordis';
9
+ export interface PresetDocument {
10
+ readonly agentPreset: string;
11
+ readonly content: string;
12
+ }
13
+ export interface PresetDefinitionLike {
14
+ readonly id: string;
15
+ readonly name: string;
16
+ readonly description: string;
17
+ readonly order: number;
18
+ readonly plugins: readonly unknown[];
19
+ }
20
+ export interface PresetsPort {
21
+ readDocument(agentPreset: string): Promise<PresetDocument>;
22
+ register(definition: PresetDefinitionLike): Promise<() => Promise<void>>;
23
+ resolve(id?: string): Promise<{
24
+ readonly id: string;
25
+ }>;
26
+ mount(target: Context, id?: string): Promise<unknown>;
27
+ composedPreset(target: Context): string | undefined;
28
+ }
29
+ /** Resolve the preset registry facade; undefined when the host has no agentPresets service. */
30
+ export declare function presetsPort(ctx: Context): PresetsPort | undefined;
31
+ //# 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,30 @@
1
+ /**
2
+ * The session-projection half of the family's host platform boundary.
3
+ *
4
+ * The target 0.2.2 registry returns an awaitable callable-thenable handle;
5
+ * the 0.2.1 registry returns a disposer function and reads through
6
+ * registry.stateOf. Both forms are adapted here; the legacy branch is deleted
7
+ * when platform-line moves to 0.2.2.
8
+ */
9
+ import type { Context } from '@deepseek-ai/cordis';
10
+ import type { ZodType } from 'zod';
11
+ import type { Session, SessionEvent } from '@deepseek-ai/dsh-session';
12
+ /** The family-owned shape of one projection unit; platform types stay behind the port. */
13
+ export interface EvolutionProjectionDefinition<K extends string, S> {
14
+ readonly key: K;
15
+ readonly stateVersion: number;
16
+ readonly stateSchema: ZodType<S>;
17
+ readonly init: (header: unknown, inheritedEventCount: number) => S;
18
+ readonly apply: (state: S, event: SessionEvent) => S;
19
+ }
20
+ /** One registered unit's read face, independent of the platform's handle class. */
21
+ export interface ProjectionHandleLike<S> {
22
+ stateOf(session: Session): S | undefined;
23
+ dispose(): Promise<void>;
24
+ }
25
+ export interface ProjectionPort {
26
+ register<K extends string, S>(definition: EvolutionProjectionDefinition<K, S>): Promise<ProjectionHandleLike<S>>;
27
+ }
28
+ /** Resolve the projection port; undefined means the host has no projection registry. */
29
+ export declare function projectionPort(ctx: Context): ProjectionPort | undefined;
30
+ //# sourceMappingURL=projections.d.ts.map
@@ -0,0 +1,31 @@
1
+ function isCallableThenable(value) {
2
+ return typeof value === 'function' && typeof value.then === 'function';
3
+ }
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
+ return {
11
+ async register(definition) {
12
+ const raw = registry.register(definition);
13
+ if (isCallableThenable(raw)) {
14
+ const resolved = await raw;
15
+ if (resolved !== null && typeof resolved === 'object' && typeof resolved.stateOf === 'function') {
16
+ const handle = resolved;
17
+ return {
18
+ stateOf: (session) => handle.stateOf(session),
19
+ dispose: () => handle.dispose(),
20
+ };
21
+ }
22
+ }
23
+ const dispose = raw;
24
+ return {
25
+ stateOf: (session) => registry.stateOf?.(session, definition.key),
26
+ dispose: async () => { dispose(); },
27
+ };
28
+ },
29
+ };
30
+ }
31
+ //# sourceMappingURL=projections.js.map
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The tools half of the family's host platform boundary.
3
+ *
4
+ * Only this module imports @deepseek-ai/dsh-tools; consumers receive a typed
5
+ * port and never reshape ctx.get('tools') themselves. Missing service is a
6
+ * capability downgrade, not a crash.
7
+ */
8
+ import type { Context } from '@deepseek-ai/cordis';
9
+ import type { ToolDefinition, ToolGuard, ToolRestriction } from '@deepseek-ai/dsh-tools';
10
+ /** The subset of the platform tools registry the family consumes. */
11
+ export interface ToolsPort {
12
+ register(definition: ToolDefinition): () => void;
13
+ guard(guard: ToolGuard): () => void;
14
+ restrict(filter: ToolRestriction): () => void;
15
+ }
16
+ /**
17
+ * Resolve the tools port from a context; undefined means the host has no tools service.
18
+ * platform-declaration anchor: tools is declared in core PLATFORM_SERVICE_PROBES.
19
+ */
20
+ export declare function toolsPort(ctx: Context): ToolsPort | undefined;
21
+ /** Register one family tool through the port; a missing service yields a no-op disposer. */
22
+ export declare function registerEvolutionTool(ctx: Context, definition: ToolDefinition): () => void;
23
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Resolve the tools port from a context; undefined means the host has no tools service.
3
+ * platform-declaration anchor: tools is declared in core PLATFORM_SERVICE_PROBES.
4
+ */
5
+ export function toolsPort(ctx) {
6
+ // The cast is confined to the boundary: the platform service class is the
7
+ // contract, while the port keeps feature code independent of its full face.
8
+ const tools = ctx.get('tools');
9
+ if (tools === undefined)
10
+ return undefined;
11
+ return {
12
+ register: (definition) => tools.register(definition),
13
+ guard: (guard) => tools.guard(guard),
14
+ restrict: (filter) => tools.restrict(filter),
15
+ };
16
+ }
17
+ /** Register one family tool through the port; a missing service yields a no-op disposer. */
18
+ export function registerEvolutionTool(ctx, definition) {
19
+ return toolsPort(ctx)?.register(definition) ?? (() => { });
20
+ }
21
+ //# sourceMappingURL=tools.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.1-rc.3";
4
- readonly floor: "0.2.1-rc.2";
5
- readonly previousAnchor: "0.2.0-rc.2";
6
- readonly peersRange: "^0.2.1-rc.2";
7
- readonly enginesRange: ">=0.2.1-rc.2 <0.2.2-0";
8
- readonly upstreamRef: "dsh-v0.2.1-rc.3";
3
+ readonly version: "0.2.2-rc.1";
4
+ readonly floor: "0.2.2-rc.0";
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";
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.1-rc.3',
6
- floor: '0.2.1-rc.2',
7
- previousAnchor: '0.2.0-rc.2',
8
- peersRange: '^0.2.1-rc.2',
9
- enginesRange: '>=0.2.1-rc.2 <0.2.2-0',
10
- upstreamRef: 'dsh-v0.2.1-rc.3',
5
+ version: '0.2.2-rc.1',
6
+ floor: '0.2.2-rc.0',
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',
11
11
  };
12
12
  //# sourceMappingURL=platform-line.generated.js.map
@@ -13,7 +13,7 @@
13
13
  */
14
14
  import type { PlatformServiceProbe } from '@lmzhen/dsh-evolution-contract';
15
15
  export type { PlatformServiceProbe } from '@lmzhen/dsh-evolution-contract';
16
- /** The 30 probes, in service-name order (the guard checks this list against the tree). */
16
+ /** The probes, in service-name order (the guard checks this list against the tree). */
17
17
  export declare const PLATFORM_SERVICE_PROBES: readonly PlatformServiceProbe[];
18
18
  /**
19
19
  * The HOST-side probes that do not resolve in this runtime — what `/evolution doctor` prints as
@@ -11,7 +11,7 @@
11
11
  * `client` probes run in the browser half, where the host has no view of the seats.
12
12
  * @module @lmzhen/dsh-evolution-core
13
13
  */
14
- /** The 30 probes, in service-name order (the guard checks this list against the tree). */
14
+ /** The probes, in service-name order (the guard checks this list against the tree). */
15
15
  export const PLATFORM_SERVICE_PROBES = Object.freeze([
16
16
  { service: 'agentDefaultModel', feature: 'the model route inherited by a plugin review branch', side: 'host' },
17
17
  { service: 'agentPresets', feature: 'the preset mount that gives a plugin review branch its tools/system', side: 'host' },
@@ -25,6 +25,7 @@ export const PLATFORM_SERVICE_PROBES = Object.freeze([
25
25
  { service: 'evolutionMerge', feature: 'merge command delegation and the merge doctor fact', side: 'host' },
26
26
  { service: 'hmr', feature: 'the preset install read-merge-write commit (the platform HMR lock serializes it)', side: 'host' },
27
27
  { service: 'evolutionMemoryBudget', feature: 'the memory-budget divergence section of this report', side: 'host' },
28
+ { service: 'evolutionPlatform', feature: 'the single host edge object behind every family platform port', side: 'host' },
28
29
  { service: 'evolutionPolicy', feature: 'the policy snapshot that shadows row knobs', side: 'host' },
29
30
  { service: 'evolutionReplay', feature: '/evolution replay', side: 'host' },
30
31
  { service: 'evolutionState', feature: 'the state facade behind activity and replay', side: 'host' },
@@ -34,6 +35,8 @@ export const PLATFORM_SERVICE_PROBES = Object.freeze([
34
35
  { service: 'pluginManager', feature: 'the platform plugin and preset surfaces this report reads', side: 'host' },
35
36
  { service: 'profileContext', feature: 'writing the agent-preset row into a profile patch', side: 'host' },
36
37
  { service: 'sessionProjections', feature: 'the domain-owned session units', side: 'host' },
38
+ { service: 'evolutionProjections', feature: 'the family-owned projection runtime behind the pure readers', side: 'host' },
39
+ { service: 'evolutionLlm', feature: 'the family LLM runtime for auxiliary model calls', side: 'host' },
37
40
  { service: 'sessionQuery', feature: 'the session corpus behind /evolution sessions', side: 'host' },
38
41
  { service: 'settings', feature: 'the settings user layer and the params view', side: 'host' },
39
42
  { service: 'skillUsage', feature: 'usage counters feeding the curator and the review planner', side: 'host' },
@@ -1,3 +1,5 @@
1
+ import { presetsPort } from "./platform/presets.js";
2
+ import { toolsPort } from "./platform/tools.js";
1
3
  import { errorText } from "./errors.js";
2
4
  export const name = 'evolution-restrictor';
3
5
  export const inject = ['agentPresets'];
@@ -22,8 +24,8 @@ export function apply(ctx, config = {}) {
22
24
  const on = ctx.on;
23
25
  if (typeof on !== 'function')
24
26
  throw failure('requires a context that owns on()');
25
- const presets = ctx.agentPresets;
26
- if (presets === undefined || typeof presets.composedPreset !== 'function') {
27
+ const presets = presetsPort(ctx);
28
+ if (presets === undefined) {
27
29
  throw failure('requires the agentPresets service (inject: agentPresets)');
28
30
  }
29
31
  // The listener lives in the preset MOUNT scope: scope routing delivers every descendant
@@ -35,14 +37,10 @@ export function apply(ctx, config = {}) {
35
37
  return;
36
38
  if (presets.composedPreset(agent.ctx) !== presetId)
37
39
  return;
38
- const tools = agent.ctx.tools;
39
- if (tools === undefined || typeof tools.restrict !== 'function') {
40
+ const tools = toolsPort(agent.ctx);
41
+ if (tools === undefined)
40
42
  throw failure('child scope exposes no tools.restrict()');
41
- }
42
- const effect = agent.ctx.effect;
43
- if (effect === undefined)
44
- throw failure('child scope owns no effect() to release the restriction');
45
- effect.call(agent.ctx, () => tools.restrict(filter), 'evolution-restrictor:child');
43
+ agent.ctx.effect(() => tools.restrict(filter), 'evolution-restrictor:child');
46
44
  });
47
45
  }
48
46
  //# sourceMappingURL=restrictor.js.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The family's LLM runtime: one route/purpose/transport path for auxiliary
3
+ * model calls. Feature-specific retries and parsing stay in their features.
4
+ */
5
+ import { Service } from '@deepseek-ai/cordis';
6
+ import type { Context } from '@deepseek-ai/cordis';
7
+ import { type EvolutionLlmRequest, type ModelRoute, type StreamChunk } from '../platform/index.ts';
8
+ export interface EvolutionLlmInput {
9
+ readonly purpose: EvolutionLlmRequest['purpose'];
10
+ readonly messages: EvolutionLlmRequest['messages'];
11
+ readonly route?: ModelRoute | undefined;
12
+ readonly agent?: unknown;
13
+ readonly session?: unknown;
14
+ readonly maxTokens?: number | undefined;
15
+ readonly temperature?: number | undefined;
16
+ readonly signal?: AbortSignal | undefined;
17
+ readonly timeoutMs?: number | undefined;
18
+ }
19
+ /** Domain service for every auxiliary LLM request in the family. */
20
+ export declare class EvolutionLlm extends Service {
21
+ static inject: never[];
22
+ private port;
23
+ constructor(ctx: Context);
24
+ protected [Service.init](): void;
25
+ /** Whether the platform llm service is mounted. */
26
+ available(): boolean;
27
+ /** One assembled text response. */
28
+ text(input: EvolutionLlmInput): Promise<string>;
29
+ /** Raw chunk stream for callers that need incremental delivery. */
30
+ stream(input: EvolutionLlmInput): AsyncIterable<StreamChunk>;
31
+ private prepare;
32
+ private classify;
33
+ }
34
+ //# sourceMappingURL=llm.d.ts.map
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The family's LLM runtime: one route/purpose/transport path for auxiliary
3
+ * model calls. Feature-specific retries and parsing stay in their features.
4
+ */
5
+ import { Service } from '@deepseek-ai/cordis';
6
+ import { EvolutionLlmError, llmPort, modelRoute } from "../platform/index.js";
7
+ /** Domain service for every auxiliary LLM request in the family. */
8
+ export class EvolutionLlm extends Service {
9
+ static inject = [];
10
+ port;
11
+ constructor(ctx) {
12
+ super(ctx, 'evolutionLlm');
13
+ }
14
+ [Service.init]() {
15
+ const platform = this.ctx.get('evolutionPlatform');
16
+ this.port = platform?.ports?.llm ?? llmPort(this.ctx);
17
+ if (this.port === undefined)
18
+ this.ctx.logger.warn('evolution-core-runtime: llm service unavailable; model calls fail with llm-unavailable');
19
+ }
20
+ /** Whether the platform llm service is mounted. */
21
+ available() { return this.port !== undefined; }
22
+ /** One assembled text response. */
23
+ async text(input) {
24
+ const prepared = this.prepare(input);
25
+ try {
26
+ return await prepared.port.completeText(prepared.request);
27
+ }
28
+ catch (error) {
29
+ throw this.classify(error, prepared.timeout, prepared.caller);
30
+ }
31
+ }
32
+ /** Raw chunk stream for callers that need incremental delivery. */
33
+ async *stream(input) {
34
+ const prepared = this.prepare(input);
35
+ try {
36
+ yield* prepared.port.stream(prepared.request);
37
+ }
38
+ catch (error) {
39
+ throw this.classify(error, prepared.timeout, prepared.caller);
40
+ }
41
+ }
42
+ prepare(input) {
43
+ const port = this.port;
44
+ if (port === undefined)
45
+ throw new EvolutionLlmError('model-unavailable', 'llm-unavailable: no llm service is mounted');
46
+ const route = input.route ?? modelRoute(this.ctx, input.agent, input.session);
47
+ if (route === undefined)
48
+ throw new EvolutionLlmError('no-route', 'llm-unavailable: no model route is configured');
49
+ const timeout = input.timeoutMs !== undefined && Number.isFinite(input.timeoutMs) && input.timeoutMs > 0
50
+ ? AbortSignal.timeout(input.timeoutMs)
51
+ : undefined;
52
+ const signal = input.signal === undefined ? timeout : timeout === undefined ? input.signal : AbortSignal.any([input.signal, timeout]);
53
+ const request = {
54
+ provider: route.provider,
55
+ model: route.model,
56
+ purpose: input.purpose,
57
+ messages: input.messages,
58
+ ...(input.maxTokens === undefined ? {} : { maxTokens: input.maxTokens }),
59
+ ...(input.temperature === undefined ? {} : { temperature: input.temperature }),
60
+ ...(signal === undefined ? {} : { signal }),
61
+ };
62
+ return { port, request, ...(timeout === undefined ? {} : { timeout }), ...(input.signal === undefined ? {} : { caller: input.signal }) };
63
+ }
64
+ classify(error, timeout, caller) {
65
+ if (error instanceof EvolutionLlmError)
66
+ return error;
67
+ const kind = timeout?.aborted === true ? 'timeout' : caller?.aborted === true ? 'cancelled' : 'transport';
68
+ return new EvolutionLlmError(kind, error instanceof Error ? error.message : String(error), error);
69
+ }
70
+ }
71
+ //# sourceMappingURL=llm.js.map