@lmzhen/dsh-evolution-core 0.46.0 → 0.48.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.
- package/lib/authority-plugin.js +1 -1
- package/lib/composition/index.js +3 -3
- package/lib/{composition-Da8NfRI7.js → composition-Cqjbho0t.js} +1 -1
- package/lib/{ensure-C5Mo1dbB.js → ensure-CAjLGd9f.js} +1 -2
- package/lib/http-routes.js +21 -96
- package/lib/index.js +47 -246
- package/lib/{io-AmUf4lVY.js → io-GxghO3Ip.js} +30 -70
- package/lib/io-node.js +1 -1
- package/lib/io-registry.js +1 -35
- package/lib/{mutation-authority-DeJ_Wz14.js → mutation-authority-l57R626O.js} +17 -15
- package/lib/{mutations-DwvbjRHF.js → mutations-DQXddSJd.js} +1 -1
- package/lib/{numeric-DLeLvvGb.js → numeric-D8js3sqC.js} +1 -5
- package/lib/platform/index.js +1 -1
- package/lib/{platform-CFA12Jam.js → platform-Cc9cNt5j.js} +4 -28
- package/lib/policy.js +1 -1
- package/lib/runtime/plugin.js +21 -43
- package/lib/{session-projection-EB7mUOlJ.js → session-projection-DSXnUNZG.js} +3 -21
- package/lib/{skill-health-D1pZGk5V.js → skill-health-DP8z9TPf.js} +4 -25
- package/lib/{skill-history-CjypdYqv.js → skill-history-CxrDE3Rb.js} +54 -102
- package/lib/skills.js +166 -184
- package/lib/subagent/index.js +4 -10
- package/lib/types/authority.d.ts +2 -0
- package/lib/types/authority.js +5 -0
- package/lib/types/composition/preset-ids.d.ts +0 -1
- package/lib/types/composition/preset-ids.js +0 -1
- package/lib/types/constants.d.ts +0 -4
- package/lib/types/constants.js +0 -4
- package/lib/types/contract.d.ts +0 -5
- package/lib/types/curator.d.ts +0 -1
- package/lib/types/curator.js +0 -1
- package/lib/types/document-body.d.ts +0 -12
- package/lib/types/document-body.js +0 -14
- package/lib/types/health-baseline.d.ts +0 -13
- package/lib/types/health-baseline.js +0 -20
- package/lib/types/home-fence.d.ts +2 -0
- package/lib/types/home-fence.js +11 -1
- package/lib/types/http-routes.d.ts +9 -4
- package/lib/types/http-routes.js +36 -116
- package/lib/types/index.d.ts +0 -3
- package/lib/types/index.js +0 -3
- package/lib/types/io-registry.d.ts +0 -16
- package/lib/types/io-registry.js +0 -27
- package/lib/types/io.d.ts +6 -54
- package/lib/types/io.js +35 -65
- package/lib/types/journal-protocol.d.ts +0 -15
- package/lib/types/journal-protocol.js +1 -19
- package/lib/types/lease-store.d.ts +1 -1
- package/lib/types/lease-store.js +4 -15
- package/lib/types/live.d.ts +0 -12
- package/lib/types/live.js +0 -18
- package/lib/types/memory-store.d.ts +0 -1
- package/lib/types/memory-store.js +13 -6
- package/lib/types/mutation-authority.js +5 -0
- package/lib/types/mutation-unit.d.ts +1 -1
- package/lib/types/mutation-unit.js +14 -31
- package/lib/types/params.d.ts +11 -29
- package/lib/types/params.js +13 -60
- package/lib/types/platform/llm.d.ts +2 -3
- package/lib/types/platform/llm.js +3 -10
- package/lib/types/platform/projections.d.ts +4 -5
- package/lib/types/platform/projections.js +4 -18
- package/lib/types/probe.d.ts +0 -3
- package/lib/types/probe.js +0 -7
- package/lib/types/run-registry.js +10 -12
- package/lib/types/runtime/llm.js +2 -2
- package/lib/types/runtime/platform.d.ts +7 -11
- package/lib/types/runtime/platform.js +13 -19
- package/lib/types/runtime/plugin.d.ts +1 -1
- package/lib/types/runtime/plugin.js +6 -4
- package/lib/types/runtime/projections.js +1 -2
- package/lib/types/session-fold.d.ts +0 -8
- package/lib/types/session-fold.js +0 -5
- package/lib/types/session-projection.js +2 -2
- package/lib/types/skill-discovery.d.ts +0 -2
- package/lib/types/skill-discovery.js +1 -2
- package/lib/types/skill-health.d.ts +29 -1
- package/lib/types/skill-history.d.ts +0 -24
- package/lib/types/skill-history.js +0 -41
- package/lib/types/skill-lint.d.ts +0 -3
- package/lib/types/skill-lint.js +0 -12
- package/lib/types/skill-store.d.ts +6 -0
- package/lib/types/skill-store.js +130 -142
- package/lib/types/subagent/readiness.d.ts +0 -1
- package/lib/types/subagent/readiness.js +2 -8
- package/lib/types/tool-dispatch.d.ts +1 -16
- package/lib/types/tool-dispatch.js +0 -18
- package/lib/types/unit-journal.d.ts +1 -1
- package/lib/types/unit-journal.js +20 -15
- package/lib/types/unit-storage.d.ts +1 -1
- package/lib/types/unit-storage.js +5 -16
- package/lib/types/write-inventory.d.ts +0 -4
- package/lib/types/write-inventory.js +0 -9
- package/lib/types/write-kernel.d.ts +3 -4
- package/lib/types/write-kernel.js +13 -25
- package/lib/write.js +2 -2
- package/package.json +1 -1
- package/persisted-write-inventory.json +72 -9
- package/lib/types/fold-untrusted.d.ts +0 -35
- package/lib/types/fold-untrusted.js +0 -44
- package/lib/types/unit-recovery.d.ts +0 -5
- package/lib/types/unit-recovery.js +0 -12
package/lib/types/params.js
CHANGED
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
* the SAME name in two carriers (reviewMode, staleAfterDays, archiveAfterDays —
|
|
6
6
|
* resolved by the existing policy-shadows-row rule) and six use DIFFERENT names.
|
|
7
7
|
* This module owns the six: the policy/snapshot name is the canonical id, the
|
|
8
|
-
* plugin-row name is a deprecated alias
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* plugin-row name is a deprecated alias. The alias table survives only for the one-time
|
|
9
|
+
* legacy-document migration and the doctor's old-key report; live readers use the
|
|
10
|
+
* canonical id and its carrier no longer falls back to the legacy spelling.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
* writing is strict (the write path accepts canonical ids only, so no new
|
|
14
|
-
* document is created under a deprecated name).
|
|
12
|
+
* Writing is canonical-only (a deprecated name is not a live row field in 0.48).
|
|
15
13
|
* @module
|
|
16
14
|
*/
|
|
17
|
-
/** Deprecated alias (plugin-row name) -> canonical id (policy/snapshot name).
|
|
15
|
+
/** Deprecated alias (plugin-row name) -> canonical id (policy/snapshot name).
|
|
16
|
+
* Retained for the one-time legacy-document migration and the doctor's old-key report;
|
|
17
|
+
* live readers use the canonical id only. */
|
|
18
18
|
export const PARAM_ALIASES = Object.freeze({
|
|
19
19
|
memoryInterval: 'reviewMemoryInterval',
|
|
20
20
|
skillInterval: 'reviewSkillInterval',
|
|
@@ -23,15 +23,6 @@ export const PARAM_ALIASES = Object.freeze({
|
|
|
23
23
|
memoryCharLimit: 'memoryChars',
|
|
24
24
|
userCharLimit: 'userChars',
|
|
25
25
|
});
|
|
26
|
-
/** Canonical ids that have at least one deprecated alias, for read fallback. */
|
|
27
|
-
const ALIASES_BY_CANONICAL = (() => {
|
|
28
|
-
const index = {};
|
|
29
|
-
for (const [alias, canonical] of Object.entries(PARAM_ALIASES)) {
|
|
30
|
-
;
|
|
31
|
-
(index[canonical] ??= []).push(alias);
|
|
32
|
-
}
|
|
33
|
-
return index;
|
|
34
|
-
})();
|
|
35
26
|
/**
|
|
36
27
|
* Resolve any parameter id to its canonical form.
|
|
37
28
|
* @param id - canonical id or deprecated alias.
|
|
@@ -49,35 +40,15 @@ export function isDeprecatedParamId(id) {
|
|
|
49
40
|
return PARAM_ALIASES[id] !== undefined;
|
|
50
41
|
}
|
|
51
42
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @param id - parameter id a caller intends to write.
|
|
54
|
-
* @returns the canonical id.
|
|
55
|
-
* @throws {Error} when the id is a deprecated alias; the message names both ids.
|
|
56
|
-
*/
|
|
57
|
-
export function canonicalWriteId(id) {
|
|
58
|
-
const canonical = PARAM_ALIASES[id];
|
|
59
|
-
if (canonical === undefined)
|
|
60
|
-
return id;
|
|
61
|
-
throw new Error(`parameter id \`${id}\` is deprecated; write \`${canonical}\` instead`);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Read a parameter from a carrier that may still spell the legacy name.
|
|
43
|
+
* Read a parameter by its canonical id.
|
|
65
44
|
* @param carrier - config/snapshot object to read from, or undefined.
|
|
66
|
-
* @param id - canonical id (
|
|
67
|
-
* @returns the canonical value
|
|
45
|
+
* @param id - canonical id (an alias is resolved first, for migration callers).
|
|
46
|
+
* @returns the canonical value, or undefined.
|
|
68
47
|
*/
|
|
69
48
|
export function readParam(carrier, id) {
|
|
70
49
|
if (carrier === undefined)
|
|
71
50
|
return undefined;
|
|
72
|
-
|
|
73
|
-
const canonical = resolveParamId(id);
|
|
74
|
-
if (record[canonical] !== undefined)
|
|
75
|
-
return record[canonical];
|
|
76
|
-
for (const alias of ALIASES_BY_CANONICAL[canonical] ?? []) {
|
|
77
|
-
if (record[alias] !== undefined)
|
|
78
|
-
return record[alias];
|
|
79
|
-
}
|
|
80
|
-
return undefined;
|
|
51
|
+
return carrier[resolveParamId(id)];
|
|
81
52
|
}
|
|
82
53
|
/**
|
|
83
54
|
* Chinese display name per group, one entry per line (the scripts read this block
|
|
@@ -190,10 +161,8 @@ export const PARAM_EXPOSURE = Object.freeze([
|
|
|
190
161
|
{ id: 'evolution-commands.maintainTimeoutMs', group: 'deployment', tier: 'E2', authority: 'cordis', owner: 'evolution-commands', applies: 'none', docAnchor: 'PARAMETERS.md#deployment', summary: 'Timeout of one maintenance run started from the command surface.', why: 'internal' },
|
|
191
162
|
{ id: 'evolution-maintenance.probeTimeoutMs', group: 'deployment', tier: 'E2', authority: 'cordis', owner: 'evolution-maintenance', applies: 'none', docAnchor: 'PARAMETERS.md#deployment', summary: 'Model-facing budget of one maintenance_probe call — a hang guard, not a latency budget.', why: 'internal' },
|
|
192
163
|
{ id: 'skill-usage.supportReadToolNames', group: 'deployment', tier: 'E2', authority: 'cordis', owner: 'skill-usage', applies: 'none', docAnchor: 'PARAMETERS.md#deployment', summary: 'Tool names whose file reads are attributed to support files.', why: 'internal' },
|
|
193
|
-
{ id: 'install.mode', group: 'deployment', tier: 'E4', authority: 'install', owner: 'scripts', applies: 'restart', docAnchor: 'PARAMETERS.md#deployment', summary: 'Install target plane (values all / host;
|
|
194
|
-
{ id: 'install.basePreset', group: 'deployment', tier: 'E4', authority: 'install', owner: 'scripts', applies: 'restart', docAnchor: 'PARAMETERS.md#deployment', summary: 'Agent-preset base the layered install composes from (--base).', why: 'install', consumer: 'basePresetPlugins' },
|
|
164
|
+
{ id: 'install.mode', group: 'deployment', tier: 'E4', authority: 'install', owner: 'scripts', applies: 'restart', docAnchor: 'PARAMETERS.md#deployment', summary: 'Install target plane (values all / host; legacy modes are uninstall-only in 0.48).', why: 'install' },
|
|
195
165
|
{ id: 'install.home', group: 'deployment', tier: 'E4', authority: 'install', owner: 'scripts', applies: 'restart', docAnchor: 'PARAMETERS.md#deployment', summary: 'Harness home the installer writes into (--home).', why: 'install' },
|
|
196
|
-
{ id: 'install.presetRowOverrides', group: 'deployment', tier: 'E4', authority: 'install', owner: 'scripts', applies: 'restart', docAnchor: 'PARAMETERS.md#deployment', summary: 'Preset row overrides the installer injects (row-overrides.json).', why: 'install', consumer: 'loadRowOverrides' },
|
|
197
166
|
{ id: 'mergeApproval', group: 'merge', tier: 'E3', authority: 'cordis', owner: 'evolution-merge', applies: 'live', docAnchor: 'PARAMETERS.md#merge', summary: 'Pause after round 1 and put the pair in the pending queue instead of authoring round 2 automatically.', label: '合并审批', hint: '开启后,第一轮判定完先停下、进入待批准清单;关闭则直接进入第二轮合并。', control: 'switch', unit: '', values: '', card: 'evolution-merge' },
|
|
198
167
|
{ id: 'mergeSkippedTtlDays', group: 'merge', tier: 'E3', authority: 'cordis', owner: 'evolution-merge', applies: 'live', docAnchor: 'PARAMETERS.md#merge', summary: 'Days a skipped pair stays out of screening; 0 means it never expires.', label: '无需合并保留天数', hint: '判定无需合并的对,多少天内不再参与筛选;0 表示一直保留。', control: 'number', unit: '天', values: '', card: 'evolution-merge' },
|
|
199
168
|
{ id: 'mergeRunTimeoutMinutes', group: 'merge', tier: 'E3', authority: 'cordis', owner: 'evolution-merge', applies: 'live', docAnchor: 'PARAMETERS.md#merge', summary: 'Wall-clock budget of one merge run; 0 means no limit.', label: '单次运行上限', hint: '一次合并运行最多持续多少分钟;0 表示不设上限。', control: 'number', unit: '分钟', values: '', card: 'evolution-merge' },
|
|
@@ -233,22 +202,6 @@ export const PARAM_NAMESPACES = Object.freeze({
|
|
|
233
202
|
export const NAMESPACE_MIGRATIONS = Object.freeze(Object.entries(PARAM_NAMESPACES)
|
|
234
203
|
.filter(([owner, namespace]) => namespace !== owner)
|
|
235
204
|
.map(([owner, namespace]) => Object.freeze({ namespace, rowId: owner })));
|
|
236
|
-
/**
|
|
237
|
-
* The LEGACY settings namespace one owner package used to register through the family's
|
|
238
|
-
* own seam (0.1.x). It is no longer what the platform calls the section: the platform
|
|
239
|
-
* derives a settings namespace from the Loader entry id, and this registry's `owner` field
|
|
240
|
-
* IS that row id, so a live lookup uses {@link paramRowId}. What remains here is the
|
|
241
|
-
* migration SOURCE (G3 moves a user layer out of this string and into the row id).
|
|
242
|
-
* @param owner - owner package directory name (the map's key).
|
|
243
|
-
* @returns the legacy namespace that owner registered.
|
|
244
|
-
* @throws when the owner has no entry in {@link PARAM_NAMESPACES}.
|
|
245
|
-
*/
|
|
246
|
-
export function paramNamespace(owner) {
|
|
247
|
-
const namespace = PARAM_NAMESPACES[owner];
|
|
248
|
-
if (namespace === undefined)
|
|
249
|
-
throw new Error('no settings namespace registered for owner `' + owner + '` (add it to PARAM_NAMESPACES)');
|
|
250
|
-
return namespace;
|
|
251
|
-
}
|
|
252
205
|
/**
|
|
253
206
|
* The settings id one row's user layer lives under, or undefined when the owner publishes
|
|
254
207
|
* no user layer at all (a deployment-only row: its knobs are E2 and never reach a settings
|
|
@@ -256,7 +209,7 @@ export function paramNamespace(owner) {
|
|
|
256
209
|
* it in `settings.describe()` / `configForms.get(entryId)`, and an owner package's row id is
|
|
257
210
|
* its own name — spelled the same in every bundle patch.
|
|
258
211
|
*
|
|
259
|
-
* This is the id to LOOK UP with; {@link
|
|
212
|
+
* This is the id to LOOK UP with; {@link PARAM_NAMESPACES} keeps the legacy string the 0.1.x
|
|
260
213
|
* seam registered, which is the G3 migration source and never a live lookup key.
|
|
261
214
|
* @param owner - owner package directory name (the row id).
|
|
262
215
|
* @returns the entry id the platform reports for that row, or undefined for a row without
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* The LLM half of the family's host platform boundary.
|
|
3
3
|
*
|
|
4
4
|
* Features pass a family request (route, messages, purpose); this module owns
|
|
5
|
-
* the platform GenerateOptions cast
|
|
6
|
-
*
|
|
7
|
-
* union and 0.2.2's declaration-merge map.
|
|
5
|
+
* the platform GenerateOptions cast and text assembly. The purpose declaration
|
|
6
|
+
* merge below is the family's contribution to the 0.2.2 request map.
|
|
8
7
|
*/
|
|
9
8
|
import type { StreamChunk, UserMessage } from '@deepseek-ai/dsh-llm';
|
|
10
9
|
import type { Context } from '@deepseek-ai/cordis';
|
|
@@ -29,16 +29,9 @@ export function llmPort(ctx) {
|
|
|
29
29
|
const port = {
|
|
30
30
|
async *stream(request) {
|
|
31
31
|
const options = toOptions(request);
|
|
32
|
-
if (llm.stream
|
|
33
|
-
|
|
34
|
-
|
|
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');
|
|
32
|
+
if (llm.stream === undefined)
|
|
33
|
+
throw new EvolutionLlmError('transport', 'llm service has no stream()');
|
|
34
|
+
yield* llm.stream(options);
|
|
42
35
|
},
|
|
43
36
|
async completeText(request) {
|
|
44
37
|
let text = '';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The session-projection half of the family's host platform boundary.
|
|
3
3
|
*
|
|
4
|
-
* The platform
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* which reads as "the sessions have no projection data" instead of "this build cannot read them".
|
|
4
|
+
* The 0.2.2 platform returns an awaitable `ProjectionHandle` (`stateOf` + `dispose`). The port
|
|
5
|
+
* accepts that one contract and NAMES a non-conforming answer (`unrecognised`) instead of
|
|
6
|
+
* returning undefined for every unit without an error (audit 06-P1).
|
|
8
7
|
*/
|
|
9
8
|
import type { Context } from '@deepseek-ai/cordis';
|
|
10
9
|
import type { ZodType } from 'zod';
|
|
@@ -23,7 +22,7 @@ export interface ProjectionHandleLike<S> {
|
|
|
23
22
|
dispose(): Promise<void>;
|
|
24
23
|
}
|
|
25
24
|
/** Which registration contract the live registry speaks. */
|
|
26
|
-
export type ProjectionPortShape = 'handle' | '
|
|
25
|
+
export type ProjectionPortShape = 'handle' | 'unrecognised';
|
|
27
26
|
export interface ProjectionPort {
|
|
28
27
|
/** The shape this port adapted to; `unrecognised` means reads will be empty and why. */
|
|
29
28
|
readonly shape: ProjectionPortShape;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
const isThenable = (value) =>
|
|
2
|
-
// A callable-thenable is a FUNCTION with \ hen\ (the deprecated shape); a plain Promise is an
|
|
3
|
-
// object. Both must be awaited, or the callable one falls into the legacy branch by accident.
|
|
4
|
-
(typeof value === 'object' || typeof value === 'function') && value !== null && typeof value.then === 'function';
|
|
5
1
|
const isHandle = (value) => value !== null && typeof value === 'object'
|
|
6
2
|
&& typeof value.stateOf === 'function'
|
|
7
3
|
&& typeof value.dispose === 'function';
|
|
@@ -17,9 +13,7 @@ export function projectionPort(ctx) {
|
|
|
17
13
|
get shape() { return shape; },
|
|
18
14
|
get reason() { return shape === 'unrecognised' ? reason : undefined; },
|
|
19
15
|
async register(definition) {
|
|
20
|
-
const
|
|
21
|
-
// A callable-thenable and a plain Promise are the same contract from the caller's side.
|
|
22
|
-
const resolved = isThenable(raw) ? await raw : raw;
|
|
16
|
+
const resolved = await registry.register(definition);
|
|
23
17
|
if (isHandle(resolved)) {
|
|
24
18
|
shape = 'handle';
|
|
25
19
|
reason = undefined;
|
|
@@ -28,19 +22,11 @@ export function projectionPort(ctx) {
|
|
|
28
22
|
dispose: () => resolved.dispose(),
|
|
29
23
|
};
|
|
30
24
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
reason = undefined;
|
|
34
|
-
return {
|
|
35
|
-
stateOf: (session) => registry.stateOf?.(session, definition.key),
|
|
36
|
-
dispose: async () => { raw(); },
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
// Neither contract: keep reads empty, but say so through `shape`/`reason` instead of
|
|
40
|
-
// pretending the units have no data.
|
|
25
|
+
// Keep reads empty, but say so through `shape`/`reason` instead of pretending the
|
|
26
|
+
// units have no data.
|
|
41
27
|
shape = 'unrecognised';
|
|
42
28
|
reason = 'sessionProjections.register returned ' + (resolved === null ? 'null' : typeof resolved)
|
|
43
|
-
+ '
|
|
29
|
+
+ ' without a projection handle';
|
|
44
30
|
return { stateOf: () => undefined, dispose: async () => { } };
|
|
45
31
|
},
|
|
46
32
|
};
|
package/lib/types/probe.d.ts
CHANGED
|
@@ -39,9 +39,6 @@ export declare function isUnknown<T>(probe: Probe<T>): probe is {
|
|
|
39
39
|
kind: 'unknown';
|
|
40
40
|
reason: string;
|
|
41
41
|
};
|
|
42
|
-
/** Only a PRESENT probe yields a value; absent and unknown both fall back. */
|
|
43
|
-
export declare function valueOr<T>(probe: Probe<T>, fallback: T): T;
|
|
44
|
-
export declare function mapProbe<T, U>(probe: Probe<T>, transform: (value: T) => U): Probe<U>;
|
|
45
42
|
/** The reason an `unknown` probe carries (message, never a bare String(object)). */
|
|
46
43
|
export declare function probeReason(error: unknown): string;
|
|
47
44
|
/**
|
package/lib/types/probe.js
CHANGED
|
@@ -16,13 +16,6 @@ export function isAbsent(probe) {
|
|
|
16
16
|
export function isUnknown(probe) {
|
|
17
17
|
return probe.kind === 'unknown';
|
|
18
18
|
}
|
|
19
|
-
/** Only a PRESENT probe yields a value; absent and unknown both fall back. */
|
|
20
|
-
export function valueOr(probe, fallback) {
|
|
21
|
-
return probe.kind === 'present' ? probe.value : fallback;
|
|
22
|
-
}
|
|
23
|
-
export function mapProbe(probe, transform) {
|
|
24
|
-
return probe.kind === 'present' ? probePresent(transform(probe.value)) : probe;
|
|
25
|
-
}
|
|
26
19
|
/** The reason an `unknown` probe carries (message, never a bare String(object)). */
|
|
27
20
|
export function probeReason(error) {
|
|
28
21
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -160,6 +160,13 @@ export function newRunRegistry(options) {
|
|
|
160
160
|
}
|
|
161
161
|
return [...live, ...[...perKind.values()].flat()].sort((a, b) => b.startedAt - a.startedAt);
|
|
162
162
|
};
|
|
163
|
+
/** One serialization for every run-index write (live first, then terminal, then foreign rows). */
|
|
164
|
+
const serializeIndex = (records, foreignRows) => {
|
|
165
|
+
const kept = capped(records);
|
|
166
|
+
const live = kept.filter(row => row.state === 'running');
|
|
167
|
+
const done = kept.filter(row => TERMINAL.has(row.state));
|
|
168
|
+
return JSON.stringify({ schemaVersion: RUNS_SCHEMA_VERSION, runs: [...live, ...done, ...foreignRows] }, null, 2);
|
|
169
|
+
};
|
|
163
170
|
/**
|
|
164
171
|
* Update a surviving foreign row in place (identity stable), or add it.
|
|
165
172
|
*
|
|
@@ -218,12 +225,9 @@ export function newRunRegistry(options) {
|
|
|
218
225
|
if (row.state === 'running' && !owned.has(id) && ownerIsGone(row))
|
|
219
226
|
merged.set(id, orphanOf(row));
|
|
220
227
|
}
|
|
221
|
-
const kept = capped([...merged.values()]);
|
|
222
|
-
const live = kept.filter(row => row.state === 'running');
|
|
223
|
-
const done = kept.filter(row => TERMINAL.has(row.state));
|
|
224
228
|
// Rows this build does not understand ride along untouched (P2-5): it cannot
|
|
225
229
|
// judge them, and dropping them would erase another writer's record.
|
|
226
|
-
return
|
|
230
|
+
return serializeIndex([...merged.values()], onDisk.foreign);
|
|
227
231
|
});
|
|
228
232
|
}
|
|
229
233
|
catch (error) {
|
|
@@ -380,10 +384,7 @@ export function newRunRegistry(options) {
|
|
|
380
384
|
row.supersededAt = now();
|
|
381
385
|
marked += 1;
|
|
382
386
|
}
|
|
383
|
-
|
|
384
|
-
const live = kept.filter(row => row.state === 'running');
|
|
385
|
-
const done = kept.filter(row => TERMINAL.has(row.state));
|
|
386
|
-
return JSON.stringify({ schemaVersion: RUNS_SCHEMA_VERSION, runs: [...live, ...done, ...onDisk.foreign] }, null, 2);
|
|
387
|
+
return serializeIndex([...merged.values()], onDisk.foreign);
|
|
387
388
|
});
|
|
388
389
|
return marked;
|
|
389
390
|
},
|
|
@@ -429,10 +430,7 @@ export function newRunRegistry(options) {
|
|
|
429
430
|
...(outcome.resultRef === undefined ? {} : { resultRef: outcome.resultRef }),
|
|
430
431
|
...(outcome.failure === undefined ? {} : { failure: outcome.failure }),
|
|
431
432
|
};
|
|
432
|
-
|
|
433
|
-
const live = kept.filter(item => item.state === 'running');
|
|
434
|
-
const done = kept.filter(item => TERMINAL.has(item.state));
|
|
435
|
-
return JSON.stringify({ schemaVersion: RUNS_SCHEMA_VERSION, runs: [...live, ...done, ...onDisk.foreign] }, null, 2);
|
|
433
|
+
return serializeIndex(onDisk.records.map(item => item.id === id ? next : item), onDisk.foreign);
|
|
436
434
|
});
|
|
437
435
|
// Rebuild the foreign view so this process answers the upgraded verdict at once.
|
|
438
436
|
if (changed)
|
package/lib/types/runtime/llm.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* model calls. Feature-specific retries and parsing stay in their features.
|
|
4
4
|
*/
|
|
5
5
|
import { Service } from '@deepseek-ai/cordis';
|
|
6
|
-
import { EvolutionLlmError,
|
|
6
|
+
import { EvolutionLlmError, modelRoute } from "../platform/index.js";
|
|
7
7
|
/** Domain service for every auxiliary LLM request in the family. */
|
|
8
8
|
export class EvolutionLlm extends Service {
|
|
9
9
|
static inject = [];
|
|
@@ -13,7 +13,7 @@ export class EvolutionLlm extends Service {
|
|
|
13
13
|
}
|
|
14
14
|
[Service.init]() {
|
|
15
15
|
const platform = this.ctx.get('evolutionPlatform');
|
|
16
|
-
this.port = platform?.ports
|
|
16
|
+
this.port = platform?.ports.llm;
|
|
17
17
|
if (this.port === undefined)
|
|
18
18
|
this.ctx.logger.warn('evolution-core-runtime: llm service unavailable; model calls fail with llm-unavailable');
|
|
19
19
|
}
|
|
@@ -9,12 +9,6 @@ import type { LlmPort } from '../platform/llm.ts';
|
|
|
9
9
|
import type { PresetsPort } from '../platform/presets.ts';
|
|
10
10
|
import type { ProjectionPort } from '../platform/projections.ts';
|
|
11
11
|
import type { ToolsPort } from '../platform/tools.ts';
|
|
12
|
-
/** One capability row for doctor/status consumers. */
|
|
13
|
-
export interface PlatformCapability {
|
|
14
|
-
readonly name: 'projections' | 'llm' | 'tools' | 'presets';
|
|
15
|
-
readonly available: boolean;
|
|
16
|
-
readonly reason?: string;
|
|
17
|
-
}
|
|
18
12
|
/** Resolved host ports and their availability. */
|
|
19
13
|
export interface HostPlatformPorts {
|
|
20
14
|
readonly projections: ProjectionPort | undefined;
|
|
@@ -25,11 +19,13 @@ export interface HostPlatformPorts {
|
|
|
25
19
|
/** Domain service owning the host port table. */
|
|
26
20
|
export declare class EvolutionPlatform extends Service {
|
|
27
21
|
static inject: never[];
|
|
28
|
-
|
|
22
|
+
private resolved;
|
|
29
23
|
constructor(ctx: Context);
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Resolve the host ports on first use and keep that answer for the service
|
|
26
|
+
* lifetime. Consumers read this one table; they never fall back to a direct
|
|
27
|
+
* platform import (the second resolution D7 removed).
|
|
28
|
+
*/
|
|
29
|
+
get ports(): HostPlatformPorts;
|
|
34
30
|
}
|
|
35
31
|
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -11,28 +11,22 @@ import { llmPort } from "../platform/llm.js";
|
|
|
11
11
|
/** Domain service owning the host port table. */
|
|
12
12
|
export class EvolutionPlatform extends Service {
|
|
13
13
|
static inject = [];
|
|
14
|
-
|
|
14
|
+
resolved;
|
|
15
15
|
constructor(ctx) {
|
|
16
16
|
super(ctx, 'evolutionPlatform');
|
|
17
|
-
this.ports = {
|
|
18
|
-
projections: projectionPort(ctx),
|
|
19
|
-
llm: llmPort(ctx),
|
|
20
|
-
tools: toolsPort(ctx),
|
|
21
|
-
presets: presetsPort(ctx),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/** True when the two services the runtime cannot work without are present. */
|
|
25
|
-
ready() {
|
|
26
|
-
return this.ports.projections !== undefined && this.ports.llm !== undefined;
|
|
27
17
|
}
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the host ports on first use and keep that answer for the service
|
|
20
|
+
* lifetime. Consumers read this one table; they never fall back to a direct
|
|
21
|
+
* platform import (the second resolution D7 removed).
|
|
22
|
+
*/
|
|
23
|
+
get ports() {
|
|
24
|
+
return this.resolved ??= {
|
|
25
|
+
projections: projectionPort(this.ctx),
|
|
26
|
+
llm: llmPort(this.ctx),
|
|
27
|
+
tools: toolsPort(this.ctx),
|
|
28
|
+
presets: presetsPort(this.ctx),
|
|
29
|
+
};
|
|
36
30
|
}
|
|
37
31
|
}
|
|
38
32
|
//# sourceMappingURL=platform.js.map
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
import type { Context } from '@deepseek-ai/cordis';
|
|
7
7
|
export declare const name = "evolution-core-runtime";
|
|
8
8
|
/** @param ctx - the composition context that owns the runtime services. */
|
|
9
|
-
export declare function apply(ctx: Context): void
|
|
9
|
+
export declare function apply(ctx: Context): Promise<void>;
|
|
10
10
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -3,9 +3,11 @@ import { EvolutionPlatform } from "./platform.js";
|
|
|
3
3
|
import { EvolutionProjections } from "./projections.js";
|
|
4
4
|
export const name = 'evolution-core-runtime';
|
|
5
5
|
/** @param ctx - the composition context that owns the runtime services. */
|
|
6
|
-
export function apply(ctx) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
ctx.plugin(
|
|
6
|
+
export async function apply(ctx) {
|
|
7
|
+
// Ports resolve from the platform service now, so the platform must be mounted
|
|
8
|
+
// before the consumers initialize; sequential plugin mounts make that order real.
|
|
9
|
+
await ctx.plugin(EvolutionPlatform);
|
|
10
|
+
await ctx.plugin(EvolutionProjections);
|
|
11
|
+
await ctx.plugin(EvolutionLlm);
|
|
10
12
|
}
|
|
11
13
|
//# sourceMappingURL=plugin.js.map
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* into the host.
|
|
6
6
|
*/
|
|
7
7
|
import { Service } from '@deepseek-ai/cordis';
|
|
8
|
-
import { projectionPort } from "../platform/index.js";
|
|
9
8
|
import { evolutionActivityProjection, evolutionEvidenceProjection, evolutionProjectionHistoryProjection, evolutionReadsProjection, evolutionSignalsProjection, } from "../session-projection.js";
|
|
10
9
|
/** Domain service owning the family's projection registrations. */
|
|
11
10
|
export class EvolutionProjections extends Service {
|
|
@@ -17,7 +16,7 @@ export class EvolutionProjections extends Service {
|
|
|
17
16
|
}
|
|
18
17
|
async [Service.init]() {
|
|
19
18
|
const platform = this.ctx.get('evolutionPlatform');
|
|
20
|
-
const port = platform?.ports
|
|
19
|
+
const port = platform?.ports.projections;
|
|
21
20
|
if (port === undefined) {
|
|
22
21
|
this.markDegraded('sessionProjections service unavailable');
|
|
23
22
|
return;
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
export type SessionEventClass = 'model' | 'plugin-record' | 'unknown';
|
|
2
|
-
/** Frames the model authored/saw (the only frames evidence, reads and usage accounting may consume). */
|
|
3
|
-
import { MODEL_SESSION_EVENT_TYPES } from './tool-dispatch.ts';
|
|
4
|
-
export { MODEL_SESSION_EVENT_TYPES as MODEL_SESSION_EVENTS };
|
|
5
2
|
/** Classify one session event WITHOUT interpreting it (pure). */
|
|
6
3
|
export declare function classifySessionEvent(event: {
|
|
7
4
|
readonly type?: unknown;
|
|
8
5
|
readonly ignorable?: unknown;
|
|
9
6
|
}): SessionEventClass;
|
|
10
|
-
/** True when the event must be skipped by evidence/usage readers (tolerant, never fatal). */
|
|
11
|
-
export declare function isIgnorableEvent(event: {
|
|
12
|
-
readonly type?: unknown;
|
|
13
|
-
readonly ignorable?: unknown;
|
|
14
|
-
}): boolean;
|
|
15
7
|
//# sourceMappingURL=session-fold.d.ts.map
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
// helper would make the contract depend on the bed rather than on the rule.
|
|
12
12
|
/** Frames the model authored/saw (the only frames evidence, reads and usage accounting may consume). */
|
|
13
13
|
import { MODEL_SESSION_EVENT_TYPES } from "./tool-dispatch.js";
|
|
14
|
-
export { MODEL_SESSION_EVENT_TYPES as MODEL_SESSION_EVENTS };
|
|
15
14
|
const MODEL_EVENT_TYPES = new Set(MODEL_SESSION_EVENT_TYPES);
|
|
16
15
|
/** Classify one session event WITHOUT interpreting it (pure). */
|
|
17
16
|
export function classifySessionEvent(event) {
|
|
@@ -21,8 +20,4 @@ export function classifySessionEvent(event) {
|
|
|
21
20
|
}
|
|
22
21
|
return MODEL_EVENT_TYPES.has(type) ? 'model' : 'unknown';
|
|
23
22
|
}
|
|
24
|
-
/** True when the event must be skipped by evidence/usage readers (tolerant, never fatal). */
|
|
25
|
-
export function isIgnorableEvent(event) {
|
|
26
|
-
return classifySessionEvent(event) !== 'model';
|
|
27
|
-
}
|
|
28
23
|
//# sourceMappingURL=session-fold.js.map
|
|
@@ -103,7 +103,7 @@ const readsStateSchema = z.object({
|
|
|
103
103
|
failed: z.boolean(),
|
|
104
104
|
file: z.string().nullable().optional(),
|
|
105
105
|
tool: z.string().optional(),
|
|
106
|
-
}).strict()),
|
|
106
|
+
}).strict()).max(512),
|
|
107
107
|
}).strict();
|
|
108
108
|
const signalsStateSchema = z.object({
|
|
109
109
|
through: z.number().int().min(-1).max(Number.MAX_SAFE_INTEGER),
|
|
@@ -202,7 +202,7 @@ export const evolutionReadsProjection = {
|
|
|
202
202
|
arguments: step.arguments,
|
|
203
203
|
ok: step.outcome?.ok,
|
|
204
204
|
}) ?? null;
|
|
205
|
-
return { reads: [...state.reads, { key: step.key, skill, failed: step.outcome?.ok === false }] };
|
|
205
|
+
return { reads: [...state.reads.slice(-511), { key: step.key, skill, failed: step.outcome?.ok === false }] };
|
|
206
206
|
},
|
|
207
207
|
};
|
|
208
208
|
/** The `evolutionSignals` unit (host-only: no client view is registered for it). */
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** 技能名文法(与平台 `isSkillName` 等价:kebab-case,点前缀与下划线一律不是技能名)。 */
|
|
2
|
-
export declare const SKILL_NAME_RE: RegExp;
|
|
3
1
|
/** 名字是否是技能名 —— `._x`、`Bad_Name`、`.archive` 都返回 false。 */
|
|
4
2
|
export declare function isSkillName(name: string): boolean;
|
|
5
3
|
/** 相对技能根的路径是否落在平台会发现的位置(depth<=2 且最后一段是 SKILL.md 或 `<name>.md`)。 */
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
11
11
|
import { join } from 'node:path';
|
|
12
|
-
|
|
13
|
-
export const SKILL_NAME_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
12
|
+
import { SKILL_NAME_RE } from "./constants.js";
|
|
14
13
|
/** 名字是否是技能名 —— `._x`、`Bad_Name`、`.archive` 都返回 false。 */
|
|
15
14
|
export function isSkillName(name) {
|
|
16
15
|
return SKILL_NAME_RE.test(name);
|
|
@@ -72,7 +72,7 @@ interface SkillHealthSnapshot {
|
|
|
72
72
|
/** Mechanical hard-cap-hit count, when the caller has it; null = unknown. */
|
|
73
73
|
hardCapHits?: number | null | undefined;
|
|
74
74
|
}
|
|
75
|
-
interface SkillHealthDim {
|
|
75
|
+
export interface SkillHealthDim {
|
|
76
76
|
bodyChars: number;
|
|
77
77
|
/** The same body on the token scale (limit basis) — the judged quantity. */
|
|
78
78
|
bodyTokens: number;
|
|
@@ -93,6 +93,34 @@ export interface SkillHealthAssessment {
|
|
|
93
93
|
/** The same judgement as `reasons`, in diffable form: (rule id, severity, count). G1. */
|
|
94
94
|
findings: LintFinding[];
|
|
95
95
|
}
|
|
96
|
+
/** One finding as the health route/panel sees it (wire shape, not the engine's LintFinding). */
|
|
97
|
+
export interface SkillHealthWireFinding {
|
|
98
|
+
rule: string;
|
|
99
|
+
count: number;
|
|
100
|
+
line: string | null;
|
|
101
|
+
countIsMeaningful: boolean;
|
|
102
|
+
severity?: 'warn' | 'error';
|
|
103
|
+
message?: string;
|
|
104
|
+
}
|
|
105
|
+
/** Measured dimensions on the health wire; absent when the scan could not read them. */
|
|
106
|
+
export interface SkillHealthWireDims {
|
|
107
|
+
bodyChars: number | null;
|
|
108
|
+
bodyTokens: number | null;
|
|
109
|
+
supportGroups: number;
|
|
110
|
+
supportFiles: number | null;
|
|
111
|
+
churnPatches: number | null;
|
|
112
|
+
churnReads: number | null;
|
|
113
|
+
stampDensityPerKb: number | null;
|
|
114
|
+
}
|
|
115
|
+
/** One health row on the wire; `readable: false` is its own verdict, never healthy. */
|
|
116
|
+
export interface SkillHealthWireRow {
|
|
117
|
+
name: string;
|
|
118
|
+
verdict: 'healthy' | 'warn' | 'error' | 'unreadable' | 'needs-restructure';
|
|
119
|
+
findings: SkillHealthWireFinding[];
|
|
120
|
+
dims?: SkillHealthWireDims | null;
|
|
121
|
+
protection?: string | null;
|
|
122
|
+
hardCapHits?: number | null;
|
|
123
|
+
}
|
|
96
124
|
/**
|
|
97
125
|
* The findings for ONE body, computed by the engine that owns the judgement (G4).
|
|
98
126
|
*
|
|
@@ -347,30 +347,6 @@ export declare const TEXT_DIFF_MAX_CHARS = 4000;
|
|
|
347
347
|
* @returns the counts, the windowed hunk, and whether the window cut anything.
|
|
348
348
|
*/
|
|
349
349
|
export declare function textDiffFacts(before: string, after: string, path: string, maxLines?: number): TextDiffFacts;
|
|
350
|
-
/** Characters one generated summary may carry. */
|
|
351
|
-
export declare const VERSION_SUMMARY_MAX_CHARS = 80;
|
|
352
|
-
/**
|
|
353
|
-
* The fixed prompt the optional per-write summarizer runs (registry `skillVersionSummary`).
|
|
354
|
-
*
|
|
355
|
-
* Model-visible, so it is written from the model’s perspective and pinned: the tests assert that it
|
|
356
|
-
* carries the skill name, the character cap and both bodies, because a silent change to a prompt is a
|
|
357
|
-
* silent change to what every recorded version says.
|
|
358
|
-
* @param input - the skill, the action, and the two bodies (null when absent).
|
|
359
|
-
* @returns the prompt text.
|
|
360
|
-
*/
|
|
361
|
-
export declare function versionSummaryPrompt(input: {
|
|
362
|
-
name: string;
|
|
363
|
-
action: string;
|
|
364
|
-
before: string | null;
|
|
365
|
-
after: string | null;
|
|
366
|
-
}): string;
|
|
367
|
-
/**
|
|
368
|
-
* Reduce a model answer to the one line the index stores.
|
|
369
|
-
* @param raw - the model’s answer, whatever shape it came in.
|
|
370
|
-
* @param maxChars - the character cap.
|
|
371
|
-
* @returns the one line, or undefined when there is nothing usable (callers store no summary).
|
|
372
|
-
*/
|
|
373
|
-
export declare function normalizeVersionSummary(raw: string, maxChars?: number): string | undefined;
|
|
374
350
|
/** A relative age, in the shape the platform’s own `relativeTime(at, now)` returns. */
|
|
375
351
|
export interface RelativeAge {
|
|
376
352
|
readonly unit: 'now' | 'minutes' | 'hours' | 'days' | 'months' | 'years';
|