@linxin666/dsh-liangshen 0.3.22 → 0.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +45 -38
  3. package/README.zh.md +44 -37
  4. package/lib/client.js +1058 -11
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +105 -22
  7. package/lib/types/client/LiangShenSettingsCard.d.ts +61 -0
  8. package/lib/types/client/PluginSettingsCard.d.ts +133 -0
  9. package/lib/types/client/index.d.ts +34 -0
  10. package/lib/types/client/locales.d.ts +27 -1
  11. package/lib/types/client/plugin-card-seat.d.ts +96 -0
  12. package/lib/types/client/settings-form.d.ts +197 -0
  13. package/lib/types/core/lever.d.ts +6 -3
  14. package/lib/types/index.d.ts +23 -11
  15. package/lib/types/sync.d.ts +29 -2
  16. package/package.json +6 -2
  17. package/presets/liangshen/NOTICE +4 -4
  18. package/presets/liangshen/agent.cordis.yml +130 -119
  19. package/presets/liangshen/minimal-prompt.mjs +71 -36
  20. package/presets/liangshen/paging.mjs +232 -0
  21. package/presets/liangshen/tool-activate.mjs +176 -0
  22. package/presets/liangshen/tool-catalog.mjs +610 -218
  23. package/presets/liangshen/working-context.mjs +214 -0
  24. package/src/client/LiangShenLever.tsx +4 -1
  25. package/src/client/LiangShenSettingsCard.tsx +149 -0
  26. package/src/client/PluginSettingsCard.tsx +550 -0
  27. package/src/client/index.ts +60 -1
  28. package/src/client/locales.ts +53 -1
  29. package/src/client/plugin-card-seat.ts +185 -0
  30. package/src/client/settings-card.module.css +418 -0
  31. package/src/client/settings-form.ts +439 -0
  32. package/src/core/lever.ts +7 -4
  33. package/src/index.ts +35 -14
  34. package/src/sync.test.ts +86 -7
  35. package/src/sync.ts +108 -6
  36. package/tools/benchmark-live-run.mjs +24 -33
  37. package/presets/liangshen/custom-bash.mjs +0 -213
