@lmzhen/dsh-evolution-core 0.49.0 → 0.51.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 (110) hide show
  1. package/lib/authority-plugin.js +2 -1
  2. package/lib/citations-CZKTUGQF.js +198 -0
  3. package/lib/composition/index.js +3 -3
  4. package/lib/{composition-Cqjbho0t.js → composition-CtNbVHq3.js} +1 -1
  5. package/lib/connection-DAJy7Xjm.js +28 -0
  6. package/lib/{ensure-CAjLGd9f.js → ensure-BLmEW0Ju.js} +25 -7
  7. package/lib/errors.js +2 -0
  8. package/lib/extract-plan-D6o__2Kf.js +271 -0
  9. package/lib/extract.js +240 -0
  10. package/lib/http-routes.js +27 -7
  11. package/lib/index.js +100 -811
  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-DpAS0rd9.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-BQCM4N8z.js +1419 -0
  24. package/lib/{skill-history-CxrDE3Rb.js → skill-history-CZp8vhyL.js} +46 -2
  25. package/lib/skills.js +140 -20
  26. package/lib/state-store-Jpa-iYIZ.js +54 -0
  27. package/lib/subagent/index.js +214 -176
  28. package/lib/{tools-DzcNFex2.js → tools-BrUswg8v.js} +3 -1
  29. package/lib/types/composition/ensure.js +21 -7
  30. package/lib/types/composition/preset-ids.d.ts +2 -1
  31. package/lib/types/composition/preset-ids.js +7 -1
  32. package/lib/types/events.d.ts +3 -0
  33. package/lib/types/extract-plan.d.ts +2 -0
  34. package/lib/types/extract.d.ts +12 -0
  35. package/lib/types/extract.js +12 -0
  36. package/lib/types/http-routes.js +32 -9
  37. package/lib/types/index.d.ts +0 -3
  38. package/lib/types/index.js +0 -3
  39. package/lib/types/opt-in.js +4 -3
  40. package/lib/types/params.js +2 -1
  41. package/lib/types/platform/agents.d.ts +32 -0
  42. package/lib/types/platform/agents.js +26 -0
  43. package/lib/types/platform/commands.d.ts +14 -0
  44. package/lib/types/platform/commands.js +9 -0
  45. package/lib/types/platform/connection.d.ts +26 -0
  46. package/lib/types/platform/connection.js +27 -0
  47. package/lib/types/platform/index.d.ts +26 -0
  48. package/lib/types/platform/index.js +13 -0
  49. package/lib/types/platform/llm.d.ts +3 -1
  50. package/lib/types/platform/llm.js +1 -0
  51. package/lib/types/platform/platformView.d.ts +21 -0
  52. package/lib/types/platform/platformView.js +29 -0
  53. package/lib/types/platform/profileContext.d.ts +16 -0
  54. package/lib/types/platform/profileContext.js +14 -0
  55. package/lib/types/platform/sessionQuery.d.ts +14 -0
  56. package/lib/types/platform/sessionQuery.js +9 -0
  57. package/lib/types/platform/settings.d.ts +22 -0
  58. package/lib/types/platform/settings.js +14 -0
  59. package/lib/types/platform/skills.d.ts +16 -0
  60. package/lib/types/platform/skills.js +9 -0
  61. package/lib/types/platform/storageDomain.d.ts +13 -0
  62. package/lib/types/platform/storageDomain.js +9 -0
  63. package/lib/types/platform/subagents.d.ts +25 -0
  64. package/lib/types/platform/subagents.js +17 -0
  65. package/lib/types/platform/systemPrompt.d.ts +16 -0
  66. package/lib/types/platform/systemPrompt.js +13 -0
  67. package/lib/types/platform/tools.d.ts +4 -0
  68. package/lib/types/platform/tools.js +2 -0
  69. package/lib/types/platform/userQuestions.d.ts +33 -0
  70. package/lib/types/platform/userQuestions.js +9 -0
  71. package/lib/types/platform/workingDirectory.d.ts +14 -0
  72. package/lib/types/platform/workingDirectory.js +9 -0
  73. package/lib/types/platform-line.generated.d.ts +5 -5
  74. package/lib/types/platform-line.generated.js +5 -5
  75. package/lib/types/platform-services.js +4 -0
  76. package/lib/types/prompts.d.ts +9 -8
  77. package/lib/types/prompts.js +20 -1
  78. package/lib/types/result.d.ts +35 -0
  79. package/lib/types/result.js +25 -0
  80. package/lib/types/review-context.d.ts +8 -0
  81. package/lib/types/review-context.js +11 -0
  82. package/lib/types/run-registry.d.ts +2 -1
  83. package/lib/types/run-registry.js +37 -7
  84. package/lib/types/runtime/llm.d.ts +2 -2
  85. package/lib/types/runtime/llm.js +5 -8
  86. package/lib/types/runtime/platform.d.ts +37 -4
  87. package/lib/types/runtime/platform.js +40 -5
  88. package/lib/types/runtime/projections.d.ts +9 -4
  89. package/lib/types/runtime/projections.js +64 -28
  90. package/lib/types/section-selection.js +5 -0
  91. package/lib/types/skill-history.d.ts +29 -3
  92. package/lib/types/skill-history.js +30 -0
  93. package/lib/types/skill-store.d.ts +32 -4
  94. package/lib/types/skill-store.js +109 -15
  95. package/lib/types/subagent/channel.d.ts +1 -3
  96. package/lib/types/subagent/channel.js +2 -332
  97. package/lib/types/subagent/index.d.ts +2 -0
  98. package/lib/types/subagent/index.js +2 -0
  99. package/lib/types/subagent/kernel.d.ts +4 -0
  100. package/lib/types/subagent/kernel.js +234 -0
  101. package/lib/types/subagent/readiness.js +5 -7
  102. package/lib/types/subagent/run.d.ts +53 -0
  103. package/lib/types/subagent/run.js +125 -0
  104. package/lib/types/subagent/types.d.ts +3 -3
  105. package/lib/types/write-gates.js +11 -1
  106. package/lib/usage-B5a90TKv.js +1257 -0
  107. package/lib/write.js +1 -1
  108. package/package.json +37 -25
  109. package/lib/platform-Cc9cNt5j.js +0 -111
  110. package/lib/skill-health-DP8z9TPf.js +0 -2923
