@cnstra/core 2.5.0 → 3.0.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 -4
- package/dist/CNS.d.ts +16 -12
- package/dist/CNS.d.ts.map +1 -1
- package/dist/CNSCollateral.d.ts +2 -2
- package/dist/CNSCollateral.d.ts.map +1 -1
- package/dist/CNSNetwork.d.ts +11 -10
- package/dist/CNSNetwork.d.ts.map +1 -1
- package/dist/CNSStimulation.d.ts +21 -48
- package/dist/CNSStimulation.d.ts.map +1 -1
- package/dist/factory/index.d.ts +45 -105
- package/dist/factory/index.d.ts.map +1 -1
- package/dist/index.cjs +44 -247
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -243
- package/dist/index.js.map +1 -1
- package/dist/utils/CNSStimulationGate.d.ts +9 -9
- package/dist/utils/CNSStimulationGate.d.ts.map +1 -1
- package/package.json +5 -2
- package/dist/CNSPersistOptionsRegistry.d.ts +0 -28
- package/dist/CNSPersistOptionsRegistry.d.ts.map +0 -1
- package/dist/CNSStimulationContextStore.d.ts +0 -11
- package/dist/CNSStimulationContextStore.d.ts.map +0 -1
- package/dist/interfaces/ICNS.d.ts +0 -27
- package/dist/interfaces/ICNS.d.ts.map +0 -1
- package/dist/interfaces/ICNSCollateral.d.ts +0 -6
- package/dist/interfaces/ICNSCollateral.d.ts.map +0 -1
- package/dist/interfaces/ICNSStimulationContextStore.d.ts +0 -8
- package/dist/interfaces/ICNSStimulationContextStore.d.ts.map +0 -1
- package/dist/types/TCNSAfferentPath.d.ts +0 -4
- package/dist/types/TCNSAfferentPath.d.ts.map +0 -1
- package/dist/types/TCNSAxon.d.ts +0 -26
- package/dist/types/TCNSAxon.d.ts.map +0 -1
- package/dist/types/TCNSDendrite.d.ts +0 -9
- package/dist/types/TCNSDendrite.d.ts.map +0 -1
- package/dist/types/TCNSHandlerContext.d.ts +0 -24
- package/dist/types/TCNSHandlerContext.d.ts.map +0 -1
- package/dist/types/TCNSLocalContextValueStore.d.ts +0 -6
- package/dist/types/TCNSLocalContextValueStore.d.ts.map +0 -1
- package/dist/types/TCNSModality.d.ts +0 -5
- package/dist/types/TCNSModality.d.ts.map +0 -1
- package/dist/types/TCNSNeuron.d.ts +0 -12
- package/dist/types/TCNSNeuron.d.ts.map +0 -1
- package/dist/types/TCNSNeuronActivationTask.d.ts +0 -8
- package/dist/types/TCNSNeuronActivationTask.d.ts.map +0 -1
- package/dist/types/TCNSNeuronActivationTaskFailure.d.ts +0 -7
- package/dist/types/TCNSNeuronActivationTaskFailure.d.ts.map +0 -1
- package/dist/types/TCNSNeuronResponseReturn.d.ts +0 -9
- package/dist/types/TCNSNeuronResponseReturn.d.ts.map +0 -1
- package/dist/types/TCNSOptions.d.ts +0 -11
- package/dist/types/TCNSOptions.d.ts.map +0 -1
- package/dist/types/TCNSPersist.d.ts +0 -16
- package/dist/types/TCNSPersist.d.ts.map +0 -1
- package/dist/types/TCNSSignal.d.ts +0 -6
- package/dist/types/TCNSSignal.d.ts.map +0 -1
- package/dist/types/TCNSStimulationDrain.d.ts +0 -37
- package/dist/types/TCNSStimulationDrain.d.ts.map +0 -1
- package/dist/types/TCNSStimulationOptions.d.ts +0 -32
- package/dist/types/TCNSStimulationOptions.d.ts.map +0 -1
- package/dist/types/TCNSStimulationQueueItem.d.ts +0 -11
- package/dist/types/TCNSStimulationQueueItem.d.ts.map +0 -1
- package/dist/types/TCNSStimulationResponse.d.ts +0 -57
- package/dist/types/TCNSStimulationResponse.d.ts.map +0 -1
- package/dist/types/TCNSStimulationSerializedContextValue.d.ts +0 -4
- package/dist/types/TCNSStimulationSerializedContextValue.d.ts.map +0 -1
- package/dist/types/TCNSSubscriber.d.ts +0 -7
- package/dist/types/TCNSSubscriber.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -76,14 +76,13 @@ import { CNSPersistOptionsRegistry } from '@cnstra/core';
|
|
|
76
76
|
export const registry = new CNSPersistOptionsRegistry();
|
|
77
77
|
|
|
78
78
|
// src/neurons/deck.ts — each neuron registers itself
|
|
79
|
-
import { collateral,
|
|
79
|
+
import { collateral, neuron } from '@cnstra/core';
|
|
80
80
|
import { registry } from './registry';
|
|
81
81
|
|
|
82
82
|
const deckCreated = collateral<{ deckId: string }>();
|
|
83
83
|
const importStarted = collateral<{ importId: string }>(); // external entry point
|
|
84
84
|
|
|
85
|
-
const deckNeuron =
|
|
86
|
-
.neuron({ deckCreated })
|
|
85
|
+
const deckNeuron = neuron({ deckCreated })
|
|
87
86
|
.bind({ importStarted }, {
|
|
88
87
|
importStarted: ({ importId }, axon) => axon.deckCreated.createSignal({ deckId: importId }),
|
|
89
88
|
});
|
|
@@ -122,7 +121,7 @@ const { cns, registry } = createCNS({ deckNeuron, cardNeuron });
|
|
|
122
121
|
- **[API Reference](https://cnstra.org/docs/core/api)** — Complete API documentation
|
|
123
122
|
- **[Concepts](https://cnstra.org/docs/core/concepts)** — Neurons, collaterals, signals, and the CNS model (Central Neural Network of your app)
|
|
124
123
|
- **[Recipes](https://cnstra.org/docs/recipes)** — Common patterns and use cases
|
|
125
|
-
- **[Advanced Topics](https://cnstra.org/docs/advanced)** — Performance,
|
|
124
|
+
- **[Advanced Topics](https://cnstra.org/docs/advanced)** — Performance, integrations
|
|
126
125
|
|
|
127
126
|
---
|
|
128
127
|
|
package/dist/CNS.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { ICNSCollateral } from '@cnstra/types';
|
|
2
|
+
import { TCNSNeuron } from '@cnstra/types';
|
|
3
|
+
import { TCNSDendrite } from '@cnstra/types';
|
|
4
|
+
import { TCNSOptions } from '@cnstra/types';
|
|
5
|
+
import { TCNSStimulationOptions } from '@cnstra/types';
|
|
5
6
|
import { CNSStimulation } from './CNSStimulation';
|
|
6
|
-
import { TCNSSignal } from '
|
|
7
|
+
import { TCNSSignal } from '@cnstra/types';
|
|
7
8
|
import { CNSInstanceNeuronQueue } from './CNSInstanceNeuronQueue';
|
|
8
|
-
import { TCNSStimulationResponse } from '
|
|
9
|
-
import { TCNSStimulationDrain } from '
|
|
10
|
-
import { TCNSNeuronActivationTask } from '
|
|
9
|
+
import { TCNSStimulationResponse } from '@cnstra/types';
|
|
10
|
+
import { TCNSStimulationDrain } from '@cnstra/types';
|
|
11
|
+
import { TCNSNeuronActivationTask } from '@cnstra/types';
|
|
11
12
|
import { CNSNetwork } from './CNSNetwork';
|
|
12
|
-
import { ICNS } from '
|
|
13
|
-
|
|
14
|
-
export declare class CNS<TNeuron extends TCNSNeuron<any, any>, TDendrite extends TCNSDendrite<any, any, any> = TCNSDendrite<any, any, any>> implements ICNS<TNeuron, TDendrite> {
|
|
13
|
+
import { ICNS } from '@cnstra/types';
|
|
14
|
+
export declare class CNS<TNeuron extends TCNSNeuron<any>, TDendrite extends TCNSDendrite<any, any, any> = TCNSDendrite<any, any, any>> implements ICNS<TNeuron, TDendrite> {
|
|
15
15
|
protected readonly neurons: TNeuron[];
|
|
16
16
|
readonly options?: TCNSOptions | undefined;
|
|
17
17
|
/**
|
|
@@ -38,6 +38,8 @@ export declare class CNS<TNeuron extends TCNSNeuron<any, any>, TDendrite extends
|
|
|
38
38
|
*/
|
|
39
39
|
readonly global?: unknown;
|
|
40
40
|
constructor(neurons: TNeuron[], options?: TCNSOptions | undefined, global?: unknown);
|
|
41
|
+
/** Push a listener onto a list; return an idempotent unsubscribe. */
|
|
42
|
+
private addListener;
|
|
41
43
|
addResponseListener(listener: (response: TCNSStimulationResponse) => void | Promise<void>): () => void;
|
|
42
44
|
/**
|
|
43
45
|
* Register a listener called once at the end of every synchronous turn of
|
|
@@ -57,7 +59,9 @@ export declare class CNS<TNeuron extends TCNSNeuron<any, any>, TDendrite extends
|
|
|
57
59
|
*/
|
|
58
60
|
private wrapOnDrain;
|
|
59
61
|
private wrapOnResponse;
|
|
60
|
-
|
|
62
|
+
/** Build a stimulation (wired listeners, unseeded). Shared by stimulate/activate. */
|
|
63
|
+
private createStimulation;
|
|
64
|
+
stimulate(signalOrSignals: TCNSSignal<ICNSCollateral<unknown>> | TCNSSignal<ICNSCollateral<unknown>>[], options?: TCNSStimulationOptions<TCNSStimulationResponse>): CNSStimulation<TNeuron, TDendrite>;
|
|
61
65
|
/**
|
|
62
66
|
* Start a stimulation with activation tasks directly
|
|
63
67
|
*/
|
package/dist/CNS.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CNS.d.ts","sourceRoot":"","sources":["../src/CNS.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"CNS.d.ts","sourceRoot":"","sources":["../src/CNS.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,qBAAa,GAAG,CACZ,OAAO,SAAS,UAA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sB,CAAC,uBAAuB,CAAC,GAC1D,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC;IAMrC;;OAEG;IACI,QAAQ,CACX,KAAK,EAAE,wBAAwB,CAAC,OAAO,CAAC,EAAE,EAC1C,OAAO,CAAC,EAAE,sBAAsB,CAAC,uBAAuB,CAAC,GAC1D,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC;CAKxC"}
|
package/dist/CNSCollateral.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TCNSSignal } from '
|
|
2
|
-
import { ICNSCollateral } from '
|
|
1
|
+
import { TCNSSignal } from '@cnstra/types';
|
|
2
|
+
import { ICNSCollateral } from '@cnstra/types';
|
|
3
3
|
export declare class CNSCollateral<TPayload> implements ICNSCollateral<TPayload> {
|
|
4
4
|
createSignal(): TCNSSignal<CNSCollateral<TPayload>>;
|
|
5
5
|
createSignal(payload: TPayload): TCNSSignal<CNSCollateral<TPayload>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CNSCollateral.d.ts","sourceRoot":"","sources":["../src/CNSCollateral.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"CNSCollateral.d.ts","sourceRoot":"","sources":["../src/CNSCollateral.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,qBAAa,aAAa,CAAC,QAAQ,CAAE,YAAW,cAAc,CAAC,QAAQ,CAAC;IACpE,YAAY,IAAI,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACnD,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;CAIvE"}
|
package/dist/CNSNetwork.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export declare class CNSNetwork<TNeuron extends TCNSNeuron<any
|
|
1
|
+
import type { ICNSCollateral } from '@cnstra/types';
|
|
2
|
+
import { TCNSNeuron } from '@cnstra/types';
|
|
3
|
+
import { TCNSSubscriber } from '@cnstra/types';
|
|
4
|
+
import { TCNSDendrite } from '@cnstra/types';
|
|
5
|
+
export declare class CNSNetwork<TNeuron extends TCNSNeuron<any>, TDendrite extends TCNSDendrite<any, any, any>> {
|
|
6
6
|
private readonly neurons;
|
|
7
7
|
/**
|
|
8
8
|
* Strongly Connected Components of the neuron graph.
|
|
9
9
|
* Each component is a set of neuron objects that can reach each other.
|
|
10
10
|
*
|
|
11
|
-
* Computed lazily on first access: the SCC machinery
|
|
12
|
-
*
|
|
11
|
+
* Computed lazily on first access: the SCC machinery only drives graph
|
|
12
|
+
* introspection (`getSCCSetByNeuron`, `canNeuronBeGuaranteedDone`), so a
|
|
13
|
+
* network that never inspects reachability never pays for it.
|
|
13
14
|
*/
|
|
14
15
|
private _stronglyConnectedComponents;
|
|
15
16
|
private sccBuilt;
|
|
@@ -68,9 +69,9 @@ export declare class CNSNetwork<TNeuron extends TCNSNeuron<any, any>, TDendrite
|
|
|
68
69
|
*/
|
|
69
70
|
canNeuronBeGuaranteedDone(neuron: TNeuron, activeSccCounts: Map<number, number>): boolean;
|
|
70
71
|
private buildIndexes;
|
|
71
|
-
getParentNeuronByCollateral(collateral:
|
|
72
|
+
getParentNeuronByCollateral(collateral: ICNSCollateral<unknown>): TNeuron | undefined;
|
|
72
73
|
getDendrites(): TDendrite[];
|
|
73
|
-
getCollaterals():
|
|
74
|
-
getSubscribers(collateral:
|
|
74
|
+
getCollaterals(): ICNSCollateral<unknown>[];
|
|
75
|
+
getSubscribers(collateral: ICNSCollateral<unknown>): TCNSSubscriber<TNeuron, TDendrite>[];
|
|
75
76
|
}
|
|
76
77
|
//# sourceMappingURL=CNSNetwork.d.ts.map
|
package/dist/CNSNetwork.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CNSNetwork.d.ts","sourceRoot":"","sources":["../src/CNSNetwork.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"CNSNetwork.d.ts","sourceRoot":"","sources":["../src/CNSNetwork.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,qBAAa,UAAU,CACnB,OAAO,SAAS,UAAU,CAAC,GAAG,CAAC,EAC/B,SAAS,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IA4CjC,OAAO,CAAC,QAAQ,CAAC,OAAO;IA1CpC;;;;;;;OAOG;IACH,OAAO,CAAC,4BAA4B,CAAsB;IAC1D,OAAO,CAAC,QAAQ,CAAS;IAEzB,IAAW,2BAA2B,IAAI,GAAG,CAAC,OAAO,CAAC,EAAE,CAGvD;IAED;;OAEG;IACH,OAAO,CAAC,WAAW,CAA8B;IAEjD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAuC;IAErD;;OAEG;IACH,OAAO,CAAC,YAAY,CAAuC;IAE3D;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAGZ;IAEJ,OAAO,CAAC,wBAAwB,CAA+C;gBAElD,OAAO,EAAE,OAAO,EAAE;IAM/C,+DAA+D;IAC/D,OAAO,CAAC,SAAS;IAMjB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAiCxB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAqEhB;;OAEG;IACH,OAAO,CAAC,WAAW;IA6BnB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAmDzB;;;;OAIG;IACI,iBAAiB,CAAC,MAAM,EAAE,OAAO;IASxC;;OAEG;IACI,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;IAK/D;;;OAGG;IACI,yBAAyB,CAC5B,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACrC,OAAO;IA6BV,OAAO,CAAC,YAAY;IAsBb,2BAA2B,CAAC,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC;IAM/D,YAAY;IAaZ,cAAc;IAUd,cAAc,CACjB,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC,GACpC,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;CAG1C"}
|
package/dist/CNSStimulation.d.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TCNSStimulationOptions } from '
|
|
3
|
-
import { TCNSNeuron } from '
|
|
4
|
-
import { TCNSDendrite } from '
|
|
5
|
-
import { TCNSSubscriber } from '
|
|
1
|
+
import type { ICNSCollateral } from '@cnstra/types';
|
|
2
|
+
import { TCNSStimulationOptions } from '@cnstra/types';
|
|
3
|
+
import { TCNSNeuron } from '@cnstra/types';
|
|
4
|
+
import { TCNSDendrite } from '@cnstra/types';
|
|
5
|
+
import { TCNSSubscriber } from '@cnstra/types';
|
|
6
6
|
import { CNSInstanceNeuronQueue } from './CNSInstanceNeuronQueue';
|
|
7
|
-
import { TCNSSignal } from '
|
|
8
|
-
import { TCNSNeuronActivationTask } from '
|
|
7
|
+
import { TCNSSignal } from '@cnstra/types';
|
|
8
|
+
import { TCNSNeuronActivationTask } from '@cnstra/types';
|
|
9
9
|
import { CNS } from './CNS';
|
|
10
|
-
import { TCNSNeuronActivationTaskFailure } from '
|
|
11
|
-
import { TCNSStimulationResponse } from '
|
|
12
|
-
import { TCNSStimulationDrain } from '
|
|
13
|
-
|
|
14
|
-
export declare class CNSStimulation<TNeuron extends TCNSNeuron<any, any>, TDendrite extends TCNSDendrite<any, any, any> = TCNSDendrite<any, any, any>> {
|
|
10
|
+
import { TCNSNeuronActivationTaskFailure } from '@cnstra/types';
|
|
11
|
+
import { TCNSStimulationResponse } from '@cnstra/types';
|
|
12
|
+
import { TCNSStimulationDrain } from '@cnstra/types';
|
|
13
|
+
export declare class CNSStimulation<TNeuron extends TCNSNeuron<any>, TDendrite extends TCNSDendrite<any, any, any> = TCNSDendrite<any, any, any>> {
|
|
15
14
|
readonly cns: CNS<TNeuron, TDendrite>;
|
|
16
15
|
readonly options?: TCNSStimulationOptions<TCNSStimulationResponse> | undefined;
|
|
17
|
-
private ctxStore?;
|
|
18
16
|
private qItems?;
|
|
19
17
|
private qHead;
|
|
20
18
|
private qTail;
|
|
@@ -49,17 +47,10 @@ export declare class CNSStimulation<TNeuron extends TCNSNeuron<any, any>, TDendr
|
|
|
49
47
|
* stimulation with no drain listener pays only the turn depth counter.
|
|
50
48
|
*/
|
|
51
49
|
private readonly onDrain?;
|
|
52
|
-
/**
|
|
53
|
-
* Track active SCCs: SCC index -> count of active neurons in that SCC.
|
|
54
|
-
* Only allocated when context auto-cleanup is enabled.
|
|
55
|
-
*/
|
|
56
|
-
private readonly activeSccCounts?;
|
|
57
50
|
constructor(cns: CNS<TNeuron, TDendrite>, instanceNeuronQueue: CNSInstanceNeuronQueue<TNeuron>, options?: TCNSStimulationOptions<TCNSStimulationResponse> | undefined, onResponse?: (response: TCNSStimulationResponse) => void | Promise<void>, onDrain?: (drain: TCNSStimulationDrain) => void);
|
|
58
51
|
private pushFailedTask;
|
|
59
52
|
private finalizeResolve;
|
|
60
53
|
private finalizeReject;
|
|
61
|
-
/** Lazily-created neuron context store (see {@link ctxStore}). */
|
|
62
|
-
private get ctx();
|
|
63
54
|
private get canStartOperation();
|
|
64
55
|
private qResize;
|
|
65
56
|
private qDequeue;
|
|
@@ -102,41 +93,23 @@ export declare class CNSStimulation<TNeuron extends TCNSNeuron<any, any>, TDendr
|
|
|
102
93
|
*/
|
|
103
94
|
getFailedTasks(): Array<TCNSNeuronActivationTaskFailure<TNeuron>>;
|
|
104
95
|
/**
|
|
105
|
-
*
|
|
96
|
+
* The current outstanding frontier — every task that has not completed:
|
|
97
|
+
* queued, active, and pending (awaiting an async onResponse), plus any
|
|
98
|
+
* failed/aborted tasks. This is the set to persist for resume: re-activating
|
|
99
|
+
* it re-runs exactly the not-yet-done work. Safe to call at any point during
|
|
100
|
+
* a run (for progress) or after it fails.
|
|
106
101
|
*/
|
|
107
|
-
|
|
102
|
+
getOutstandingTasks(): TCNSNeuronActivationTask<TNeuron>[];
|
|
108
103
|
/**
|
|
109
104
|
* Enqueue activation tasks directly into the stimulation queue
|
|
110
105
|
*/
|
|
111
106
|
enqueueTasks(tasks: TCNSNeuronActivationTask<TNeuron>[]): void;
|
|
112
107
|
protected get concurrencyEnabled(): boolean;
|
|
113
|
-
protected
|
|
114
|
-
/**
|
|
115
|
-
* Mark a neuron as active (being processed)
|
|
116
|
-
*/
|
|
117
|
-
protected markNeuronActive(neuron: TNeuron): void;
|
|
118
|
-
/**
|
|
119
|
-
* Mark a neuron as inactive (finished processing)
|
|
120
|
-
*/
|
|
121
|
-
protected markNeuronInactive(neuron: TNeuron): void;
|
|
122
|
-
/**
|
|
123
|
-
* Increment the active count for the SCC containing this neuron
|
|
124
|
-
*/
|
|
125
|
-
private incrementSccCount;
|
|
126
|
-
/**
|
|
127
|
-
* Decrement the active count for the SCC containing this neuron
|
|
128
|
-
*/
|
|
129
|
-
private decrementSccCount;
|
|
130
|
-
/**
|
|
131
|
-
* Check if a neuron can be guaranteed not to be visited again
|
|
132
|
-
*/
|
|
133
|
-
protected canNeuronBeGuaranteedDone(neuron: TNeuron): boolean;
|
|
134
|
-
protected cleanupCtxIfNeeded(neuron: TNeuron): void;
|
|
135
|
-
protected createSubscriberQueueItem(subscriber: TCNSSubscriber<TNeuron, TDendrite>, inputSignal?: TCNSSignal<CNSCollateral<unknown>>): TCNSNeuronActivationTask<TNeuron>;
|
|
108
|
+
protected createSubscriberQueueItem(subscriber: TCNSSubscriber<TNeuron, TDendrite>, inputSignal?: TCNSSignal<ICNSCollateral<unknown>>): TCNSNeuronActivationTask<TNeuron>;
|
|
136
109
|
private executeActivationTask;
|
|
137
110
|
private runStarter;
|
|
138
|
-
protected processResponseOrResponses(emitter: TNeuron | undefined, inputSignal?: TCNSSignal<
|
|
139
|
-
protected processResponse(emitter: TNeuron | undefined, inputSignal?: TCNSSignal<
|
|
140
|
-
responseToSignal(signalOrSignals: TCNSSignal<
|
|
111
|
+
protected processResponseOrResponses(emitter: TNeuron | undefined, inputSignal?: TCNSSignal<ICNSCollateral<unknown>>, outputSignalOrSignals?: TCNSSignal<ICNSCollateral<unknown>> | TCNSSignal<ICNSCollateral<unknown>>[], error?: any): void;
|
|
112
|
+
protected processResponse(emitter: TNeuron | undefined, inputSignal?: TCNSSignal<ICNSCollateral<unknown>>, outputSignal?: TCNSSignal<ICNSCollateral<unknown>>, error?: any): void;
|
|
113
|
+
responseToSignal(signalOrSignals: TCNSSignal<ICNSCollateral<unknown>> | TCNSSignal<ICNSCollateral<unknown>>[]): void;
|
|
141
114
|
}
|
|
142
115
|
//# sourceMappingURL=CNSStimulation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CNSStimulation.d.ts","sourceRoot":"","sources":["../src/CNSStimulation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CNSStimulation.d.ts","sourceRoot":"","sources":["../src/CNSStimulation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAA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ral } from '../CNSCollateral';
|
|
3
|
-
import {
|
|
4
|
-
import { TCNSAxon } from '
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { TCNSModality } from '../types/TCNSModality';
|
|
11
|
-
import { TCNSAfferentPath } from '../types/TCNSAfferentPath';
|
|
2
|
+
import type { ICNSCollateral } from '@cnstra/types';
|
|
3
|
+
import { TCNSAxon } from '@cnstra/types';
|
|
4
|
+
import { TCNSDendrite } from '@cnstra/types';
|
|
5
|
+
import { TCNSHandlerContext } from '@cnstra/types';
|
|
6
|
+
import { TCNSNeuronResponseReturn } from '@cnstra/types';
|
|
7
|
+
import { TCNSModality } from '@cnstra/types';
|
|
8
|
+
import { TCNSAfferentPath } from '@cnstra/types';
|
|
12
9
|
export declare const collateral: <TPayload = undefined>() => CNSCollateral<TPayload>;
|
|
13
|
-
type CollateralPayloadUnion<TCollaterals extends readonly
|
|
14
|
-
[K in keyof TCollaterals]: TCollaterals[K] extends
|
|
10
|
+
type CollateralPayloadUnion<TCollaterals extends readonly ICNSCollateral<unknown>[]> = {
|
|
11
|
+
[K in keyof TCollaterals]: TCollaterals[K] extends ICNSCollateral<infer P> ? P : never;
|
|
15
12
|
}[number];
|
|
16
|
-
type InterNeuronAPI<
|
|
13
|
+
type InterNeuronAPI<TAxonType extends TCNSAxon = TCNSAxon, TGlobal = unknown> = {
|
|
17
14
|
axon: TAxonType;
|
|
18
15
|
concurrency?: number;
|
|
19
16
|
maxDuration?: number;
|
|
20
|
-
dendrites: TCNSDendrite<
|
|
21
|
-
setConcurrency: (n: number | undefined) => InterNeuronAPI<
|
|
22
|
-
setMaxDuration: (ms: number | undefined) => InterNeuronAPI<
|
|
23
|
-
bind: <TFollowAxon extends Record<string,
|
|
24
|
-
[K in keyof TFollowAxon]: TCNSDendrite<
|
|
25
|
-
}) => InterNeuronAPI<
|
|
17
|
+
dendrites: TCNSDendrite<ICNSCollateral<unknown>, TAxonType, TGlobal>[];
|
|
18
|
+
setConcurrency: (n: number | undefined) => InterNeuronAPI<TAxonType, TGlobal>;
|
|
19
|
+
setMaxDuration: (ms: number | undefined) => InterNeuronAPI<TAxonType, TGlobal>;
|
|
20
|
+
bind: <TFollowAxon extends Record<string, ICNSCollateral<unknown>>>(axon: TFollowAxon, dendrites: {
|
|
21
|
+
[K in keyof TFollowAxon]: TCNSDendrite<TFollowAxon[K], TAxonType, TGlobal> | TCNSDendrite<TFollowAxon[K], TAxonType, TGlobal>['response'];
|
|
22
|
+
}) => InterNeuronAPI<TAxonType, TGlobal>;
|
|
26
23
|
dendrite: {
|
|
27
|
-
<TSenderCollateral extends
|
|
24
|
+
<TSenderCollateral extends ICNSCollateral<unknown>>(s: {
|
|
28
25
|
collateral: TSenderCollateral;
|
|
29
|
-
response: (payload: TSenderCollateral extends
|
|
30
|
-
}): InterNeuronAPI<
|
|
26
|
+
response: (payload: TSenderCollateral extends ICNSCollateral<infer P> ? P : never, axon: TAxonType, ctx: TCNSHandlerContext<TGlobal>) => TCNSNeuronResponseReturn<TAxonType>;
|
|
27
|
+
}): InterNeuronAPI<TAxonType, TGlobal>;
|
|
31
28
|
<TCollaterals extends readonly [
|
|
32
|
-
|
|
33
|
-
...
|
|
29
|
+
ICNSCollateral<unknown>,
|
|
30
|
+
...ICNSCollateral<unknown>[]
|
|
34
31
|
]>(s: {
|
|
35
32
|
collateral: TCollaterals;
|
|
36
|
-
response: (payload: CollateralPayloadUnion<TCollaterals>, axon: TAxonType, ctx: TCNSHandlerContext<
|
|
37
|
-
}): InterNeuronAPI<
|
|
33
|
+
response: (payload: CollateralPayloadUnion<TCollaterals>, axon: TAxonType, ctx: TCNSHandlerContext<TGlobal>) => TCNSNeuronResponseReturn<TAxonType>;
|
|
34
|
+
}): InterNeuronAPI<TAxonType, TGlobal>;
|
|
38
35
|
<TPayloadUnion>(s: {
|
|
39
|
-
collateral:
|
|
40
|
-
response: (payload: TPayloadUnion, axon: TAxonType, ctx: TCNSHandlerContext<
|
|
41
|
-
}): InterNeuronAPI<
|
|
42
|
-
(s: TCNSDendrite<
|
|
36
|
+
collateral: ICNSCollateral<unknown>[];
|
|
37
|
+
response: (payload: TPayloadUnion, axon: TAxonType, ctx: TCNSHandlerContext<TGlobal>) => TCNSNeuronResponseReturn<TAxonType>;
|
|
38
|
+
}): InterNeuronAPI<TAxonType, TGlobal>;
|
|
39
|
+
(s: TCNSDendrite<ICNSCollateral<unknown>, TAxonType, TGlobal>): InterNeuronAPI<TAxonType, TGlobal>;
|
|
43
40
|
};
|
|
44
41
|
modalityDendrite: {
|
|
45
|
-
<TSenderCollateral extends
|
|
42
|
+
<TSenderCollateral extends ICNSCollateral<unknown>, TResult>(s: {
|
|
46
43
|
collateral: TSenderCollateral;
|
|
47
44
|
modality: TCNSModality;
|
|
48
|
-
afferentPaths?: Map<TCNSAfferentPath, (payload: TSenderCollateral extends
|
|
49
|
-
default?: (payload: TSenderCollateral extends
|
|
50
|
-
output: (result: TResult, axon: TAxonType, ctx: TCNSHandlerContext<
|
|
51
|
-
}): InterNeuronAPI<
|
|
52
|
-
<TSenderCollateral extends
|
|
45
|
+
afferentPaths?: Map<TCNSAfferentPath, (payload: TSenderCollateral extends ICNSCollateral<infer P> ? P : never, axon: TAxonType, ctx: TCNSHandlerContext<TGlobal>) => TResult | Promise<TResult>>;
|
|
46
|
+
default?: (payload: TSenderCollateral extends ICNSCollateral<infer P> ? P : never, axon: TAxonType, ctx: TCNSHandlerContext<TGlobal>) => TResult | Promise<TResult>;
|
|
47
|
+
output: (result: TResult, axon: TAxonType, ctx: TCNSHandlerContext<TGlobal>) => TCNSNeuronResponseReturn<TAxonType>;
|
|
48
|
+
}): InterNeuronAPI<TAxonType, TGlobal>;
|
|
49
|
+
<TSenderCollateral extends ICNSCollateral<unknown>, TResult>(s: {
|
|
53
50
|
collateral: TSenderCollateral;
|
|
54
51
|
modalities: Array<{
|
|
55
52
|
modality: TCNSModality;
|
|
56
|
-
afferentPaths?: Map<TCNSAfferentPath, (payload: TSenderCollateral extends
|
|
57
|
-
default?: (payload: TSenderCollateral extends
|
|
53
|
+
afferentPaths?: Map<TCNSAfferentPath, (payload: TSenderCollateral extends ICNSCollateral<infer P> ? P : never, axon: TAxonType, ctx: TCNSHandlerContext<TGlobal>) => TResult | Promise<TResult>>;
|
|
54
|
+
default?: (payload: TSenderCollateral extends ICNSCollateral<infer P> ? P : never, axon: TAxonType, ctx: TCNSHandlerContext<TGlobal>) => TResult | Promise<TResult>;
|
|
58
55
|
}>;
|
|
59
|
-
default?: (payload: TSenderCollateral extends
|
|
60
|
-
output: (result: TResult, axon: TAxonType, ctx: TCNSHandlerContext<
|
|
61
|
-
}): InterNeuronAPI<
|
|
56
|
+
default?: (payload: TSenderCollateral extends ICNSCollateral<infer P> ? P : never, axon: TAxonType, ctx: TCNSHandlerContext<TGlobal>) => TResult | Promise<TResult>;
|
|
57
|
+
output: (result: TResult, axon: TAxonType, ctx: TCNSHandlerContext<TGlobal>) => TCNSNeuronResponseReturn<TAxonType>;
|
|
58
|
+
}): InterNeuronAPI<TAxonType, TGlobal>;
|
|
62
59
|
};
|
|
63
60
|
};
|
|
64
|
-
export declare const neuron: <
|
|
61
|
+
export declare const neuron: <TProvidedAxon extends Record<string, ICNSCollateral<unknown>>, TGlobal = unknown>(axon: TProvidedAxon) => InterNeuronAPI<TCNSAxon<TProvidedAxon>, TGlobal>;
|
|
65
62
|
/**
|
|
66
63
|
* A composable neuron factory. Each `.withX<T>()` returns a *new typed view* of
|
|
67
64
|
* the same underlying builder (the layers are type-only — zero runtime cost, no
|
|
@@ -77,7 +74,7 @@ export declare const neuron: <TContextValue, TProvidedAxon extends Record<string
|
|
|
77
74
|
* @example
|
|
78
75
|
* // src/neurons/factory.ts — ctx shape baked once
|
|
79
76
|
* type TGlobal = { store: Store; now(): number; newId(): string };
|
|
80
|
-
* export const { neuron } = neuronFactory().withGlobal<TGlobal>()
|
|
77
|
+
* export const { neuron } = neuronFactory().withGlobal<TGlobal>();
|
|
81
78
|
*
|
|
82
79
|
* // any neuron file — plain value, reaches deps via ctx.global
|
|
83
80
|
* export const taskNeuron = neuron({ taskCreated }).bind({ createTask }, {
|
|
@@ -85,76 +82,19 @@ export declare const neuron: <TContextValue, TProvidedAxon extends Record<string
|
|
|
85
82
|
* axon.taskCreated.createSignal({ id: global.newId(), title, at: global.now() }),
|
|
86
83
|
* });
|
|
87
84
|
*/
|
|
88
|
-
export type TNeuronFactory<
|
|
89
|
-
/** Bake the per-stimulation, per-neuron context value type (`ctx.get()/set()`). */
|
|
90
|
-
withCtx: <T>() => TNeuronFactory<T, TExt>;
|
|
85
|
+
export type TNeuronFactory<TExt = unknown> = {
|
|
91
86
|
/** Add `{ global: T }` to ctx; the value is injected once at `createCNS`/`new CNS`. */
|
|
92
|
-
withGlobal: <T>() => TNeuronFactory<
|
|
87
|
+
withGlobal: <T>() => TNeuronFactory<TExt & {
|
|
93
88
|
global: T;
|
|
94
89
|
}>;
|
|
95
|
-
neuron: <TProvidedAxon extends Record<string,
|
|
90
|
+
neuron: <TProvidedAxon extends Record<string, ICNSCollateral<unknown>>>(axon: TProvidedAxon) => InterNeuronAPI<TCNSAxon<TProvidedAxon>, TExt>;
|
|
96
91
|
};
|
|
97
|
-
export declare const neuronFactory: <
|
|
98
|
-
/** Sugar: `neuronFactory().withCtx<T>()`. Still exposes `.neuron`, so existing usage is unchanged. */
|
|
99
|
-
export declare const withCtx: <TContextValue>() => TNeuronFactory<TContextValue>;
|
|
92
|
+
export declare const neuronFactory: <TExt = unknown>() => TNeuronFactory<TExt>;
|
|
100
93
|
/** Sugar: `neuronFactory().withGlobal<T>()`. */
|
|
101
|
-
export declare const withGlobal: <T>() => TNeuronFactory<
|
|
94
|
+
export declare const withGlobal: <T>() => TNeuronFactory<{
|
|
102
95
|
global: T;
|
|
103
96
|
}>;
|
|
104
97
|
export declare const afferentPath: (parentAfferentPath?: TCNSAfferentPath) => TCNSAfferentPath;
|
|
105
98
|
export declare const modality: (afferentPaths: Record<string | number, TCNSAfferentPath>) => TCNSModality;
|
|
106
|
-
type CNSRegistryValue<N extends TCNSNeuron<any, any>> = N | (N extends TCNSNeuron<any, infer TAxon> ? {
|
|
107
|
-
neuron: N;
|
|
108
|
-
collaterals?: {
|
|
109
|
-
[K in keyof TAxon]?: string;
|
|
110
|
-
};
|
|
111
|
-
} : never);
|
|
112
|
-
/**
|
|
113
|
-
* Creates a CNSPersistOptionsRegistry from a plain object of named neurons.
|
|
114
|
-
* All axon collaterals are registered automatically.
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* // Auto names from JS identifiers:
|
|
118
|
-
* export const registry = createPersistRegistry({ deckNeuron, cardNeuron });
|
|
119
|
-
*
|
|
120
|
-
* // Explicit neuron name:
|
|
121
|
-
* export const registry = createPersistRegistry({ 'deck-neuron': deckNeuron });
|
|
122
|
-
*
|
|
123
|
-
* // Explicit collateral names (keys are type-checked against the neuron's axon):
|
|
124
|
-
* export const registry = createPersistRegistry({
|
|
125
|
-
* 'deck-neuron': { neuron: deckNeuron, collaterals: { deckCreated: 'deck-created' } }
|
|
126
|
-
* });
|
|
127
|
-
*/
|
|
128
|
-
export declare const createPersistRegistry: <TMap extends Record<string, TCNSNeuron<any, any>>>(namedNeurons: { [K in keyof TMap]: CNSRegistryValue<TMap[K]>; }) => CNSPersistOptionsRegistry;
|
|
129
|
-
/**
|
|
130
|
-
* Creates a CNS and its CNSPersistOptionsRegistry from a single plain object of
|
|
131
|
-
* named neurons, so the neuron set is listed exactly once.
|
|
132
|
-
*
|
|
133
|
-
* `cns` is the runtime engine; `registry` carries the names used by devtools,
|
|
134
|
-
* mcp and persistence. Both derive from the same map, so they can never drift.
|
|
135
|
-
* If you don't need naming/persistence, just use `new CNS([...])` directly —
|
|
136
|
-
* this factory is purely additive.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* const { cns, registry } = createCNS({
|
|
140
|
-
* task: createTaskNeuron(store),
|
|
141
|
-
* comment: createCommentNeuron(store),
|
|
142
|
-
* });
|
|
143
|
-
*
|
|
144
|
-
* // Explicit names / collateral names work exactly like createPersistRegistry:
|
|
145
|
-
* const { cns, registry } = createCNS({
|
|
146
|
-
* 'task-neuron': { neuron: taskNeuron, collaterals: { taskCreated: 'task-created' } },
|
|
147
|
-
* });
|
|
148
|
-
*
|
|
149
|
-
* // Inject the shared `global` once — it surfaces as `ctx.global` in every neuron
|
|
150
|
-
* // (type it once via `neuronFactory().withGlobal<T>()`). Swappable per instance:
|
|
151
|
-
* const { cns } = createCNS(map, { global: { store, now, newId } });
|
|
152
|
-
*/
|
|
153
|
-
export declare const createCNS: <TMap extends Record<string, TCNSNeuron<any, any>>, TGlobal = undefined>(namedNeurons: { [K in keyof TMap]: CNSRegistryValue<TMap[K]>; }, options?: TCNSOptions & {
|
|
154
|
-
global?: TGlobal;
|
|
155
|
-
}) => {
|
|
156
|
-
cns: CNS<TCNSNeuron<any, any>>;
|
|
157
|
-
registry: CNSPersistOptionsRegistry;
|
|
158
|
-
};
|
|
159
99
|
export {};
|
|
160
100
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C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