@@ -0,0 +1,61 @@
1
+ /**
2
+ * LiangShen settings card: availability and the wire presentation. Registers
3
+ * into the `web-ui.plugin.item` child slot the Web UI plugin group renders,
4
+ * bound to the `dsh-liangshen` namespace.
5
+ *
6
+ * The presentation field does not act on this client half: the Host writes it
7
+ * into the synced preset composition, so a session reads it from its preset.
8
+ * This card is the operator's only handle on it, which is why every field the
9
+ * Host schema carries appears here.
10
+ */
11
+ import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
12
+ import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
13
+ import type { SettingsScope } from '@deepseek-ai/dsh-client-ui-settings/client';
14
+ import { type CardActions, type CardShell, type FieldState as CardFieldState } from './settings-form.ts';
15
+ /** Wire presentations the tool catalog accepts (mirrors the Host schema). */
16
+ export declare const PRESENTATION_CHOICES: readonly ["ptc", "native", "both"];
17
+ /** The LiangShen fields this card edits (the namespace's full schema). */
18
+ export interface LiangShenSettings {
19
+ /** Master switch for the plugin. */
20
+ enabled?: boolean;
21
+ /** Whether the plugin announces itself in every agent's system prompt. */
22
+ announceToAgent?: boolean;
23
+ /** Wire presentation written into the synced preset. */
24
+ presentation?: string;
25
+ }
26
+ /** What the LiangShen card renders. */
27
+ export interface LiangShenSettingsCardState extends CardShell {
28
+ enabled: CardFieldState;
29
+ announceToAgent: CardFieldState;
30
+ presentation: CardFieldState;
31
+ }
32
+ /** The registration-side face the card's slot entry injects. */
33
+ export interface LiangShenSettingsCardFace extends CardActions {
34
+ hooks: {
35
+ /** Card snapshot bound by the renderer as useLiangShenSettingsCard. */
36
+ liangShenSettingsCard: SnapshotStore<LiangShenSettingsCardState>;
37
+ };
38
+ }
39
+ /** Bridges the `dsh-liangshen` scope onto the card's staged form. */
40
+ export declare class LiangShenSettingsCardController {
41
+ private readonly form;
42
+ private readonly store;
43
+ /** @param scope - the bound settings scope for the `dsh-liangshen` namespace. */
44
+ constructor(scope: SettingsScope<LiangShenSettings>);
45
+ private projection;
46
+ /**
47
+ * Build the face the card's slot registration injects.
48
+ * @returns the card's snapshot and its form actions.
49
+ */
50
+ inject(): LiangShenSettingsCardFace;
51
+ /** Release the card's scope subscription and bound stores. */
52
+ dispose(): void;
53
+ }
54
+ /** Props the renderer binds for the LiangShen card. */
55
+ export type LiangShenSettingsCardProps = PropsRuntime<'web-ui.plugin.item'> & PropsLocale<'liangshen'> & InjectFace<LiangShenSettingsCardFace>;
56
+ /**
57
+ * Render the LiangShen card.
58
+ * @param props - locale copy, the card snapshot, and its form actions.
59
+ * @returns the card.
60
+ */
61
+ export declare function LiangShenSettingsCard(props: LiangShenSettingsCardProps): import("react").JSX.Element;
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Family-shared chrome for plugin settings cards: a disclosure header naming
3
+ * the plugin and what its settings govern, the controls inside, and the save
4
+ * that writes them. Renders nothing while the namespace is unavailable — a
5
+ * deployment that does not compose the owning plugin should show no trace of
6
+ * it. Inlined into each consumer's client bundle; mirrors the official
7
+ * ui-plugin-config PluginCard in a self-contained slice.
8
+ */
9
+ import { type ReactNode } from 'react';
10
+ import type { CardShell } from './settings-form.ts';
11
+ /** Copy keys the card chrome itself reads; every consumer locale carries this shared vocabulary. */
12
+ export declare const CARD_COPY_KEYS: readonly ["settings.collapse", "settings.expand", "settings.notExposed", "settings.unsaved", "settings.readOnly", "settings.saveFailed", "settings.discard", "settings.save", "settings.saving"];
13
+ /** Copy key the card chrome itself reads. */
14
+ export type CardCopyKey = (typeof CARD_COPY_KEYS)[number];
15
+ /** Key domain for the plugin's own copy (inferred per consumer). */
16
+ export type SettingsCardKey<TKey extends string = string> = TKey | CardCopyKey;
17
+ /** Card chrome shared by every plugin settings card. */
18
+ export interface PluginSettingsCardProps<TKey extends string = string> {
19
+ /** Locale reader for this card's copy. */
20
+ t: (key: SettingsCardKey<TKey>, params?: Record<string, string | number>) => string;
21
+ /** Locale key of the plugin's name. */
22
+ titleKey: TKey;
23
+ /** Locale key of the line describing what this plugin's settings govern. */
24
+ descriptionKey: TKey;
25
+ /** Optional rich header description rendered instead of the plain t(descriptionKey) text (the plain text stays as the tooltip). */
26
+ descriptionNode?: ReactNode;
27
+ /** The card's form state: availability, writability, and what a save would do. */
28
+ state: CardShell;
29
+ /** Write every staged edit. */
30
+ onSave: () => void;
31
+ /** Drop every staged edit. */
32
+ onDiscard: () => void;
33
+ /**
34
+ * Render the controls expanded on arrival (still collapsible). Defaults to
35
+ * true: promoted first-level sections show their settings immediately.
36
+ */
37
+ defaultOpen?: boolean;
38
+ /**
39
+ * Render without the collapse affordance: a static header and an always
40
+ * visible body. Used by first-level settings sections whose nav entry
41
+ * already provides the selection.
42
+ */
43
+ alwaysOpen?: boolean;
44
+ /**
45
+ * Hide the save/discard footer: cards whose body applies its own changes
46
+ * immediately (an embedded external settings section) have no staged
47
+ * edits, so the footer would sit there permanently disabled.
48
+ */
49
+ hideFooter?: boolean;
50
+ /** The plugin's controls. */
51
+ children: ReactNode;
52
+ }
53
+ /**
54
+ * Render one plugin settings card.
55
+ * @param props - the plugin's copy keys, its form state, and its controls.
56
+ * @returns the card, or nothing while the namespace is still loading.
57
+ */
58
+ export declare function PluginSettingsCard<TKey extends string = string>(props: PluginSettingsCardProps<TKey>): import("react").JSX.Element | null;
59
+ /** Props every field control needs regardless of its value type. */
60
+ export interface FieldProps {
61
+ /** Stable id associating the label with its control. */
62
+ id: string;
63
+ /** Visible label. */
64
+ label: string;
65
+ /** One-line explanation rendered under the control. */
66
+ hint: string;
67
+ /** Draft text this control renders. */
68
+ text: string;
69
+ /** True when saving would leave a user-layer entry for this field. */
70
+ overridden: boolean;
71
+ /** True when the draft is not a value this field accepts. */
72
+ invalid: boolean;
73
+ /** Copy for the overridden badge. */
74
+ overriddenLabel: string;
75
+ /** Copy for the reset control. */
76
+ resetLabel: string;
77
+ /** Copy shown in place of the hint while the draft is invalid. */
78
+ invalidLabel: string;
79
+ /** Disables every control (read-only document, or an unavailable namespace). */
80
+ disabled: boolean;
81
+ /** Stage draft text. */
82
+ onEdit: (text: string) => void;
83
+ /** Stage a clear so the field re-inherits the composition layer. */
84
+ onReset: () => void;
85
+ }
86
+ /** A staged value field. `numeric` only hints the keypad: which drafts a field accepts is decided by its spec. */
87
+ export declare function ValueField(props: FieldProps & {
88
+ /** Hints a numeric keypad without narrowing what the control accepts. */
89
+ numeric?: boolean;
90
+ /** Placeholder shown while the draft is empty. */
91
+ placeholder?: string;
92
+ }): import("react").JSX.Element;
93
+ interface SelectOption {
94
+ value: string;
95
+ label: string;
96
+ }
97
+ /**
98
+ * The shared dual-mode select control. While an appearance skin is active it
99
+ * renders the legacy native `<select>` untouched, so element-level skin
100
+ * selectors keep working; under the default appearance it renders a
101
+ * self-drawn `role="listbox"` popup whose open/close is transition-animated.
102
+ * Staged cards reach it through BooleanField/ChoiceField; immediate-apply
103
+ * editors (the side-card prefs) bind it directly through onEdit.
104
+ * 双模式下拉框:皮肤激活时用原生 select,默认外观用自绘动画弹层。
105
+ */
106
+ export declare function SelectField(props: {
107
+ id: string;
108
+ options: ReadonlyArray<SelectOption>;
109
+ value: string;
110
+ disabled: boolean;
111
+ invalid: boolean;
112
+ onEdit: (text: string) => void;
113
+ }): import("react").JSX.Element;
114
+ /** A staged boolean field: 继承 / 开 / 关. */
115
+ export declare function BooleanField(props: FieldProps & {
116
+ /** Copy for the inherit option. */
117
+ inheritLabel: string;
118
+ /** Copy for the on option. */
119
+ onLabel: string;
120
+ /** Copy for the off option. */
121
+ offLabel: string;
122
+ }): import("react").JSX.Element;
123
+ /** A staged enumerated field rendered as a select. */
124
+ export declare function ChoiceField(props: FieldProps & {
125
+ /** Copy for the inherit option (draft text is the empty string). */
126
+ inheritLabel: string;
127
+ /** Choices rendered in order; `value` is the draft/stored text. */
128
+ choices: ReadonlyArray<{
129
+ value: string;
130
+ label: string;
131
+ }>;
132
+ }): import("react").JSX.Element;
133
+ export {};
@@ -18,9 +18,43 @@
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 { SettingsScopeSpec } from '@deepseek-ai/dsh-client-ui-settings/client';
21
22
  import { type LiangShenKey } from './locales.ts';