@@ -275,46 +275,4 @@ const DEFAULT_SKILL_LIMITS = {
275
275
  versionKeep: 20
276
276
  };
277
277
  //#endregion
278
- //#region lib/types/numeric.js
279
- /**
280
- * Numeric config clamping for the dsh-evolution plugin family.
281
- *
282
- * G3.1 (0.3.23): numeric configuration values are normalised through a single
283
- * helper so 0 / negative / NaN / ±Infinity / out-of-range all fall back to the
284
- * package default instead of silently becoming a "disabled" special value or
285
- * folding as NaN into a computation. A non-finite value (NaN, ±Infinity) is
286
- * never a legitimate config, so it always falls back. The schema layer (a
287
- * `.min(1)` clamp on the number schema) is a first-line guard where it can
288
- * reject invalid values; this helper is the mandatory assembly-time clamp that
289
- * also catches what schemastery lets through (NaN and +Infinity both pass a
290
- * bare number schema).
291
- *
292
- * The scope here is pure numeric conversion only (no schemastery import), so
293
- * evolution-core stays free of a schemastery dependency. Per-package Config
294
- * schemas keep their own `.min()`/`.default()` call sites.
295
- * @module @lmzhen/dsh-evolution-core
296
- */
297
- /**
298
- * Clamp a numeric config to the `[min, max]` range.
299
- *
300
- * A non-finite value (NaN, ±Infinity), a non-number, or a value outside the
301
- * inclusive range falls back to `fallback`. When `opts.min >= 1`, 0 and
302
- * negative values also fall back to `fallback` — a 0 is never treated as a
303
- * special "disabled" meaning (G3.1 decision). Callers that legitimately allow
304
- * 0 (e.g. a threshold or a zero-cost weight) pass `{ min: 0 }` or omit the
305
- * range.
306
- *
307
- * @param value - the raw numeric config, possibly `undefined` (absent).
308
- * @param fallback - the default value to return when the value is invalid.
309
- * @param opts - optional inclusive lower/upper bound.
310
- * @returns `value` when it is a finite number within range, else `fallback`.
311
- */
312
- function clampedNumber(value, fallback, opts) {
313
- if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
314
- const { min, max } = opts ?? {};
315
- if (min !== void 0 && value < min) return fallback;
316
- if (max !== void 0 && value > max) return fallback;
317
- return value;
318
- }
319
- //#endregion
320
- export { DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS as A, MAX_SKILL_NAME_LENGTH as B, DEFAULT_REVIEW_TIMEOUT_MS as C, DEFAULT_SKILL_VERSION_KEEP as D, DEFAULT_SKILL_REVIEW_TRIGGER as E, EVOLUTION_WRITE_TOOLS as F, SKILL_ACTION_REQUIRED_FIELDS as G, MEMORY_GUIDANCE_SECTION_ORDER as H, FORBIDDEN_CONTROL_KEYS as I, SUPPORT_SPRAWL_FILES as J, SKILL_NAME_RE as K, MAX_DESCRIPTION_LENGTH as L, DEFAULT_THREAT_MAX_SCAN_CHARS as M, DEFAULT_USER_CHAR_LIMIT as N, DEFAULT_STALE_AFTER_DAYS as O, ENTRY_DELIMITER as P, MAX_SKILL_CONTENT_CHARS as R, DEFAULT_REVIEW_SKILL_INTERVAL as S, DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS as T, PROTECTED_BUILTIN_SKILLS as U, MAX_TIMER_DELAY_MS as V, SKILLS_GUIDANCE_SECTION_ORDER as W, UPSTREAM_LIMIT_CHARS_PER_TOKEN as Y, DEFAULT_CURATOR_REVIEW_MAX_TOKENS as _, DEFAULT_SKILL_LIMITS as a, DEFAULT_PROBE_TIMEOUT_MS as b, policyStageLimits as c, CONTENT_SPLIT_HINT as d, DEFAULT_ARCHIVE_AFTER_DAYS as f, DEFAULT_CURATOR_MODEL as g, DEFAULT_CURATOR_INTERVAL_HOURS as h, DEFAULT_REFERENCE_REWRITE_POLICY as i, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS as j, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS as k, AUTHORING_DESCRIPTION_BAR as l, DEFAULT_CURATOR_BOOT_GRACE_SECONDS as m, DEFAULT_ARCHIVE_RETENTION_POLICY as n, DEFAULT_SUPPORT_FILE_CHAR_POLICY as o, DEFAULT_CONSOLIDATION_FAILURES as p, SUPPORT_DIRS as q, DEFAULT_CITATION_POLICY as r, POLICY_STAGE_DEFAULTS as s, clampedNumber as t, AUTHORING_SPLIT_LINE_CHARS as u, DEFAULT_MEMORY_CHAR_LIMIT as v, DEFAULT_SKILL_CONTENT_CHARS as w, DEFAULT_REVIEW_MEMORY_INTERVAL as x, DEFAULT_MIN_IDLE_HOURS as y, MAX_SKILL_FILE_BYTES as z };
278
+ export { DEFAULT_SUBSTANTIVE_MIN_USER_CHARS as A, MAX_TIMER_DELAY_MS as B, DEFAULT_SKILL_CONTENT_CHARS as C, DEFAULT_STALE_AFTER_DAYS as D, DEFAULT_SKILL_VERSION_KEEP as E, FORBIDDEN_CONTROL_KEYS as F, SKILL_NAME_RE as G, PROTECTED_BUILTIN_SKILLS as H, MAX_DESCRIPTION_LENGTH as I, UPSTREAM_LIMIT_CHARS_PER_TOKEN as J, SUPPORT_DIRS as K, MAX_SKILL_CONTENT_CHARS as L, DEFAULT_USER_CHAR_LIMIT as M, ENTRY_DELIMITER as N, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS as O, EVOLUTION_WRITE_TOOLS as P, MAX_SKILL_FILE_BYTES as R, DEFAULT_REVIEW_TIMEOUT_MS as S, DEFAULT_SKILL_REVIEW_TRIGGER as T, SKILLS_GUIDANCE_SECTION_ORDER as U, MEMORY_GUIDANCE_SECTION_ORDER as V, SKILL_ACTION_REQUIRED_FIELDS as W, DEFAULT_MEMORY_CHAR_LIMIT as _, DEFAULT_SUPPORT_FILE_CHAR_POLICY as a, DEFAULT_REVIEW_MEMORY_INTERVAL as b, AUTHORING_DESCRIPTION_BAR as c, DEFAULT_ARCHIVE_AFTER_DAYS as d, DEFAULT_CONSOLIDATION_FAILURES as f, DEFAULT_CURATOR_REVIEW_MAX_TOKENS as g, DEFAULT_CURATOR_MODEL as h, DEFAULT_SKILL_LIMITS as i, DEFAULT_THREAT_MAX_SCAN_CHARS as j, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS as k, AUTHORING_SPLIT_LINE_CHARS as l, DEFAULT_CURATOR_INTERVAL_HOURS as m, DEFAULT_CITATION_POLICY as n, POLICY_STAGE_DEFAULTS as o, DEFAULT_CURATOR_BOOT_GRACE_SECONDS as p, SUPPORT_SPRAWL_FILES as q, DEFAULT_REFERENCE_REWRITE_POLICY as r, policyStageLimits as s, DEFAULT_ARCHIVE_RETENTION_POLICY as t, CONTENT_SPLIT_HINT as u, DEFAULT_MIN_IDLE_HOURS as v, DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS as w, DEFAULT_REVIEW_SKILL_INTERVAL as x, DEFAULT_PROBE_TIMEOUT_MS as y, MAX_SKILL_NAME_LENGTH as z };
@@ -1,10 +1,9 @@
1
1
  import { a as isProcessAlive, c as transactIo } from "./io-GxghO3Ip.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  import { mkdir, readFile, rm } from "node:fs/promises";
