@linxin666/dsh-liangshen 0.3.24 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +24 -17
- package/README.zh.md +25 -18
- package/cordis.patch.yml +3 -2
- package/icon.svg +3 -0
- package/lib/client.js +381 -77
- package/lib/client.js.map +1 -1
- package/lib/index.js +594 -428
- package/lib/types/announce.test.d.ts +10 -0
- package/lib/types/client/LiangShenSettingsCard.d.ts +27 -10
- package/lib/types/client/PluginSettingsCard.d.ts +4 -0
- package/lib/types/client/index.d.ts +32 -13
- package/lib/types/client/lever-controller.d.ts +16 -2
- package/lib/types/client/locales.d.ts +13 -0
- package/lib/types/client/main-session.d.ts +32 -0
- package/lib/types/client/plugin-card-seat.d.ts +23 -16
- package/lib/types/client/settings-form.d.ts +17 -17
- package/lib/types/composition.d.ts +116 -0
- package/lib/types/composition.test.d.ts +7 -0
- package/lib/types/index.d.ts +146 -31
- package/lib/types/index.test.d.ts +5 -0
- package/package.json +25 -20
- package/presets/liangshen/agent.cordis.yml +44 -10
- package/presets/liangshen/fact-ledger.mjs +141 -0
- package/presets/liangshen/guard.mjs +426 -0
- package/presets/liangshen/minimal-prompt.mjs +2 -2
- package/presets/liangshen/tool-catalog.mjs +24 -20
- package/presets/liangshen/working-context.mjs +10 -2
- package/src/announce.test.ts +248 -55
- package/src/client/LiangShenLever.module.css +2 -0
- package/src/client/LiangShenLever.tsx +37 -9
- package/src/client/LiangShenSettingsCard.tsx +96 -12
- package/src/client/PluginSettingsCard.tsx +7 -2
- package/src/client/index.ts +61 -23
- package/src/client/lever-controller.ts +76 -9
- package/src/client/locales.ts +30 -4
- package/src/client/main-session.ts +43 -0
- package/src/client/plugin-card-seat.ts +24 -17
- package/src/client/settings-form.ts +34 -31
- package/src/composition.test.ts +294 -0
- package/src/composition.ts +554 -0
- package/src/index.test.ts +68 -1
- package/src/index.ts +278 -107
- package/tools/benchmark-live-run.mjs +171 -32
- package/lib/types/schema.d.ts +0 -18
- package/lib/types/schema.test.d.ts +0 -1
- package/lib/types/sync.d.ts +0 -74
- package/lib/types/sync.test.d.ts +0 -1
- package/src/schema.test.ts +0 -64
- package/src/schema.ts +0 -110
- package/src/sync.test.ts +0 -303
- package/src/sync.ts +0 -324
|
@@ -1 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host half against a fake cordis context: announcing (issue #839) and the
|
|
3
|
+
* preset DECLARATION that replaces the pre-0.1.7 preset-file sync.
|
|
4
|
+
*
|
|
5
|
+
* Declare = enabled: activation registers the bundled preset with
|
|
6
|
+
* `ctx.agentPresets` and keeps the returned disposer, a committed settings write
|
|
7
|
+
* re-declares through `loader/volatile-update`, and unloading releases the
|
|
8
|
+
* registration. Each test re-imports the module so the mount-once guard cannot
|
|
9
|
+
* swallow a second apply call.
|
|
10
|
+
*/
|
|
1
11
|
export {};
|
|
@@ -1,33 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LiangShen settings card: availability and the wire presentation. Registers
|
|
3
3
|
* into the `web-ui.plugin.item` child slot the Web UI plugin group renders,
|
|
4
|
-
* bound to the `
|
|
4
|
+
* bound to the `liangshen` settings namespace (the Host profile entry id).
|
|
5
5
|
*
|
|
6
|
-
* The presentation field does not act on this client half: the Host
|
|
7
|
-
*
|
|
8
|
-
* This card is the operator's only handle on it, which is why
|
|
9
|
-
* Host schema carries appears here.
|
|
6
|
+
* The presentation field does not act on this client half: the Host applies it
|
|
7
|
+
* to the preset it declares to the agent-preset registry, so a session reads it
|
|
8
|
+
* from its preset. This card is the operator's only handle on it, which is why
|
|
9
|
+
* every field the Host schema carries appears here.
|
|
10
10
|
*/
|
|
11
11
|
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
12
12
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
13
|
-
import type {
|
|
13
|
+
import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
14
14
|
import { type CardActions, type CardShell, type FieldState as CardFieldState } from './settings-form.ts';
|
|
15
15
|
/** Wire presentations the tool catalog accepts (mirrors the Host schema). */
|
|
16
16
|
export declare const PRESENTATION_CHOICES: readonly ["ptc", "native", "both"];
|
|
17
|
+
/** Sensitivity presets for the circuit breaker (mirrors the Host schema). */
|
|
18
|
+
export declare const SENSITIVITY_CHOICES: readonly ["conservative", "balanced", "aggressive"];
|
|
17
19
|
/** The LiangShen fields this card edits (the namespace's full schema). */
|
|
18
20
|
export interface LiangShenSettings {
|
|
19
21
|
/** Master switch for the plugin. */
|
|
20
22
|
enabled?: boolean;
|
|
21
23
|
/** Whether the plugin announces itself in every agent's system prompt. */
|
|
22
24
|
announceToAgent?: boolean;
|
|
23
|
-
/** Wire presentation
|
|
25
|
+
/** Wire presentation the Host applies to the preset's tool-catalog row. */
|
|
24
26
|
presentation?: string;
|
|
27
|
+
/** Master switch for the runtime degeneration circuit breaker. */
|
|
28
|
+
guardEnabled?: boolean;
|
|
29
|
+
/** Sensitivity preset scaling the breaker's adaptive thresholds. */
|
|
30
|
+
guardSensitivity?: string;
|
|
31
|
+
/** Per-step reasoning-character floor for the breaker's runaway ladder. */
|
|
32
|
+
guardStallReasoningChars?: number;
|
|
33
|
+
/** Consecutive output-free reasoning steps for the breaker's slow-burn ladder. */
|
|
34
|
+
guardGlobalStallCap?: number;
|
|
35
|
+
/** Identical-argument tool failures for the breaker's echo ladder. */
|
|
36
|
+
guardEchoFailures?: number;
|
|
25
37
|
}
|
|
26
38
|
/** What the LiangShen card renders. */
|
|
27
39
|
export interface LiangShenSettingsCardState extends CardShell {
|
|
28
40
|
enabled: CardFieldState;
|
|
29
41
|
announceToAgent: CardFieldState;
|
|
30
42
|
presentation: CardFieldState;
|
|
43
|
+
guardEnabled: CardFieldState;
|
|
44
|
+
guardSensitivity: CardFieldState;
|
|
45
|
+
guardStallReasoningChars: CardFieldState;
|
|
46
|
+
guardGlobalStallCap: CardFieldState;
|
|
47
|
+
guardEchoFailures: CardFieldState;
|
|
31
48
|
}
|
|
32
49
|
/** The registration-side face the card's slot entry injects. */
|
|
33
50
|
export interface LiangShenSettingsCardFace extends CardActions {
|
|
@@ -36,12 +53,12 @@ export interface LiangShenSettingsCardFace extends CardActions {
|
|
|
36
53
|
liangShenSettingsCard: SnapshotStore<LiangShenSettingsCardState>;
|
|
37
54
|
};
|
|
38
55
|
}
|
|
39
|
-
/** Bridges the `
|
|
56
|
+
/** Bridges the `liangshen` settings form onto the card's staged form. */
|
|
40
57
|
export declare class LiangShenSettingsCardController {
|
|
41
58
|
private readonly form;
|
|
42
59
|
private readonly store;
|
|
43
|
-
/** @param scope - the bound
|
|
44
|
-
constructor(scope:
|
|
60
|
+
/** @param scope - the bound configuration form of the entry that owns this namespace. */
|
|
61
|
+
constructor(scope: ConfigForm<LiangShenSettings>);
|
|
45
62
|
private projection;
|
|
46
63
|
/**
|
|
47
64
|
* Build the face the card's slot registration injects.
|
|
@@ -47,6 +47,10 @@ export interface PluginSettingsCardProps<TKey extends string = string> {
|
|
|
47
47
|
* edits, so the footer would sit there permanently disabled.
|
|
48
48
|
*/
|
|
49
49
|
hideFooter?: boolean;
|
|
50
|
+
/** Render children even when the settings namespace is not exposed by the host. */
|
|
51
|
+
renderChildrenWhenNotExposed?: boolean;
|
|
52
|
+
/** Hide the 'not exposed' warning banner when the settings namespace is not exposed. */
|
|
53
|
+
hideNotExposedNotice?: boolean;
|
|
50
54
|
/** The plugin's controls. */
|
|
51
55
|
children: ReactNode;
|
|
52
56
|
}
|
|
@@ -18,12 +18,18 @@
|
|
|
18
18
|
* thrown — one external plugin must not take the GUI boot down.
|
|
19
19
|
*/
|
|
20
20
|
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
21
|
-
import type {
|
|
21
|
+
import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
22
22
|
import { type LiangShenKey } from './locales.ts';
|
|
23
23
|
/** Locale namespace this half owns. */
|
|
24
24
|
export declare const NS = "liangshen";
|
|
25
|
-
/**
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Settings namespace the settings card edits. Under the 0.1.7 settings
|
|
27
|
+
* contract the namespace IS the Host profile entry id, so this names the
|
|
28
|
+
* standalone row; the aggregate install mounts the generated
|
|
29
|
+
* `web-ui-liangshen` row instead and the family binder resolves between the
|
|
30
|
+
* two. Without that binder the card binds the entry id directly.
|
|
31
|
+
*/
|
|
32
|
+
export declare const SETTINGS_NAMESPACE = "liangshen";
|
|
27
33
|
/** Owner share of a plugin card (the section supplies nothing). */
|
|
28
34
|
export interface SettingsPluginItemOwnerProps {
|
|
29
35
|
/** Marker field: card owner props are intentionally empty. */
|
|
@@ -33,8 +39,9 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
33
39
|
interface SlotMap {
|
|
34
40
|
/**
|
|
35
41
|
* The child slot the Web UI plugin group declares; this card registers into
|
|
36
|
-
* the group
|
|
37
|
-
* here so this package needs no dependency on the sibling UI
|
|
42
|
+
* the group's list seat rather than the official bundle-configuration
|
|
43
|
+
* seat. Declared here so this package needs no dependency on the sibling UI
|
|
44
|
+
* package.
|
|
38
45
|
*/
|
|
39
46
|
'web-ui.plugin.item': {
|
|
40
47
|
kind: 'list';
|
|
@@ -46,20 +53,32 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
46
53
|
declare module '@deepseek-ai/cordis' {
|
|
47
54
|
interface Context {
|
|
48
55
|
/**
|
|
49
|
-
* Optional
|
|
50
|
-
* that group plugin is not installed, so callers
|
|
51
|
-
*
|
|
56
|
+
* Optional family settings binder provided by dsh-web-settings; absent when
|
|
57
|
+
* that group plugin is not installed, so callers bind the shared forms
|
|
58
|
+
* service (`ctx.configForms`) by profile entry id directly.
|
|
52
59
|
*/
|
|
53
60
|
webUiSettings?: {
|
|
54
|
-
bind<S>(spec:
|
|
61
|
+
bind<S>(spec: LiangShenFormSpec<S>): ConfigForm<S>;
|
|
55
62
|
};
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
|
|
66
|
+
* One settings namespace a family card binds. The 0.1.7 client exports no spec
|
|
67
|
+
* type (the form controller takes it privately), so the binder's input shape is
|
|
68
|
+
* restated here.
|
|
69
|
+
*/
|
|
70
|
+
export interface LiangShenFormSpec<T> {
|
|
71
|
+
/** Settings namespace registered by the owning host plugin. */
|
|
72
|
+
namespace: string;
|
|
73
|
+
/** Narrow one wire section; undefined keeps the last accepted value. */
|
|
74
|
+
decode?: (section: unknown) => T | undefined;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Required client services: the slot registry, locale, sessions, the shared
|
|
78
|
+
* configuration forms, and the roster Remote. Both `remote` and
|
|
79
|
+
* `remote.agentPresets` are declared: the context proxy refuses an uninjected
|
|
80
|
+
* service, and a nested service name does not imply its parent, so reading
|
|
81
|
+
* `ctx.remote.agentPresets` needs `remote` as well.
|
|
63
82
|
*/
|
|
64
83
|
export declare const inject: string[];
|
|
65
84
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The view stays pure; every fact and verb comes from here. The roster arrives
|
|
5
5
|
* over the agent-preset Remote namespace (the same one the official surfaces
|
|
6
|
-
* read), the
|
|
6
|
+
* read), the main-view session comes from the catalog's ownership marker, and the
|
|
7
7
|
* switch goes through `agentPresets.select`, which the host accepts only while
|
|
8
8
|
* the session is still blank.
|
|
9
9
|
*
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* default.
|
|
15
15
|
*/
|
|
16
16
|
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
17
|
-
import type { AgentPresetRoster } from '@deepseek-ai/dsh-agent-
|
|
17
|
+
import type { AgentPresetRoster } from '@deepseek-ai/dsh-agent-preset-registry/types';
|
|
18
18
|
import type { RemoteResult } from '@deepseek-ai/dsh-api-remotes/client';
|
|
19
19
|
import { type SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
20
20
|
import { type LeverState } from '../core/lever.ts';
|
|
@@ -47,6 +47,14 @@ export type LeverError =
|
|
|
47
47
|
};
|
|
48
48
|
/** How long one preset switch may stay in flight before it is reported as timed out. */
|
|
49
49
|
export declare const SELECT_TIMEOUT_MS = 10000;
|
|
50
|
+
/**
|
|
51
|
+
* Settings entry ids whose writes can move the roster this lever reads: the
|
|
52
|
+
* agent-preset registry's own entry (its default and selection policy) and this
|
|
53
|
+
* plugin's row under either install shape — the aggregate's generated row id
|
|
54
|
+
* and the standalone row id — because disabling the plugin unregisters the
|
|
55
|
+
* preset it declares.
|
|
56
|
+
*/
|
|
57
|
+
export declare const ROSTER_SETTINGS_ENTRY_IDS: readonly string[];
|
|
50
58
|
/** What the lever view renders. */
|
|
51
59
|
export interface LeverSnapshot {
|
|
52
60
|
/** Resolved lever state. */
|
|
@@ -119,6 +127,12 @@ export declare class LeverController {
|
|
|
119
127
|
refresh(): void;
|
|
120
128
|
/** The verb behind one gesture direction. */
|
|
121
129
|
private toggle;
|
|
130
|
+
/**
|
|
131
|
+
* Try to detect the active preset from the DOM hero chip or storage
|
|
132
|
+
* when session.projectionValues.agentPreset is absent.
|
|
133
|
+
*/
|
|
134
|
+
private detectPreset;
|
|
135
|
+
private rememberPrevious;
|
|
122
136
|
/** The facts one decision reads, from the live session and the roster. */
|
|
123
137
|
private facts;
|
|
124
138
|
private currentSessionId;
|
|
@@ -46,6 +46,19 @@ export declare const zh: {
|
|
|
46
46
|
'presentation.ptc': string;
|
|
47
47
|
'presentation.native': string;
|
|
48
48
|
'presentation.both': string;
|
|
49
|
+
'settings.guardEnabled': string;
|
|
50
|
+
'settings.guardEnabledHint': string;
|
|
51
|
+
'settings.guardStallChars': string;
|
|
52
|
+
'settings.guardStallCharsHint': string;
|
|
53
|
+
'settings.guardGlobalCap': string;
|
|
54
|
+
'settings.guardGlobalCapHint': string;
|
|
55
|
+
'settings.guardSensitivity': string;
|
|
56
|
+
'settings.guardSensitivityHint': string;
|
|
57
|
+
'sensitivity.conservative': string;
|
|
58
|
+
'sensitivity.balanced': string;
|
|
59
|
+
'sensitivity.aggressive': string;
|
|
60
|
+
'settings.guardEchoFailures': string;
|
|
61
|
+
'settings.guardEchoFailuresHint': string;
|
|
49
62
|
};
|
|
50
63
|
/** English counterpart; the key set mirrors {@link zh} exactly. */
|
|
51
64
|
export declare const en: Record<keyof typeof zh, string>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main-view Session derivation for the multi-instance Client Session model.
|
|
3
|
+
*
|
|
4
|
+
* The Client Session Controller carries no global "current" selection: view
|
|
5
|
+
* selection belongs to the workspace UI, which owns the main-area reference and
|
|
6
|
+
* publishes it through the catalog's per-source ownership counts
|
|
7
|
+
* (`SessionSummary.retainedBy.mainView`). A plugin that needs the Session the
|
|
8
|
+
* main view shows derives it from that marker instead of the removed
|
|
9
|
+
* `SessionListState.current` field.
|
|
10
|
+
*
|
|
11
|
+
* The marker describes view ownership, not authority. It is the right input for
|
|
12
|
+
* presentation and for deciding which view a navigation targets; it is not a
|
|
13
|
+
* business fallback, because source counts never imply visibility or success.
|
|
14
|
+
* @module dsh-web/shared/main-session
|
|
15
|
+
*/
|
|
16
|
+
/** The catalog row subset this helper reads (a `SessionSummary` projection). */
|
|
17
|
+
export interface MainViewOwnedRow<Id extends string = string> {
|
|
18
|
+
/** Catalog row identity. */
|
|
19
|
+
readonly id: Id;
|
|
20
|
+
/** Per-source local ownership counts; absent rows are never owned. */
|
|
21
|
+
readonly retainedBy?: Readonly<Partial<Record<string, number>>> | undefined;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the Session the main view currently shows.
|
|
25
|
+
*
|
|
26
|
+
* Reads the catalog's rows rather than a per-id retain-info source: ownership
|
|
27
|
+
* counts ride the list snapshot, so this neither allocates observers nor opens
|
|
28
|
+
* history, and a subscription to the list still fires when the selection moves.
|
|
29
|
+
* @param byId - the session catalog's rows (`SessionListState.byId`), when available.
|
|
30
|
+
* @returns the main-view session id, or undefined when the main view shows none.
|
|
31
|
+
*/
|
|
32
|
+
export declare function mainViewSessionId<Id extends string>(byId: Readonly<Record<Id, MainViewOwnedRow<Id> | undefined>> | undefined | null): Id | undefined;
|
|
@@ -6,22 +6,24 @@
|
|
|
6
6
|
*
|
|
7
7
|
* - `web-ui.plugin.item` — the list seat declared by the dsh-web-settings
|
|
8
8
|
* group section (this family's own first-level "Web UI plugins" section);
|
|
9
|
-
* - `
|
|
10
|
-
*
|
|
9
|
+
* - `plugins.bundle.config` — the official keyed seat of the harness's plugin
|
|
10
|
+
* manager page, keyed by the bundle's package name and rendered on that
|
|
11
|
+
* bundle's page. alpha.2 removed the `settings.plugin.item` keyed seat of the
|
|
12
|
+
* `ui-settings-plugins` tab that this helper used before, so a card keyed by
|
|
13
|
+
* its settings namespace has no seat to land in any more.
|
|
11
14
|
*
|
|
12
|
-
* SEAT SELECTION IS NOT A DECLARATION PROBE. The official
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* heading and zero cards.
|
|
15
|
+
* SEAT SELECTION IS NOT A DECLARATION PROBE. The official plugin surface
|
|
16
|
+
* belongs to the harness bundle and declares its seats before any external
|
|
17
|
+
* plugin's `apply()` runs, so "is the official seat declared?" answers yes even
|
|
18
|
+
* in the deployment whose whole point is the family group. Choosing on that
|
|
19
|
+
* probe sends every family card to the official page and leaves the group's own
|
|
20
|
+
* section permanently empty — the family of reports where the section renders
|
|
21
|
+
* its heading and zero cards.
|
|
20
22
|
*
|
|
21
23
|
* The signal that actually distinguishes the two deployments is whether
|
|
22
24
|
* dsh-web-settings is loaded: it is the package that owns the group section and
|
|
23
25
|
* it publishes the `webUiSettings` service during `apply()`, which every
|
|
24
|
-
* family plugin already reads for its settings
|
|
26
|
+
* family plugin already reads for its settings form. Group loaded -> the family
|
|
25
27
|
* seat; group absent -> the official seat.
|
|
26
28
|
*
|
|
27
29
|
* The decision is re-evaluated on every `slots/changed` because the group may
|
|
@@ -37,8 +39,8 @@
|
|
|
37
39
|
*/
|
|
38
40
|
/** The family list seat key. */
|
|
39
41
|
export declare const FAMILY_PLUGIN_CARD_SEAT = "web-ui.plugin.item";
|
|
40
|
-
/** The official keyed plugin-card seat key. */
|
|
41
|
-
export declare const OFFICIAL_PLUGIN_CARD_SEAT = "
|
|
42
|
+
/** The official keyed plugin-card seat key (the alpha.2 bundle-configuration seat). */
|
|
43
|
+
export declare const OFFICIAL_PLUGIN_CARD_SEAT = "plugins.bundle.config";
|
|
42
44
|
/** The service dsh-web-settings publishes while it is loaded. */
|
|
43
45
|
export declare const FAMILY_GROUP_SERVICE = "webUiSettings";
|
|
44
46
|
/** The slot-registry member this helper uses (structurally satisfied by ctx.slots). */
|
|
@@ -54,15 +56,20 @@ export interface PluginCardContext {
|
|
|
54
56
|
/** Event subscription seat; absent on an event-less test double. */
|
|
55
57
|
on?(event: string, listener: (...args: never[]) => void): unknown;
|
|
56
58
|
}
|
|
57
|
-
/** Owner share of a
|
|
59
|
+
/** Owner share of a family list-seat card (that seat supplies nothing). */
|
|
58
60
|
export interface SettingsPluginItemOwnerProps {
|
|
59
61
|
/** Marker field: card owner props are intentionally empty. */
|
|
60
62
|
children?: never;
|
|
61
63
|
}
|
|
62
64
|
/** One family plugin's card contribution. */
|
|
63
65
|
export interface PluginCardSeat {
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Npm package name of the bundle this card configures; the official keyed
|
|
68
|
+
* seat dispatches on it. Every family package ships its own bundle patch, so
|
|
69
|
+
* a standalone install lists that package as the bundle whose page renders
|
|
70
|
+
* this card.
|
|
71
|
+
*/
|
|
72
|
+
bundle: string;
|
|
66
73
|
/** Family list-seat entry id. */
|
|
67
74
|
id: string;
|
|
68
75
|
/** Family list-seat sort order. */
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* each plugin's client bundle; mirrors the official ui-plugin-config
|
|
7
7
|
* card-store pattern.
|
|
8
8
|
*/
|
|
9
|
-
import type {
|
|
9
|
+
import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
10
10
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
11
11
|
/** The write one field's staged text performs when the card is saved. */
|
|
12
12
|
export type FieldWrite = {
|
|
@@ -86,7 +86,7 @@ export interface CardActions {
|
|
|
86
86
|
/** Drop every staged edit. */
|
|
87
87
|
discard: () => void;
|
|
88
88
|
}
|
|
89
|
-
/** One durable write inside the save's atomic
|
|
89
|
+
/** One durable write inside the save's atomic form mutation. */
|
|
90
90
|
export interface BatchedWrite {
|
|
91
91
|
/** Field this entry writes. */
|
|
92
92
|
field: string;
|
|
@@ -130,20 +130,20 @@ export declare class CardForm<T> {
|
|
|
130
130
|
private readonly specs;
|
|
131
131
|
private readonly staged;
|
|
132
132
|
private readonly listeners;
|
|
133
|
-
/** The
|
|
134
|
-
private readonly
|
|
133
|
+
/** The form subscription installed in the constructor; released by dispose(). */
|
|
134
|
+
private readonly disposeForm;
|
|
135
135
|
private disposed;
|
|
136
136
|
private saving;
|
|
137
137
|
private failed;
|
|
138
138
|
private failedReason;
|
|
139
|
-
/** @param scope - the bound
|
|
140
|
-
constructor(scope:
|
|
139
|
+
/** @param scope - the bound configuration form for this card's namespace. */
|
|
140
|
+
constructor(scope: ConfigForm<T>, specs: FieldSpec[]);
|
|
141
141
|
/**
|
|
142
|
-
* Release the
|
|
142
|
+
* Release the form subscription and every bound store listener. The card
|
|
143
143
|
* must call this on teardown; later calls are no-ops.
|
|
144
144
|
*/
|
|
145
145
|
dispose(): void;
|
|
146
|
-
/** Publish a projection of this form, rebuilt whenever the
|
|
146
|
+
/** Publish a projection of this form, rebuilt whenever the form or a draft changes. */
|
|
147
147
|
bind<S>(project: () => S): SnapshotStore<S>;
|
|
148
148
|
/** Read the card-level state: what the Host serves, and what a save would do. */
|
|
149
149
|
shell(): CardShell;
|
|
@@ -152,19 +152,19 @@ export declare class CardForm<T> {
|
|
|
152
152
|
/** The actions the card's slot registration injects. */
|
|
153
153
|
actions(): CardActions;
|
|
154
154
|
/**
|
|
155
|
-
* Write every staged edit in one atomic
|
|
155
|
+
* Write every staged edit in one atomic form mutation, then re-seed from
|
|
156
156
|
* what the Host accepted.
|
|
157
157
|
*
|
|
158
158
|
* The whole batch rides one mutate, so cross-field validate hooks
|
|
159
159
|
* (baseURL+model) judge it as a unit: the Host either applies every write
|
|
160
|
-
* or refuses the batch. The
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* settled snapshot back
|
|
164
|
-
* fails the whole save. A
|
|
165
|
-
*
|
|
166
|
-
* message. A save that did not land keeps its drafts, so
|
|
167
|
-
* correct them instead of retyping.
|
|
160
|
+
* or refuses the batch. The form contract answers a refusal or a skipped
|
|
161
|
+
* write with `false` (it recovers with a fresh Host view instead of
|
|
162
|
+
* throwing), so the outcome is judged twice: the answer itself, and then the
|
|
163
|
+
* settled snapshot read back one planned write at a time. One missed write
|
|
164
|
+
* fails the whole save. A transport that rejects instead (the dsh-web bridge
|
|
165
|
+
* controller on a dead connection) reports through the same failure path
|
|
166
|
+
* with its rejection message. A save that did not land keeps its drafts, so
|
|
167
|
+
* the user can correct them instead of retyping.
|
|
168
168
|
* @returns settlement after the mutation and the read-back.
|
|
169
169
|
*/
|
|
170
170
|
save(): Promise<void>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The LiangShen preset's composition reader: just enough YAML to turn the
|
|
3
|
+
* bundled `presets/liangshen/agent.cordis.yml` — and the flat `preset.yml`
|
|
4
|
+
* display map beside it — into the declaration the agent-preset registry takes.
|
|
5
|
+
*
|
|
6
|
+
* Under 0.1.7 a preset is an ordinary registry declaration instead of a
|
|
7
|
+
* directory the harness discovers, so this plugin hands `ctx.agentPresets` the
|
|
8
|
+
* rows of its OWN composition. No YAML package is resolvable from this package
|
|
9
|
+
* and the harness's reader is not importable from here, so the subset is owned
|
|
10
|
+
* here; the shipped composition is the only file it must read, and tests fence
|
|
11
|
+
* it against that whole file. Supported: block maps and sequences, quoted and
|
|
12
|
+
* plain scalars, single-line flow sequences, literal and folded block scalars,
|
|
13
|
+
* comments, and `!!js` expressions preserved as data (`{ __jsExpr }`, the shape
|
|
14
|
+
* the Loader itself hands a plugin).
|
|
15
|
+
*
|
|
16
|
+
* Fail-closed: a construct outside the subset — anchors, aliases, tags other
|
|
17
|
+
* than `!!js`, nested flow collections, multiple documents, tabs — raises
|
|
18
|
+
* {@link CompositionError} rather than being guessed at, so an unreadable
|
|
19
|
+
* composition is refused instead of half-declared.
|
|
20
|
+
*
|
|
21
|
+
* Relative module names (`name: ./minimal-prompt.mjs`) are resolved against
|
|
22
|
+
* the preset directory handed to {@link readCompositionRows} and emitted as
|
|
23
|
+
* file URLs: the registry mounts a declaration under the DECLARING LOADER's
|
|
24
|
+
* base, so a relative name would otherwise be resolved outside this package.
|
|
25
|
+
* @module @linxin666/dsh-liangshen/composition
|
|
26
|
+
*/
|
|
27
|
+
import type { PresetDefinition } from '@deepseek-ai/dsh-agent-preset-registry';
|
|
28
|
+
/** A construct outside the supported subset, or malformed YAML. */
|
|
29
|
+
export declare class CompositionError extends Error {
|
|
30
|
+
constructor(message: string);
|
|
31
|
+
}
|
|
32
|
+
/** A Loader `!!js` expression preserved as data instead of executed. */
|
|
33
|
+
export interface JsExpression {
|
|
34
|
+
__jsExpr: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* One parsed composition row. Deliberately loose: the Loader owns each child
|
|
38
|
+
* plugin's own schema, and this reader only has to preserve what the file says.
|
|
39
|
+
*/
|
|
40
|
+
export interface CompositionRow {
|
|
41
|
+
/** Row id; the settings overlay and the Loader's patch index address a row by it. */
|
|
42
|
+
id?: string;
|
|
43
|
+
/** Module specifier: a bare package name, a `cordis:` builtin, or a relative path. */
|
|
44
|
+
name?: string;
|
|
45
|
+
/** Whether this row's `config` is a nested entry list. */
|
|
46
|
+
group?: boolean;
|
|
47
|
+
/** Boolean or `!!js` expression. */
|
|
48
|
+
disabled?: unknown;
|
|
49
|
+
/** Shared-realm declarations of the group this row opens. */
|
|
50
|
+
isolate?: unknown;
|
|
51
|
+
/** Row configuration, or the nested entry list of a group row. */
|
|
52
|
+
config?: unknown;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Read the child plugin rows of one `agent.cordis.yml`.
|
|
56
|
+
* @param text - the raw composition document.
|
|
57
|
+
* @param baseDir - directory a relative row `name` resolves against (the preset's own directory).
|
|
58
|
+
* @returns the row list to hand the registry, relative names resolved to file URLs.
|
|
59
|
+
* @throws {CompositionError} on malformed YAML or a row the registry would reject.
|
|
60
|
+
*/
|
|
61
|
+
export declare function readCompositionRows(text: string, baseDir: string): PresetDefinition['plugins'];
|
|
62
|
+
/** The display text `preset.yml` contributes to a declaration. */
|
|
63
|
+
export interface PresetMetadata {
|
|
64
|
+
/** Display name the roster shows. */
|
|
65
|
+
name?: string;
|
|
66
|
+
/** One sentence on what the preset is for. */
|
|
67
|
+
description?: string;
|
|
68
|
+
/** Roster ordering rank. */
|
|
69
|
+
order?: number;
|
|
70
|
+
}
|
|
71
|
+
/** Read the single-line display scalars of one `preset.yml`. */
|
|
72
|
+
export declare function readPresetMetadata(text: string): PresetMetadata;
|
|
73
|
+
/**
|
|
74
|
+
* Build the registry declaration of one preset directory.
|
|
75
|
+
* @param id - preset identity the roster keys the declaration by.
|
|
76
|
+
* @param dir - absolute preset directory holding `agent.cordis.yml` and `preset.yml`.
|
|
77
|
+
* @returns the definition to submit to `ctx.agentPresets.register`.
|
|
78
|
+
* @throws {CompositionError} when either file is missing, unreadable, or unparsable.
|
|
79
|
+
*/
|
|
80
|
+
export declare function readPresetDefinition(id: string, dir: string): PresetDefinition;
|
|
81
|
+
/**
|
|
82
|
+
* The preset-row settings the plugin exposes in the web settings surface, as the
|
|
83
|
+
* values to apply to the declared composition.
|
|
84
|
+
*
|
|
85
|
+
* The settings surface edits the PLUGIN's own Config, while the values that
|
|
86
|
+
* shape a session live in the declared preset's rows; applying them here is what
|
|
87
|
+
* connects the two. Every field is optional — an absent value leaves the shipped
|
|
88
|
+
* row exactly as the composition declares it.
|
|
89
|
+
*/
|
|
90
|
+
export interface PresetOverrides {
|
|
91
|
+
/** The `tool-catalog` row's `presentation` value. */
|
|
92
|
+
presentation?: string;
|
|
93
|
+
/** The `guard` row's `enabled` switch. */
|
|
94
|
+
guardEnabled?: boolean;
|
|
95
|
+
/** The `guard` row's sensitivity preset. */
|
|
96
|
+
guardSensitivity?: string;
|
|
97
|
+
/** The `guard` row's per-step reasoning-character floor. */
|
|
98
|
+
guardStallReasoningChars?: number;
|
|
99
|
+
/** The `guard` row's slow-burn step cap. */
|
|
100
|
+
guardGlobalStallCap?: number;
|
|
101
|
+
/** The `guard` row's identical-argument failure count. */
|
|
102
|
+
guardEchoFailures?: number;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Apply the settings overlay to one parsed row list.
|
|
106
|
+
*
|
|
107
|
+
* Rows are addressed by their `id`, and only a row the composition actually
|
|
108
|
+
* carries is touched: the overlay narrows the shipped configuration, it never
|
|
109
|
+
* invents a mount the preset did not have. The shipped composition declares
|
|
110
|
+
* every key the overlay writes, so leaving a key absent only matters for a
|
|
111
|
+
* composition that dropped it.
|
|
112
|
+
* @param rows - the parsed composition rows.
|
|
113
|
+
* @param overrides - the operator's settings-surface choices.
|
|
114
|
+
* @returns a new row list with the overlay applied.
|
|
115
|
+
*/
|
|
116
|
+
export declare function applyPresetOverrides(rows: PresetDefinition['plugins'], overrides: PresetOverrides): PresetDefinition['plugins'];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The composition reader the preset declaration is built from. It is the only
|
|
3
|
+
* thing standing between the shipped `agent.cordis.yml` and the registry, and
|
|
4
|
+
* it must not guess: these tests fence the supported subset against the real
|
|
5
|
+
* file, the settings overlay, and every construct it refuses.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|