eve 0.24.0 → 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.
- package/CHANGELOG.md +17 -0
- package/dist/src/cli/run.js +2 -2
- package/dist/src/cli/vercel-service-output.d.ts +4 -0
- package/dist/src/cli/vercel-service-output.js +1 -0
- package/dist/src/compiled/.vendor-stamp.json +11 -11
- package/dist/src/compiled/@ai-sdk/anthropic/index.d.ts +1 -1
- package/dist/src/compiled/@ai-sdk/anthropic/index.js +2 -2
- package/dist/src/compiled/@ai-sdk/google/index.d.ts +7 -0
- package/dist/src/compiled/@ai-sdk/google/index.js +6 -6
- package/dist/src/compiled/@ai-sdk/mcp/index.d.ts +42 -1
- package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/openai/index.d.ts +34 -6
- package/dist/src/compiled/@ai-sdk/openai/index.js +2 -2
- package/dist/src/compiled/@ai-sdk/otel/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/provider/index.d.ts +245 -3
- package/dist/src/compiled/@ai-sdk/provider-utils/index.d.ts +273 -15
- package/dist/src/compiled/@workflow/core/index.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/start.d.ts +12 -0
- package/dist/src/compiled/@workflow/core/runtime.js +1 -1
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/world/analytics.d.ts +56 -21
- package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +46 -0
- package/dist/src/compiled/@workflow/world/queue.d.ts +12 -0
- package/dist/src/compiled/@workflow/world-local/index.js +3 -3
- package/dist/src/compiled/@workflow/world-vercel/index.js +16 -16
- package/dist/src/compiled/_chunks/workflow/attribute-changes-MGTOG_uX.js +20 -0
- package/dist/src/compiled/_chunks/workflow/{dist-CQenixFf.js → dist-Blxnyb7-.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/dist-zLevmMyU.js +77 -0
- package/dist/src/compiled/_chunks/workflow/{resume-hook-BH01MfRF.js → resume-hook-DHP5ql3-.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/run-D8hv1ptT.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{sleep-BkAHCD_s.js → sleep-uA9pS-PT.js} +1 -1
- package/dist/src/compiler/artifacts.d.ts +7 -6
- package/dist/src/compiler/artifacts.js +1 -1
- package/dist/src/compiler/compile-agent.d.ts +15 -2
- package/dist/src/compiler/compile-agent.js +3 -3
- package/dist/src/execution/sandbox/prewarm.d.ts +1 -0
- package/dist/src/execution/sandbox/prewarm.js +1 -1
- package/dist/src/harness/compaction-prompt.d.ts +16 -0
- package/dist/src/harness/compaction-prompt.js +24 -0
- package/dist/src/harness/compaction.d.ts +2 -1
- package/dist/src/harness/compaction.js +1 -4
- package/dist/src/harness/input-requests.d.ts +1 -0
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/instrumentation-runtime-context.d.ts +1 -1
- package/dist/src/harness/tool-loop.js +3 -1
- package/dist/src/internal/application/build-workspace.d.ts +36 -0
- package/dist/src/internal/application/build-workspace.js +1 -0
- package/dist/src/internal/application/compiled-artifacts.d.ts +5 -0
- package/dist/src/internal/application/compiled-artifacts.js +4 -3
- package/dist/src/internal/application/output-publication-artifacts.d.ts +7 -0
- package/dist/src/internal/application/output-publication-artifacts.js +1 -0
- package/dist/src/internal/application/output-publication-journal.d.ts +30 -0
- package/dist/src/internal/application/output-publication-journal.js +1 -0
- package/dist/src/internal/application/output-publication-lock.d.ts +10 -0
- package/dist/src/internal/application/output-publication-lock.js +1 -0
- package/dist/src/internal/application/output-publication.d.ts +33 -0
- package/dist/src/internal/application/output-publication.js +1 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/paths.d.ts +2 -0
- package/dist/src/internal/application/paths.js +1 -1
- package/dist/src/internal/application/production-compiler-artifacts.d.ts +4 -0
- package/dist/src/internal/application/production-compiler-artifacts.js +1 -0
- package/dist/src/internal/application/tsconfig-dependencies.js +1 -1
- package/dist/src/internal/authored-directive-prologue.d.ts +4 -0
- package/dist/src/internal/authored-directive-prologue.js +1 -0
- package/dist/src/internal/authored-module-loader.d.ts +15 -5
- package/dist/src/internal/authored-module-loader.js +4 -2
- package/dist/src/internal/authored-module-map-loader.js +1 -1
- package/dist/src/internal/authored-package-boundary.d.ts +25 -0
- package/dist/src/internal/authored-package-boundary.js +1 -0
- package/dist/src/internal/authored-package-tsconfig-paths.js +1 -1
- package/dist/src/internal/bundler/nitro-node-file-trace.d.ts +10 -0
- package/dist/src/internal/bundler/nitro-node-file-trace.js +1 -0
- package/dist/src/internal/materialize-authored-external-dependencies.d.ts +10 -0
- package/dist/src/internal/materialize-authored-external-dependencies.js +2 -0
- package/dist/src/internal/materialized-authored-modules.d.ts +15 -0
- package/dist/src/internal/materialized-authored-modules.js +1 -0
- package/dist/src/internal/nitro/dev-runtime-artifacts.d.ts +1 -9
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/development-generation.d.ts +12 -0
- package/dist/src/internal/nitro/development-generation.js +1 -0
- package/dist/src/internal/nitro/host/artifacts-config.d.ts +9 -11
- package/dist/src/internal/nitro/host/artifacts-config.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.d.ts +1 -7
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
- package/dist/src/internal/nitro/host/channel-routes.d.ts +3 -3
- package/dist/src/internal/nitro/host/configure-nitro-routes.d.ts +9 -5
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +3 -3
- package/dist/src/internal/nitro/host/copy-host-middleware.d.ts +12 -0
- package/dist/src/internal/nitro/host/copy-host-middleware.js +1 -0
- package/dist/src/internal/nitro/host/create-application-nitro.d.ts +18 -10
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dispatch-schedule-in-dev.d.ts +2 -2
- package/dist/src/internal/nitro/host/dispatch-schedule-in-dev.js +1 -1
- package/dist/src/internal/nitro/host/prepare-application-host.d.ts +13 -5
- package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
- package/dist/src/internal/nitro/host/schedule-task-routes.d.ts +3 -3
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/host/types.d.ts +4 -0
- package/dist/src/internal/nitro/routes/agent-info/load-agent-info-data.d.ts +3 -6
- package/dist/src/internal/nitro/routes/agent-info/load-agent-info-data.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/dev-schedule-dispatch.d.ts +2 -2
- package/dist/src/internal/nitro/routes/info.d.ts +1 -6
- package/dist/src/internal/nitro/routes/info.js +1 -1
- package/dist/src/internal/nitro/routes/runtime-artifacts.d.ts +9 -5
- package/dist/src/internal/nitro/routes/runtime-artifacts.js +1 -1
- package/dist/src/internal/workflow-bundle/build-queue.d.ts +1 -0
- package/dist/src/internal/workflow-bundle/build-queue.js +1 -0
- package/dist/src/internal/workflow-bundle/builder-support.d.ts +0 -1
- package/dist/src/internal/workflow-bundle/builder-support.js +2 -2
- package/dist/src/internal/workflow-bundle/builder.js +2 -2
- package/dist/src/internal/workflow-bundle/nitro-step-entry.d.ts +1 -0
- package/dist/src/internal/workflow-bundle/nitro-step-entry.js +2 -2
- package/dist/src/public/instrumentation/index.d.ts +3 -3
- package/dist/src/public/next/vercel-output-config.js +1 -1
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/scaffold/update/channels.js +1 -1
- package/dist/src/shared/atomic-write-file.d.ts +11 -0
- package/dist/src/shared/atomic-write-file.js +1 -0
- package/dist/src/shared/guards.d.ts +7 -0
- package/dist/src/shared/guards.js +1 -1
- package/dist/src/shared/path-exists.d.ts +9 -0
- package/dist/src/shared/path-exists.js +1 -0
- package/docs/agent-config.md +1 -1
- package/docs/concepts/default-harness.md +1 -1
- package/docs/reference/cli.md +4 -2
- package/package.json +14 -14
- package/dist/src/compiled/_chunks/workflow/attribute-changes-Dmf_myUv.js +0 -20
- package/dist/src/compiled/_chunks/workflow/dist-D7CzPkf8.js +0 -77
- package/dist/src/compiled/_chunks/workflow/run-CL3mguvM.js +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { resolveOutputPublicationLockPath } from "#internal/application/output-publication-lock.js";
|
|
2
|
+
export { resolveOutputPublicationLockPath };
|
|
3
|
+
export interface OutputPublicationInput {
|
|
4
|
+
readonly appRoot: string;
|
|
5
|
+
readonly finalOutputDir: string;
|
|
6
|
+
readonly finalSummaryPath: string;
|
|
7
|
+
/** Invocation-owned directory containing the staged paths; recovery removes it. */
|
|
8
|
+
readonly scratchDir: string;
|
|
9
|
+
readonly stagedOutputDir: string;
|
|
10
|
+
readonly stagedSummaryPath: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A publication failure that retained the lock journal on disk. The staged
|
|
14
|
+
* artifacts (and the scratch directory containing them) must outlive this
|
|
15
|
+
* invocation so a later build can finish the interrupted publication.
|
|
16
|
+
*/
|
|
17
|
+
export declare class RecoverablePublicationError extends AggregateError {
|
|
18
|
+
constructor(errors: readonly unknown[], message: string, options?: ErrorOptions);
|
|
19
|
+
}
|
|
20
|
+
interface OutputPublicationObserver {
|
|
21
|
+
afterBackup(): Promise<void>;
|
|
22
|
+
afterOutputInstall(): Promise<void>;
|
|
23
|
+
onContention(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Atomically installs a build's staged output and summary as the app's
|
|
27
|
+
* published artifacts: backs up the previous publication, renames the staged
|
|
28
|
+
* paths into place, and rolls back to the backup on failure. A journaled,
|
|
29
|
+
* cross-process lock serializes publishers and lets the next build finish an
|
|
30
|
+
* interrupted publication.
|
|
31
|
+
*/
|
|
32
|
+
export declare function publishApplicationBuildArtifacts(input: OutputPublicationInput): Promise<void>;
|
|
33
|
+
export declare function publishApplicationBuildArtifactsWithObserver(input: OutputPublicationInput, observer: OutputPublicationObserver): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve}from"node:path";import{randomUUID}from"node:crypto";import{assertStagedPublicationExists,backupOutputPublication,installOutputPublication,prepareOutputPublication,removeOutputPublicationBackups,rollbackOutputPublication}from"#internal/application/output-publication-artifacts.js";import{writeOutputPublicationJournal}from"#internal/application/output-publication-journal.js";import{acquireOutputPublicationLock,resolveOutputPublicationLockPath,startPublicationJournalHeartbeat}from"#internal/application/output-publication-lock.js";var RecoverablePublicationError=class extends AggregateError{constructor(e,t,n){super(e,t,n),this.name=`RecoverablePublicationError`}};const DEFAULT_OBSERVER={async afterBackup(){},async afterOutputInstall(){},async onContention(){}};async function publishApplicationBuildArtifacts(e){await publishApplicationBuildArtifactsWithObserver(e,DEFAULT_OBSERVER)}async function publishApplicationBuildArtifactsWithObserver(e,t){let o=createOutputPublicationJournal(e);await assertStagedPublicationExists(o);let s=resolveOutputPublicationLockPath(e.appRoot),c=await acquireOutputPublicationLock(s,o,t.onContention),l=startPublicationJournalHeartbeat(s),u=!1;try{await prepareOutputPublication(o),o.phase=`prepared`,await writeOutputPublicationJournal(s,o),await backupOutputPublication(o),o.phase=`backed-up`,await writeOutputPublicationJournal(s,o),await t.afterBackup(),await installOutputPublication(o,t.afterOutputInstall),o.phase=`committed`,await writeOutputPublicationJournal(s,o),u=!0,await removeOutputPublicationBackups(o)}catch(e){u&&await throwRecoverablePublicationError({errors:[e],journal:o,lockPath:s,message:`Build output was committed but backup cleanup failed.`});try{await rollbackOutputPublication(o)}catch(t){await throwRecoverablePublicationError({errors:[e,t],journal:o,lockPath:s,message:`Build output publication failed and could not fully restore the previous output.`})}throw await c(),e}finally{l()}await c()}function createOutputPublicationJournal(n){let r=randomUUID(),i=resolve(n.finalOutputDir),a=resolve(n.finalSummaryPath);return{finalOutputDir:i,finalSummaryPath:a,hadOutput:!1,hadSummary:!1,liveness:`active`,outputBackupPath:`${i}.eve-backup-${r}`,phase:`acquired`,pid:process.pid,scratchDir:resolve(n.scratchDir),stagedOutputDir:resolve(n.stagedOutputDir),stagedSummaryPath:resolve(n.stagedSummaryPath),summaryBackupPath:`${a}.eve-backup-${r}`,token:r}}async function throwRecoverablePublicationError(e){e.journal.liveness=`recoverable`;try{await writeOutputPublicationJournal(e.lockPath,e.journal)}catch(t){throw new RecoverablePublicationError([...e.errors,t],e.message,{cause:e.errors[0]})}throw new RecoverablePublicationError(e.errors,e.message,{cause:e.errors[0]})}export{RecoverablePublicationError,publishApplicationBuildArtifacts,publishApplicationBuildArtifactsWithObserver,resolveOutputPublicationLockPath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.24.
|
|
1
|
+
import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.24.2`,WORKFLOW_MODULE_ALIASES={"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let n=e;for(;;){if(existsSync(join(n,`package.json`))&&!isBuildOutputPackageRoot(n))return n;let r=dirname(n);if(r===n)throw Error(`Failed to resolve package root from "${e}".`);n=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let r=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(r?.name===t)return r}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function readWorkflowVersionFromManifest(e){let t=e;for(let e of[t.devDependencies,t.dependencies,t.peerDependencies]){let t=e?.[`@workflow/core`];if(typeof t==`string`&&t.trim().length>0)return t}}function resolveExpectedWorkflowVersion(){let e=tryResolvePackageRoot();if(e!==void 0)try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(join(e,`package.json`),`utf8`)))}catch{}try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),`utf8`)))}catch{return}}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/api`||e===`workflow/runtime`)return resolvePackageSourceFilePath(`src/internal/workflow/runtime.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveExpectedWorkflowVersion,resolveInstalledPackageInfo,resolvePackageCompiledFilePath,resolvePackageDependencyPath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { NitroBuildSurface } from "#internal/nitro/host/types.js";
|
|
2
|
+
export declare const EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV = "EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY";
|
|
3
|
+
export declare const EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV = "EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY";
|
|
2
4
|
export interface ApplicationInfo {
|
|
3
5
|
appRoot: string;
|
|
4
6
|
outputDir: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveInstalledPackageInfo,resolvePackageRoot,resolvePackageSourceDirectoryPath}from"#internal/application/package.js";import{existsSync,readFileSync,readdirSync,rmSync}from"node:fs";import{join,resolve}from"node:path";import{createHash}from"node:crypto";import{workflowEntryReference}from"#execution/workflow-runtime.js";function resolveApplicationRoot(e=process.cwd()){return resolve(e)}function getWorkflowBuildCacheKey(e){return createHash(`sha256`).update(e).digest(`hex`).slice(0,12)}function isVercelBuildEnvironment(){return!!process.env.VERCEL}function resolveNitroBuildDirectory(e,t=`all`){let n=join(e,`.eve`,`nitro`);return t===`all`?n:join(n,t)}function resolveApplicationHostArtifactsDirectory(e){return join(e,`.eve`,`host`)}function resolveNitroSurfaceOutputDirectory(e,t){return join(e,`.eve`,`nitro-output`,t)}function resolveWorkflowBuildDirectory(e){let n=join(resolvePackageRoot(),`.eve`,`workflow-cache`);return pruneStaleWorkflowCacheSiblings(n),join(n,getWorkflowBuildCacheKey(e))}function pruneStaleWorkflowCacheSiblings(t){if(!existsSync(t))return;let n=resolveInstalledPackageInfo().version,i;try{i=readdirSync(t)}catch{return}for(let e of i){let r=join(t,e),i=join(r,`eve-cache.json`);if(existsSync(i))try{let e=JSON.parse(readFileSync(i,`utf8`));typeof e.eveVersion==`string`&&e.eveVersion!==n&&rmSync(r,{force:!0,recursive:!0})}catch{}}}function resolveSandboxCacheDirectory(e){return join(e,`.eve`,`sandbox-cache`)}function resolveOutputDirectory(e){return isVercelBuildEnvironment()?join(e,`.vercel`,`output`):join(e,`.output`)}function getApplicationInfo(e){return{appRoot:e,outputDir:resolveOutputDirectory(e),workflowId:workflowEntryReference.workflowId,workflowBuildDir:resolveWorkflowBuildDirectory(e),workflowSourceDir:resolvePackageSourceDirectoryPath(`src/execution`)}}export{getApplicationInfo,isVercelBuildEnvironment,resolveApplicationHostArtifactsDirectory,resolveApplicationRoot,resolveNitroBuildDirectory,resolveNitroSurfaceOutputDirectory,resolveOutputDirectory,resolveSandboxCacheDirectory,resolveWorkflowBuildDirectory};
|
|
1
|
+
import{resolveInstalledPackageInfo,resolvePackageRoot,resolvePackageSourceDirectoryPath}from"#internal/application/package.js";import{existsSync,readFileSync,readdirSync,rmSync}from"node:fs";import{join,resolve}from"node:path";import{createHash}from"node:crypto";import{workflowEntryReference}from"#execution/workflow-runtime.js";const EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV=`EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY`,EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV=`EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY`;function resolveApplicationRoot(e=process.cwd()){return resolve(e)}function getWorkflowBuildCacheKey(e){return createHash(`sha256`).update(e).digest(`hex`).slice(0,12)}function isVercelBuildEnvironment(){return!!process.env.VERCEL}function resolveNitroBuildDirectory(e,t=`all`){let n=join(e,`.eve`,`nitro`);return t===`all`?n:join(n,t)}function resolveApplicationHostArtifactsDirectory(e){return join(e,`.eve`,`host`)}function resolveNitroSurfaceOutputDirectory(e,t){return join(e,`.eve`,`nitro-output`,t)}function resolveWorkflowBuildDirectory(e){let n=join(resolvePackageRoot(),`.eve`,`workflow-cache`);return pruneStaleWorkflowCacheSiblings(n),join(n,getWorkflowBuildCacheKey(e))}function pruneStaleWorkflowCacheSiblings(t){if(!existsSync(t))return;let n=resolveInstalledPackageInfo().version,i;try{i=readdirSync(t)}catch{return}for(let e of i){let r=join(t,e),i=join(r,`eve-cache.json`);if(existsSync(i))try{let e=JSON.parse(readFileSync(i,`utf8`));typeof e.eveVersion==`string`&&e.eveVersion!==n&&rmSync(r,{force:!0,recursive:!0})}catch{}}}function resolveSandboxCacheDirectory(e){return join(e,`.eve`,`sandbox-cache`)}function resolveOutputDirectory(e){return isVercelBuildEnvironment()?join(e,`.vercel`,`output`):join(e,`.output`)}function getApplicationInfo(e){return{appRoot:e,outputDir:resolveOutputDirectory(e),workflowId:workflowEntryReference.workflowId,workflowBuildDir:resolveWorkflowBuildDirectory(e),workflowSourceDir:resolvePackageSourceDirectoryPath(`src/execution`)}}export{EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV,EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV,getApplicationInfo,isVercelBuildEnvironment,resolveApplicationHostArtifactsDirectory,resolveApplicationRoot,resolveNitroBuildDirectory,resolveNitroSurfaceOutputDirectory,resolveOutputDirectory,resolveSandboxCacheDirectory,resolveWorkflowBuildDirectory};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dirname,join}from"node:path";import{cp,mkdir}from"node:fs/promises";async function stageProductionCompilerArtifacts(e){let t=join(e.outputDir,`.eve`);await mkdir(dirname(t),{recursive:!0}),await cp(e.compilerArtifactsRoot,t,{recursive:!0})}export{stageProductionCompilerArtifacts};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire}from"node:module";import{existsSync}from"node:fs";import{dirname,isAbsolute,join,resolve}from"node:path";import{readFile,readdir}from"node:fs/promises";import{parse}from"#compiled/jsonc-parser/index.js";async function resolveTsConfigDependencyPaths(e){let t=await resolveRootTsConfigPaths(e),n=new Set,r=new Set;for(let e of t)await collectTsConfigDependencyPaths({configPath:e,resolvedConfigPaths:n,visitingConfigPaths:r});return[...n].sort((e,t)=>e.localeCompare(t))}async function resolveRootTsConfigPaths(e){let t=new Set([join(e,`tsconfig.json`),join(e,`jsconfig.json`)]);try{let n=await readdir(e,{withFileTypes:!0});for(let r of n)r.isFile()&&/^tsconfig\..+\.json$/i.test(r.name)&&t.add(join(e,r.name))}catch{}return[...t]}async function collectTsConfigDependencyPaths(e){let t=resolve(e.configPath);if(e.resolvedConfigPaths.has(t)||e.visitingConfigPaths.has(t))return;let n=await readTextFileIfExists(t);if(n!==void 0){e.resolvedConfigPaths.add(t),e.visitingConfigPaths.add(t);try{let r=extractTsConfigExtendsSpecifiers(n);for(let n of r)for(let r of resolveTsConfigExtendsTargetPaths({configPath:t,extendsSpecifier:n}))await collectTsConfigDependencyPaths({configPath:r,resolvedConfigPaths:e.resolvedConfigPaths,visitingConfigPaths:e.visitingConfigPaths})}finally{e.visitingConfigPaths.delete(t)}}}async function readTextFileIfExists(e){try{return await readFile(e,`utf8`)}catch{return}}function parseTsConfigObject(e){let t=[],n=parse(e,t,{allowTrailingComma:!0});if(!(t.length>0||typeof n!=`object`||!n||Array.isArray(n)))return n}function extractTsConfigExtendsSpecifiers(e){let t=parseTsConfigObject(e);if(t===void 0)return[];let n=t.extends;return typeof n==`string`?n.length>0?[n]:[]:Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}function resolveTsConfigExtendsTargetPaths(e){let t=new Set;if(isTsConfigFilePath(e.extendsSpecifier))for(let n of resolveFileExtendsCandidates({configPath:e.configPath,extendsSpecifier:e.extendsSpecifier}))t.add(n);else for(let n of resolvePackageExtendsCandidates({configPath:e.configPath,extendsSpecifier:e.extendsSpecifier}))t.add(n);return[...t]}function resolveFirstExistingTsConfigExtendsTarget(e){for(let n of resolveTsConfigExtendsTargetPaths(e))if(existsSync(n))return n}function resolveFileExtendsCandidates(e){let t=resolve(dirname(e.configPath),e.extendsSpecifier),r=new Set;return r.add(t),t.endsWith(`.json`)||(r.add(`${t}.json`),r.add(join(t,`tsconfig.json`))),[...r]}function resolvePackageExtendsCandidates(t){let n=new Set([t.extendsSpecifier]);t.extendsSpecifier.endsWith(`.json`)||(n.add(`${t.extendsSpecifier}.json`),n.add(`${t.extendsSpecifier}/tsconfig.json`));let r=new Set,i=createRequire(t.configPath);for(let e of n)try{r.add(i.resolve(e))}catch{}return[...r]}function isTsConfigFilePath(e){return e.startsWith(`.`)||isAbsolute(e)?!0:/^[A-Za-z]:[\\/]/.test(e)}export{collectTsConfigDependencyPaths,extractTsConfigExtendsSpecifiers,isTsConfigFilePath,parseTsConfigObject,readTextFileIfExists,resolveFirstExistingTsConfigExtendsTarget,resolveRootTsConfigPaths,resolveTsConfigDependencyPaths,resolveTsConfigExtendsTargetPaths};
|
|
1
|
+
import{createRequire}from"node:module";import{existsSync}from"node:fs";import{dirname,isAbsolute,join,resolve}from"node:path";import{readFile,readdir}from"node:fs/promises";import{parse as parse$1}from"#compiled/jsonc-parser/index.js";async function resolveTsConfigDependencyPaths(e){let t=await resolveRootTsConfigPaths(e),n=new Set,r=new Set;for(let e of t)await collectTsConfigDependencyPaths({configPath:e,resolvedConfigPaths:n,visitingConfigPaths:r});return[...n].sort((e,t)=>e.localeCompare(t))}async function resolveRootTsConfigPaths(e){let t=new Set([join(e,`tsconfig.json`),join(e,`jsconfig.json`)]);try{let n=await readdir(e,{withFileTypes:!0});for(let r of n)r.isFile()&&/^tsconfig\..+\.json$/i.test(r.name)&&t.add(join(e,r.name))}catch{}return[...t]}async function collectTsConfigDependencyPaths(e){let t=resolve(e.configPath);if(e.resolvedConfigPaths.has(t)||e.visitingConfigPaths.has(t))return;let n=await readTextFileIfExists(t);if(n!==void 0){e.resolvedConfigPaths.add(t),e.visitingConfigPaths.add(t);try{let r=extractTsConfigExtendsSpecifiers(n);for(let n of r)for(let r of resolveTsConfigExtendsTargetPaths({configPath:t,extendsSpecifier:n}))await collectTsConfigDependencyPaths({configPath:r,resolvedConfigPaths:e.resolvedConfigPaths,visitingConfigPaths:e.visitingConfigPaths})}finally{e.visitingConfigPaths.delete(t)}}}async function readTextFileIfExists(e){try{return await readFile(e,`utf8`)}catch{return}}function parseTsConfigObject(e){let t=[],n=parse$1(e,t,{allowTrailingComma:!0});if(!(t.length>0||typeof n!=`object`||!n||Array.isArray(n)))return n}function extractTsConfigExtendsSpecifiers(e){let t=parseTsConfigObject(e);if(t===void 0)return[];let n=t.extends;return typeof n==`string`?n.length>0?[n]:[]:Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}function resolveTsConfigExtendsTargetPaths(e){let t=new Set;if(isTsConfigFilePath(e.extendsSpecifier))for(let n of resolveFileExtendsCandidates({configPath:e.configPath,extendsSpecifier:e.extendsSpecifier}))t.add(n);else for(let n of resolvePackageExtendsCandidates({configPath:e.configPath,extendsSpecifier:e.extendsSpecifier}))t.add(n);return[...t]}function resolveFirstExistingTsConfigExtendsTarget(e){for(let n of resolveTsConfigExtendsTargetPaths(e))if(existsSync(n))return n}function resolveFileExtendsCandidates(e){let t=resolve(dirname(e.configPath),e.extendsSpecifier),r=new Set;return r.add(t),t.endsWith(`.json`)||(r.add(`${t}.json`),r.add(join(t,`tsconfig.json`))),[...r]}function resolvePackageExtendsCandidates(t){let n=new Set([t.extendsSpecifier]);t.extendsSpecifier.endsWith(`.json`)||(n.add(`${t.extendsSpecifier}.json`),n.add(`${t.extendsSpecifier}/tsconfig.json`));let r=new Set,i=createRequire(t.configPath);for(let e of n)try{r.add(i.resolve(e))}catch{}return[...r]}function isTsConfigFilePath(e){return e.startsWith(`.`)||isAbsolute(e)?!0:/^[A-Za-z]:[\\/]/.test(e)}export{collectTsConfigDependencyPaths,extractTsConfigExtendsSpecifiers,isTsConfigFilePath,parseTsConfigObject,readTextFileIfExists,resolveFirstExistingTsConfigExtendsTarget,resolveRootTsConfigPaths,resolveTsConfigDependencyPaths,resolveTsConfigExtendsTargetPaths};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parseWithNitroRolldownAst}from"#internal/bundler/nitro-rolldown.js";const UNSUPPORTED_WORKFLOW_DIRECTIVES=new Set([`use step`,`use workflow`]);async function assertNoWorkflowDirectivePrologue(t){let n=await parseWithNitroRolldownAst(t.filePath,t.source);if(!Array.isArray(n.body))throw Error(`Failed to parse authored module "${t.filePath}".`);for(let e of n.body){if(typeof e.directive!=`string`)break;if(UNSUPPORTED_WORKFLOW_DIRECTIVES.has(e.directive))throw Error(`Authored module "${t.filePath}" contains an actual "${e.directive}" directive. Workflow directives are reserved for eve-generated workflow entrypoints.`)}}export{assertNoWorkflowDirectivePrologue};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ResolvedAuthoredExternalModule } from "#internal/materialize-authored-external-dependencies.js";
|
|
1
2
|
export interface AuthoredModuleLoadOptions {
|
|
2
3
|
readonly externalDependencies?: readonly string[];
|
|
3
4
|
/**
|
|
@@ -7,6 +8,10 @@ export interface AuthoredModuleLoadOptions {
|
|
|
7
8
|
*/
|
|
8
9
|
readonly extensionScopeNamespace?: string;
|
|
9
10
|
}
|
|
11
|
+
export interface AuthoredGenerationModuleBundle {
|
|
12
|
+
readonly code: string;
|
|
13
|
+
readonly externalModules: readonly ResolvedAuthoredExternalModule[];
|
|
14
|
+
}
|
|
10
15
|
/**
|
|
11
16
|
* Loads one authored module namespace from disk during compile-time
|
|
12
17
|
* discovery. Concurrent loads of the same `modulePath` share a single
|
|
@@ -14,10 +19,15 @@ export interface AuthoredModuleLoadOptions {
|
|
|
14
19
|
*/
|
|
15
20
|
export declare function loadAuthoredModuleNamespace(modulePath: string, options?: AuthoredModuleLoadOptions): Promise<Record<string, unknown>>;
|
|
16
21
|
/**
|
|
17
|
-
* Bundles one authored entry
|
|
18
|
-
*
|
|
19
|
-
* external, relative source is inlined, and (when `extensionScopeNamespace` is
|
|
20
|
-
* set) `defineState`/`defineExtension` are scoped to that namespace. Shared with
|
|
21
|
-
* `eve extension build`'s entrypoint compilation so both paths bundle identically.
|
|
22
|
+
* Bundles one authored entry for immediate dev/eval loading. Package dependencies
|
|
23
|
+
* remain external while relative authored source is inlined.
|
|
22
24
|
*/
|
|
23
25
|
export declare function bundleAuthoredModuleCode(modulePath: string, options?: AuthoredModuleLoadOptions): Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Bundles one authored entry for an immutable development generation. Ordinary
|
|
28
|
+
* package dependencies are inlined so the emitted code stays executable after
|
|
29
|
+
* the original workspace changes; framework runtime imports and configured
|
|
30
|
+
* external dependencies stay external, and every configured external the
|
|
31
|
+
* bundle references is reported for closure materialization.
|
|
32
|
+
*/
|
|
33
|
+
export declare function bundleAuthoredModuleForGeneration(modulePath: string, options?: AuthoredModuleLoadOptions): Promise<AuthoredGenerationModuleBundle>;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`),moduleType:`js`}}}:null,t.extensionScopeNamespace===void 0?null:createFixedNamespaceScopePlugin(t.extensionScopeNamespace),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin(),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:
|
|
1
|
+
import{expectObjectRecord}from"#internal/authored-module.js";import{existsSync,mkdirSync,statSync,writeFileSync}from"node:fs";import{dirname,isAbsolute,join,resolve}from"node:path";import{createHash}from"node:crypto";import{buildWithNitroRolldown,getSingleRolldownChunk}from"#internal/bundler/nitro-rolldown.js";import{createAuthoredAssetImportPlugin}from"#internal/authored-asset-import-plugin.js";import{assertNoWorkflowDirectivePrologue}from"#internal/authored-directive-prologue.js";import{createAuthoredModuleBundleError}from"#internal/authored-module-bundle.js";import{createAuthoredPackageTsConfigPathsPlugin}from"#internal/authored-package-tsconfig-paths.js";import{createFixedNamespaceScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{CACHED_CHANNEL_PREFIX,RESOLVE_EXTENSIONS,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies}from"#internal/authored-package-boundary.js";import{createNodeEsmCompatBannerPlugin}from"#internal/node-esm-compat-banner.js";const AUTHORED_BUNDLED_MODULE_EXTENSION=/\.[cm]?[jt]sx?$/,AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH=join(`node_modules`,`.cache`,`eve`,`authored-modules`),CHANNEL_MODULE_CACHE_KEY=`__eveChannelModuleCache__`;function getChannelModuleCache(){return globalThis[CHANNEL_MODULE_CACHE_KEY]}const inFlightModuleLoads=new Map;function loadAuthoredModuleNamespace(e,t={}){let n=createInFlightModuleLoadKey(resolve(e),t),r=inFlightModuleLoads.get(n);if(r!==void 0)return r;let i=(async()=>{try{return await doLoadAuthoredModuleNamespace(e,t)}finally{inFlightModuleLoads.delete(n)}})();return inFlightModuleLoads.set(n,i),i}async function doLoadAuthoredModuleNamespace(t,n){return expectObjectRecord(AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)?await loadBundledAuthoredModule(t,n):await import(createFileImportSpecifier(t)),`Expected "${t}" to export a module namespace object.`)}function createFileImportSpecifier(e){let t=e.replaceAll(`\\`,`/`);return/^[A-Za-z]:\//.test(t)?`file:///${encodeURI(t)}`:t.startsWith(`/`)?`file://${encodeURI(t)}`:t}async function bundleAuthoredModuleCode(e,t={}){return await buildAuthoredModuleBundle(e,t,{channelIdentity:!0,packageBoundaryPlugin:createRuntimeLoaderPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e)}),plugins:[],sourcemap:`inline`})}async function bundleAuthoredModuleForGeneration(e,t={}){let n=new Map;return{code:removeRolldownModuleRegionComments(await buildAuthoredModuleBundle(e,t,{channelIdentity:!1,packageBoundaryPlugin:createGenerationPackageBoundaryPlugin({externalDependencies:normalizeExternalDependencies(t.externalDependencies),packageRoot:resolveAuthoredPackageRoot(e),recordExternalModule(e){n.set(`${e.packageName}\0${e.resolvedId}`,e)}}),plugins:[createAuthoredDirectiveGuardPlugin()],sourcemap:!1})),externalModules:[...n.values()].sort((e,t)=>`${e.packageName}\0${e.resolvedId}`.localeCompare(`${t.packageName}\0${t.resolvedId}`))}}async function buildAuthoredModuleBundle(e,t,n){let r=n.channelIdentity?getChannelModuleCache():void 0,i=resolveAuthoredPackageRoot(e),a=resolveAuthoredTsConfigPath(i),o=[r&&r.size>0?{name:`eve-channel-identity`,async resolveId(e,t,n){if(!/channels[/\\]/.test(e)||n.kind!==`import-statement`)return;let i=await this.resolve(e,t,{kind:n.kind,skipSelf:!0});if(i===null||typeof i.id!=`string`)return;let a=resolve(i.id);if(r.has(a))return{id:`${CACHED_CHANNEL_PREFIX}${a}`}},load(e){if(!e.startsWith(CACHED_CHANNEL_PREFIX))return;let t=e.slice(CACHED_CHANNEL_PREFIX.length);return{code:[`const cache = globalThis["${CHANNEL_MODULE_CACHE_KEY}"];`,`export default cache.get(${JSON.stringify(t)});`].join(`
|
|
2
|
+
`),moduleType:`js`}}}:null,...n.plugins,t.extensionScopeNamespace===void 0?null:createFixedNamespaceScopePlugin(t.extensionScopeNamespace),createAuthoredRelativeExtensionResolverPlugin({extensions:RESOLVE_EXTENSIONS}),createAuthoredAssetImportPlugin(),createAuthoredPackageTsConfigPathsPlugin({appPackageRoot:i,extensions:RESOLVE_EXTENSIONS}),createNodeEsmCompatBannerPlugin({includeRequire:!0}),n.packageBoundaryPlugin].filter(e=>e!==null);try{return getSingleRolldownChunk(await buildWithNitroRolldown({cwd:i,input:e,platform:`node`,plugins:o,resolve:{extensions:[...RESOLVE_EXTENSIONS]},tsconfig:a,write:!1,output:{comments:!1,format:`esm`,sourcemap:n.sourcemap}}),`authored module for "${e}"`).code}catch(t){throw createAuthoredModuleBundleError(e,t)}}function createAuthoredDirectiveGuardPlugin(){return{name:`eve-authored-directive-guard`,async transform(e,t){!AUTHORED_BUNDLED_MODULE_EXTENSION.test(t)||isNodeModulesPath(t)||await assertNoWorkflowDirectivePrologue({filePath:t,source:e})}}}function removeRolldownModuleRegionComments(e){return e.split(`
|
|
3
|
+
`).filter(e=>!e.startsWith(`//#region `)&&e!==`//#endregion`).join(`
|
|
4
|
+
`)}async function loadBundledAuthoredModule(e,r){let a=await bundleAuthoredModuleCode(e,r),o=normalizeExternalDependencies(r.externalDependencies),s=createHash(`sha1`).update(e).update(`\0`).update(o.join(`\0`)).update(`\0`).update(r.extensionScopeNamespace??``).update(`\0`).update(a).digest(`hex`),c=join(resolveAuthoredPackageRoot(e),AUTHORED_MODULE_BUNDLE_DIRECTORY_PATH),l=join(c,`${s}.mjs`);return existsSync(l)||(mkdirSync(c,{recursive:!0}),writeFileSync(l,a)),await import(`${createFileImportSpecifier(l)}?v=${s}`)}function createAuthoredRelativeExtensionResolverPlugin(e){return{name:`eve-authored-relative-extension-resolver`,resolveId(t,n){if(n===void 0||n.startsWith(`\0`)||n.startsWith(CACHED_CHANNEL_PREFIX)||!isPathImport(t))return;let r=resolveExistingImportPath(isAbsolute(t)?t:resolve(dirname(n),t),e.extensions);if(r!==void 0)return{id:r}}}}function createInFlightModuleLoadKey(e,t){return`${e}\0${normalizeExternalDependencies(t.externalDependencies).join(`\0`)}\0${t.extensionScopeNamespace??``}`}function resolveExistingImportPath(e,t){if(isFile(e))return e;for(let n of t){let t=`${e}${n}`;if(isFile(t))return t}for(let n of t){let t=join(e,`index${n}`);if(isFile(t))return t}}function isFile(e){try{return statSync(e).isFile()}catch{return!1}}function resolveAuthoredTsConfigPath(e){for(let n of[`tsconfig.json`,`jsconfig.json`]){let r=join(e,n);if(existsSync(r))return r}return!1}function resolveAuthoredPackageRoot(e){let n=dirname(e);for(;;){if(existsSync(join(n,`package.json`)))return n;let r=dirname(n);if(r===n)throw Error(`Failed to resolve the authored package root for "${e}".`);n=r}}export{bundleAuthoredModuleCode,bundleAuthoredModuleForGeneration,loadAuthoredModuleNamespace};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join}from"node:path";import{collectModuleRefsForManifest}from"#compiler/module-map.js";import{ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{loadAuthoredModuleNamespace}from"#internal/authored-module-loader.js";import{loadCompiledManifest}from"#runtime/loaders/manifest.js";const EXT_CONFIG_SCOPE=Symbol.for(`eve.ext-config-scope`);async function loadCompiledModuleMapFromAuthoredSource(e){return await hydrateCompiledModuleMapFromManifest(await loadCompiledManifest({compiledArtifactsSource:e.compiledArtifactsSource}))}async function hydrateCompiledModuleMapFromManifest(e){let
|
|
1
|
+
import{expectObjectRecord}from"#internal/authored-module.js";import{join}from"node:path";import{collectModuleRefsForManifest}from"#compiler/module-map.js";import{ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{loadAuthoredModuleNamespace}from"#internal/authored-module-loader.js";import{loadCompiledManifest}from"#runtime/loaders/manifest.js";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import{pathToFileURL}from"node:url";const EXT_CONFIG_SCOPE=Symbol.for(`eve.ext-config-scope`);async function loadCompiledModuleMapFromAuthoredSource(e){return await hydrateCompiledModuleMapFromManifest(await loadCompiledManifest({compiledArtifactsSource:e.compiledArtifactsSource}),e.compiledArtifactsSource.appRoot)}async function hydrateCompiledModuleMapFromManifest(e,t){let n={},i=[{agentRoot:e.agentRoot,manifest:e,nodeId:ROOT_COMPILED_AGENT_NODE_ID},...[...e.subagents].sort((e,t)=>e.nodeId.localeCompare(t.nodeId)).map(e=>({agentRoot:e.agent.agentRoot,manifest:e.agent,nodeId:e.nodeId}))],a={byMountNamespace:new Map(e.extensionMounts.map(e=>[e.namespace,e.packageNamespace])),byMountSourceId:new Map(e.extensionMounts.map(e=>[e.mountSourceId,e.packageNamespace]))},s=await readMaterializedAuthoredModuleIndex(t);for(let e of i){let r=s?.nodes[e.nodeId]?.modules;if(s!==void 0&&r===void 0)throw Error(`Materialized authored module index is missing node "${e.nodeId}".`);n[e.nodeId]={modules:await hydrateCompiledNodeScope({agentRoot:e.agentRoot,manifest:e.manifest,materializedModules:r,runtimeAppRoot:t,scopeIndex:a})}}return{nodes:n}}function extensionNamespaceForSourceId(e,t){let n=e.match(/^ext:([^:]+):/);return n===null?void 0:t.byMountNamespace.get(n[1])}async function hydrateCompiledNodeScope(r){let a=collectModuleRefsForManifest(r.manifest).sort((e,t)=>e.sourceId.localeCompare(t.sourceId)),o=r.manifest.config.build?.externalDependencies??[],l=globalThis,u={};for(let n of a){let a=join(r.agentRoot,n.logicalPath),d=extensionNamespaceForSourceId(n.sourceId,r.scopeIndex),f=r.scopeIndex.byMountSourceId.get(n.sourceId);f!==void 0&&(l[EXT_CONFIG_SCOPE]=f);try{let c=r.materializedModules?.[n.sourceId];if(r.materializedModules!==void 0&&c===void 0)throw Error(`Materialized authored module index is missing source "${n.sourceId}".`);if(c!==void 0){u[n.sourceId]=expectObjectRecord(await import(`${pathToFileURL(join(r.runtimeAppRoot,`.eve`,`compile`,c)).href}?generation=${encodeURIComponent(c)}`),`Expected materialized authored module "${n.sourceId}" to export a namespace object.`);continue}u[n.sourceId]=await loadAuthoredModuleNamespace(a,{externalDependencies:o,extensionScopeNamespace:d})}finally{f!==void 0&&(l[EXT_CONFIG_SCOPE]=void 0)}}return u}export{loadCompiledModuleMapFromAuthoredSource};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ResolvedAuthoredExternalModule } from "#internal/materialize-authored-external-dependencies.js";
|
|
2
|
+
export declare const CACHED_CHANNEL_PREFIX = "eve-cached-channel:";
|
|
3
|
+
export declare const RESOLVE_EXTENSIONS: readonly [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs", ".json"];
|
|
4
|
+
type RolldownResolveResult = {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
};
|
|
7
|
+
export type RolldownResolveContext = {
|
|
8
|
+
resolve(source: string, importer: string | undefined, options: {
|
|
9
|
+
kind: string;
|
|
10
|
+
skipSelf: boolean;
|
|
11
|
+
}): Promise<RolldownResolveResult | null>;
|
|
12
|
+
};
|
|
13
|
+
export declare function createGenerationPackageBoundaryPlugin(input: {
|
|
14
|
+
readonly externalDependencies: readonly string[];
|
|
15
|
+
readonly packageRoot: string;
|
|
16
|
+
readonly recordExternalModule: (externalModule: ResolvedAuthoredExternalModule) => void;
|
|
17
|
+
}): Record<string, unknown>;
|
|
18
|
+
export declare function createRuntimeLoaderPackageBoundaryPlugin(input: {
|
|
19
|
+
readonly externalDependencies: readonly string[];
|
|
20
|
+
readonly packageRoot: string;
|
|
21
|
+
}): Record<string, unknown>;
|
|
22
|
+
export declare function normalizeExternalDependencies(externalDependencies?: readonly string[]): string[];
|
|
23
|
+
export declare function isPathImport(source: string): boolean;
|
|
24
|
+
export declare function isNodeModulesPath(path: string): boolean;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync,realpathSync}from"node:fs";import{join,resolve,sep}from"node:path";import{SERVER_EXTERNAL_PACKAGES}from"#internal/nitro/host/server-external-packages.js";const CACHED_CHANNEL_PREFIX=`eve-cached-channel:`,RESOLVE_EXTENSIONS=[`.ts`,`.tsx`,`.mts`,`.cts`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`];function createGenerationPackageBoundaryPlugin(e){return{name:`eve-generation-package-boundary`,async resolveId(t,n,r){if(!isPackageImport(t))return;if(isFrameworkRuntimeImport(t,n))return{external:!0,id:t};let i=await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:n,kind:r.kind,packageRoot:e.packageRoot,source:t});if(i!==void 0)return e.recordExternalModule(i),{external:!0,id:t}}}}function createRuntimeLoaderPackageBoundaryPlugin(e){let t=toCanonicalPath(e.packageRoot);return{name:`eve-runtime-loader-package-boundary`,async resolveId(n,i,a){if(!isPackageImport(n))return;if(isFrameworkRuntimeImport(n,i))return{external:!0,id:n};let o=await resolveConfiguredExternalModule.call(this,{externalDependencies:e.externalDependencies,importer:i,kind:a.kind,packageRoot:e.packageRoot,source:n});if(o!==void 0)return{external:!0,id:resolveExistingExternalFilePath(o.resolvedId)??o.resolvedId};let s=i===void 0||i.startsWith(`\0`)||i.startsWith(`eve-cached-channel:`)?void 0:resolve(i);if(s!==void 0&&isPathInsideOrEqual(toCanonicalPath(s),t)){let e=await this.resolve(n,i,{kind:a.kind,skipSelf:!0});if(e===null||typeof e.id!=`string`)throw Error(`Cannot resolve package "${n}" imported from "${s}". Install it with your package manager (e.g. \`pnpm install\`); a running \`eve dev\` retries on the next rebuild.`);if(isNodeModulesPath(e.id))return{external:!0,id:n}}}}}async function resolveConfiguredExternalModule(e){let t=resolveConfiguredExternalDependency(e.source,e.externalDependencies);if(t===void 0)return;let r=await this.resolve(e.source,e.importer,{kind:e.kind,skipSelf:!0});if(r===null&&(r=await this.resolve(e.source,join(e.packageRoot,`package.json`),{kind:e.kind,skipSelf:!0})),r===null||typeof r.id!=`string`)throw Error(`Cannot resolve external package "${e.source}".`);return{packageName:t,resolvedId:r.id}}function normalizeExternalDependencies(e=[]){return[...new Set([...SERVER_EXTERNAL_PACKAGES,...e])].sort()}function resolveConfiguredExternalDependency(e,t){return t.find(t=>e===t||e.startsWith(`${t}/`))}function resolveExistingExternalFilePath(t){if(existsSync(t))return t;for(let n of RESOLVE_EXTENSIONS){let r=`${t}${n}`;if(existsSync(r))return r}}function isPackageImport(e){return isPathImport(e)||/^(?:node|data|file):/.test(e)||e.startsWith(`@/`)?!1:!e.startsWith(CACHED_CHANNEL_PREFIX)}function isPathImport(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function isFrameworkRuntimeImport(e,t){return e===`eve`||e.startsWith(`eve/`)?!0:e===`workflow`||e.startsWith(`workflow/`)||e.startsWith(`@workflow/`)?t===void 0||!isNodeModulesPath(t):!1}function isNodeModulesPath(e){return e.replaceAll(`\\`,`/`).includes(`/node_modules/`)}function toCanonicalPath(e){try{return realpathSync(e)}catch{return resolve(e)}}function isPathInsideOrEqual(e,t){let n=resolve(e),a=resolve(t);return n===a||n.startsWith(`${a}${sep}`)}export{CACHED_CHANNEL_PREFIX,RESOLVE_EXTENSIONS,createGenerationPackageBoundaryPlugin,createRuntimeLoaderPackageBoundaryPlugin,isNodeModulesPath,isPathImport,normalizeExternalDependencies};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dirname,join,resolve,sep}from"node:path";import{readFile,stat}from"node:fs/promises";import{parse}from"#compiled/jsonc-parser/index.js";const packageTsConfigPathsCache=new Map,nearestPackageRootCache=new Map;function createAuthoredPackageTsConfigPathsPlugin(e){return{name:`eve-package-tsconfig-paths`,async resolveId(t,r,i){if(r===void 0||!isPackageImport(t))return;let a=resolve(r);if(isPathInsideOrEqual(a,e.appPackageRoot))return;let o=await resolveNearestPackageRoot(a);if(o===void 0||isPathInsideOrEqual(o,e.appPackageRoot))return;let s=await loadPackageTsConfigPaths(o);if(s!==void 0)for(let n of createTsConfigPathCandidates(t,s)){let t=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(t!==null)return t;let a=await resolveExistingPath(n,e.extensions);if(a!==void 0)return{id:a}}}}}function loadPackageTsConfigPaths(e){let t=packageTsConfigPathsCache.get(e);if(t!==void 0)return t;let n=readPackageTsConfigPaths(e);return packageTsConfigPathsCache.set(e,n),n}async function readPackageTsConfigPaths(t){let r=await readPackageConfig(t);if(r===void 0)return;let i=[],a=parse(r.source,i,{allowTrailingComma:!0});if(i.length>0||!isObjectRecord(a))return;let s=a.compilerOptions;if(!isObjectRecord(s)||!isObjectRecord(s.paths))return;let c=dirname(r.path),l=typeof s.baseUrl==`string`?resolve(c,s.baseUrl):c,u=Object.entries(s.paths).flatMap(([e,t])=>!Array.isArray(t)||!t.every(e=>typeof e==`string`)?[]:[{pattern:e,targets:t}]).sort((e,t)=>t.pattern.length-e.pattern.length);if(u.length!==0)return{baseDirectory:l,entries:u}}async function readPackageConfig(e){for(let n of[`tsconfig.json`,`jsconfig.json`]){let r=join(e,n);try{return{path:r,source:await readFile(r,`utf8`)}}catch(e){if(!isPathNotFoundError(e))throw e}}}function createTsConfigPathCandidates(e,t){let r=[];for(let i of t.entries){let a=matchTsConfigPathPattern(e,i.pattern);if(a!==void 0)for(let e of i.targets){let i=e.includes(`*`)?e.replaceAll(`*`,a):e;r.push(resolve(t.baseDirectory,i))}}return r}function matchTsConfigPathPattern(e,t){let n=t.indexOf(`*`);if(n===-1)return e===t?``:void 0;let r=t.slice(0,n),i=t.slice(n+1);if(!(!e.startsWith(r)||!e.endsWith(i)))return e.slice(r.length,e.length-i.length)}async function resolveExistingPath(e,n){if(await existsAsFile(e))return e;for(let t of n){let n=`${e}${t}`;if(await existsAsFile(n))return n}for(let r of n){let n=join(e,`index${r}`);if(await existsAsFile(n))return n}}async function existsAsFile(e){try{return(await stat(e)).isFile()}catch{return!1}}function resolveNearestPackageRoot(t){let n=dirname(t),r=nearestPackageRootCache.get(n);if(r!==void 0)return r;let i=findNearestPackageRoot(n);return nearestPackageRootCache.set(n,i),i}async function findNearestPackageRoot(n){let r=n;for(;;){if(await pathExists(join(r,`package.json`)))return r;let n=dirname(r);if(n===r)return;r=n}}async function pathExists(e){try{return await stat(e),!0}catch{return!1}}function isPathNotFoundError(e){return typeof e==`object`&&!!e&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`)}function isPackageImport(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)?!1:!/^(?:node|data|file):/.test(e)}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function isPathInsideOrEqual(e,t){let i=resolve(e),a=resolve(t);return i===a||i.startsWith(`${a}${sep}`)}export{createAuthoredPackageTsConfigPathsPlugin};
|
|
1
|
+
import{dirname,join,resolve,sep}from"node:path";import{readFile,stat}from"node:fs/promises";import{parse as parse$1}from"#compiled/jsonc-parser/index.js";const packageTsConfigPathsCache=new Map,nearestPackageRootCache=new Map;function createAuthoredPackageTsConfigPathsPlugin(e){return{name:`eve-package-tsconfig-paths`,async resolveId(t,r,i){if(r===void 0||!isPackageImport(t))return;let a=resolve(r);if(isPathInsideOrEqual(a,e.appPackageRoot))return;let o=await resolveNearestPackageRoot(a);if(o===void 0||isPathInsideOrEqual(o,e.appPackageRoot))return;let s=await loadPackageTsConfigPaths(o);if(s!==void 0)for(let n of createTsConfigPathCandidates(t,s)){let t=await this.resolve(n,r,{kind:i.kind,skipSelf:!0});if(t!==null)return t;let a=await resolveExistingPath(n,e.extensions);if(a!==void 0)return{id:a}}}}}function loadPackageTsConfigPaths(e){let t=packageTsConfigPathsCache.get(e);if(t!==void 0)return t;let n=readPackageTsConfigPaths(e);return packageTsConfigPathsCache.set(e,n),n}async function readPackageTsConfigPaths(t){let r=await readPackageConfig(t);if(r===void 0)return;let i=[],a=parse$1(r.source,i,{allowTrailingComma:!0});if(i.length>0||!isObjectRecord(a))return;let s=a.compilerOptions;if(!isObjectRecord(s)||!isObjectRecord(s.paths))return;let c=dirname(r.path),l=typeof s.baseUrl==`string`?resolve(c,s.baseUrl):c,u=Object.entries(s.paths).flatMap(([e,t])=>!Array.isArray(t)||!t.every(e=>typeof e==`string`)?[]:[{pattern:e,targets:t}]).sort((e,t)=>t.pattern.length-e.pattern.length);if(u.length!==0)return{baseDirectory:l,entries:u}}async function readPackageConfig(e){for(let n of[`tsconfig.json`,`jsconfig.json`]){let r=join(e,n);try{return{path:r,source:await readFile(r,`utf8`)}}catch(e){if(!isPathNotFoundError(e))throw e}}}function createTsConfigPathCandidates(e,t){let r=[];for(let i of t.entries){let a=matchTsConfigPathPattern(e,i.pattern);if(a!==void 0)for(let e of i.targets){let i=e.includes(`*`)?e.replaceAll(`*`,a):e;r.push(resolve(t.baseDirectory,i))}}return r}function matchTsConfigPathPattern(e,t){let n=t.indexOf(`*`);if(n===-1)return e===t?``:void 0;let r=t.slice(0,n),i=t.slice(n+1);if(!(!e.startsWith(r)||!e.endsWith(i)))return e.slice(r.length,e.length-i.length)}async function resolveExistingPath(e,n){if(await existsAsFile(e))return e;for(let t of n){let n=`${e}${t}`;if(await existsAsFile(n))return n}for(let r of n){let n=join(e,`index${r}`);if(await existsAsFile(n))return n}}async function existsAsFile(e){try{return(await stat(e)).isFile()}catch{return!1}}function resolveNearestPackageRoot(t){let n=dirname(t),r=nearestPackageRootCache.get(n);if(r!==void 0)return r;let i=findNearestPackageRoot(n);return nearestPackageRootCache.set(n,i),i}async function findNearestPackageRoot(n){let r=n;for(;;){if(await pathExists(join(r,`package.json`)))return r;let n=dirname(r);if(n===r)return;r=n}}async function pathExists(e){try{return await stat(e),!0}catch{return!1}}function isPathNotFoundError(e){return typeof e==`object`&&!!e&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`)}function isPackageImport(e){return e.startsWith(`.`)||e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)?!1:!/^(?:node|data|file):/.test(e)}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function isPathInsideOrEqual(e,t){let i=resolve(e),a=resolve(t);return i===a||i.startsWith(`${a}${sep}`)}export{createAuthoredPackageTsConfigPathsPlugin};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface NodeFileTraceResult {
|
|
2
|
+
readonly fileList: ReadonlySet<string>;
|
|
3
|
+
readonly warnings: ReadonlySet<Error>;
|
|
4
|
+
}
|
|
5
|
+
export declare function traceNodeEsmFiles(input: {
|
|
6
|
+
readonly base: string;
|
|
7
|
+
readonly entries: readonly string[];
|
|
8
|
+
readonly processCwd: string;
|
|
9
|
+
}): Promise<NodeFileTraceResult>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire}from"node:module";import{pathToFileURL}from"node:url";let nodeFileTraceModulePromise;async function loadNitroNodeFileTrace(){return nodeFileTraceModulePromise??=(async()=>await import(pathToFileURL(createRequire(createRequire(import.meta.url).resolve(`nitro/package.json`)).resolve(`@vercel/nft`)).href))(),await nodeFileTraceModulePromise}async function traceNodeEsmFiles(e){let{nodeFileTrace:t}=await loadNitroNodeFileTrace();return await t([...e.entries],{base:e.base,conditions:[`node`,`import`],processCwd:e.processCwd})}export{traceNodeEsmFiles};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ResolvedAuthoredExternalModule {
|
|
2
|
+
readonly packageName: string;
|
|
3
|
+
readonly resolvedId: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function materializeAuthoredExternalDependencies(input: {
|
|
6
|
+
readonly appRoot: string;
|
|
7
|
+
readonly externalModules: readonly ResolvedAuthoredExternalModule[];
|
|
8
|
+
readonly snapshotSourceRoot: string;
|
|
9
|
+
readonly sourceRoot: string;
|
|
10
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{constants}from"node:fs";import{dirname,isAbsolute,join,parse,relative,resolve,sep}from"node:path";import{copyFile,lstat,mkdir,readFile,readdir,readlink,realpath,rm,stat,symlink}from"node:fs/promises";import{createHash}from"node:crypto";import{traceNodeEsmFiles}from"#internal/bundler/nitro-node-file-trace.js";const COPY_MODE=constants.COPYFILE_FICLONE;async function materializeAuthoredExternalDependencies(e){if(e.externalModules.length===0)return createHash(`sha256`).digest(`hex`);let n=await realpath(e.sourceRoot),i=await realpath(e.appRoot),s=await resolveExternalPackages(e.externalModules),c=createHash(`sha256`),l=await traceExternalDependencyPaths(s,i),u=new Set,d=new Set;for(let t of s)await materializeDependencyDirectory({fingerprint:c,materializedDirectories:d,materializedPaths:u,snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t.packageRoot,sourceRoot:n});for(let t of l){let r=await findNearestPackageRoot(t);r!==void 0&&await materializeDependencyDirectory({fingerprint:c,materializedDirectories:d,materializedPaths:u,snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:r,sourceRoot:n})}for(let t of l)await materializeTracedPath({fingerprint:c,materializedPaths:u,snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t,sourceRoot:n});for(let l of s){let s=toMaterializedPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:l.packageRoot,sourceRoot:n}),u=join(toMaterializedPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:i,sourceRoot:n}),`node_modules`,...l.packageName.split(`/`));resolve(u)!==resolve(s)&&(await rm(u,{force:!0,recursive:!0}),await mkdir(dirname(u),{recursive:!0}),await symlink(relative(dirname(u),s)||`.`,u,`junction`)),c.update(`package\0`).update(l.packageName).update(`\0`).update(toSemanticPath(l.packageRoot,n)).update(`\0`)}return c.digest(`hex`)}async function traceExternalDependencyPaths(e,t){let r=new Map;for(let t of e){let e=parse(t.resolvedId).root,n=normalizePathRoot(e),a=r.get(n)??{base:e,entries:[]};a.entries.push(t.resolvedId),r.set(n,a)}let a=new Set,s=[];for(let e of[...r.values()].sort((e,t)=>normalizePathRoot(e.base).localeCompare(normalizePathRoot(t.base)))){let r=await traceNodeEsmFiles({base:e.base,entries:e.entries.sort(),processCwd:t});s.push(...r.warnings);for(let t of r.fileList)a.add(isAbsolute(t)?t:resolve(e.base,t))}if(s.length>0){let e=s.map(e=>e.message).sort();throw Error(`Failed to trace the complete authored external dependency closure:\n${e.join(`
|
|
2
|
+
`)}`)}return[...a].sort((e,t)=>e.localeCompare(t))}async function materializeDependencyDirectory(e){let t=await realpath(e.sourcePath);if(!e.materializedDirectories.has(t)){e.materializedDirectories.add(t);for(let n of(await readdir(t,{withFileTypes:!0})).sort((e,t)=>e.name.localeCompare(t.name))){let i=join(t,n.name),a=await lstat(i);if(a.isDirectory()){await materializeDependencyDirectory({...e,sourcePath:i});continue}if(a.isSymbolicLink()){await materializeTracedPath({fingerprint:e.fingerprint,materializedPaths:e.materializedPaths,snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:i,sourceRoot:e.sourceRoot});continue}await materializeTracedPath({fingerprint:e.fingerprint,materializedPaths:e.materializedPaths,snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:i,sourceRoot:e.sourceRoot})}}}async function resolveExternalPackages(e){let t=new Map;for(let n of e){let e=await findPackageRoot(n.resolvedId,n.packageName),r=t.get(n.packageName);if(r!==void 0&&resolve(r.packageRoot)!==resolve(e))throw Error(`Authored external dependency "${n.packageName}" resolves to multiple package instances.`);t.set(n.packageName,{packageName:n.packageName,packageRoot:e,resolvedId:n.resolvedId})}return[...t.values()].sort((e,t)=>e.packageName.localeCompare(t.packageName))}async function findPackageRoot(e,n){let i=dirname(await realpath(e));for(;;){let a=join(i,`package.json`);try{if(JSON.parse(await readFile(a,`utf8`)).name===n)return i}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let o=dirname(i);if(o===i)throw Error(`Cannot find package root for authored external dependency "${n}" from "${e}".`);i=o}}async function findNearestPackageRoot(e){let n=await realpath(e),i=(await stat(n)).isDirectory()?n:dirname(n);for(;;){try{let e=JSON.parse(await readFile(join(i,`package.json`),`utf8`));if(typeof e.name==`string`&&e.name.length>0)return i}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let e=dirname(i);if(e===i)return;i=e}}async function materializeTracedPath(e){let n=toSemanticPath(e.sourcePath,e.sourceRoot);if(e.materializedPaths.has(n))return;e.materializedPaths.add(n);let r=toMaterializedPath(e),i=await lstat(e.sourcePath),s=toSemanticPath(e.sourcePath,e.sourceRoot);if(i.isSymbolicLink()){let n=await readlink(e.sourcePath),i=await realpath(resolve(dirname(e.sourcePath),n)),c=toMaterializedPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:i,sourceRoot:e.sourceRoot}),l=await stat(e.sourcePath);await rm(r,{force:!0,recursive:!0}),await mkdir(dirname(r),{recursive:!0}),await symlink(relative(dirname(r),c)||`.`,r,l.isDirectory()?`junction`:`file`),e.fingerprint.update(s).update(`\0link\0`).update(toSemanticPath(i,e.sourceRoot)).update(`\0`);return}if(!i.isFile())throw Error(`Unsupported traced authored dependency path "${e.sourcePath}".`);await mkdir(dirname(r),{recursive:!0}),await copyFile(e.sourcePath,r,COPY_MODE),e.fingerprint.update(s).update(`\0file\0`).update(await readFile(e.sourcePath)).update(`\0`)}function toMaterializedPath(e){if(isPathInsideOrEqual(e.sourcePath,e.sourceRoot))return join(e.snapshotSourceRoot,relative(e.sourceRoot,e.sourcePath));let t=parse(resolve(e.sourcePath)).root;return join(e.snapshotSourceRoot,`.eve`,`external-dependencies`,createPathRootKey(t),relative(t,e.sourcePath))}function toSemanticPath(e,t){if(isPathInsideOrEqual(e,t))return`source/${toPortablePath(relative(t,e))}`;let n=parse(resolve(e)).root;return`external/${createPathRootKey(n)}/${toPortablePath(relative(n,e))}`}function createPathRootKey(e){return createHash(`sha256`).update(normalizePathRoot(e)).digest(`hex`).slice(0,12)}function isPathInsideOrEqual(e,t){let r=relative(resolve(t),resolve(e));return!(isAbsolute(r)||r===`..`||r.startsWith(`..${sep}`)||r.startsWith(sep))}function normalizePathRoot(e){return toPortablePath(e).toLowerCase()}function toPortablePath(e){return e.split(sep).join(`/`)}export{materializeAuthoredExternalDependencies};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface MaterializedAuthoredModuleIndex {
|
|
2
|
+
readonly fingerprint: string;
|
|
3
|
+
readonly instrumentation?: string;
|
|
4
|
+
readonly nodes: Readonly<Record<string, {
|
|
5
|
+
readonly modules: Readonly<Record<string, string>>;
|
|
6
|
+
}>>;
|
|
7
|
+
readonly version: 1;
|
|
8
|
+
}
|
|
9
|
+
export declare function materializeAuthoredModules(input: {
|
|
10
|
+
readonly appRoot: string;
|
|
11
|
+
readonly runtimeAppRoot: string;
|
|
12
|
+
readonly snapshotSourceRoot: string;
|
|
13
|
+
readonly sourceRoot: string;
|
|
14
|
+
}): Promise<MaterializedAuthoredModuleIndex>;
|
|
15
|
+
export declare function readMaterializedAuthoredModuleIndex(runtimeAppRoot: string): Promise<MaterializedAuthoredModuleIndex | undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync}from"node:fs";import{join,relative,sep}from"node:path";import{lstat,mkdir,readFile,readdir,readlink,writeFile}from"node:fs/promises";import{createHash}from"node:crypto";import{collectModuleRefsForManifest}from"#compiler/module-map.js";import{COMPILED_AGENT_MANIFEST_KIND,ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{bundleAuthoredModuleForGeneration}from"#internal/authored-module-loader.js";import{materializeAuthoredExternalDependencies}from"#internal/materialize-authored-external-dependencies.js";const MATERIALIZED_MODULES_DIRECTORY=`authored-modules`,MATERIALIZED_MODULES_INDEX=`authored-modules.json`,INSTRUMENTATION_EXTENSIONS=[`.ts`,`.mts`,`.js`,`.mjs`];async function materializeAuthoredModules(e){let n=join(e.runtimeAppRoot,`.eve`,`compile`),r=await readCompiledManifest(join(n,`compiled-agent-manifest.json`)),i=join(n,MATERIALIZED_MODULES_DIRECTORY),o=createExtensionScopeIndex(r),s={},c=[],u=createHash(`sha256`);await mkdir(i,{recursive:!0});for(let e of collectNodeManifests(r)){let n={};for(let r of collectModuleRefsForManifest(e.manifest).sort((e,t)=>e.sourceId.localeCompare(t.sourceId))){let a=await bundleAuthoredModuleForGeneration(join(e.agentRoot,r.logicalPath),{externalDependencies:e.manifest.config.build?.externalDependencies??[],extensionScopeNamespace:extensionNamespaceForSourceId(r.sourceId,o)}),s=createMaterializedModuleFileName(e.nodeId,r.sourceId,a.code);await writeFile(join(i,s),a.code),c.push(...a.externalModules),u.update(`module\0`).update(e.nodeId).update(`\0`).update(r.sourceId).update(`\0`).update(a.code).update(`\0`),n[r.sourceId]=join(MATERIALIZED_MODULES_DIRECTORY,s)}s[e.nodeId]={modules:n}}let d=resolveInstrumentationModule(r.agentRoot),f;if(d!==void 0){let e=await bundleAuthoredModuleForGeneration(d,{externalDependencies:r.config.build?.externalDependencies??[]}),n=createMaterializedModuleFileName(ROOT_COMPILED_AGENT_NODE_ID,`instrumentation`,e.code);await writeFile(join(i,n),e.code),c.push(...e.externalModules),f=join(MATERIALIZED_MODULES_DIRECTORY,n),u.update(`instrumentation\0`).update(e.code).update(`\0`)}await hashDirectoryIfPresent({fingerprint:u,path:join(n,`workspace-resources`),root:join(n,`workspace-resources`)}),u.update(`external-dependencies\0`).update(await materializeAuthoredExternalDependencies({appRoot:e.appRoot,externalModules:c,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot})).update(`\0`);let p={fingerprint:u.digest(`hex`),nodes:s,version:1};return f!==void 0&&(p.instrumentation=f),await writeFile(join(n,MATERIALIZED_MODULES_INDEX),`${JSON.stringify(p)}\n`),p}async function readMaterializedAuthoredModuleIndex(n){let r=join(n,`.eve`,`compile`,MATERIALIZED_MODULES_INDEX);if(!existsSync(r))return;let i=JSON.parse(await readFile(r,`utf8`));if(i.version!==1||typeof i.fingerprint!=`string`||i.fingerprint.length===0||typeof i.nodes!=`object`||i.nodes===null||i.instrumentation!==void 0&&typeof i.instrumentation!=`string`)throw Error(`Invalid materialized authored module index at "${r}".`);return i}function collectNodeManifests(e){return[{agentRoot:e.agentRoot,manifest:e,nodeId:ROOT_COMPILED_AGENT_NODE_ID},...[...e.subagents].sort((e,t)=>e.nodeId.localeCompare(t.nodeId)).map(e=>({agentRoot:e.agent.agentRoot,manifest:e.agent,nodeId:e.nodeId}))]}function createExtensionScopeIndex(e){return{byMountNamespace:new Map(e.extensionMounts.map(e=>[e.namespace,e.packageNamespace]))}}function extensionNamespaceForSourceId(e,t){let n=e.match(/^ext:([^:]+):/u);return n===null?void 0:t.byMountNamespace.get(n[1])}async function readCompiledManifest(e){let t=JSON.parse(await readFile(e,`utf8`));if(t.kind!==COMPILED_AGENT_MANIFEST_KIND)throw Error(`Invalid compiled agent manifest at "${e}".`);return t}function resolveInstrumentationModule(n){for(let r of INSTRUMENTATION_EXTENSIONS){let i=join(n,`instrumentation${r}`);if(existsSync(i))return i}}function createMaterializedModuleFileName(e,t,n){return`${createHash(`sha256`).update(e).update(`\0`).update(t).update(`\0`).update(n).digest(`hex`)}.mjs`}async function hashDirectoryIfPresent(r){if(!existsSync(r.path))return;let a=await lstat(r.path),l=toPortablePath(relative(r.root,r.path));if(a.isSymbolicLink()){r.fingerprint.update(l).update(`\0link\0`).update(await readlink(r.path)).update(`\0`);return}if(a.isDirectory()){for(let e of(await readdir(r.path)).sort())await hashDirectoryIfPresent({...r,path:join(r.path,e)});return}a.isFile()&&r.fingerprint.update(l).update(`\0file\0`).update(await readFile(r.path)).update(`\0`)}function toPortablePath(e){return e.split(sep).join(`/`)}export{materializeAuthoredModules,readMaterializedAuthoredModuleIndex};
|
|
@@ -6,16 +6,13 @@ export interface DevelopmentRuntimeArtifactsSnapshot {
|
|
|
6
6
|
readonly runtimeAppRoot: string;
|
|
7
7
|
readonly snapshotRoot: string;
|
|
8
8
|
readonly snapshotSourceRoot: string;
|
|
9
|
+
readonly sourceRoot: string;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Resolves the dev-server pointer that records the latest runtime artifact
|
|
12
13
|
* snapshot for new sessions.
|
|
13
14
|
*/
|
|
14
15
|
export declare function resolveDevelopmentRuntimeArtifactsPointerPath(appRoot: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Publishes one immutable dev runtime snapshot and points future sessions at it.
|
|
17
|
-
*/
|
|
18
|
-
export declare function publishDevelopmentRuntimeArtifactsSnapshot(compileResult: CompileAgentResult): Promise<DevelopmentRuntimeArtifactsSnapshot>;
|
|
19
16
|
/**
|
|
20
17
|
* Stages one immutable dev runtime snapshot without moving the latest pointer.
|
|
21
18
|
*/
|
|
@@ -35,11 +32,6 @@ export declare function readDevelopmentRuntimeArtifactsSnapshotRoot(pointerPath:
|
|
|
35
32
|
* Reads a revision token for the latest dev runtime artifact snapshot.
|
|
36
33
|
*/
|
|
37
34
|
export declare function readDevelopmentRuntimeArtifactsRevision(appRoot: string): DevelopmentRuntimeArtifactsRevision;
|
|
38
|
-
/**
|
|
39
|
-
* Starts best-effort cleanup for stale dev-runtime snapshots without delaying
|
|
40
|
-
* `eve dev` startup or rebuild handling.
|
|
41
|
-
*/
|
|
42
|
-
export declare function pruneDevelopmentRuntimeArtifactsSnapshotsInBackground(appRoot: string): void;
|
|
43
35
|
export declare function pruneDevelopmentRuntimeArtifactsSnapshots(input: {
|
|
44
36
|
readonly appRoot: string;
|
|
45
37
|
readonly now?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync,readFileSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{cp,mkdir,readFile,readdir,rename,rm,stat,writeFile}from"node:fs/promises";import{randomUUID}from"node:crypto";import{copyDevelopmentSourceSnapshot}from"#internal/nitro/dev-runtime-source-snapshot-copy.js";import{createDevelopmentSourceSnapshotPlan}from"#internal/nitro/dev-runtime-source-snapshot.js";const DEV_RUNTIME_ARTIFACTS_DIRECTORY=`dev-runtime`,TERMINAL_WORKFLOW_RUN_STATUSES=new Set([`completed`,`failed`,`cancelled`,`canceled`]);function resolveDevelopmentRuntimeArtifactsPointerPath(e){return join(e,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`current.json`)}function resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e){return join(e,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`snapshots`)}async function
|
|
1
|
+
import{existsSync,readFileSync}from"node:fs";import{dirname,join,relative,resolve,sep}from"node:path";import{cp,mkdir,readFile,readdir,rename,rm,stat,writeFile}from"node:fs/promises";import{randomUUID}from"node:crypto";import{copyDevelopmentSourceSnapshot}from"#internal/nitro/dev-runtime-source-snapshot-copy.js";import{createDevelopmentSourceSnapshotPlan}from"#internal/nitro/dev-runtime-source-snapshot.js";const DEV_RUNTIME_ARTIFACTS_DIRECTORY=`dev-runtime`,DEV_RUNTIME_ARTIFACTS_ACTIVATED_MARKER=`activated`,TERMINAL_WORKFLOW_RUN_STATUSES=new Set([`completed`,`failed`,`cancelled`,`canceled`]);function resolveDevelopmentRuntimeArtifactsPointerPath(e){return join(e,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`current.json`)}function resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e){return join(e,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`snapshots`)}async function stageDevelopmentRuntimeArtifactsSnapshot(e){let t=join(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.project.appRoot),`${Date.now().toString(36)}-${randomUUID()}`),n=await createDevelopmentSourceSnapshotPlan({appRoot:e.project.appRoot,snapshotRoot:t});try{await copyDevelopmentSourceSnapshot(n),await cp(e.paths.compileDirectoryPath,join(n.runtimeAppRoot,`.eve`,`compile`),{recursive:!0}),await rewriteSnapshotCompiledManifest({appRoot:e.project.appRoot,manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:n.runtimeAppRoot}),await validateSnapshotCompiledManifestRoots({manifestPath:join(n.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:n.runtimeAppRoot})}catch(e){throw await rm(t,{force:!0,recursive:!0}).catch(()=>{}),e}return{runtimeAppRoot:n.runtimeAppRoot,snapshotRoot:t,snapshotSourceRoot:n.snapshotSourceRoot,sourceRoot:n.sourceRoot}}async function activateDevelopmentRuntimeArtifactsSnapshot(e){await writeFile(join(e.snapshot.snapshotRoot,DEV_RUNTIME_ARTIFACTS_ACTIVATED_MARKER),``),await writeDevelopmentRuntimeArtifactsPointer(e)}function readDevelopmentRuntimeArtifactsSnapshotRoot(e){let t=readDevelopmentRuntimeArtifactsPointer(e);if(t!==void 0)return t.version===1?t.appRoot:t.runtimeAppRoot}function readDevelopmentRuntimeArtifactsRevision(e){return{revision:readDevelopmentRuntimeArtifactsSnapshotRoot(resolveDevelopmentRuntimeArtifactsPointerPath(e))??e}}async function pruneDevelopmentRuntimeArtifactsSnapshots(t){let n=resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(t.appRoot),i=[...collectProtectedSnapshotPaths(readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(t.appRoot))),...await collectWorkflowDataSnapshotPaths({appRoot:t.appRoot,snapshotsDirectory:n})],a=t.now??Date.now(),o=t.recentWindowMs??9e5,s=t.retainCount??5,c;try{c=await readdir(n,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let l=(await Promise.all(c.filter(e=>e.isDirectory()).map(async e=>{let t=join(n,e.name);return{path:t,mtimeMs:(await stat(t)).mtimeMs}}))).sort((e,t)=>t.mtimeMs-e.mtimeMs);await Promise.all(l.map(async(t,n)=>{existsSync(join(t.path,DEV_RUNTIME_ARTIFACTS_ACTIVATED_MARKER))||n<s||a-t.mtimeMs<=o||i.some(e=>pathsOverlap(t.path,e))||await rm(t.path,{force:!0,recursive:!0})}))}function readDevelopmentRuntimeArtifactsPointer(n){if(!(n===void 0||!existsSync(n)))try{let e=JSON.parse(readFileSync(n,`utf8`));return e.kind!==`eve-dev-runtime-artifacts-pointer`||typeof e.version!=`number`?void 0:e.version===1&&typeof e.appRoot==`string`&&e.appRoot.length>0?{appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,version:1}:e.version===2&&typeof e.appRoot==`string`&&typeof e.runtimeAppRoot==`string`&&e.runtimeAppRoot.length>0&&typeof e.snapshotRoot==`string`&&e.snapshotRoot.length>0?{appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:e.runtimeAppRoot,snapshotRoot:e.snapshotRoot,version:2}:void 0}catch{return}}function collectProtectedSnapshotPaths(e){return e===void 0?[]:e.version===1?[e.appRoot]:[e.runtimeAppRoot,e.snapshotRoot]}async function collectWorkflowDataSnapshotPaths(e){let t=join(e.appRoot,`.workflow-data`),n=new Set;return await collectSnapshotPathsFromDirectory({directory:t,snapshotPaths:n,snapshotsDirectory:e.snapshotsDirectory}),[...n]}async function collectSnapshotPathsFromDirectory(e){let t;try{t=await readdir(e.directory,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}await Promise.all(t.map(async t=>{let n=join(e.directory,t.name);if(t.isDirectory()){await collectSnapshotPathsFromDirectory({directory:n,snapshotPaths:e.snapshotPaths,snapshotsDirectory:e.snapshotsDirectory});return}if(!t.isFile()||(await stat(n)).size>1048576)return;let i=await readFile(n,`utf8`);if(shouldScanWorkflowDataSource(i))for(let t of collectSnapshotPathsFromText(i,e.snapshotsDirectory))e.snapshotPaths.add(t)}))}function collectSnapshotPathsFromText(e,t){let n=new Set,i=t.replaceAll(`\\`,`/`),a=RegExp(`${escapeRegExp(i)}/([^/"'\\s]+)`,`gu`),o=e.replaceAll(`\\\\`,`/`).replaceAll(`\\`,`/`);for(let e of o.matchAll(a)){let i=e[1];i!==void 0&&i.length>0&&n.add(join(t,i))}return[...n]}function shouldScanWorkflowDataSource(e){let t=parseJsonObject(e);if(t===void 0)return!0;let n=t.status;return typeof n!=`string`||!TERMINAL_WORKFLOW_RUN_STATUSES.has(n)}function parseJsonObject(e){try{let t=JSON.parse(e);return isObjectRecord(t)?t:void 0}catch{return}}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/gu,`\\$&`)}function pathsOverlap(e,t){return isPathInsideOrEqual(e,t)||isPathInsideOrEqual(t,e)}async function rewriteSnapshotCompiledManifest(e){let t=JSON.parse(await readFile(e.manifestPath,`utf8`)),n=rewriteManifestRoots({appRoot:e.appRoot,runtimeAppRoot:e.runtimeAppRoot,value:t});await writeFile(e.manifestPath,`${JSON.stringify(n,null,2)}\n`)}function rewriteManifestRoots(e){if(Array.isArray(e.value))return e.value.map(t=>rewriteManifestRoots({...e,value:t}));if(e.value===null||typeof e.value!=`object`)return e.value;let t={};for(let[n,r]of Object.entries(e.value)){if(typeof r==`string`&&(n===`appRoot`||n===`agentRoot`)){t[n]=rewritePathWithinAppRoot({appRoot:e.appRoot,path:r,runtimeAppRoot:e.runtimeAppRoot});continue}t[n]=rewriteManifestRoots({appRoot:e.appRoot,runtimeAppRoot:e.runtimeAppRoot,value:r})}return t}function rewritePathWithinAppRoot(e){if(!isPathInsideOrEqual(e.path,e.appRoot))return e.path;let t=relative(e.appRoot,e.path);return t.length===0?e.runtimeAppRoot:join(e.runtimeAppRoot,t)}async function writeDevelopmentRuntimeArtifactsPointer(e){let t=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),r=`${t}.${randomUUID()}.tmp`,i={appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:e.snapshot.runtimeAppRoot,snapshotRoot:e.snapshot.snapshotRoot,version:2};await mkdir(dirname(t),{recursive:!0}),await writeFile(r,`${JSON.stringify(i,null,2)}\n`);try{await rename(r,t)}catch(e){throw await rm(r,{force:!0}).catch(()=>{}),e}}async function validateSnapshotCompiledManifestRoots(e){let t=collectManifestRootPaths(JSON.parse(await readFile(e.manifestPath,`utf8`)));for(let n of t)if(!isPathInsideOrEqual(n,e.runtimeAppRoot))throw Error(`Development runtime snapshot manifest root "${n}" is outside runtime app root "${e.runtimeAppRoot}".`)}function collectManifestRootPaths(e){if(Array.isArray(e))return e.flatMap(e=>collectManifestRootPaths(e));if(typeof e!=`object`||!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if((n===`appRoot`||n===`agentRoot`)&&typeof r==`string`){t.push(r);continue}t.push(...collectManifestRootPaths(r))}return t}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{activateDevelopmentRuntimeArtifactsSnapshot,pruneDevelopmentRuntimeArtifactsSnapshots,readDevelopmentRuntimeArtifactsRevision,readDevelopmentRuntimeArtifactsSnapshotRoot,resolveDevelopmentRuntimeArtifactsPointerPath,stageDevelopmentRuntimeArtifactsSnapshot};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CompileAgentResult } from "#compiler/compile-agent.js";
|
|
2
|
+
import { type DevelopmentRuntimeArtifactsSnapshot } from "#internal/nitro/dev-runtime-artifacts.js";
|
|
3
|
+
export interface DevelopmentGeneration extends DevelopmentRuntimeArtifactsSnapshot {
|
|
4
|
+
readonly fingerprint: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function stageDevelopmentGeneration(compileResult: CompileAgentResult): Promise<DevelopmentGeneration>;
|
|
7
|
+
export declare function publishDevelopmentGeneration(compileResult: CompileAgentResult): Promise<DevelopmentGeneration>;
|
|
8
|
+
export declare function activateDevelopmentGeneration(input: {
|
|
9
|
+
readonly appRoot: string;
|
|
10
|
+
readonly generation: DevelopmentGeneration;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
export declare function discardDevelopmentGeneration(generation: DevelopmentGeneration): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{rm}from"node:fs/promises";import{materializeAuthoredModules}from"#internal/materialized-authored-modules.js";import{activateDevelopmentRuntimeArtifactsSnapshot,stageDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts.js";async function stageDevelopmentGeneration(n){let r=await stageDevelopmentRuntimeArtifactsSnapshot(n);try{let e=await materializeAuthoredModules({appRoot:n.project.appRoot,runtimeAppRoot:r.runtimeAppRoot,snapshotSourceRoot:r.snapshotSourceRoot,sourceRoot:r.sourceRoot});return{...r,fingerprint:e.fingerprint}}catch(t){try{await rm(r.snapshotRoot,{force:!0,recursive:!0})}catch(e){throw AggregateError([t,e],`Failed to materialize and discard development generation "${r.snapshotRoot}".`)}throw t}}async function publishDevelopmentGeneration(e){let t=await stageDevelopmentGeneration(e);return await activateDevelopmentGeneration({appRoot:e.project.appRoot,generation:t}),t}async function activateDevelopmentGeneration(e){await activateDevelopmentRuntimeArtifactsSnapshot({appRoot:e.appRoot,snapshot:e.generation})}async function discardDevelopmentGeneration(t){await rm(t.snapshotRoot,{force:!0,recursive:!0})}export{activateDevelopmentGeneration,discardDevelopmentGeneration,publishDevelopmentGeneration,stageDevelopmentGeneration};
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DevelopmentNitroArtifactsConfig, ProductionNitroArtifactsConfig } from "#internal/nitro/routes/runtime-artifacts.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Runtime-artifacts wiring for the dev server: routes read compiled
|
|
4
|
+
* artifacts from the authored app root via the snapshot pointer so hot
|
|
5
|
+
* reload can swap them.
|
|
5
6
|
*/
|
|
6
|
-
export
|
|
7
|
+
export declare function createDevelopmentNitroArtifactsConfig(input: {
|
|
7
8
|
readonly appRoot: string;
|
|
8
|
-
|
|
9
|
-
}
|
|
9
|
+
}): DevelopmentNitroArtifactsConfig;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Runtime-artifacts wiring for built output: routes require the artifacts
|
|
12
|
+
* bundled into the server at build time and never touch the filesystem.
|
|
12
13
|
*/
|
|
13
|
-
export declare function
|
|
14
|
-
readonly appRoot: string;
|
|
15
|
-
readonly dev: boolean;
|
|
16
|
-
}): NitroArtifactsConfigInput;
|
|
14
|
+
export declare function createProductionNitroArtifactsConfig(): ProductionNitroArtifactsConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{resolveDevelopmentRuntimeArtifactsPointerPath}from"#internal/nitro/dev-runtime-artifacts.js";function
|
|
1
|
+
import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{resolveDevelopmentRuntimeArtifactsPointerPath}from"#internal/nitro/dev-runtime-artifacts.js";function createDevelopmentNitroArtifactsConfig(e){return{appRoot:e.appRoot,devRuntimeArtifactsPointerPath:resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),kind:`development`,moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`)}}function createProductionNitroArtifactsConfig(){return{kind:`production`}}export{createDevelopmentNitroArtifactsConfig,createProductionNitroArtifactsConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolvePackageRoot}from"#internal/application/package.js";import{dirname,join,resolve}from"node:path";import{tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{readFile}from"node:fs/promises";import{
|
|
1
|
+
import{resolvePackageRoot,resolvePackageSourceFilePath}from"#internal/application/package.js";import{dirname,join,resolve}from"node:path";import{tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{readFile}from"node:fs/promises";import{resolveDiscoveryProject}from"#discover/project.js";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{build,copyPublicAssets,prepare,prerender}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createApplicationBuildWorkspace,removeApplicationBuildWorkspace}from"#internal/application/build-workspace.js";import{RecoverablePublicationError,publishApplicationBuildArtifacts}from"#internal/application/output-publication.js";import{stageProductionCompilerArtifacts}from"#internal/application/production-compiler-artifacts.js";import{WorkflowBundleBuilder}from"#internal/workflow-bundle/builder.js";import{normalizeEveVercelFunctionOutput}from"#internal/workflow-bundle/vercel-workflow-output.js";import{createProductionApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{emitVercelAgentSummary}from"#internal/nitro/host/build-vercel-agent-summary.js";import{copyHostMiddlewareFunctions}from"#internal/nitro/host/copy-host-middleware.js";import{prepareProductionApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{runVercelBuildPrewarm}from"#internal/nitro/host/vercel-build-prewarm.js";import{findClosestVercelOutputDirectory}from"#shared/vercel-output-directory.js";function trimTrailingSlash(e){return e.replace(/[\\/]+$/,``)}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function normalizeEntrypoint(e,t){return typeof t!=`string`||t.trim().length===0?null:resolve(e,t)}function normalizeServiceRoot(e,t){return typeof t.root==`string`&&t.root.trim().length>0?resolve(e,t.root):normalizeEntrypoint(e,t.entrypoint)}function normalizeServicePrefix(e){return typeof e.routePrefix==`string`?e.routePrefix.trim():typeof e.mount==`string`?e.mount.trim():isRecord(e.mount)&&typeof e.mount.path==`string`&&e.mount.path.trim().length>0?e.mount.path.trim():``}function normalizeServiceCollection(e){if(isRecord(e))return Object.values(e).filter(isRecord);if(Array.isArray(e))return e.filter(isRecord)}function resolveCoDeployedEveServicePrefix(e){if(!isRecord(e.config))return;let t=normalizeServiceCollection(e.config.experimentalServices)??normalizeServiceCollection(e.config.experimentalServicesV2)??normalizeServiceCollection(e.config.services);if(t===void 0)return;let n=!1,r;for(let i of t){if(i.framework!==`eve`){n=!0;continue}let t=normalizeServiceRoot(e.configRoot,i),a=normalizeServicePrefix(i);t!==null&&e.appRoots.includes(t)&&a.length>0&&a!==`/`&&(r=a)}return n?r:void 0}async function resolveCoDeployedEveServicePrefixForVercelFunctionOutput(e,t){let a=Array.from(new Set([resolve(e),resolve(t)])),s=await findClosestVercelOutputDirectory(e);if(s!==void 0)try{let e=JSON.parse(await readFile(join(s,`config.json`),`utf8`)),t=resolveCoDeployedEveServicePrefix({appRoots:a,configRoot:await resolveVercelOutputConfigRoot(s),config:e});if(t!==void 0)return t}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let c=e;for(;;){for(let e of[join(c,`vercel.json`),join(c,`.vercel`,`output`,`config.json`)])try{let t=JSON.parse(await readFile(e,`utf8`)),r=resolveCoDeployedEveServicePrefix({appRoots:a,configRoot:e.endsWith(`vercel.json`)?c:await resolveVercelOutputConfigRoot(dirname(e)),config:t});if(r!==void 0)return r}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let e=dirname(c);if(e===c)return;c=e}}async function readVercelServerRuntime(e){try{return JSON.parse(await readFile(join(e,`functions`,`__server.func`,`.vc-config.json`),`utf8`)).runtime}catch{return}}async function resolveVercelOutputConfigRoot(e){let t=dirname(dirname(e));try{let e=JSON.parse(await readFile(join(t,`.vercel`,`project.json`),`utf8`));if(isRecord(e)&&isRecord(e.settings)&&typeof e.settings.rootDirectory==`string`&&e.settings.rootDirectory.trim().length>0)return resolve(t,e.settings.rootDirectory)}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}return t}async function emitVercelWorkflowFunctions(t){let n=new WorkflowBundleBuilder({agentName:t.agentName,appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifactsBootstrapPath,outDir:t.workflowBuildDir,rootDir:resolvePackageRoot(),watch:!1}),r=await readVercelServerRuntime(t.outputDir);await n.buildVercelOutput({flowNitroOutputDir:t.flowNitroOutputDir,outputDir:t.outputDir,runtime:r})}async function buildNitroOutput(e){let t=trimTrailingSlash(e.options.output.dir);return await prepareEveVersionedCacheDirectory(t),await prepare(e),await copyPublicAssets(e),await prerender(e),await build(e),await writeEveVersionedCacheMetadata(t),t}async function buildVercelNitroSurface(e,t,n){let i=await createProductionApplicationNitro(e,{buildDir:join(t.nitro.buildDir,n),outputDir:join(t.nitro.surfaceOutputDir,n),surface:n});try{return await buildNitroOutput(i)}finally{await i.close()}}async function buildApplication(e,t){let n=await tryReadExtensionBuildConfig(e);if(n!==null)throw Error(`Package "${n.packageName}" is an eve extension. Run \`eve extension build\` instead of \`eve build\`.`);let r=await createApplicationBuildWorkspace((await resolveDiscoveryProject(e)).appRoot,t.vercelServiceOutput?.serviceOutputDirectory),i=!1;try{return await buildApplicationInWorkspace(r,t)}catch(e){throw i=e instanceof RecoverablePublicationError,e}finally{i||await removeApplicationBuildWorkspace(r)}}async function buildApplicationInWorkspace(e,n){let i=await prepareProductionApplicationHost(e);if(!process.env.VERCEL){let t=await createProductionApplicationNitro(i,{buildDir:e.nitro.buildDir,outputDir:e.publication.output.stagedDir,surface:`all`});try{await buildNitroOutput(t),await emitVercelAgentSummary({manifest:i.compileResult.manifest,outputPath:e.publication.summary.stagedPath}),await stageProductionCompilerArtifacts({compilerArtifactsRoot:e.compiler.artifactsDir,outputDir:e.publication.output.stagedDir})}finally{await t.close()}return await publishCompletedApplicationBuild(e),e.publication.output.finalDir}let a=await resolveCoDeployedEveServicePrefixForVercelFunctionOutput(i.appRoot,i.compileResult.project.agentRoot),o=await createProductionApplicationNitro(i,{buildDir:join(e.nitro.buildDir,`app`),outputDir:e.publication.output.stagedDir,surface:`app`});try{await buildNitroOutput(o),n.skipVercelSandboxPrewarm||await runVercelBuildPrewarm({appRoot:i.appRoot,compiledArtifactsSource:createDiskRuntimeCompiledArtifactsSource(e.compiler.rootDir,{moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:i.appRoot}),log(e){console.log(e)}});let r=await buildVercelNitroSurface(i,e,`flow`);await emitVercelWorkflowFunctions({agentName:i.compileResult.manifest.config.name,appRoot:i.appRoot,compiledArtifactsBootstrapPath:i.compiledArtifacts.bootstrapPath,flowNitroOutputDir:r,outputDir:e.publication.output.stagedDir,workflowBuildDir:e.workflow.buildDir}),a!==void 0&&await normalizeEveVercelFunctionOutput(e.publication.output.stagedDir,{servicePrefix:a}),n.vercelServiceOutput!==void 0&&await copyHostMiddlewareFunctions({hostOutputDirectory:n.vercelServiceOutput.hostOutputDirectory,serviceOutputDirectory:e.publication.output.stagedDir}),await emitVercelAgentSummary({manifest:i.compileResult.manifest,outputPath:e.publication.summary.stagedPath})}finally{await o.close()}return await publishCompletedApplicationBuild(e),e.publication.output.finalDir}async function publishCompletedApplicationBuild(e){await publishApplicationBuildArtifacts({appRoot:e.appRoot,finalOutputDir:e.publication.output.finalDir,finalSummaryPath:e.publication.summary.finalPath,scratchDir:e.rootDir,stagedOutputDir:e.publication.output.stagedDir,stagedSummaryPath:e.publication.summary.stagedPath})}export{buildApplication};
|
|
@@ -14,12 +14,6 @@ export declare function buildVercelAgentSummary(input: {
|
|
|
14
14
|
* Writes the agent summary file. Returns the absolute path of the
|
|
15
15
|
* written file.
|
|
16
16
|
*
|
|
17
|
-
* The file is written to {@link VERCEL_EVE_AGENT_SUMMARY_OUTPUT_PATH}
|
|
18
|
-
* relative to {@link input.appRoot} — i.e.
|
|
19
|
-
* `<appRoot>/.eve/agent-summary.json`. Lives outside `.vercel/output/`
|
|
20
|
-
* by design, so it is not part of the Build Output API surface and is
|
|
21
|
-
* never served on the deployment URL.
|
|
22
|
-
*
|
|
23
17
|
* On Vercel deployments, the build container's
|
|
24
18
|
* `upload-eve-agent-summary.ts` helper picks up this file from
|
|
25
19
|
* `rootPath` (which equals `appRoot` for the project being built) and
|
|
@@ -35,6 +29,6 @@ export declare function buildVercelAgentSummary(input: {
|
|
|
35
29
|
*/
|
|
36
30
|
export declare function emitVercelAgentSummary(input: {
|
|
37
31
|
manifest: CompiledAgentManifest;
|
|
38
|
-
appRoot: string;
|
|
39
32
|
generatorVersion?: string;
|
|
33
|
+
outputPath: string;
|
|
40
34
|
}): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{dirname
|
|
1
|
+
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{dirname}from"node:path";import{mkdir,writeFile}from"node:fs/promises";import{VERCEL_EVE_AGENT_SUMMARY_KIND,VERCEL_EVE_AGENT_SUMMARY_VERSION,normalizeChannelKindForDisplay}from"#internal/vercel-agent-summary.js";function buildVercelAgentSummary(t){let{manifest:n}=t;return{kind:VERCEL_EVE_AGENT_SUMMARY_KIND,schemaVersion:VERCEL_EVE_AGENT_SUMMARY_VERSION,generatorVersion:t.generatorVersion??resolveInstalledPackageInfo().version,agent:{name:n.config.name,description:n.config.description,modelId:n.config.model.id},instructions:n.instructions?toInstructionsEntry(n.instructions):null,schedules:n.schedules.map(toScheduleEntry),tools:n.tools.map(toToolEntry),skills:n.skills.map(toSkillEntry),connections:n.connections.map(toConnectionEntry),channels:n.channels.filter(isActiveChannel).map(toChannelEntry),sandbox:n.sandbox===null?null:{logicalPath:n.sandbox.logicalPath},subagents:n.subagents.map(toSubagentEntry),diagnostics:{errors:n.diagnosticsSummary.errors,warnings:n.diagnosticsSummary.warnings}}}async function emitVercelAgentSummary(e){let r=buildVercelAgentSummary({generatorVersion:e.generatorVersion,manifest:e.manifest});return await mkdir(dirname(e.outputPath),{recursive:!0}),await writeFile(e.outputPath,`${JSON.stringify(r,null,2)}\n`),e.outputPath}function isActiveChannel(e){return e.kind===`channel`}function toInstructionsEntry(e){return{logicalPath:e.logicalPath,sourceKind:e.sourceKind,markdown:e.markdown}}function toScheduleEntry(e){return{name:e.name,cron:e.cron,logicalPath:e.logicalPath}}function toToolEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}function toSkillEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath,sourceKind:e.sourceKind}}function toConnectionEntry(e){let t={name:e.connectionName,description:e.description,url:e.url,logicalPath:e.logicalPath,type:e.protocol};return e.vercelConnect===void 0?t:{...t,vercelConnect:{connector:e.vercelConnect.connector}}}function toChannelEntry(e){let t={name:e.name,method:e.method,urlPath:e.urlPath,type:normalizeChannelKindForDisplay(e.adapterKind),logicalPath:e.logicalPath};return e.adapterKind===void 0?t:{...t,adapterKind:e.adapterKind}}function toSubagentEntry(e){return{name:e.name,description:e.description,logicalPath:e.logicalPath}}export{buildVercelAgentSummary,emitVercelAgentSummary};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Nitro } from "nitro/types";
|
|
2
2
|
import type { NormalizedChannelCorsOptions } from "#channel/cors.js";
|
|
3
3
|
import type { ChannelRouteMethod } from "#public/definitions/channel.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { NitroArtifactsConfig } from "#internal/nitro/routes/runtime-artifacts.js";
|
|
5
5
|
import type { PreparedApplicationHost } from "#internal/nitro/host/types.js";
|
|
6
6
|
interface ChannelRouteNitro {
|
|
7
7
|
options: Pick<Nitro["options"], "handlers" | "virtual">;
|
|
@@ -25,7 +25,7 @@ export declare function computeChannelRouteRegistrations(preparedHost: PreparedA
|
|
|
25
25
|
* Registers virtual Nitro handlers for the provided eve channel routes.
|
|
26
26
|
*/
|
|
27
27
|
export declare function registerChannelVirtualHandlers(nitro: Pick<ChannelRouteNitro, "options">, input: {
|
|
28
|
-
readonly artifactsConfig:
|
|
28
|
+
readonly artifactsConfig: NitroArtifactsConfig;
|
|
29
29
|
readonly registrations: readonly NitroChannelRouteRegistration[];
|
|
30
30
|
}): void;
|
|
31
31
|
/**
|
|
@@ -33,7 +33,7 @@ export declare function registerChannelVirtualHandlers(nitro: Pick<ChannelRouteN
|
|
|
33
33
|
* set changes.
|
|
34
34
|
*/
|
|
35
35
|
export declare function syncChannelVirtualHandlers(nitro: ChannelRouteNitro, input: {
|
|
36
|
-
readonly artifactsConfig:
|
|
36
|
+
readonly artifactsConfig: NitroArtifactsConfig;
|
|
37
37
|
readonly next: readonly NitroChannelRouteRegistration[];
|
|
38
38
|
readonly previous: readonly NitroChannelRouteRegistration[];
|
|
39
39
|
}): boolean;
|