jssm 5.153.0 → 5.154.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 +7 -7
- package/custom-elements.json +290 -4
- package/dist/cdn/instance.js +148 -1
- package/dist/cdn/viz.js +146 -1
- package/dist/cli/fsl-export-system-prompt.cjs +1 -1
- package/dist/cli/fsl-render.cjs +1 -1
- package/dist/cli/fsl.cjs +1 -1
- package/dist/cli/lib.cjs +1 -1
- package/dist/cli/lib.mjs +1 -1
- package/dist/deno/README.md +7 -7
- package/dist/deno/jssm.d.ts +64 -1
- package/dist/deno/jssm.js +1 -1
- package/dist/deno/jssm_types.d.ts +29 -1
- package/dist/jssm.es5.cjs +1 -1
- package/dist/jssm.es5.iife.js +1 -1
- package/dist/jssm.es6.mjs +1 -1
- package/dist/jssm_viz.cjs +1 -1
- package/dist/jssm_viz.iife.cjs +1 -1
- package/dist/jssm_viz.mjs +1 -1
- package/dist/wc/instance.js +2 -0
- package/dist/wc/widgets.define.js +3 -2
- package/dist/wc/widgets.js +331 -34
- package/jssm.es5.d.cts +92 -1
- package/jssm.es6.d.ts +92 -1
- package/jssm_viz.es5.d.cts +87 -0
- package/jssm_viz.es6.d.ts +87 -0
- package/package.json +1 -1
package/jssm.es6.d.ts
CHANGED
|
@@ -524,6 +524,34 @@ declare type JssmEditorConfig = {
|
|
|
524
524
|
stochastic_run_count?: number;
|
|
525
525
|
panels?: Array<string>;
|
|
526
526
|
};
|
|
527
|
+
/** Which stochastic view a run batch produces. */
|
|
528
|
+
declare type JssmStochasticMode = 'montecarlo' | 'steady_state';
|
|
529
|
+
/** Options for {@link Machine.stochastic_summary} / {@link Machine.stochastic_runs}. */
|
|
530
|
+
declare type JssmStochasticOptions = {
|
|
531
|
+
mode?: JssmStochasticMode;
|
|
532
|
+
runs?: number;
|
|
533
|
+
max_steps?: number;
|
|
534
|
+
seed?: number;
|
|
535
|
+
};
|
|
536
|
+
/** One walk's result, yielded by {@link Machine.stochastic_runs}. */
|
|
537
|
+
declare type JssmStochasticRun = {
|
|
538
|
+
states: Array<string>;
|
|
539
|
+
edges: Array<string>;
|
|
540
|
+
length: number;
|
|
541
|
+
terminated: boolean;
|
|
542
|
+
};
|
|
543
|
+
/** Aggregate statistics over a stochastic run batch. */
|
|
544
|
+
declare type JssmStochasticSummary = {
|
|
545
|
+
mode: JssmStochasticMode;
|
|
546
|
+
runs: number;
|
|
547
|
+
seed: number;
|
|
548
|
+
state_visits: Map<string, number>;
|
|
549
|
+
state_visit_fraction: Map<string, number>;
|
|
550
|
+
edge_traversals: Map<string, number>;
|
|
551
|
+
path_lengths?: Array<number>;
|
|
552
|
+
terminal_reached?: number;
|
|
553
|
+
capped?: number;
|
|
554
|
+
};
|
|
527
555
|
declare type JssmGenericConfig<StateType, DataType> = {
|
|
528
556
|
graph_layout?: JssmLayout;
|
|
529
557
|
complete?: Array<StateType>;
|
|
@@ -1991,6 +2019,10 @@ declare function transfer_state_properties(state_decl: JssmStateDeclaration): Js
|
|
|
1991
2019
|
*
|
|
1992
2020
|
*/
|
|
1993
2021
|
declare function state_style_condense(jssk: JssmStateStyleKeyList, machine?: any): JssmStateConfig;
|
|
2022
|
+
/** Default number of independent Monte-Carlo runs when none is declared. */
|
|
2023
|
+
declare const STOCHASTIC_DEFAULT_RUNS = 1000;
|
|
2024
|
+
/** Default per-run step cap (montecarlo) / walk length (steady_state). */
|
|
2025
|
+
declare const STOCHASTIC_DEFAULT_MAX_STEPS = 1000;
|
|
1994
2026
|
declare class Machine<mDT> {
|
|
1995
2027
|
_state: StateType;
|
|
1996
2028
|
_states: Map<StateType, JssmGenericState>;
|
|
@@ -2919,6 +2951,65 @@ declare class Machine<mDT> {
|
|
|
2919
2951
|
* @returns A `Map` from state name to visit count.
|
|
2920
2952
|
*/
|
|
2921
2953
|
probabilistic_histo_walk(n: number): Map<StateType, number>;
|
|
2954
|
+
/** One non-destructive weighted-random walk over the graph from `start`.
|
|
2955
|
+
*
|
|
2956
|
+
* Reads the graph and advances the PRNG only — it never calls
|
|
2957
|
+
* {@link Machine.transition}, so it fires no hooks, mutates no machine
|
|
2958
|
+
* state, and touches no `data`. A state with no probabilistic exits
|
|
2959
|
+
* (a terminal, or a forced-only `~>` state) ends the walk.
|
|
2960
|
+
*
|
|
2961
|
+
* @param start - State to begin the walk from.
|
|
2962
|
+
* @param max_steps - Maximum transitions before the walk is step-capped.
|
|
2963
|
+
* @returns The {@link JssmStochasticRun} for this walk.
|
|
2964
|
+
*/
|
|
2965
|
+
private _stochastic_one_walk;
|
|
2966
|
+
/** Lazily yield one {@link JssmStochasticRun} at a time.
|
|
2967
|
+
*
|
|
2968
|
+
* In `montecarlo` mode (default) yields `runs` independent walks from the
|
|
2969
|
+
* current state, each ending at a terminal or after `max_steps`. In
|
|
2970
|
+
* `steady_state` mode yields exactly one walk of `max_steps` steps. This
|
|
2971
|
+
* is the lazy engine behind {@link Machine.stochastic_summary}; the
|
|
2972
|
+
* fsl-stochastic panel drives it across animation frames.
|
|
2973
|
+
*
|
|
2974
|
+
* Passing `seed` reseeds the machine for reproducible runs. Unlike
|
|
2975
|
+
* {@link Machine.stochastic_summary}, the generator does NOT restore the
|
|
2976
|
+
* prior seed afterward — a direct caller's machine is left reseeded.
|
|
2977
|
+
*
|
|
2978
|
+
* @param opts - {@link JssmStochasticOptions}.
|
|
2979
|
+
* @returns A generator of per-run results.
|
|
2980
|
+
*
|
|
2981
|
+
* @example
|
|
2982
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
2983
|
+
* [...m.stochastic_runs({ runs: 2, seed: 1 })].length; // => 2
|
|
2984
|
+
*/
|
|
2985
|
+
stochastic_runs(opts?: JssmStochasticOptions): Generator<JssmStochasticRun>;
|
|
2986
|
+
/** Run many weighted-random walks and return aggregate statistics.
|
|
2987
|
+
*
|
|
2988
|
+
* Honors `%` transition probabilities (via the existing probabilistic
|
|
2989
|
+
* machinery). Non-destructive: the machine's current state and
|
|
2990
|
+
* {@link Machine.rng_seed} are restored before returning, so calling this
|
|
2991
|
+
* never perturbs the live machine. `montecarlo` mode (default) reports
|
|
2992
|
+
* per-run `path_lengths`, `terminal_reached`, and `capped`; `steady_state`
|
|
2993
|
+
* mode runs one long walk and omits those fields.
|
|
2994
|
+
*
|
|
2995
|
+
* Timing (`after`) decorations and data-guard conditions are not modeled
|
|
2996
|
+
* by this sampler; it walks the probabilistic graph topology.
|
|
2997
|
+
*
|
|
2998
|
+
* @param opts - {@link JssmStochasticOptions}. `runs` defaults to the
|
|
2999
|
+
* machine's declared `editor: { stochastic_run_count }` (fsl#1334) when
|
|
3000
|
+
* present, otherwise {@link STOCHASTIC_DEFAULT_RUNS}.
|
|
3001
|
+
* @returns A {@link JssmStochasticSummary}.
|
|
3002
|
+
*
|
|
3003
|
+
* @see Machine.stochastic_runs
|
|
3004
|
+
* @see Machine.probabilistic_walk
|
|
3005
|
+
* @see Machine.editor_config
|
|
3006
|
+
*
|
|
3007
|
+
* @example
|
|
3008
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
3009
|
+
* const s = m.stochastic_summary({ runs: 100, seed: 1 });
|
|
3010
|
+
* s.terminal_reached; // => 100
|
|
3011
|
+
*/
|
|
3012
|
+
stochastic_summary(opts?: JssmStochasticOptions): JssmStochasticSummary;
|
|
2922
3013
|
/********
|
|
2923
3014
|
*
|
|
2924
3015
|
* List all actions available from this state. Please note that the order of
|
|
@@ -4691,4 +4782,4 @@ declare function compareVersions(v1: string, v2: string): number;
|
|
|
4691
4782
|
*/
|
|
4692
4783
|
declare function deserialize<mDT>(machine_string: string, ser: JssmSerialization<mDT>): Machine<mDT>;
|
|
4693
4784
|
|
|
4694
|
-
export { FslDirections, Machine, abstract_everything_hook_step, abstract_hook_step, action_label_chars, arrow_direction, arrow_left_kind, arrow_right_kind, build_time, compareVersions, compile, jssm_constants_d as constants, deserialize, find_repeated, from, fslCompletions, fslDiagnostics, fslSemanticSpans, gen_splitmix32, gviz_shapes, histograph, is_hook_complex_result, is_hook_rejection, make, named_colors, wrap_parse as parse, seq, shapes, sleep, sm, state_name_chars, state_name_first_chars, state_style_condense, transfer_state_properties, unique, version, weighted_histo_key, weighted_rand_select, weighted_sample_select };
|
|
4785
|
+
export { FslDirections, Machine, STOCHASTIC_DEFAULT_MAX_STEPS, STOCHASTIC_DEFAULT_RUNS, abstract_everything_hook_step, abstract_hook_step, action_label_chars, arrow_direction, arrow_left_kind, arrow_right_kind, build_time, compareVersions, compile, jssm_constants_d as constants, deserialize, find_repeated, from, fslCompletions, fslDiagnostics, fslSemanticSpans, gen_splitmix32, gviz_shapes, histograph, is_hook_complex_result, is_hook_rejection, make, named_colors, wrap_parse as parse, seq, shapes, sleep, sm, state_name_chars, state_name_first_chars, state_style_condense, transfer_state_properties, unique, version, weighted_histo_key, weighted_rand_select, weighted_sample_select };
|
package/jssm_viz.es5.d.cts
CHANGED
|
@@ -519,6 +519,34 @@ declare type JssmEditorConfig = {
|
|
|
519
519
|
stochastic_run_count?: number;
|
|
520
520
|
panels?: Array<string>;
|
|
521
521
|
};
|
|
522
|
+
/** Which stochastic view a run batch produces. */
|
|
523
|
+
declare type JssmStochasticMode = 'montecarlo' | 'steady_state';
|
|
524
|
+
/** Options for {@link Machine.stochastic_summary} / {@link Machine.stochastic_runs}. */
|
|
525
|
+
declare type JssmStochasticOptions = {
|
|
526
|
+
mode?: JssmStochasticMode;
|
|
527
|
+
runs?: number;
|
|
528
|
+
max_steps?: number;
|
|
529
|
+
seed?: number;
|
|
530
|
+
};
|
|
531
|
+
/** One walk's result, yielded by {@link Machine.stochastic_runs}. */
|
|
532
|
+
declare type JssmStochasticRun = {
|
|
533
|
+
states: Array<string>;
|
|
534
|
+
edges: Array<string>;
|
|
535
|
+
length: number;
|
|
536
|
+
terminated: boolean;
|
|
537
|
+
};
|
|
538
|
+
/** Aggregate statistics over a stochastic run batch. */
|
|
539
|
+
declare type JssmStochasticSummary = {
|
|
540
|
+
mode: JssmStochasticMode;
|
|
541
|
+
runs: number;
|
|
542
|
+
seed: number;
|
|
543
|
+
state_visits: Map<string, number>;
|
|
544
|
+
state_visit_fraction: Map<string, number>;
|
|
545
|
+
edge_traversals: Map<string, number>;
|
|
546
|
+
path_lengths?: Array<number>;
|
|
547
|
+
terminal_reached?: number;
|
|
548
|
+
capped?: number;
|
|
549
|
+
};
|
|
522
550
|
declare type JssmGenericConfig<StateType, DataType> = {
|
|
523
551
|
graph_layout?: JssmLayout;
|
|
524
552
|
complete?: Array<StateType>;
|
|
@@ -2156,6 +2184,65 @@ declare class Machine<mDT> {
|
|
|
2156
2184
|
* @returns A `Map` from state name to visit count.
|
|
2157
2185
|
*/
|
|
2158
2186
|
probabilistic_histo_walk(n: number): Map<StateType, number>;
|
|
2187
|
+
/** One non-destructive weighted-random walk over the graph from `start`.
|
|
2188
|
+
*
|
|
2189
|
+
* Reads the graph and advances the PRNG only — it never calls
|
|
2190
|
+
* {@link Machine.transition}, so it fires no hooks, mutates no machine
|
|
2191
|
+
* state, and touches no `data`. A state with no probabilistic exits
|
|
2192
|
+
* (a terminal, or a forced-only `~>` state) ends the walk.
|
|
2193
|
+
*
|
|
2194
|
+
* @param start - State to begin the walk from.
|
|
2195
|
+
* @param max_steps - Maximum transitions before the walk is step-capped.
|
|
2196
|
+
* @returns The {@link JssmStochasticRun} for this walk.
|
|
2197
|
+
*/
|
|
2198
|
+
private _stochastic_one_walk;
|
|
2199
|
+
/** Lazily yield one {@link JssmStochasticRun} at a time.
|
|
2200
|
+
*
|
|
2201
|
+
* In `montecarlo` mode (default) yields `runs` independent walks from the
|
|
2202
|
+
* current state, each ending at a terminal or after `max_steps`. In
|
|
2203
|
+
* `steady_state` mode yields exactly one walk of `max_steps` steps. This
|
|
2204
|
+
* is the lazy engine behind {@link Machine.stochastic_summary}; the
|
|
2205
|
+
* fsl-stochastic panel drives it across animation frames.
|
|
2206
|
+
*
|
|
2207
|
+
* Passing `seed` reseeds the machine for reproducible runs. Unlike
|
|
2208
|
+
* {@link Machine.stochastic_summary}, the generator does NOT restore the
|
|
2209
|
+
* prior seed afterward — a direct caller's machine is left reseeded.
|
|
2210
|
+
*
|
|
2211
|
+
* @param opts - {@link JssmStochasticOptions}.
|
|
2212
|
+
* @returns A generator of per-run results.
|
|
2213
|
+
*
|
|
2214
|
+
* @example
|
|
2215
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
2216
|
+
* [...m.stochastic_runs({ runs: 2, seed: 1 })].length; // => 2
|
|
2217
|
+
*/
|
|
2218
|
+
stochastic_runs(opts?: JssmStochasticOptions): Generator<JssmStochasticRun>;
|
|
2219
|
+
/** Run many weighted-random walks and return aggregate statistics.
|
|
2220
|
+
*
|
|
2221
|
+
* Honors `%` transition probabilities (via the existing probabilistic
|
|
2222
|
+
* machinery). Non-destructive: the machine's current state and
|
|
2223
|
+
* {@link Machine.rng_seed} are restored before returning, so calling this
|
|
2224
|
+
* never perturbs the live machine. `montecarlo` mode (default) reports
|
|
2225
|
+
* per-run `path_lengths`, `terminal_reached`, and `capped`; `steady_state`
|
|
2226
|
+
* mode runs one long walk and omits those fields.
|
|
2227
|
+
*
|
|
2228
|
+
* Timing (`after`) decorations and data-guard conditions are not modeled
|
|
2229
|
+
* by this sampler; it walks the probabilistic graph topology.
|
|
2230
|
+
*
|
|
2231
|
+
* @param opts - {@link JssmStochasticOptions}. `runs` defaults to the
|
|
2232
|
+
* machine's declared `editor: { stochastic_run_count }` (fsl#1334) when
|
|
2233
|
+
* present, otherwise {@link STOCHASTIC_DEFAULT_RUNS}.
|
|
2234
|
+
* @returns A {@link JssmStochasticSummary}.
|
|
2235
|
+
*
|
|
2236
|
+
* @see Machine.stochastic_runs
|
|
2237
|
+
* @see Machine.probabilistic_walk
|
|
2238
|
+
* @see Machine.editor_config
|
|
2239
|
+
*
|
|
2240
|
+
* @example
|
|
2241
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
2242
|
+
* const s = m.stochastic_summary({ runs: 100, seed: 1 });
|
|
2243
|
+
* s.terminal_reached; // => 100
|
|
2244
|
+
*/
|
|
2245
|
+
stochastic_summary(opts?: JssmStochasticOptions): JssmStochasticSummary;
|
|
2159
2246
|
/********
|
|
2160
2247
|
*
|
|
2161
2248
|
* List all actions available from this state. Please note that the order of
|
package/jssm_viz.es6.d.ts
CHANGED
|
@@ -519,6 +519,34 @@ declare type JssmEditorConfig = {
|
|
|
519
519
|
stochastic_run_count?: number;
|
|
520
520
|
panels?: Array<string>;
|
|
521
521
|
};
|
|
522
|
+
/** Which stochastic view a run batch produces. */
|
|
523
|
+
declare type JssmStochasticMode = 'montecarlo' | 'steady_state';
|
|
524
|
+
/** Options for {@link Machine.stochastic_summary} / {@link Machine.stochastic_runs}. */
|
|
525
|
+
declare type JssmStochasticOptions = {
|
|
526
|
+
mode?: JssmStochasticMode;
|
|
527
|
+
runs?: number;
|
|
528
|
+
max_steps?: number;
|
|
529
|
+
seed?: number;
|
|
530
|
+
};
|
|
531
|
+
/** One walk's result, yielded by {@link Machine.stochastic_runs}. */
|
|
532
|
+
declare type JssmStochasticRun = {
|
|
533
|
+
states: Array<string>;
|
|
534
|
+
edges: Array<string>;
|
|
535
|
+
length: number;
|
|
536
|
+
terminated: boolean;
|
|
537
|
+
};
|
|
538
|
+
/** Aggregate statistics over a stochastic run batch. */
|
|
539
|
+
declare type JssmStochasticSummary = {
|
|
540
|
+
mode: JssmStochasticMode;
|
|
541
|
+
runs: number;
|
|
542
|
+
seed: number;
|
|
543
|
+
state_visits: Map<string, number>;
|
|
544
|
+
state_visit_fraction: Map<string, number>;
|
|
545
|
+
edge_traversals: Map<string, number>;
|
|
546
|
+
path_lengths?: Array<number>;
|
|
547
|
+
terminal_reached?: number;
|
|
548
|
+
capped?: number;
|
|
549
|
+
};
|
|
522
550
|
declare type JssmGenericConfig<StateType, DataType> = {
|
|
523
551
|
graph_layout?: JssmLayout;
|
|
524
552
|
complete?: Array<StateType>;
|
|
@@ -2156,6 +2184,65 @@ declare class Machine<mDT> {
|
|
|
2156
2184
|
* @returns A `Map` from state name to visit count.
|
|
2157
2185
|
*/
|
|
2158
2186
|
probabilistic_histo_walk(n: number): Map<StateType, number>;
|
|
2187
|
+
/** One non-destructive weighted-random walk over the graph from `start`.
|
|
2188
|
+
*
|
|
2189
|
+
* Reads the graph and advances the PRNG only — it never calls
|
|
2190
|
+
* {@link Machine.transition}, so it fires no hooks, mutates no machine
|
|
2191
|
+
* state, and touches no `data`. A state with no probabilistic exits
|
|
2192
|
+
* (a terminal, or a forced-only `~>` state) ends the walk.
|
|
2193
|
+
*
|
|
2194
|
+
* @param start - State to begin the walk from.
|
|
2195
|
+
* @param max_steps - Maximum transitions before the walk is step-capped.
|
|
2196
|
+
* @returns The {@link JssmStochasticRun} for this walk.
|
|
2197
|
+
*/
|
|
2198
|
+
private _stochastic_one_walk;
|
|
2199
|
+
/** Lazily yield one {@link JssmStochasticRun} at a time.
|
|
2200
|
+
*
|
|
2201
|
+
* In `montecarlo` mode (default) yields `runs` independent walks from the
|
|
2202
|
+
* current state, each ending at a terminal or after `max_steps`. In
|
|
2203
|
+
* `steady_state` mode yields exactly one walk of `max_steps` steps. This
|
|
2204
|
+
* is the lazy engine behind {@link Machine.stochastic_summary}; the
|
|
2205
|
+
* fsl-stochastic panel drives it across animation frames.
|
|
2206
|
+
*
|
|
2207
|
+
* Passing `seed` reseeds the machine for reproducible runs. Unlike
|
|
2208
|
+
* {@link Machine.stochastic_summary}, the generator does NOT restore the
|
|
2209
|
+
* prior seed afterward — a direct caller's machine is left reseeded.
|
|
2210
|
+
*
|
|
2211
|
+
* @param opts - {@link JssmStochasticOptions}.
|
|
2212
|
+
* @returns A generator of per-run results.
|
|
2213
|
+
*
|
|
2214
|
+
* @example
|
|
2215
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
2216
|
+
* [...m.stochastic_runs({ runs: 2, seed: 1 })].length; // => 2
|
|
2217
|
+
*/
|
|
2218
|
+
stochastic_runs(opts?: JssmStochasticOptions): Generator<JssmStochasticRun>;
|
|
2219
|
+
/** Run many weighted-random walks and return aggregate statistics.
|
|
2220
|
+
*
|
|
2221
|
+
* Honors `%` transition probabilities (via the existing probabilistic
|
|
2222
|
+
* machinery). Non-destructive: the machine's current state and
|
|
2223
|
+
* {@link Machine.rng_seed} are restored before returning, so calling this
|
|
2224
|
+
* never perturbs the live machine. `montecarlo` mode (default) reports
|
|
2225
|
+
* per-run `path_lengths`, `terminal_reached`, and `capped`; `steady_state`
|
|
2226
|
+
* mode runs one long walk and omits those fields.
|
|
2227
|
+
*
|
|
2228
|
+
* Timing (`after`) decorations and data-guard conditions are not modeled
|
|
2229
|
+
* by this sampler; it walks the probabilistic graph topology.
|
|
2230
|
+
*
|
|
2231
|
+
* @param opts - {@link JssmStochasticOptions}. `runs` defaults to the
|
|
2232
|
+
* machine's declared `editor: { stochastic_run_count }` (fsl#1334) when
|
|
2233
|
+
* present, otherwise {@link STOCHASTIC_DEFAULT_RUNS}.
|
|
2234
|
+
* @returns A {@link JssmStochasticSummary}.
|
|
2235
|
+
*
|
|
2236
|
+
* @see Machine.stochastic_runs
|
|
2237
|
+
* @see Machine.probabilistic_walk
|
|
2238
|
+
* @see Machine.editor_config
|
|
2239
|
+
*
|
|
2240
|
+
* @example
|
|
2241
|
+
* const m = sm`a 'go' -> b 'go' -> c;`;
|
|
2242
|
+
* const s = m.stochastic_summary({ runs: 100, seed: 1 });
|
|
2243
|
+
* s.terminal_reached; // => 100
|
|
2244
|
+
*/
|
|
2245
|
+
stochastic_summary(opts?: JssmStochasticOptions): JssmStochasticSummary;
|
|
2159
2246
|
/********
|
|
2160
2247
|
*
|
|
2161
2248
|
* List all actions available from this state. Please note that the order of
|