@lmzhen/dsh-evolution-core 0.58.0 → 0.59.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@ The root entry is a library, not a user-facing command. The package also exposes
6
6
 
7
7
  The former `./platform` compatibility barrel is removed: feature packages import port types from `@lmzhen/dsh-evolution-platform-contract`, port functions from `@lmzhen/dsh-evolution-adapter/ports`, and host runtime helpers from `@lmzhen/dsh-evolution-adapter/values`. `./runtime` no longer mounts `evolutionPlatform`; the bundle's `evolution-adapter` row owns it and mounts before core/runtime.
8
8
 
9
- `./runtime` is a function plugin. It provides `evolutionProjections`, the single owner of the five host-only session units (`evolutionActivity`, `evolutionEvidence`, `evolutionReads`, `evolutionProjectionHistory`, `evolutionSignals`); readers ask that service and degrade to `undefined` when the platform registry is absent. It also provides `evolutionLlm`, the single route/purpose/transport owner for auxiliary model calls (curator, merge judge, domain generation). A granular composition that mounts feature rows without a family bundle must mount this row too.
9
+ `./runtime` is a function plugin. It provides `evolutionProjections`, the single owner of the five host-only session units (`evolutionActivity`, `evolutionEvidence`, `evolutionReads`, `evolutionProjectionHistory`, `evolutionSignals`); readers ask that service and degrade to `undefined` when the platform registry is absent. It also provides `evolutionLlm`, the single route/purpose/transport owner for auxiliary model calls (curator, merge judge, domain generation). A granular composition that mounts feature rows without a family bundle must mount this row too. The runtime also installs the minimal-preset guard: while the active preset is `minimal`, family model tools are hidden per agent scope and AUX review is skipped; UI/commands remain profile-level.
10
10
 
11
11
  `./restrictor` is a function plugin for restricted presets. It requires a `presetId` and a non-empty `allow` or `deny` set, then applies `tools.restrict()` in matching child-agent scopes. It constrains inherited tools, not the preset mount scope itself.
12
12
 
