@jay-framework/stack-server-runtime 0.11.0 → 0.13.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/dist/index.d.ts +430 -30
- package/dist/index.js +968 -100
- package/package.json +13 -11
package/dist/index.d.ts
CHANGED
|
@@ -2,15 +2,36 @@ import { AnyJayStackComponentDefinition, PageProps, AnySlowlyRenderResult, UrlPa
|
|
|
2
2
|
import { JayComponentCore } from '@jay-framework/component';
|
|
3
3
|
import { ViteDevServer } from 'vite';
|
|
4
4
|
import { JayRoute } from '@jay-framework/stack-route-scanner';
|
|
5
|
-
import { WithValidations } from '@jay-framework/compiler-shared';
|
|
5
|
+
import { WithValidations, JsonSchemaProperty, PluginManifest } from '@jay-framework/compiler-shared';
|
|
6
|
+
export { JsonSchemaProperty } from '@jay-framework/compiler-shared';
|
|
7
|
+
import { Contract, HeadlessContractInfo, ForEachHeadlessInstance, DiscoveredHeadlessInstance } from '@jay-framework/compiler-jay-html';
|
|
8
|
+
export { ForEachHeadlessInstance } from '@jay-framework/compiler-jay-html';
|
|
6
9
|
import { JayRollupConfig } from '@jay-framework/rollup-plugin';
|
|
7
10
|
import { TrackByMap } from '@jay-framework/view-state-merge';
|
|
11
|
+
import { Coordinate } from '@jay-framework/runtime';
|
|
8
12
|
|
|
9
13
|
interface DevServerPagePart {
|
|
10
14
|
compDefinition: AnyJayStackComponentDefinition;
|
|
11
15
|
key?: string;
|
|
12
16
|
clientImport: string;
|
|
13
17
|
clientPart: string;
|
|
18
|
+
/** Contract metadata for dynamic contract components */
|
|
19
|
+
contractInfo?: {
|
|
20
|
+
contractName: string;
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Instance-only headless component (no key attribute).
|
|
26
|
+
* Used for server-side phase orchestration of `<jay:xxx>` instances.
|
|
27
|
+
*/
|
|
28
|
+
interface HeadlessInstanceComponent {
|
|
29
|
+
/** Contract name from the script tag (e.g., "product-card") */
|
|
30
|
+
contractName: string;
|
|
31
|
+
/** Component definition for calling slowlyRender/fastRender */
|
|
32
|
+
compDefinition: AnyJayStackComponentDefinition;
|
|
33
|
+
/** Parsed contract (for phase detection in slow render Pass 2) */
|
|
34
|
+
contract: Contract;
|
|
14
35
|
}
|
|
15
36
|
interface LoadedPageParts {
|
|
16
37
|
parts: DevServerPagePart[];
|
|
@@ -20,6 +41,10 @@ interface LoadedPageParts {
|
|
|
20
41
|
clientTrackByMap?: Record<string, string>;
|
|
21
42
|
/** NPM package names used on this page (for filtering plugin inits) */
|
|
22
43
|
usedPackages: Set<string>;
|
|
44
|
+
/** Headless contracts for slow rendering (already loaded by parseJayFile) */
|
|
45
|
+
headlessContracts: HeadlessContractInfo[];
|
|
46
|
+
/** Instance-only headless components (no key) for server-side phase orchestration */
|
|
47
|
+
headlessInstanceComponents: HeadlessInstanceComponent[];
|
|
23
48
|
}
|
|
24
49
|
interface LoadPagePartsOptions {
|
|
25
50
|
/**
|
|
@@ -44,6 +69,50 @@ declare function runSlowlyChangingRender<Refs extends object, SlowVS extends obj
|
|
|
44
69
|
|
|
45
70
|
declare function renderFastChangingData(pageParams: object, pageProps: PageProps, carryForward: object, parts: Array<DevServerPagePart>): Promise<AnyFastRenderResult>;
|
|
46
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Action metadata loaded from .jay-action files.
|
|
74
|
+
*
|
|
75
|
+
* Uses the compiler's parseAction to parse .jay-action YAML into JayType,
|
|
76
|
+
* then converts JayType → JSON Schema for consumers (AI agent tool builders).
|
|
77
|
+
*
|
|
78
|
+
* Actions without .jay-action files are not exposed to AI agents.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Input schema for an action (JSON Schema object type).
|
|
83
|
+
*/
|
|
84
|
+
interface ActionSchema {
|
|
85
|
+
type: 'object';
|
|
86
|
+
properties: Record<string, JsonSchemaProperty>;
|
|
87
|
+
required?: string[];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Metadata loaded from a .jay-action file.
|
|
91
|
+
*/
|
|
92
|
+
interface ActionMetadata {
|
|
93
|
+
/** Action name (must match the export name in plugin code) */
|
|
94
|
+
name: string;
|
|
95
|
+
/** Human-readable description of what the action does */
|
|
96
|
+
description: string;
|
|
97
|
+
/** JSON Schema for the action's input parameters */
|
|
98
|
+
inputSchema: ActionSchema;
|
|
99
|
+
/** JSON Schema for the action's output (optional) */
|
|
100
|
+
outputSchema?: JsonSchemaProperty;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Parses a .jay-action YAML string into ActionMetadata.
|
|
104
|
+
* Uses the compiler's parseAction to produce JayType, then converts to JSON Schema.
|
|
105
|
+
*/
|
|
106
|
+
declare function parseActionMetadata(yamlContent: string, fileName: string): ActionMetadata | null;
|
|
107
|
+
/**
|
|
108
|
+
* Loads action metadata from a .jay-action file on disk.
|
|
109
|
+
*/
|
|
110
|
+
declare function loadActionMetadata(filePath: string): ActionMetadata | null;
|
|
111
|
+
/**
|
|
112
|
+
* Resolves the absolute path of a .jay-action file relative to a plugin directory.
|
|
113
|
+
*/
|
|
114
|
+
declare function resolveActionMetadataPath(actionPath: string, pluginDir: string): string;
|
|
115
|
+
|
|
47
116
|
/**
|
|
48
117
|
* Action registry for Jay Stack server-side action handling.
|
|
49
118
|
*
|
|
@@ -65,6 +134,9 @@ interface RegisteredAction {
|
|
|
65
134
|
services: any[];
|
|
66
135
|
/** The handler function */
|
|
67
136
|
handler: (input: any, ...services: any[]) => Promise<any>;
|
|
137
|
+
/** Optional metadata from .jay-action file (description, input/output schemas).
|
|
138
|
+
* Actions with metadata are exposed to AI agents; those without are not. */
|
|
139
|
+
metadata?: ActionMetadata;
|
|
68
140
|
}
|
|
69
141
|
/**
|
|
70
142
|
* Result of executing an action.
|
|
@@ -130,6 +202,24 @@ declare class ActionRegistry {
|
|
|
130
202
|
* @returns Array of registered action names
|
|
131
203
|
*/
|
|
132
204
|
getNames(): string[];
|
|
205
|
+
/**
|
|
206
|
+
* Attaches metadata from a .jay-action file to a registered action.
|
|
207
|
+
* Called during action discovery when a plugin declares action metadata.
|
|
208
|
+
*
|
|
209
|
+
* @param actionName - The action name
|
|
210
|
+
* @param metadata - Parsed ActionMetadata from .jay-action file
|
|
211
|
+
*/
|
|
212
|
+
setMetadata(actionName: string, metadata: ActionMetadata): void;
|
|
213
|
+
/**
|
|
214
|
+
* Gets all registered actions that have .jay-action metadata.
|
|
215
|
+
* These are the actions that should be exposed to AI agents.
|
|
216
|
+
*
|
|
217
|
+
* @returns Array of { actionName, metadata } for actions with metadata
|
|
218
|
+
*/
|
|
219
|
+
getActionsWithMetadata(): Array<{
|
|
220
|
+
actionName: string;
|
|
221
|
+
metadata: ActionMetadata;
|
|
222
|
+
}>;
|
|
133
223
|
/**
|
|
134
224
|
* Clears all registered actions.
|
|
135
225
|
*/
|
|
@@ -191,33 +281,6 @@ declare function executeAction<T = any>(actionName: string, input: unknown): Pro
|
|
|
191
281
|
* @deprecated Use actionRegistry.getCacheHeaders() instead
|
|
192
282
|
*/
|
|
193
283
|
declare function getActionCacheHeaders(actionName: string): string | undefined;
|
|
194
|
-
/**
|
|
195
|
-
* Executes an action directly with proper service injection.
|
|
196
|
-
* Use this when calling actions from backend code (e.g., render phases).
|
|
197
|
-
*
|
|
198
|
-
* Unlike calling the action directly (which bypasses service injection),
|
|
199
|
-
* this function resolves services and calls the handler correctly.
|
|
200
|
-
*
|
|
201
|
-
* @param action - The JayAction to execute (with definition metadata)
|
|
202
|
-
* @param input - The input data for the action
|
|
203
|
-
* @returns The action result (throws on error)
|
|
204
|
-
*
|
|
205
|
-
* @example
|
|
206
|
-
* ```typescript
|
|
207
|
-
* // In a render phase
|
|
208
|
-
* import { runAction } from '@jay-framework/stack-server-runtime';
|
|
209
|
-
* import { searchProducts } from '../actions/stores-actions';
|
|
210
|
-
*
|
|
211
|
-
* async function renderFastChanging(props, slowCarryForward, wixStores) {
|
|
212
|
-
* // ✅ Correct - services are injected
|
|
213
|
-
* const result = await runAction(searchProducts, { query: '', pageSize: 12 });
|
|
214
|
-
*
|
|
215
|
-
* // ❌ Wrong - services are NOT injected (passes empty array)
|
|
216
|
-
* // const result = await searchProducts({ query: '', pageSize: 12 });
|
|
217
|
-
* }
|
|
218
|
-
* ```
|
|
219
|
-
*/
|
|
220
|
-
declare function runAction<I, O>(action: JayAction<I, O> & JayActionDefinition<I, O, any[]>, input: I): Promise<O>;
|
|
221
284
|
|
|
222
285
|
/**
|
|
223
286
|
* Action discovery and auto-registration for Jay Stack.
|
|
@@ -350,6 +413,8 @@ interface PluginWithInit {
|
|
|
350
413
|
initExport: string;
|
|
351
414
|
/** Dependencies from package.json (for ordering) */
|
|
352
415
|
dependencies: string[];
|
|
416
|
+
/** When true, plugin is loaded on every page regardless of usage in jay-html */
|
|
417
|
+
global: boolean;
|
|
353
418
|
}
|
|
354
419
|
/**
|
|
355
420
|
* Options for plugin init discovery.
|
|
@@ -387,7 +452,7 @@ declare function sortPluginsByDependencies(plugins: PluginWithInit[]): PluginWit
|
|
|
387
452
|
* @param viteServer - Vite server for SSR module loading (optional)
|
|
388
453
|
* @param verbose - Whether to log progress
|
|
389
454
|
*/
|
|
390
|
-
declare function executePluginServerInits(plugins: PluginWithInit[], viteServer?: ViteSSRLoader, verbose?: boolean): Promise<
|
|
455
|
+
declare function executePluginServerInits(plugins: PluginWithInit[], viteServer?: ViteSSRLoader, verbose?: boolean): Promise<Map<string, Error>>;
|
|
391
456
|
/**
|
|
392
457
|
* Information needed to generate client init script for a plugin.
|
|
393
458
|
*/
|
|
@@ -489,6 +554,11 @@ declare function hasService<ServiceType>(marker: ServiceMarker<ServiceType>): bo
|
|
|
489
554
|
* Internal API used by dev-server during hot reload.
|
|
490
555
|
*/
|
|
491
556
|
declare function clearServiceRegistry(): void;
|
|
557
|
+
/**
|
|
558
|
+
* Returns the internal service registry map.
|
|
559
|
+
* Internal API used by contract materializer to pass services to dynamic generators.
|
|
560
|
+
*/
|
|
561
|
+
declare function getServiceRegistry(): Map<symbol, any>;
|
|
492
562
|
/**
|
|
493
563
|
* Resolves an array of service markers to their registered instances.
|
|
494
564
|
* Used by the runtime to inject services into render functions.
|
|
@@ -598,6 +668,62 @@ declare function getClientInitDataForKey(key: string): Record<string, any>;
|
|
|
598
668
|
*/
|
|
599
669
|
declare function clearClientInitData(): void;
|
|
600
670
|
|
|
671
|
+
/**
|
|
672
|
+
* Server-side slow render orchestration for headless component instances.
|
|
673
|
+
*
|
|
674
|
+
* Given discovered instances (from discoverHeadlessInstances) and their
|
|
675
|
+
* component definitions, runs slowlyRender for each instance and collects
|
|
676
|
+
* the results for downstream consumers (pre-render pipeline, direct mode, fast phase).
|
|
677
|
+
*/
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Data needed by the fast phase to render headless instances.
|
|
681
|
+
* Stored in carryForward.__instances so the fast phase can access it
|
|
682
|
+
* (both in pre-render and cached flows).
|
|
683
|
+
*/
|
|
684
|
+
interface InstancePhaseData {
|
|
685
|
+
/** Discovered instances with their props and coordinates */
|
|
686
|
+
discovered: Array<{
|
|
687
|
+
contractName: string;
|
|
688
|
+
props: Record<string, string>;
|
|
689
|
+
coordinate: Coordinate;
|
|
690
|
+
}>;
|
|
691
|
+
/** CarryForward per instance (keyed by coordinate path, e.g. "p1/product-card:0") */
|
|
692
|
+
carryForwards: Record<string, object>;
|
|
693
|
+
/** ForEach instances that need fast-phase per-item rendering */
|
|
694
|
+
forEachInstances?: ForEachHeadlessInstance[];
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Result of running slowlyRender for all discovered headless instances.
|
|
698
|
+
*/
|
|
699
|
+
interface InstanceSlowRenderResult {
|
|
700
|
+
/** Resolved data for each instance (for resolveHeadlessInstances pass 2) */
|
|
701
|
+
resolvedData: Array<{
|
|
702
|
+
coordinate: Coordinate;
|
|
703
|
+
contract: Contract;
|
|
704
|
+
slowViewState: Record<string, unknown>;
|
|
705
|
+
}>;
|
|
706
|
+
/** Per-instance slow ViewState keyed by coordinate (for direct mode merge) */
|
|
707
|
+
slowViewStates: Record<string, object>;
|
|
708
|
+
/** Phase data for the fast render phase */
|
|
709
|
+
instancePhaseData: InstancePhaseData;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Run slowlyRender for each discovered headless instance.
|
|
713
|
+
*
|
|
714
|
+
* Shared between preRenderJayHtml (pre-render path) and handleDirectRequest (direct path).
|
|
715
|
+
*/
|
|
716
|
+
declare function slowRenderInstances(discovered: DiscoveredHeadlessInstance[], headlessInstanceComponents: HeadlessInstanceComponent[]): Promise<InstanceSlowRenderResult | undefined>;
|
|
717
|
+
/**
|
|
718
|
+
* Validate that forEach headless instances do not have a slow phase.
|
|
719
|
+
*
|
|
720
|
+
* Components with slowlyRender cannot be used inside forEach because
|
|
721
|
+
* forEach items are only known at request time, after slow rendering completes.
|
|
722
|
+
*
|
|
723
|
+
* @returns Array of validation error messages (empty if all valid)
|
|
724
|
+
*/
|
|
725
|
+
declare function validateForEachInstances(forEachInstances: ForEachHeadlessInstance[], headlessInstanceComponents: HeadlessInstanceComponent[]): string[];
|
|
726
|
+
|
|
601
727
|
/**
|
|
602
728
|
* Cache entry for pre-rendered jay-html
|
|
603
729
|
*/
|
|
@@ -677,4 +803,278 @@ declare class SlowRenderCache {
|
|
|
677
803
|
getCachedPaths(): string[];
|
|
678
804
|
}
|
|
679
805
|
|
|
680
|
-
|
|
806
|
+
/**
|
|
807
|
+
* Contract Materializer
|
|
808
|
+
*
|
|
809
|
+
* Materializes dynamic contracts to disk for agent discovery.
|
|
810
|
+
* Also creates an index file listing both static and dynamic contracts.
|
|
811
|
+
*
|
|
812
|
+
* @see Design Log #80 - Materializing Dynamic Contracts for Agentic Page Generation
|
|
813
|
+
*/
|
|
814
|
+
|
|
815
|
+
interface ContractIndexEntry {
|
|
816
|
+
plugin: string;
|
|
817
|
+
name: string;
|
|
818
|
+
type: 'static' | 'dynamic';
|
|
819
|
+
path: string;
|
|
820
|
+
metadata?: Record<string, unknown>;
|
|
821
|
+
}
|
|
822
|
+
interface ContractsIndex {
|
|
823
|
+
materialized_at: string;
|
|
824
|
+
jay_stack_version: string;
|
|
825
|
+
contracts: ContractIndexEntry[];
|
|
826
|
+
}
|
|
827
|
+
/** Action metadata entry in plugins-index.yaml */
|
|
828
|
+
interface ActionIndexEntry {
|
|
829
|
+
name: string;
|
|
830
|
+
description: string;
|
|
831
|
+
/** Path to the .jay-action file (relative to project root) */
|
|
832
|
+
path: string;
|
|
833
|
+
}
|
|
834
|
+
/** Entry for plugins-index.yaml (Design Log #85) */
|
|
835
|
+
interface PluginsIndexEntry {
|
|
836
|
+
name: string;
|
|
837
|
+
path: string;
|
|
838
|
+
contracts: Array<{
|
|
839
|
+
name: string;
|
|
840
|
+
type: 'static' | 'dynamic';
|
|
841
|
+
path: string;
|
|
842
|
+
}>;
|
|
843
|
+
/** Actions with .jay-action metadata (exposed to AI agents) */
|
|
844
|
+
actions?: ActionIndexEntry[];
|
|
845
|
+
}
|
|
846
|
+
interface PluginsIndex {
|
|
847
|
+
materialized_at: string;
|
|
848
|
+
jay_stack_version: string;
|
|
849
|
+
plugins: PluginsIndexEntry[];
|
|
850
|
+
}
|
|
851
|
+
interface MaterializeContractsOptions {
|
|
852
|
+
projectRoot: string;
|
|
853
|
+
outputDir?: string;
|
|
854
|
+
force?: boolean;
|
|
855
|
+
dynamicOnly?: boolean;
|
|
856
|
+
pluginFilter?: string;
|
|
857
|
+
verbose?: boolean;
|
|
858
|
+
/** Optional Vite server for TypeScript support */
|
|
859
|
+
viteServer?: ViteSSRLoader;
|
|
860
|
+
}
|
|
861
|
+
interface MaterializeResult {
|
|
862
|
+
index: ContractsIndex;
|
|
863
|
+
staticCount: number;
|
|
864
|
+
dynamicCount: number;
|
|
865
|
+
outputDir: string;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Materializes all contracts (static references + dynamic generated) to disk.
|
|
869
|
+
*
|
|
870
|
+
* @param options - Materialization options
|
|
871
|
+
* @param services - Map of service markers to service instances (from init.ts)
|
|
872
|
+
*/
|
|
873
|
+
declare function materializeContracts(options: MaterializeContractsOptions, services?: Map<symbol, unknown>): Promise<MaterializeResult>;
|
|
874
|
+
/**
|
|
875
|
+
* Lists contracts without writing files (for --list mode)
|
|
876
|
+
*/
|
|
877
|
+
declare function listContracts(options: MaterializeContractsOptions): Promise<ContractsIndex>;
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Plugin Scanner
|
|
881
|
+
*
|
|
882
|
+
* Shared utility for scanning Jay plugins in a project.
|
|
883
|
+
* Used by both plugin-init-discovery and contract-materializer.
|
|
884
|
+
*/
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Basic plugin information from scanning.
|
|
888
|
+
*/
|
|
889
|
+
interface ScannedPlugin {
|
|
890
|
+
/** Plugin name (from plugin.yaml or directory/package name) */
|
|
891
|
+
name: string;
|
|
892
|
+
/** Full path to plugin directory */
|
|
893
|
+
pluginPath: string;
|
|
894
|
+
/** Package name for NPM plugins, or directory name for local plugins */
|
|
895
|
+
packageName: string;
|
|
896
|
+
/** Whether this is a local plugin (src/plugins/) or NPM package */
|
|
897
|
+
isLocal: boolean;
|
|
898
|
+
/** Parsed plugin.yaml manifest */
|
|
899
|
+
manifest: PluginManifest;
|
|
900
|
+
/** Dependencies from package.json (for ordering) */
|
|
901
|
+
dependencies: string[];
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Options for plugin scanning.
|
|
905
|
+
*/
|
|
906
|
+
interface PluginScanOptions {
|
|
907
|
+
/** Project root directory */
|
|
908
|
+
projectRoot: string;
|
|
909
|
+
/** Whether to log discovery progress */
|
|
910
|
+
verbose?: boolean;
|
|
911
|
+
/** Whether to include dev dependencies (default: false) */
|
|
912
|
+
includeDevDeps?: boolean;
|
|
913
|
+
/** Whether to discover transitive plugin dependencies (default: false) */
|
|
914
|
+
discoverTransitive?: boolean;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Scans for all Jay plugins in a project.
|
|
918
|
+
*
|
|
919
|
+
* Scans both local plugins (src/plugins/) and NPM plugins (node_modules/).
|
|
920
|
+
* Returns basic plugin information that can be used by different consumers
|
|
921
|
+
* (init discovery, contract materialization, etc.)
|
|
922
|
+
*
|
|
923
|
+
* @param options - Scanning options
|
|
924
|
+
* @returns Map of package/directory name to plugin info
|
|
925
|
+
*/
|
|
926
|
+
declare function scanPlugins(options: PluginScanOptions): Promise<Map<string, ScannedPlugin>>;
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* Plugin Setup and References (Design Log #87)
|
|
930
|
+
*
|
|
931
|
+
* Two separate concerns:
|
|
932
|
+
* - **Setup** (jay-stack setup): Config creation + credential/service validation
|
|
933
|
+
* - **References** (jay-stack agent-kit): Generate discovery data using live services
|
|
934
|
+
*
|
|
935
|
+
* Setup flow:
|
|
936
|
+
* 1. Scan plugins for `setup.handler` in plugin.yaml
|
|
937
|
+
* 2. Run init for all plugins (dependency-ordered)
|
|
938
|
+
* 3. For each target plugin: load setup handler → call it → report result
|
|
939
|
+
*
|
|
940
|
+
* References flow (called by agent-kit after materializing contracts):
|
|
941
|
+
* 1. Scan plugins for `setup.references` in plugin.yaml
|
|
942
|
+
* 2. Services are already initialized (agent-kit does this for contract materialization)
|
|
943
|
+
* 3. For each plugin: load references handler → call it → report result
|
|
944
|
+
*/
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* Context passed to a plugin's setup handler.
|
|
948
|
+
* Setup handles config creation and service validation only.
|
|
949
|
+
*/
|
|
950
|
+
interface PluginSetupContext {
|
|
951
|
+
/** Plugin name (from plugin.yaml) */
|
|
952
|
+
pluginName: string;
|
|
953
|
+
/** Project root directory */
|
|
954
|
+
projectRoot: string;
|
|
955
|
+
/** Config directory path (from .jay configBase, defaults to ./config) */
|
|
956
|
+
configDir: string;
|
|
957
|
+
/** Registered services (may be empty if init failed) */
|
|
958
|
+
services: Map<symbol, unknown>;
|
|
959
|
+
/** Present if plugin init failed */
|
|
960
|
+
initError?: Error;
|
|
961
|
+
/** Whether --force flag was passed */
|
|
962
|
+
force: boolean;
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Result returned by a plugin's setup handler.
|
|
966
|
+
*/
|
|
967
|
+
interface PluginSetupResult {
|
|
968
|
+
/** Overall status */
|
|
969
|
+
status: 'configured' | 'needs-config' | 'error';
|
|
970
|
+
/** Config files created (relative to project root) */
|
|
971
|
+
configCreated?: string[];
|
|
972
|
+
/** Human-readable status message */
|
|
973
|
+
message?: string;
|
|
974
|
+
}
|
|
975
|
+
/** A plugin's setup handler function signature. */
|
|
976
|
+
type PluginSetupHandler = (context: PluginSetupContext) => Promise<PluginSetupResult>;
|
|
977
|
+
/**
|
|
978
|
+
* Context passed to a plugin's references handler.
|
|
979
|
+
* Services may or may not be initialized — check initError if your handler needs them.
|
|
980
|
+
*/
|
|
981
|
+
interface PluginReferencesContext {
|
|
982
|
+
/** Plugin name (from plugin.yaml) */
|
|
983
|
+
pluginName: string;
|
|
984
|
+
/** Project root directory */
|
|
985
|
+
projectRoot: string;
|
|
986
|
+
/** Directory for this plugin's reference data (agent-kit/references/<plugin>/) */
|
|
987
|
+
referencesDir: string;
|
|
988
|
+
/** Registered services */
|
|
989
|
+
services: Map<symbol, unknown>;
|
|
990
|
+
/** Present if this plugin's server init failed */
|
|
991
|
+
initError?: Error;
|
|
992
|
+
/** Whether --force flag was passed */
|
|
993
|
+
force: boolean;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* Result returned by a plugin's references handler.
|
|
997
|
+
*/
|
|
998
|
+
interface PluginReferencesResult {
|
|
999
|
+
/** Reference files created (relative to project root) */
|
|
1000
|
+
referencesCreated: string[];
|
|
1001
|
+
/** Human-readable status message */
|
|
1002
|
+
message?: string;
|
|
1003
|
+
}
|
|
1004
|
+
/** A plugin's references handler function signature. */
|
|
1005
|
+
type PluginReferencesHandler = (context: PluginReferencesContext) => Promise<PluginReferencesResult>;
|
|
1006
|
+
/**
|
|
1007
|
+
* Information about a discovered plugin with a setup handler.
|
|
1008
|
+
*/
|
|
1009
|
+
interface PluginWithSetup {
|
|
1010
|
+
/** Plugin name from plugin.yaml */
|
|
1011
|
+
name: string;
|
|
1012
|
+
/** Plugin path (directory containing plugin.yaml) */
|
|
1013
|
+
pluginPath: string;
|
|
1014
|
+
/** Package name for NPM plugins, or path for local plugins */
|
|
1015
|
+
packageName: string;
|
|
1016
|
+
/** Whether this is a local plugin */
|
|
1017
|
+
isLocal: boolean;
|
|
1018
|
+
/** Setup handler export name or relative path */
|
|
1019
|
+
setupHandler: string;
|
|
1020
|
+
/** Setup description from plugin.yaml */
|
|
1021
|
+
setupDescription?: string;
|
|
1022
|
+
/** Dependencies from package.json (for ordering) */
|
|
1023
|
+
dependencies: string[];
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Information about a discovered plugin with a references handler.
|
|
1027
|
+
*/
|
|
1028
|
+
interface PluginWithReferences {
|
|
1029
|
+
/** Plugin name from plugin.yaml */
|
|
1030
|
+
name: string;
|
|
1031
|
+
/** Plugin path (directory containing plugin.yaml) */
|
|
1032
|
+
pluginPath: string;
|
|
1033
|
+
/** Package name for NPM plugins, or path for local plugins */
|
|
1034
|
+
packageName: string;
|
|
1035
|
+
/** Whether this is a local plugin */
|
|
1036
|
+
isLocal: boolean;
|
|
1037
|
+
/** References handler export name */
|
|
1038
|
+
referencesHandler: string;
|
|
1039
|
+
/** Dependencies from package.json (for ordering) */
|
|
1040
|
+
dependencies: string[];
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Discovers all plugins that have a `setup.handler` in plugin.yaml.
|
|
1044
|
+
*/
|
|
1045
|
+
declare function discoverPluginsWithSetup(options: {
|
|
1046
|
+
projectRoot: string;
|
|
1047
|
+
verbose?: boolean;
|
|
1048
|
+
pluginFilter?: string;
|
|
1049
|
+
}): Promise<PluginWithSetup[]>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Discovers all plugins that have a `setup.references` in plugin.yaml.
|
|
1052
|
+
*/
|
|
1053
|
+
declare function discoverPluginsWithReferences(options: {
|
|
1054
|
+
projectRoot: string;
|
|
1055
|
+
verbose?: boolean;
|
|
1056
|
+
pluginFilter?: string;
|
|
1057
|
+
}): Promise<PluginWithReferences[]>;
|
|
1058
|
+
/**
|
|
1059
|
+
* Loads and executes a plugin's setup handler.
|
|
1060
|
+
*/
|
|
1061
|
+
declare function executePluginSetup(plugin: PluginWithSetup, options: {
|
|
1062
|
+
projectRoot: string;
|
|
1063
|
+
configDir: string;
|
|
1064
|
+
force: boolean;
|
|
1065
|
+
initError?: Error;
|
|
1066
|
+
viteServer?: ViteSSRLoader;
|
|
1067
|
+
verbose?: boolean;
|
|
1068
|
+
}): Promise<PluginSetupResult>;
|
|
1069
|
+
/**
|
|
1070
|
+
* Loads and executes a plugin's references handler.
|
|
1071
|
+
*/
|
|
1072
|
+
declare function executePluginReferences(plugin: PluginWithReferences, options: {
|
|
1073
|
+
projectRoot: string;
|
|
1074
|
+
force: boolean;
|
|
1075
|
+
initError?: Error;
|
|
1076
|
+
viteServer?: ViteSSRLoader;
|
|
1077
|
+
verbose?: boolean;
|
|
1078
|
+
}): Promise<PluginReferencesResult>;
|
|
1079
|
+
|
|
1080
|
+
export { type ActionDiscoveryOptions, type ActionDiscoveryResult, type ActionErrorResponse, type ActionExecutionResult, type ActionIndexEntry, type ActionMetadata, ActionRegistry, type ActionSchema, type ContractIndexEntry, type ContractsIndex, type DevServerPagePart, DevSlowlyChangingPhase, type GenerateClientScriptOptions, type HeadlessInstanceComponent, type InstancePhaseData, type InstanceSlowRenderResult, type LoadedPageParts, type MaterializeContractsOptions, type MaterializeResult, type PluginActionDiscoveryOptions, type PluginClientInitInfo, type PluginInitDiscoveryOptions, type PluginReferencesContext, type PluginReferencesHandler, type PluginReferencesResult, type PluginScanOptions, type PluginSetupContext, type PluginSetupHandler, type PluginSetupResult, type PluginWithInit, type PluginWithReferences, type PluginWithSetup, type PluginsIndex, type PluginsIndexEntry, type ProjectClientInitInfo, type RegisteredAction, type ScannedPlugin, SlowRenderCache, type SlowRenderCacheEntry, type SlowlyChangingPhase, type ViteSSRLoader, actionRegistry, clearActionRegistry, clearClientInitData, clearLifecycleCallbacks, clearServiceRegistry, discoverAllPluginActions, discoverAndRegisterActions, discoverPluginActions, discoverPluginsWithInit, discoverPluginsWithReferences, discoverPluginsWithSetup, executeAction, executePluginReferences, executePluginServerInits, executePluginSetup, generateClientScript, getActionCacheHeaders, getClientInitData, getClientInitDataForKey, getRegisteredAction, getRegisteredActionNames, getService, getServiceRegistry, hasAction, hasService, listContracts, loadActionMetadata, loadPageParts, materializeContracts, onInit, onShutdown, parseActionMetadata, preparePluginClientInits, registerAction, registerService, renderFastChangingData, resolveActionMetadataPath, resolveServices, runInitCallbacks, runLoadParams, runShutdownCallbacks, runSlowlyChangingRender, scanPlugins, setClientInitData, slowRenderInstances, sortPluginsByDependencies, validateForEachInstances };
|