eve 0.6.0-beta.3 → 0.6.0-beta.4
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 +7 -0
- package/README.md +2 -2
- package/dist/docs/public/advanced/auth-and-route-protection.md +1 -1
- package/dist/docs/public/channels/eve.mdx +1 -1
- package/dist/docs/public/getting-started.mdx +4 -4
- package/dist/src/cli/commands/channels.js +1 -1
- package/dist/src/execution/eve-workflow-attributes.d.ts +7 -6
- package/dist/src/execution/eve-workflow-attributes.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/tsconfig-dependencies.d.ts +23 -0
- package/dist/src/internal/application/tsconfig-dependencies.js +1 -0
- package/dist/src/internal/nitro/dev-runtime-artifacts.d.ts +8 -3
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.d.ts +2 -0
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.js +1 -0
- package/dist/src/internal/nitro/dev-runtime-source-snapshot.d.ts +31 -0
- package/dist/src/internal/nitro/dev-runtime-source-snapshot.js +1 -0
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
- package/dist/src/packages/eve-scaffold/src/channels.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# eve
|
|
2
2
|
|
|
3
|
+
## 0.6.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2aec0cf: Raise the derived `$eve.title` cap (`EVE_SESSION_TITLE_MAX_CHARS`) from 80 to 125 code points so Agent Runs titles keep more of the original prompt.
|
|
8
|
+
- 5b69978: Fix `eve dev` source snapshots so monorepo-relative config paths and local workspace package links keep resolving from immutable dev-runtime snapshots.
|
|
9
|
+
|
|
3
10
|
## 0.6.0-beta.3
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -105,12 +105,12 @@ export default defineAgent({
|
|
|
105
105
|
## Quick Start
|
|
106
106
|
|
|
107
107
|
```bash
|
|
108
|
-
pnpm create eve
|
|
108
|
+
pnpm create eve@beta
|
|
109
109
|
cd my-agent
|
|
110
110
|
pnpm dev
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
The wizard scaffolds the project, picks a model, and (for the REPL channel) installs dependencies and starts the dev server for you. To scaffold into the current empty directory, run `pnpm create eve .`.
|
|
113
|
+
The wizard scaffolds the project, picks a model, and (for the REPL channel) installs dependencies and starts the dev server for you. To scaffold into the current empty directory, run `pnpm create eve@beta .`.
|
|
114
114
|
|
|
115
115
|
CLI commands:
|
|
116
116
|
|
|
@@ -184,7 +184,7 @@ export default defineChannel({
|
|
|
184
184
|
|
|
185
185
|
## Replace `placeholderAuth` before production
|
|
186
186
|
|
|
187
|
-
`pnpm create eve` sometimes scaffolds `agent/channels/eve.ts` with a `placeholderAuth()` guardrail:
|
|
187
|
+
`pnpm create eve@beta` sometimes scaffolds `agent/channels/eve.ts` with a `placeholderAuth()` guardrail:
|
|
188
188
|
|
|
189
189
|
```ts
|
|
190
190
|
import { eveChannel } from "eve/channels/eve";
|
|
@@ -36,7 +36,7 @@ The `auth` option decides who can call these routes. The built-in helpers are me
|
|
|
36
36
|
|
|
37
37
|
Neither admits browser users or external clients in production. For a public app, wire the channel to your own auth (Clerk, Auth.js, or your own OIDC/JWT verification).
|
|
38
38
|
|
|
39
|
-
`pnpm create eve` scaffolds an `agent/channels/eve.ts` with a production placeholder so you replace it before going live. The generated channel allows Vercel OIDC and localhost, and includes `placeholderAuth()`, which returns a setup-focused 401 in production until you swap it for real auth. Delete the file and Eve falls back to `[localDev(), vercelOidc()]`, which still does not admit browser users in production.
|
|
39
|
+
`pnpm create eve@beta` scaffolds an `agent/channels/eve.ts` with a production placeholder so you replace it before going live. The generated channel allows Vercel OIDC and localhost, and includes `placeholderAuth()`, which returns a setup-focused 401 in production until you swap it for real auth. Delete the file and Eve falls back to `[localDev(), vercelOidc()]`, which still does not admit browser users in production.
|
|
40
40
|
|
|
41
41
|
For the full auth model and helper list, see [Auth & route protection](../advanced/auth-and-route-protection).
|
|
42
42
|
|
|
@@ -25,7 +25,7 @@ The wizard asks for a model and which channel you want (Web Chat or Slack). You
|
|
|
25
25
|
To add Eve to an existing app instead:
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
pnpm add
|
|
28
|
+
pnpm add eve@beta
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
## What's In Your Project
|
|
@@ -153,9 +153,9 @@ See [Sessions, runs & streaming](./advanced/sessions-runs-and-streaming) for the
|
|
|
153
153
|
|
|
154
154
|
If a coding agent (Claude Code, Cursor, and the like) is doing the setup, hand it this prompt:
|
|
155
155
|
|
|
156
|
-
<CopyPrompt text="Set up an Eve agent for the user. Eve is a filesystem-first TypeScript framework for durable agents, published as the npm package eve. Read its docs: once eve is installed they are bundled in the package at node_modules/eve/dist/docs/public; before eve is installed, read the published Introduction and Getting Started pages. If the project has no Eve app, scaffold one with `pnpm create eve`; to add Eve to an existing app, run `pnpm add eve`. Make sure agent/agent.ts (which sets the model) and agent/instructions.md exist, then add a first typed tool at agent/tools/get_weather.ts using defineTool from eve/tools with a Zod inputSchema and an inline execute. Run it locally with `pnpm dev` (or `eve dev`), then exercise the HTTP API: create a session with POST /eve/v1/session, attach to GET /eve/v1/session/:id/stream, and send a follow-up with the returned continuationToken. Verify with the project's typecheck, adapt model and provider choices to the project, and do not commit unless the user asks.">
|
|
156
|
+
<CopyPrompt text="Set up an Eve agent for the user. Eve is a filesystem-first TypeScript framework for durable agents, published as the npm package eve. Read its docs: once eve is installed they are bundled in the package at node_modules/eve/dist/docs/public; before eve is installed, read the published Introduction and Getting Started pages. If the project has no Eve app, scaffold one with `pnpm create eve@beta`; to add Eve to an existing app, run `pnpm add eve@beta`. Make sure agent/agent.ts (which sets the model) and agent/instructions.md exist, then add a first typed tool at agent/tools/get_weather.ts using defineTool from eve/tools with a Zod inputSchema and an inline execute. Run it locally with `pnpm dev` (or `eve dev`), then exercise the HTTP API: create a session with POST /eve/v1/session, attach to GET /eve/v1/session/:id/stream, and send a follow-up with the returned continuationToken. Verify with the project's typecheck, adapt model and provider choices to the project, and do not commit unless the user asks.">
|
|
157
157
|
Set up an Eve agent: read the Eve docs (bundled at node_modules/eve/dist/docs/public once eve is
|
|
158
|
-
installed), scaffold with `pnpm create eve` (or `pnpm add eve` in an existing app), add a typed
|
|
158
|
+
installed), scaffold with `pnpm create eve@beta` (or `pnpm add eve@beta` in an existing app), add a typed
|
|
159
159
|
tool at agent/tools/get_weather.ts, run it with `pnpm dev`, then create a session, stream it, and
|
|
160
160
|
send a follow-up.
|
|
161
161
|
</CopyPrompt>
|
|
@@ -164,7 +164,7 @@ Once `eve` is a dependency, the full docs are bundled in the package, so the age
|
|
|
164
164
|
|
|
165
165
|
- Docs: `node_modules/eve/dist/docs/public/`
|
|
166
166
|
|
|
167
|
-
To scaffold a project end to end, `pnpm create eve` collects the decisions (name, model, channels), runs setup, adds Slack interactively with `eve channels add slack`, and verifies the result with `eve info --json`.
|
|
167
|
+
To scaffold a project end to end, `pnpm create eve@beta` collects the decisions (name, model, channels), runs setup, adds Slack interactively with `eve channels add slack`, and verifies the result with `eve info --json`.
|
|
168
168
|
|
|
169
169
|
## What to read next
|
|
170
170
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertCanAddSelectedChannels,inspectExistingChannelRegistrations}from"./channel-add-conflicts.js";import{isEveProject}from"../../packages/eve-scaffold/src/project.js";import{listAuthoredChannels}from"../../packages/eve-scaffold/src/channels.js";import"../../packages/eve-scaffold/src/index.js";import{detectDeployment}from"../../packages/eve-scaffold/src/primitives/detect-deployment.js";import{createAddToAgentState,deployProject,runAddToAgent}from"../../packages/eve-scaffold/src/steps/run-add-to-agent.js";import"../../packages/eve-scaffold/src/steps/index.js";import{ChannelAddCancelledError,createChannelAddPrompter}from"../../packages/eve-scaffold/src/cli/channel-add-prompter.js";import"../../packages/eve-scaffold/src/cli/index.js";import"../../packages/eve-scaffold/src/primitives/index.js";const NOT_AN_AGENT_MESSAGE="No Eve agent in this directory. Run `pnpm create eve`, then run this command from inside the new project.",KNOWN_CHANNEL_KINDS=[`slack`,`web`];function isChannelKind(e){return KNOWN_CHANNEL_KINDS.includes(e)}function parseChannelKind(e){if(!isChannelKind(e))throw Error(`Unknown channel kind "${e}". Known: ${KNOWN_CHANNEL_KINDS.join(`, `)}.`);return e}const defaultChannelsAddDependencies={detectDeployment,deployProject,runAddToAgent};async function runAddChannelsFlow(n,r,i,o){if(r===void 0&&(i.yes||!process.stdin.isTTY||!process.stdout.isTTY))throw Error(`Pass a channel kind: \`eve channels add <${KNOWN_CHANNEL_KINDS.join(`|`)}>\`.`);let s=o.createPrompter?.()??createChannelAddPrompter();s.intro(`Add channels to your Eve agent`),s.log.message(`Checking the current Vercel project...`);let c=createAddToAgentState(await o.detectDeployment(n)),l;function inspectRegistrations(){return l===void 0&&(s.log.message(`Inspecting existing channel registrations...`),l=inspectExistingChannelRegistrations(n)),l}let u=r===void 0?(await inspectRegistrations()).disabledChannelReasons:void 0;c=await o.runAddToAgent({prompter:s,projectPath:n,state:c,presetChannels:r===void 0?void 0:[r],presetCreateSlackbot:i.yes?!0:void 0,disabledChannelReasons:u,force:i.force,validateSelectedChannels:async t=>{!t.includes(`web`)&&!t.includes(`slack`)||assertCanAddSelectedChannels(t,await inspectRegistrations())}}),c=await o.deployProject({prompter:s,projectPath:n,state:c}),s.outro(c.channels.length===0?`No channels added.`:`Channels added.`)}async function runChannelsAddCommand(e,t,r,i=defaultChannelsAddDependencies){if(!await isEveProject(t)){e.error(NOT_AN_AGENT_MESSAGE),process.exitCode=1;return}try{await runAddChannelsFlow(t,r.kind===void 0?void 0:parseChannelKind(r.kind),r.options,i)}catch(t){if(t instanceof ChannelAddCancelledError)return;e.error(t instanceof Error?t.message:String(t)),process.exitCode=1}}async function runChannelsListCommand(e,t,i){if(!await isEveProject(t)){e.error(NOT_AN_AGENT_MESSAGE),process.exitCode=1;return}let a=await listAuthoredChannels(t);if(i.json){e.log(JSON.stringify({channels:a},null,2));return}if(a.length===0){e.log("No channels defined. Run `eve channels add` to add one.");return}for(let t of a)e.log(t)}export{runChannelsAddCommand,runChannelsListCommand};
|
|
1
|
+
import{assertCanAddSelectedChannels,inspectExistingChannelRegistrations}from"./channel-add-conflicts.js";import{isEveProject}from"../../packages/eve-scaffold/src/project.js";import{listAuthoredChannels}from"../../packages/eve-scaffold/src/channels.js";import"../../packages/eve-scaffold/src/index.js";import{detectDeployment}from"../../packages/eve-scaffold/src/primitives/detect-deployment.js";import{createAddToAgentState,deployProject,runAddToAgent}from"../../packages/eve-scaffold/src/steps/run-add-to-agent.js";import"../../packages/eve-scaffold/src/steps/index.js";import{ChannelAddCancelledError,createChannelAddPrompter}from"../../packages/eve-scaffold/src/cli/channel-add-prompter.js";import"../../packages/eve-scaffold/src/cli/index.js";import"../../packages/eve-scaffold/src/primitives/index.js";const NOT_AN_AGENT_MESSAGE="No Eve agent in this directory. Run `pnpm create eve@beta`, then run this command from inside the new project.",KNOWN_CHANNEL_KINDS=[`slack`,`web`];function isChannelKind(e){return KNOWN_CHANNEL_KINDS.includes(e)}function parseChannelKind(e){if(!isChannelKind(e))throw Error(`Unknown channel kind "${e}". Known: ${KNOWN_CHANNEL_KINDS.join(`, `)}.`);return e}const defaultChannelsAddDependencies={detectDeployment,deployProject,runAddToAgent};async function runAddChannelsFlow(n,r,i,o){if(r===void 0&&(i.yes||!process.stdin.isTTY||!process.stdout.isTTY))throw Error(`Pass a channel kind: \`eve channels add <${KNOWN_CHANNEL_KINDS.join(`|`)}>\`.`);let s=o.createPrompter?.()??createChannelAddPrompter();s.intro(`Add channels to your Eve agent`),s.log.message(`Checking the current Vercel project...`);let c=createAddToAgentState(await o.detectDeployment(n)),l;function inspectRegistrations(){return l===void 0&&(s.log.message(`Inspecting existing channel registrations...`),l=inspectExistingChannelRegistrations(n)),l}let u=r===void 0?(await inspectRegistrations()).disabledChannelReasons:void 0;c=await o.runAddToAgent({prompter:s,projectPath:n,state:c,presetChannels:r===void 0?void 0:[r],presetCreateSlackbot:i.yes?!0:void 0,disabledChannelReasons:u,force:i.force,validateSelectedChannels:async t=>{!t.includes(`web`)&&!t.includes(`slack`)||assertCanAddSelectedChannels(t,await inspectRegistrations())}}),c=await o.deployProject({prompter:s,projectPath:n,state:c}),s.outro(c.channels.length===0?`No channels added.`:`Channels added.`)}async function runChannelsAddCommand(e,t,r,i=defaultChannelsAddDependencies){if(!await isEveProject(t)){e.error(NOT_AN_AGENT_MESSAGE),process.exitCode=1;return}try{await runAddChannelsFlow(t,r.kind===void 0?void 0:parseChannelKind(r.kind),r.options,i)}catch(t){if(t instanceof ChannelAddCancelledError)return;e.error(t instanceof Error?t.message:String(t)),process.exitCode=1}}async function runChannelsListCommand(e,t,i){if(!await isEveProject(t)){e.error(NOT_AN_AGENT_MESSAGE),process.exitCode=1;return}let a=await listAuthoredChannels(t);if(i.json){e.log(JSON.stringify({channels:a},null,2));return}if(a.length===0){e.log("No channels defined. Run `eve channels add` to add one.");return}for(let t of a)e.log(t)}export{runChannelsAddCommand,runChannelsListCommand};
|
|
@@ -73,13 +73,14 @@ export declare function readRootSessionId(serializedContext: Record<string, unkn
|
|
|
73
73
|
/**
|
|
74
74
|
* Maximum visible length (in code points) of a derived `$eve.title`.
|
|
75
75
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
76
|
+
* Titles render as the first column of the dashboard's run table, so
|
|
77
|
+
* they get a tighter, display-oriented cap here than the generic
|
|
78
|
+
* runtime byte budget (`EVE_ATTRIBUTE_VALUE_MAX_BYTES`). Mostly-ASCII
|
|
79
|
+
* titles stay within that budget; a title dominated by multi-byte
|
|
80
|
+
* characters may still be further truncated by the runtime tag
|
|
81
|
+
* truncator, which is acceptable.
|
|
81
82
|
*/
|
|
82
|
-
export declare const EVE_SESSION_TITLE_MAX_CHARS =
|
|
83
|
+
export declare const EVE_SESSION_TITLE_MAX_CHARS = 125;
|
|
83
84
|
/**
|
|
84
85
|
* Derives the `$eve.title` value from the first user message of a
|
|
85
86
|
* top-level session.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isNonEmptyString}from"#shared/guards.js";function readChannelKind(t){let n=t[`eve.channel`]?.kind;return isNonEmptyString(n)?n:void 0}function readParentLineage(t){let n=t[`eve.parentSession`],r=n?.callId,i=n?.rootSessionId,a=n?.sessionId,o=n?.turn?.id;return{callId:isNonEmptyString(r)?r:void 0,rootSessionId:isNonEmptyString(i)?i:void 0,sessionId:isNonEmptyString(a)?a:void 0,turnId:isNonEmptyString(o)?o:void 0}}function readParentSessionId(e){return readParentLineage(e).sessionId}function readRootSessionId(e){return readParentLineage(e).rootSessionId}const EVE_SESSION_TITLE_MAX_CHARS=
|
|
1
|
+
import{isNonEmptyString}from"#shared/guards.js";function readChannelKind(t){let n=t[`eve.channel`]?.kind;return isNonEmptyString(n)?n:void 0}function readParentLineage(t){let n=t[`eve.parentSession`],r=n?.callId,i=n?.rootSessionId,a=n?.sessionId,o=n?.turn?.id;return{callId:isNonEmptyString(r)?r:void 0,rootSessionId:isNonEmptyString(i)?i:void 0,sessionId:isNonEmptyString(a)?a:void 0,turnId:isNonEmptyString(o)?o:void 0}}function readParentSessionId(e){return readParentLineage(e).sessionId}function readRootSessionId(e){return readParentLineage(e).rootSessionId}const EVE_SESSION_TITLE_MAX_CHARS=125;function deriveSessionTitle(e){let t=collectMessageText(e);if(t===void 0||t.length===0)return;let n=t.replace(/\s+/gu,` `).trim();if(n.length===0)return;let r=Array.from(n);return r.length<=125?n:`${r.slice(0,124).join(``)}…`}function collectMessageText(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return;let t=[];for(let n of e)n&&typeof n==`object`&&n.type===`text`&&typeof n.text==`string`&&t.push(n.text);return t.length>0?t.join(` `):void 0}function buildSessionAttributes(e){return{"$eve.type":`session`,"$eve.trigger":readChannelKind(e.serializedContext),"$eve.title":deriveSessionTitle(e.inputMessage)}}function buildSubagentRootAttributes(e){return{"$eve.type":`subagent`,"$eve.parent":e.parentSessionId,"$eve.parent_call":e.parentCallId,"$eve.parent_turn":e.parentTurnId,"$eve.root":e.rootSessionId,"$eve.subagent":e.identity.nodeId,"$eve.trigger":readChannelKind(e.serializedContext)}}function buildTurnAttributes(e){return{"$eve.type":`turn`,"$eve.parent":e.parentSessionId,"$eve.root":e.rootSessionId}}export{EVE_SESSION_TITLE_MAX_CHARS,buildSessionAttributes,buildSubagentRootAttributes,buildTurnAttributes,deriveSessionTitle,readChannelKind,readParentLineage,readParentSessionId,readRootSessionId};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const WORKFLOW_MODULE_ALIASES={"workflow/api":`src/compiled/@workflow/core/runtime.js`,"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`,"workflow/runtime":`src/compiled/@workflow/core/runtime.js`};function resolveFallbackPackageVersion(){return`0.6.0-beta.
|
|
1
|
+
import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const WORKFLOW_MODULE_ALIASES={"workflow/api":`src/compiled/@workflow/core/runtime.js`,"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`,"workflow/runtime":`src/compiled/@workflow/core/runtime.js`};function resolveFallbackPackageVersion(){return`0.6.0-beta.4`}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let t=e;for(;;){if(existsSync(join(t,`package.json`))&&!isBuildOutputPackageRoot(t))return t;let r=dirname(t);if(r===t)throw Error(`Failed to resolve package root from "${e}".`);t=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveInstalledPackageInfo,resolvePackageDependencyPath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves every local tsconfig/jsconfig file that can affect bundling from
|
|
3
|
+
* one package root: root configs plus their extends chain.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveTsConfigDependencyPaths(appRoot: string): Promise<string[]>;
|
|
6
|
+
export declare function resolveRootTsConfigPaths(appRoot: string): Promise<string[]>;
|
|
7
|
+
export declare function collectTsConfigDependencyPaths(input: {
|
|
8
|
+
readonly configPath: string;
|
|
9
|
+
readonly resolvedConfigPaths: Set<string>;
|
|
10
|
+
readonly visitingConfigPaths: Set<string>;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
export declare function readTextFileIfExists(path: string): Promise<string | undefined>;
|
|
13
|
+
export declare function parseTsConfigObject(source: string): Record<string, unknown> | undefined;
|
|
14
|
+
export declare function extractTsConfigExtendsSpecifiers(source: string): string[];
|
|
15
|
+
export declare function resolveTsConfigExtendsTargetPaths(input: {
|
|
16
|
+
readonly configPath: string;
|
|
17
|
+
readonly extendsSpecifier: string;
|
|
18
|
+
}): string[];
|
|
19
|
+
export declare function resolveFirstExistingTsConfigExtendsTarget(input: {
|
|
20
|
+
readonly configPath: string;
|
|
21
|
+
readonly extendsSpecifier: string;
|
|
22
|
+
}): string | undefined;
|
|
23
|
+
export declare function isTsConfigFilePath(specifier: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire}from"node:module";import{dirname,isAbsolute,join,resolve}from"node:path";import{readFile,readdir}from"node:fs/promises";import{existsSync}from"node:fs";import{parse}from"#compiled/jsonc-parser/index.js";async function resolveTsConfigDependencyPaths(e){let t=await resolveRootTsConfigPaths(e),n=new Set,r=new Set;for(let e of t)await collectTsConfigDependencyPaths({configPath:e,resolvedConfigPaths:n,visitingConfigPaths:r});return[...n].sort((e,t)=>e.localeCompare(t))}async function resolveRootTsConfigPaths(e){let t=new Set([join(e,`tsconfig.json`),join(e,`jsconfig.json`)]);try{let n=await readdir(e,{withFileTypes:!0});for(let i of n)i.isFile()&&/^tsconfig\..+\.json$/i.test(i.name)&&t.add(join(e,i.name))}catch{}return[...t]}async function collectTsConfigDependencyPaths(e){let t=resolve(e.configPath);if(e.resolvedConfigPaths.has(t)||e.visitingConfigPaths.has(t))return;let n=await readTextFileIfExists(t);if(n!==void 0){e.resolvedConfigPaths.add(t),e.visitingConfigPaths.add(t);try{let r=extractTsConfigExtendsSpecifiers(n);for(let n of r)for(let r of resolveTsConfigExtendsTargetPaths({configPath:t,extendsSpecifier:n}))await collectTsConfigDependencyPaths({configPath:r,resolvedConfigPaths:e.resolvedConfigPaths,visitingConfigPaths:e.visitingConfigPaths})}finally{e.visitingConfigPaths.delete(t)}}}async function readTextFileIfExists(e){try{return await readFile(e,`utf8`)}catch{return}}function parseTsConfigObject(e){let t=[],n=parse(e,t,{allowTrailingComma:!0});if(!(t.length>0||typeof n!=`object`||!n||Array.isArray(n)))return n}function extractTsConfigExtendsSpecifiers(e){let t=parseTsConfigObject(e);if(t===void 0)return[];let n=t.extends;return typeof n==`string`?n.length>0?[n]:[]:Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}function resolveTsConfigExtendsTargetPaths(e){let t=new Set;if(isTsConfigFilePath(e.extendsSpecifier))for(let n of resolveFileExtendsCandidates({configPath:e.configPath,extendsSpecifier:e.extendsSpecifier}))t.add(n);else for(let n of resolvePackageExtendsCandidates({configPath:e.configPath,extendsSpecifier:e.extendsSpecifier}))t.add(n);return[...t]}function resolveFirstExistingTsConfigExtendsTarget(e){for(let t of resolveTsConfigExtendsTargetPaths(e))if(existsSync(t))return t}function resolveFileExtendsCandidates(e){let n=resolve(dirname(e.configPath),e.extendsSpecifier),a=new Set;return a.add(n),n.endsWith(`.json`)||(a.add(`${n}.json`),a.add(join(n,`tsconfig.json`))),[...a]}function resolvePackageExtendsCandidates(t){let n=new Set([t.extendsSpecifier]);t.extendsSpecifier.endsWith(`.json`)||(n.add(`${t.extendsSpecifier}.json`),n.add(`${t.extendsSpecifier}/tsconfig.json`));let r=new Set,i=createRequire(t.configPath);for(let e of n)try{r.add(i.resolve(e))}catch{}return[...r]}function isTsConfigFilePath(e){return e.startsWith(`.`)||isAbsolute(e)?!0:/^[A-Za-z]:[\\/]/.test(e)}export{collectTsConfigDependencyPaths,extractTsConfigExtendsSpecifiers,isTsConfigFilePath,parseTsConfigObject,readTextFileIfExists,resolveFirstExistingTsConfigExtendsTarget,resolveRootTsConfigPaths,resolveTsConfigDependencyPaths,resolveTsConfigExtendsTargetPaths};
|
|
@@ -2,6 +2,11 @@ import type { CompileAgentResult } from "#compiler/compile-agent.js";
|
|
|
2
2
|
export interface DevelopmentRuntimeArtifactsRevision {
|
|
3
3
|
readonly revision: string;
|
|
4
4
|
}
|
|
5
|
+
export interface DevelopmentRuntimeArtifactsSnapshot {
|
|
6
|
+
readonly runtimeAppRoot: string;
|
|
7
|
+
readonly snapshotRoot: string;
|
|
8
|
+
readonly snapshotSourceRoot: string;
|
|
9
|
+
}
|
|
5
10
|
/**
|
|
6
11
|
* Resolves the dev-server pointer that records the latest runtime artifact
|
|
7
12
|
* snapshot for new sessions.
|
|
@@ -10,17 +15,17 @@ export declare function resolveDevelopmentRuntimeArtifactsPointerPath(appRoot: s
|
|
|
10
15
|
/**
|
|
11
16
|
* Publishes one immutable dev runtime snapshot and points future sessions at it.
|
|
12
17
|
*/
|
|
13
|
-
export declare function publishDevelopmentRuntimeArtifactsSnapshot(compileResult: CompileAgentResult): Promise<
|
|
18
|
+
export declare function publishDevelopmentRuntimeArtifactsSnapshot(compileResult: CompileAgentResult): Promise<DevelopmentRuntimeArtifactsSnapshot>;
|
|
14
19
|
/**
|
|
15
20
|
* Stages one immutable dev runtime snapshot without moving the latest pointer.
|
|
16
21
|
*/
|
|
17
|
-
export declare function stageDevelopmentRuntimeArtifactsSnapshot(compileResult: CompileAgentResult): Promise<
|
|
22
|
+
export declare function stageDevelopmentRuntimeArtifactsSnapshot(compileResult: CompileAgentResult): Promise<DevelopmentRuntimeArtifactsSnapshot>;
|
|
18
23
|
/**
|
|
19
24
|
* Moves the dev runtime pointer so future sessions use a staged snapshot.
|
|
20
25
|
*/
|
|
21
26
|
export declare function activateDevelopmentRuntimeArtifactsSnapshot(input: {
|
|
22
27
|
readonly appRoot: string;
|
|
23
|
-
readonly
|
|
28
|
+
readonly snapshot: DevelopmentRuntimeArtifactsSnapshot;
|
|
24
29
|
}): Promise<void>;
|
|
25
30
|
/**
|
|
26
31
|
* Reads the latest dev runtime snapshot root when the dev server has one.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{basename,dirname,join,relative}from"node:path";import{cp,mkdir,readFile,
|
|
1
|
+
import{basename,dirname,join,relative,resolve,sep}from"node:path";import{cp,mkdir,readFile,rename,rm,writeFile}from"node:fs/promises";import{existsSync,readFileSync}from"node:fs";import{randomUUID}from"node:crypto";import{copyDevelopmentSourceSnapshot}from"#internal/nitro/dev-runtime-source-snapshot-copy.js";import{createDevelopmentSourceSnapshotPlan}from"#internal/nitro/dev-runtime-source-snapshot.js";const DEV_RUNTIME_ARTIFACTS_DIRECTORY=`dev-runtime`;function resolveDevelopmentRuntimeArtifactsPointerPath(e){return join(e,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`current.json`)}async function publishDevelopmentRuntimeArtifactsSnapshot(e){let t=await stageDevelopmentRuntimeArtifactsSnapshot(e);return await activateDevelopmentRuntimeArtifactsSnapshot({appRoot:e.project.appRoot,snapshot:t}),t}async function stageDevelopmentRuntimeArtifactsSnapshot(e){let t=join(e.project.appRoot,`.eve`,DEV_RUNTIME_ARTIFACTS_DIRECTORY,`snapshots`,`${Date.now().toString(36)}-${randomUUID()}`),r=await createDevelopmentSourceSnapshotPlan({appRoot:e.project.appRoot,snapshotRoot:t});return await copyDevelopmentSourceSnapshot(r),await cp(e.paths.compileDirectoryPath,join(r.runtimeAppRoot,`.eve`,`compile`),{recursive:!0}),await rewriteSnapshotCompiledManifest({appRoot:e.project.appRoot,manifestPath:join(r.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:r.runtimeAppRoot}),await validateSnapshotCompiledManifestRoots({manifestPath:join(r.runtimeAppRoot,`.eve`,`compile`,`compiled-agent-manifest.json`),runtimeAppRoot:r.runtimeAppRoot}),{runtimeAppRoot:r.runtimeAppRoot,snapshotRoot:t,snapshotSourceRoot:r.snapshotSourceRoot}}async function activateDevelopmentRuntimeArtifactsSnapshot(e){await writeDevelopmentRuntimeArtifactsPointer(e)}function readDevelopmentRuntimeArtifactsSnapshotRoot(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?t.appRoot:t.version===2&&typeof t.runtimeAppRoot==`string`&&t.runtimeAppRoot.length>0?t.runtimeAppRoot:void 0}catch{return}}function readDevelopmentRuntimeArtifactsRevision(e){return{revision:readDevelopmentRuntimeArtifactsSnapshotRoot(resolveDevelopmentRuntimeArtifactsPointerPath(e))??e}}async function rewriteSnapshotCompiledManifest(e){let t=JSON.parse(await readFile(e.manifestPath,`utf8`)),n=rewriteManifestRoots({appRoot:e.appRoot,runtimeAppRoot:e.runtimeAppRoot,value:t});await writeFile(e.manifestPath,`${JSON.stringify(n,null,2)}\n`)}function rewriteManifestRoots(e){if(Array.isArray(e.value))return e.value.map(t=>rewriteManifestRoots({...e,value:t}));if(e.value===null||typeof e.value!=`object`)return e.value;let t={};for(let[n,r]of Object.entries(e.value)){if(typeof r==`string`&&(n===`appRoot`||n===`agentRoot`)){t[n]=rewritePathWithinAppRoot({appRoot:e.appRoot,path:r,runtimeAppRoot:e.runtimeAppRoot});continue}t[n]=rewriteManifestRoots({appRoot:e.appRoot,runtimeAppRoot:e.runtimeAppRoot,value:r})}return t}function rewritePathWithinAppRoot(t){let i=relative(t.appRoot,t.path);return i.startsWith(`..`)||i.length===0||basename(i)===``?t.path===t.appRoot?t.runtimeAppRoot:t.path:join(t.runtimeAppRoot,i)}async function writeDevelopmentRuntimeArtifactsPointer(e){let n=resolveDevelopmentRuntimeArtifactsPointerPath(e.appRoot),r=`${n}.${randomUUID()}.tmp`,i={appRoot:e.appRoot,kind:`eve-dev-runtime-artifacts-pointer`,runtimeAppRoot:e.snapshot.runtimeAppRoot,snapshotRoot:e.snapshot.snapshotRoot,version:2};await mkdir(dirname(n),{recursive:!0}),await writeFile(r,`${JSON.stringify(i,null,2)}\n`);try{await rename(r,n)}catch(e){throw await rm(r,{force:!0}).catch(()=>{}),e}}async function validateSnapshotCompiledManifestRoots(e){let t=collectManifestRootPaths(JSON.parse(await readFile(e.manifestPath,`utf8`)));for(let n of t)if(!isPathInsideOrEqual(n,e.runtimeAppRoot))throw Error(`Development runtime snapshot manifest root "${n}" is outside runtime app root "${e.runtimeAppRoot}".`)}function collectManifestRootPaths(e){if(Array.isArray(e))return e.flatMap(e=>collectManifestRootPaths(e));if(typeof e!=`object`||!e)return[];let t=[];for(let[n,r]of Object.entries(e)){if((n===`appRoot`||n===`agentRoot`)&&typeof r==`string`){t.push(r);continue}t.push(...collectManifestRootPaths(r))}return t}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}export{activateDevelopmentRuntimeArtifactsSnapshot,publishDevelopmentRuntimeArtifactsSnapshot,readDevelopmentRuntimeArtifactsRevision,readDevelopmentRuntimeArtifactsSnapshotRoot,resolveDevelopmentRuntimeArtifactsPointerPath,stageDevelopmentRuntimeArtifactsSnapshot};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dirname,join,relative,resolve,sep}from"node:path";import{cp,lstat,mkdir,readFile,readdir,symlink,writeFile}from"node:fs/promises";import{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([`.eve`,`.git`,`.output`,`.turbo`,`.vercel`,`.workflow-data`,`node_modules`]);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 createSnapshotSymlinks(e),await validateDevelopmentSourceSnapshot(e)}async function copySnapshotPath(t){try{if((await lstat(t.sourcePath)).isDirectory()){await copySnapshotDirectory(t);return}await mkdir(dirname(t.targetPath),{recursive:!0}),await cp(t.sourcePath,t.targetPath,{recursive:!0})}catch(e){throw new DevelopmentRuntimeSourceSnapshotError(`Failed to copy development runtime source snapshot path "${t.sourcePath}" to "${t.targetPath}": ${formatErrorMessage(e)}`)}}async function copySnapshotDirectory(e){await mkdir(e.targetPath,{recursive:!0});for(let n of await readdir(e.sourcePath,{withFileTypes:!0})){let r=join(e.sourcePath,n.name);shouldSkipSnapshotSource(e.plan.sourceRoot,r)||await cp(r,join(e.targetPath,n.name),{filter:t=>!shouldSkipSnapshotSource(e.plan.sourceRoot,t),recursive:!0})}}function shouldSkipSnapshotSource(e,t){let r=relative(e,t);return r.length===0?!1:r.split(/[\\/]/).some(e=>SNAPSHOT_SKIP_NAMES.has(e))}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 createSnapshotSymlinks(t){for(let r of t.symlinks){let i=toSnapshotPathForPlan(t,r.linkPath),a=r.targetKind===`local`?toSnapshotPathForPlan(t,r.targetPath):r.targetPath,o=r.targetKind===`local`?relative(dirname(i),a)||`.`:a;await mkdir(dirname(i),{recursive:!0}),await symlink(o,i,`junction`)}}async function validateDevelopmentSourceSnapshot(e){let n=join(e.runtimeAppRoot,`package.json`);if(!existsSync(n))throw new DevelopmentRuntimeSourceSnapshotError(`Development runtime source snapshot is missing the runtime app package.json at "${n}".`);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),a=resolve(t);return n===a||n.startsWith(`${a}${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};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const DEV_RUNTIME_SOURCE_DIRECTORY = "source";
|
|
2
|
+
export declare class DevelopmentRuntimeSourceSnapshotError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export interface DevelopmentSourceSnapshotPlan {
|
|
6
|
+
readonly appRoot: string;
|
|
7
|
+
readonly copyFiles: readonly string[];
|
|
8
|
+
readonly copyRoots: readonly string[];
|
|
9
|
+
readonly runtimeAppRoot: string;
|
|
10
|
+
readonly snapshotRoot: string;
|
|
11
|
+
readonly snapshotSourceRoot: string;
|
|
12
|
+
readonly sourceRoot: string;
|
|
13
|
+
readonly symlinks: readonly DevelopmentSourceSnapshotSymlink[];
|
|
14
|
+
readonly tsconfigPaths: readonly string[];
|
|
15
|
+
readonly watchPaths: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
export interface DevelopmentSourceSnapshotSymlink {
|
|
18
|
+
readonly linkPath: string;
|
|
19
|
+
readonly targetKind: "external" | "local";
|
|
20
|
+
readonly targetPath: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function createDevelopmentSourceSnapshotPlan(input: {
|
|
23
|
+
readonly appRoot: string;
|
|
24
|
+
readonly snapshotRoot: string;
|
|
25
|
+
}): Promise<DevelopmentSourceSnapshotPlan>;
|
|
26
|
+
export declare function resolveDevelopmentSourceSnapshotWatchPaths(appRoot: string): Promise<string[]>;
|
|
27
|
+
export declare function toDevelopmentSourceSnapshotPath(input: {
|
|
28
|
+
readonly snapshotSourceRoot: string;
|
|
29
|
+
readonly sourcePath: string;
|
|
30
|
+
readonly sourceRoot: string;
|
|
31
|
+
}): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dirname,join,relative,resolve,sep}from"node:path";import{lstat,readlink,realpath}from"node:fs/promises";import{existsSync}from"node:fs";import{parseTsConfigObject,readTextFileIfExists,resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.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 n=resolve(e.appRoot),i=resolve(e.snapshotRoot),a=resolveDevelopmentSourceRoot(n),o=join(i,DEV_RUNTIME_SOURCE_DIRECTORY),s={appRoot:n,copyFiles:new Set,copyRoots:new Set,localRootsToProcess:[n],processedLocalRoots:new Set,snapshotRoot:i,snapshotSourceRoot:o,sourceRoot:a,symlinksByLinkPath:new Map,tsconfigPaths:new Set};for(addWorkspaceMetadataFiles(s);s.localRootsToProcess.length>0;){let e=s.localRootsToProcess.shift();if(e===void 0)continue;let t=resolve(e);s.processedLocalRoots.has(t)||!isAuthoredSourcePath(t,a)||(s.processedLocalRoots.add(t),s.copyRoots.add(t),await addTsConfigDependenciesForRoot(s,t),await addDependencySymlinksForRoot(s,t))}let c=normalizeCopyRoots([...s.copyRoots]),l=[...s.copyFiles].filter(e=>isPathInsideOrEqual(e,a)).sort((e,t)=>e.localeCompare(t)),u=[...s.tsconfigPaths].filter(e=>isPathInsideOrEqual(e,a)).sort((e,t)=>e.localeCompare(t)),d=[...s.symlinksByLinkPath.values()].sort((e,t)=>e.linkPath.localeCompare(t.linkPath)),f=createWatchPaths({appRoot:n,copyFiles:l,copyRoots:c,sourceRoot:a,symlinks:d,tsconfigPaths:u});return{appRoot:n,copyFiles:l,copyRoots:c,runtimeAppRoot:toSnapshotPath({sourcePath:n,sourceRoot:a,snapshotSourceRoot:o}),snapshotRoot:i,snapshotSourceRoot:o,sourceRoot:a,symlinks:d,tsconfigPaths:u,watchPaths:f}}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(n){let i=resolve(n);for(;;){if(SOURCE_ROOT_MARKER_NAMES.some(e=>existsSync(join(i,e))))return i;let a=dirname(i);if(a===i)return resolve(n);i=a}}function addWorkspaceMetadataFiles(e){for(let n of WORKSPACE_METADATA_FILE_NAMES){let r=join(e.sourceRoot,n);existsSync(r)&&e.copyFiles.add(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}))enqueueLocalRoot(e,n)}}async function addDependencySymlinksForRoot(e,t){let n=await readPackageDependencyNames(t);for(let r of n)for(let n of[t,e.sourceRoot])await addDependencySymlink(e,joinNodeModulesPackagePath(n,r))}async function addDependencySymlink(e,t){let n;try{n=await lstat(t)}catch{return}if(!n.isSymbolicLink())return;let i=await resolveSymlinkTargetPathCandidates(t),o=i.find(t=>isAuthoredSourcePath(t,e.sourceRoot));if(o!==void 0){await addLocalDependencySymlink({linkPath:t,state:e,targetPath:o});return}let s=i.find(e=>existsSync(e));s!==void 0&&e.symlinksByLinkPath.set(resolve(t),{linkPath:resolve(t),targetKind:`external`,targetPath:s})}async function addLocalDependencySymlink(e){let t=await resolveNearestPackageRoot(e.targetPath,e.state.sourceRoot);if(t===void 0||!isAuthoredSourcePath(t,e.state.sourceRoot))return;let{state:n}=e;enqueueLocalRoot(n,t),n.symlinksByLinkPath.set(resolve(e.linkPath),{linkPath:resolve(e.linkPath),targetKind:`local`,targetPath:t})}async function resolveSymlinkTargetPathCandidates(t){let n=new Set;try{let i=await readlink(t);n.add(resolve(dirname(t),i))}catch{}try{n.add(await realpath(t))}catch{}return[...n]}function enqueueLocalRoot(e,t){let n=resolve(t);e.processedLocalRoots.has(n)||e.localRootsToProcess.includes(n)||!isAuthoredSourcePath(n,e.sourceRoot)||e.localRootsToProcess.push(n)}async function readPackageDependencyNames(e){let n=await readTextFileIfExists(join(e,`package.json`));if(n===void 0)return[];let r;try{r=JSON.parse(n)}catch{return[]}if(!isObjectRecord(r))return[];let i=new Set;for(let e of PACKAGE_DEPENDENCY_FIELDS){let t=r[e];if(isObjectRecord(t))for(let e of Object.keys(t))i.add(e)}return[...i].sort((e,t)=>e.localeCompare(t))}async function resolveLocalTsConfigPathTargetRoots(t){let n=await readTextFileIfExists(t.configPath);if(n===void 0)return[];let i=parseTsConfigObject(n),a=isObjectRecord(i?.compilerOptions)?i.compilerOptions:void 0,o=isObjectRecord(a?.paths)?a.paths:void 0;if(a===void 0||o===void 0)return[];let s=typeof a.baseUrl==`string`?resolve(dirname(t.configPath),a.baseUrl):dirname(t.configPath),c=new Set;for(let e of Object.values(o))if(Array.isArray(e))for(let n of e){if(typeof n!=`string`||n.length===0)continue;let e=await resolveLocalTsConfigPathTargetRoot({baseDirectory:s,sourceRoot:t.sourceRoot,target:n});e!==void 0&&c.add(e)}return[...c].sort((e,t)=>e.localeCompare(t))}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 i=resolve(e.baseDirectory,n);if(!isAuthoredSourcePath(i,e.sourceRoot))return;let a=await resolveExistingPathOrAncestor({path:i,stopDirectory:e.sourceRoot});if(a===void 0)return;let o=await resolveNearestPackageRoot(a,e.sourceRoot);if(o!==void 0&&o!==e.sourceRoot)return o;if(!t)return a===e.sourceRoot?void 0:a}async function resolveExistingPathOrAncestor(t){let n=resolve(t.path);for(;isAuthoredSourcePath(n,t.stopDirectory);){if(existsSync(n))return n;let t=dirname(n);if(t===n)return;n=t}}async function resolveNearestPackageRoot(n,i){let o=resolve(n);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 n=dirname(o);if(n===o)return;o=n}}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 n=new Set([join(e.appRoot,`package.json`),...e.copyFiles,...e.tsconfigPaths]);for(let t of e.copyRoots)t!==e.appRoot&&n.add(t);for(let t of e.symlinks)n.add(t.linkPath),t.targetKind===`local`&&t.targetPath!==e.appRoot&&n.add(t.targetPath);if(e.sourceRoot!==e.appRoot)for(let r of WORKSPACE_METADATA_FILE_NAMES){let i=join(e.sourceRoot,r);existsSync(i)&&n.add(i)}return[...n].sort((e,t)=>e.localeCompare(t))}function joinNodeModulesPackagePath(e,n){return join(e,`node_modules`,...n.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 isPathInsideOrEqual(e,t){let n=resolve(e),a=resolve(t);return n===a||n.startsWith(`${a}${sep}`)}function isAuthoredSourcePath(e,t){return isPathInsideOrEqual(e,t)?!relative(t,e).split(/[\\/]/).includes(`node_modules`):!1}function isObjectRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{DEV_RUNTIME_SOURCE_DIRECTORY,DevelopmentRuntimeSourceSnapshotError,createDevelopmentSourceSnapshotPlan,resolveDevelopmentSourceSnapshotWatchPaths,toDevelopmentSourceSnapshotPath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{dirname,join,resolve}from"node:path";import{existsSync}from"node:fs";import{toErrorMessage}from"#shared/errors.js";import{getDevelopmentEnvironmentFilePaths,loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{clearCompiledRuntimeAgentBundleCache}from"#runtime/sessions/compiled-agent-cache.js";import{resolveDevelopmentSourceSnapshotWatchPaths}from"#internal/nitro/dev-runtime-source-snapshot.js";import{resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";import{prepareApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{createNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{computeChannelRouteRegistrations,syncChannelVirtualHandlers}from"#internal/nitro/host/channel-routes.js";import{watch}from"#compiled/chokidar/index.js";import{resolveNitroCompiledArtifactsSource}from"#internal/nitro/routes/runtime-artifacts.js";import{prewarmAppSandboxes}from"#execution/sandbox/prewarm.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_PATTERNS=[`**/.eve/**`,`**/.git/**`,`**/.output/**`,`**/.turbo/**`,`**/.vercel/**`,`**/.workflow-data/**`,`**/node_modules/**`];async function startAuthoredSourceWatcher(e){let t=e.preparedHost,n=!1,r=Promise.resolve(),a,o=new Set,s=new Set,l=await resolveAuthoredWatchPaths(t),u=createWatchPathMap(l),d=watch(l,{awaitWriteFinish:{pollInterval:50,stabilityThreshold:160},followSymlinks:!1,ignoreInitial:!0,ignored:WATCHER_IGNORED_PATTERNS}),f=waitForWatcherReady(d),flush=()=>{n||(r=r.then(async()=>{if(n)return;let r=o.size,a=[...s];o.clear(),s.clear();let c=t,l=hasDevelopmentEnvironmentFileChange(c.appRoot,a);console.log(`[eve:dev] change detected (${r} event${r===1?``:`s`}), rebuilding authored artifacts...`);try{l&&loadDevelopmentEnvironmentFiles(c.appRoot);let n=await prepareApplicationHost(c.appRoot,{dev:e.nitro.options.dev===!0}),r=createNitroArtifactsConfig({appRoot:n.appRoot,dev:e.nitro.options.dev===!0});await prewarmAppSandboxes({appRoot:n.appRoot,compiledArtifactsSource:resolveNitroCompiledArtifactsSource(r),log:e=>console.log(e)});let i=syncChannelVirtualHandlers(e.nitro,{artifactsConfig:r,next:computeChannelRouteRegistrations(n),previous:computeChannelRouteRegistrations(c)});clearCompiledRuntimeAgentBundleCache(),t=n,i||l?(console.log(`[eve:dev] structural change detected, reloading Nitro worker...`),await e.nitro.hooks.callHook(`rollup:reload`)):console.log(`[eve:dev] authored artifacts updated.`),u=syncWatcherPaths({nextWatchPaths:await resolveAuthoredWatchPaths(n),previousWatchPathsByKey:u,watcher:d})}catch(e){console.error(`[eve:dev] rebuild failed: ${toErrorMessage(e)}`)}}).catch(e=>{console.error(`[eve:dev] rebuild queue error: ${toErrorMessage(e)}`)}))};return d.on(`all`,(e,t)=>{n||(o.add(`${e}:${t}`),s.add(t),a!==void 0&&clearTimeout(a),a=setTimeout(()=>{a=void 0,flush()},120))}),await f,{async close(){n=!0,a!==void 0&&(clearTimeout(a),a=void 0),await d.close(),await r}}}async function waitForWatcherReady(e){await new Promise((t,n)=>{e.on(`ready`,()=>{t()}),e.on(`error`,e=>{n(e)})})}async function resolveAuthoredWatchPaths(e){let n=new Set([e.compileResult.project.agentRoot,join(e.appRoot,`package.json`),join(e.appRoot,`jsconfig.json`),join(e.appRoot,`tsconfig.json`),join(e.appRoot,`tsconfig.*.json`)]),r=await resolveTsConfigWatchPaths(e.appRoot),i=await resolveDevelopmentSourceSnapshotWatchPaths(e.appRoot);for(let t of getDevelopmentEnvironmentFilePaths(e.appRoot))n.add(t);for(let e of i)n.add(e);for(let e of r)n.add(e);for(let r of resolveLockfileSearchDirectories(e.appRoot))for(let e of WATCHED_LOCKFILE_NAMES)n.add(join(r,e));return[...n].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 e.replaceAll(`\\`,`/`)}function hasDevelopmentEnvironmentFileChange(e,t){let r=new Set(getDevelopmentEnvironmentFilePaths(e).map(e=>toWatchPathKey(resolve(e))));return t.some(e=>r.has(toWatchPathKey(resolve(e))))}function resolveLockfileSearchDirectories(t){let r=resolve(t),i=[r],a=r;for(;;){if(hasWatchRootMarker(a))return i;let t=dirname(a);if(t===a)return[r];a=t,i.push(a)}}function hasWatchRootMarker(e){return WATCH_ROOT_MARKER_NAMES.some(n=>existsSync(join(e,n)))}async function resolveTsConfigWatchPaths(e){return await resolveTsConfigDependencyPaths(e)}export{startAuthoredSourceWatcher};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile}from"node:fs/promises";import{resolveWorkflowBuildDirectory}from"#internal/application/paths.js";import{createAuthoredSourceRuntimeCompiledArtifactsSource}from"#internal/application/runtime-compiled-artifacts-source.js";import{resolveRuntimeCompilerArtifactPaths}from"#runtime/loaders/artifact-paths.js";import{activateDevelopmentRuntimeArtifactsSnapshot,stageDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts.js";import{createScheduleRegistrations}from"#runtime/schedules/register.js";import{loadResolvedCompiledSchedules}from"#runtime/schedules/resolve-schedule.js";import{compileAgent}from"#compiler/compile-agent.js";import{writeCompiledArtifactsFiles}from"#internal/application/compiled-artifacts.js";async function prepareApplicationHost(e,t={}){let n=await compileAgent({startPath:e}),r=await loadResolvedCompiledSchedules({compiledArtifactsSource:createAuthoredSourceRuntimeCompiledArtifactsSource(n.project.appRoot)}),i=createScheduleRegistrations(r),a=resolveWorkflowBuildDirectory(n.project.appRoot),o=t.dev===!0?await stageDevelopmentRuntimeArtifactsSnapshot(n):
|
|
1
|
+
import{readFile}from"node:fs/promises";import{resolveWorkflowBuildDirectory}from"#internal/application/paths.js";import{createAuthoredSourceRuntimeCompiledArtifactsSource}from"#internal/application/runtime-compiled-artifacts-source.js";import{resolveRuntimeCompilerArtifactPaths}from"#runtime/loaders/artifact-paths.js";import{activateDevelopmentRuntimeArtifactsSnapshot,stageDevelopmentRuntimeArtifactsSnapshot}from"#internal/nitro/dev-runtime-artifacts.js";import{createScheduleRegistrations}from"#runtime/schedules/register.js";import{loadResolvedCompiledSchedules}from"#runtime/schedules/resolve-schedule.js";import{compileAgent}from"#compiler/compile-agent.js";import{writeCompiledArtifactsFiles}from"#internal/application/compiled-artifacts.js";async function prepareApplicationHost(e,t={}){let n=await compileAgent({startPath:e}),r=await loadResolvedCompiledSchedules({compiledArtifactsSource:createAuthoredSourceRuntimeCompiledArtifactsSource(n.project.appRoot)}),i=createScheduleRegistrations(r),a=resolveWorkflowBuildDirectory(n.project.appRoot),o=t.dev===!0?await stageDevelopmentRuntimeArtifactsSnapshot(n):void 0,s=resolveRuntimeCompilerArtifactPaths(o===void 0?n.project.appRoot:o.runtimeAppRoot),c=await writeCompiledArtifactsFiles({compileResult:t.dev===!0?{...n,manifest:JSON.parse(await readFile(s.compiledManifestPath,`utf8`))}:n,outDir:s.compileDirectoryPath});return o!==void 0&&await activateDevelopmentRuntimeArtifactsSnapshot({appRoot:n.project.appRoot,snapshot:o}),{appRoot:n.project.appRoot,compileResult:n,compiledArtifacts:c,scheduleRegistrations:i,schedules:r,workflowBuildDir:a}}export{prepareApplicationHost};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{getSupportedModuleBaseName,matchesSupportedModuleBaseName}from"./module-files.js";import{pathExists,writeTextFile}from"./files.js";import{PNPM_WORKSPACE_PATH,ensurePnpmWorkspacePolicy}from"./pnpm-workspace.js";import{WEB_APP_TEMPLATE_FILES,WEB_APP_TEMPLATE_PACKAGE_JSON}from"./web-template.js";import"./project.js";import{patchPackageJson}from"./package-json.js";import{basename,join,resolve}from"node:path";import{readFile,readdir,writeFile}from"node:fs/promises";const SLACK_CHANNEL_DEFAULT_ROUTE=`/eve/v1/slack`,DEFAULT_SLACK_CONNECTOR_SLUG=`my-agent`,PACKAGE_DEPENDENCY_FIELDS=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`],WEB_NEXT_CONFIG_PATH=`next.config.ts`,WEB_VERCEL_JSON_PATH=`vercel.json`,WEB_VERCEL_JSON_SCHEMA=`https://openapi.vercel.sh/vercel.json`,WEB_COMPETING_NEXT_CONFIG_PATHS=[`next.config.js`,`next.config.mjs`,WEB_NEXT_CONFIG_PATH,`next.config.mts`].filter(e=>e!==WEB_NEXT_CONFIG_PATH),WEB_DEFAULT_VERCEL_SERVICES={web:{entrypoint:`.`,framework:`nextjs`,routePrefix:`/`},eve:{buildCommand:`eve build`,entrypoint:`.`,framework:`eve`,routePrefix:`/_eve_internal/eve`}};function toSlackConnectorSlug(e){return e}function isJsonObject(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function readDependencyVersion(e,t){let n=JSON.parse(await readFile(e,`utf8`));if(!isJsonObject(n)||!isJsonObject(n.dependencies))return;let r=n.dependencies[t];return typeof r==`string`?r:void 0}function packageJsonHasDependency(e,t){for(let n of PACKAGE_DEPENDENCY_FIELDS){let r=e[n];if(isJsonObject(r)&&typeof r[t]==`string`)return!0}return!1}async function hasPackageDependency(e,t){if(!await pathExists(e))return!1;let r=JSON.parse(await readFile(e,`utf8`));return isJsonObject(r)&&packageJsonHasDependency(r,t)}async function ensurePackageDependency(e,t,r){return!await pathExists(e)||await readDependencyVersion(e,t)===r?[]:(await patchPackageJson(e,{dependencies:{[t]:r}}),[{path:e,dependencies:[t],devDependencies:[],scripts:[]}])}function resolveWebPackageVersions(e){return{evePackageVersion:e?.evePackageVersion??`0.6.0-beta.
|
|
1
|
+
import{getSupportedModuleBaseName,matchesSupportedModuleBaseName}from"./module-files.js";import{pathExists,writeTextFile}from"./files.js";import{PNPM_WORKSPACE_PATH,ensurePnpmWorkspacePolicy}from"./pnpm-workspace.js";import{WEB_APP_TEMPLATE_FILES,WEB_APP_TEMPLATE_PACKAGE_JSON}from"./web-template.js";import"./project.js";import{patchPackageJson}from"./package-json.js";import{basename,join,resolve}from"node:path";import{readFile,readdir,writeFile}from"node:fs/promises";const SLACK_CHANNEL_DEFAULT_ROUTE=`/eve/v1/slack`,DEFAULT_SLACK_CONNECTOR_SLUG=`my-agent`,PACKAGE_DEPENDENCY_FIELDS=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`],WEB_NEXT_CONFIG_PATH=`next.config.ts`,WEB_VERCEL_JSON_PATH=`vercel.json`,WEB_VERCEL_JSON_SCHEMA=`https://openapi.vercel.sh/vercel.json`,WEB_COMPETING_NEXT_CONFIG_PATHS=[`next.config.js`,`next.config.mjs`,WEB_NEXT_CONFIG_PATH,`next.config.mts`].filter(e=>e!==WEB_NEXT_CONFIG_PATH),WEB_DEFAULT_VERCEL_SERVICES={web:{entrypoint:`.`,framework:`nextjs`,routePrefix:`/`},eve:{buildCommand:`eve build`,entrypoint:`.`,framework:`eve`,routePrefix:`/_eve_internal/eve`}};function toSlackConnectorSlug(e){return e}function isJsonObject(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function readDependencyVersion(e,t){let n=JSON.parse(await readFile(e,`utf8`));if(!isJsonObject(n)||!isJsonObject(n.dependencies))return;let r=n.dependencies[t];return typeof r==`string`?r:void 0}function packageJsonHasDependency(e,t){for(let n of PACKAGE_DEPENDENCY_FIELDS){let r=e[n];if(isJsonObject(r)&&typeof r[t]==`string`)return!0}return!1}async function hasPackageDependency(e,t){if(!await pathExists(e))return!1;let r=JSON.parse(await readFile(e,`utf8`));return isJsonObject(r)&&packageJsonHasDependency(r,t)}async function ensurePackageDependency(e,t,r){return!await pathExists(e)||await readDependencyVersion(e,t)===r?[]:(await patchPackageJson(e,{dependencies:{[t]:r}}),[{path:e,dependencies:[t],devDependencies:[],scripts:[]}])}function resolveWebPackageVersions(e){return{evePackageVersion:e?.evePackageVersion??`0.6.0-beta.4`,aiPackageVersion:e?.aiPackageVersion??`7.0.0-canary.165`,nextPackageVersion:e?.nextPackageVersion??`16.2.6`,reactPackageVersion:e?.reactPackageVersion??`19.2.6`,reactDomPackageVersion:e?.reactDomPackageVersion??`19.2.6`,streamdownPackageVersion:e?.streamdownPackageVersion??`2.5.0`,zodPackageVersion:e?.zodPackageVersion??`4.4.3`,tsgoPackageVersion:e?.tsgoPackageVersion??`7.0.0-dev.20260523.1`,typesNodePackageVersion:e?.typesNodePackageVersion??`25.9.1`,typesReactPackageVersion:e?.typesReactPackageVersion??`19.2.15`,typesReactDomPackageVersion:e?.typesReactDomPackageVersion??`19.2.3`}}function formatEveDependencySpecifier(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/.test(e)?`^${e}`:e}async function patchWebPackageJson(e,t){if(!await pathExists(e))return[];assertStampedVersion(`evePackageVersion`,t.evePackageVersion),assertStampedVersion(`aiPackageVersion`,t.aiPackageVersion),assertStampedVersion(`nextPackageVersion`,t.nextPackageVersion),assertStampedVersion(`reactPackageVersion`,t.reactPackageVersion),assertStampedVersion(`reactDomPackageVersion`,t.reactDomPackageVersion),assertStampedVersion(`streamdownPackageVersion`,t.streamdownPackageVersion),assertStampedVersion(`zodPackageVersion`,t.zodPackageVersion),assertStampedVersion(`tsgoPackageVersion`,t.tsgoPackageVersion),assertStampedVersion(`typesNodePackageVersion`,t.typesNodePackageVersion),assertStampedVersion(`typesReactPackageVersion`,t.typesReactPackageVersion),assertStampedVersion(`typesReactDomPackageVersion`,t.typesReactDomPackageVersion);let r={...WEB_APP_TEMPLATE_PACKAGE_JSON.dependencies,ai:t.aiPackageVersion,eve:formatEveDependencySpecifier(t.evePackageVersion),next:t.nextPackageVersion,react:t.reactPackageVersion,"react-dom":t.reactDomPackageVersion,streamdown:t.streamdownPackageVersion,zod:t.zodPackageVersion},i={...WEB_APP_TEMPLATE_PACKAGE_JSON.devDependencies,"@types/node":t.typesNodePackageVersion,"@types/react":t.typesReactPackageVersion,"@types/react-dom":t.typesReactDomPackageVersion,"@typescript/native-preview":t.tsgoPackageVersion},a=WEB_APP_TEMPLATE_PACKAGE_JSON.scripts;return await patchPackageJson(e,{dependencies:r,devDependencies:i,scripts:a}),[{path:e,dependencies:Object.keys(r),devDependencies:Object.keys(i),scripts:Object.keys(a)}]}function normalizeSlackConnectorSlug(e){return toSlackConnectorSlug((e.trim().replace(/^@/,``).split(`/`).at(-1)??``).toLowerCase().replace(/[^a-z0-9_-]+/g,`-`).replace(/^[^a-z0-9]+/,``).replace(/[^a-z0-9]+$/,``).slice(0,100).replace(/[^a-z0-9]+$/,``)||`my-agent`)}async function deriveSlackConnectorSlug(e,t){if(t!==void 0&&t.length>0&&t!==`.`)return normalizeSlackConnectorSlug(t);try{let t=await readFile(join(e,`package.json`),`utf8`),n=JSON.parse(t);if(typeof n.name==`string`&&n.name.length>0)return normalizeSlackConnectorSlug(n.name)}catch{}return normalizeSlackConnectorSlug(basename(resolve(e))||`my-agent`)}function buildSlackTemplate(e){return`import { connectSlackCredentials } from "@vercel/connect/eve";
|
|
2
2
|
import { slackChannel } from "eve/channels/slack";
|
|
3
3
|
|
|
4
4
|
export default slackChannel({
|