package/lib/index.js CHANGED
@@ -3,9 +3,9 @@ import { a as leaseFile, c as AuthorityBusyError, d as HomeAuthority, f as autho
3
3
  import { a as isFileShapedPath, i as KEEP_LINE_RE, n as DEFAULT_CITATION_REF_BUDGET, o as resolveCitations, r as HOOK_LINE_RE, s as scanBodyHooks, t as CITATION_SUPPORT_DIRS } from "./citations-CZKTUGQF.js";
4
4
  import { $ as SUPPORT_SPRAWL_FILES, A as DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, B as MAX_SKILL_CONTENT_CHARS, C as DEFAULT_REVIEW_TIMEOUT_MS, D as DEFAULT_SKILL_VERSION_KEEP, E as DEFAULT_SKILL_REVIEW_TRIGGER, F as DEFAULT_USER_TOKENS, G as MEMORY_GUIDANCE_SECTION_ORDER, H as MAX_SKILL_NAME_LENGTH, I as ENTRY_DELIMITER, J as REVIEW_TEXT_PREVIEW_GRAPHEMES, K as MERGE_BODY_PREVIEW_BYTES, L as EVOLUTION_WRITE_TOOLS, M as DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, N as DEFAULT_THREAT_MAX_SCAN_CHARS, O as DEFAULT_SOFT_BODY_TOKENS, P as DEFAULT_USER_CHAR_LIMIT, Q as SUPPORT_DIRS, R as FORBIDDEN_CONTROL_KEYS, S as DEFAULT_REVIEW_SKILL_INTERVAL, T as DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, U as MAX_TIMER_DELAY_MS, V as MAX_SKILL_FILE_BYTES, W as MEMORY_ENTRY_PREVIEW_GRAPHEMES, X as SKILL_ACTION_REQUIRED_FIELDS, Y as SKILLS_GUIDANCE_SECTION_ORDER, Z as SKILL_NAME_RE, _ as DEFAULT_MEMORY_CHAR_LIMIT, a as DEFAULT_SUPPORT_FILE_CHAR_POLICY, b as DEFAULT_PROBE_TIMEOUT_MS, c as AUTHORING_DESCRIPTION_BAR, d as DEFAULT_ARCHIVE_AFTER_DAYS, et as TEXT_DIFF_MAX_GRAPHEMES, f as DEFAULT_CONSOLIDATION_FAILURES, g as DEFAULT_CURATOR_REVIEW_MAX_TOKENS, h as DEFAULT_CURATOR_MODEL, i as DEFAULT_SKILL_LIMITS, j as DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, k as DEFAULT_STALE_AFTER_DAYS, l as AUTHORING_SPLIT_LINE_CHARS, m as DEFAULT_CURATOR_INTERVAL_HOURS, n as DEFAULT_CITATION_POLICY, nt as VERSION_BODY_PREVIEW_GRAPHEMES, o as POLICY_STAGE_DEFAULTS, p as DEFAULT_CURATOR_BOOT_GRACE_SECONDS, q as PROTECTED_BUILTIN_SKILLS, r as DEFAULT_REFERENCE_REWRITE_POLICY, s as policyStageLimits, t as DEFAULT_ARCHIVE_RETENTION_POLICY, tt as UPSTREAM_LIMIT_CHARS_PER_TOKEN, u as CONTENT_SPLIT_HINT, v as DEFAULT_MEMORY_TOKENS, w as DEFAULT_SKILL_CONTENT_CHARS, x as DEFAULT_REVIEW_MEMORY_INTERVAL, y as DEFAULT_MIN_IDLE_HOURS, z as MAX_DESCRIPTION_LENGTH } from "./limits-CO4JGSJL.js";
5
5
  import { _ as scopedPackageName, d as RESTRICTED_TOOLS_ROW_ID, f as RESTRICTOR_MODULE, g as scopeOfNearestManifest, l as MAINTAINER_PRESET_ID, p as REVIEWER_PRESET_ID, s as EVOLUTION_PRESET_IDS, u as RESTRICTED_PRESET_DISPLAY } from "./ensure-BpVDuDnA.js";
6
- import { A as retainEventArchives, C as appendEvolutionEvent, D as parseEvolutionEvents, E as listEventArchives, G as DEFAULT_WRITE_CONFIRM_MODE, H as isUnreadWrite, I as softBodyTokenBudget, K as DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, L as RULES, O as readEvolutionEvents, P as assessStructureHealth, S as EVENT_LOG_VERSION, T as evolutionEventPayloadIssue, _ as fuzzyPatch, a as isReviewChannelSession, b as EVENT_LOG_RETAIN_ARCHIVES, c as PATTERN_OVERLAP, d as scanContentThreats, f as scanMemoryThreats, g as FUZZY_MAX_WORK, h as FUZZY_MAX_PATTERN_CHARS, i as clearReviewChannel, j as DEFAULT_HEALTH_THRESHOLDS, k as readEvolutionTimeline, l as THREAT_EXEMPTION_HINT, m as makeSerialQueue, n as recordReviewRead, o as markReviewChannel, p as scanThreats, q as authorityFrom, r as withReviewContext, s as sweepReviewChannelSessions, t as currentReviewContext, u as evaluateThreat, v as trimPatternBoundaries, w as eventsFile, x as EVENT_LOG_ROTATE_AT, y as EVENT_ARCHIVE_PREFIX, z as lintSkill } from "./review-context-70XYS11J.js";
6
+ import { A as retainEventArchives, C as appendEvolutionEvent, D as parseEvolutionEvents, E as listEventArchives, G as DEFAULT_WRITE_CONFIRM_MODE, H as isUnreadWrite, I as softBodyTokenBudget, K as DEFAULT_WRITE_CONFIRM_TIMEOUT_SECONDS, L as RULES, O as readEvolutionEvents, P as assessStructureHealth, S as EVENT_LOG_VERSION, T as evolutionEventPayloadIssue, _ as fuzzyPatch, a as isReviewChannelSession, b as EVENT_LOG_RETAIN_ARCHIVES, c as PATTERN_OVERLAP, d as scanContentThreats, f as scanMemoryThreats, g as FUZZY_MAX_WORK, h as FUZZY_MAX_PATTERN_CHARS, i as clearReviewChannel, j as DEFAULT_HEALTH_THRESHOLDS, k as readEvolutionTimeline, l as THREAT_EXEMPTION_HINT, m as makeSerialQueue, n as recordReviewRead, o as markReviewChannel, p as scanThreats, q as authorityFrom, r as withReviewContext, s as sweepReviewChannelSessions, t as currentReviewContext, u as evaluateThreat, v as trimPatternBoundaries, w as eventsFile, x as EVENT_LOG_ROTATE_AT, y as EVENT_ARCHIVE_PREFIX, z as lintSkill } from "./review-context-CW_kJAzn.js";
7
7
  import { i as HOST_LOCALES, n as errorText, r as errorTextIn, t as EVOLUTION_ERRORS } from "./errors-BxzLTVbS.js";
8
- import { A as dispatchKeyOf, C as PTC_DISPATCH_EVENT, D as assertDispatchPayload, E as ToolDispatchPayloadError, F as isSkillToolName, I as readDispatchSignal, L as skillReadNameOf, M as dispatchStepOf, N as foldToolDispatches, O as collectReadSkillNames, P as isSkillReadToolName, R as supportFileReadFromPath, S as NATIVE_RESULT_EVENT, T as ToolDispatchNormalizer, _ as isBookkeepingFrame, a as evolutionSignalsProjection, b as MODEL_SESSION_EVENT_TYPES, c as sessionLastEventTime, d as advanceReview, f as foldTurnEvent, g as evidenceKindIndex, h as observeEvent, i as evolutionReadsProjection, j as dispatchPathOf, k as collectReadSupportFiles, l as sessionReadNames, m as initialTurnFold, n as evolutionEvidenceProjection, o as isProjectableSession, p as foldTurnEvents, r as evolutionProjectionHistoryProjection, s as sessionEvidenceIndex, t as evolutionActivityProjection, u as sessionTurnSignals, v as DEFAULT_SUPPORT_READ_TOOL_NAMES, w as PTC_DISPATCH_START_EVENT, x as NATIVE_CALL_EVENT, y as DISPATCH_EVENT_TYPES, z as supportFileReadOf } from "./session-projection-CbIKvDfJ.js";
8
+ import { A as dispatchKeyOf, C as PTC_DISPATCH_EVENT, D as assertDispatchPayload, E as ToolDispatchPayloadError, F as isSkillToolName, I as readDispatchSignal, L as skillReadNameOf, M as dispatchStepOf, N as foldToolDispatches, O as collectReadSkillNames, P as isSkillReadToolName, R as supportFileReadFromPath, S as NATIVE_RESULT_EVENT, T as ToolDispatchNormalizer, _ as isBookkeepingFrame, a as evolutionSignalsProjection, b as MODEL_SESSION_EVENT_TYPES, c as sessionLastEventTime, d as advanceReview, f as foldTurnEvent, g as evidenceKindIndex, h as observeEvent, i as evolutionReadsProjection, j as dispatchPathOf, k as collectReadSupportFiles, l as sessionReadNames, m as initialTurnFold, n as evolutionEvidenceProjection, o as isProjectableSession, p as foldTurnEvents, r as evolutionProjectionHistoryProjection, s as sessionEvidenceIndex, t as evolutionActivityProjection, u as sessionTurnSignals, v as DEFAULT_SUPPORT_READ_TOOL_NAMES, w as PTC_DISPATCH_START_EVENT, x as NATIVE_CALL_EVENT, y as DISPATCH_EVENT_TYPES, z as supportFileReadOf } from "./session-projection-DM15fsRp.js";
9
9
  import { a as measureUnit, i as measureText, n as conservativeTokenEstimator, o as truncateGraphemes, r as graphemeCount, s as utf8ByteLength, t as codePointCount } from "./text-metrics-CyJhxWBs.js";
10
10
  import { A as h2Sections, C as saveUsage, D as usageObserved, E as usageFile, F as describeReferenceRewrite, I as planReferenceRewrite, L as planRehoming, M as externalRefs, N as supportRefs, O as selectSections, P as applyReferenceRewrite, S as saveSuppressedNames, T as updateSuppressedNames, _ as loadUsage, a as applyCuratorMetaFields, b as normalizeUsageRecord, c as bumpUse, d as emptyRecord, f as foldCuratorFields, g as loadSuppressedNames, h as latestActivityAt, i as applyCuratorLifecycleFields, j as readingStats, k as displayBodyOf, l as bumpView, m as idleDays, n as SUPPRESSED_FILE_VERSION, o as bumpPatch, p as getRecord, r as VIEW_WINDOW_DAYS, s as bumpSupportRead, t as MAX_SUPPORT_READ_PATHS, u as daysSinceIso, v as markAgentCreated, w as suppressedFile, x as recentViewCount, y as mutateUsage } from "./usage-DrczLTP4.js";
11
11
  import { n as isRecord, t as asRecord } from "./guards-3f02mnf2.js";
@@ -2129,7 +2129,7 @@ const SKILLS_GUIDANCE = `Skills guidance:
2129
2129
  • After a complex task (5+ tool calls), a tricky fix, or a non-trivial workflow, decide whether an existing owner should be updated or a new class-level skill is needed; search the library before creating.
2130
2130
  • When using a skill and finding it outdated, incomplete, or wrong, patch it immediately with skill_manage (action='patch') — don't wait to be asked. Skills that aren't maintained become liabilities.`;
2131
2131
  function reviewPrompt(kind, surface = "inject") {
2132
- if (surface === "aux") return kind === "memory" ? INJECT_MEMORY_REVIEW_PROMPT : INJECT_COMBINED_REVIEW_PROMPT;
2132
+ if (surface === "aux") return kind === "memory" ? INJECT_MEMORY_REVIEW_PROMPT : INJECT_SKILL_REVIEW_PROMPT;
2133
2133
  if (kind === "memory") return INJECT_MEMORY_REVIEW_PROMPT;
2134
2134
  if (kind === "skill") return INJECT_SKILL_REVIEW_PROMPT;
2135
2135
  return INJECT_COMBINED_REVIEW_PROMPT;
@@ -1,6 +1,6 @@
1
1
  import { c as transactIo } from "./io-GxghO3Ip.js";
2
2
  import { N as DEFAULT_THREAT_MAX_SCAN_CHARS, O as DEFAULT_SOFT_BODY_TOKENS, tt as UPSTREAM_LIMIT_CHARS_PER_TOKEN } from "./limits-CO4JGSJL.js";
3
- import { O as collectReadSkillNames, R as supportFileReadFromPath, k as collectReadSupportFiles, l as sessionReadNames, o as isProjectableSession, v as DEFAULT_SUPPORT_READ_TOOL_NAMES } from "./session-projection-CbIKvDfJ.js";
3
+ import { O as collectReadSkillNames, R as supportFileReadFromPath, k as collectReadSupportFiles, l as sessionReadNames, o as isProjectableSession, v as DEFAULT_SUPPORT_READ_TOOL_NAMES } from "./session-projection-DM15fsRp.js";
4
4
  import { a as measureUnit, i as measureText } from "./text-metrics-CyJhxWBs.js";
5
5
  import { t as clampedNumber } from "./numeric-Dc53KQoe.js";
6
6
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -1,4 +1,4 @@
1
- import { a as evolutionSignalsProjection, i as evolutionReadsProjection, n as evolutionEvidenceProjection, r as evolutionProjectionHistoryProjection, t as evolutionActivityProjection } from "../session-projection-CbIKvDfJ.js";
1
+ import { a as evolutionSignalsProjection, i as evolutionReadsProjection, n as evolutionEvidenceProjection, r as evolutionProjectionHistoryProjection, t as evolutionActivityProjection } from "../session-projection-DM15fsRp.js";
2
2
  import { join } from "node:path";
3
3
  import { existsSync, readFileSync } from "node:fs";
4
4
  import { EvolutionLlmError, modelRoute, profileContextPort } from "@lmzhen/dsh-evolution-adapter/ports";
@@ -261,12 +261,82 @@ var EvolutionProjections = class extends Service {
261
261
  }
262
262
  };
263
263
  //#endregion
264
+ //#region lib/types/runtime/minimal-preset.js
265
+ /** Family tools that must never be model-visible in the minimal preset. */
266
+ const MINIMAL_PRESET_DENY_TOOLS = [
267
+ "memory",
268
+ "skill_manage",
269
+ "skill_search",
270
+ "skill",
271
+ "maintenance_probe",
272
+ "merge_stage"
273
+ ];
274
+ function activePreset(ctx, agent) {
275
+ const projected = ctx.get("sessionProjections")?.snapshot?.(agent.session, ["agentPreset"])?.values?.agentPreset;
276
+ if (typeof projected === "string") return projected;
277
+ const headerPreset = agent.session?.header?.agentPreset;
278
+ return typeof headerPreset === "string" ? headerPreset : void 0;
279
+ }
280
+ /** Install the per-agent minimal-preset guard. */
281
+ function installMinimalPresetGuard(ctx) {
282
+ const disposers = /* @__PURE__ */ new Map();
283
+ const sync = (agent) => {
284
+ const key = agent.id;
285
+ if (activePreset(ctx, agent) !== "minimal") {
286
+ disposers.get(key)?.();
287
+ disposers.delete(key);
288
+ return;
289
+ }
290
+ if (disposers.has(key)) return;
291
+ const tools = agent.ctx?.tools;
292
+ if (tools?.restrict === void 0) return;
293
+ const known = MINIMAL_PRESET_DENY_TOOLS.filter((name) => {
294
+ try {
295
+ return tools.get?.(name, agent) !== void 0;
296
+ } catch {
297
+ return false;
298
+ }
299
+ });
300
+ if (known.length === 0) return;
301
+ try {
302
+ disposers.set(key, tools.restrict({ deny: known }));
303
+ } catch (error) {
304
+ ctx.logger.warn("dsh-evolution-core: minimal preset tool restriction failed: " + (error instanceof Error ? error.message : String(error)));
305
+ }
306
+ };
307
+ ctx.inject(["agents"], (child) => {
308
+ const events = child;
309
+ const created = events.on("agent/created", (payload) => {
310
+ const agent = payload?.agent;
311
+ if (agent !== void 0) sync(agent);
312
+ });
313
+ const selected = events.on("agent-preset/selected", (sessionId) => {
314
+ const agent = events.agents?.get(sessionId);
315
+ if (agent !== void 0) sync(agent);
316
+ });
317
+ const disposed = events.on("agent/disposed", (payload) => {
318
+ const agent = payload?.agent;
319
+ if (agent === void 0) return;
320
+ disposers.get(agent.id)?.();
321
+ disposers.delete(agent.id);
322
+ });
323
+ child.effect(() => () => {
324
+ created();
325
+ selected();
326
+ disposed();
327
+ for (const dispose of disposers.values()) dispose();
328
+ disposers.clear();
329
+ });
330
+ });
331
+ }
332
+ //#endregion
264
333
  //#region lib/types/runtime/plugin.js
265
334
  const name = "evolution-core-runtime";
266
335
  /** @param ctx - the composition context that owns the runtime services. */
267
336
  async function apply(ctx) {
268
337
  await ctx.plugin(EvolutionProjections);
269
338
  await ctx.plugin(EvolutionLlm);
339
+ installMinimalPresetGuard(ctx);
270
340
  warnIfFamilyMixed(ctx);
271
341
  }
272
342
  //#endregion
@@ -676,23 +676,15 @@ function advanceReview(state, turn, signal, config) {
676
676
  state.turnsSinceSkill += signal.skillSignal ? 1 : Math.max(1, signal.toolCalls);
677
677
  const memoryDue = state.turnsSinceMemory >= config.memoryInterval;
678
678
  const skillDue = state.turnsSinceSkill >= config.skillInterval;
679
- const zero = () => {
680
- state.turnsSinceMemory = 0;
681
- state.turnsSinceSkill = 0;
682
- };
683
- if (memoryDue && skillDue) {
684
- if (config.resetOnFire !== false) zero();
685
- return "combined";
686
- }
687
- if (memoryDue) {
688
- if (config.resetOnFire !== false) state.turnsSinceMemory = 0;
689
- return "memory";
690
- }
691
- if (skillDue) {
692
- if (config.resetOnFire !== false) state.turnsSinceSkill = 0;
693
- return "skill";
679
+ if (!memoryDue && !skillDue) return null;
680
+ if (config.resetOnFire !== false) {
681
+ if (memoryDue) state.turnsSinceMemory = 0;
682
+ if (skillDue) state.turnsSinceSkill = 0;
694
683
  }
695
- return null;
684
+ return {
685
+ memory: memoryDue,
686
+ skill: skillDue
687
+ };
696
688
  }
697
689
  /**
698
690
  * Fold a log slice into one turn window, purely.
package/lib/skills.js CHANGED
@@ -2,7 +2,7 @@ import { _ as probeMtime, b as probeText, c as transactIo, d as isAbsent, g as p
2
2
  import { n as mutationLockFrom } from "./mutation-authority-Du-ON0NY.js";
3
3
  import { o as resolveCitations } from "./citations-CZKTUGQF.js";
4
4
  import { Q as SUPPORT_DIRS, Z as SKILL_NAME_RE, a as DEFAULT_SUPPORT_FILE_CHAR_POLICY, i as DEFAULT_SKILL_LIMITS, n as DEFAULT_CITATION_POLICY, o as POLICY_STAGE_DEFAULTS, q as PROTECTED_BUILTIN_SKILLS, r as DEFAULT_REFERENCE_REWRITE_POLICY, s as policyStageLimits, t as DEFAULT_ARCHIVE_RETENTION_POLICY, u as CONTENT_SPLIT_HINT } from "./limits-CO4JGSJL.js";
5
- import { B as READ_REQUIRED_ACTIONS, C as appendEvolutionEvent, F as lintBody, H as isUnreadWrite, I as softBodyTokenBudget, L as RULES, M as HEALTH_STAMP_RE, N as MIN_STAMP_BODY_CHARS, P as assessStructureHealth, R as diffFindings, U as sessionReadSkillNames, V as filterUnreadSkillOps, W as sessionReadSupportFiles, _ as fuzzyPatch, a as isReviewChannelSession, d as scanContentThreats, j as DEFAULT_HEALTH_THRESHOLDS, m as makeSerialQueue, q as authorityFrom, t as currentReviewContext, v as trimPatternBoundaries, w as eventsFile, z as lintSkill } from "./review-context-70XYS11J.js";
5
+ import { B as READ_REQUIRED_ACTIONS, C as appendEvolutionEvent, F as lintBody, H as isUnreadWrite, I as softBodyTokenBudget, L as RULES, M as HEALTH_STAMP_RE, N as MIN_STAMP_BODY_CHARS, P as assessStructureHealth, R as diffFindings, U as sessionReadSkillNames, V as filterUnreadSkillOps, W as sessionReadSupportFiles, _ as fuzzyPatch, a as isReviewChannelSession, d as scanContentThreats, j as DEFAULT_HEALTH_THRESHOLDS, m as makeSerialQueue, q as authorityFrom, t as currentReviewContext, v as trimPatternBoundaries, w as eventsFile, z as lintSkill } from "./review-context-CW_kJAzn.js";
6
6
  import { a as measureUnit } from "./text-metrics-CyJhxWBs.js";
7
7
  import { E as usageFile, F as describeReferenceRewrite, I as planReferenceRewrite, L as planRehoming, N as supportRefs, O as selectSections, P as applyReferenceRewrite, _ as loadUsage, p as getRecord, w as suppressedFile, y as mutateUsage } from "./usage-DrczLTP4.js";
8
8
  import { _ as validateFrontmatter, c as ensureSkillFrontmatter, d as frontmatterCatalogInvalid, f as normalizeFrontmatter, g as skillMdOnDisk, h as shrinksOverLimit, i as loadMutations, l as exceedsContentLimit, m as relatedSkillNames, o as recordMutation, p as parseFrontmatter, r as contentHash, s as authoringFeedback, u as frontmatterBlock, v as yamlPlainScalarNeedsQuotes } from "./mutations-mvTnWkua.js";
@@ -46,10 +46,15 @@ export interface EvolutionReviewAction {
46
46
  export interface EvolutionReviewCompletedEvent {
47
47
  readonly version: 1;
48
48
  readonly reviewId: string;
49
+ readonly taskId?: string | undefined;
49
50
  readonly sessionId: string;
50
51
  readonly branchSessionId?: string | undefined;
51
52
  readonly kind: ReviewKind;
52
- readonly status: 'completed' | 'failed' | 'timeout' | 'aborted';
53
+ readonly status: 'completed' | 'partial' | 'failed' | 'timeout' | 'aborted';
54
+ /** Tool transport used by an auxiliary review; absent for foreground inject. */
55
+ readonly toolMode?: 'native' | 'ptc' | undefined;
56
+ /** Session preset id carried by the parent header, when one exists. */
57
+ readonly preset?: string | undefined;
53
58
  readonly trigger: {
54
59
  readonly reason: string;
55
60
  readonly toolCalls: number;
@@ -61,6 +66,15 @@ export interface EvolutionReviewCompletedEvent {
61
66
  /** Model requests actually spent, and tool calls issued inside them. */
62
67
  readonly requests?: number | undefined;
63
68
  readonly toolCalls?: number | undefined;
69
+ readonly waitCount?: number | undefined;
70
+ readonly hitRoundLimit?: boolean | undefined;
71
+ readonly report?: {
72
+ readonly summary: string;
73
+ readonly memoryChanged: boolean;
74
+ readonly skillsChanged: readonly string[];
75
+ readonly unresolved: readonly string[];
76
+ } | undefined;
77
+ readonly partialReason?: string | undefined;
64
78
  readonly usage?: {
65
79
  readonly inputTokens: number;
66
80
  readonly outputTokens: number;
@@ -261,7 +261,7 @@ export const SKILLS_GUIDANCE = `Skills guidance:
261
261
  • When using a skill and finding it outdated, incomplete, or wrong, patch it immediately with skill_manage (action='patch') — don't wait to be asked. Skills that aren't maintained become liabilities.`;
262
262
  export function reviewPrompt(kind, surface = 'inject') {
263
263
  if (surface === 'aux')
264
- return kind === 'memory' ? INJECT_MEMORY_REVIEW_PROMPT : INJECT_COMBINED_REVIEW_PROMPT;
264
+ return kind === 'memory' ? INJECT_MEMORY_REVIEW_PROMPT : INJECT_SKILL_REVIEW_PROMPT;
265
265
  if (kind === 'memory')
266
266
  return INJECT_MEMORY_REVIEW_PROMPT;
267
267
  if (kind === 'skill')
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Keep the family's model-facing surface out of the platform's minimal preset.
3
+ *
4
+ * The platform minimal preset deliberately has no skill loader or skill
5
+ * catalog. `evolution-all` mounts its model rows at profile root, which would
6
+ * otherwise leak memory/skill management into that preset. The public runtime
7
+ * API can hide those tools per agent scope without unloading the family's
8
+ * infrastructure; UI panels and commands remain profile-level.
9
+ *
10
+ * @module @lmzhen/dsh-evolution-core/runtime/minimal-preset
11
+ */
12
+ import type { Context } from '@deepseek-ai/cordis';
13
+ /** Family tools that must never be model-visible in the minimal preset. */
14
+ export declare const MINIMAL_PRESET_DENY_TOOLS: readonly ["memory", "skill_manage", "skill_search", "skill", "maintenance_probe", "merge_stage"];
15
+ /** Install the per-agent minimal-preset guard. */
16
+ export declare function installMinimalPresetGuard(ctx: Context): void;
17
+ //# sourceMappingURL=minimal-preset.d.ts.map
@@ -0,0 +1,81 @@
1
+ // platform-declaration anchor: sessionProjections is declared in core PLATFORM_SERVICE_PROBES.
2
+ /** Family tools that must never be model-visible in the minimal preset. */
3
+ export const MINIMAL_PRESET_DENY_TOOLS = [
4
+ 'memory',
5
+ 'skill_manage',
6
+ 'skill_search',
7
+ 'skill',
8
+ 'maintenance_probe',
9
+ 'merge_stage',
10
+ ];
11
+ function activePreset(ctx, agent) {
12
+ const registry = ctx.get('sessionProjections');
13
+ const projected = registry?.snapshot?.(agent.session, ['agentPreset'])?.values?.agentPreset;
14
+ if (typeof projected === 'string')
15
+ return projected;
16
+ const headerPreset = agent.session?.header?.agentPreset;
17
+ return typeof headerPreset === 'string' ? headerPreset : undefined;
18
+ }
19
+ /** Install the per-agent minimal-preset guard. */
20
+ export function installMinimalPresetGuard(ctx) {
21
+ const disposers = new Map();
22
+ const sync = (agent) => {
23
+ const key = agent.id;
24
+ if (activePreset(ctx, agent) !== 'minimal') {
25
+ disposers.get(key)?.();
26
+ disposers.delete(key);
27
+ return;
28
+ }
29
+ if (disposers.has(key))
30
+ return;
31
+ const tools = agent.ctx?.tools;
32
+ if (tools?.restrict === undefined)
33
+ return;
34
+ const known = MINIMAL_PRESET_DENY_TOOLS.filter(name => {
35
+ try {
36
+ return tools.get?.(name, agent) !== undefined;
37
+ }
38
+ catch {
39
+ return false;
40
+ }
41
+ });
42
+ if (known.length === 0)
43
+ return;
44
+ try {
45
+ disposers.set(key, tools.restrict({ deny: known }));
46
+ }
47
+ catch (error) {
48
+ // A guard failure must never veto agent creation; the next sync retries.
49
+ ctx.logger.warn('dsh-evolution-core: minimal preset tool restriction failed: ' + (error instanceof Error ? error.message : String(error)));
50
+ }
51
+ };
52
+ ctx.inject(['agents'], child => {
53
+ const events = child;
54
+ const created = events.on('agent/created', payload => {
55
+ const agent = payload?.agent;
56
+ if (agent !== undefined)
57
+ sync(agent);
58
+ });
59
+ const selected = events.on('agent-preset/selected', (sessionId) => {
60
+ const agent = events.agents?.get(sessionId);
61
+ if (agent !== undefined)
62
+ sync(agent);
63
+ });
64
+ const disposed = events.on('agent/disposed', payload => {
65
+ const agent = payload?.agent;
66
+ if (agent === undefined)
67
+ return;
68
+ disposers.get(agent.id)?.();
69
+ disposers.delete(agent.id);
70
+ });
71
+ child.effect(() => () => {
72
+ created();
73
+ selected();
74
+ disposed();
75
+ for (const dispose of disposers.values())
76
+ dispose();
77
+ disposers.clear();
78
+ });
79
+ });
80
+ }
81
+ //# sourceMappingURL=minimal-preset.js.map
@@ -1,12 +1,14 @@
1
1
  import { warnIfFamilyMixed } from "./coherence.js";
2
2
  import { EvolutionLlm } from "./llm.js";
3
3
  import { EvolutionProjections } from "./projections.js";
4
+ import { installMinimalPresetGuard } from "./minimal-preset.js";
4
5
  export const name = 'evolution-core-runtime';
5
6
  /** @param ctx - the composition context that owns the runtime services. */
6
7
  export async function apply(ctx) {
7
8
  // The adapter row owns `evolutionPlatform` and mounts before this row.
8
9
  await ctx.plugin(EvolutionProjections);
9
10
  await ctx.plugin(EvolutionLlm);
11
+ installMinimalPresetGuard(ctx);
10
12
  warnIfFamilyMixed(ctx);
11
13
  }
12
14
  //# sourceMappingURL=plugin.js.map
@@ -7,6 +7,12 @@
7
7
  */
8
8
  import type { SessionEvent } from '@lmzhen/dsh-evolution-platform-contract';
9
9
  export type ReviewKind = 'memory' | 'skill' | 'combined';
10
+ /** Review work due at one turn boundary. The delivery channel decides whether
11
+ * to combine memory/skill (foreground) or schedule them independently (aux). */
12
+ export interface ReviewDebt {
13
+ readonly memory: boolean;
14
+ readonly skill: boolean;
15
+ }
10
16
  export interface SignalConfig {
11
17
  memoryInterval: number;
12
18
  skillInterval: number;
@@ -67,7 +73,7 @@ export declare function foldTurnEvent(state: TurnFoldState, event: SessionEvent)
67
73
  */
68
74
  export declare function observeEvent(signal: TurnSignals, event: SessionEvent): void;
69
75
  /** Compute review cadence after `turn/end`. */
70
- export declare function advanceReview(state: ReviewState, turn: number, signal: TurnSignals, config: SignalConfig): ReviewKind | null;
76
+ export declare function advanceReview(state: ReviewState, turn: number, signal: TurnSignals, config: SignalConfig): ReviewDebt | null;
71
77
  /**
72
78
  * Fold a log slice into one turn window, purely.
73
79
  *
@@ -160,28 +160,17 @@ export function advanceReview(state, turn, signal, config) {
160
160
  state.turnsSinceSkill += signal.skillSignal ? 1 : Math.max(1, signal.toolCalls);
161
161
  const memoryDue = state.turnsSinceMemory >= config.memoryInterval;
162
162
  const skillDue = state.turnsSinceSkill >= config.skillInterval;
163
+ if (!memoryDue && !skillDue)
164
+ return null;
163
165
  // 0.3.40: with resetOnFire=false the counters stay monotonic — the caller
164
- // resets them at its injection point (the counting window is inject→inject).
165
- const zero = () => {
166
- state.turnsSinceMemory = 0;
167
- state.turnsSinceSkill = 0;
168
- };
169
- if (memoryDue && skillDue) {
170
- if (config.resetOnFire !== false)
171
- zero();
172
- return 'combined';
173
- }
174
- if (memoryDue) {
175
- if (config.resetOnFire !== false)
166
+ // resets them at its consumption point (the counting window is consume→consume).
167
+ if (config.resetOnFire !== false) {
168
+ if (memoryDue)
176
169
  state.turnsSinceMemory = 0;
177
- return 'memory';
178
- }
179
- if (skillDue) {
180
- if (config.resetOnFire !== false)
170
+ if (skillDue)
181
171
  state.turnsSinceSkill = 0;
182
- return 'skill';
183
172
  }
184
- return null;
173
+ return { memory: memoryDue, skill: skillDue };
185
174
  }
186
175
  /**
187
176
  * Fold a log slice into one turn window, purely.
@@ -97,11 +97,48 @@ export interface SkillStatsGovernance {
97
97
  readonly mode: string | null;
98
98
  readonly resultRef: string | null;
99
99
  }
100
+ /** One recent automatic review, as the activity sidecar records it. */
101
+ export interface SkillStatsReview {
102
+ readonly reviewId: string;
103
+ readonly kind: 'memory' | 'skill' | 'combined';
104
+ readonly status: 'completed' | 'partial' | 'failed' | 'timeout' | 'aborted';
105
+ readonly startedAt: number;
106
+ readonly finishedAt: number;
107
+ readonly partialReason?: string;
108
+ readonly hitRoundLimit?: boolean;
109
+ readonly requests?: number;
110
+ readonly toolCalls?: number;
111
+ readonly waitCount?: number;
112
+ readonly toolMode?: 'native' | 'ptc';
113
+ readonly preset?: string;
114
+ readonly report?: {
115
+ readonly summary: string;
116
+ readonly memoryChanged: boolean;
117
+ readonly skillsChanged: readonly string[];
118
+ readonly unresolved: readonly string[];
119
+ };
120
+ }
121
+ /** Library-wide automatic-review health summary; absent when no reviews are retained. */
122
+ export interface SkillStatsReviewSummary {
123
+ readonly total: number;
124
+ readonly completed: number;
125
+ readonly partial: number;
126
+ readonly timeout: number;
127
+ readonly failed: number;
128
+ readonly aborted: number;
129
+ readonly hitRoundLimit: number;
130
+ readonly avgRequests: number | null;
131
+ readonly avgToolCalls: number | null;
132
+ }
100
133
  /** Library-wide facts. These never belong in a single-skill detail view. */
101
134
  export interface SkillStatsGlobal {
102
135
  readonly totals: SkillStatsTotals;
103
136
  readonly counts: SkillStatsCounts | null;
104
137
  readonly governance: readonly SkillStatsGovernance[];
138
+ /** Recent automatic reviews; absent means this deployment did not report them. */
139
+ readonly reviews?: readonly SkillStatsReview[];
140
+ /** Health summary over all retained reviews; absent when none are retained. */
141
+ readonly reviewSummary?: SkillStatsReviewSummary;
105
142
  /** Label keys for the three success counters; the browser never imports core runtime. */
106
143
  readonly operations?: readonly {
107
144
  readonly id: SkillOperationId;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-core",
3
3
  "description": "Shared stores, prompts, signals and lifecycle logic for the dsh-evolution plugin family (community build)",
4
- "version": "0.58.0",
4
+ "version": "0.59.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -98,8 +98,8 @@
98
98
  "yaml": "^2.4.2",
99
99
  "zod": "^4.4.3",
100
100
  "@deepseek-ai/schemastery": "^3.18.5",
101
- "@lmzhen/dsh-evolution-adapter": "0.58.0",
102
- "@lmzhen/dsh-evolution-platform-contract": "0.58.0"
101
+ "@lmzhen/dsh-evolution-adapter": "0.59.1",
102
+ "@lmzhen/dsh-evolution-platform-contract": "0.59.1"
103
103
  },
104
104
  "peerDependencies": {
105
105
  "@deepseek-ai/cordis": "^4.0.5"