4
- import { dirname, join, resolve } from "node:path";
4
+ import { dirname, join } from "node:path";
5
5
  import { withFileLock } from "@deepseek-ai/dsh-atomic-write";
6
6
  import { randomUUID } from "node:crypto";
7
- import { homedir } from "node:os";
8
7
  //#region lib/types/authority.js
9
8
  /**
10
9
  * The family's one mutual-exclusion entry (W9-authority, invariant I1).
@@ -247,57 +246,6 @@ function leaseAsTreeLock(lease) {
247
246
  };
248
247
  }
249
248
  //#endregion
250
- //#region lib/types/state-store.js
251
- /**
252
- * Evolution home path helpers: the DSH root and `$DSH_HOME/evolution` for
253
- * plugin-owned sidecar state (reports, activity store, feedback file,
254
- * state-domain data).
255
- *
256
- * C-10: PATH HELPERS ONLY — despite the file name there is no store
257
- * here. Durable evolution state lives in the state stack (evolution-state over
258
- * evolution-state-domain); skills and memories live in skill-store.ts
259
- * / memory-store.ts. The file name is kept deliberately: renaming it would
260
- * touch every family import for zero behavior change, and the audit records
261
- * the mismatch as known naming debt.
262
- */
263
- /**
264
- * DSH home root: `$DSH_HOME` or `~/.dsh`. Single source of the empty-string
265
- * fallback — an EMPTY or WHITESPACE-ONLY DSH_HOME resolves to the default
266
- * home, never to a CWD-relative path (0.3.19 W1.3, 0.3.22 F-207);
267
- * V8-06 (0.3.47) extends the guard to whitespace.
268
- * C-11 correction (S2.2, PLAN 2026-09-16): upstream `resolveDshHome`
269
- * (util/home-paths) uses `trim()` ONLY as the ADOPTION test and then uses the
270
- * RAW env value — the earlier "same trimmed source" form returned the trimmed
271
- * text, so `DSH_HOME=" /x "` produced `/x` where upstream produced the literal
272
- * padded path. The value semantics now match upstream line for line:
273
- * `const selected = configured ?? (fromEnv !== undefined &&
274
- * fromEnv.trim().length > 0 ? fromEnv : defaultDshHome())`.
275
- * OPT-27 (2026-09, plan D5 — accepted): the v10-era "no `~` expansion, no
276
- * resolve" divergence from upstream `resolveDshHome` is RETIRED. It became
277
- * load-bearing when the skill-catalog shadow made "same tree as the upstream
278
- * `USER_DSH_RANK` provider" a hard contract: upstream watches the EXPANDED
279
- * absolute `<home>/skills` while this value fed a literal `~/x` (a directory
280
- * named `~` under the host CWD) or a CWD-relative path — split-brain skill
281
- * trees, preset installs the platform never reads, doctor probes of a
282
- * directory nothing serves.
283
- * S2.2 (PLAN 2026-09-16), final correction: the result is ALWAYS
284
- * `resolve(expandHomePath(selected))` — the earlier form returned an
285
- * already-absolute value VERBATIM, so a trailing slash or `..` segment
286
- * landed unnormalized while upstream normalizes every value. Relative
287
- * `DSH_HOME` values change landing spot; a CLEAN absolute home stays
288
- * byte-identical (resolve is a no-op on it).
289
- */
290
- function evolutionRoot(env = process.env) {
291
- const fromEnv = env.DSH_HOME;
292
- const selected = fromEnv !== void 0 && fromEnv.trim().length > 0 ? fromEnv : join(homedir(), ".dsh");
293
- return resolve(selected === "~" ? homedir() : selected.startsWith("~/") || selected.startsWith("~\\") ? join(homedir(), selected.slice(2)) : selected);
294
- }
295
- /** Evolution home path helper: `$DSH_HOME/evolution` for plugin-owned sidecar
296
- * state (reports, activity store, feedback file, state-domain data). */
297
- function evolutionHome(env = process.env) {
298
- return join(evolutionRoot(env), "evolution");
299
- }
300
- //#endregion
301
249
  //#region lib/types/home-fence.js
