@lmzhen/dsh-evolution-core 0.37.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/lib/composition/index.js +2 -2
- package/lib/{composition-3QFfEe56.js → composition-dy0gJWDd.js} +1 -1
- package/lib/{ensure-C2tUoF5U.js → ensure-B4fjEI0w.js} +4 -11
- package/lib/{errors-DRZ9A187.js → errors-DUcEoTLR.js} +4 -4
- package/lib/index.js +37 -1305
- 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 +8 -8
- 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/errors.d.ts +4 -4
- package/lib/types/errors.js +4 -4
- package/lib/types/opt-in.d.ts +1 -1
- package/lib/types/opt-in.js +1 -1
- package/lib/types/params.js +7 -7
- 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/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/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/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,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family's LLM runtime: one route/purpose/transport path for auxiliary
|
|
3
|
+
* model calls. Feature-specific retries and parsing stay in their features.
|
|
4
|
+
*/
|
|
5
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
6
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
7
|
+
import { type EvolutionLlmRequest, type ModelRoute, type StreamChunk } from '../platform/index.ts';
|
|
8
|
+
export interface EvolutionLlmInput {
|
|
9
|
+
readonly purpose: EvolutionLlmRequest['purpose'];
|
|
10
|
+
readonly messages: EvolutionLlmRequest['messages'];
|
|
11
|
+
readonly route?: ModelRoute | undefined;
|
|
12
|
+
readonly agent?: unknown;
|
|
13
|
+
readonly session?: unknown;
|
|
14
|
+
readonly maxTokens?: number | undefined;
|
|
15
|
+
readonly temperature?: number | undefined;
|
|
16
|
+
readonly signal?: AbortSignal | undefined;
|
|
17
|
+
readonly timeoutMs?: number | undefined;
|
|
18
|
+
}
|
|
19
|
+
/** Domain service for every auxiliary LLM request in the family. */
|
|
20
|
+
export declare class EvolutionLlm extends Service {
|
|
21
|
+
static inject: never[];
|
|
22
|
+
private port;
|
|
23
|
+
constructor(ctx: Context);
|
|
24
|
+
protected [Service.init](): void;
|
|
25
|
+
/** Whether the platform llm service is mounted. */
|
|
26
|
+
available(): boolean;
|
|
27
|
+
/** One assembled text response. */
|
|
28
|
+
text(input: EvolutionLlmInput): Promise<string>;
|
|
29
|
+
/** Raw chunk stream for callers that need incremental delivery. */
|
|
30
|
+
stream(input: EvolutionLlmInput): AsyncIterable<StreamChunk>;
|
|
31
|
+
private prepare;
|
|
32
|
+
private classify;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=llm.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family's LLM runtime: one route/purpose/transport path for auxiliary
|
|
3
|
+
* model calls. Feature-specific retries and parsing stay in their features.
|
|
4
|
+
*/
|
|
5
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
6
|
+
import { EvolutionLlmError, llmPort, modelRoute } from "../platform/index.js";
|
|
7
|
+
/** Domain service for every auxiliary LLM request in the family. */
|
|
8
|
+
export class EvolutionLlm extends Service {
|
|
9
|
+
static inject = [];
|
|
10
|
+
port;
|
|
11
|
+
constructor(ctx) {
|
|
12
|
+
super(ctx, 'evolutionLlm');
|
|
13
|
+
}
|
|
14
|
+
[Service.init]() {
|
|
15
|
+
const platform = this.ctx.get('evolutionPlatform');
|
|
16
|
+
this.port = platform?.ports?.llm ?? llmPort(this.ctx);
|
|
17
|
+
if (this.port === undefined)
|
|
18
|
+
this.ctx.logger.warn('evolution-core-runtime: llm service unavailable; model calls fail with llm-unavailable');
|
|
19
|
+
}
|
|
20
|
+
/** Whether the platform llm service is mounted. */
|
|
21
|
+
available() { return this.port !== undefined; }
|
|
22
|
+
/** One assembled text response. */
|
|
23
|
+
async text(input) {
|
|
24
|
+
const prepared = this.prepare(input);
|
|
25
|
+
try {
|
|
26
|
+
return await prepared.port.completeText(prepared.request);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
throw this.classify(error, prepared.timeout, prepared.caller);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** Raw chunk stream for callers that need incremental delivery. */
|
|
33
|
+
async *stream(input) {
|
|
34
|
+
const prepared = this.prepare(input);
|
|
35
|
+
try {
|
|
36
|
+
yield* prepared.port.stream(prepared.request);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
throw this.classify(error, prepared.timeout, prepared.caller);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
prepare(input) {
|
|
43
|
+
const port = this.port;
|
|
44
|
+
if (port === undefined)
|
|
45
|
+
throw new EvolutionLlmError('model-unavailable', 'llm-unavailable: no llm service is mounted');
|
|
46
|
+
const route = input.route ?? modelRoute(this.ctx, input.agent, input.session);
|
|
47
|
+
if (route === undefined)
|
|
48
|
+
throw new EvolutionLlmError('no-route', 'llm-unavailable: no model route is configured');
|
|
49
|
+
const timeout = input.timeoutMs !== undefined && Number.isFinite(input.timeoutMs) && input.timeoutMs > 0
|
|
50
|
+
? AbortSignal.timeout(input.timeoutMs)
|
|
51
|
+
: undefined;
|
|
52
|
+
const signal = input.signal === undefined ? timeout : timeout === undefined ? input.signal : AbortSignal.any([input.signal, timeout]);
|
|
53
|
+
const request = {
|
|
54
|
+
provider: route.provider,
|
|
55
|
+
model: route.model,
|
|
56
|
+
purpose: input.purpose,
|
|
57
|
+
messages: input.messages,
|
|
58
|
+
...(input.maxTokens === undefined ? {} : { maxTokens: input.maxTokens }),
|
|
59
|
+
...(input.temperature === undefined ? {} : { temperature: input.temperature }),
|
|
60
|
+
...(signal === undefined ? {} : { signal }),
|
|
61
|
+
};
|
|
62
|
+
return { port, request, ...(timeout === undefined ? {} : { timeout }), ...(input.signal === undefined ? {} : { caller: input.signal }) };
|
|
63
|
+
}
|
|
64
|
+
classify(error, timeout, caller) {
|
|
65
|
+
if (error instanceof EvolutionLlmError)
|
|
66
|
+
return error;
|
|
67
|
+
const kind = timeout?.aborted === true ? 'timeout' : caller?.aborted === true ? 'cancelled' : 'transport';
|
|
68
|
+
return new EvolutionLlmError(kind, error instanceof Error ? error.message : String(error), error);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=llm.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family's host capability service: one place that resolves the platform
|
|
3
|
+
* ports and reports which halves are available. Feature code reads ports from
|
|
4
|
+
* this service; the port modules remain the only @deepseek-ai/dsh-* importers.
|
|
5
|
+
*/
|
|
6
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
7
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
8
|
+
import type { LlmPort } from '../platform/llm.ts';
|
|
9
|
+
import type { PresetsPort } from '../platform/presets.ts';
|
|
10
|
+
import type { ProjectionPort } from '../platform/projections.ts';
|
|
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
|
+
/** Resolved host ports and their availability. */
|
|
19
|
+
export interface HostPlatformPorts {
|
|
20
|
+
readonly projections: ProjectionPort | undefined;
|
|
21
|
+
readonly llm: LlmPort | undefined;
|
|
22
|
+
readonly tools: ToolsPort | undefined;
|
|
23
|
+
readonly presets: PresetsPort | undefined;
|
|
24
|
+
}
|
|
25
|
+
/** Domain service owning the host port table. */
|
|
26
|
+
export declare class EvolutionPlatform extends Service {
|
|
27
|
+
static inject: never[];
|
|
28
|
+
readonly ports: HostPlatformPorts;
|
|
29
|
+
constructor(ctx: Context);
|
|
30
|
+
/** True when the two services the runtime cannot work without are present. */
|
|
31
|
+
ready(): boolean;
|
|
32
|
+
/** One row per optional host service; absent services stay visible, not silent. */
|
|
33
|
+
capabilities(): readonly PlatformCapability[];
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family's host capability service: one place that resolves the platform
|
|
3
|
+
* ports and reports which halves are available. Feature code reads ports from
|
|
4
|
+
* this service; the port modules remain the only @deepseek-ai/dsh-* importers.
|
|
5
|
+
*/
|
|
6
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
7
|
+
import { presetsPort } from "../platform/presets.js";
|
|
8
|
+
import { projectionPort } from "../platform/projections.js";
|
|
9
|
+
import { toolsPort } from "../platform/tools.js";
|
|
10
|
+
import { llmPort } from "../platform/llm.js";
|
|
11
|
+
/** Domain service owning the host port table. */
|
|
12
|
+
export class EvolutionPlatform extends Service {
|
|
13
|
+
static inject = [];
|
|
14
|
+
ports;
|
|
15
|
+
constructor(ctx) {
|
|
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
|
+
}
|
|
28
|
+
/** One row per optional host service; absent services stay visible, not silent. */
|
|
29
|
+
capabilities() {
|
|
30
|
+
return [
|
|
31
|
+
{ name: 'projections', available: this.ports.projections !== undefined, ...(this.ports.projections === undefined ? { reason: 'sessionProjections unavailable' } : {}) },
|
|
32
|
+
{ name: 'llm', available: this.ports.llm !== undefined, ...(this.ports.llm === undefined ? { reason: 'llm unavailable' } : {}) },
|
|
33
|
+
{ name: 'tools', available: this.ports.tools !== undefined, ...(this.ports.tools === undefined ? { reason: 'tools unavailable' } : {}) },
|
|
34
|
+
{ name: 'presets', available: this.ports.presets !== undefined, ...(this.ports.presets === undefined ? { reason: 'agentPresets unavailable' } : {}) },
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime composition entry: mount the family's domain services once per
|
|
3
|
+
* composition scope. Projection consumers read the service; they never
|
|
4
|
+
* register units themselves.
|
|
5
|
+
*/
|
|
6
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
7
|
+
export declare const name = "evolution-core-runtime";
|
|
8
|
+
/** @param ctx - the composition context that owns the runtime services. */
|
|
9
|
+
export declare function apply(ctx: Context): void;
|
|
10
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EvolutionLlm } from "./llm.js";
|
|
2
|
+
import { EvolutionPlatform } from "./platform.js";
|
|
3
|
+
import { EvolutionProjections } from "./projections.js";
|
|
4
|
+
export const name = 'evolution-core-runtime';
|
|
5
|
+
/** @param ctx - the composition context that owns the runtime services. */
|
|
6
|
+
export function apply(ctx) {
|
|
7
|
+
ctx.plugin(EvolutionPlatform);
|
|
8
|
+
ctx.plugin(EvolutionProjections);
|
|
9
|
+
ctx.plugin(EvolutionLlm);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family's projection runtime: register the five host-only units once and
|
|
3
|
+
* expose typed reads to the pure readers. Missing registry or a registration
|
|
4
|
+
* failure degrades to undefined (the existing fail-open posture), never throws
|
|
5
|
+
* into the host.
|
|
6
|
+
*/
|
|
7
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
8
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
9
|
+
import { type Session } from '../platform/index.ts';
|
|
10
|
+
import { type EvolutionActivityState, type EvolutionEvidenceState, type EvolutionProjectionHistoryState, type EvolutionReadsState, type EvolutionSignalsState } from '../session-projection.ts';
|
|
11
|
+
/** Domain service owning the family's projection registrations. */
|
|
12
|
+
export declare class EvolutionProjections extends Service {
|
|
13
|
+
static inject: never[];
|
|
14
|
+
private handles;
|
|
15
|
+
private degradedReason;
|
|
16
|
+
constructor(ctx: Context);
|
|
17
|
+
protected [Service.init](): Promise<void>;
|
|
18
|
+
/** Whether the five units are registered and readable. */
|
|
19
|
+
status(): 'ready' | 'degraded';
|
|
20
|
+
/** Why the service is degraded; undefined while ready. */
|
|
21
|
+
reason(): string | undefined;
|
|
22
|
+
activity(session: Session): EvolutionActivityState | undefined;
|
|
23
|
+
evidence(session: Session): EvolutionEvidenceState | undefined;
|
|
24
|
+
reads(session: Session): EvolutionReadsState | undefined;
|
|
25
|
+
history(session: Session): EvolutionProjectionHistoryState | undefined;
|
|
26
|
+
signals(session: Session): EvolutionSignalsState | undefined;
|
|
27
|
+
private markDegraded;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=projections.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family's projection runtime: register the five host-only units once and
|
|
3
|
+
* expose typed reads to the pure readers. Missing registry or a registration
|
|
4
|
+
* failure degrades to undefined (the existing fail-open posture), never throws
|
|
5
|
+
* into the host.
|
|
6
|
+
*/
|
|
7
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
8
|
+
import { projectionPort } from "../platform/index.js";
|
|
9
|
+
import { evolutionActivityProjection, evolutionEvidenceProjection, evolutionProjectionHistoryProjection, evolutionReadsProjection, evolutionSignalsProjection, } from "../session-projection.js";
|
|
10
|
+
/** Domain service owning the family's projection registrations. */
|
|
11
|
+
export class EvolutionProjections extends Service {
|
|
12
|
+
static inject = [];
|
|
13
|
+
handles;
|
|
14
|
+
degradedReason;
|
|
15
|
+
constructor(ctx) {
|
|
16
|
+
super(ctx, 'evolutionProjections');
|
|
17
|
+
}
|
|
18
|
+
async [Service.init]() {
|
|
19
|
+
const platform = this.ctx.get('evolutionPlatform');
|
|
20
|
+
const port = platform?.ports?.projections ?? projectionPort(this.ctx);
|
|
21
|
+
if (port === undefined) {
|
|
22
|
+
this.markDegraded('sessionProjections service unavailable');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const partial = {};
|
|
26
|
+
try {
|
|
27
|
+
partial.activity = await port.register(evolutionActivityProjection);
|
|
28
|
+
partial.evidence = await port.register(evolutionEvidenceProjection);
|
|
29
|
+
partial.reads = await port.register(evolutionReadsProjection);
|
|
30
|
+
partial.history = await port.register(evolutionProjectionHistoryProjection);
|
|
31
|
+
partial.signals = await port.register(evolutionSignalsProjection);
|
|
32
|
+
this.handles = partial;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
for (const handle of Object.values(partial).reverse()) {
|
|
36
|
+
try {
|
|
37
|
+
await handle.dispose();
|
|
38
|
+
}
|
|
39
|
+
catch { /* best-effort rollback; keep the original failure */ }
|
|
40
|
+
}
|
|
41
|
+
this.markDegraded('projection registration failed: ' + (error instanceof Error ? error.message : String(error)));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Whether the five units are registered and readable. */
|
|
45
|
+
status() {
|
|
46
|
+
return this.handles === undefined ? 'degraded' : 'ready';
|
|
47
|
+
}
|
|
48
|
+
/** Why the service is degraded; undefined while ready. */
|
|
49
|
+
reason() {
|
|
50
|
+
return this.handles === undefined ? this.degradedReason : undefined;
|
|
51
|
+
}
|
|
52
|
+
activity(session) { return this.handles?.activity.stateOf(session); }
|
|
53
|
+
evidence(session) { return this.handles?.evidence.stateOf(session); }
|
|
54
|
+
reads(session) { return this.handles?.reads.stateOf(session); }
|
|
55
|
+
history(session) { return this.handles?.history.stateOf(session); }
|
|
56
|
+
signals(session) { return this.handles?.signals.stateOf(session); }
|
|
57
|
+
markDegraded(reason) {
|
|
58
|
+
this.degradedReason = reason;
|
|
59
|
+
this.ctx.logger.warn('evolution-core-runtime: %s; projection reads degrade to undefined', reason);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=projections.js.map
|
package/lib/types/scope.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* The platform's registry reads are scope-sensitive: `skills.list(options)`
|
|
5
5
|
* documents its `scope` as "the calling agent; OMITTED READS THE GLOBAL LAYER
|
|
6
6
|
* ALONE", and `tools.get(name, scope?)` resolves visibility the same way
|
|
7
|
-
* (packages/skill/skill/src/index.ts:113-120, packages/core/tools/src/index.ts:
|
|
7
|
+
* (packages/skill/skill/src/index.ts:113-120, packages/core/tools/src/index.ts:239).
|
|
8
8
|
* A preset-mounted family row therefore lives in its PRESET'S STANDING SCOPE,
|
|
9
9
|
* so a scope-less read cannot see it — the asymmetry between "evolution mounted
|
|
10
10
|
* onto the original preset" and "the evolution variant preset".
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
-
import type { Session } from '
|
|
3
|
-
import type { ProjectionDefinition } from '@deepseek-ai/dsh-session-projection';
|
|
2
|
+
import type { EvolutionProjectionDefinition, Session } from './platform/index.ts';
|
|
4
3
|
import { type EvidenceIndex } from './evidence.ts';
|
|
5
4
|
import { type TurnFoldState, type TurnSignals } from './signals.ts';
|
|
6
5
|
/** Time of the newest event folded for one session; 0 for a log with no event. */
|
|
@@ -28,18 +27,10 @@ export interface EvolutionEvidenceState {
|
|
|
28
27
|
/** Boundary seqs, ascending. Every other seq at or below `through` carries content. */
|
|
29
28
|
readonly bookkeeping: readonly number[];
|
|
30
29
|
}
|
|
31
|
-
declare module '@deepseek-ai/dsh-session-projection/types' {
|
|
32
|
-
interface SessionProjectionStateMap {
|
|
33
|
-
/** The curator's idleness gate input: the newest event time of one session. */
|
|
34
|
-
evolutionActivity: EvolutionActivityState;
|
|
35
|
-
/** The plan path's evidence-class input: the boundary seqs of one session. */
|
|
36
|
-
evolutionEvidence: EvolutionEvidenceState;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
30
|
/** The `evolutionActivity` unit (host-only: no client view is registered for it). */
|
|
40
|
-
export declare const evolutionActivityProjection:
|
|
31
|
+
export declare const evolutionActivityProjection: EvolutionProjectionDefinition<'evolutionActivity', EvolutionActivityState>;
|
|
41
32
|
/** The `evolutionEvidence` unit (host-only: no client view is registered for it). */
|
|
42
|
-
export declare const evolutionEvidenceProjection:
|
|
33
|
+
export declare const evolutionEvidenceProjection: EvolutionProjectionDefinition<'evolutionEvidence', EvolutionEvidenceState>;
|
|
43
34
|
/**
|
|
44
35
|
* Whether one session object can be projected at all.
|
|
45
36
|
*
|
|
@@ -102,41 +93,24 @@ export interface EvolutionProjectionHistoryState {
|
|
|
102
93
|
readonly catalogs: readonly EvolutionCatalogFrame[];
|
|
103
94
|
readonly digests: readonly string[];
|
|
104
95
|
}
|
|
105
|
-
declare module '@deepseek-ai/dsh-session-projection/types' {
|
|
106
|
-
interface SessionProjectionStateMap {
|
|
107
|
-
/** The skill names one session read, for the read-before-write gate and the review plan path. */
|
|
108
|
-
evolutionReads: EvolutionReadsState;
|
|
109
|
-
/** Catalog/projection frames and digests, newest last; bounded so the state cannot grow with the session. */
|
|
110
|
-
evolutionProjectionHistory: EvolutionProjectionHistoryState;
|
|
111
|
-
/** The open turn's window signals, for the review cadence. */
|
|
112
|
-
evolutionSignals: EvolutionSignalsState;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
96
|
/** The `evolutionProjectionHistory` unit (host-only). */
|
|
116
|
-
export declare const evolutionProjectionHistoryProjection:
|
|
97
|
+
export declare const evolutionProjectionHistoryProjection: EvolutionProjectionDefinition<'evolutionProjectionHistory', EvolutionProjectionHistoryState>;
|
|
117
98
|
/** The `evolutionReads` unit (host-only: no client view is registered for it). */
|
|
118
|
-
export declare const evolutionReadsProjection:
|
|
99
|
+
export declare const evolutionReadsProjection: EvolutionProjectionDefinition<'evolutionReads', EvolutionReadsState>;
|
|
119
100
|
/** The `evolutionSignals` unit (host-only: no client view is registered for it). */
|
|
120
|
-
export declare const evolutionSignalsProjection:
|
|
121
|
-
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
* registry folds the in-memory log on first touch, so a unit that appears mid-session is still
|
|
130
|
-
* correct (`:602-630`).
|
|
131
|
-
*
|
|
132
|
-
* Idempotent by design, so a plugin mounting later does not need its own call.
|
|
133
|
-
* @param ctx - the mounting plugin's context.
|
|
134
|
-
*/
|
|
135
|
-
export declare function installEvolutionProjections(ctx: Context): void;
|
|
101
|
+
export declare const evolutionSignalsProjection: EvolutionProjectionDefinition<'evolutionSignals', EvolutionSignalsState>;
|
|
102
|
+
/** The read face the runtime service provides to the family's pure readers. */
|
|
103
|
+
export interface EvolutionProjectionReader {
|
|
104
|
+
activity(session: Session): EvolutionActivityState | undefined;
|
|
105
|
+
evidence(session: Session): EvolutionEvidenceState | undefined;
|
|
106
|
+
reads(session: Session): EvolutionReadsState | undefined;
|
|
107
|
+
history(session: Session): EvolutionProjectionHistoryState | undefined;
|
|
108
|
+
signals(session: Session): EvolutionSignalsState | undefined;
|
|
109
|
+
}
|
|
136
110
|
/**
|
|
137
|
-
* Time of one session's newest event, or
|
|
111
|
+
* Time of one session's newest event, or undefined when the unit is not available.
|
|
138
112
|
*
|
|
139
|
-
* The curator's idleness gate reads this instead of folding the session log;
|
|
113
|
+
* The curator's idleness gate reads this instead of folding the session log; undefined is a
|
|
140
114
|
* measurement that did not happen, which the gate answers with the deployment's fail-open policy.
|
|
141
115
|
* @param ctx - a context of the runtime (the service is read from the global store).
|
|
142
116
|
* @param session - the session to ask about.
|
|
@@ -144,22 +118,21 @@ export declare function installEvolutionProjections(ctx: Context): void;
|
|
|
144
118
|
*/
|
|
145
119
|
export declare function sessionLastEventTime(ctx: Context, session: Session): number | undefined;
|
|
146
120
|
/**
|
|
147
|
-
* The skill names one session read through a non-failed dispatch, or
|
|
148
|
-
* cannot be projected (a structural view, or a host without the
|
|
121
|
+
* The skill names one session read through a non-failed dispatch, or undefined when the session
|
|
122
|
+
* cannot be projected (a structural view, or a host without the runtime service).
|
|
149
123
|
*
|
|
150
|
-
*
|
|
151
|
-
* behavior rather than refusing every write in a composition whose session object is a bare stub
|
|
152
|
-
* (`skill-reads.ts` documents that three-state posture).
|
|
124
|
+
* undefined is NOT an empty set: the tool path's read-before-write gate keeps its previous
|
|
125
|
+
* behavior rather than refusing every write in a composition whose session object is a bare stub.
|
|
153
126
|
* @param ctx - a context of the runtime.
|
|
154
127
|
* @param session - the session whose reads are wanted.
|
|
155
128
|
* @returns the names read, or undefined when the log cannot be folded.
|
|
156
129
|
*/
|
|
157
130
|
export declare function sessionReadNames(ctx: Context, session: Session): ReadonlySet<string> | undefined;
|
|
158
131
|
/**
|
|
159
|
-
* The open turn's window signals, or
|
|
132
|
+
* The open turn's window signals, or undefined when the session cannot be projected.
|
|
160
133
|
*
|
|
161
|
-
* The window is the events since the newest
|
|
162
|
-
*
|
|
134
|
+
* The window is the events since the newest turn/start, folded by the same foldTurnEvent
|
|
135
|
+
* observeEvent uses; undefined means the caller has no measurement (a structural view), not
|
|
163
136
|
* that the turn was empty.
|
|
164
137
|
* @param ctx - a context of the runtime.
|
|
165
138
|
* @param session - the session whose open turn is being judged.
|
|
@@ -167,10 +140,10 @@ export declare function sessionReadNames(ctx: Context, session: Session): Readon
|
|
|
167
140
|
*/
|
|
168
141
|
export declare function sessionTurnSignals(ctx: Context, session: Session): TurnSignals | undefined;
|
|
169
142
|
/**
|
|
170
|
-
* The evidence index of one session, or
|
|
143
|
+
* The evidence index of one session, or undefined when the log cannot be classified.
|
|
171
144
|
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
145
|
+
* undefined covers both the missing unit and a log whose frames carry no seq: the plan path's
|
|
146
|
+
* EVIDENCE_CLASS row is report-only and must stay silent rather than report every op.
|
|
174
147
|
* @param ctx - a context of the runtime.
|
|
175
148
|
* @param session - the session the review plan is authored against.
|
|
176
149
|
* @returns an index answering "does this seq carry content?".
|
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
* 0.2.x deprecates the synchronous log reads (`Session.snapshotEvents` — "existing logic may
|
|
5
5
|
* remain unmigrated for now, but new calls are prohibited",
|
|
6
6
|
* `core/session/src/index.ts:639-658`) and drives DOMAIN-OWNED units instead: a registered unit
|
|
7
|
-
* folds every committed event once, the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* gains a projection-backed one beside it.
|
|
7
|
+
* folds every committed event once, the runtime service owns the handle and the registry, and a
|
|
8
|
+
* reader asks that service for the current state. Each unit here carries exactly what one pure
|
|
9
|
+
* family reader derives from a log, so that reader keeps its pure form and gains a
|
|
10
|
+
* projection-backed one beside it.
|
|
12
11
|
*
|
|
13
12
|
* State stays bounded. The evidence unit keeps the SPARSE boundary seqs and answers the dense
|
|
14
13
|
* question by complement: a content-seq set grows with every session event, while a turn/step
|
|
@@ -223,43 +222,13 @@ export const evolutionSignalsProjection = {
|
|
|
223
222
|
return { through: seq, lastEventTime: time, turnStartSeq, turn };
|
|
224
223
|
},
|
|
225
224
|
};
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
*
|
|
229
|
-
* Called by the READERS (not by a plugin's mount) and idempotent by the registry's own reference
|
|
230
|
-
* count: the first read of a foldable session installs the definitions, later reads count as
|
|
231
|
-
* co-owners, and the keys survive until the last registrant unloads
|
|
232
|
-
* (`session-projection/src/index.ts:273-292`). Registering at the read is what keeps a session
|
|
233
|
-
* view the registry cannot fold (`isProjectableSession`) from ever reaching its drive — the
|
|
234
|
-
* registry folds the in-memory log on first touch, so a unit that appears mid-session is still
|
|
235
|
-
* correct (`:602-630`).
|
|
236
|
-
*
|
|
237
|
-
* Idempotent by design, so a plugin mounting later does not need its own call.
|
|
238
|
-
* @param ctx - the mounting plugin's context.
|
|
239
|
-
*/
|
|
240
|
-
export function installEvolutionProjections(ctx) {
|
|
241
|
-
const register = (registry) => {
|
|
242
|
-
registry.register(evolutionActivityProjection);
|
|
243
|
-
registry.register(evolutionEvidenceProjection);
|
|
244
|
-
registry.register(evolutionReadsProjection);
|
|
245
|
-
registry.register(evolutionProjectionHistoryProjection);
|
|
246
|
-
registry.register(evolutionSignalsProjection);
|
|
247
|
-
};
|
|
248
|
-
// Already-mounted registry first: a reader that runs in the same tick as its own mount
|
|
249
|
-
// (a unit spec, an assembly-time probe) must see its units registered, and the injected
|
|
250
|
-
// callback of a not-yet-available service is not guaranteed to have run by then.
|
|
251
|
-
// platform-declaration anchor: the platform’s `sessionProjections` service (optional; undefined ⇒ no measurement)
|
|
252
|
-
const mounted = ctx.get('sessionProjections');
|
|
253
|
-
if (mounted !== undefined) {
|
|
254
|
-
register(mounted);
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
ctx.inject(['sessionProjections'], (injected) => { register(injected.sessionProjections); });
|
|
225
|
+
function projectionService(ctx) {
|
|
226
|
+
return ctx.get('evolutionProjections');
|
|
258
227
|
}
|
|
259
228
|
/**
|
|
260
|
-
* Time of one session's newest event, or
|
|
229
|
+
* Time of one session's newest event, or undefined when the unit is not available.
|
|
261
230
|
*
|
|
262
|
-
* The curator's idleness gate reads this instead of folding the session log;
|
|
231
|
+
* The curator's idleness gate reads this instead of folding the session log; undefined is a
|
|
263
232
|
* measurement that did not happen, which the gate answers with the deployment's fail-open policy.
|
|
264
233
|
* @param ctx - a context of the runtime (the service is read from the global store).
|
|
265
234
|
* @param session - the session to ask about.
|
|
@@ -268,19 +237,17 @@ export function installEvolutionProjections(ctx) {
|
|
|
268
237
|
export function sessionLastEventTime(ctx, session) {
|
|
269
238
|
if (!isProjectableSession(session))
|
|
270
239
|
return undefined;
|
|
271
|
-
|
|
272
|
-
const state = ctx.get('sessionProjections')?.stateOf(session, 'evolutionActivity');
|
|
240
|
+
const state = projectionService(ctx)?.activity(session);
|
|
273
241
|
if (state === undefined || state.lastEventTime === 0)
|
|
274
242
|
return undefined;
|
|
275
243
|
return state.lastEventTime;
|
|
276
244
|
}
|
|
277
245
|
/**
|
|
278
|
-
* The skill names one session read through a non-failed dispatch, or
|
|
279
|
-
* cannot be projected (a structural view, or a host without the
|
|
246
|
+
* The skill names one session read through a non-failed dispatch, or undefined when the session
|
|
247
|
+
* cannot be projected (a structural view, or a host without the runtime service).
|
|
280
248
|
*
|
|
281
|
-
*
|
|
282
|
-
* behavior rather than refusing every write in a composition whose session object is a bare stub
|
|
283
|
-
* (`skill-reads.ts` documents that three-state posture).
|
|
249
|
+
* undefined is NOT an empty set: the tool path's read-before-write gate keeps its previous
|
|
250
|
+
* behavior rather than refusing every write in a composition whose session object is a bare stub.
|
|
284
251
|
* @param ctx - a context of the runtime.
|
|
285
252
|
* @param session - the session whose reads are wanted.
|
|
286
253
|
* @returns the names read, or undefined when the log cannot be folded.
|
|
@@ -288,8 +255,7 @@ export function sessionLastEventTime(ctx, session) {
|
|
|
288
255
|
export function sessionReadNames(ctx, session) {
|
|
289
256
|
if (!isProjectableSession(session))
|
|
290
257
|
return undefined;
|
|
291
|
-
|
|
292
|
-
const state = ctx.get('sessionProjections')?.stateOf(session, 'evolutionReads');
|
|
258
|
+
const state = projectionService(ctx)?.reads(session);
|
|
293
259
|
if (state === undefined)
|
|
294
260
|
return undefined;
|
|
295
261
|
const names = new Set();
|
|
@@ -300,10 +266,10 @@ export function sessionReadNames(ctx, session) {
|
|
|
300
266
|
return names;
|
|
301
267
|
}
|
|
302
268
|
/**
|
|
303
|
-
* The open turn's window signals, or
|
|
269
|
+
* The open turn's window signals, or undefined when the session cannot be projected.
|
|
304
270
|
*
|
|
305
|
-
* The window is the events since the newest
|
|
306
|
-
*
|
|
271
|
+
* The window is the events since the newest turn/start, folded by the same foldTurnEvent
|
|
272
|
+
* observeEvent uses; undefined means the caller has no measurement (a structural view), not
|
|
307
273
|
* that the turn was empty.
|
|
308
274
|
* @param ctx - a context of the runtime.
|
|
309
275
|
* @param session - the session whose open turn is being judged.
|
|
@@ -312,18 +278,17 @@ export function sessionReadNames(ctx, session) {
|
|
|
312
278
|
export function sessionTurnSignals(ctx, session) {
|
|
313
279
|
if (!isProjectableSession(session))
|
|
314
280
|
return undefined;
|
|
315
|
-
|
|
316
|
-
const state = ctx.get('sessionProjections')?.stateOf(session, 'evolutionSignals');
|
|
281
|
+
const state = projectionService(ctx)?.signals(session);
|
|
317
282
|
if (state === undefined)
|
|
318
283
|
return undefined;
|
|
319
284
|
const { substantive, toolCalls, userChars, assistantChars, memorySignal, skillSignal } = state.turn;
|
|
320
285
|
return { substantive, toolCalls, userChars, assistantChars, memorySignal, skillSignal };
|
|
321
286
|
}
|
|
322
287
|
/**
|
|
323
|
-
* The evidence index of one session, or
|
|
288
|
+
* The evidence index of one session, or undefined when the log cannot be classified.
|
|
324
289
|
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
290
|
+
* undefined covers both the missing unit and a log whose frames carry no seq: the plan path's
|
|
291
|
+
* EVIDENCE_CLASS row is report-only and must stay silent rather than report every op.
|
|
327
292
|
* @param ctx - a context of the runtime.
|
|
328
293
|
* @param session - the session the review plan is authored against.
|
|
329
294
|
* @returns an index answering "does this seq carry content?".
|
|
@@ -331,8 +296,7 @@ export function sessionTurnSignals(ctx, session) {
|
|
|
331
296
|
export function sessionEvidenceIndex(ctx, session) {
|
|
332
297
|
if (!isProjectableSession(session))
|
|
333
298
|
return undefined;
|
|
334
|
-
|
|
335
|
-
const state = ctx.get('sessionProjections')?.stateOf(session, 'evolutionEvidence');
|
|
299
|
+
const state = projectionService(ctx)?.evidence(session);
|
|
336
300
|
if (state === undefined || state.sequenced === 0)
|
|
337
301
|
return undefined;
|
|
338
302
|
const { through, bookkeeping } = state;
|
package/lib/types/skill-reads.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { collectReadSkillNames, collectReadSupportFiles, DEFAULT_SUPPORT_READ_TOOL_NAMES, supportFileReadFromPath } from "./tool-dispatch.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isProjectableSession, sessionReadNames } from "./session-projection.js";
|
|
3
3
|
/**
|
|
4
4
|
* The skill names ONE session read, or `undefined` when its log is not readable.
|
|
5
5
|
*
|
|
@@ -41,8 +41,8 @@ export function sessionReadSupportFiles(ctx, session, options) {
|
|
|
41
41
|
if (session === undefined)
|
|
42
42
|
return undefined;
|
|
43
43
|
if (isProjectableSession(session)) {
|
|
44
|
-
|
|
45
|
-
const state =
|
|
44
|
+
const projections = ctx.get('evolutionProjections');
|
|
45
|
+
const state = projections?.reads(session);
|
|
46
46
|
if (state !== undefined) {
|
|
47
47
|
const toolNames = options.toolNames ?? DEFAULT_SUPPORT_READ_TOOL_NAMES;
|
|
48
48
|
const reads = new Map();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Agent, AgentOptions } from '@deepseek-ai/dsh-agent';
|
|
2
2
|
import type { SessionId } from '@deepseek-ai/dsh-session';
|
|
3
3
|
import type { SubagentStopReason } from '@deepseek-ai/dsh-subagent';
|
|
4
|
-
import type { ObjectJsonSchema } from '
|
|
4
|
+
import type { ObjectJsonSchema } from '../platform/index.ts';
|
|
5
5
|
export type ChannelCode = 'E-323' | 'E-324';
|
|
6
6
|
export type ChannelKind = 'reviewer' | 'maintainer';
|
|
7
7
|
export interface PresetStatus {
|