22
23
  /** Locale namespace this half owns. */
23
24
  export declare const NS = "liangshen";
25
+ /** Settings namespace the settings card edits (the Host plugin registers it). */
26
+ export declare const SETTINGS_NAMESPACE = "dsh-liangshen";
27
+ /** Owner share of a plugin card (the section supplies nothing). */
28
+ export interface SettingsPluginItemOwnerProps {
29
+ /** Marker field: card owner props are intentionally empty. */
30
+ children?: never;
31
+ }
32
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
33
+ interface SlotMap {
34
+ /**
35
+ * The child slot the Web UI plugin group declares; this card registers into
36
+ * the group instead of the top-level `settings.plugin.item` list. Declared
37
+ * here so this package needs no dependency on the sibling UI package.
38
+ */
39
+ 'web-ui.plugin.item': {
40
+ kind: 'list';
41
+ scope: 'root';
42
+ owner: SettingsPluginItemOwnerProps;
43
+ };
44
+ }
45
+ }
46
+ declare module '@deepseek-ai/cordis' {
47
+ interface Context {
48
+ /**
49
+ * Optional compatibility binder provided by dsh-web-settings; absent when
50
+ * that group plugin is not installed, so callers fall back to the official
51
+ * settings scope.
52
+ */
53
+ webUiSettings?: {
54
+ bind<S>(spec: SettingsScopeSpec<S>): import('@deepseek-ai/dsh-client-ui-settings/client').SettingsScope<S>;
55
+ };
56
+ }
57
+ }
24
58
  /**
25
59
  * Required client services: the slot registry, locale, sessions, and the roster
26
60
  * Remote. Both `remote` and `remote.agentPresets` are declared: the context
@@ -20,8 +20,34 @@ export declare const zh: {
20
20
  'lever.failed.failed': string;
21
21
  'burst.line1': string;
22
22
  'burst.line2': string;
23
+ 'settings.title': string;
24
+ 'settings.description': string;
25
+ 'settings.enabled': string;
26
+ 'settings.enabledHint': string;
27
+ 'settings.announceToAgent': string;
28
+ 'settings.announceToAgentHint': string;
29
+ 'settings.presentation': string;
30
+ 'settings.presentationHint': string;
31
+ 'settings.on': string;
32
+ 'settings.off': string;
33
+ 'settings.inherit': string;
34
+ 'settings.overridden': string;
35
+ 'settings.reset': string;
36
+ 'settings.notExposed': string;
37
+ 'settings.readOnly': string;
38
+ 'settings.expand': string;
39
+ 'settings.collapse': string;
40
+ 'settings.save': string;
41
+ 'settings.saving': string;
42
+ 'settings.discard': string;
43
+ 'settings.unsaved': string;
44
+ 'settings.saveFailed': string;
45
+ 'settings.invalidValue': string;
46
+ 'presentation.ptc': string;
47
+ 'presentation.native': string;
48
+ 'presentation.both': string;
23
49
  };
24
50
  /** English counterpart; the key set mirrors {@link zh} exactly. */