302
250
  /**
303
251
  * Lease adapter over the one HomeAuthority (W9-authority).
@@ -536,4 +484,4 @@ function mutationLockFrom(ctx) {
536
484
  return ctx.get("evolutionMutationAuthority")?.mutationLock;
537
485
  }
538
486
  //#endregion
539
- export { leaseFile as a, evolutionHome as c, AuthorityOrderError as d, AuthorityReentryError as f, leaseAsTreeLock as h, LeaseStore as i, evolutionRoot as l, authorityHolder as m, mutationLockFrom as n, HomeFence as o, HomeAuthority as p, DEFAULT_LEASE_TTL_MS as r, HomeFenceError as s, MutationAuthority as t, AuthorityBusyError as u };
487
+ export { leaseFile as a, AuthorityBusyError as c, HomeAuthority as d, authorityHolder as f, LeaseStore as i, AuthorityOrderError as l, mutationLockFrom as n, HomeFence as o, leaseAsTreeLock as p, DEFAULT_LEASE_TTL_MS as r, HomeFenceError as s, MutationAuthority as t, AuthorityReentryError as u };
@@ -0,0 +1,43 @@
1
+ //#region lib/types/numeric.js
2
+ /**
3
+ * Numeric config clamping for the dsh-evolution plugin family.
4
+ *
5
+ * G3.1 (0.3.23): numeric configuration values are normalised through a single
6
+ * helper so 0 / negative / NaN / ±Infinity / out-of-range all fall back to the
7
+ * package default instead of silently becoming a "disabled" special value or
8
+ * folding as NaN into a computation. A non-finite value (NaN, ±Infinity) is
9
+ * never a legitimate config, so it always falls back. The schema layer (a
10
+ * `.min(1)` clamp on the number schema) is a first-line guard where it can
11
+ * reject invalid values; this helper is the mandatory assembly-time clamp that
12
+ * also catches what schemastery lets through (NaN and +Infinity both pass a
13
+ * bare number schema).
14
+ *
15
+ * The scope here is pure numeric conversion only (no schemastery import), so
16
+ * evolution-core stays free of a schemastery dependency. Per-package Config
17
+ * schemas keep their own `.min()`/`.default()` call sites.
18
+ * @module @lmzhen/dsh-evolution-core
19
+ */
20
+ /**
21
+ * Clamp a numeric config to the `[min, max]` range.
22
+ *
23
+ * A non-finite value (NaN, ±Infinity), a non-number, or a value outside the
24
+ * inclusive range falls back to `fallback`. When `opts.min >= 1`, 0 and
25
+ * negative values also fall back to `fallback` — a 0 is never treated as a
26
+ * special "disabled" meaning (G3.1 decision). Callers that legitimately allow
27
+ * 0 (e.g. a threshold or a zero-cost weight) pass `{ min: 0 }` or omit the
28
+ * range.
29
+ *
30
+ * @param value - the raw numeric config, possibly `undefined` (absent).
31
+ * @param fallback - the default value to return when the value is invalid.
32
+ * @param opts - optional inclusive lower/upper bound.
33
+ * @returns `value` when it is a finite number within range, else `fallback`.
34
+ */
35
+ function clampedNumber(value, fallback, opts) {
36
+ if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
37
+ const { min, max } = opts ?? {};
38
+ if (min !== void 0 && value < min) return fallback;
39
+ if (max !== void 0 && value > max) return fallback;
40
+ return value;
41
+ }
42
+ //#endregion
43
+ export { clampedNumber as t };
@@ -1,4 +1,5 @@
1
+ import { t as connectionPort } from "../connection-DAJy7Xjm.js";
2
+ import { C as workingDirectoryPort, D as profileContextPort, E as pluginManagerPort, O as commandsPort, S as skillsPort, T as pluginInventoryPort, _ as agentsPort, a as createUserMessage, b as storageDomainPort, c as domainTable, d as EvolutionLlmError, f as llmPort, g as subagentsPort, h as userQuestionsPort, i as createToolResultMessage, l as escapeText, m as projectionPort, n as DomainError, o as defineDomain, p as modelRoute, r as SessionId, s as defineTool, t as BlockAssembler, u as scopeOf, v as systemPromptPort, w as configEditorPort, x as sessionQueryPort, y as settingsPort } from "../platform-DyHnHUmQ.js";
1
3
  import { t as presetsPort } from "../presets-C8vuCuNA.js";
