@lmzhen/dsh-evolution-core 0.37.1 → 0.39.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/README.md +4 -2
- package/lib/composition/index.js +2 -2
- package/lib/{composition-DckDtQTR.js → composition-dy0gJWDd.js} +1 -1
- package/lib/{ensure-CLF9YeBD.js → ensure-B4fjEI0w.js} +3 -10
- package/lib/index.js +67 -1302
- package/lib/platform/index.js +4 -0
- package/lib/platform-Be-_wSVz.js +113 -0
- package/lib/presets-C8vuCuNA.js +27 -0
- package/lib/restrictor.js +7 -7
- package/lib/runtime/plugin.js +197 -0
- package/lib/session-projection-CXUNPkq9.js +1250 -0
- package/lib/subagent/index.js +1 -1
- package/lib/tools-DzcNFex2.js +20 -0
- package/lib/types/composition/ensure.js +3 -13
- package/lib/types/events.d.ts +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/opt-in.d.ts +1 -1
- package/lib/types/opt-in.js +1 -1
- package/lib/types/params.js +2 -2
- package/lib/types/platform/index.d.ts +21 -0
- package/lib/types/platform/index.js +12 -0
- package/lib/types/platform/llm.d.ts +46 -0
- package/lib/types/platform/llm.js +75 -0
- package/lib/types/platform/presets.d.ts +31 -0
- package/lib/types/platform/presets.js +31 -0
- package/lib/types/platform/projections.d.ts +30 -0
- package/lib/types/platform/projections.js +31 -0
- package/lib/types/platform/tools.d.ts +23 -0
- package/lib/types/platform/tools.js +21 -0
- package/lib/types/platform-line.generated.d.ts +6 -6
- package/lib/types/platform-line.generated.js +6 -6
- package/lib/types/platform-services.d.ts +1 -1
- package/lib/types/platform-services.js +4 -1
- package/lib/types/restrictor.js +7 -9
- package/lib/types/review-context.d.ts +20 -0
- package/lib/types/review-context.js +28 -0
- package/lib/types/runtime/llm.d.ts +34 -0
- package/lib/types/runtime/llm.js +71 -0
- package/lib/types/runtime/platform.d.ts +35 -0
- package/lib/types/runtime/platform.js +38 -0
- package/lib/types/runtime/plugin.d.ts +10 -0
- package/lib/types/runtime/plugin.js +11 -0
- package/lib/types/runtime/projections.d.ts +29 -0
- package/lib/types/runtime/projections.js +62 -0
- package/lib/types/scope.d.ts +1 -1
- package/lib/types/session-projection.d.ts +26 -53
- package/lib/types/session-projection.js +22 -58
- package/lib/types/skill-reads.js +3 -3
- package/lib/types/skill-store.js +3 -0
- package/lib/types/subagent/types.d.ts +1 -1
- package/lib/types/tool-dispatch.d.ts +2 -2
- package/lib/types/tool-dispatch.js +3 -3
- package/package.json +30 -16
package/lib/subagent/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as restrictedPresetId, n as ensureRestrictedPreset, r as restrictedPresetState } from "../ensure-
|
|
1
|
+
import { h as restrictedPresetId, n as ensureRestrictedPreset, r as restrictedPresetState } from "../ensure-B4fjEI0w.js";
|
|
2
2
|
//#region lib/types/subagent/readiness.js
|
|
3
3
|
function serviceOf$1(ctx, name) {
|
|
4
4
|
return ctx.get(name);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region lib/types/platform/tools.js
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the tools port from a context; undefined means the host has no tools service.
|
|
4
|
+
* platform-declaration anchor: tools is declared in core PLATFORM_SERVICE_PROBES.
|
|
5
|
+
*/
|
|
6
|
+
function toolsPort(ctx) {
|
|
7
|
+
const tools = ctx.get("tools");
|
|
8
|
+
if (tools === void 0) return void 0;
|
|
9
|
+
return {
|
|
10
|
+
register: (definition) => tools.register(definition),
|
|
11
|
+
guard: (guard) => tools.guard(guard),
|
|
12
|
+
restrict: (filter) => tools.restrict(filter)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** Register one family tool through the port; a missing service yields a no-op disposer. */
|
|
16
|
+
function registerEvolutionTool(ctx, definition) {
|
|
17
|
+
return toolsPort(ctx)?.register(definition) ?? (() => {});
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { toolsPort as n, registerEvolutionTool as t };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { presetsPort } from "../platform/presets.js";
|
|
1
2
|
import { normalizeAllow } from "./preset-ids.js";
|
|
2
3
|
import { composeRestrictedPresetDefinition, } from "./restricted-preset.js";
|
|
3
4
|
const SLOTS = new WeakMap();
|
|
@@ -14,22 +15,11 @@ function slotFor(ctx, kind) {
|
|
|
14
15
|
}
|
|
15
16
|
return slot;
|
|
16
17
|
}
|
|
17
|
-
function registryOf(ctx) {
|
|
18
|
-
const candidate = ctx.get('agentPresets');
|
|
19
|
-
if (candidate === undefined)
|
|
20
|
-
return undefined;
|
|
21
|
-
if (typeof candidate.readDocument !== 'function' || typeof candidate.register !== 'function')
|
|
22
|
-
return undefined;
|
|
23
|
-
return candidate;
|
|
24
|
-
}
|
|
25
18
|
function installReleaseEffect(ctx, slot) {
|
|
26
19
|
if (slot.effectInstalled === true)
|
|
27
20
|
return;
|
|
28
|
-
const effect = ctx.effect;
|
|
29
|
-
if (effect === undefined)
|
|
30
|
-
return;
|
|
31
21
|
slot.effectInstalled = true;
|
|
32
|
-
effect
|
|
22
|
+
ctx.effect(() => () => { void releaseRestrictedPreset(ctx, undefined, slot); }, 'evolution-restricted-preset');
|
|
33
23
|
}
|
|
34
24
|
async function releaseRestrictedPreset(ctx, kind, explicitSlot) {
|
|
35
25
|
const slot = explicitSlot ?? (kind === undefined ? undefined : slotFor(ctx, kind));
|
|
@@ -56,7 +46,7 @@ export async function ensureRestrictedPreset(ctx, req) {
|
|
|
56
46
|
slot.state = { kind: 'failed', code: 'E-324', reason: 'allow set is empty' };
|
|
57
47
|
return slot.state;
|
|
58
48
|
}
|
|
59
|
-
const registry =
|
|
49
|
+
const registry = presetsPort(ctx);
|
|
60
50
|
if (registry === undefined) {
|
|
61
51
|
slot.state = { kind: 'failed', code: 'E-324', reason: 'agentPresets service unavailable or incomplete' };
|
|
62
52
|
return slot.state;
|
package/lib/types/events.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface EvolutionReviewScheduledEvent {
|
|
|
31
31
|
* `'subagent'` (spawned review run), `'inject'` (prompt injected into the
|
|
32
32
|
* parent — direct, fallback, or deferred-drain), `'completion'`
|
|
33
33
|
* (completion-trigger prompt, direct or deferred-drain). */
|
|
34
|
-
channel?: 'subagent' | 'inject' | 'completion' | '
|
|
34
|
+
channel?: 'subagent' | 'inject' | 'completion' | 'aux' | undefined;
|
|
35
35
|
}
|
|
36
36
|
/** One normalized skill/memory action performed by a review branch. */
|
|
37
37
|
export interface EvolutionReviewAction {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ export * from './prompts.ts';
|
|
|
70
70
|
export * from './quality.ts';
|
|
71
71
|
export * from './redact.ts';
|
|
72
72
|
export * from './review-channel.ts';
|
|
73
|
+
export * from './review-context.ts';
|
|
73
74
|
export * from './run-registry.ts';
|
|
74
75
|
export * from './tree-lock.ts';
|
|
75
76
|
export * from './unit-undo-plan.ts';
|
package/lib/types/index.js
CHANGED
|
@@ -71,6 +71,7 @@ export * from "./prompts.js";
|
|
|
71
71
|
export * from "./quality.js";
|
|
72
72
|
export * from "./redact.js";
|
|
73
73
|
export * from "./review-channel.js";
|
|
74
|
+
export * from "./review-context.js";
|
|
74
75
|
export * from "./run-registry.js";
|
|
75
76
|
export * from "./tree-lock.js";
|
|
76
77
|
export * from "./unit-undo-plan.js";
|
package/lib/types/opt-in.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export declare function scopedProbeReport(): ScopedProbeReport;
|
|
|
69
69
|
* Does this session's scope see the family's model tools?
|
|
70
70
|
*
|
|
71
71
|
* The scope is the live agent's — the platform's own addressing for "what does
|
|
72
|
-
* this session see" (`tools.get(name, scope)`, packages/core/tools/src/index.ts:
|
|
72
|
+
* this session see" (`tools.get(name, scope)`, packages/core/tools/src/index.ts:239).
|
|
73
73
|
* A session with no live agent (a finished or cold session) has no scope to ask
|
|
74
74
|
* in, so it resolves to false; the consumers this gate serves only run for live
|
|
75
75
|
* agents.
|
package/lib/types/opt-in.js
CHANGED
|
@@ -37,7 +37,7 @@ export function scopedProbeReport() {
|
|
|
37
37
|
* Does this session's scope see the family's model tools?
|
|
38
38
|
*
|
|
39
39
|
* The scope is the live agent's — the platform's own addressing for "what does
|
|
40
|
-
* this session see" (`tools.get(name, scope)`, packages/core/tools/src/index.ts:
|
|
40
|
+
* this session see" (`tools.get(name, scope)`, packages/core/tools/src/index.ts:239).
|
|
41
41
|
* A session with no live agent (a finished or cold session) has no scope to ask
|
|
42
42
|
* in, so it resolves to false; the consumers this gate serves only run for live
|
|
43
43
|
* agents.
|
package/lib/types/params.js
CHANGED
|
@@ -105,9 +105,9 @@ export const PARAM_EXPOSURE = Object.freeze([
|
|
|
105
105
|
{ id: 'skillReviewTrigger', group: 'review', tier: 'E3', authority: 'cordis', owner: 'evolution-review', applies: 'live', docAnchor: 'PARAMETERS.md#review', summary: 'Which channel may inject a skill review (cadence, completion, both).', label: '技能检查时机', hint: '什么时候检查技能:按间隔/按任务完成/两者。', control: 'select', unit: '', values: 'cadence|completion|both', valueLabels: '按间隔|按任务完成|两者', card: 'evolution-review' },
|
|
106
106
|
{ id: 'skillReviewCompletionMinToolCalls', group: 'review', tier: 'E3', authority: 'cordis', owner: 'evolution-review', applies: 'live', docAnchor: 'PARAMETERS.md#review', summary: 'Tool calls a task needs before the completion channel injects.', label: '完成时的最少工具调用', hint: '选「按任务完成」时,任务至少用了几次工具才检查。', control: 'number', unit: '次', values: '', card: 'evolution-review' },
|
|
107
107
|
{ id: 'reviewEnabled', group: 'review', tier: 'E3', authority: 'cordis', owner: 'evolution-review', applies: 'live', docAnchor: 'PARAMETERS.md#review', summary: 'Master switch for the review plugin.', label: '启用自动检查', hint: '关闭后不再自动回顾会话。', control: 'switch', unit: '', values: '', card: 'evolution-review' },
|
|
108
|
-
{ id: 'reviewMode', group: 'review', tier: 'E3', authority: 'cordis', owner: 'evolution-review', applies: 'live', docAnchor: 'PARAMETERS.md#review', summary: 'Run the review in the
|
|
108
|
+
{ id: 'reviewMode', group: 'review', tier: 'E3', authority: 'cordis', owner: 'evolution-review', applies: 'live', docAnchor: 'PARAMETERS.md#review', summary: 'Run the review in the plugin-owned auxiliary loop (aux), or as a parent-session turn (inject; debugging only).', label: '运行位置', hint: '默认在插件内辅助审查;inject 仅用于调试,会把审查写入当前会话。', control: 'select', unit: '', values: 'aux|inject', valueLabels: '插件内辅助|当前会话(调试)', card: 'evolution-review' },
|
|
109
109
|
{ id: 'reviewWakeInject', group: 'review', tier: 'E3', authority: 'cordis', owner: 'evolution-review', applies: 'live', docAnchor: 'PARAMETERS.md#review', summary: 'Deliver the deferred review as a waking follow-up message.', label: '延后结果发提醒', hint: '会话空闲时,把延后的检查结果作为一条提醒发给你。', control: 'switch', unit: '', values: '', card: 'evolution-review' },
|
|
110
|
-
{ id: 'reviewNotice', group: 'review', tier: 'E3', authority: 'cordis', owner: 'evolution-review', applies: 'live', docAnchor: 'PARAMETERS.md#review', summary: 'Deliver result notices into the parent conversation.', label: '结果通知', hint: '
|
|
110
|
+
{ id: 'reviewNotice', group: 'review', tier: 'E3', authority: 'cordis', owner: 'evolution-review', applies: 'live', docAnchor: 'PARAMETERS.md#review', summary: 'Deliver result notices into the parent conversation for inject mode; aux results are audit-only.', label: '结果通知', hint: 'inject 调试模式下才把结果写进对话;aux 结果只进审计记录,始终不写对话。', control: 'switch', unit: '', values: '', card: 'evolution-review' },
|
|
111
111
|
{ id: 'reviewProvider', group: 'review', tier: 'E2', authority: 'cordis', owner: 'evolution-review', applies: 'none', docAnchor: 'PARAMETERS.md#review', summary: 'LLM provider for review subagents (deployment identity).', why: 'identity' },
|
|
112
112
|
{ id: 'reviewTimeoutMs', group: 'review', tier: 'E2', authority: 'cordis', owner: 'evolution-review', applies: 'none', docAnchor: 'PARAMETERS.md#review', summary: 'Bound on one review subagent run and its write leg.', why: 'internal' },
|
|
113
113
|
{ id: 'reviewContextMessages', group: 'review', tier: 'E2', authority: 'cordis', owner: 'evolution-review', applies: 'none', docAnchor: 'PARAMETERS.md#review', summary: 'Messages of context handed to a review subagent.', why: 'internal' },
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host platform boundary for the evolution family (G1a).
|
|
3
|
+
*
|
|
4
|
+
* Feature packages import platform tool values/types from this subpath only;
|
|
5
|
+
* the platform-boundary gate keeps @deepseek-ai/dsh-* imports inside core/platform.
|
|
6
|
+
*/
|
|
7
|
+
export { defineTool } from '@deepseek-ai/dsh-tools';
|
|
8
|
+
export type { ObjectJsonSchema, ToolDefinition, ToolGuard, ToolRestriction, } from '@deepseek-ai/dsh-tools';
|
|
9
|
+
export type { CommandInvocation, CommandResult } from '@deepseek-ai/dsh-commands';
|
|
10
|
+
export type { StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
11
|
+
export type { Session, SessionEvent } from '@deepseek-ai/dsh-session';
|
|
12
|
+
export type { PromptContext, PromptSection } from '@deepseek-ai/dsh-system-prompt';
|
|
13
|
+
export { presetsPort } from './presets.ts';
|
|
14
|
+
export type { PresetDefinitionLike, PresetDocument, PresetsPort } from './presets.ts';
|
|
15
|
+
export { projectionPort } from './projections.ts';
|
|
16
|
+
export type { EvolutionProjectionDefinition, ProjectionHandleLike, ProjectionPort } from './projections.ts';
|
|
17
|
+
export { EvolutionLlmError, llmPort, modelRoute } from './llm.ts';
|
|
18
|
+
export type { EvolutionLlmFailureKind, EvolutionLlmPurpose, EvolutionLlmRequest, LlmPort, ModelRoute } from './llm.ts';
|
|
19
|
+
export { registerEvolutionTool, toolsPort } from './tools.ts';
|
|
20
|
+
export type { ToolsPort } from './tools.ts';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host platform boundary for the evolution family (G1a).
|
|
3
|
+
*
|
|
4
|
+
* Feature packages import platform tool values/types from this subpath only;
|
|
5
|
+
* the platform-boundary gate keeps @deepseek-ai/dsh-* imports inside core/platform.
|
|
6
|
+
*/
|
|
7
|
+
export { defineTool } from '@deepseek-ai/dsh-tools';
|
|
8
|
+
export { presetsPort } from "./presets.js";
|
|
9
|
+
export { projectionPort } from "./projections.js";
|
|
10
|
+
export { EvolutionLlmError, llmPort, modelRoute } from "./llm.js";
|
|
11
|
+
export { registerEvolutionTool, toolsPort } from "./tools.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The LLM half of the family's host platform boundary.
|
|
3
|
+
*
|
|
4
|
+
* Features pass a family request (route, messages, purpose); this module owns
|
|
5
|
+
* the platform GenerateOptions cast, prepareCall fallback, and text assembly.
|
|
6
|
+
* The purpose cast is the only compatibility point between the 0.2.1 fixed
|
|
7
|
+
* union and 0.2.2's declaration-merge map.
|
|
8
|
+
*/
|
|
9
|
+
import type { StreamChunk, UserMessage } from '@deepseek-ai/dsh-llm';
|
|
10
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
11
|
+
export type EvolutionLlmFailureKind = 'model-unavailable' | 'no-route' | 'timeout' | 'cancelled' | 'transport';
|
|
12
|
+
/** Typed auxiliary-LLM failure; callers may map these without parsing messages. */
|
|
13
|
+
export declare class EvolutionLlmError extends Error {
|
|
14
|
+
readonly kind: EvolutionLlmFailureKind;
|
|
15
|
+
constructor(kind: EvolutionLlmFailureKind, message: string, cause?: unknown);
|
|
16
|
+
}
|
|
17
|
+
export type EvolutionLlmPurpose = 'evolution-curator' | 'evolution-merge-engine' | 'evolution-skill-discovery';
|
|
18
|
+
declare module '@deepseek-ai/dsh-llm/types' {
|
|
19
|
+
interface LlmRequestPurposeMap {
|
|
20
|
+
'evolution-curator': true;
|
|
21
|
+
'evolution-merge-engine': true;
|
|
22
|
+
'evolution-skill-discovery': true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export interface ModelRoute {
|
|
26
|
+
readonly provider: string;
|
|
27
|
+
readonly model: string;
|
|
28
|
+
}
|
|
29
|
+
export interface EvolutionLlmRequest {
|
|
30
|
+
readonly provider: string;
|
|
31
|
+
readonly model: string;
|
|
32
|
+
readonly purpose: EvolutionLlmPurpose;
|
|
33
|
+
readonly messages: readonly UserMessage[];
|
|
34
|
+
readonly maxTokens?: number;
|
|
35
|
+
readonly temperature?: number;
|
|
36
|
+
readonly signal?: AbortSignal;
|
|
37
|
+
}
|
|
38
|
+
export interface LlmPort {
|
|
39
|
+
stream(request: EvolutionLlmRequest): AsyncIterable<StreamChunk>;
|
|
40
|
+
completeText(request: EvolutionLlmRequest): Promise<string>;
|
|
41
|
+
}
|
|
42
|
+
/** Resolve the LLM port; undefined means the host has no llm service. */
|
|
43
|
+
export declare function llmPort(ctx: Context): LlmPort | undefined;
|
|
44
|
+
/** Resolve the model route: agent-owned selection first, deployment default second. */
|
|
45
|
+
export declare function modelRoute(ctx: Context, agent?: unknown, session?: unknown): ModelRoute | undefined;
|
|
46
|
+
//# sourceMappingURL=llm.d.ts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** Typed auxiliary-LLM failure; callers may map these without parsing messages. */
|
|
2
|
+
export class EvolutionLlmError extends Error {
|
|
3
|
+
kind;
|
|
4
|
+
constructor(kind, message, cause) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = 'EvolutionLlmError';
|
|
7
|
+
this.kind = kind;
|
|
8
|
+
if (cause !== undefined)
|
|
9
|
+
this.cause = cause;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function toOptions(request) {
|
|
13
|
+
return {
|
|
14
|
+
provider: request.provider,
|
|
15
|
+
model: request.model,
|
|
16
|
+
messages: request.messages,
|
|
17
|
+
...(request.maxTokens === undefined ? {} : { maxTokens: request.maxTokens }),
|
|
18
|
+
...(request.temperature === undefined ? {} : { temperature: request.temperature }),
|
|
19
|
+
...(request.signal === undefined ? {} : { signal: request.signal }),
|
|
20
|
+
purpose: request.purpose,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** Resolve the LLM port; undefined means the host has no llm service. */
|
|
24
|
+
export function llmPort(ctx) {
|
|
25
|
+
// platform-declaration anchor: llm is declared in core PLATFORM_SERVICE_PROBES.
|
|
26
|
+
const llm = ctx.get('llm');
|
|
27
|
+
if (llm === undefined)
|
|
28
|
+
return undefined;
|
|
29
|
+
const port = {
|
|
30
|
+
async *stream(request) {
|
|
31
|
+
const options = toOptions(request);
|
|
32
|
+
if (llm.stream !== undefined) {
|
|
33
|
+
yield* llm.stream(options);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (llm.prepareCall !== undefined) {
|
|
37
|
+
const call = await llm.prepareCall(options, request.signal);
|
|
38
|
+
yield* call.stream({ ...call.config, messages: request.messages, ...(request.signal === undefined ? {} : { signal: request.signal }) });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
throw new EvolutionLlmError('transport', 'llm service has neither stream nor prepareCall');
|
|
42
|
+
},
|
|
43
|
+
async completeText(request) {
|
|
44
|
+
let text = '';
|
|
45
|
+
for await (const chunk of port.stream(request)) {
|
|
46
|
+
const frame = chunk;
|
|
47
|
+
if (frame.type === 'text-delta' || frame.type === 'text')
|
|
48
|
+
text += typeof frame.text === 'string' ? frame.text : '';
|
|
49
|
+
if (frame.type === 'finish' && frame.reason?.kind === 'error') {
|
|
50
|
+
const message = frame.reason.failure?.message;
|
|
51
|
+
throw new EvolutionLlmError('transport', 'model call failed: ' + (typeof message === 'string' ? message : 'unknown'));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return text;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
return port;
|
|
58
|
+
}
|
|
59
|
+
/** Resolve the model route: agent-owned selection first, deployment default second. */
|
|
60
|
+
export function modelRoute(ctx, agent, session) {
|
|
61
|
+
const owned = agent?.model?.current?.();
|
|
62
|
+
if (owned !== undefined)
|
|
63
|
+
return { provider: owned.provider, model: owned.model };
|
|
64
|
+
// 0.2.2 modelSelection is client-visible: snapshot() returns lastUsed/next.
|
|
65
|
+
if (session !== undefined) {
|
|
66
|
+
const registry = ctx.get('sessionProjections');
|
|
67
|
+
const value = registry?.snapshot?.(session, ['modelSelection'])?.values?.modelSelection;
|
|
68
|
+
const chosen = value?.next ?? value?.lastUsed;
|
|
69
|
+
if (chosen !== undefined && chosen !== null)
|
|
70
|
+
return { provider: chosen.provider, model: chosen.model };
|
|
71
|
+
}
|
|
72
|
+
const fallback = ctx.get('agentDefaultModel')?.currentSelection?.();
|
|
73
|
+
return fallback === undefined ? undefined : { provider: fallback.provider, model: fallback.model };
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=llm.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The agent-preset half of the family's host platform boundary.
|
|
3
|
+
*
|
|
4
|
+
* Restricted presets need the registry's document/register face; the review
|
|
5
|
+
* branch needs resolve/mount; the restrictor needs composedPreset. The
|
|
6
|
+
* platform service is optional, so every method is reached through one facade.
|
|
7
|
+
*/
|
|
8
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
9
|
+
export interface PresetDocument {
|
|
10
|
+
readonly agentPreset: string;
|
|
11
|
+
readonly content: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PresetDefinitionLike {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly order: number;
|
|
18
|
+
readonly plugins: readonly unknown[];
|
|
19
|
+
}
|
|
20
|
+
export interface PresetsPort {
|
|
21
|
+
readDocument(agentPreset: string): Promise<PresetDocument>;
|
|
22
|
+
register(definition: PresetDefinitionLike): Promise<() => Promise<void>>;
|
|
23
|
+
resolve(id?: string): Promise<{
|
|
24
|
+
readonly id: string;
|
|
25
|
+
}>;
|
|
26
|
+
mount(target: Context, id?: string): Promise<unknown>;
|
|
27
|
+
composedPreset(target: Context): string | undefined;
|
|
28
|
+
}
|
|
29
|
+
/** Resolve the preset registry facade; undefined when the host has no agentPresets service. */
|
|
30
|
+
export declare function presetsPort(ctx: Context): PresetsPort | undefined;
|
|
31
|
+
//# sourceMappingURL=presets.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Resolve the preset registry facade; undefined when the host has no agentPresets service. */
|
|
2
|
+
export function presetsPort(ctx) {
|
|
3
|
+
// platform-declaration anchor: agentPresets is declared in core PLATFORM_SERVICE_PROBES.
|
|
4
|
+
const registry = ctx.get('agentPresets');
|
|
5
|
+
if (registry === undefined)
|
|
6
|
+
return undefined;
|
|
7
|
+
return {
|
|
8
|
+
readDocument: (id) => {
|
|
9
|
+
if (registry.readDocument === undefined)
|
|
10
|
+
throw new Error('agentPresets service has no readDocument()');
|
|
11
|
+
return registry.readDocument(id);
|
|
12
|
+
},
|
|
13
|
+
register: (definition) => {
|
|
14
|
+
if (registry.register === undefined)
|
|
15
|
+
throw new Error('agentPresets service has no register()');
|
|
16
|
+
return registry.register(definition);
|
|
17
|
+
},
|
|
18
|
+
resolve: (id) => {
|
|
19
|
+
if (registry.resolve === undefined)
|
|
20
|
+
throw new Error('agentPresets service has no resolve()');
|
|
21
|
+
return registry.resolve(id);
|
|
22
|
+
},
|
|
23
|
+
mount: (target, id) => {
|
|
24
|
+
if (registry.mount === undefined)
|
|
25
|
+
throw new Error('agentPresets service has no mount()');
|
|
26
|
+
return registry.mount(target, id);
|
|
27
|
+
},
|
|
28
|
+
composedPreset: (target) => registry.composedPreset?.(target),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=presets.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session-projection half of the family's host platform boundary.
|
|
3
|
+
*
|
|
4
|
+
* The target 0.2.2 registry returns an awaitable callable-thenable handle;
|
|
5
|
+
* the 0.2.1 registry returns a disposer function and reads through
|
|
6
|
+
* registry.stateOf. Both forms are adapted here; the legacy branch is deleted
|
|
7
|
+
* when platform-line moves to 0.2.2.
|
|
8
|
+
*/
|
|
9
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
10
|
+
import type { ZodType } from 'zod';
|
|
11
|
+
import type { Session, SessionEvent } from '@deepseek-ai/dsh-session';
|
|
12
|
+
/** The family-owned shape of one projection unit; platform types stay behind the port. */
|
|
13
|
+
export interface EvolutionProjectionDefinition<K extends string, S> {
|
|
14
|
+
readonly key: K;
|
|
15
|
+
readonly stateVersion: number;
|
|
16
|
+
readonly stateSchema: ZodType<S>;
|
|
17
|
+
readonly init: (header: unknown, inheritedEventCount: number) => S;
|
|
18
|
+
readonly apply: (state: S, event: SessionEvent) => S;
|
|
19
|
+
}
|
|
20
|
+
/** One registered unit's read face, independent of the platform's handle class. */
|
|
21
|
+
export interface ProjectionHandleLike<S> {
|
|
22
|
+
stateOf(session: Session): S | undefined;
|
|
23
|
+
dispose(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export interface ProjectionPort {
|
|
26
|
+
register<K extends string, S>(definition: EvolutionProjectionDefinition<K, S>): Promise<ProjectionHandleLike<S>>;
|
|
27
|
+
}
|
|
28
|
+
/** Resolve the projection port; undefined means the host has no projection registry. */
|
|
29
|
+
export declare function projectionPort(ctx: Context): ProjectionPort | undefined;
|
|
30
|
+
//# sourceMappingURL=projections.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function isCallableThenable(value) {
|
|
2
|
+
return typeof value === 'function' && typeof value.then === 'function';
|
|
3
|
+
}
|
|
4
|
+
/** Resolve the projection port; undefined means the host has no projection registry. */
|
|
5
|
+
export function projectionPort(ctx) {
|
|
6
|
+
// platform-declaration anchor: sessionProjections is declared in core PLATFORM_SERVICE_PROBES.
|
|
7
|
+
const registry = ctx.get('sessionProjections');
|
|
8
|
+
if (registry === undefined)
|
|
9
|
+
return undefined;
|
|
10
|
+
return {
|
|
11
|
+
async register(definition) {
|
|
12
|
+
const raw = registry.register(definition);
|
|
13
|
+
if (isCallableThenable(raw)) {
|
|
14
|
+
const resolved = await raw;
|
|
15
|
+
if (resolved !== null && typeof resolved === 'object' && typeof resolved.stateOf === 'function') {
|
|
16
|
+
const handle = resolved;
|
|
17
|
+
return {
|
|
18
|
+
stateOf: (session) => handle.stateOf(session),
|
|
19
|
+
dispose: () => handle.dispose(),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const dispose = raw;
|
|
24
|
+
return {
|
|
25
|
+
stateOf: (session) => registry.stateOf?.(session, definition.key),
|
|
26
|
+
dispose: async () => { dispose(); },
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=projections.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tools half of the family's host platform boundary.
|
|
3
|
+
*
|
|
4
|
+
* Only this module imports @deepseek-ai/dsh-tools; consumers receive a typed
|
|
5
|
+
* port and never reshape ctx.get('tools') themselves. Missing service is a
|
|
6
|
+
* capability downgrade, not a crash.
|
|
7
|
+
*/
|
|
8
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
9
|
+
import type { ToolDefinition, ToolGuard, ToolRestriction } from '@deepseek-ai/dsh-tools';
|
|
10
|
+
/** The subset of the platform tools registry the family consumes. */
|
|
11
|
+
export interface ToolsPort {
|
|
12
|
+
register(definition: ToolDefinition): () => void;
|
|
13
|
+
guard(guard: ToolGuard): () => void;
|
|
14
|
+
restrict(filter: ToolRestriction): () => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the tools port from a context; undefined means the host has no tools service.
|
|
18
|
+
* platform-declaration anchor: tools is declared in core PLATFORM_SERVICE_PROBES.
|
|
19
|
+
*/
|
|
20
|
+
export declare function toolsPort(ctx: Context): ToolsPort | undefined;
|
|
21
|
+
/** Register one family tool through the port; a missing service yields a no-op disposer. */
|
|
22
|
+
export declare function registerEvolutionTool(ctx: Context, definition: ToolDefinition): () => void;
|
|
23
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the tools port from a context; undefined means the host has no tools service.
|
|
3
|
+
* platform-declaration anchor: tools is declared in core PLATFORM_SERVICE_PROBES.
|
|
4
|
+
*/
|
|
5
|
+
export function toolsPort(ctx) {
|
|
6
|
+
// The cast is confined to the boundary: the platform service class is the
|
|
7
|
+
// contract, while the port keeps feature code independent of its full face.
|
|
8
|
+
const tools = ctx.get('tools');
|
|
9
|
+
if (tools === undefined)
|
|
10
|
+
return undefined;
|
|
11
|
+
return {
|
|
12
|
+
register: (definition) => tools.register(definition),
|
|
13
|
+
guard: (guard) => tools.guard(guard),
|
|
14
|
+
restrict: (filter) => tools.restrict(filter),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** Register one family tool through the port; a missing service yields a no-op disposer. */
|
|
18
|
+
export function registerEvolutionTool(ctx, definition) {
|
|
19
|
+
return toolsPort(ctx)?.register(definition) ?? (() => { });
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** The frozen platform line this release targets (peers/engines/anchors derived from version+floor). */
|
|
2
2
|
export declare const PLATFORM_LINE: {
|
|
3
|
-
readonly version: "0.2.
|
|
4
|
-
readonly floor: "0.2.
|
|
5
|
-
readonly previousAnchor: "0.2.
|
|
6
|
-
readonly peersRange: "^0.2.
|
|
7
|
-
readonly enginesRange: ">=0.2.
|
|
8
|
-
readonly upstreamRef: "dsh-v0.2.
|
|
3
|
+
readonly version: "0.2.2-rc.1";
|
|
4
|
+
readonly floor: "0.2.2-rc.0";
|
|
5
|
+
readonly previousAnchor: "0.2.1-rc.2";
|
|
6
|
+
readonly peersRange: "^0.2.2-rc.0";
|
|
7
|
+
readonly enginesRange: ">=0.2.2-rc.0 <0.2.3-0";
|
|
8
|
+
readonly upstreamRef: "dsh-v0.2.2-rc.1";
|
|
9
9
|
};
|
|
10
10
|
//# sourceMappingURL=platform-line.generated.d.ts.map
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Regenerate with: node packages/scripts/gen-platform-line.mjs
|
|
3
3
|
/** The frozen platform line this release targets (peers/engines/anchors derived from version+floor). */
|
|
4
4
|
export const PLATFORM_LINE = {
|
|
5
|
-
version: '0.2.
|
|
6
|
-
floor: '0.2.
|
|
7
|
-
previousAnchor: '0.2.
|
|
8
|
-
peersRange: '^0.2.
|
|
9
|
-
enginesRange: '>=0.2.
|
|
10
|
-
upstreamRef: 'dsh-v0.2.
|
|
5
|
+
version: '0.2.2-rc.1',
|
|
6
|
+
floor: '0.2.2-rc.0',
|
|
7
|
+
previousAnchor: '0.2.1-rc.2',
|
|
8
|
+
peersRange: '^0.2.2-rc.0',
|
|
9
|
+
enginesRange: '>=0.2.2-rc.0 <0.2.3-0',
|
|
10
|
+
upstreamRef: 'dsh-v0.2.2-rc.1',
|
|
11
11
|
};
|
|
12
12
|
//# sourceMappingURL=platform-line.generated.js.map
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { PlatformServiceProbe } from '@lmzhen/dsh-evolution-contract';
|
|
15
15
|
export type { PlatformServiceProbe } from '@lmzhen/dsh-evolution-contract';
|
|
16
|
-
/** The
|
|
16
|
+
/** The probes, in service-name order (the guard checks this list against the tree). */
|
|
17
17
|
export declare const PLATFORM_SERVICE_PROBES: readonly PlatformServiceProbe[];
|
|
18
18
|
/**
|
|
19
19
|
* The HOST-side probes that do not resolve in this runtime — what `/evolution doctor` prints as
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* `client` probes run in the browser half, where the host has no view of the seats.
|
|
12
12
|
* @module @lmzhen/dsh-evolution-core
|
|
13
13
|
*/
|
|
14
|
-
/** The
|
|
14
|
+
/** The probes, in service-name order (the guard checks this list against the tree). */
|
|
15
15
|
export const PLATFORM_SERVICE_PROBES = Object.freeze([
|
|
16
16
|
{ service: 'agentDefaultModel', feature: 'the model route inherited by a plugin review branch', side: 'host' },
|
|
17
17
|
{ service: 'agentPresets', feature: 'the preset mount that gives a plugin review branch its tools/system', side: 'host' },
|
|
@@ -25,6 +25,7 @@ export const PLATFORM_SERVICE_PROBES = Object.freeze([
|
|
|
25
25
|
{ service: 'evolutionMerge', feature: 'merge command delegation and the merge doctor fact', side: 'host' },
|
|
26
26
|
{ service: 'hmr', feature: 'the preset install read-merge-write commit (the platform HMR lock serializes it)', side: 'host' },
|
|
27
27
|
{ service: 'evolutionMemoryBudget', feature: 'the memory-budget divergence section of this report', side: 'host' },
|
|
28
|
+
{ service: 'evolutionPlatform', feature: 'the single host edge object behind every family platform port', side: 'host' },
|
|
28
29
|
{ service: 'evolutionPolicy', feature: 'the policy snapshot that shadows row knobs', side: 'host' },
|
|
29
30
|
{ service: 'evolutionReplay', feature: '/evolution replay', side: 'host' },
|
|
30
31
|
{ service: 'evolutionState', feature: 'the state facade behind activity and replay', side: 'host' },
|
|
@@ -34,6 +35,8 @@ export const PLATFORM_SERVICE_PROBES = Object.freeze([
|
|
|
34
35
|
{ service: 'pluginManager', feature: 'the platform plugin and preset surfaces this report reads', side: 'host' },
|
|
35
36
|
{ service: 'profileContext', feature: 'writing the agent-preset row into a profile patch', side: 'host' },
|
|
36
37
|
{ service: 'sessionProjections', feature: 'the domain-owned session units', side: 'host' },
|
|
38
|
+
{ service: 'evolutionProjections', feature: 'the family-owned projection runtime behind the pure readers', side: 'host' },
|
|
39
|
+
{ service: 'evolutionLlm', feature: 'the family LLM runtime for auxiliary model calls', side: 'host' },
|
|
37
40
|
{ service: 'sessionQuery', feature: 'the session corpus behind /evolution sessions', side: 'host' },
|
|
38
41
|
{ service: 'settings', feature: 'the settings user layer and the params view', side: 'host' },
|
|
39
42
|
{ service: 'skillUsage', feature: 'usage counters feeding the curator and the review planner', side: 'host' },
|
package/lib/types/restrictor.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { presetsPort } from "./platform/presets.js";
|
|
2
|
+
import { toolsPort } from "./platform/tools.js";
|
|
1
3
|
import { errorText } from "./errors.js";
|
|
2
4
|
export const name = 'evolution-restrictor';
|
|
3
5
|
export const inject = ['agentPresets'];
|
|
@@ -22,8 +24,8 @@ export function apply(ctx, config = {}) {
|
|
|
22
24
|
const on = ctx.on;
|
|
23
25
|
if (typeof on !== 'function')
|
|
24
26
|
throw failure('requires a context that owns on()');
|
|
25
|
-
const presets = ctx
|
|
26
|
-
if (presets === undefined
|
|
27
|
+
const presets = presetsPort(ctx);
|
|
28
|
+
if (presets === undefined) {
|
|
27
29
|
throw failure('requires the agentPresets service (inject: agentPresets)');
|
|
28
30
|
}
|
|
29
31
|
// The listener lives in the preset MOUNT scope: scope routing delivers every descendant
|
|
@@ -35,14 +37,10 @@ export function apply(ctx, config = {}) {
|
|
|
35
37
|
return;
|
|
36
38
|
if (presets.composedPreset(agent.ctx) !== presetId)
|
|
37
39
|
return;
|
|
38
|
-
const tools = agent.ctx
|
|
39
|
-
if (tools === undefined
|
|
40
|
+
const tools = toolsPort(agent.ctx);
|
|
41
|
+
if (tools === undefined)
|
|
40
42
|
throw failure('child scope exposes no tools.restrict()');
|
|
41
|
-
|
|
42
|
-
const effect = agent.ctx.effect;
|
|
43
|
-
if (effect === undefined)
|
|
44
|
-
throw failure('child scope owns no effect() to release the restriction');
|
|
45
|
-
effect.call(agent.ctx, () => tools.restrict(filter), 'evolution-restrictor:child');
|
|
43
|
+
agent.ctx.effect(() => tools.restrict(filter), 'evolution-restrictor:child');
|
|
46
44
|
});
|
|
47
45
|
}
|
|
48
46
|
//# sourceMappingURL=restrictor.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** One review run's write provenance. */
|
|
2
|
+
export interface ReviewExecutionContext {
|
|
3
|
+
/** Stable ReviewRun id used by audit and actions. */
|
|
4
|
+
readonly reviewId: string;
|
|
5
|
+
/** Execution id; currently the same run id. */
|
|
6
|
+
readonly runId: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Run one review tool loop under the review write context.
|
|
10
|
+
* @param context - review/run identity.
|
|
11
|
+
* @param task - loop body; nested tool executions inherit the context.
|
|
12
|
+
* @returns the task's value.
|
|
13
|
+
*/
|
|
14
|
+
export declare function withReviewContext<T>(context: ReviewExecutionContext, task: () => T): T;
|
|
15
|
+
/**
|
|
16
|
+
* The active review context, when the current async execution belongs to a review loop.
|
|
17
|
+
* @returns the frozen context, or undefined outside a review loop.
|
|
18
|
+
*/
|
|
19
|
+
export declare function currentReviewContext(): ReviewExecutionContext | undefined;
|
|
20
|
+
//# sourceMappingURL=review-context.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin-local review execution context.
|
|
3
|
+
*
|
|
4
|
+
* This is deliberately not a platform API: the family review executor wraps one
|
|
5
|
+
* bounded tool loop, and the write tools read the context to attribute writes as
|
|
6
|
+
* background_review without relying on a Session header or a global mark.
|
|
7
|
+
*
|
|
8
|
+
* @module @lmzhen/dsh-evolution-core/review-context
|
|
9
|
+
*/
|
|
10
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
11
|
+
const storage = new AsyncLocalStorage();
|
|
12
|
+
/**
|
|
13
|
+
* Run one review tool loop under the review write context.
|
|
14
|
+
* @param context - review/run identity.
|
|
15
|
+
* @param task - loop body; nested tool executions inherit the context.
|
|
16
|
+
* @returns the task's value.
|
|
17
|
+
*/
|
|
18
|
+
export function withReviewContext(context, task) {
|
|
19
|
+
return storage.run(Object.freeze({ ...context }), task);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The active review context, when the current async execution belongs to a review loop.
|
|
23
|
+
* @returns the frozen context, or undefined outside a review loop.
|
|
24
|
+
*/
|
|
25
|
+
export function currentReviewContext() {
|
|
26
|
+
return storage.getStore();
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=review-context.js.map
|