eve 0.37.1 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/src/chunks/{use-eve-agent-DbKUBhl-.js → use-eve-agent-BbSsu99c.js} +70 -31
- package/dist/src/chunks/{use-eve-agent-Bi5fRxcZ.js → use-eve-agent-Dt8Y5QtW.js} +69 -30
- package/dist/src/cli/acp/command.d.ts +2 -1
- package/dist/src/cli/acp/command.js +2 -2
- package/dist/src/cli/application-command.d.ts +8 -0
- package/dist/src/cli/application-command.js +1 -0
- package/dist/src/cli/application-root.d.ts +8 -0
- package/dist/src/cli/application-root.js +1 -0
- package/dist/src/cli/commands/build.d.ts +2 -1
- package/dist/src/cli/commands/build.js +1 -1
- package/dist/src/cli/commands/init-repl.js +1 -1
- package/dist/src/cli/commands/register-integration-commands.d.ts +2 -1
- package/dist/src/cli/commands/register-integration-commands.js +1 -1
- package/dist/src/cli/commands/register-project-commands.d.ts +2 -1
- package/dist/src/cli/commands/register-project-commands.js +1 -1
- package/dist/src/cli/commands/register-registry-commands.d.ts +2 -1
- package/dist/src/cli/commands/register-registry-commands.js +4 -1
- package/dist/src/cli/commands/registry-recovery.d.ts +14 -0
- package/dist/src/cli/commands/registry-recovery.js +1 -0
- package/dist/src/cli/commands/registry.d.ts +2 -5
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/dev/diagnostic-dump.js +1 -1
- package/dist/src/cli/dev/environment.js +1 -1
- package/dist/src/cli/invoke/command.d.ts +3 -2
- package/dist/src/cli/invoke/command.js +1 -1
- package/dist/src/cli/run.d.ts +3 -2
- package/dist/src/cli/run.js +3 -3
- package/dist/src/client/eve-agent-store.d.ts +15 -3
- package/dist/src/client/eve-agent-store.js +2 -2
- package/dist/src/client/message-response.d.ts +10 -2
- package/dist/src/client/message-response.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +4 -1
- package/dist/src/compiled/@ai-sdk/otel/index.js +3 -3
- package/dist/src/compiled/@chat-adapter/slack/index.js +25 -25
- package/dist/src/compiled/@opentelemetry/api/index.js +1 -1
- package/dist/src/compiled/@opentelemetry/otlp-transformer/index.js +1 -1
- package/dist/src/compiled/@photon-ai/chat-adapter-imessage/index.js +61 -61
- package/dist/src/compiled/@vercel/oidc/index.js +14 -14
- package/dist/src/compiled/@vercel/otel/index.js +1 -1
- package/dist/src/compiled/@vercel/sandbox/index.js +1 -1
- package/dist/src/compiled/@workflow/core/index.js +1 -1
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +2 -2
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world-local/index.js +5 -5
- package/dist/src/compiled/@workflow/world-vercel/index.js +13 -13
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-BoH7JsWp.js → attribute-changes-DZtQkszH.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/chunk-5MU5Z6L3-B_3nkJFi.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{chunk-NWCAEW5Y-Oxw40oRR.js → chunk-NWCAEW5Y-BgbcH0OK.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-DlFv0aHY.js → dist-CPlyFOVo.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-tJoQXAF6.js → dist-DpYyXbJv.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-CRTn4Sg8.js → dist-xQXN70ED.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/esm-seIr7a6j.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{frames-CTpeJYEQ.js → frames-BBs-9k1d.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/{functions-CeeNvKsq.js → functions-DAYiHNti.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{getMachineId-bsd-WEBNKY2R-CEYkx6Nv.js → getMachineId-bsd-WEBNKY2R-BTaxrQ52.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{getMachineId-darwin-LT47KAXP-DPwWlhif.js → getMachineId-darwin-LT47KAXP-DhYmwE_R.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{getMachineId-linux-LTVQO6VW-DAFXHwZp.js → getMachineId-linux-LTVQO6VW-Dru_L5ru.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{getMachineId-unsupported-UKWBA27G-BZKOI8mG.js → getMachineId-unsupported-UKWBA27G-DGfoqVW1.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{getMachineId-win-NLJKOPY6-r7_CJB5o.js → getMachineId-win-NLJKOPY6-CLM98q4X.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{private-tvMBynnC.js → private-UQtz8ZcW.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{resume-hook-BPQHjeY5.js → resume-hook-CYtSorp6.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{rolldown-runtime-DaDcL9Zw.js → rolldown-runtime-8V8biNmG.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{run-DQ5dOyjm.js → run-Cjo0A3NO.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{signal-exit-C8vsI6zj.js → signal-exit-o3IPQwwv.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/sleep-C1P0OWBm.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{token-DHD-q-fS.js → token-DGzfw-Vb.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{token-DtCUEpJs.js → token-DNbxVpeq.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/token-util-BneBe0g5.js +27 -0
- package/dist/src/compiled/_chunks/workflow/{token-util-Ldar52H7.js → token-util-DjMgNdXS.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{undici-CUIybhQ2.js → undici-BBG5cZTy.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{wait-until-DK2lnH6U.js → wait-until-CT1ve8qB.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/{wrapper-CMGju7QA.js → wrapper-CQNxP9mU.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/{ws-transport-Csi6Cydc.js → ws-transport-beXxD0s_.js} +1 -1
- package/dist/src/compiled/env-runner/node-worker.js +1 -1
- package/dist/src/compiled/jose/index.js +1 -1
- package/dist/src/compiled/shadcn-registry/index.js +403 -403
- package/dist/src/compiler/artifacts.js +1 -1
- package/dist/src/compiler/compile-agent.js +2 -2
- package/dist/src/compiler/extension-compatibility.d.ts +10 -0
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/normalize-extension.d.ts +8 -5
- package/dist/src/compiler/normalize-extension.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/discover/discover-agent.js +1 -1
- package/dist/src/discover/extensions.d.ts +0 -6
- package/dist/src/discover/extensions.js +1 -1
- package/dist/src/evals/cli/eval.d.ts +1 -1
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-templates.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-templates.js +1 -1
- package/dist/src/execution/sandbox/prewarm.js +1 -1
- package/dist/src/harness/instrumentation/providers.js +1 -1
- package/dist/src/harness/instrumentation/runtime-context.d.ts +2 -0
- package/dist/src/harness/instrumentation/runtime-context.js +1 -1
- package/dist/src/harness/instrumentation/runtime.d.ts +3 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/internal/application/cache-metadata.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +2 -2
- package/dist/src/internal/application/optional-package-install.js +1 -1
- package/dist/src/internal/application/output-publication-lock.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/paths.js +1 -1
- package/dist/src/internal/application/tsconfig-dependencies.js +1 -1
- package/dist/src/internal/authored-module-evaluation-error.js +4 -4
- package/dist/src/internal/authored-module-loader.js +3 -3
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/authored-relative-extension-resolver.js +1 -1
- package/dist/src/internal/bundler/extension-scope-plugin.js +1 -1
- package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
- package/dist/src/internal/instrumentation-layout.js +1 -1
- package/dist/src/internal/materialized-authored-modules.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts-retention.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-local-roots.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot.js +1 -1
- package/dist/src/internal/nitro/host/application-route-registry.d.ts +88 -0
- package/dist/src/internal/nitro/host/application-route-registry.js +1 -0
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/build-extension.js +1 -1
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
- package/dist/src/internal/nitro/host/channel-routes.d.ts +4 -11
- package/dist/src/internal/nitro/host/channel-routes.js +3 -3
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +3 -3
- 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/dev-runner.js +1 -1
- package/dist/src/internal/nitro/host/dev-workspace-extensions.js +1 -1
- package/dist/src/internal/nitro/host/extension-capability-requirements.js +1 -1
- package/dist/src/internal/nitro/host/local-tracing-runtime-plugin.js +1 -1
- package/dist/src/internal/nitro/host/nitro-bundler-config.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/host/start-production-server.js +2 -2
- package/dist/src/internal/nitro/host/vercel-build-output-config.js +1 -1
- package/dist/src/internal/process/pnpm.js +1 -1
- package/dist/src/internal/workflow/development-world-client.js +1 -1
- package/dist/src/internal/workflow/development-world-server.js +1 -1
- package/dist/src/internal/workflow-bundle/builder-support.d.ts +12 -8
- package/dist/src/internal/workflow-bundle/builder-support.js +8 -7
- package/dist/src/internal/workflow-bundle/builder.d.ts +1 -1
- package/dist/src/internal/workflow-bundle/builder.js +2 -3
- package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
- package/dist/src/public/channels/discord/discordChannel.d.ts +2 -0
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/eve.d.ts +2 -0
- package/dist/src/public/channels/eve.js +1 -1
- package/dist/src/public/channels/github/dispatch.js +1 -1
- package/dist/src/public/channels/github/githubChannel.d.ts +2 -0
- package/dist/src/public/channels/linear/linearChannel.d.ts +2 -0
- package/dist/src/public/channels/linear/linearChannel.js +1 -1
- package/dist/src/public/channels/photon/photonIMessageChannel.d.ts +2 -0
- package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +3 -1
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.d.ts +2 -0
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/telegramChannel.d.ts +2 -0
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/channels/twilio/twilioChannel.d.ts +2 -0
- package/dist/src/public/channels/twilio/twilioChannel.js +1 -1
- package/dist/src/public/instrumentation/index.d.ts +9 -3
- package/dist/src/public/next/server.js +1 -1
- package/dist/src/public/nuxt/dev-server.js +1 -1
- package/dist/src/public/sveltekit/dev-server.js +1 -1
- package/dist/src/react/use-eve-agent.d.ts +4 -4
- package/dist/src/react/use-eve-agent.js +1 -1
- package/dist/src/services/inspect-application.js +1 -1
- package/dist/src/setup/primitives/pm/pnpm.js +2 -2
- package/dist/src/setup/primitives/run-vercel.js +1 -1
- package/dist/src/setup/scaffold/create/extension.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
- package/dist/src/setup/scaffold/create/web-template.js +8 -86
- package/dist/src/setup/scaffold/version-tokens.js +1 -1
- package/dist/src/setup/scaffold/workspace-root.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.d.ts +3 -3
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tracing/install-instrumentation-runtime.d.ts +2 -1
- package/dist/src/tracing/install-instrumentation-runtime.js +1 -1
- package/dist/src/tracing/otel-declaration.d.ts +32 -3
- package/dist/src/tracing/otel-declaration.js +1 -1
- package/dist/src/tracing/otel-registration.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.d.ts +3 -3
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/channels/custom.mdx +1 -1
- package/docs/channels/discord.mdx +1 -1
- package/docs/channels/eve.mdx +1 -2
- package/docs/channels/github.mdx +1 -1
- package/docs/channels/linear.mdx +1 -1
- package/docs/channels/overview.mdx +1 -1
- package/docs/channels/photon.mdx +1 -1
- package/docs/channels/slack.mdx +1 -1
- package/docs/channels/teams.mdx +1 -1
- package/docs/channels/telegram.mdx +1 -1
- package/docs/channels/twilio.mdx +1 -1
- package/docs/extensions.md +10 -6
- package/docs/guides/client/streaming.mdx +6 -5
- package/docs/guides/frontend/overview.mdx +10 -8
- package/docs/guides/frontend/use-eve-agent-svelte.mdx +10 -10
- package/docs/guides/frontend/use-eve-agent-vue.mdx +10 -10
- package/docs/install-integrations.mdx +4 -0
- package/docs/reference/cli.md +1 -1
- package/docs/schedules.mdx +2 -2
- package/package.json +1 -1
- package/dist/src/compiled/_chunks/workflow/chunk-5MU5Z6L3-CaJgXkVg.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-CzdoBiqy.js +0 -1
- package/dist/src/compiled/_chunks/workflow/src-Cj3P1ChQ.js +0 -1
- package/dist/src/compiled/_chunks/workflow/token-util-DNwIAn_u.js +0 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomUUID}from"node:crypto";import{cp,mkdir,readFile,rm,writeFile}from"node:fs/promises";import{
|
|
1
|
+
import{randomUUID}from"node:crypto";import{cp,mkdir,readFile,rm,writeFile}from"node:fs/promises";import{dirname,join,relative,resolve,sep}from"node:path";import{existsSync,readFileSync}from"node:fs";import{renameWithTransientBusyRetry}from"#shared/rename-with-retry.js";import{copyDevelopmentSourceSnapshot}from"#internal/nitro/dev-runtime-source-snapshot-copy.js";import{createDevelopmentSourceSnapshotPlan,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";import{DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER,pruneDevelopmentRuntimeArtifactsSnapshotDirectory,recordRetiredDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts-retention.js";const DEV_RUNTIME_ARTIFACTS_DIRECTORY=`dev-runtime`;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`)}function isDevelopmentRuntimeArtifactsSnapshotRoot(e,t){return dirname(resolve(t))===resolve(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e))}async function stageDevelopmentRuntimeArtifactsSnapshot(n){let r=join(resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(n.project.appRoot),`${Date.now().toString(36)}-${randomUUID()}`),a=await createDevelopmentSourceSnapshotPlan({appRoot:n.project.appRoot,authoredSourceRoots:collectExtensionMountSourceRoots(n.manifest),snapshotRoot:r});try{await copyDevelopmentSourceSnapshot(a),await cp(n.paths.compileDirectoryPath,join(a.runtimeAppRoot,`.eve`,`compile`),{recursive:!0}),await rewriteSnapshotCompiledManifest({appRoot:n.project.appRoot,manifestPath:join(a.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:a.runtimeAppRoot,snapshotSourceRoot:a.snapshotSourceRoot,sourceRoot:a.sourceRoot}),await validateSnapshotCompiledManifestRoots({manifestPath:join(a.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:a.runtimeAppRoot}),await writeFile(join(r,`generation.json`),`${JSON.stringify({runtimeAppRoot:a.runtimeAppRoot})}\n`)}catch(e){throw await rm(r,{force:!0,recursive:!0}).catch(()=>{}),e}return{runtimeAppRoot:a.runtimeAppRoot,snapshotRoot:r,snapshotSourceRoot:a.snapshotSourceRoot,sourceRoot:a.sourceRoot}}async function activateDevelopmentRuntimeArtifactsSnapshot(e){(await activateDevelopmentRuntimeArtifactsSnapshotTransaction(e)).commit()}async function activateDevelopmentRuntimeArtifactsSnapshotTransaction(e){let t=join(e.snapshot.snapshotRoot,DEVELOPMENT_RUNTIME_ARTIFACTS_ACTIVATED_MARKER),n=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),r=readDevelopmentRuntimeArtifactsPointer(n),i=await readOptionalFile(n);try{await writeFile(t,``),await writeDevelopmentRuntimeArtifactsPointer(e),r?.version===2&&r.snapshotRoot!==e.snapshot.snapshotRoot&&isDevelopmentRuntimeArtifactsSnapshotRoot(e.appRoot,r.snapshotRoot)&&await recordRetiredDevelopmentRuntimeArtifactsSnapshot(r.snapshotRoot).catch(e=>{console.warn(`[eve:dev] failed to record retired runtime generation "${r.snapshotRoot}": ${String(e)}`)})}catch(e){throw await rollbackFailedActivation({cause:e,markerPath:t,pointerPath:n,previousPointerSource:i})}let a=!1;return{commit(){a=!0},async rollback(){if(a)return;a=!0;let e=await restoreDevelopmentRuntimeArtifactsActivation({markerPath:t,pointerPath:n,previousPointerSource:i});if(e!==void 0)throw e}}}function readDevelopmentRuntimeArtifactsSnapshotRoot(e){let t=readDevelopmentRuntimeArtifactsPointer(e);if(t!==void 0)return t.version===1?t.appRoot:t.runtimeAppRoot}function readActiveDevelopmentRuntimeArtifactsSnapshot(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e));if(!(t===void 0||t.version===1))return{runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot}}function readDevelopmentRuntimeArtifactsRevision(e){return{revision:readDevelopmentRuntimeArtifactsSnapshotRoot(resolveDevelopmentRuntimeArtifactsPointerPath(e))??e}}async function pruneDevelopmentRuntimeArtifactsSnapshots(e){let t=readDevelopmentRuntimeArtifactsPointer(resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot));await pruneDevelopmentRuntimeArtifactsSnapshotDirectory({activeSnapshotRoot:t?.version===2?t.snapshotRoot:void 0,gracePeriodMs:e.gracePeriodMs,now:e.now,protectAll:t?.version===1,retainCount:e.retainCount,snapshotsDirectory:resolveDevelopmentRuntimeArtifactsSnapshotsDirectory(e.appRoot)})}function collectExtensionMountSourceRoots(e){return e===void 0?[]:[e,...(e.subagents??[]).map(e=>e.agent)].flatMap(e=>(e.extensionMounts??[]).map(e=>e.sourceRoot))}function readDevelopmentRuntimeArtifactsPointer(e){if(!(e===void 0||!existsSync(e)))try{let t=JSON.parse(readFileSync(e,`utf8`));return t.kind!==`eve-dev-runtime-artifacts-pointer`||typeof t.version!=`number`?void 0:t.version===1&&typeof t.appRoot==`string`&&t.appRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,version:1}:t.version===2&&typeof t.appRoot==`string`&&typeof t.runtimeAppRoot==`string`&&t.runtimeAppRoot.length>0&&typeof t.snapshotRoot==`string`&&t.snapshotRoot.length>0?{appRoot:t.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:t.runtimeAppRoot,snapshotRoot:t.snapshotRoot,version:2}:void 0}catch{return}}async function rewriteSnapshotCompiledManifest(e){let t=JSON.parse(await readFile(e.manifestPath,`utf8`)),n=rewriteManifestRoots({appRoot:e.appRoot,runtimeAppRoot:e.runtimeAppRoot,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,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}if(typeof r==`string`&&n===`sourceRoot`){t[n]=rewritePathWithinSourceRoot({path:r,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot});continue}t[n]=rewriteManifestRoots({appRoot:e.appRoot,runtimeAppRoot:e.runtimeAppRoot,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:r})}return t}function rewritePathWithinSourceRoot(e){return isPathInsideOrEqual(e.path,e.sourceRoot)?toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:e.path,sourceRoot:e.sourceRoot}):e.path}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),n={appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:e.snapshot.runtimeAppRoot,snapshotRoot:e.snapshot.snapshotRoot,version:2};await writeDevelopmentRuntimeArtifactsPointerSource(t,`${JSON.stringify(n,null,2)}\n`)}async function writeDevelopmentRuntimeArtifactsPointerSource(t,r){let o=`${t}.${randomUUID()}.tmp`;await mkdir(dirname(t),{recursive:!0}),await writeFile(o,r);try{await renameWithTransientBusyRetry(o,t)}catch(e){throw await rm(o,{force:!0}).catch(()=>{}),e}}async function readOptionalFile(e){try{return await readFile(e,`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}}async function rollbackFailedActivation(e){let t=await restoreDevelopmentRuntimeArtifactsActivation(e);return t===void 0?e.cause:AggregateError([e.cause,t],`Development runtime activation and rollback failed.`,{cause:e.cause})}async function restoreDevelopmentRuntimeArtifactsActivation(e){let t=(await Promise.allSettled([e.previousPointerSource===void 0?rm(e.pointerPath,{force:!0}):writeDevelopmentRuntimeArtifactsPointerSource(e.pointerPath,e.previousPointerSource),rm(e.markerPath,{force:!0})])).flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(t.length!==0)return AggregateError(t,`Failed to restore development runtime activation.`)}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,activateDevelopmentRuntimeArtifactsSnapshotTransaction,pruneDevelopmentRuntimeArtifactsSnapshots,readActiveDevelopmentRuntimeArtifactsSnapshot,readDevelopmentRuntimeArtifactsRevision,readDevelopmentRuntimeArtifactsSnapshotRoot,resolveDevelopmentRuntimeArtifactsPointerPath,stageDevelopmentRuntimeArtifactsSnapshot};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cp,lstat,mkdir,readFile,readdir,symlink,writeFile}from"node:fs/promises";import{
|
|
1
|
+
import{cp,lstat,mkdir,readFile,readdir,symlink,writeFile}from"node:fs/promises";import{dirname,join,relative,resolve,sep}from"node:path";import{constants,existsSync}from"node:fs";import{DevelopmentRuntimeSourceSnapshotError,toDevelopmentSourceSnapshotPath}from"#internal/nitro/dev-runtime-source-snapshot.js";import{extractTsConfigExtendsSpecifiers,isTsConfigFilePath,parseTsConfigObject,readTextFileIfExists,resolveFirstExistingTsConfigExtendsTarget,resolveTsConfigExtendsTargetPaths}from"#internal/application/tsconfig-dependencies.js";const SNAPSHOT_SKIP_NAMES=new Set([`.devtools`,`.generated`,`.eve`,`.git`,`.next`,`.output`,`.turbo`,`.vercel`,`.workflow-data`,`.workflow-vitest`,`node_modules`]),SNAPSHOT_APP_ROOT_SKIP_NAMES=new Set([`build`,`dist`]),SNAPSHOT_COPY_MODE=constants.COPYFILE_FICLONE;async function copyDevelopmentSourceSnapshot(e){await mkdir(e.snapshotSourceRoot,{recursive:!0});for(let t of e.copyRoots)await copySnapshotPath({plan:e,sourcePath:t,targetPath:toSnapshotPathForPlan(e,t)});for(let t of e.copyFiles)existsSync(t)&&await copySnapshotPath({plan:e,sourcePath:t,targetPath:toSnapshotPathForPlan(e,t)});await rewriteSnapshotTsConfigAbsoluteExtends(e),await createSnapshotDependencyMounts(e),await ensureRuntimePackageJson(e),await validateDevelopmentSourceSnapshot(e)}async function copySnapshotPath(r){try{if((await lstat(r.sourcePath)).isDirectory()){await copySnapshotDirectory(r);return}await mkdir(dirname(r.targetPath),{recursive:!0}),await cp(r.sourcePath,r.targetPath,{mode:SNAPSHOT_COPY_MODE,recursive:!0})}catch(e){throw new DevelopmentRuntimeSourceSnapshotError(`Failed to copy development runtime source snapshot path "${r.sourcePath}" to "${r.targetPath}": ${formatErrorMessage(e)}`)}}async function copySnapshotDirectory(t){await mkdir(t.targetPath,{recursive:!0});for(let n of await readdir(t.sourcePath,{withFileTypes:!0})){let r=join(t.sourcePath,n.name);shouldSkipSnapshotSource(t.plan,r)||await cp(r,join(t.targetPath,n.name),{filter:e=>!shouldSkipSnapshotSource(t.plan,e),mode:SNAPSHOT_COPY_MODE,recursive:!0})}}function shouldSkipSnapshotSource(e,t){let n=relative(e.sourceRoot,t);return n.length===0?!1:n.split(/[\\/]/).some(e=>SNAPSHOT_SKIP_NAMES.has(e)||e.startsWith(`.env`))||existsSync(join(t,`.git`))?!0:isDirectAppRootSkipPath({appRoot:e.appRoot,sourcePath:t})}function isDirectAppRootSkipPath(e){if(!isPathInsideOrEqual(e.sourcePath,e.appRoot))return!1;let t=relative(e.appRoot,e.sourcePath);if(t.length===0)return!1;let n=t.split(/[\\/]/)[0];return n!==void 0&&SNAPSHOT_APP_ROOT_SKIP_NAMES.has(n)}async function rewriteSnapshotTsConfigAbsoluteExtends(e){for(let t of e.tsconfigPaths){let n=await readTextFileIfExists(t);if(n===void 0)continue;let r=rewriteTsConfigAbsoluteExtends({configPath:t,snapshotConfigPath:toSnapshotPathForPlan(e,t),snapshotSourceRoot:e.snapshotSourceRoot,source:n,sourceRoot:e.sourceRoot});r!==void 0&&await writeFile(toSnapshotPathForPlan(e,t),r)}}function rewriteTsConfigAbsoluteExtends(e){let t=parseTsConfigObject(e.source);if(t===void 0)return;let n=rewriteTsConfigExtendsValue({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:t.extends});if(n.changed===!0)return`${JSON.stringify({...t,extends:n.value},null,2)}\n`}function rewriteTsConfigExtendsValue(e){if(typeof e.value==`string`){let t=rewriteTsConfigExtendsSpecifier({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:e.value});return t===void 0?{changed:!1,value:e.value}:{changed:!0,value:t}}if(!Array.isArray(e.value))return{changed:!1,value:e.value};let t=!1,n=e.value.map(n=>{if(typeof n!=`string`)return n;let r=rewriteTsConfigExtendsSpecifier({configPath:e.configPath,snapshotConfigPath:e.snapshotConfigPath,snapshotSourceRoot:e.snapshotSourceRoot,sourceRoot:e.sourceRoot,value:n});return r===void 0?n:(t=!0,r)});return{changed:t,value:n}}function rewriteTsConfigExtendsSpecifier(e){if(!isTsConfigFilePath(e.value)||!isAbsoluteFilePath(e.value))return;let t=resolveFirstExistingTsConfigExtendsTarget({configPath:e.configPath,extendsSpecifier:e.value});if(!(t===void 0||!isPathInsideOrEqual(t,e.sourceRoot)))return toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t,sourceRoot:e.sourceRoot})}async function createSnapshotDependencyMounts(e){for(let t of e.dependencyMounts){let r=toSnapshotPathForPlan(e,t.mountPath),i=t.copied?toSnapshotPathForPlan(e,t.sourcePath):t.sourcePath,a=t.copied?relative(dirname(r),i)||`.`:i;await mkdir(dirname(r),{recursive:!0}),await symlink(a,r,`junction`)}}async function ensureRuntimePackageJson(e){let t=join(e.runtimeAppRoot,`package.json`);existsSync(t)||(await mkdir(e.runtimeAppRoot,{recursive:!0}),await writeFile(t,`${JSON.stringify({private:!0,type:`module`},null,2)}\n`))}async function validateDevelopmentSourceSnapshot(e){let t=join(e.runtimeAppRoot,`package.json`);if(!existsSync(t))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot is missing the runtime app package.json at "${t}".`);for(let t of e.tsconfigPaths){let n=toSnapshotPathForPlan(e,t);if(!existsSync(n))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot is missing tsconfig dependency "${n}".`);await validateSnapshotTsConfigExtends(n)}}async function validateSnapshotTsConfigExtends(e){let t=extractTsConfigExtendsSpecifiers(await readFile(e,`utf8`));for(let n of t)if(!(!isTsConfigFilePath(n)||resolveTsConfigExtendsTargetPaths({configPath:e,extendsSpecifier:n}).some(e=>existsSync(e))))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot cannot resolve tsconfig extends "${n}" from "${e}".`)}function toSnapshotPathForPlan(e,t){return toDevelopmentSourceSnapshotPath({snapshotSourceRoot:e.snapshotSourceRoot,sourcePath:t,sourceRoot:e.sourceRoot})}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}function isAbsoluteFilePath(e){return e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}function formatErrorMessage(e){return e instanceof Error?e.message:String(e)}export{copyDevelopmentSourceSnapshot};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{lstat}from"node:fs/promises";import{
|
|
1
|
+
import{lstat}from"node:fs/promises";import{dirname,join,relative,resolve,sep}from"node:path";import{existsSync}from"node:fs";import{parseTsConfigObject,readTextFileIfExists}from"#internal/application/tsconfig-dependencies.js";async function resolveLocalTsConfigPathTargetRoots(e){let n=await readTextFileIfExists(e.configPath);if(n===void 0)return[];let r=parseTsConfigObject(n),i=isObjectRecord(r?.compilerOptions)?r.compilerOptions:void 0,a=isObjectRecord(i?.paths)?i.paths:void 0;if(i===void 0||a===void 0)return[];let s=typeof i.baseUrl==`string`?resolve(dirname(e.configPath),i.baseUrl):dirname(e.configPath),c=new Set;for(let t of Object.values(a))if(Array.isArray(t))for(let n of t){if(typeof n!=`string`||n.length===0)continue;let t=await resolveLocalTsConfigPathTargetRoot({baseDirectory:s,sourceRoot:e.sourceRoot,target:n});t!==void 0&&c.add(t)}return[...c].sort((e,t)=>e.localeCompare(t))}async function resolveNearestPackageRoot(r,i){let o=resolve(r);try{(await lstat(o)).isDirectory()||(o=dirname(o))}catch{o=dirname(o)}for(;isAuthoredSourcePath(o,i);){if(existsSync(join(o,`package.json`)))return o;let e=dirname(o);if(e===o)return;o=e}}function isAuthoredSourcePath(e,t){return isPathInsideOrEqual(e,t)?!relative(t,e).split(/[\\/]/).includes(`node_modules`):!1}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}async function resolveLocalTsConfigPathTargetRoot(e){let t=e.target.includes(`*`),n=t?e.target.slice(0,e.target.indexOf(`*`)):e.target;if(n.length===0||n===`.`||n===`./`)return;let r=resolve(e.baseDirectory,n);if(!isAuthoredSourcePath(r,e.sourceRoot))return;let i=await resolveExistingPathOrAncestor({path:r,stopDirectory:e.sourceRoot});if(i===void 0)return;let a=await resolveNearestPackageRoot(i,e.sourceRoot);if(a!==void 0&&a!==e.sourceRoot)return a;if(!t)return i===e.sourceRoot?void 0:i}async function resolveExistingPathOrAncestor(e){let n=resolve(e.path);for(;isAuthoredSourcePath(n,e.stopDirectory);){if(existsSync(n))return n;let e=dirname(n);if(e===n)return;n=e}}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{isAuthoredSourcePath,isPathInsideOrEqual,resolveLocalTsConfigPathTargetRoots,resolveNearestPackageRoot};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{lstat,readlink,realpath}from"node:fs/promises";import{
|
|
1
|
+
import{lstat,readlink,realpath}from"node:fs/promises";import{dirname,join,relative,resolve}from"node:path";import{existsSync,readFileSync}from"node:fs";import{readTextFileIfExists,resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";import{isAuthoredSourcePath,isAuthoredSourcePath as isAuthoredSourcePath$1,isPathInsideOrEqual,resolveLocalTsConfigPathTargetRoots,resolveNearestPackageRoot}from"#internal/nitro/dev-runtime-source-snapshot-local-roots.js";const DEV_RUNTIME_SOURCE_DIRECTORY=`source`,SOURCE_ROOT_MARKER_NAMES=[`.git`,`pnpm-workspace.yaml`],WORKSPACE_METADATA_FILE_NAMES=[`package.json`,`pnpm-workspace.yaml`,`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`,`.npmrc`],PACKAGE_DEPENDENCY_FIELDS=[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`];var DevelopmentRuntimeSourceSnapshotError=class extends Error{constructor(e){super(e),this.name=`DevelopmentRuntimeSourceSnapshotError`}};async function createDevelopmentSourceSnapshotPlan(e){let t=resolve(e.appRoot),n=resolve(e.snapshotRoot),r=resolveDevelopmentSourceRoot(t),a=join(n,DEV_RUNTIME_SOURCE_DIRECTORY),o={appRoot:t,authoredLocalRoots:new Set([t]),copyFiles:new Set,dependencyMountsByPath:new Map,localRootsToProcess:[t],processedLocalRoots:new Set,snapshotRoot:n,snapshotSourceRoot:a,sourceRoot:r,tsconfigPaths:new Set};for(addWorkspaceMetadataFiles(o),await addAuthoredSourceRoots(o,e.authoredSourceRoots??[]);o.localRootsToProcess.length>0;){let e=o.localRootsToProcess.shift();if(e===void 0)continue;let t=resolve(e);o.processedLocalRoots.has(t)||!isAuthoredSourcePath$1(t,r)||(o.processedLocalRoots.add(t),await addTsConfigDependenciesForRoot(o,t),await addDependencyMountsForRoot(o,t))}let s=normalizeCopyRoots([...o.processedLocalRoots].filter(e=>o.authoredLocalRoots.has(e))),c=[...o.copyFiles].filter(e=>isPathInsideOrEqual(e,r)).sort((e,t)=>e.localeCompare(t)),l=[...o.tsconfigPaths].filter(e=>isPathInsideOrEqual(e,r)).sort((e,t)=>e.localeCompare(t)),u=[...o.dependencyMountsByPath.values()].map(e=>({...e,copied:e.sourceKind===`workspace`&&[...o.authoredLocalRoots].some(t=>isPathInsideOrEqual(e.sourcePath,t))})).sort((e,t)=>e.mountPath.localeCompare(t.mountPath)),d=createWatchPaths({appRoot:t,copyFiles:c,copyRoots:s,dependencyMounts:u,sourceRoot:r,tsconfigPaths:l});return{appRoot:t,copyFiles:c,copyRoots:s,dependencyMounts:u,runtimeAppRoot:toSnapshotPath({sourcePath:t,sourceRoot:r,snapshotSourceRoot:a}),snapshotRoot:n,snapshotSourceRoot:a,sourceRoot:r,tsconfigPaths:l,watchPaths:d}}async function resolveDevelopmentSourceSnapshotWatchPaths(e){return[...(await createDevelopmentSourceSnapshotPlan({appRoot:e,snapshotRoot:join(resolve(e),`.eve`,`dev-runtime`,`__watch-plan__`)})).watchPaths]}function toDevelopmentSourceSnapshotPath(e){return toSnapshotPath(e)}function resolveDevelopmentSourceRoot(e){let t=resolve(e);for(;;){if(SOURCE_ROOT_MARKER_NAMES.some(e=>existsSync(join(t,e)))||isWorkspaceManifestRoot(t))return t;let n=dirname(t);if(n===t)return resolve(e);t=n}}function addWorkspaceMetadataFiles(e){for(let t of WORKSPACE_METADATA_FILE_NAMES){let n=join(e.sourceRoot,t);existsSync(n)&&e.copyFiles.add(n)}}async function addAuthoredSourceRoots(e,t){for(let n of t){let t=resolve(n);if(!isAuthoredSourcePath$1(t,e.sourceRoot))continue;let r=await resolveNearestPackageRoot(t,e.sourceRoot)??t;e.authoredLocalRoots.add(r),enqueueLocalRoot(e,r)}}async function addTsConfigDependenciesForRoot(e,t){let n=await resolveTsConfigDependencyPaths(t);for(let t of n)if(isPathInsideOrEqual(t,e.sourceRoot)){e.tsconfigPaths.add(t),e.copyFiles.add(t);for(let n of await resolveLocalTsConfigPathTargetRoots({configPath:t,sourceRoot:e.sourceRoot}))e.authoredLocalRoots.add(n),enqueueLocalRoot(e,n)}}async function addDependencyMountsForRoot(e,t){let n=await readPackageDependencyNames(resolveDependencyDeclarationRoot(t,e.sourceRoot));for(let r of n)for(let n of listAncestorNodeModulesRoots(t,e.sourceRoot))await addDependencyMount(e,joinNodeModulesPackagePath(n,r))}function resolveDependencyDeclarationRoot(e,t){let n=resolve(e),a=resolve(t);for(;isPathInsideOrEqual(n,a);){if(existsSync(join(n,`package.json`)))return n;let e=dirname(n);if(e===n)break;n=e}return e}function listAncestorNodeModulesRoots(e,t){let n=resolve(t),i=new Set,a=resolve(e);for(;isPathInsideOrEqual(a,n);){i.add(a);let e=dirname(a);if(e===a)break;a=e}return i.add(resolve(e)),i.add(n),[...i]}function isWorkspaceManifestRoot(e){let t=join(e,`package.json`);if(!existsSync(t))return!1;try{let e=JSON.parse(readFileSync(t,`utf8`));return isObjectRecord(e)&&e.workspaces!==void 0}catch{return!1}}async function addDependencyMount(t,n){let r;try{r=await lstat(n)}catch{return}if(!r.isDirectory()&&!r.isSymbolicLink())return;let i=await resolveDependencySourcePathCandidates(n),a=i.find(e=>isAuthoredSourcePath$1(e,t.sourceRoot));if(a!==void 0){await addWorkspaceDependencyMount({mountPath:n,state:t,sourcePath:a});return}let s=i.find(e=>existsSync(e));s!==void 0&&t.dependencyMountsByPath.set(resolve(n),{mountPath:resolve(n),sourceKind:`installed`,sourcePath:s})}async function addWorkspaceDependencyMount(e){let t=await resolveNearestPackageRoot(e.sourcePath,e.state.sourceRoot);if(t===void 0||!isAuthoredSourcePath$1(t,e.state.sourceRoot))return;let{state:n}=e;enqueueLocalRoot(n,t),n.dependencyMountsByPath.set(resolve(e.mountPath),{mountPath:resolve(e.mountPath),sourceKind:`workspace`,sourcePath:t})}async function resolveDependencySourcePathCandidates(e){let i=new Set;try{let n=await readlink(e);i.add(resolve(dirname(e),n))}catch{}try{i.add(await realpath(e))}catch{}return[...i]}function enqueueLocalRoot(e,t){let n=resolve(t);e.processedLocalRoots.has(n)||e.localRootsToProcess.includes(n)||!isAuthoredSourcePath$1(n,e.sourceRoot)||e.localRootsToProcess.push(n)}async function readPackageDependencyNames(e){let t=await readTextFileIfExists(join(e,`package.json`));if(t===void 0)return[];let n;try{n=JSON.parse(t)}catch{return[]}if(!isObjectRecord(n))return[];let r=new Set;for(let e of PACKAGE_DEPENDENCY_FIELDS){let t=n[e];if(isObjectRecord(t))for(let e of Object.keys(t))r.add(e)}return[...r].sort((e,t)=>e.localeCompare(t))}function normalizeCopyRoots(e){let t=[...new Set(e.map(e=>resolve(e)))].sort((e,t)=>{let n=e.length-t.length;return n===0?e.localeCompare(t):n}),n=[];for(let e of t)n.some(t=>isPathInsideOrEqual(e,t))||n.push(e);return n.sort((e,t)=>e.localeCompare(t))}function createWatchPaths(e){let t=new Set([join(e.appRoot,`package.json`),...e.copyFiles,...e.tsconfigPaths]);for(let n of e.copyRoots)n!==e.appRoot&&t.add(n);for(let n of e.dependencyMounts)n.sourceKind===`workspace`&&n.sourcePath!==e.appRoot&&t.add(n.sourcePath);if(e.sourceRoot!==e.appRoot)for(let n of WORKSPACE_METADATA_FILE_NAMES){let r=join(e.sourceRoot,n);existsSync(r)&&t.add(r)}return[...t].sort((e,t)=>e.localeCompare(t))}function joinNodeModulesPackagePath(e,t){return join(e,`node_modules`,...t.split(`/`))}function toSnapshotPath(e){if(!isPathInsideOrEqual(e.sourcePath,e.sourceRoot))throw new DevelopmentRuntimeSourceSnapshotError(`Cannot map source path "${e.sourcePath}" into a development runtime snapshot because it is outside source root "${e.sourceRoot}".`);return join(e.snapshotSourceRoot,relative(e.sourceRoot,e.sourcePath))}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{DEV_RUNTIME_SOURCE_DIRECTORY,DevelopmentRuntimeSourceSnapshotError,createDevelopmentSourceSnapshotPlan,isAuthoredSourcePath,resolveDevelopmentSourceRoot,resolveDevelopmentSourceSnapshotWatchPaths,toDevelopmentSourceSnapshotPath};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { NormalizedChannelCorsOptions } from "#channel/cors.js";
|
|
2
|
+
import type { CompiledAgentManifest } from "#compiler/manifest.js";
|
|
3
|
+
import type { ChannelRouteMethod } from "#public/definitions/channel.js";
|
|
4
|
+
export type ApplicationRouteMethod = ChannelRouteMethod | "ALL" | "HEAD" | "OPTIONS";
|
|
5
|
+
export interface ApplicationChannelRouteRegistration {
|
|
6
|
+
readonly method: ChannelRouteMethod;
|
|
7
|
+
readonly route: string;
|
|
8
|
+
readonly cors?: NormalizedChannelCorsOptions;
|
|
9
|
+
}
|
|
10
|
+
export interface ApplicationChannelRoute {
|
|
11
|
+
readonly kind: "channel";
|
|
12
|
+
readonly method: ChannelRouteMethod;
|
|
13
|
+
readonly path: string;
|
|
14
|
+
readonly cors?: NormalizedChannelCorsOptions;
|
|
15
|
+
}
|
|
16
|
+
export interface ApplicationChannelPreflightRoute {
|
|
17
|
+
readonly kind: "channel-preflight";
|
|
18
|
+
readonly method: "OPTIONS";
|
|
19
|
+
readonly path: string;
|
|
20
|
+
readonly cors: NormalizedChannelCorsOptions;
|
|
21
|
+
}
|
|
22
|
+
export type ApplicationRouteRegistration = ApplicationChannelPreflightRoute | ApplicationChannelRoute | {
|
|
23
|
+
readonly kind: "development-artifacts";
|
|
24
|
+
readonly method: "GET";
|
|
25
|
+
readonly path: string;
|
|
26
|
+
} | {
|
|
27
|
+
readonly kind: "development-schedule";
|
|
28
|
+
readonly method: "POST";
|
|
29
|
+
readonly path: string;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: "health";
|
|
32
|
+
readonly method: "GET" | "HEAD";
|
|
33
|
+
readonly path: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "home";
|
|
36
|
+
readonly method: "GET";
|
|
37
|
+
readonly path: string;
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: "workflow";
|
|
40
|
+
readonly method: "ALL";
|
|
41
|
+
readonly path: string;
|
|
42
|
+
};
|
|
43
|
+
export interface ApplicationRouteRegistry {
|
|
44
|
+
/** Active channel bindings after framework override and route deduplication. */
|
|
45
|
+
readonly channelRegistrations: readonly ApplicationChannelRouteRegistration[];
|
|
46
|
+
/** Channel and preflight routes accepted by the application-wide registry. */
|
|
47
|
+
readonly channelRoutes: readonly (ApplicationChannelPreflightRoute | ApplicationChannelRoute)[];
|
|
48
|
+
/** Globally deduplicated method/path bindings in Nitro registration order. */
|
|
49
|
+
readonly routes: readonly ApplicationRouteRegistration[];
|
|
50
|
+
}
|
|
51
|
+
interface ApplicationRouteRegistryHost {
|
|
52
|
+
readonly compileResult: {
|
|
53
|
+
readonly manifest: Pick<CompiledAgentManifest, "channels">;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
type ApplicationChannelManifestEntry = {
|
|
57
|
+
readonly kind: "channel";
|
|
58
|
+
readonly name: string;
|
|
59
|
+
readonly method: ChannelRouteMethod;
|
|
60
|
+
readonly urlPath: string;
|
|
61
|
+
readonly cors?: NormalizedChannelCorsOptions;
|
|
62
|
+
} | {
|
|
63
|
+
readonly kind: "disabled";
|
|
64
|
+
readonly name: string;
|
|
65
|
+
};
|
|
66
|
+
interface ApplicationFrameworkChannelDefinition {
|
|
67
|
+
readonly name: string;
|
|
68
|
+
readonly method: ChannelRouteMethod;
|
|
69
|
+
readonly urlPath: string;
|
|
70
|
+
readonly cors?: NormalizedChannelCorsOptions;
|
|
71
|
+
}
|
|
72
|
+
interface MergeApplicationChannelRoutesInput {
|
|
73
|
+
readonly frameworkChannelNames: ReadonlySet<string>;
|
|
74
|
+
readonly frameworkChannels: readonly ApplicationFrameworkChannelDefinition[];
|
|
75
|
+
readonly manifestChannels: readonly ApplicationChannelManifestEntry[];
|
|
76
|
+
}
|
|
77
|
+
interface CreateApplicationRouteRegistryInput extends MergeApplicationChannelRoutesInput {
|
|
78
|
+
readonly development?: boolean;
|
|
79
|
+
}
|
|
80
|
+
/** Applies authored-name overrides before deduplicating framework-first route bindings. */
|
|
81
|
+
export declare function mergeApplicationChannelRouteRegistrations(input: MergeApplicationChannelRoutesInput): readonly ApplicationChannelRouteRegistration[];
|
|
82
|
+
/** Compiles route identity, precedence, and deduplication without importing Nitro. */
|
|
83
|
+
export declare function createApplicationRouteRegistryFromInput(input: CreateApplicationRouteRegistryInput): ApplicationRouteRegistry;
|
|
84
|
+
export declare function createApplicationRouteRegistry(preparedHost: ApplicationRouteRegistryHost, options?: {
|
|
85
|
+
readonly development?: boolean;
|
|
86
|
+
}): ApplicationRouteRegistry;
|
|
87
|
+
export declare function computeApplicationChannelRouteRegistrations(preparedHost: ApplicationRouteRegistryHost): readonly ApplicationChannelRouteRegistration[];
|
|
88
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH,EVE_HEALTH_ROUTE_PATH}from"#protocol/routes.js";import{getAllFrameworkChannelNames,getFrameworkChannelDefinitions}from"#runtime/framework-channels/index.js";import{EVE_WORKFLOW_FLOW_ROUTE_PATH}from"#internal/workflow-bundle/eve-service-route-output.js";const PACKAGE_ROUTES=[{kind:`home`,method:`GET`,path:`/`},{kind:`health`,method:`GET`,path:EVE_HEALTH_ROUTE_PATH},{kind:`health`,method:`HEAD`,path:EVE_HEALTH_ROUTE_PATH}];function createMethodPathKey(e){return`${e.method} ${e.path}`}function mergeApplicationChannelRouteRegistrations(e){let t=new Set,n=[],r=new Set;for(let i of e.manifestChannels){if(i.kind===`disabled`){if(!e.frameworkChannelNames.has(i.name))throw Error(`agent/channels/${i.name}.ts exports disableRoute() but "${i.name}" is not a framework channel. Rename the file to one of: ${[...e.frameworkChannelNames].sort().join(`, `)}.`);r.add(i.name);continue}t.add(i.name),n.push({cors:i.cors,method:i.method,route:i.urlPath})}let i=e.frameworkChannels.filter(e=>!t.has(e.name)&&!r.has(e.name)).map(e=>({cors:e.cors,method:e.method,route:e.urlPath})),a=new Set,o=[];for(let e of[...i,...n]){let t=createMethodPathKey({method:e.method,path:e.route});a.has(t)||(a.add(t),o.push(e))}return o}function createApplicationRouteRegistryFromInput(n){let r=[],i=[],s=[],c=new Set,addRoute=e=>{let t=createMethodPathKey(e);return c.has(t)?!1:(c.add(t),r.push(e),!0)};for(let e of PACKAGE_ROUTES)addRoute(e);let l=new Set;for(let e of mergeApplicationChannelRouteRegistrations(n)){let t={cors:e.cors,kind:`channel`,method:e.method,path:e.route};if(addRoute(t)&&(s.push(e),i.push(t),e.method!==`WEBSOCKET`&&e.cors!==void 0&&!l.has(e.route))){l.add(e.route);let t={cors:e.cors,kind:`channel-preflight`,method:`OPTIONS`,path:e.route};addRoute(t)&&i.push(t)}}return n.development===!0&&(addRoute({kind:`development-artifacts`,method:`GET`,path:EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}),addRoute({kind:`development-schedule`,method:`POST`,path:EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN})),addRoute({kind:`workflow`,method:`ALL`,path:EVE_WORKFLOW_FLOW_ROUTE_PATH}),{channelRegistrations:s,channelRoutes:i,routes:r}}function createApplicationRouteRegistry(e,t={}){return createApplicationRouteRegistryFromInput({development:t.development,frameworkChannelNames:getAllFrameworkChannelNames(),frameworkChannels:getFrameworkChannelDefinitions(),manifestChannels:e.compileResult.manifest.channels})}function computeApplicationChannelRouteRegistrations(e){return mergeApplicationChannelRouteRegistrations({frameworkChannelNames:getAllFrameworkChannelNames(),frameworkChannels:getFrameworkChannelDefinitions(),manifestChannels:e.compileResult.manifest.channels})}export{computeApplicationChannelRouteRegistrations,createApplicationRouteRegistry,createApplicationRouteRegistryFromInput,mergeApplicationChannelRouteRegistrations};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile}from"node:fs/promises";import{
|
|
1
|
+
import{readFile}from"node:fs/promises";import{dirname,isAbsolute,join,relative,resolve,sep}from"node:path";import{resolveDiscoveryProject}from"#discover/project.js";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{toErrorMessage}from"#shared/errors.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{ApplicationBuildProfiler,createApplicationBuildProfile,measureApplicationBuildOutput,writeApplicationBuildProfile}from"#internal/application/build-profile.js";import{RecoverablePublicationError,publishApplicationBuildArtifacts}from"#internal/application/output-publication.js";import{stageProductionCompilerArtifacts}from"#internal/application/production-compiler-artifacts.js";import{materializeVercelWorkflowFunctionOutput,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{normalizeVercelServiceCrons}from"#internal/nitro/host/normalize-vercel-service-crons.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(/[\\/]+$/,``)}async function measureBuildPhase(e,t,n){return e===void 0?n():e.measure(t,n)}function isPathInside(e,t){let r=relative(e,t);return r.length===0||!r.startsWith(`..${sep}`)&&r!==`..`&&!isAbsolute(r)}function assertProfileOutputOutsideBuildOutput(e,t){if(e!==void 0&&isPathInside(t,e))throw Error(`Build profile path ${e} must be outside the published output directory ${t}.`)}async function writeOptionalApplicationBuildProfile(e){try{assertProfileOutputOutsideBuildOutput(e.profileOutputPath,e.outputDirectory);let t=e.profiler.finish(),n=await measureApplicationBuildOutput(e.outputDirectory);await writeApplicationBuildProfile(e.profileOutputPath,createApplicationBuildProfile({output:n,target:process.env.VERCEL?`vercel`:`local`,timing:t}))}catch(t){console.warn(`eve: failed to write optional build profile to ${e.profileOutputPath}; continuing with the published build output: ${toErrorMessage(t)}`)}}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(n,i){let o=Array.from(new Set([resolve(n),resolve(i)])),s=await findClosestVercelOutputDirectory(n);if(s!==void 0)try{let t=JSON.parse(await readFile(join(s,`config.json`),`utf8`)),n=resolveCoDeployedEveServicePrefix({appRoots:o,configRoot:await resolveVercelOutputConfigRoot(s),config:t});if(n!==void 0)return n}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let c=n;for(;;){for(let n of[join(c,`vercel.json`),join(c,`.vercel`,`output`,`config.json`)])try{let r=JSON.parse(await readFile(n,`utf8`)),i=resolveCoDeployedEveServicePrefix({appRoots:o,configRoot:n.endsWith(`vercel.json`)?c:await resolveVercelOutputConfigRoot(dirname(n)),config:r});if(i!==void 0)return i}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let n=dirname(c);if(n===c)return;c=n}}async function resolveVercelOutputConfigRoot(n){let i=dirname(dirname(n));try{let t=JSON.parse(await readFile(join(i,`.vercel`,`project.json`),`utf8`));if(isRecord(t)&&isRecord(t.settings)&&typeof t.settings.rootDirectory==`string`&&t.settings.rootDirectory.trim().length>0)return resolve(i,t.settings.rootDirectory)}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}return i}async function buildNitroOutput(e,t,n){let r=trimTrailingSlash(e.options.output.dir);return await measureBuildPhase(t,`${n}.cache.prepare`,()=>prepareEveVersionedCacheDirectory(r)),await measureBuildPhase(t,`${n}.prepare`,()=>prepare(e)),await measureBuildPhase(t,`${n}.public-assets`,()=>copyPublicAssets(e)),await measureBuildPhase(t,`${n}.prerender`,()=>prerender(e)),await measureBuildPhase(t,`${n}.bundle`,()=>build(e)),await measureBuildPhase(t,`${n}.cache.write`,()=>writeEveVersionedCacheMetadata(r)),r}async function buildApplication(e,t){let n=t.profileOutputPath===void 0?void 0:resolve(t.profileOutputPath),r=n===void 0?void 0:new ApplicationBuildProfiler,i=await measureBuildPhase(r,`extension.check`,()=>tryReadExtensionBuildConfig(e));if(i!==null)throw Error(`Package "${i.packageName}" is an eve extension. Run \`eve extension build\` instead of \`eve build\`.`);let o=await measureBuildPhase(r,`project.resolve`,()=>resolveDiscoveryProject(e)),c=await measureBuildPhase(r,`workspace.create`,()=>createApplicationBuildWorkspace(o.appRoot,t.vercelServiceOutput?.serviceOutputDirectory)),l=!1,u;try{u=await buildApplicationInWorkspace(c,t,r)}catch(e){throw l=e instanceof RecoverablePublicationError,e}finally{l||await measureBuildPhase(r,`workspace.remove`,()=>removeApplicationBuildWorkspace(c))}return r!==void 0&&n!==void 0&&await writeOptionalApplicationBuildProfile({outputDirectory:u,profileOutputPath:n,profiler:r}),u}async function buildApplicationInWorkspace(e,t,n){let r=await measureBuildPhase(n,`host.prepare`,()=>prepareProductionApplicationHost(e)),i=!!process.env.VERCEL,a=i?await measureBuildPhase(n,`vercel.service-prefix.resolve`,()=>resolveCoDeployedEveServicePrefixForVercelFunctionOutput(r.appRoot,r.compileResult.project.agentRoot)):void 0,o=await measureBuildPhase(n,`nitro.create`,()=>createProductionApplicationNitro(r,{buildDir:e.nitro.buildDir,outputDir:e.publication.output.stagedDir,publicRoutePrefix:t.publicRoutePrefix}));try{i&&!t.skipVercelSandboxPrewarm&&await measureBuildPhase(n,`sandbox.prewarm`,()=>runVercelBuildPrewarm({appRoot:r.appRoot,compiledArtifactsSource:createDiskRuntimeCompiledArtifactsSource(e.compiler.rootDir,{moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:r.appRoot}),log(e){console.log(e)}})),await buildNitroOutput(o,n,`nitro`),i&&await measureBuildPhase(n,`vercel.workflow-function.materialize`,()=>materializeVercelWorkflowFunctionOutput(e.publication.output.stagedDir)),a!==void 0&&await measureBuildPhase(n,`vercel.functions.normalize`,()=>normalizeEveVercelFunctionOutput(e.publication.output.stagedDir,{servicePrefix:a}));let s=t.vercelServiceOutput;s!==void 0&&(await measureBuildPhase(n,`vercel.service-crons.normalize`,()=>normalizeVercelServiceCrons({publicRoutePrefix:t.publicRoutePrefix,serviceOutputDirectory:e.publication.output.stagedDir})),await measureBuildPhase(n,`vercel.host-middleware.copy`,()=>copyHostMiddlewareFunctions({hostOutputDirectory:s.hostOutputDirectory,serviceOutputDirectory:e.publication.output.stagedDir}))),await measureBuildPhase(n,`agent-summary.emit`,()=>emitVercelAgentSummary({manifest:r.compileResult.manifest,outputPath:e.publication.summary.stagedPath})),i||await measureBuildPhase(n,`compiler-artifacts.stage`,()=>stageProductionCompilerArtifacts({compilerArtifactsRoot:e.compiler.artifactsDir,outputDir:e.publication.output.stagedDir}))}finally{await measureBuildPhase(n,`nitro.close`,()=>o.close())}return await measureBuildPhase(n,`output.publish`,()=>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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{mkdir,mkdtemp,rm}from"node:fs/promises";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{
|
|
1
|
+
import{mkdir,mkdtemp,rm}from"node:fs/promises";import{join,relative,resolve}from"node:path";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{discoverAgent}from"#discover/discover-agent.js";import{createDiskProjectSource}from"#discover/project-source.js";import{discoverFlatModuleSource,readSortedDirectoryEntries}from"#discover/grammar.js";import{EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,writeExtensionCompatibilityManifest}from"#compiler/extension-compatibility.js";import{ensureExtensionExports,tryReadExtensionBuildConfig}from"#internal/nitro/host/extension-build-config.js";import{deriveExtensionCapabilityRequirements}from"#internal/nitro/host/extension-capability-requirements.js";import{ExtensionOutputRestoreError,emitExtensionDistribution,replaceExtensionBuildOutput}from"#internal/nitro/host/extension-distribution.js";async function buildExtensionPackage(t,n){let r=resolve(t),i=createDiskProjectSource(),{diagnostics:a,manifest:o}=await discoverAgent({agentRoot:n.sourceRoot,appRoot:r,source:i,role:`extension`}),s=a.filter(e=>e.severity===`error`);if(s.length>0)throw Error(`Cannot build extension "${n.packageName}":\n${s.map(e=>` - ${e.message}`).join(`
|
|
2
2
|
`)}`);let c=discoverFlatModuleSource({rootEntries:await readSortedDirectoryEntries(i,n.sourceRoot),rootPath:n.sourceRoot,slotName:`extension`}).module;if(c===void 0)throw Error(`Cannot build extension "${n.packageName}": its source root "${n.sourceRoot}" is missing an "extension.<ext>" declaration. Add \`export default defineExtension(...)\` there (with or without config).`);let l=await mkdtemp(join(r,`.eve-extension-build-`)),u=join(l,`output`),d=join(u,relative(n.outDir,n.distRoot)),f=!1;try{return await mkdir(d,{recursive:!0}),await emitExtensionDistribution({appRoot:r,declarationModule:c,declarationsRoot:join(l,`declarations`),manifest:o,runtimeDependencies:n.runtimeDependencies,shortName:n.shortName,sourceRoot:n.sourceRoot,stagedDistRoot:d,stagedOutDir:u,transactionRoot:l}),await writeExtensionCompatibilityManifest(d,{kind:EXTENSION_COMPATIBILITY_MANIFEST_KIND,formatVersion:EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,builtWithEve:resolveInstalledPackageInfo().version,requires:await deriveExtensionCapabilityRequirements({declarationModule:c,manifest:o,runtimeDependencies:n.runtimeDependencies,sourceRoot:n.sourceRoot})}),await ensureExtensionExports(r,n.outDir),await replaceExtensionBuildOutput({outDir:n.outDir,stagedOutDir:u,transactionRoot:l}),n.outDir}catch(e){throw f=e instanceof ExtensionOutputRestoreError,e}finally{f||await rm(l,{force:!0,recursive:!0})}}export{buildExtensionPackage,tryReadExtensionBuildConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mkdir,writeFile}from"node:fs/promises";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{
|
|
1
|
+
import{mkdir,writeFile}from"node:fs/promises";import{dirname}from"node:path";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{VERCEL_EVE_AGENT_SUMMARY_KIND,VERCEL_EVE_AGENT_SUMMARY_VERSION,normalizeChannelKindForDisplay}from"#internal/vercel-agent-summary.js";function buildVercelAgentSummary(e){let{manifest:t}=e;return{kind:VERCEL_EVE_AGENT_SUMMARY_KIND,schemaVersion:VERCEL_EVE_AGENT_SUMMARY_VERSION,generatorVersion:e.generatorVersion??resolveInstalledPackageInfo().version,agent:t.config.dynamicModel===void 0?{name:t.config.name,description:t.config.description,modelId:t.config.model.id}:{name:t.config.name,description:t.config.description,modelRouting:{kind:`dynamic`}},instructions:t.instructions.map(toInstructionsEntry),schedules:t.schedules.map(toScheduleEntry),tools:t.tools.map(toToolEntry),skills:t.skills.map(toSkillEntry),connections:t.connections.map(toConnectionEntry),channels:t.channels.filter(isActiveChannel).map(toChannelEntry),sandbox:t.sandbox===null?null:{logicalPath:t.sandbox.logicalPath},subagents:t.subagents.map(toSubagentEntry),diagnostics:{errors:t.diagnosticsSummary.errors,warnings:t.diagnosticsSummary.warnings}}}async function emitVercelAgentSummary(n){let r=buildVercelAgentSummary({generatorVersion:n.generatorVersion,manifest:n.manifest});return await mkdir(dirname(n.outputPath),{recursive:!0}),await writeFile(n.outputPath,`${JSON.stringify(r,null,2)}\n`),n.outputPath}function isActiveChannel(e){return e.kind===`channel`}function toInstructionsEntry(e){return{content:e.content,logicalPath:e.logicalPath,role:e.role,sourceKind:e.sourceKind}}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,19 +1,12 @@
|
|
|
1
1
|
import type { Nitro } from "nitro/types";
|
|
2
|
-
import type
|
|
3
|
-
import type { ChannelRouteMethod } from "#public/definitions/channel.js";
|
|
2
|
+
import { type ApplicationChannelPreflightRoute, type ApplicationChannelRoute, type ApplicationChannelRouteRegistration } from "#internal/nitro/host/application-route-registry.js";
|
|
4
3
|
import type { NitroArtifactsConfig } from "#internal/nitro/routes/runtime-artifacts.js";
|
|
5
4
|
import type { PreparedApplicationHost } from "#internal/nitro/host/types.js";
|
|
6
5
|
interface ChannelRouteNitro {
|
|
7
6
|
readonly options: Pick<Nitro["options"], "handlers" | "virtual">;
|
|
8
7
|
}
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
export interface NitroChannelRouteRegistration {
|
|
13
|
-
readonly method: ChannelRouteMethod;
|
|
14
|
-
readonly route: string;
|
|
15
|
-
readonly cors?: NormalizedChannelCorsOptions;
|
|
16
|
-
}
|
|
8
|
+
/** One active channel binding in the eve-owned application route registry. */
|
|
9
|
+
export type NitroChannelRouteRegistration = ApplicationChannelRouteRegistration;
|
|
17
10
|
/**
|
|
18
11
|
* Computes the merged set of channel routes the Nitro host should mount.
|
|
19
12
|
*/
|
|
@@ -23,6 +16,6 @@ export declare function computeChannelRouteRegistrations(preparedHost: PreparedA
|
|
|
23
16
|
*/
|
|
24
17
|
export declare function registerChannelVirtualHandlers(nitro: Pick<ChannelRouteNitro, "options">, input: {
|
|
25
18
|
readonly artifactsConfig: NitroArtifactsConfig;
|
|
26
|
-
readonly
|
|
19
|
+
readonly routes: readonly (ApplicationChannelPreflightRoute | ApplicationChannelRoute)[];
|
|
27
20
|
}): void;
|
|
28
21
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{resolvePackageDependencyPath,resolvePackageSourceFilePath}from"#internal/application/package.js";import{stringifyEsmImportSpecifier}from"#internal/application/import-specifier.js";import{
|
|
2
|
-
`);return}r.options.handlers.push({handler:
|
|
1
|
+
import{resolvePackageDependencyPath,resolvePackageSourceFilePath}from"#internal/application/package.js";import{stringifyEsmImportSpecifier}from"#internal/application/import-specifier.js";import{computeApplicationChannelRouteRegistrations}from"#internal/nitro/host/application-route-registry.js";const EVE_CHANNEL_VIRTUAL_ID_PREFIX=`#nitro/virtual/eve-channel/`;function computeChannelRouteRegistrations(e){return computeApplicationChannelRouteRegistrations(e)}function registerChannelVirtualHandlers(e,t){for(let n of t.routes)addChannelVirtualHandler(e,{artifactsConfig:t.artifactsConfig,route:n})}function createChannelRouteKey(e){return`${e.method.toUpperCase()} ${e.path}`}function addChannelVirtualHandler(r,i){if(i.route.kind===`channel-preflight`){addChannelCorsPreflightHandler(r,i.route);return}let a=createChannelRouteKey(i.route),o=`${EVE_CHANNEL_VIRTUAL_ID_PREFIX}${a}`,s=stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/nitro/routes/channel-dispatch.ts`)),c=stringifyEsmImportSpecifier(resolvePackageDependencyPath(`nitro`)),l=stringifyEsmImportSpecifier(resolvePackageDependencyPath(`nitro/h3`));if(i.route.method===`WEBSOCKET`){r.options.handlers.push({handler:o,route:i.route.path}),r.options.virtual[o]=[`import { defineWebSocketHandler } from ${c};`,`import { dispatchChannelWebSocketRequest } from ${s};`,`const config = ${JSON.stringify(i.artifactsConfig)};`,`export default defineWebSocketHandler((event) => dispatchChannelWebSocketRequest(event, ${JSON.stringify(a)}, config));`].join(`
|
|
2
|
+
`);return}r.options.handlers.push({handler:o,method:i.route.method,route:i.route.path}),r.options.virtual[o]=[...i.route.cors===void 0?[]:[`import { handleCors } from ${l};`,`const cors = ${JSON.stringify(i.route.cors)};`],`import { dispatchChannelRequest } from ${s};`,`const config = ${JSON.stringify(i.artifactsConfig)};`,i.route.cors===void 0?`export default (event) => dispatchChannelRequest(event, ${JSON.stringify(a)}, config);`:[`export default (event) => {`,` const corsResponse = handleCors(event, cors);`,` if (corsResponse !== false) return corsResponse;`,` return dispatchChannelRequest(event, ${JSON.stringify(a)}, config);`,`};`].join(`
|
|
3
3
|
`)].join(`
|
|
4
|
-
`)}function addChannelCorsPreflightHandler(
|
|
4
|
+
`)}function addChannelCorsPreflightHandler(t,r){let i=createChannelRouteKey(r),a=`${EVE_CHANNEL_VIRTUAL_ID_PREFIX}${i}`,o=stringifyEsmImportSpecifier(resolvePackageDependencyPath(`nitro/h3`));t.options.handlers.push({handler:a,method:`OPTIONS`,route:r.path}),t.options.virtual[a]=[`import { handleCors } from ${o};`,`const cors = ${JSON.stringify(r.cors)};`,`export default (event) => {`,` const corsResponse = handleCors(event, cors);`,` if (corsResponse !== false) return corsResponse;`,` return new Response(null, { status: 204 });`,`};`].join(`
|
|
5
5
|
`)}export{computeChannelRouteRegistrations,registerChannelVirtualHandlers};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{mkdir,writeFile}from"node:fs/promises";import{
|
|
2
|
-
`)}function resolveNitroWorkflowBuildDirectory(e){return join(e.options.buildDir,`workflow`)}function createRelativeImportSpecifier(e,t){let n=relative(e,t).replaceAll(`\\`,`/`);return n.startsWith(`.`)?n:`./${n}`}async function addWorkflowFileHandler(
|
|
1
|
+
import{mkdir,writeFile}from"node:fs/promises";import{dirname,join,relative}from"node:path";import{resolvePackageRoot,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{isVercelBuildEnvironment}from"#internal/application/paths.js";import{normalizeEsmImportSpecifier,stringifyEsmImportSpecifier}from"#internal/application/import-specifier.js";import{usesParentDevelopmentWorkflowWorld}from"#internal/workflow/development-world-protocol.js";import{createApplicationRouteRegistry}from"#internal/nitro/host/application-route-registry.js";import{WorkflowBundleBuilder}from"#internal/workflow-bundle/builder.js";import{createDevelopmentNitroArtifactsConfig,createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{deriveEveWorkflowQueuePrefix}from"#internal/workflow/queue-namespace.js";import{registerChannelVirtualHandlers}from"#internal/nitro/host/channel-routes.js";function registerHandler(e,t){let n=`#eve-route-handler/${t.method??`ALL`} ${t.route}`,r=stringifyEsmImportSpecifier(t.handlerPath);e.options.handlers.push({handler:n,method:t.method,route:t.route}),e.options.virtual[n]=[`import handler from ${r};`,`export default handler;`].join(`
|
|
2
|
+
`)}function resolveNitroWorkflowBuildDirectory(e){return join(e.options.buildDir,`workflow`)}function createRelativeImportSpecifier(e,t){let n=relative(e,t).replaceAll(`\\`,`/`);return n.startsWith(`.`)?n:`./${n}`}async function addWorkflowFileHandler(i,a){let o=join(resolveNitroWorkflowBuildDirectory(i),`${a.bundleName}-handler.mjs`),s=dirname(o),c=createRelativeImportSpecifier(s,a.bundlePath),l=a.directHandlers??[],u=l.length>0&&a.workflowWorldPluginPath!==void 0?createRelativeImportSpecifier(s,a.workflowWorldPluginPath):void 0,d=l.map(e=>{let t=createRelativeImportSpecifier(s,e.bundlePath);return{importSpecifier:t,isOwnBundle:t===c,queuePrefix:e.queuePrefix}});await mkdir(s,{recursive:!0}),await writeFile(o,buildWorkflowFileHandlerSource({bundlePath:c,directHandlers:d,runtimeImportSpecifier:a.runtimeImportSpecifier,workflowWorldPluginImportSpecifier:u})),i.options.handlers.push({handler:o,route:a.route})}function buildWorkflowFileHandlerSource(e){let t=[`// Generated by eve. Do not edit by hand.`,`import { POST } from ${JSON.stringify(e.bundlePath)};`];if(e.directHandlers.length>0&&e.runtimeImportSpecifier!==void 0){let n=0,r=e.directHandlers.map(e=>{if(e.isOwnBundle)return{...e,binding:`POST`};let t=`__eveWorkflowDirectHandler${n}`;return n+=1,{...e,binding:t}});for(let e of r)e.isOwnBundle||t.push(`import { POST as ${e.binding} } from ${JSON.stringify(e.importSpecifier)};`);e.workflowWorldPluginImportSpecifier!==void 0&&t.push(`import ${JSON.stringify(e.workflowWorldPluginImportSpecifier)};`),t.push(`import { getWorld as __eveGetWorkflowWorld } from ${JSON.stringify(e.runtimeImportSpecifier)};`,``,`try {`,` const __eveWorkflowWorld = await __eveGetWorkflowWorld();`,` if (typeof __eveWorkflowWorld?.registerHandler === "function") {`);for(let e of r)t.push(` __eveWorkflowWorld.registerHandler(${JSON.stringify(e.queuePrefix)}, ${e.binding});`);t.push(` }`,`} catch (err) {`,` console.warn("[eve] Failed to register direct workflow queue handlers:", err);`,`}`)}return t.push(``,`export default async ({ req }) => {`,` return await POST(req);`,`};`,``),t.join(`
|
|
3
3
|
`)}function addFrameworkVirtualHandler(e,t){let n=`#eve-route${t.route}`,r=stringifyEsmImportSpecifier(t.modulePath);e.options.handlers.push({handler:n,method:t.method,route:t.route}),e.options.virtual[n]=[`import { ${t.handlerExport} } from ${r};`,`export default async (event) => ${t.handlerExport}(${t.args}, event.req);`].join(`
|
|
4
|
-
`)}async function registerWorkflowArtifactBuildHook(e,t){let n=!0;await t(),e.hooks.hook(`build:before`,async()=>{if(n){n=!1;return}await t()})}function registerApplicationRoutes(e,t,n){addFrameworkVirtualHandler(e,{args:JSON.stringify({agentName:t.compileResult.manifest.config.name}),handlerExport:`handleHomePageRequest`,method
|
|
4
|
+
`)}async function registerWorkflowArtifactBuildHook(e,t){let n=!0;await t(),e.hooks.hook(`build:before`,async()=>{if(n){n=!1;return}await t()})}function registerApplicationRoutes(e,t,n,r){for(let i of r.routes)switch(i.kind){case`home`:addFrameworkVirtualHandler(e,{args:JSON.stringify({agentName:t.compileResult.manifest.config.name}),handlerExport:`handleHomePageRequest`,method:i.method,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/index.ts`),route:i.path});break;case`health`:registerHandler(e,{handlerPath:resolvePackageSourceFilePath(`src/internal/nitro/routes/health.ts`),method:i.method,route:i.path});break;case`channel`:case`channel-preflight`:registerChannelVirtualHandlers(e,{artifactsConfig:n,routes:[i]});break;case`development-artifacts`:addFrameworkVirtualHandler(e,{args:JSON.stringify({appRoot:n.appRoot}),handlerExport:`handleDevRuntimeArtifactsRequest`,method:i.method,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-runtime-artifacts.ts`),route:i.path});break;case`development-schedule`:addFrameworkVirtualHandler(e,{args:JSON.stringify(n),handlerExport:`handleDevScheduleDispatchRequest`,method:i.method,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-schedule-dispatch.ts`),route:i.path});break;case`workflow`:break}}function findWorkflowRoute(e){return e.routes.find(e=>e.kind===`workflow`)?.path}function createWorkflowDirectHandlerEntry(e,t){return{bundlePath:t,queuePrefix:deriveEveWorkflowQueuePrefix(e.compileResult.manifest.config.name)}}async function registerWorkflowRoute(e,t,n,r,i){await addWorkflowFileHandler(e,{bundleName:`workflows`,bundlePath:n,directHandlers:r,route:i,runtimeImportSpecifier:r.length===0?void 0:normalizeEsmImportSpecifier(resolveWorkflowModulePath(`workflow/runtime`)),workflowWorldPluginPath:t.compiledArtifacts.workflowWorldPluginPath})}async function configureDevelopmentNitroRoutes(e,t){let n=resolveNitroWorkflowBuildDirectory(e),i=new WorkflowBundleBuilder({agentName:t.compileResult.manifest.config.name,appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifacts.bootstrapPath,outDir:t.workflowBuildDir,rootDir:resolvePackageRoot(),watch:!0});await registerWorkflowArtifactBuildHook(e,async()=>{await i.build({nitroStepOutfile:join(n,`steps.mjs`),nitroWorkflowOutfile:join(n,`workflows.mjs`)})});let o=createDevelopmentNitroArtifactsConfig({appRoot:t.appRoot,configuredWorld:t.compileResult.manifest.config.experimental?.workflow?.world}),s=createApplicationRouteRegistry(t,{development:!0});registerApplicationRoutes(e,t,o,s);let c=join(n,`workflows.mjs`),l=[];usesParentDevelopmentWorkflowWorld(t.compileResult.manifest.config.experimental?.workflow?.world)||l.push(createWorkflowDirectHandlerEntry(t,c));let u=findWorkflowRoute(s);u!==void 0&&await registerWorkflowRoute(e,t,c,l,u),e.routing.sync()}async function configureProductionNitroRoutes(e,t){let n=new WorkflowBundleBuilder({agentName:t.compileResult.manifest.config.name,appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifacts.bootstrapPath,outDir:t.workflowBuildDir,rootDir:resolvePackageRoot(),watch:!1});await registerWorkflowArtifactBuildHook(e,async()=>{await n.build({nitroStepOutfile:join(resolveNitroWorkflowBuildDirectory(e),`steps.mjs`)})});let i=createApplicationRouteRegistry(t);registerApplicationRoutes(e,t,createProductionNitroArtifactsConfig(),i);let o=join(t.workflowBuildDir,`workflows.mjs`),s=t.compileResult.manifest.config.experimental?.workflow?.world!==void 0,l=!isVercelBuildEnvironment()&&s?[createWorkflowDirectHandlerEntry(t,o)]:[],u=findWorkflowRoute(i);u!==void 0&&await registerWorkflowRoute(e,t,o,l,u),e.routing.sync()}export{configureDevelopmentNitroRoutes,configureProductionNitroRoutes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile}from"node:fs/promises";import{resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{dirname,isAbsolute,join,relative,resolve}from"node:path";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{createExtensionScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{createDynamicCapabilityTransformPlugin}from"#internal/workflow-bundle/dynamic-capability-transform-plugin.js";import{createNitro}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{createEveVercelOptions}from"#internal/nitro/host/vercel-build-output-config.js";import{createCompiledSandboxBackendPrunePlugin}from"#internal/nitro/host/compiled-sandbox-backend-prune-plugin.js";import{configureDevelopmentNitroRoutes,configureProductionNitroRoutes}from"#internal/nitro/host/configure-nitro-routes.js";import{applyEveCronHandlerRoute}from"#internal/nitro/host/cron-handler-route.js";import{createNitroBundlerConfig}from"#internal/nitro/host/nitro-bundler-config.js";import{OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME,createOptionalEngineDependencyPlugin}from"#internal/nitro/host/optional-engine-dependency-plugin.js";import{addNitroRoutingImportSpecifierPlugin}from"#internal/nitro/host/nitro-routing-import-specifier-plugin.js";import{registerScheduleTaskHandlers}from"#internal/nitro/host/schedule-task-routes.js";import{applyWorkflowTransform}from"#internal/workflow-bundle/workflow-builders.js";const WORKFLOW_ALIAS_SPECIFIERS=[`workflow`,`workflow/api`,`workflow/errors`,`workflow/internal/builtins`,`workflow/internal/private`,`workflow/runtime`],WORKFLOW_TRANSFORM_PATCHED=Symbol(`eve.workflow-transform-patched`),FRAMEWORK_HOSTED_EXTERNAL_PACKAGES=[`@napi-rs/keyring`],LOCAL_SANDBOX_BACKEND_NAMES=new Set([`docker`,...Object.keys(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME)]);function resolveWorkflowAliases(){let e={};for(let t of WORKFLOW_ALIAS_SPECIFIERS)e[t]=resolveWorkflowModulePath(t);return e}function resolveProductionNitroPreset(){return process.env.VERCEL?`vercel`:void 0}function manifestEnablesWorkflow(e){return[e,...e.subagents.map(e=>e.agent)].some(e=>e.workflowTool!==void 0)}function manifestHasWebSocketChannel(e){return e.channels.some(e=>e.kind===`channel`&&e.method===`WEBSOCKET`)}function collectHostedTraceDependencies(e,t){let n=[...e.compileResult.manifest.config.build?.externalDependencies??[],...e.compileResult.manifest.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])];return[...new Set([...FRAMEWORK_HOSTED_EXTERNAL_PACKAGES,...t,...n])].filter(e=>e!==EVE_PACKAGE_NAME)}function collectConfiguredSandboxBackendNames(e){let t=[e,...e.subagents.map(e=>e.agent)];return new Set(t.map(e=>e.sandbox?.backendName).filter(e=>typeof e==`string`))}function shouldPruneLocalSandboxBackends(e){return e.preset===`vercel`&&![...e.configuredBackendNames].some(e=>LOCAL_SANDBOX_BACKEND_NAMES.has(e))}function createDevelopmentWatchOptions(e){return{ignored:[e,join(e,`**`)]}}function normalizePath(e){return e.replaceAll(`\\`,`/`)}function stripPathQueryAndHash(e){let t=e.indexOf(`?`),n=e.indexOf(`#`),r=t===-1?n:n===-1?t:Math.min(t,n);return r===-1?e:e.slice(0,r)}function stripFileSystemPrefix(e){return e.startsWith(`/@fs/`)?e.slice(4):e}function resolveNitroModuleComparisonPath(e,t){return t.startsWith(`file://`)?normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(fileURLToPath(t)))):isAbsolute(t)?normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(t))):normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(resolve(e,t))))}function isWorkflowBundlePath(e,t){let n=normalizePath(e);return n.startsWith(t)||n.includes(`/.eve/workflow-cache/`)}function normalizeStepTransformComparisonPath(e){let t=normalizePath(e);return process.platform===`win32`?t.toLowerCase():t}function parseImportedModuleSpecifiers(e){let t=/^\s*import\s+(?:.+?\s+from\s+)?["']([^"']+)["'];?\s*$/gm,n=[];for(let r of e.matchAll(t)){let e=r[1];e!==void 0&&n.push(e)}return n}function resolveNitroImportPath(e,t,n){return t.startsWith(`workflow`)?resolveWorkflowModulePath(t):t.startsWith(`.`)||t.startsWith(`/`)||t.startsWith(`file://`)?resolveNitroModuleComparisonPath(n===void 0?e:dirname(resolveNitroModuleComparisonPath(e,n)),t):null}async function collectNitroStepTransformTargets(t,n){let r=await readFile(t,`utf8`),i=new Set;for(let e of parseImportedModuleSpecifiers(r)){let r=resolveNitroImportPath(n,e,t);r!==null&&i.add(normalizeStepTransformComparisonPath(r))}return i}async function addNitroStepNoExternals(e,t){if(e.options.noExternals===!0)return;let n;try{n=await collectNitroStepTransformTargets(t,e.options.rootDir)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let r=Array.isArray(e.options.noExternals)?[...e.options.noExternals]:[];e.options.noExternals=[...new Set([...r,...n])]}function createRelativeTransformFilename(e,t){let n=createPackageRelativeTransformFilename(t);if(n!==void 0)return n;let r=normalizePath(e).replace(/\/$/,``),i=normalizePath(t),a=r.toLowerCase(),o=i.toLowerCase();if(o.startsWith(`${a}/`))return i.slice(r.length+1);if(o===a)return`.`;let s=relative(r,i).replaceAll(`\\`,`/`);if(s.startsWith(`../`)&&(s=s.split(`/`).filter(e=>e!==`..`).join(`/`)),s.includes(`:`)||s.startsWith(`/`)){let e=i.split(`/`).pop();return e===void 0||e.length===0?`unknown.ts`:e}return s}function createPackageRelativeTransformFilename(e){let n=normalizePath(resolvePackageRoot()).replace(/\/$/,``),r=normalizePath(e),i=n.toLowerCase(),a=r.toLowerCase(),o=`${n}/src/`,s=`${i}/src/`,c=`${n}/dist/src/`,l=`${i}/dist/src/`;if(a.startsWith(s))return`src/${r.slice(o.length)}`;if(a.startsWith(l))return`src/${r.slice(c.length)}`}function addWorkflowModuleSideEffectsPlugin(e,t){let n=[t,join(e.options.buildDir,`workflow`)].map(t=>resolveNitroModuleComparisonPath(e.options.rootDir,t));e.hooks.hook(`rollup:before`,(t,r)=>{Array.isArray(r.plugins)&&r.plugins.unshift({name:`eve:workflow-module-side-effects`,resolveId(t,r){let i=resolveNitroImportPath(e.options.rootDir,t,r)??resolveNitroModuleComparisonPath(e.options.rootDir,t);return n.some(e=>isWorkflowBundlePath(i,e))?{id:i,moduleSideEffects:`no-treeshake`}:null}})})}function addNitroStepModuleSideEffectsPlugin(e,t){let n=null,getStepTransformTargets=async()=>(n===null&&(n=await collectNitroStepTransformTargets(t.stepEntrypointPath,e.options.rootDir)),n),clearCachedStepTransformTargets=()=>{n=null};return e.hooks.hook(`build:before`,clearCachedStepTransformTargets),e.hooks.hook(`rollup:before`,(t,n)=>{Array.isArray(n.plugins)&&n.plugins.unshift({name:`eve:workflow-step-module-side-effects`,async resolveId(t,n){let r=resolveNitroImportPath(e.options.rootDir,t,n);return r===null||!(await getStepTransformTargets()).has(normalizeStepTransformComparisonPath(r))?null:{id:r,moduleSideEffects:`no-treeshake`}}})}),clearCachedStepTransformTargets}function addNitroStepTransformPlugin(e,t){let n=null,getStepTransformTargets=async()=>(n===null&&(n=await collectNitroStepTransformTargets(t.stepEntrypointPath,e.options.rootDir)),n),clearCachedStepTransformTargets=()=>{n=null};return e.hooks.hook(`build:before`,clearCachedStepTransformTargets),e.hooks.hook(`rollup:before`,(t,n)=>{Array.isArray(n.plugins)&&n.plugins.unshift({async transform(t,n){let r=await getStepTransformTargets(),i=resolveNitroModuleComparisonPath(e.options.rootDir,n);return r.has(normalizeStepTransformComparisonPath(i))?{code:(await applyWorkflowTransform(createRelativeTransformFilename(e.options.rootDir,i),t,`step`,i,e.options.rootDir)).code,map:null}:null},name:`eve:workflow-step-transform`})}),clearCachedStepTransformTargets}function addDynamicCapabilityTransformPlugin(e){e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift(createDynamicCapabilityTransformPlugin())})}function addInstrumentationModuleSideEffectsPlugin(e,t){let n=new Set(t.map(normalizePath));e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({name:`eve:instrumentation-module-side-effects`,resolveId(e){return n.has(normalizePath(e))?{id:e,moduleSideEffects:`no-treeshake`}:null}})})}function patchWorkflowTransformExcludePath(e,t){let n=normalizePath(t);e.hooks.hook(`rollup:before`,(e,t)=>{if(Array.isArray(t.plugins))for(let e of t.plugins){if(typeof e!=`object`||!e)continue;let t=e;if(t.name!==`workflow:transform`||t[WORKFLOW_TRANSFORM_PATCHED]===!0||typeof t.transform!=`function`)continue;let r=t.transform;t.transform=function(e,t,...i){return isWorkflowBundlePath(t,n)?null:r.call(this,e,t,...i)},t[WORKFLOW_TRANSFORM_PATCHED]=!0}})}function createApplicationNitroBundlerConfiguration(e,t){let n=collectConfiguredSandboxBackendNames(e.compileResult.manifest),r=shouldPruneLocalSandboxBackends({configuredBackendNames:n,preset:t})?createCompiledSandboxBackendPrunePlugin():null,i=[],a=[];for(let[e,t]of Object.entries(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME))(n.has(e)?i:a).push(t);let o=createExtensionScopePlugin([e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.map(e=>({sourceRoot:e.sourceRoot,packageNamespace:e.packageNamespace})))),s=[r,createOptionalEngineDependencyPlugin(a),o].filter(e=>e!==null);return{nitroRolldownConfig:createNitroBundlerConfig(s),nitroRollupConfig:createNitroBundlerConfig(s),tracedAppDependencies:collectHostedTraceDependencies(e,i)}}function createApplicationNitroPlugins(e){let t=[e.compiledArtifacts.bootstrapPath,e.compiledArtifacts.workflowWorldPluginPath];return manifestEnablesWorkflow(e.compileResult.manifest)&&t.push(resolvePackageSourceFilePath(`src/internal/nitro/host/workflow-sandbox-runtime-plugin.ts`)),e.compiledArtifacts.instrumentationPluginPath!==void 0&&t.push(e.compiledArtifacts.instrumentationPluginPath),t}function configureSharedApplicationNitro(e,t){addNitroRoutingImportSpecifierPlugin(e);let n=resolveWorkflowAliases();for(let[t,r]of Object.entries(n))e.options.alias[t]=r;addWorkflowModuleSideEffectsPlugin(e,t.workflowBuildDir),patchWorkflowTransformExcludePath(e,t.workflowBuildDir),addDynamicCapabilityTransformPlugin(e),t.compiledArtifacts.instrumentationSourcePaths!==void 0&&addInstrumentationModuleSideEffectsPlugin(e,t.compiledArtifacts.instrumentationSourcePaths)}function configureNitroStepPlugins(e,t){return[addNitroStepModuleSideEffectsPlugin(e,{stepEntrypointPath:t}),addNitroStepTransformPlugin(e,{stepEntrypointPath:t})]}function externalizeDevelopmentWorkflowBundle(e,t){let n=new Set([normalizePath(join(t.workflowBuildDir,`workflows.mjs`))]);e.hooks.hook(`rollup:before`,(e,t)=>{let r=t.external;t.external=(e,...t)=>{if(n.has(normalizePath(e)))return!0;if(typeof r==`function`)return r(e,...t)}})}async function createDevelopmentApplicationNitro(e){let t=e.workspace.nitroBuildDir,i=createApplicationNitroBundlerConfiguration(e,void 0),a=createApplicationNitroPlugins(e);e.compiledArtifacts.instrumentationPluginPath===void 0&&a.unshift(resolvePackageSourceFilePath(`src/internal/nitro/host/local-tracing-runtime-plugin.ts`)),await prepareEveVersionedCacheDirectory(t);let o=await createNitro({_cli:{command:`dev`},buildDir:t,dev:!0,features:{websocket:!0},logLevel:1,output:{dir:e.workspace.nitroOutputDir},plugins:a,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:i.nitroRolldownConfig,rollupConfig:i.nitroRollupConfig,rootDir:e.appRoot,serverDir:!1,traceDeps:i.tracedAppDependencies,vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:!1}),watchOptions:createDevelopmentWatchOptions(e.appRoot)},{watch:!0});await writeEveVersionedCacheMetadata(t);let c=join(o.options.buildDir,`workflow`,`steps.mjs`);configureSharedApplicationNitro(o,e);let l=configureNitroStepPlugins(o,c);return o.hooks.hook(`dev:reload`,()=>{for(let e of l)e()}),externalizeDevelopmentWorkflowBundle(o,e),await configureDevelopmentNitroRoutes(o,e),await addNitroStepNoExternals(o,c),o}async function createProductionApplicationNitro(e,t){let i=resolveProductionNitroPreset(),a=createApplicationNitroBundlerConfiguration(e,i),o=createApplicationNitroPlugins(e);o.push(resolvePackageSourceFilePath(`src/internal/nitro/host/sandbox-shutdown-plugin.ts`)),await prepareEveVersionedCacheDirectory(t.buildDir);let c=await createNitro({_cli:{command:`build`},buildDir:t.buildDir,dev:!1,features:{websocket:manifestHasWebSocketChannel(e.compileResult.manifest)},output:{dir:t.outputDir},preset:i,plugins:o,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:a.nitroRolldownConfig,rollupConfig:a.nitroRollupConfig,rootDir:e.appRoot,serverDir:!1,traceDeps:a.tracedAppDependencies,vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:i===`vercel`,publicRoutePrefix:t.publicRoutePrefix})});return await writeEveVersionedCacheMetadata(t.buildDir),configureSharedApplicationNitro(c,e),configureNitroStepPlugins(c,join(e.workflowBuildDir,`steps.mjs`)),e.scheduleRegistrations.length>0&&(applyEveCronHandlerRoute(c),registerScheduleTaskHandlers(c,{artifactsConfig:createProductionNitroArtifactsConfig(),dispatchModulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/schedule-task.ts`),registrations:e.scheduleRegistrations})),await configureProductionNitroRoutes(c,e),await addNitroStepNoExternals(c,join(e.workflowBuildDir,`steps.mjs`)),c}export{createDevelopmentApplicationNitro,createProductionApplicationNitro,shouldPruneLocalSandboxBackends};
|
|
1
|
+
import{readFile}from"node:fs/promises";import{dirname,isAbsolute,join,relative,resolve}from"node:path";import{resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{createExtensionScopePlugin}from"#internal/bundler/extension-scope-plugin.js";import{createDynamicCapabilityTransformPlugin}from"#internal/workflow-bundle/dynamic-capability-transform-plugin.js";import{createNitro}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createProductionNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{createCompiledSandboxBackendPrunePlugin}from"#internal/nitro/host/compiled-sandbox-backend-prune-plugin.js";import{configureDevelopmentNitroRoutes,configureProductionNitroRoutes}from"#internal/nitro/host/configure-nitro-routes.js";import{applyEveCronHandlerRoute}from"#internal/nitro/host/cron-handler-route.js";import{createNitroBundlerConfig}from"#internal/nitro/host/nitro-bundler-config.js";import{OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME,createOptionalEngineDependencyPlugin}from"#internal/nitro/host/optional-engine-dependency-plugin.js";import{addNitroRoutingImportSpecifierPlugin}from"#internal/nitro/host/nitro-routing-import-specifier-plugin.js";import{registerScheduleTaskHandlers}from"#internal/nitro/host/schedule-task-routes.js";import{createEveVercelOptions}from"#internal/nitro/host/vercel-build-output-config.js";import{applyWorkflowTransform}from"#internal/workflow-bundle/workflow-builders.js";const WORKFLOW_ALIAS_SPECIFIERS=[`workflow`,`workflow/api`,`workflow/errors`,`workflow/internal/builtins`,`workflow/internal/private`,`workflow/runtime`],WORKFLOW_TRANSFORM_PATCHED=Symbol(`eve.workflow-transform-patched`),FRAMEWORK_HOSTED_EXTERNAL_PACKAGES=[`@napi-rs/keyring`],LOCAL_SANDBOX_BACKEND_NAMES=new Set([`docker`,...Object.keys(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME)]);function resolveWorkflowAliases(){let e={};for(let t of WORKFLOW_ALIAS_SPECIFIERS)e[t]=resolveWorkflowModulePath(t);return e}function resolveProductionNitroPreset(){return process.env.VERCEL?`vercel`:void 0}function manifestEnablesWorkflow(e){return[e,...e.subagents.map(e=>e.agent)].some(e=>e.workflowTool!==void 0)}function manifestHasWebSocketChannel(e){return e.channels.some(e=>e.kind===`channel`&&e.method===`WEBSOCKET`)}function collectHostedTraceDependencies(e,t){let n=[...e.compileResult.manifest.config.build?.externalDependencies??[],...e.compileResult.manifest.subagents.flatMap(e=>e.configResolver===void 0?e.agent.config.build?.externalDependencies??[]:e.configResolver.build?.externalDependencies??[])];return[...new Set([...FRAMEWORK_HOSTED_EXTERNAL_PACKAGES,...t,...n])].filter(e=>e!==EVE_PACKAGE_NAME)}function collectConfiguredSandboxBackendNames(e){let t=[e,...e.subagents.map(e=>e.agent)];return new Set(t.map(e=>e.sandbox?.backendName).filter(e=>typeof e==`string`))}function shouldPruneLocalSandboxBackends(e){return e.preset===`vercel`&&![...e.configuredBackendNames].some(e=>LOCAL_SANDBOX_BACKEND_NAMES.has(e))}function createDevelopmentWatchOptions(e){return{ignored:[e,join(e,`**`)]}}function normalizePath(e){return e.replaceAll(`\\`,`/`)}function stripPathQueryAndHash(e){let t=e.indexOf(`?`),n=e.indexOf(`#`),r=t===-1?n:n===-1?t:Math.min(t,n);return r===-1?e:e.slice(0,r)}function stripFileSystemPrefix(e){return e.startsWith(`/@fs/`)?e.slice(4):e}function resolveNitroModuleComparisonPath(e,t){return t.startsWith(`file://`)?normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(fileURLToPath(t)))):isAbsolute(t)?normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(t))):normalizePath(stripFileSystemPrefix(stripPathQueryAndHash(resolve(e,t))))}function isWorkflowBundlePath(e,t){let n=normalizePath(e);return n.startsWith(t)||n.includes(`/.eve/workflow-cache/`)}function normalizeStepTransformComparisonPath(e){let t=normalizePath(e);return process.platform===`win32`?t.toLowerCase():t}function parseImportedModuleSpecifiers(e){let t=/^\s*import\s+(?:.+?\s+from\s+)?["']([^"']+)["'];?\s*$/gm,n=[];for(let r of e.matchAll(t)){let e=r[1];e!==void 0&&n.push(e)}return n}function resolveNitroImportPath(e,n,r){return n.startsWith(`workflow`)?resolveWorkflowModulePath(n):n.startsWith(`.`)||n.startsWith(`/`)||n.startsWith(`file://`)?resolveNitroModuleComparisonPath(r===void 0?e:dirname(resolveNitroModuleComparisonPath(e,r)),n):null}async function collectNitroStepTransformTargets(t,n){let r=await readFile(t,`utf8`),i=new Set;for(let e of parseImportedModuleSpecifiers(r)){let r=resolveNitroImportPath(n,e,t);r!==null&&i.add(normalizeStepTransformComparisonPath(r))}return i}async function addNitroStepNoExternals(e,t){if(e.options.noExternals===!0)return;let n;try{n=await collectNitroStepTransformTargets(t,e.options.rootDir)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let r=Array.isArray(e.options.noExternals)?[...e.options.noExternals]:[];e.options.noExternals=[...new Set([...r,...n])]}function createRelativeTransformFilename(e,t){let n=createPackageRelativeTransformFilename(t);if(n!==void 0)return n;let r=normalizePath(e).replace(/\/$/,``),a=normalizePath(t),o=r.toLowerCase(),s=a.toLowerCase();if(s.startsWith(`${o}/`))return a.slice(r.length+1);if(s===o)return`.`;let c=relative(r,a).replaceAll(`\\`,`/`);if(c.startsWith(`../`)&&(c=c.split(`/`).filter(e=>e!==`..`).join(`/`)),c.includes(`:`)||c.startsWith(`/`)){let e=a.split(`/`).pop();return e===void 0||e.length===0?`unknown.ts`:e}return c}function createPackageRelativeTransformFilename(e){let t=normalizePath(resolvePackageRoot()).replace(/\/$/,``),n=normalizePath(e),r=t.toLowerCase(),i=n.toLowerCase(),a=`${t}/src/`,s=`${r}/src/`,c=`${t}/dist/src/`,l=`${r}/dist/src/`;if(i.startsWith(s))return`src/${n.slice(a.length)}`;if(i.startsWith(l))return`src/${n.slice(c.length)}`}function addWorkflowModuleSideEffectsPlugin(e,t){let n=[t,join(e.options.buildDir,`workflow`)].map(t=>resolveNitroModuleComparisonPath(e.options.rootDir,t));e.hooks.hook(`rollup:before`,(t,r)=>{Array.isArray(r.plugins)&&r.plugins.unshift({name:`eve:workflow-module-side-effects`,resolveId(t,r){let i=resolveNitroImportPath(e.options.rootDir,t,r)??resolveNitroModuleComparisonPath(e.options.rootDir,t);return n.some(e=>isWorkflowBundlePath(i,e))?{id:i,moduleSideEffects:`no-treeshake`}:null}})})}function addNitroStepModuleSideEffectsPlugin(e,t){let n=null,getStepTransformTargets=async()=>(n===null&&(n=await collectNitroStepTransformTargets(t.stepEntrypointPath,e.options.rootDir)),n),clearCachedStepTransformTargets=()=>{n=null};return e.hooks.hook(`build:before`,clearCachedStepTransformTargets),e.hooks.hook(`rollup:before`,(t,n)=>{Array.isArray(n.plugins)&&n.plugins.unshift({name:`eve:workflow-step-module-side-effects`,async resolveId(t,n){let r=resolveNitroImportPath(e.options.rootDir,t,n);return r===null||!(await getStepTransformTargets()).has(normalizeStepTransformComparisonPath(r))?null:{id:r,moduleSideEffects:`no-treeshake`}}})}),clearCachedStepTransformTargets}function addNitroStepTransformPlugin(e,t){let n=null,getStepTransformTargets=async()=>(n===null&&(n=await collectNitroStepTransformTargets(t.stepEntrypointPath,e.options.rootDir)),n),clearCachedStepTransformTargets=()=>{n=null};return e.hooks.hook(`build:before`,clearCachedStepTransformTargets),e.hooks.hook(`rollup:before`,(t,n)=>{Array.isArray(n.plugins)&&n.plugins.unshift({async transform(t,n){let r=await getStepTransformTargets(),i=resolveNitroModuleComparisonPath(e.options.rootDir,n);return r.has(normalizeStepTransformComparisonPath(i))?{code:(await applyWorkflowTransform(createRelativeTransformFilename(e.options.rootDir,i),t,`step`,i,e.options.rootDir)).code,map:null}:null},name:`eve:workflow-step-transform`})}),clearCachedStepTransformTargets}function addDynamicCapabilityTransformPlugin(e){e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift(createDynamicCapabilityTransformPlugin())})}function addInstrumentationModuleSideEffectsPlugin(e,t){let n=new Set(t.map(normalizePath));e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({name:`eve:instrumentation-module-side-effects`,resolveId(e){return n.has(normalizePath(e))?{id:e,moduleSideEffects:`no-treeshake`}:null}})})}function patchWorkflowTransformExcludePath(e,t){let n=normalizePath(t);e.hooks.hook(`rollup:before`,(e,t)=>{if(Array.isArray(t.plugins))for(let e of t.plugins){if(typeof e!=`object`||!e)continue;let t=e;if(t.name!==`workflow:transform`||t[WORKFLOW_TRANSFORM_PATCHED]===!0||typeof t.transform!=`function`)continue;let r=t.transform;t.transform=function(e,t,...i){return isWorkflowBundlePath(t,n)?null:r.call(this,e,t,...i)},t[WORKFLOW_TRANSFORM_PATCHED]=!0}})}function createApplicationNitroBundlerConfiguration(e,t){let n=collectConfiguredSandboxBackendNames(e.compileResult.manifest),r=shouldPruneLocalSandboxBackends({configuredBackendNames:n,preset:t})?createCompiledSandboxBackendPrunePlugin():null,i=[],a=[];for(let[e,t]of Object.entries(OPTIONAL_ENGINE_PACKAGES_BY_BACKEND_NAME))(n.has(e)?i:a).push(t);let o=createExtensionScopePlugin([e.compileResult.manifest,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.extensionMounts.map(e=>({sourceRoot:e.sourceRoot,packageNamespace:e.packageNamespace})))),s=[r,createOptionalEngineDependencyPlugin(a),o].filter(e=>e!==null);return{nitroRolldownConfig:createNitroBundlerConfig(s),nitroRollupConfig:createNitroBundlerConfig(s),tracedAppDependencies:collectHostedTraceDependencies(e,i)}}function createApplicationNitroPlugins(e){let t=[e.compiledArtifacts.bootstrapPath,e.compiledArtifacts.workflowWorldPluginPath];return manifestEnablesWorkflow(e.compileResult.manifest)&&t.push(resolvePackageSourceFilePath(`src/internal/nitro/host/workflow-sandbox-runtime-plugin.ts`)),e.compiledArtifacts.instrumentationPluginPath!==void 0&&t.push(e.compiledArtifacts.instrumentationPluginPath),t}function configureSharedApplicationNitro(e,t){addNitroRoutingImportSpecifierPlugin(e);let n=resolveWorkflowAliases();for(let[t,r]of Object.entries(n))e.options.alias[t]=r;addWorkflowModuleSideEffectsPlugin(e,t.workflowBuildDir),patchWorkflowTransformExcludePath(e,t.workflowBuildDir),addDynamicCapabilityTransformPlugin(e),t.compiledArtifacts.instrumentationSourcePaths!==void 0&&addInstrumentationModuleSideEffectsPlugin(e,t.compiledArtifacts.instrumentationSourcePaths)}function configureNitroStepPlugins(e,t){return[addNitroStepModuleSideEffectsPlugin(e,{stepEntrypointPath:t}),addNitroStepTransformPlugin(e,{stepEntrypointPath:t})]}function externalizeDevelopmentWorkflowBundle(e,t){let n=new Set([normalizePath(join(t.workflowBuildDir,`workflows.mjs`))]);e.hooks.hook(`rollup:before`,(e,t)=>{let r=t.external;t.external=(e,...t)=>{if(n.has(normalizePath(e)))return!0;if(typeof r==`function`)return r(e,...t)}})}async function createDevelopmentApplicationNitro(e){let t=e.workspace.nitroBuildDir,n=createApplicationNitroBundlerConfiguration(e,void 0),i=createApplicationNitroPlugins(e);e.compiledArtifacts.instrumentationPluginPath===void 0&&i.unshift(resolvePackageSourceFilePath(`src/internal/nitro/host/local-tracing-runtime-plugin.ts`)),await prepareEveVersionedCacheDirectory(t);let a=await createNitro({_cli:{command:`dev`},buildDir:t,dev:!0,features:{websocket:!0},logLevel:1,output:{dir:e.workspace.nitroOutputDir},plugins:i,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:n.nitroRolldownConfig,rollupConfig:n.nitroRollupConfig,rootDir:e.appRoot,serverDir:!1,traceDeps:n.tracedAppDependencies,vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:!1}),watchOptions:createDevelopmentWatchOptions(e.appRoot)},{watch:!0});await writeEveVersionedCacheMetadata(t);let o=join(a.options.buildDir,`workflow`,`steps.mjs`);configureSharedApplicationNitro(a,e);let l=configureNitroStepPlugins(a,o);return a.hooks.hook(`dev:reload`,()=>{for(let e of l)e()}),externalizeDevelopmentWorkflowBundle(a,e),await configureDevelopmentNitroRoutes(a,e),await addNitroStepNoExternals(a,o),a}async function createProductionApplicationNitro(e,t){let n=resolveProductionNitroPreset(),i=createApplicationNitroBundlerConfiguration(e,n),a=createApplicationNitroPlugins(e);a.push(resolvePackageSourceFilePath(`src/internal/nitro/host/sandbox-shutdown-plugin.ts`)),await prepareEveVersionedCacheDirectory(t.buildDir);let o=await createNitro({_cli:{command:`build`},buildDir:t.buildDir,dev:!1,features:{websocket:manifestHasWebSocketChannel(e.compileResult.manifest)},output:{dir:t.outputDir},preset:n,plugins:a,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:i.nitroRolldownConfig,rollupConfig:i.nitroRollupConfig,rootDir:e.appRoot,serverDir:!1,traceDeps:i.tracedAppDependencies,vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:n===`vercel`,publicRoutePrefix:t.publicRoutePrefix})});return await writeEveVersionedCacheMetadata(t.buildDir),configureSharedApplicationNitro(o,e),configureNitroStepPlugins(o,join(e.workflowBuildDir,`steps.mjs`)),e.scheduleRegistrations.length>0&&(applyEveCronHandlerRoute(o),registerScheduleTaskHandlers(o,{artifactsConfig:createProductionNitroArtifactsConfig(),dispatchModulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/schedule-task.ts`),registrations:e.scheduleRegistrations})),await configureProductionNitroRoutes(o,e),await addNitroStepNoExternals(o,join(e.workflowBuildDir,`steps.mjs`)),o}export{createDevelopmentApplicationNitro,createProductionApplicationNitro,shouldPruneLocalSandboxBackends};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getDevelopmentEnvironmentFilePaths}from"#cli/dev/environment.js";import{
|
|
1
|
+
import{getDevelopmentEnvironmentFilePaths}from"#cli/dev/environment.js";import{dirname,join,normalize,resolve,sep}from"node:path";import{existsSync}from"node:fs";import{toErrorMessage}from"#shared/errors.js";import{AUTHORED_ARTIFACTS_UPDATED_LOG_LINE,STRUCTURAL_RELOAD_LOG_LINE,formatChangeDetectedLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{resolveDevelopmentSourceSnapshotWatchPaths}from"#internal/nitro/dev-runtime-source-snapshot.js";import{resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";import{watch as watch$1}from"#compiled/chokidar/index.js";const WATCHED_LOCKFILE_NAMES=[`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`],WATCH_ROOT_MARKER_NAMES=[`.git`,`pnpm-workspace.yaml`],WATCHER_IGNORED_DIRECTORY_NAMES=new Set([`.devtools`,`.generated`,`.eve`,`.git`,`.next`,`.output`,`.turbo`,`.vercel`,`build`,`dist`,`node_modules`]);async function startAuthoredSourceWatcher(e){let t=e.preparedHost,n=!1,r=Promise.resolve(),i,a=!1,o=0,s=new Map,c=new Set,u=await resolveAuthoredWatchPaths(t),d=createWatchPathMap(u),f=watch$1(u,{awaitWriteFinish:{pollInterval:50,stabilityThreshold:160},followSymlinks:!1,ignoreInitial:!0,ignored:e=>shouldIgnoreWatcherPath(e,t.workspaceExtensions)}),p=waitForWatcherReady(f),rebuild=async(i,a=!1)=>{n||o>0||(r=r.then(async()=>{if(n)return;let r=[...s.values()];if(!i&&r.length===0)return;let o=[...c];s.clear(),c.clear();let l=t;!a&&r.length>0&&console.log(formatChangeDetectedLogLine(l.appRoot,r));try{let n=await e.coordinator.rebuild({changedPaths:o});t=n.host,a||(n.kind===`structural`?console.log(STRUCTURAL_RELOAD_LOG_LINE):console.log(AUTHORED_ARTIFACTS_UPDATED_LOG_LINE)),d=syncWatcherPaths({nextWatchPaths:await resolveAuthoredWatchPaths(t),previousWatchPathsByKey:d,watcher:f})}catch(e){console.error(`[eve:dev] rebuild failed: ${toErrorMessage(e)}`)}}).catch(e=>{console.error(`[eve:dev] rebuild queue error: ${toErrorMessage(e)}`)}),await r)},flush=async()=>{i!==void 0&&(clearTimeout(i),i=void 0),await rebuild(!1)},forceRebuild=async(e=!1)=>{i!==void 0&&(clearTimeout(i),i=void 0),await rebuild(!0,e)};return f.on(`all`,(e,t)=>{n||!a||e===`addDir`||e===`unlinkDir`||(s.set(`${e}:${t}`,{event:e,path:t}),c.add(t),i!==void 0&&clearTimeout(i),i=setTimeout(()=>{i=void 0,flush()},120))}),await p,a=!0,{async close(){n=!0,i!==void 0&&(clearTimeout(i),i=void 0),await f.close(),await r},flush,rebuild:forceRebuild,async suspend(){o+=1,i!==void 0&&(clearTimeout(i),i=void 0),await r},async resume(e){o!==0&&(--o,o===0&&await forceRebuild(e?.silent))}}}async function waitForWatcherReady(e){await new Promise((t,n)=>{e.on(`ready`,()=>{t()}),e.on(`error`,e=>{n(e)})})}async function resolveAuthoredWatchPaths(t){let r=new Set([t.compileResult.project.agentRoot,join(t.appRoot,`package.json`),join(t.appRoot,`jsconfig.json`),join(t.appRoot,`tsconfig.json`),join(t.appRoot,`tsconfig.*.json`)]),i=await resolveTsConfigWatchPaths(t.appRoot),a=await resolveDevelopmentSourceSnapshotWatchPaths(t.appRoot);for(let e of t.workspaceExtensions){r.add(e.config.sourceRoot);for(let t of e.buildConfigPaths)r.add(t)}for(let n of getDevelopmentEnvironmentFilePaths(t.appRoot))r.add(n);for(let e of a)r.add(e);for(let e of i)r.add(e);for(let e of resolveLockfileSearchDirectories(t.appRoot))for(let t of WATCHED_LOCKFILE_NAMES)r.add(join(e,t));return[...r].sort((e,t)=>e.localeCompare(t))}function createWatchPathMap(e){let t=new Map;for(let n of e)t.set(toWatchPathKey(n),n);return t}function syncWatcherPaths(e){let t=createWatchPathMap(e.nextWatchPaths),n=[],r=[];for(let[r,i]of t)e.previousWatchPathsByKey.has(r)||n.push(i);for(let[n,i]of e.previousWatchPathsByKey)t.has(n)||r.push(i);return n.length>0&&e.watcher.add(n),r.length>0&&e.watcher.unwatch(r),t}function toWatchPathKey(e){return normalize(resolve(e))}function resolveLockfileSearchDirectories(e){let n=resolve(e),r=[n],a=n;for(;;){if(hasWatchRootMarker(a))return r;let e=dirname(a);if(e===a)return[n];a=e,r.push(a)}}function hasWatchRootMarker(e){return WATCH_ROOT_MARKER_NAMES.some(t=>existsSync(join(e,t)))}async function resolveTsConfigWatchPaths(e){return await resolveTsConfigDependencyPaths(e)}function shouldIgnoreWatcherPath(e,t){return normalize(e).split(sep).filter(Boolean).some(e=>WATCHER_IGNORED_DIRECTORY_NAMES.has(e))||t.some(t=>isPathInsideOrEqual(e,t.config.outDir))}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{startAuthoredSourceWatcher};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolvePackageCompiledFilePath}from"#internal/application/package.js";import{existsSync}from"node:fs";import{Worker}from"node:worker_threads";import{BaseEnvRunner}from"#compiled/env-runner/index.js";var NodeDevelopmentRunner=class extends BaseEnvRunner{#e;#t=new Set;#n;constructor(t){let n=resolvePackageCompiledFilePath(`src/compiled/env-runner/node-worker.js`);super({data:{entry:t.entry,...t.workerData},hooks:{onClose:(e,t)=>{let n=[...this.#t];this.#t.clear();for(let e of n)e(t)}},name:t.name,workerEntry:n}),this._initWithVirtualData(()=>this.#
|
|
1
|
+
import{resolvePackageCompiledFilePath}from"#internal/application/package.js";import{existsSync}from"node:fs";import{Worker}from"node:worker_threads";import{BaseEnvRunner}from"#compiled/env-runner/index.js";var NodeDevelopmentRunner=class extends BaseEnvRunner{#e;#t=new Set;#n;#r;#i=!1;constructor(t){let n=resolvePackageCompiledFilePath(`src/compiled/env-runner/node-worker.js`);super({data:{entry:t.entry,...t.workerData},hooks:{onClose:(e,t)=>{let n=[...this.#t];this.#t.clear();for(let e of n)e(t)}},name:t.name,workerEntry:n}),this._initWithVirtualData(()=>this.#a())}onceClosed(e){if(this.closed){e(this.#e);return}this.#t.add(e)}sendMessage(e){if(this.#n===void 0)throw Error(`Development worker is not initialized.`);this.#n.postMessage(e)}async waitForReady(e){try{await super.waitForReady(e)}catch(e){throw this.#e===void 0?e:Error(`Development worker failed before readiness: ${this.#e instanceof Error?this.#e.message:String(this.#e)}`,{cause:this.#e})}}_hasRuntime(){return this.#n!==void 0}_runtimeType(){return`worker`}async _closeRuntime(){let e=this.#n;if(e===void 0)return;let t=this.#r;this.#n=void 0,this.#r=void 0;try{this.#i||e.postMessage({event:`shutdown`}),!this.#i&&t!==void 0&&!await waitForWorkerExit(t)&&await e.terminate()}finally{e.removeAllListeners()}}_handleMessage(e){isWorkerInitializationError(e)&&(this.#e=Error(e.error)),super._handleMessage(e)}#a(){if(!existsSync(this._workerEntry)){this.close(`Development worker entry not found at "${this._workerEntry}".`);return}let e=new Worker(this._workerEntry,{env:process.env,workerData:{name:this._name,...this._data}});this.#n=e,this.#i=!1;let r;this.#r=new Promise(e=>{r=e}),e.once(`error`,e=>{this.#e=e,this.close(e)}),e.once(`exit`,e=>{if(this.#i=!0,r(),!this.closed){let t=Error(`Development worker exited with code ${String(e)}.`);this.#e??=t,this.close(t)}}),e.on(`message`,e=>this._handleMessage(e))}};const createNodeDevelopmentRunner=e=>new NodeDevelopmentRunner(e);async function waitForWorkerExit(e){let t;try{return await Promise.race([e.then(()=>!0),new Promise(e=>{t=setTimeout(()=>e(!1),15e3),t.unref()})])}finally{clearTimeout(t)}}function isWorkerInitializationError(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.event===`init-error`&&typeof t.error==`string`}export{createNodeDevelopmentRunner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{realpath,stat}from"node:fs/promises";import{basename,dirname,join,resolve,sep}from"node:path";import{discoverExtensionMountDeclarations}from"#discover/discover-agent.js";import{buildExtensionPackage,tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{
|
|
1
|
+
import{realpath,stat}from"node:fs/promises";import{basename,dirname,join,resolve,sep}from"node:path";import{resolveDiscoveryProject}from"#discover/project.js";import{discoverExtensionMountDeclarations}from"#discover/discover-agent.js";import{buildExtensionPackage,tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{createDiskProjectSource}from"#discover/project-source.js";import{locateExtensionMountPackage}from"#discover/extensions.js";import{isAuthoredSourcePath,resolveDevelopmentSourceRoot}from"#internal/nitro/dev-runtime-source-snapshot.js";import{resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";async function prepareDevelopmentWorkspaceExtensions(e){let t=resolve(e.appRoot),n=await resolveDiscoveryProject(t),r=createDiskProjectSource(),i=await discoverExtensionMountGraph({agentRoot:n.agentRoot,source:r}),o=await toCanonicalPath(resolveDevelopmentSourceRoot(t)),c=new Map;for(let e of i){let n=await resolveWorkspaceExtension({appRoot:t,agentRoot:e.agentRoot,mount:e.mount,source:r,workspaceSourceRoot:o});n!==void 0&&c.set(n.packageRoot,n)}let l=[...c.values()].sort((e,t)=>e.packageRoot.localeCompare(t.packageRoot)),u=new Map(e.previousExtensions?.map(e=>[e.packageRoot,e])),d=e.changedPaths===void 0?void 0:await Promise.all(e.changedPaths.map(async e=>await toCanonicalPath(e))),f=e.previousExtensions===void 0||d?.length===0;return await Promise.all(l.map(async e=>{let t=u.get(e.packageRoot);(f===!0||t===void 0||!sameBuildInputs(t,e)||d?.some(t=>affectsExtensionBuild(t,e))===!0)&&await buildExtensionPackage(e.packageRoot,e.config)})),l}async function discoverExtensionMountGraph(e){let t=(await discoverExtensionMountDeclarations(e)).mounts.map(t=>({agentRoot:e.agentRoot,mount:t})),n=join(e.agentRoot,`subagents`);if(await e.source.stat(n)!==`directory`)return t;let r=await e.source.readDirectory(n),a=await Promise.all(r.filter(e=>e.isDirectory()).map(async t=>await discoverExtensionMountGraph({agentRoot:join(n,t.name),source:e.source})));return[...t,...a.flat()]}async function resolveWorkspaceExtension(n){let r=await locateExtensionMountPackage({source:n.source,agentRoot:n.agentRoot,appRoot:n.appRoot,mount:n.mount.mountRef,namespace:n.mount.namespace});if(r.location?.authoredSourceRoot===void 0)return;let o=await realpath(r.location.packageRoot).catch(()=>void 0);if(o===void 0||!isAuthoredSourcePath(o,n.workspaceSourceRoot))return;let s=await tryReadExtensionBuildConfig(o);if(s===null||(await stat(s.sourceRoot).catch(()=>void 0))?.isDirectory()!==!0)return;let c=[join(o,`package.json`),join(o,`tsconfig.json`),...await resolveTsConfigDependencyPaths(o)];return{config:s,packageRoot:o,buildConfigPaths:[...new Set(c.map(e=>resolve(e)))].sort((e,t)=>e.localeCompare(t))}}function affectsExtensionBuild(e,t){return isPathInsideOrEqual(e,t.config.sourceRoot)||t.buildConfigPaths.includes(e)}function sameBuildConfig(e,t){return e.sourceRoot===t.sourceRoot&&e.distRoot===t.distRoot&&e.outDir===t.outDir&&e.packageName===t.packageName&&e.shortName===t.shortName&&e.runtimeDependencies.length===t.runtimeDependencies.length&&e.runtimeDependencies.every((e,n)=>e===t.runtimeDependencies[n])}function sameBuildInputs(e,t){return sameBuildConfig(e.config,t.config)&&e.buildConfigPaths.length===t.buildConfigPaths.length&&e.buildConfigPaths.every((e,n)=>e===t.buildConfigPaths[n])}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}async function toCanonicalPath(t){let o=resolve(t),s=[];for(;;)try{return join(await realpath(o),...s.reverse())}catch{let e=dirname(o);if(e===o)return resolve(t);s.push(basename(o)),o=e}}export{prepareDevelopmentWorkspaceExtensions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join}from"node:path";import{compileInstructionsEntry}from"#compiler/normalize-instructions.js";import{compileSkillSource}from"#compiler/normalize-skill.js";import{compileToolEntry}from"#compiler/normalize-tool.js";import{loadAuthoredModuleNamespace}from"#internal/authored-module-loader.js";import{EXTENSION_CAPABILITY_VERSIONS}from"#compiler/extension-compatibility.js";import{extensionUsesState}from"#internal/nitro/host/extension-state-usage.js";async function deriveExtensionCapabilityRequirements(t){let n=new Set([`extension`]),r={externalDependencies:t.runtimeDependencies},[i,a,o,s,c]=await Promise.all([Promise.all(t.manifest.tools.map(e=>compileToolEntry(t.sourceRoot,e,r))),Promise.all(t.manifest.skills.map(e=>compileSkillSource(t.sourceRoot,e,r))),Promise.all(t.manifest.instructions.map(e=>compileInstructionsEntry(t.sourceRoot,e,r))),loadAuthoredModuleNamespace(join(t.sourceRoot,t.declarationModule.logicalPath),{externalDependencies:t.runtimeDependencies}),extensionUsesState(t.sourceRoot)]);i.length>0&&n.add(`tool`),i.some(e=>e.kind===`dynamic-tool`)&&n.add(`dynamicTool`),t.manifest.connections.length>0&&n.add(`connection`),t.manifest.hooks.length>0&&n.add(`hook`),a.length>0&&n.add(`skill`),a.some(e=>e.kind===`dynamic-skill`)&&n.add(`dynamicSkill`),o.length>0&&n.add(`instructions`),o.some(e=>e.kind===`dynamic-instructions`)&&n.add(`dynamicInstructions`);let l=s[t.declarationModule.exportName??`default`];return(typeof l==`function`||typeof l==`object`&&l)&&`schema`in l&&l.schema!==void 0&&n.add(`config`),c&&n.add(`state`),Object.fromEntries(Object.keys(EXTENSION_CAPABILITY_VERSIONS).filter(e=>n.has(e)).map(e=>[e,EXTENSION_CAPABILITY_VERSIONS[e]]))}export{deriveExtensionCapabilityRequirements};
|
|
1
|
+
import{join}from"node:path";import{compileInstructionsEntry}from"#compiler/normalize-instructions.js";import{compileSkillSource}from"#compiler/normalize-skill.js";import{compileToolEntry}from"#compiler/normalize-tool.js";import{loadAuthoredModuleNamespace}from"#internal/authored-module-loader.js";import{EXTENSION_CAPABILITY_VERSIONS}from"#compiler/extension-compatibility.js";import{extensionUsesState}from"#internal/nitro/host/extension-state-usage.js";async function deriveExtensionCapabilityRequirements(t){let n=new Set([`extension`]),r={externalDependencies:t.runtimeDependencies},[i,a,o,s,c]=await Promise.all([Promise.all(t.manifest.tools.map(e=>compileToolEntry(t.sourceRoot,e,r))),Promise.all(t.manifest.skills.map(e=>compileSkillSource(t.sourceRoot,e,r))),Promise.all(t.manifest.instructions.map(e=>compileInstructionsEntry(t.sourceRoot,e,r))),loadAuthoredModuleNamespace(join(t.sourceRoot,t.declarationModule.logicalPath),{externalDependencies:t.runtimeDependencies}),extensionUsesState(t.sourceRoot)]);i.length>0&&n.add(`tool`),i.some(e=>e.kind===`dynamic-tool`)&&n.add(`dynamicTool`),t.manifest.channels.length>0&&n.add(`channel`),t.manifest.connections.length>0&&n.add(`connection`),t.manifest.hooks.length>0&&n.add(`hook`),t.manifest.schedules.length>0&&n.add(`schedule`),a.length>0&&n.add(`skill`),a.some(e=>e.kind===`dynamic-skill`)&&n.add(`dynamicSkill`),o.length>0&&n.add(`instructions`),o.some(e=>e.kind===`dynamic-instructions`)&&n.add(`dynamicInstructions`);let l=s[t.declarationModule.exportName??`default`];return(typeof l==`function`||typeof l==`object`&&l)&&`schema`in l&&l.schema!==void 0&&n.add(`config`),c&&n.add(`state`),Object.fromEntries(Object.keys(EXTENSION_CAPABILITY_VERSIONS).filter(e=>n.has(e)).map(e=>[e,EXTENSION_CAPABILITY_VERSIONS[e]]))}export{deriveExtensionCapabilityRequirements};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{
|
|
1
|
+
import{basename}from"node:path";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{DEVELOPMENT_WORKER_APP_ROOT_ENV}from"#internal/workflow/development-world-protocol.js";import{installLocalInstrumentationRuntime}from"#tracing/local-instrumentation-runtime.js";const appRoot=process.env[DEVELOPMENT_WORKER_APP_ROOT_ENV];if(appRoot===void 0)throw Error(`${DEVELOPMENT_WORKER_APP_ROOT_ENV} is required for local tracing.`);const runtime=installLocalInstrumentationRuntime({appRoot,frameworkVersion:resolveInstalledPackageInfo().version,serviceName:basename(appRoot)});function installLocalTracingRuntimePlugin(e){e?.hooks?.hook(`close`,()=>runtime.shutdown())}export{installLocalTracingRuntimePlugin as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createNodeEsmCompatBannerPlugin}from"#internal/node-esm-compat-banner.js";function normalizePath(e){return e.replaceAll(`\\`,`/`)}function isNodeModulesPath(e){return normalizePath(e).split(`/`).includes(`node_modules`)}function hasPathSegments(e,t){let n=normalizePath(e).split(`/`).filter(Boolean);return n.some((e,r)=>t.every((e,t)=>n[r+t]===e))}function isCompiledVendorPath(e){return hasPathSegments(e,[`.generated`,`compiled`])||hasPathSegments(e,[`dist`,`src`,`compiled`])}function getLogFilePaths(e){if(typeof e!=`object`||!e)return[];let t=e,n=Array.isArray(t.ids)?t.ids:[];return[t.id,...n,t.loc?.file
|
|
1
|
+
import{createNodeEsmCompatBannerPlugin}from"#internal/node-esm-compat-banner.js";function normalizePath(e){return e.replaceAll(`\\`,`/`)}function isNodeModulesPath(e){return normalizePath(e).split(`/`).includes(`node_modules`)}function hasPathSegments(e,t){let n=normalizePath(e).split(`/`).filter(Boolean);return n.some((e,r)=>t.every((e,t)=>n[r+t]===e))}function isCompiledVendorPath(e){return hasPathSegments(e,[`.generated`,`compiled`])||hasPathSegments(e,[`dist`,`src`,`compiled`])}function getLogFilePaths(e){if(typeof e!=`object`||!e)return[];let t=e,n=Array.isArray(t.ids)?t.ids:[];return[t.id,...n,t.loc?.file].filter(e=>typeof e==`string`)}function isVendoredDependencyWarning(e){let t=getLogFilePaths(e);return t.length>0&&t.every(e=>isNodeModulesPath(e)||isCompiledVendorPath(e))}function onNitroBundlerLog(e,t,n){e===`warn`&&isVendoredDependencyWarning(t)||n(e,t)}function createNitroBundlerConfig(t){return{onLog:onNitroBundlerLog,plugins:[createNodeEsmCompatBannerPlugin(),...t]}}export{createNitroBundlerConfig};
|