2
- import { a as createUserMessage, c as domainTable, d as EvolutionLlmError, f as llmPort, i as createToolResultMessage, l as escapeText, m as projectionPort, n as DomainError, o as defineDomain, p as modelRoute, r as SessionId, s as defineTool, t as BlockAssembler, u as scopeOf } from "../platform-Cc9cNt5j.js";
3
- import { n as toolsPort, t as registerEvolutionTool } from "../tools-DzcNFex2.js";
4
- export { BlockAssembler, DomainError, EvolutionLlmError, SessionId, createToolResultMessage, createUserMessage, defineDomain, defineTool, domainTable, escapeText, llmPort, modelRoute, presetsPort, projectionPort, registerEvolutionTool, scopeOf, toolsPort };
4
+ import { n as toolsPort, t as registerEvolutionTool } from "../tools-BrUswg8v.js";
5
+ export { BlockAssembler, DomainError, EvolutionLlmError, SessionId, agentsPort, commandsPort, configEditorPort, connectionPort, createToolResultMessage, createUserMessage, defineDomain, defineTool, domainTable, escapeText, llmPort, modelRoute, pluginInventoryPort, pluginManagerPort, presetsPort, profileContextPort, projectionPort, registerEvolutionTool, scopeOf, sessionQueryPort, settingsPort, skillsPort, storageDomainPort, subagentsPort, systemPromptPort, toolsPort, userQuestionsPort, workingDirectoryPort };
@@ -0,0 +1,251 @@
1
+ import { defineTool } from "@deepseek-ai/dsh-tools";
2
+ import { scopeOf } from "@deepseek-ai/dsh-scope";
3
+ import { DomainError, defineDomain, domainTable } from "@deepseek-ai/dsh-storage-domain";
4
+ import { escapeText } from "@deepseek-ai/dsh-skill";
5
+ import { BlockAssembler, createToolResultMessage, createUserMessage } from "@deepseek-ai/dsh-llm";
6
+ import { SessionId } from "@deepseek-ai/dsh-session";
7
+ //#region lib/types/platform/commands.js
8
+ /** Resolve the commands port; undefined means the host has no commands service. */
9
+ function commandsPort(ctx) {
10
+ const service = ctx.get("commands");
11
+ if (service === void 0 || typeof service.register !== "function") return void 0;
12
+ return { register: (definition) => service.register(definition) };
13
+ }
14
+ //#endregion
15
+ //#region lib/types/platform/profileContext.js
16
+ /** Resolve the profile-context port; undefined means no profile is mounted. */
17
+ function profileContextPort(ctx) {
18
+ const service = ctx.get("profileContext");
19
+ if (service === void 0 || typeof service.dir !== "string" || service.dir === "") return void 0;
20
+ return {
21
+ name: typeof service.name === "string" ? service.name : "",
22
+ dir: service.dir,
23
+ ...typeof service.patchPath === "string" && service.patchPath !== "" ? { patchPath: service.patchPath } : {},
24
+ ...Array.isArray(service.startedBundles) ? { startedBundles: service.startedBundles } : {}
25
+ };
26
+ }
27
+ //#endregion
28
+ //#region lib/types/platform/platformView.js
29
+ function pluginManagerPort(ctx) {
30
+ const service = ctx.get("pluginManager");
31
+ if (service === void 0) return void 0;
32
+ return {
33
+ ...typeof service.listBundles === "function" ? { listBundles: () => service.listBundles() } : {},
34
+ ...typeof service.listPlugins === "function" ? { listPlugins: () => service.listPlugins() } : {}
35
+ };
36
+ }
37
+ function pluginInventoryPort(ctx) {
38
+ const service = ctx.get("pluginInventory");
39
+ if (service === void 0) return void 0;
40
+ return { ...typeof service.list === "function" ? { list: () => service.list() } : {} };
41
+ }
42
+ function configEditorPort(ctx) {
43
+ const service = ctx.get("configEditor");
44
+ if (service === void 0) return void 0;
45
+ return { ...typeof service.configuration === "function" ? { configuration: () => service.configuration() } : {} };
46
+ }
47
+ //#endregion
48
+ //#region lib/types/platform/workingDirectory.js
49
+ /** Resolve the working-directory port; undefined means the host has no such service. */
50
+ function workingDirectoryPort(ctx) {
51
+ const service = ctx.get("workingDirectory");
52
+ if (service === void 0 || typeof service.ensure !== "function") return void 0;
53
+ return { ensure: (agent, signal) => service.ensure(agent, signal) };
54
+ }
55
+ //#endregion
56
+ //#region lib/types/platform/skills.js
57
+ /** Resolve the skills port; undefined means the host has no skills service. */
58
+ function skillsPort(ctx) {
59
+ const service = ctx.get("skills");
60
+ if (service === void 0 || typeof service.list !== "function") return void 0;
61
+ return { list: (options) => service.list(options) };
62
+ }
63
+ //#endregion
64
+ //#region lib/types/platform/sessionQuery.js
65
+ /** Resolve the session-query port; undefined means the host has no such service. */
66
+ function sessionQueryPort(ctx) {
67
+ const service = ctx.get("sessionQuery");
68
+ if (service === void 0 || typeof service.listSessions !== "function") return void 0;
69
+ return { listSessions: (signal) => service.listSessions(signal) };
70
+ }
71
+ //#endregion
72
+ //#region lib/types/platform/storageDomain.js
73
+ /** Resolve the storage-domain port; undefined means the host has no provider. */
74
+ function storageDomainPort(ctx) {
75
+ const service = ctx.get("storageDomain");
76
+ if (service === void 0 || typeof service.open !== "function") return void 0;
77
+ return { open: (spec) => service.open(spec) };
78
+ }
79
+ //#endregion
80
+ //#region lib/types/platform/settings.js
81
+ /** Resolve the settings port; undefined means the host has no settings service. */
82
+ function settingsPort(ctx) {
83
+ const service = ctx.get("settings");
84
+ if (service === void 0) return void 0;
85
+ if (typeof service.configure !== "function" && typeof service.describe !== "function") return void 0;
86
+ return {
87
+ ...typeof service.configure === "function" ? { configure: (options, owner) => service.configure(options, owner) } : {},
88
+ ...typeof service.describe === "function" ? { describe: (options) => service.describe(options) } : {}
89
+ };
90
+ }
91
+ //#endregion
92
+ //#region lib/types/platform/systemPrompt.js
93
+ /** Resolve the system-prompt port; undefined means the host has no such service. */
94
+ function systemPromptPort(ctx) {
95
+ const service = ctx.get("systemPrompt");
96
+ if (service === void 0 || typeof service.section !== "function" || typeof service.variable !== "function") return void 0;
97
+ return {
98
+ section: (section) => service.section(section),
99
+ variable: (name, provider) => service.variable(name, provider),
100
+ ...typeof service.context === "function" ? { context: (context) => service.context(context) } : {}
101
+ };
102
+ }
103
+ //#endregion
104
+ //#region lib/types/platform/agents.js
105
+ const asIdentity = (value) => {
106
+ if (value === null || typeof value !== "object") return void 0;
107
+ return typeof value.id === "string" ? value : void 0;
108
+ };
109
+ /** Resolve the agents port; undefined means the host has no agents service. */
110
+ function agentsPort(ctx) {
111
+ const agents = ctx.get("agents");
112
+ if (agents === void 0) return void 0;
113
+ if (typeof agents.get !== "function" && typeof agents.list !== "function") return void 0;
114
+ const get = typeof agents.get === "function" ? agents.get.bind(agents) : void 0;
115
+ const list = typeof agents.list === "function" ? agents.list.bind(agents) : void 0;
116
+ return {
117
+ get: (id) => get === void 0 ? void 0 : asIdentity(get(id)),
118
+ list: () => list === void 0 ? [] : list().map(asIdentity).filter((agent) => agent !== void 0),
119
+ isRoot: (agent) => {
120
+ const live = get === void 0 ? void 0 : asIdentity(get(agent.id));
121
+ return live !== void 0 && live === agent && live.session?.header?.origin !== "subagent";
122
+ }
123
+ };
124
+ }
125
+ //#endregion
126
+ //#region lib/types/platform/subagents.js
127
+ /** Resolve the subagents port; undefined means the host has no subagents service. */
128
+ function subagentsPort(ctx) {
129
+ const subagents = ctx.get("subagents");
130
+ if (subagents === void 0 || typeof subagents.getProvider !== "function" || typeof subagents.startActivation !== "function") return void 0;
131
+ return {
132
+ getProvider: (name) => subagents.getProvider(name),
133
+ start: (spec) => subagents.startActivation(spec),
134
+ ...typeof subagents.sendMessage === "function" ? { sendMessage: (sender, targetId, content, options) => subagents.sendMessage(sender, targetId, content, options) } : {}
135
+ };
136
+ }
137
+ //#endregion
138
+ //#region lib/types/platform/userQuestions.js
139
+ /** Resolve the user-questions port; undefined means the host has no such service. */
140
+ function userQuestionsPort(ctx) {
141
+ const service = ctx.get("userQuestions");
142
+ if (service === void 0 || typeof service.ask !== "function") return void 0;
143
+ return { ask: (request) => service.ask(request) };
144
+ }
145
+ //#endregion
146
+ //#region lib/types/platform/projections.js
147
+ const isHandle = (value) => value !== null && typeof value === "object" && typeof value.stateOf === "function" && typeof value.dispose === "function";
148
+ /** Resolve the projection port; undefined means the host has no projection registry. */
149
+ function projectionPort(ctx) {
150
+ const registry = ctx.get("sessionProjections");
151
+ if (registry === void 0) return void 0;
152
+ let shape = "unrecognised";
153
+ let reason = "sessionProjections.register has not answered yet";
154
+ return {
155
+ get shape() {
156
+ return shape;
157
+ },
158
+ get reason() {
159
+ return shape === "unrecognised" ? reason : void 0;
160
+ },
161
+ async register(definition) {
162
+ const resolved = await registry.register(definition);
163
+ if (isHandle(resolved)) {
164
+ shape = "handle";
165
+ reason = void 0;
166
+ return {
167
+ stateOf: (session) => resolved.stateOf(session),
168
+ dispose: () => resolved.dispose()
169
+ };
170
+ }
171
+ shape = "unrecognised";
172
+ reason = "sessionProjections.register returned " + (resolved === null ? "null" : typeof resolved) + " without a projection handle";
173
+ return {
174
+ stateOf: () => void 0,
175
+ dispose: async () => {}
176
+ };
177
+ }
178
+ };
179
+ }
180
+ //#endregion
181
+ //#region lib/types/platform/llm.js
182
+ /** Typed auxiliary-LLM failure; callers may map these without parsing messages. */
183
+ var EvolutionLlmError = class extends Error {
184
+ kind;
185
+ constructor(kind, message, cause) {
186
+ super(message);
187
+ this.name = "EvolutionLlmError";
188
+ this.kind = kind;
189
+ if (cause !== void 0) this.cause = cause;
190
+ }
191
+ };
192
+ function toOptions(request) {
193
+ return {
194
+ provider: request.provider,
195
+ model: request.model,
196
+ messages: request.messages,
197
+ ...request.maxTokens === void 0 ? {} : { maxTokens: request.maxTokens },
198
+ ...request.temperature === void 0 ? {} : { temperature: request.temperature },
199
+ ...request.signal === void 0 ? {} : { signal: request.signal },
200
+ purpose: request.purpose
201
+ };
202
+ }
203
+ /** Resolve the LLM port; undefined means the host has no llm service. */
204
+ function llmPort(ctx) {
205
+ const llm = ctx.get("llm");
206
+ if (llm === void 0) return void 0;
207
+ const port = {
208
+ async *stream(request) {
209
+ const options = toOptions(request);
210
+ if (llm.stream === void 0) throw new EvolutionLlmError("transport", "llm service has no stream()");
211
+ yield* llm.stream(options);
212
+ },
213
+ ...llm.stream === void 0 ? {} : { streamRaw: (options) => llm.stream(options) },
214
+ async completeText(request) {
215
+ let text = "";
216
+ for await (const chunk of port.stream(request)) {
217
+ const frame = chunk;
218
+ if (frame.type === "text-delta" || frame.type === "text") text += typeof frame.text === "string" ? frame.text : "";
219
+ if (frame.type === "finish" && frame.reason?.kind === "error") {
220
+ const message = frame.reason.failure?.message;
221
+ throw new EvolutionLlmError("transport", "model call failed: " + (typeof message === "string" ? message : "unknown"));
222
+ }
223
+ }
224
+ return text;
225
+ }
226
+ };
227
+ return port;
228
+ }
229
+ /** Resolve the model route: agent-owned selection first, deployment default second. */
230
+ function modelRoute(ctx, agent, session) {
231
+ const owned = agent?.model?.current?.();
232
+ if (owned !== void 0) return {
233
+ provider: owned.provider,
234
+ model: owned.model
235
+ };
236
+ if (session !== void 0) {
237
+ const value = ctx.get("sessionProjections")?.snapshot?.(session, ["modelSelection"])?.values?.modelSelection;
238
+ const chosen = value?.next ?? value?.lastUsed;
239
+ if (chosen !== void 0 && chosen !== null) return {
240
+ provider: chosen.provider,
241
+ model: chosen.model
242
+ };
243
+ }
244
+ const fallback = ctx.get("agentDefaultModel")?.currentSelection?.();
245
+ return fallback === void 0 ? void 0 : {
246
+ provider: fallback.provider,
247
+ model: fallback.model
248
+ };
249
+ }
250
+ //#endregion
251
+ export { workingDirectoryPort as C, profileContextPort as D, pluginManagerPort as E, commandsPort as O, skillsPort as S, pluginInventoryPort as T, agentsPort as _, createUserMessage as a, storageDomainPort as b, domainTable as c, EvolutionLlmError as d, llmPort as f, subagentsPort as g, userQuestionsPort as h, createToolResultMessage as i, escapeText as l, projectionPort as m, DomainError as n, defineDomain as o, modelRoute as p, SessionId as r, defineTool as s, BlockAssembler as t, scopeOf as u, systemPromptPort as v, configEditorPort as w, sessionQueryPort as x, settingsPort as y };
package/lib/policy.js CHANGED
@@ -1,6 +1,7 @@
1
- import { F as EVOLUTION_WRITE_TOOLS, I as FORBIDDEN_CONTROL_KEYS, N as DEFAULT_USER_CHAR_LIMIT, U as PROTECTED_BUILTIN_SKILLS, g as DEFAULT_CURATOR_MODEL, i as DEFAULT_REFERENCE_REWRITE_POLICY, n as DEFAULT_ARCHIVE_RETENTION_POLICY, o as DEFAULT_SUPPORT_FILE_CHAR_POLICY, r as DEFAULT_CITATION_POLICY, s as POLICY_STAGE_DEFAULTS, t as clampedNumber, v as DEFAULT_MEMORY_CHAR_LIMIT, w as DEFAULT_SKILL_CONTENT_CHARS } from "./numeric-D8js3sqC.js";
1
+ import { C as DEFAULT_SKILL_CONTENT_CHARS, F as FORBIDDEN_CONTROL_KEYS, H as PROTECTED_BUILTIN_SKILLS, M as DEFAULT_USER_CHAR_LIMIT, P as EVOLUTION_WRITE_TOOLS, _ as DEFAULT_MEMORY_CHAR_LIMIT, a as DEFAULT_SUPPORT_FILE_CHAR_POLICY, h as DEFAULT_CURATOR_MODEL, n as DEFAULT_CITATION_POLICY, o as POLICY_STAGE_DEFAULTS, r as DEFAULT_REFERENCE_REWRITE_POLICY, t as DEFAULT_ARCHIVE_RETENTION_POLICY } from "./limits-C9jfvxBl.js";
2
2
  import { t as asRecord } from "./guards-3f02mnf2.js";
3
- import { n as toolsPort } from "./tools-DzcNFex2.js";
3
+ import { t as clampedNumber } from "./numeric-Dc53KQoe.js";
4
+ import { n as toolsPort } from "./tools-BrUswg8v.js";
4
5
  import { Service } from "@deepseek-ai/cordis";
5
6
  import z from "@deepseek-ai/schemastery";
6
7
  //#region lib/types/policy.js