@jay-framework/stack-server-build 0.24.2

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 (3) hide show
  1. package/dist/index.d.ts +664 -0
  2. package/dist/index.js +2293 -0
  3. package/package.json +49 -0
@@ -0,0 +1,664 @@
1
+ import { ViteDevServer } from 'vite';
2
+ import { JayRoute } from '@jay-framework/stack-route-scanner';
3
+ import { WithValidations, JayHtmlHeadMeta, JsonSchemaProperty } from '@jay-framework/compiler-shared';
4
+ export { JsonSchemaProperty } from '@jay-framework/compiler-shared';
5
+ import { Contract, HeadlessContractInfo, DiscoveredHeadlessInstance, ForEachHeadlessInstance, JayHtmlScript } from '@jay-framework/compiler-jay-html';
6
+ import { AnyJayStackComponentDefinition, HeadTag } from '@jay-framework/fullstack-component';
7
+ import { JayRollupConfig } from '@jay-framework/rollup-plugin';
8
+ import { TrackByMap } from '@jay-framework/view-state-merge';
9
+ import { PluginClientInitInfo, ActionRegistry, ViteSSRLoader as ViteSSRLoader$1, PluginAgentKitResult, PluginSetupPrompt, PluginSetupResult } from '@jay-framework/stack-server-runtime';
10
+ export * from '@jay-framework/stack-server-runtime';
11
+ export { PluginAgentKitContext, PluginAgentKitHandler, PluginAgentKitResult, PluginSetupContext, PluginSetupHandler, PluginSetupPrompt, PluginSetupResult } from '@jay-framework/stack-server-runtime';
12
+
13
+ interface DevServerPagePart {
14
+ compDefinition: AnyJayStackComponentDefinition;
15
+ key?: string;
16
+ clientImport: string;
17
+ clientPart: string;
18
+ /** Contract metadata for dynamic contract components */
19
+ contractInfo?: {
20
+ contractName: string;
21
+ metadata?: Record<string, unknown>;
22
+ };
23
+ /** Static props from YAML body in the headless script tag (DL#156) */
24
+ headlessProps?: Record<string, string>;
25
+ }
26
+ /**
27
+ * Instance-only headless component (no key attribute).
28
+ * Used for server-side phase orchestration of `<jay:xxx>` instances.
29
+ */
30
+ interface HeadlessInstanceComponent {
31
+ /** Contract name from the script tag (e.g., "product-card") */
32
+ contractName: string;
33
+ /** Component definition for calling slowlyRender/fastRender */
34
+ compDefinition: AnyJayStackComponentDefinition;
35
+ /** Parsed contract (for phase detection in slow render Pass 2) */
36
+ contract: Contract;
37
+ }
38
+ interface LoadedPageParts {
39
+ parts: DevServerPagePart[];
40
+ /** TrackBy map for server-side merge (slow → fast) */
41
+ serverTrackByMap?: Record<string, string>;
42
+ /** TrackBy map for client-side merge (fast → interactive) */
43
+ clientTrackByMap?: Record<string, string>;
44
+ /** NPM package names used on this page (for filtering plugin inits) */
45
+ usedPackages: Set<string>;
46
+ /** Headless contracts for slow rendering (already loaded by parseJayFile) */
47
+ headlessContracts: HeadlessContractInfo[];
48
+ /** Instance-only headless components (no key) for server-side phase orchestration */
49
+ headlessInstanceComponents: HeadlessInstanceComponent[];
50
+ /** Discovered <jay:xxx> instances from the jay-html (DL#109) */
51
+ discoveredInstances: DiscoveredHeadlessInstance[];
52
+ /** Discovered forEach <jay:xxx> instances from the jay-html (DL#109) */
53
+ forEachInstances: ForEachHeadlessInstance[];
54
+ /** Absolute paths to linked CSS files (from <link rel="stylesheet">) for dev-server watching */
55
+ linkedCssFiles: string[];
56
+ /** Absolute paths to headfull FS component jay-html files for dev-server watching */
57
+ linkedComponentFiles: string[];
58
+ /** Script tags with jay-script="allow" to include in SSR output */
59
+ scripts?: JayHtmlScript[];
60
+ }
61
+ interface LoadPagePartsOptions {
62
+ /**
63
+ * Path to pre-rendered jay-html file to use instead of the original.
64
+ * When provided, this file (with slow-phase bindings resolved) is read.
65
+ * Import resolution still uses the original jay-html's directory.
66
+ */
67
+ preRenderedPath?: string;
68
+ /**
69
+ * Pre-loaded jay-html content to use instead of reading from disk.
70
+ * When provided (e.g., from SlowRenderCache with cache tag already stripped),
71
+ * this content is used directly, avoiding an extra file read.
72
+ */
73
+ preRenderedContent?: string;
74
+ }
75
+ declare function loadPageParts(vite: ViteDevServer, route: JayRoute, pagesBase: string, projectBase: string, jayRollupConfig: JayRollupConfig, options?: LoadPagePartsOptions): Promise<WithValidations<LoadedPageParts>>;
76
+
77
+ /**
78
+ * Generate JS code to reconstruct Promise.resolve()/Promise.reject() for async ViewState properties.
79
+ * JSON.stringify drops Promise objects, so this emits assignments that recreate them from tracked outcomes.
80
+ */
81
+ declare function generatePromiseReconstruction(outcomes: Array<{
82
+ id: string;
83
+ status: 'resolved' | 'rejected';
84
+ value: any;
85
+ }>): string;
86
+ /**
87
+ * Information needed to generate client init script for the project.
88
+ */
89
+ interface ProjectClientInitInfo {
90
+ /** Import path for the init module */
91
+ importPath: string;
92
+ /** Export name for the JayInit constant (default: 'init') */
93
+ initExport?: string;
94
+ }
95
+ /**
96
+ * Options for client script generation.
97
+ */
98
+ interface GenerateClientScriptOptions {
99
+ /** Enable automation integration (default: true in dev mode) */
100
+ enableAutomation?: boolean;
101
+ /**
102
+ * Slow ViewState that was baked into the pre-rendered jay-html.
103
+ * When provided, this is merged with fastViewState for the automation API
104
+ * so that AI/automation tools can see the complete page state.
105
+ */
106
+ slowViewState?: object;
107
+ /** Route pattern (e.g., /products/kitan{/:category}) for freeze entries */
108
+ routePattern?: string;
109
+ }
110
+ /**
111
+ * Shared fragments generated by buildScriptFragments().
112
+ * Used by both generateClientScript() and generateHydrationScript().
113
+ */
114
+ interface ScriptFragments {
115
+ partImports: string;
116
+ compositeParts: string;
117
+ pluginClientInitImports: string;
118
+ projectInitImport: string;
119
+ clientInitExecution: string;
120
+ automationImport: string;
121
+ slowViewStateDecl: string;
122
+ }
123
+ /**
124
+ * Build the shared script fragments used by both client and hydration scripts.
125
+ */
126
+ declare function buildScriptFragments(parts: DevServerPagePart[], clientInitData: Record<string, Record<string, any>>, projectInit: ProjectClientInitInfo | undefined, pluginInits: PluginClientInitInfo[], options: GenerateClientScriptOptions): ScriptFragments;
127
+ /**
128
+ * Generate the automation wrapping code.
129
+ * @param mode - 'client' appends to DOM; 'hydrate' skips appendChild (DOM already present)
130
+ */
131
+ declare function buildAutomationWrap(options: GenerateClientScriptOptions, mode: 'client' | 'hydrate'): string;
132
+ /**
133
+ * Resolve all top-level Promise values in a ViewState object.
134
+ * Returns the ViewState with Promises replaced by their resolved values,
135
+ * plus a list of outcomes for reconstructing Promise.resolve()/Promise.reject()
136
+ * in the client script.
137
+ */
138
+ declare function resolveViewStatePromises(viewState: object): Promise<{
139
+ resolved: object;
140
+ outcomes: Array<{
141
+ id: string;
142
+ status: 'resolved' | 'rejected';
143
+ value: any;
144
+ }>;
145
+ }>;
146
+ declare function generateClientScript(defaultViewState: object, fastCarryForward: object, parts: DevServerPagePart[], jayHtmlPath: string, trackByMap?: TrackByMap, clientInitData?: Record<string, Record<string, any>>, projectInit?: ProjectClientInitInfo, pluginInits?: PluginClientInitInfo[], options?: GenerateClientScriptOptions): Promise<string>;
147
+
148
+ /**
149
+ * Invalidate the cached server element module for a jay-html file.
150
+ * Called when the source file changes (via file watcher).
151
+ */
152
+ declare function invalidateServerElementCache(jayHtmlPath: string): void;
153
+ /**
154
+ * Invalidate all cached server element modules.
155
+ */
156
+ declare function clearServerElementCache(): void;
157
+ declare function headMetaToHeadTags(headMeta: JayHtmlHeadMeta | undefined, viewState?: object): HeadTag[];
158
+ /**
159
+ * Generate a complete SSR HTML page with server-rendered content and hydration script.
160
+ *
161
+ * Flow:
162
+ * 1. Load (or reuse cached) server element module
163
+ * 2. Execute renderToStream() to produce HTML
164
+ * 3. Build hydration script (uses ?jay-hydrate query for hydrate target)
165
+ * 4. Return full HTML page string
166
+ */
167
+ declare function generateSSRPageHtml(vite: ViteDevServer, jayHtmlContent: string, jayHtmlFilename: string, jayHtmlDir: string, viewState: object, jayHtmlImportPath: string, parts: DevServerPagePart[], carryForward: object, trackByMap: TrackByMap, clientInitData: Record<string, Record<string, any>>, buildFolder: string, projectRoot: string, routeDir: string, tsConfigFilePath?: string, projectInit?: ProjectClientInitInfo, pluginInits?: PluginClientInitInfo[], options?: GenerateClientScriptOptions,
168
+ /** Source directory for headfull FS file resolution when jayHtmlDir is pre-rendered */
169
+ sourceDir?: string,
170
+ /** Head tags to inject into <head> during SSR (Design Log #127) */
171
+ headTags?: HeadTag[],
172
+ /** Script tags with jay-script="allow" (DL#149) */
173
+ scripts?: JayHtmlScript[]): Promise<string>;
174
+ /**
175
+ * Generate a frozen page — pure SSR HTML with no client scripts (DL#127).
176
+ *
177
+ * Uses the same server element module as generateSSRPageHtml, but:
178
+ * - No hydration script
179
+ * - No Vite client
180
+ * - No component runtime
181
+ * - Just rendered HTML + CSS
182
+ *
183
+ * @param format - 'page' for full HTML document, 'fragment' for body-only (shadow DOM)
184
+ */
185
+ declare function generateFrozenPageHtml(vite: ViteDevServer, jayHtmlContent: string, jayHtmlFilename: string, jayHtmlDir: string, viewState: object, buildFolder: string, projectRoot: string, routeDir: string, tsConfigFilePath?: string, sourceDir?: string, format?: 'page' | 'fragment', freezeName?: string): Promise<string>;
186
+
187
+ /**
188
+ * Action metadata loaded from .jay-action files.
189
+ *
190
+ * Uses the compiler's parseAction to parse .jay-action YAML into JayType,
191
+ * then converts JayType → JSON Schema for consumers (AI agent tool builders).
192
+ *
193
+ * Actions without .jay-action files are not exposed to AI agents.
194
+ */
195
+
196
+ /**
197
+ * Input schema for an action (JSON Schema object type).
198
+ */
199
+ interface ActionSchema {
200
+ type: 'object';
201
+ properties: Record<string, JsonSchemaProperty>;
202
+ required?: string[];
203
+ }
204
+ /**
205
+ * Metadata loaded from a .jay-action file.
206
+ */
207
+ interface ActionMetadata {
208
+ /** Action name (must match the export name in plugin code) */
209
+ name: string;
210
+ /** Human-readable description of what the action does */
211
+ description: string;
212
+ /** JSON Schema for the action's input parameters */
213
+ inputSchema: ActionSchema;
214
+ /** JSON Schema for the action's output (optional) */
215
+ outputSchema?: JsonSchemaProperty;
216
+ }
217
+ /**
218
+ * Parses a .jay-action YAML string into ActionMetadata.
219
+ * Uses the compiler's parseAction to produce JayType, then converts to JSON Schema.
220
+ */
221
+ declare function parseActionMetadata(yamlContent: string, fileName: string): ActionMetadata | null;
222
+ /**
223
+ * Loads action metadata from a .jay-action file on disk.
224
+ */
225
+ declare function loadActionMetadata(filePath: string): ActionMetadata | null;
226
+ /**
227
+ * Resolves the absolute path of a .jay-action file relative to a plugin directory.
228
+ */
229
+ declare function resolveActionMetadataPath(actionPath: string, pluginDir: string): string;
230
+
231
+ /**
232
+ * Action discovery and auto-registration for Jay Stack.
233
+ *
234
+ * Scans project and plugin directories to discover and register actions
235
+ * automatically on server startup.
236
+ */
237
+
238
+ /**
239
+ * Vite server interface for SSR module loading.
240
+ * Using a minimal interface to avoid direct Vite dependency.
241
+ */
242
+ interface ViteSSRLoader {
243
+ ssrLoadModule: (url: string) => Promise<Record<string, any>>;
244
+ }
245
+ /**
246
+ * Options for action discovery.
247
+ */
248
+ interface ActionDiscoveryOptions {
249
+ /** Project root directory */
250
+ projectRoot: string;
251
+ /** Custom actions directory (default: src/actions) */
252
+ actionsDir?: string;
253
+ /** Registry to register actions in (default: global actionRegistry) */
254
+ registry?: ActionRegistry;
255
+ /** Whether to log discovery progress */
256
+ verbose?: boolean;
257
+ /** Vite server for SSR module loading (required in dev for TypeScript files) */
258
+ viteServer?: ViteSSRLoader;
259
+ }
260
+ /**
261
+ * Result of action discovery.
262
+ */
263
+ interface ActionDiscoveryResult {
264
+ /** Number of actions discovered and registered */
265
+ actionCount: number;
266
+ /** Names of registered actions */
267
+ actionNames: string[];
268
+ /** Paths of scanned action files */
269
+ scannedFiles: string[];
270
+ }
271
+ /**
272
+ * Discovers and registers actions from the project's actions directory.
273
+ *
274
+ * Scans `src/actions/*.actions.ts` for exported actions and registers them.
275
+ *
276
+ * @param options - Discovery options
277
+ * @returns Result with discovered action information
278
+ *
279
+ * @example
280
+ * ```typescript
281
+ * // In dev-server startup
282
+ * const result = await discoverAndRegisterActions({
283
+ * projectRoot: process.cwd(),
284
+ * verbose: true,
285
+ * });
286
+ * console.log(`Registered ${result.actionCount} actions`);
287
+ * ```
288
+ */
289
+ declare function discoverAndRegisterActions(options: ActionDiscoveryOptions): Promise<ActionDiscoveryResult>;
290
+ /**
291
+ * Options for discovering plugin actions.
292
+ */
293
+ interface PluginActionDiscoveryOptions {
294
+ /** Project root directory */
295
+ projectRoot: string;
296
+ /** Registry to register actions in (default: global actionRegistry) */
297
+ registry?: ActionRegistry;
298
+ /** Whether to log discovery progress */
299
+ verbose?: boolean;
300
+ /** Vite server for SSR module loading (required in dev for TypeScript files) */
301
+ viteServer?: ViteSSRLoader;
302
+ }
303
+ /**
304
+ * Discovers and registers actions from all plugins in a project.
305
+ *
306
+ * Scans both local plugins (src/plugins/) and installed NPM plugins.
307
+ *
308
+ * @param options - Discovery options
309
+ * @returns Array of registered action names
310
+ */
311
+ declare function discoverAllPluginActions(options: PluginActionDiscoveryOptions): Promise<string[]>;
312
+ /**
313
+ * Discovers actions from a single plugin's plugin.yaml file.
314
+ *
315
+ * Reads plugin.yaml, finds the `actions` array, and imports those
316
+ * named exports from the plugin's module.
317
+ *
318
+ * @param pluginPath - Path to the plugin directory (containing plugin.yaml)
319
+ * @param projectRoot - Project root for resolving imports
320
+ * @param registry - Registry to register actions in
321
+ * @param verbose - Whether to log progress
322
+ * @returns Array of registered action names
323
+ */
324
+ declare function discoverPluginActions(pluginPath: string, projectRoot: string, registry?: ActionRegistry, verbose?: boolean, viteServer?: ViteSSRLoader): Promise<string[]>;
325
+
326
+ /**
327
+ * Contract Materializer
328
+ *
329
+ * Materializes dynamic contracts to disk for agent discovery.
330
+ * Also creates an index file listing both static and dynamic contracts.
331
+ *
332
+ * @see Design Log #80 - Materializing Dynamic Contracts for Agentic Page Generation
333
+ */
334
+
335
+ /** Action metadata entry in plugins-index.yaml */
336
+ interface ActionIndexEntry {
337
+ name: string;
338
+ description: string;
339
+ /** Path to the .jay-action file (relative to project root) */
340
+ path: string;
341
+ }
342
+ /** Contract entry within a plugin in plugins-index.yaml */
343
+ interface PluginContractEntry {
344
+ name: string;
345
+ description?: string;
346
+ type: 'static' | 'dynamic';
347
+ path: string;
348
+ metadata?: Record<string, unknown>;
349
+ }
350
+ /** Service entry in plugins-index.yaml (DL#125) */
351
+ interface ServiceIndexEntry {
352
+ name: string;
353
+ marker: string;
354
+ description?: string;
355
+ doc?: string;
356
+ }
357
+ /** Context entry in plugins-index.yaml (DL#125) */
358
+ interface ContextIndexEntry {
359
+ name: string;
360
+ marker: string;
361
+ description?: string;
362
+ doc?: string;
363
+ }
364
+ /** Route entry in plugins-index.yaml (DL#130) */
365
+ interface RouteIndexEntry {
366
+ path: string;
367
+ description?: string;
368
+ }
369
+ /** CLI command entry in plugins-index.yaml (DL#142) */
370
+ interface CommandIndexEntry {
371
+ name: string;
372
+ description?: string;
373
+ }
374
+ /** Entry for plugins-index.yaml (Design Log #85) */
375
+ interface PluginsIndexEntry {
376
+ name: string;
377
+ path: string;
378
+ contracts: PluginContractEntry[];
379
+ /** Actions with .jay-action metadata (exposed to AI agents) */
380
+ actions?: ActionIndexEntry[];
381
+ /** Server-side services provided by this plugin (DL#125) */
382
+ services?: ServiceIndexEntry[];
383
+ /** Client-side contexts provided by this plugin (DL#125) */
384
+ contexts?: ContextIndexEntry[];
385
+ /** Plugin-provided routes (DL#130) */
386
+ routes?: RouteIndexEntry[];
387
+ /** CLI commands (DL#142) */
388
+ commands?: CommandIndexEntry[];
389
+ }
390
+ interface PluginsIndex {
391
+ plugins: PluginsIndexEntry[];
392
+ }
393
+ interface MaterializeContractsOptions {
394
+ projectRoot: string;
395
+ outputDir?: string;
396
+ force?: boolean;
397
+ dynamicOnly?: boolean;
398
+ pluginFilter?: string;
399
+ verbose?: boolean;
400
+ /** Optional Vite server for TypeScript support */
401
+ viteServer?: ViteSSRLoader$1;
402
+ }
403
+ interface MaterializeResult {
404
+ pluginsIndex: PluginsIndex;
405
+ staticCount: number;
406
+ dynamicCount: number;
407
+ outputDir: string;
408
+ }
409
+ /**
410
+ * Materializes all contracts (static references + dynamic generated) to disk.
411
+ *
412
+ * @param options - Materialization options
413
+ * @param services - Map of service markers to service instances (from init.ts)
414
+ */
415
+ declare function materializeContracts(options: MaterializeContractsOptions, services?: Map<symbol, unknown>): Promise<MaterializeResult>;
416
+ /**
417
+ * Lists contracts without writing files (for --list mode)
418
+ */
419
+ declare function listContracts(options: MaterializeContractsOptions): Promise<PluginsIndex>;
420
+
421
+ /**
422
+ * Plugin CLI Commands (Design Log #142)
423
+ *
424
+ * Plugins expose CLI commands via `commands` in plugin.yaml.
425
+ * Each command has a `makeCliCommand` handler and an optional `.jay-command` metadata file.
426
+ * Run via `jay-stack run <plugin>/<command>`.
427
+ */
428
+
429
+ interface CommandMetadata {
430
+ name: string;
431
+ description?: string;
432
+ inputSchema?: Record<string, string>;
433
+ }
434
+ interface DiscoveredCommand {
435
+ pluginName: string;
436
+ pluginPath: string;
437
+ packageName: string;
438
+ isLocal: boolean;
439
+ commandName: string;
440
+ handlerExport: string;
441
+ pluginModule?: string;
442
+ metadata?: CommandMetadata;
443
+ metadataPath?: string;
444
+ }
445
+ interface CommandFlag {
446
+ flag: string;
447
+ description: string;
448
+ required: boolean;
449
+ type: 'string' | 'boolean' | 'number';
450
+ }
451
+ declare function discoverPluginCommands(options: {
452
+ projectRoot: string;
453
+ verbose?: boolean;
454
+ pluginFilter?: string;
455
+ }): Promise<DiscoveredCommand[]>;
456
+ declare function commandSchemaToFlags(inputSchema: Record<string, string>): CommandFlag[];
457
+ declare function parseInputFromFlags(rawOptions: Record<string, any>, schema: Record<string, string>): Record<string, any>;
458
+ declare function executePluginCommand(command: DiscoveredCommand, input: Record<string, any>, viteServer?: ViteSSRLoader$1): Promise<{
459
+ success: boolean;
460
+ }>;
461
+
462
+ /**
463
+ * Plugin Setup and Agent-Kit (Design Log #87)
464
+ *
465
+ * Two separate concerns:
466
+ * - **Setup** (jay-stack setup): Config creation + credential/service validation
467
+ * - **Agent-kit** (jay-stack agent-kit): Generate discovery data using live services
468
+ *
469
+ * Setup flow:
470
+ * 1. Scan plugins for `setup` in plugin.yaml
471
+ * 2. Run init for all plugins (dependency-ordered)
472
+ * 3. For each target plugin: load setup handler → call it → report result
473
+ *
474
+ * Agent-kit flow (called by agent-kit after materializing contracts):
475
+ * 1. Scan plugins for `agentkit` in plugin.yaml
476
+ * 2. Services are already initialized (agent-kit does this for contract materialization)
477
+ * 3. For each plugin: load agent-kit handler → call it → report result
478
+ */
479
+
480
+ /**
481
+ * Thrown by non-interactive prompt when an answer is missing.
482
+ * The CLI catches this and prints structured output for agents.
483
+ */
484
+ declare class SetupNeedsAnswerError extends Error {
485
+ readonly plugin: string;
486
+ readonly key: string;
487
+ readonly type: 'input' | 'confirm' | 'select';
488
+ readonly promptMessage: string;
489
+ readonly choices?: Array<{
490
+ name: string;
491
+ value: string;
492
+ }>;
493
+ constructor(plugin: string, key: string, type: 'input' | 'confirm' | 'select', promptMessage: string, choices?: Array<{
494
+ name: string;
495
+ value: string;
496
+ }>);
497
+ }
498
+ /**
499
+ * Information about a discovered plugin with a setup handler.
500
+ */
501
+ interface PluginWithSetup {
502
+ /** Plugin name from plugin.yaml */
503
+ name: string;
504
+ /** Plugin path (directory containing plugin.yaml) */
505
+ pluginPath: string;
506
+ /** Package name for NPM plugins, or path for local plugins */
507
+ packageName: string;
508
+ /** Whether this is a local plugin */
509
+ isLocal: boolean;
510
+ /** Setup handler export name or relative path */
511
+ setupHandler: string;
512
+ /** Setup description from plugin.yaml */
513
+ setupDescription?: string;
514
+ /** Dependencies from package.json (for ordering) */
515
+ dependencies: string[];
516
+ }
517
+ /**
518
+ * Information about a discovered plugin with an agent-kit handler.
519
+ */
520
+ interface PluginWithAgentKit {
521
+ /** Plugin name from plugin.yaml */
522
+ name: string;
523
+ /** Plugin path (directory containing plugin.yaml) */
524
+ pluginPath: string;
525
+ /** Package name for NPM plugins, or path for local plugins */
526
+ packageName: string;
527
+ /** Whether this is a local plugin */
528
+ isLocal: boolean;
529
+ /** Agent-kit handler export name */
530
+ agentKitHandler: string;
531
+ /** Dependencies from package.json (for ordering) */
532
+ dependencies: string[];
533
+ }
534
+ /**
535
+ * Discovers all plugins that have a `setup` handler in plugin.yaml.
536
+ */
537
+ declare function discoverPluginsWithSetup(options: {
538
+ projectRoot: string;
539
+ verbose?: boolean;
540
+ pluginFilter?: string;
541
+ }): Promise<PluginWithSetup[]>;
542
+ /**
543
+ * Discovers all plugins that have an `agentkit` handler in plugin.yaml.
544
+ */
545
+ declare function discoverPluginsWithAgentKit(options: {
546
+ projectRoot: string;
547
+ verbose?: boolean;
548
+ pluginFilter?: string;
549
+ }): Promise<PluginWithAgentKit[]>;
550
+ /**
551
+ * Loads and executes a plugin's setup handler.
552
+ */
553
+ declare function executePluginSetup(plugin: PluginWithSetup, options: {
554
+ projectRoot: string;
555
+ configDir: string;
556
+ force: boolean;
557
+ interactive: boolean;
558
+ prompt: PluginSetupPrompt;
559
+ initError?: Error;
560
+ viteServer?: ViteSSRLoader$1;
561
+ verbose?: boolean;
562
+ }): Promise<PluginSetupResult>;
563
+ /**
564
+ * Loads and executes a plugin's agent-kit handler.
565
+ */
566
+ declare function executePluginAgentKit(plugin: PluginWithAgentKit, options: {
567
+ projectRoot: string;
568
+ force: boolean;
569
+ initError?: Error;
570
+ viteServer?: ViteSSRLoader$1;
571
+ verbose?: boolean;
572
+ }): Promise<PluginAgentKitResult>;
573
+
574
+ /**
575
+ * Cache entry for pre-rendered jay-html
576
+ */
577
+ interface SlowRenderCacheEntry {
578
+ /** Path to the pre-rendered jay-html file on disk */
579
+ preRenderedPath: string;
580
+ /** Pre-rendered jay-html content with cache metadata tag stripped */
581
+ preRenderedContent: string;
582
+ /** Slow ViewState that was baked into the jay-html */
583
+ slowViewState: object;
584
+ /** CarryForward data from slow rendering (passed to fast phase) */
585
+ carryForward: object;
586
+ /** Source jay-html path (for debugging) */
587
+ sourcePath: string;
588
+ }
589
+ /**
590
+ * Filesystem-based cache for pre-rendered jay-html files.
591
+ *
592
+ * Cache metadata (slowViewState, carryForward) is embedded in the pre-rendered
593
+ * file as a `<script type="application/jay-cache">` tag. This means:
594
+ * - Cache survives dev server restart
595
+ * - The filesystem is the single source of truth
596
+ * - No in-memory map needed for cache entries
597
+ *
598
+ * On read, the script tag is extracted and stripped before returning content.
599
+ */
600
+ declare class SlowRenderCache {
601
+ /** Maps source jay-html path → set of pre-rendered file paths (for invalidation) */
602
+ private pathToFiles;
603
+ private readonly cacheDir;
604
+ private readonly pagesRoot;
605
+ /**
606
+ * @param cacheDir - Directory where pre-rendered jay-html files are stored
607
+ * @param pagesRoot - Root directory of the pages (for relative path calculation)
608
+ */
609
+ constructor(cacheDir: string, pagesRoot: string);
610
+ /**
611
+ * Get a cached pre-rendered jay-html entry by reading from disk.
612
+ * Returns undefined if the cache file doesn't exist or has no metadata tag.
613
+ */
614
+ get(jayHtmlPath: string, params: Record<string, string>, routeDir?: string): Promise<SlowRenderCacheEntry | undefined>;
615
+ /**
616
+ * Store a pre-rendered jay-html entry.
617
+ * Embeds metadata as a <script> tag and writes to disk.
618
+ * Returns the full cache entry with stripped content.
619
+ */
620
+ set(jayHtmlPath: string, params: Record<string, string>, preRenderedJayHtml: string, slowViewState: object, carryForward: object, routeDir?: string): Promise<SlowRenderCacheEntry>;
621
+ /**
622
+ * Check if a pre-rendered entry exists for the given path and params
623
+ */
624
+ has(jayHtmlPath: string, params: Record<string, string>, routeDir?: string): Promise<boolean>;
625
+ /**
626
+ * Invalidate all cached entries for a given jay-html source path.
627
+ * Deletes cached files from disk.
628
+ */
629
+ invalidate(jayHtmlPath: string): Promise<void>;
630
+ /**
631
+ * Invalidate all entries that depend on a changed file.
632
+ * The changedPath could be:
633
+ * - A jay-html file itself
634
+ * - A component file (page.ts)
635
+ * - Any other dependency
636
+ *
637
+ * @param changedPath - Absolute path to the changed file
638
+ * @param resolveDependencies - Optional function to resolve which jay-html files depend on the changed file
639
+ */
640
+ invalidateByDependency(changedPath: string, resolveDependencies?: (changedPath: string) => string[]): Promise<void>;
641
+ /**
642
+ * Clear all cached entries and delete cached files from disk
643
+ */
644
+ clear(): Promise<void>;
645
+ /**
646
+ * Get all cached jay-html paths (for debugging/monitoring)
647
+ */
648
+ getCachedPaths(): string[];
649
+ /**
650
+ * Compute the cache file path for a given jay-html path and params.
651
+ */
652
+ private computeCachePath;
653
+ /**
654
+ * Track a pre-rendered file path for invalidation.
655
+ */
656
+ private trackFile;
657
+ /**
658
+ * Scan the cache directory for files matching a route and delete them.
659
+ * Handles the startup case where pathToFiles is not populated from a previous session.
660
+ */
661
+ private scanAndDeleteCacheFiles;
662
+ }
663
+
664
+ export { type ActionDiscoveryOptions, type ActionDiscoveryResult, type ActionIndexEntry, type ActionMetadata, type ActionSchema, type CommandFlag, type CommandIndexEntry, type CommandMetadata, type ContextIndexEntry, type DevServerPagePart, type DiscoveredCommand, type GenerateClientScriptOptions, type HeadlessInstanceComponent, type LoadPagePartsOptions, type LoadedPageParts, type MaterializeContractsOptions, type MaterializeResult, type PluginActionDiscoveryOptions, type PluginContractEntry, type PluginWithAgentKit, type PluginWithSetup, type PluginsIndex, type PluginsIndexEntry, type ProjectClientInitInfo, type RouteIndexEntry, type ScriptFragments, type ServiceIndexEntry, SetupNeedsAnswerError, SlowRenderCache, type SlowRenderCacheEntry, type ViteSSRLoader, buildAutomationWrap, buildScriptFragments, clearServerElementCache, commandSchemaToFlags, discoverAllPluginActions, discoverAndRegisterActions, discoverPluginActions, discoverPluginCommands, discoverPluginsWithAgentKit, discoverPluginsWithSetup, executePluginAgentKit, executePluginCommand, executePluginSetup, generateClientScript, generateFrozenPageHtml, generatePromiseReconstruction, generateSSRPageHtml, headMetaToHeadTags, invalidateServerElementCache, listContracts, loadActionMetadata, loadPageParts, materializeContracts, parseActionMetadata, parseInputFromFlags, resolveActionMetadataPath, resolveViewStatePromises };