25
51
  export declare const en: Record<keyof typeof zh, string>;
26
- /** One lever copy key. */
52
+ /** Every key in the locale catalog. */
27
53
  export type LiangShenKey = keyof typeof zh;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Family plugin-card seat.
3
+ *
4
+ * A family plugin contributes its settings card to whichever plugin-card seat
5
+ * the running host actually renders:
6
+ *
7
+ * - `web-ui.plugin.item` — the list seat declared by the dsh-web-settings
8
+ * group section (this family's own first-level "Web UI plugins" section);
9
+ * - `settings.plugin.item` — the official keyed seat of the harness's
10
+ * `ui-settings-plugins` tab, keyed by the settings namespace the card edits.
11
+ *
12
+ * SEAT SELECTION IS NOT A DECLARATION PROBE. The official `ui-settings-plugins`
13
+ * row belongs to the harness bundle and its `configurable` tab always declares
14
+ * `settings.plugin.item` before any external plugin's `apply()` runs, so
15
+ * "is the official seat declared?" answers yes even in the deployment whose
16
+ * whole point is the family group. Choosing on that probe sends every family
17
+ * card to the official Plugins tab and leaves the group's own section
18
+ * permanently empty — the family of reports where the section renders its
19
+ * heading and zero cards.
20
+ *
21
+ * The signal that actually distinguishes the two deployments is whether
22
+ * dsh-web-settings is loaded: it is the package that owns the group section and
23
+ * it publishes the `webUiSettings` service during `apply()`, which every
24
+ * family plugin already reads for its settings scope. Group loaded -> the family
25
+ * seat; group absent -> the official seat.
26
+ *
27
+ * The decision is re-evaluated on every `slots/changed` because the group may
28
+ * apply after this plugin (the family aggregate orders it first, a profile that
29
+ * installs the group separately need not): the initial contribution goes to the
30
+ * official seat, then moves to the family seat the moment the group's section
31
+ * registers. The entry is disposed before the replacement is registered, so a
32
+ * card is never in two seats at once.
33
+ *
34
+ * The shared tree has no client-SDK dependency, so this module reads its
35
+ * context through the structural shape below; callers pass the plugin's own
36
+ * `ctx`.
37
+ */
38
+ /** The family list seat key. */
39
+ 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 = "settings.plugin.item";
42
+ /** The service dsh-web-settings publishes while it is loaded. */
43
+ export declare const FAMILY_GROUP_SERVICE = "webUiSettings";
44
+ /** The slot-registry member this helper uses (structurally satisfied by ctx.slots). */
45
+ export interface PluginCardSlots {
46
+ /** Contribution of one card entry. */
47
+ register(options: never, component: never): unknown;
48
+ }
49
+ /** The slice of the client context a card contribution needs. */
50
+ export interface PluginCardContext {
51
+ slots: PluginCardSlots;
52
+ /** Service lookup; absent on a context double that only models the slots. */
53
+ get?(name: string): unknown;
54
+ /** Event subscription seat; absent on an event-less test double. */
55
+ on?(event: string, listener: (...args: never[]) => void): unknown;
56
+ }
57
+ /** Owner share of a plugin card (both seats supply nothing). */
58
+ export interface SettingsPluginItemOwnerProps {
59
+ /** Marker field: card owner props are intentionally empty. */
60
+ children?: never;
61
+ }
62
+ /** One family plugin's card contribution. */
63
+ export interface PluginCardSeat {
64
+ /** Settings namespace the card edits (the official seat's dispatch key). */
65
+ namespace: string;
66
+ /** Family list-seat entry id. */
67
+ id: string;
68
+ /** Family list-seat sort order. */
69
+ order?: number;
70
+ /** Family list-seat display label; the official keyed seat carries none. */
71
+ label?: () => string;
72
+ /** Locale namespace the card renders with. */
73
+ locale: string;
74
+ /** Business-face factory of the registration. */
75
+ inject?: () => object;
76
+ /**
77
+ * The card component. Its props type is the seat's composed shape, which is
78
+ * chosen at runtime, so the helper takes it erased; the registrant keeps its
79
+ * own precise typing at the call site.
80
+ */
81
+ component: unknown;
82
+ }
83
+ /**
84
+ * Whether the family group (dsh-web-settings) is loaded in this page. The
85
+ * service is the group package's own contract, so the probe cannot be fooled
86
+ * by a harness release that starts declaring the official seat differently.
87
+ */
88
+ export declare function familyGroupLoaded(ctx: PluginCardContext): boolean;
89
+ /**
90
+ * Contribute one family plugin card to the seat this host renders, following
91
+ * the group if it loads later. The entry is disposed and re-registered on a
92
+ * seat change, never duplicated.
93
+ * @param ctx - client context (its slot registry decides the seat).
94
+ * @param seat - the card contribution.
95
+ */
96
+ export declare function installPluginCard(ctx: PluginCardContext, seat: PluginCardSeat): void;
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Staged form model behind the plugin settings card. A card stages what the
3
+ * user types and writes it only when they save — the settings write is a
4
+ * durable, revision-fenced document mutation, so staging keeps what is on
5
+ * screen exactly what a save would store. Family-shared slice inlined into
6
+ * each plugin's client bundle; mirrors the official ui-plugin-config
7
+ * card-store pattern.
8
+ */
9
+ import type { SettingsScope } from '@deepseek-ai/dsh-client-ui-settings/client';
10
+ import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
11
+ /** The write one field's staged text performs when the card is saved. */
12
+ export type FieldWrite = {
13
+ kind: 'set';
14
+ value: unknown;
15
+ } | {
16
+ kind: 'clear';
17
+ };
18
+ /** How one field converts between its stored value and its draft text. */
19
+ export interface FieldSpec {
20
+ /** Field name inside the namespace section. */
21
+ field: string;
22
+ /**
23
+ * Whether the Host treats this field as a secret and redacts its value from
24
+ * the read-back (role('secret') in the section schema). Redacted secrets are
25
+ * never compared against the draft on save: the Host strips them from every
26
+ * wire view layer, so the settled snapshot carries nothing to read back. A
27
+ * staged secret set is judged by the mutation settling; the rest of its
28
+ * batch, when one exists, is still judged by read-back, and the atomic
29
+ * mutation lands every write or none.
30
+ */
31
+ secret?: boolean;
32
+ /** Render a stored value as draft text; the empty string when the section carries none. */
33
+ format: (value: unknown) => string;
34
+ /**
35
+ * The write this draft text stages, or undefined when the text is not a
36
+ * value this field accepts — which blocks the save rather than discarding it.
37
+ */
38
+ parse: (text: string) => FieldWrite | undefined;
39
+ }
40
+ /** One field as the card renders it. */
41
+ export interface FieldState {
42
+ /** Draft text the control renders. */
43
+ text: string;
44
+ /** Whether saving would leave a user-layer entry for this field. */
45
+ overridden: boolean;
46
+ /** Whether the draft is not a value this field accepts, which blocks saving. */
47
+ invalid: boolean;
48
+ }
49
+ /** Form state every plugin settings card shares. */
50
+ export interface CardShell {
51
+ /** False while the namespace is still loading; the card renders nothing. */
52
+ available: boolean;
53
+ /**
54
+ * Whether the namespace is actually served to this client. False when the
55
+ * Host deployment does not expose it (e.g. the owning plugin's settings
56
+ * domain is not mounted): the card renders an explanation
57
+ * instead of its form, so a missing namespace never looks like a missing
58
+ * plugin.
59
+ */
60
+ exposed: boolean;
61
+ /** Whether the Host document accepts writes. */
62
+ writable: boolean;
63
+ /** Whether the form holds edits that a save would write. */
64
+ dirty: boolean;
65
+ /** Whether any staged draft is invalid, which blocks the save. */
66
+ invalid: boolean;
67
+ /** Whether a save is crossing the wire. */
68
+ saving: boolean;
69
+ /** Whether the last save did not land as staged; cleared by the next edit or save. */
70
+ failed: boolean;
71
+ /**
72
+ * The rejection code/message the Host returned for the last failed save,
73
+ * surfaced next to the generic failure text. Undefined while no save has
74
+ * failed (or the failure carried no server reason).
75
+ */
76
+ failedReason?: string;
77
+ }
78
+ /** The write actions the card's slot entry injects. */
79
+ export interface CardActions {
80
+ /** Stage draft text for one field. */
81
+ edit: (field: string, text: string) => void;
82
+ /** Stage a clear, so saving lets the field re-inherit the composition layer. */
83
+ resetField: (field: string) => void;
84
+ /** Write every staged edit, then re-seed from what the Host accepted. */
85
+ save: () => void;
86
+ /** Drop every staged edit. */
87
+ discard: () => void;
88
+ }
89
+ /** One durable write inside the save's atomic scope mutation. */
90
+ export interface BatchedWrite {
91
+ /** Field this entry writes. */
92
+ field: string;
93
+ /** set stores a value; unset drops the leaf. */
94
+ op: 'set' | 'unset';
95
+ /** Value for op set (absent for unset). */
96
+ value?: unknown;
97
+ }
98
+ /** Constraints a numeric field's accepted drafts must satisfy, mirroring the host schema. */
99
+ export interface NumberConstraints {
100
+ /** The accepted value must be a whole number. */
101
+ integer?: boolean;
102
+ /** The accepted value must be at least this. */
103
+ min?: number;
104
+ }
105
+ /** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints blocks the save. */
106
+ export declare function numberField(field: string, constraints?: NumberConstraints): FieldSpec;
107
+ /** A free-text field. An empty draft clears the field. */
108
+ export declare function textField(field: string): FieldSpec;
109
+ /**
110
+ * A free-text field the Host treats as a secret and redacts from the read-back
111
+ * (role('secret') in the section schema). The card still edits it like text,
112
+ * but a save never compares the redacted value back: the staged set is judged
113
+ * by the mutation settling (see {@link FieldSpec.secret}).
114
+ */
115
+ export declare function secretField(field: string): FieldSpec;
116
+ /** A boolean field, edited through true/false draft text. */
117
+ export declare function booleanField(field: string): FieldSpec;
118
+ /** An enumerated string field; only the listed choices are accepted. An empty draft clears the field. */
119
+ export declare function choiceField(field: string, choices: readonly string[]): FieldSpec;
120
+ /**
121
+ * Stages one card's edits over one settings namespace and writes them on save.
122
+ *
123
+ * The Host is the only authority on whether a value was accepted — its
124
+ * validators own the constraints no schema can express — so the outcome is
125
+ * read back from the section rather than predicted here. A save that did not
126
+ * land keeps its drafts, so the user can correct them instead of retyping.
127
+ */
128
+ export declare class CardForm<T> {
129
+ private readonly scope;
130
+ private readonly specs;
131
+ private readonly staged;
132
+ private readonly listeners;
133
+ /** The scope subscription installed in the constructor; released by dispose(). */
134
+ private readonly disposeScope;
135
+ private disposed;
136
+ private saving;
137
+ private failed;
138
+ private failedReason;
139
+ /** @param scope - the bound settings scope for this card's namespace. */
140
+ constructor(scope: SettingsScope<T>, specs: FieldSpec[]);
141
+ /**
142
+ * Release the scope subscription and every bound store listener. The card
143
+ * must call this on teardown; later calls are no-ops.
144
+ */
145
+ dispose(): void;
146
+ /** Publish a projection of this form, rebuilt whenever the scope or a draft changes. */
147
+ bind<S>(project: () => S): SnapshotStore<S>;
148
+ /** Read the card-level state: what the Host serves, and what a save would do. */
149
+ shell(): CardShell;
150
+ /** Read one field's state from the effective section and its staged draft. */
151
+ field(field: string): FieldState;
152
+ /** The actions the card's slot registration injects. */
153
+ actions(): CardActions;
154
+ /**
155
+ * Write every staged edit in one atomic scope mutation, then re-seed from
156
+ * what the Host accepted.
157
+ *
158
+ * The whole batch rides one mutate, so cross-field validate hooks
159
+ * (baseURL+model) judge it as a unit: the Host either applies every write
160
+ * or refuses the batch. The 0.1.2 scope contract never rejects a refused
161
+ * mutation — the scope recovers with a fresh Host view and resolves — so
162
+ * resolution alone proves nothing: the outcome is judged by reading the
163
+ * settled snapshot back, one planned write at a time, and one missed write
164
+ * fails the whole save. A scope that still rejects on refusal (the dsh-web
165
+ * bridge scope) reports through the same failure path with its rejection
166
+ * message. A save that did not land keeps its drafts, so the user can
167
+ * correct them instead of retyping.
168
+ * @returns settlement after the mutation and the read-back.
169
+ */
170
+ save(): Promise<void>;
171
+ /**
172
+ * Every staged edit a save would write. An entry whose draft is not a value
173
+ * its field accepts carries no write: the form is still dirty, and the save
174
+ * refuses rather than dropping the edit. A staged edit that matches the
175
+ * effective section is not a write at all.
176
+ * @returns the planned writes, in the order the fields were staged.
177
+ */
178
+ private plan;
179
+ /**
180
+ * Read-back judgment for a planned set: the user layer must hold the
181
+ * intended value once the mutation has settled.
182
+ */
183
+ private landedSet;
184
+ /**
185
+ * Read-back judgment for a planned unset: the field must be gone from the
186
+ * user layer once the mutation has settled.
187
+ */
188
+ private landedUnset;
189
+ private stage;
190
+ private specOf;
191
+ private snapshotOf;
192
+ private sectionValue;
193
+ private baseValue;
194
+ private userLayer;
195
+ private stored;
196
+ private publish;
197
+ }
@@ -41,9 +41,12 @@ export interface LeverFacts {
41
41
  export declare function leverState(facts: LeverFacts): LeverState;
42
42
  /**
43
43
  * The preset a push-up restores: the preset the user was on before pulling the
44
- * lever, else the deployment default. A candidate is skipped when it is the
45
- * LiangShen preset itself (restoring it would be a no-op) or when the roster
46
- * no longer supplies it.
44
+ * lever, else the deployment default, else the first usable roster row that is
45
+ * not the LiangShen preset. A candidate is skipped when it is the LiangShen
46
+ * preset itself (restoring it would be a no-op) or when the roster no longer
47
+ * supplies it. That last resort is what keeps the push direction alive when the
48
+ * deployment default IS LiangShen mode: `fallback` is skipped then, and after a
49
+ * reload `previous` is gone, so without it the gesture would have no target.
47
50
  */
48
51
  export declare function restoreTarget(facts: LeverFacts): string | undefined;
49
52
  /** Whether the lever can act at all in its current state. */