eve 0.27.6 → 0.27.8
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 +14 -0
- package/dist/src/channel/session.d.ts +5 -0
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +7 -0
- package/dist/src/chunks/{use-eve-agent-COlXhAaF.js → use-eve-agent-JPfBHZJr.js} +36 -6
- package/dist/src/chunks/{use-eve-agent-DzVlKcUV.js → use-eve-agent-r5tkzjmt.js} +36 -6
- package/dist/src/cli/commands/register-registry-commands.d.ts +12 -0
- package/dist/src/cli/commands/register-registry-commands.js +1 -0
- package/dist/src/cli/commands/registry-project.d.ts +10 -0
- package/dist/src/cli/commands/registry-project.js +1 -0
- package/dist/src/cli/commands/registry.d.ts +17 -0
- package/dist/src/cli/commands/registry.js +1 -0
- package/dist/src/cli/run.js +2 -2
- package/dist/src/client/open-stream.d.ts +17 -2
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/session.d.ts +5 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/types.d.ts +7 -0
- package/dist/src/compiled/.vendor-stamp.json +2 -1
- package/dist/src/compiled/shadcn-registry/LICENSE.md +21 -0
- package/dist/src/compiled/shadcn-registry/index.d.ts +56 -0
- package/dist/src/compiled/shadcn-registry/index.js +33491 -0
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/runtime-actions.d.ts +4 -0
- package/dist/src/harness/runtime-actions.js +1 -1
- package/dist/src/harness/tool-call-input-errors.d.ts +20 -0
- package/dist/src/harness/tool-call-input-errors.js +1 -1
- package/dist/src/internal/application/build-workspace.d.ts +0 -1
- package/dist/src/internal/application/build-workspace.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/paths.d.ts +1 -6
- package/dist/src/internal/application/paths.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/configure-nitro-routes.d.ts +4 -4
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +2 -2
- package/dist/src/internal/nitro/host/create-application-nitro.d.ts +11 -7
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/types.d.ts +0 -4
- package/dist/src/internal/nitro/host/vercel-build-output-config.d.ts +29 -1
- package/dist/src/internal/nitro/host/vercel-build-output-config.js +1 -1
- package/dist/src/internal/workflow/queue-namespace.d.ts +8 -0
- package/dist/src/internal/workflow/queue-namespace.js +1 -1
- package/dist/src/internal/workflow-bundle/builder-support.d.ts +0 -5
- package/dist/src/internal/workflow-bundle/builder.d.ts +0 -5
- package/dist/src/internal/workflow-bundle/builder.js +2 -2
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.d.ts +0 -51
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -3
- package/dist/src/internal/workflow-bundle/workflow-builders.d.ts +0 -7
- package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
- package/dist/src/packages/eve-catalog/src/index.js +1 -1
- package/dist/src/protocol/message.d.ts +1 -0
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/public/channels/eve.js +2 -2
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/README.md +21 -20
- package/docs/channels/custom.mdx +1 -1
- package/docs/channels/overview.mdx +2 -0
- package/docs/channels/slack.mdx +0 -1
- package/docs/concepts/{execution-model-and-durability.md → execution-model-and-durability.mdx} +16 -0
- package/docs/concepts/security-model.md +2 -0
- package/docs/concepts/sessions-runs-and-streaming.md +9 -0
- package/docs/getting-started.mdx +13 -196
- package/docs/guides/client/streaming.mdx +15 -0
- package/docs/install-integrations.mdx +106 -0
- package/docs/installation.mdx +60 -0
- package/docs/meta.json +8 -6
- package/docs/project-structure.mdx +53 -0
- package/docs/reference/cli.md +18 -0
- package/docs/tutorial/meta.json +1 -1
- package/package.json +2 -1
- package/docs/introduction.mdx +0 -103
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{RuntimeNoActiveSessionError}from"#execution/runtime-errors.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{walkCauseChain}from"#shared/errors.js";import{serializeContext}from"#context/serialize.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{cancelRun,getHookByToken,getRun,getWorld,resumeHook,start}from"#internal/workflow/runtime.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{sessionCancelHookToken}from"#execution/turn-cancellation-token.js";import{buildSessionAttributes,buildSubagentRootAttributes,readParentLineage}from"#execution/eve-workflow-attributes.js";import{EntityConflictError,HookNotFoundError,RunExpiredError,WorkflowRunNotFoundError}from"#compiled/@workflow/errors/index.js";import{isEveDevEnvironment}from"#internal/application/dev-environment.js";import{normalizeEveAttributes}from"#runtime/attributes/normalize.js";import{buildRunContext}from"#execution/runtime-context.js";import{parseNdjsonStream}from"#execution/ndjson-stream.js";const WORKFLOW_ENTRY_NAME=`workflowEntry`,TURN_WORKFLOW_NAME=`turnWorkflow`,EVE_PACKAGE_INFO=resolveInstalledPackageInfo(),LATEST_DEPLOYMENT_UNSUPPORTED_MESSAGE=`deploymentId 'latest' requires a World that implements resolveLatestDeploymentId()`,STABLE_WORKFLOW_NAMES=new Set([WORKFLOW_ENTRY_NAME,TURN_WORKFLOW_NAME]),STABLE_ID_BASE=EVE_PACKAGE_INFO.name,log=createLogger(`execution.workflow-runtime`),workflowEntryReference={workflowId:`workflow//${STABLE_ID_BASE}//${WORKFLOW_ENTRY_NAME}`},turnWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${TURN_WORKFLOW_NAME}`};function createWorkflowRuntime(e){return{async run(n){let r=await getCompiledRuntimeAgentBundle({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:e.nodeId}),i=serializeContext(buildRunContext({bundle:r,run:n})),a=readParentLineage(i),o=a.sessionId===void 0?buildSessionAttributes({inputMessage:n.title??n.input.message,serializedContext:i}):buildSubagentRootAttributes({identity:{nodeId:r.nodeId??ROOT_RUNTIME_AGENT_NODE_ID},parentCallId:a.callId,parentSessionId:a.sessionId,parentTurnId:a.turnId,rootSessionId:a.rootSessionId??a.sessionId,serializedContext:i}),s;try{s=await startWorkflowPreferLatest(workflowEntryReference,[{input:n.input,limits:n.limits,serializedContext:i}],{allowReservedAttributes:!0,attributes:normalizeEveAttributes(o)})}catch(e){throw logError(log,`failed to start workflow run`,e,{continuationToken:n.continuationToken}),e}let c,getEvents=()=>(c??=parseNdjsonStream(()=>getRun(s.runId).getReadable()),c);return{continuationToken:n.continuationToken??s.runId,get events(){return getEvents()},sessionId:s.runId}},async cancelTurn(e){return await requestWorkflowTurnCancellation(e)},async terminateSession(e){try{return await cancelRun(await getWorld(),e.sessionId,{cancelReason:e.reason??`Session reset by channel`}),{status:`terminated`}}catch(e){if(isAlreadyTerminalSessionError(e))return{status:`already_terminal`};throw e}},async deliver(e){let r={auth:e.auth,kind:`deliver`,payloads:[e.payload],requestId:e.requestId};try{return{sessionId:normalizeWorkflowHook(await resumeHook(e.continuationToken,r)).runId}}catch(r){throw HookNotFoundError.is(r)?new RuntimeNoActiveSessionError(e.continuationToken):(logError(log,`failed to deliver to active session`,r,{continuationToken:e.continuationToken}),r)}},async getEventStream(e,t){return parseNdjsonStream(()=>getRun(e).getReadable({startIndex:t?.startIndex}))},async resolveSession(e){try{return{sessionId:(await getHookByToken(e)).runId}}catch(n){if(HookNotFoundError.is(n))return;throw logError(log,`failed to resolve session by continuation token`,n,{continuationToken:e}),n}}}}async function requestWorkflowTurnCancellation(e){let t=e.turnId===void 0?{}:{turnId:e.turnId};try{return await resumeHook(sessionCancelHookToken(e.sessionId),t),{status:`accepted`}}catch(e){if(isInactiveCancelTarget(e))return{status:`no_active_turn`};throw e}}function isInactiveCancelTarget(e){return HookNotFoundError.is(e)||WorkflowRunNotFoundError.is(e)||RunExpiredError.is(e)||EntityConflictError.is(e)}function isAlreadyTerminalSessionError(e){for(let t of walkCauseChain(e))if(WorkflowRunNotFoundError.is(t)||RunExpiredError.is(t)||EntityConflictError.is(t))return!0;return!1}async function startWorkflowPreferLatest(e,t,n){if(!shouldRouteToLatestDeployment())return n===void 0?await start(e,t):await start(e,t,n);try{return await start(e,t,{...n,deploymentId:`latest`})}catch(r){if(!isLatestDeploymentUnsupportedError(r))throw r;return n===void 0?await start(e,t):await start(e,t,n)}}function shouldRouteToLatestDeployment(){return process.env.VERCEL_ENV===`production`||isEveDevEnvironment()}function isLatestDeploymentUnsupportedError(e){return e instanceof Error&&e.message.includes(`deploymentId 'latest' requires a World that implements resolveLatestDeploymentId()`)}function normalizeWorkflowHook(e){if(typeof e!=`object`||!e||!(`runId`in e))throw Error(`Workflow hook did not include a run id.`);let t=e.runId;if(typeof t!=`string`||t.length===0)throw Error(`Workflow hook did not include a run id.`);return{runId:t}}export{LATEST_DEPLOYMENT_UNSUPPORTED_MESSAGE,STABLE_WORKFLOW_NAMES,createWorkflowRuntime,requestWorkflowTurnCancellation,startWorkflowPreferLatest,turnWorkflowReference,workflowEntryReference};
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{RuntimeNoActiveSessionError}from"#execution/runtime-errors.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{walkCauseChain}from"#shared/errors.js";import{serializeContext}from"#context/serialize.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{cancelRun,getHookByToken,getRun,getWorld,resumeHook,start}from"#internal/workflow/runtime.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{sessionCancelHookToken}from"#execution/turn-cancellation-token.js";import{buildSessionAttributes,buildSubagentRootAttributes,readParentLineage}from"#execution/eve-workflow-attributes.js";import{EntityConflictError,HookNotFoundError,RunExpiredError,WorkflowRunNotFoundError}from"#compiled/@workflow/errors/index.js";import{isEveDevEnvironment}from"#internal/application/dev-environment.js";import{normalizeEveAttributes}from"#runtime/attributes/normalize.js";import{buildRunContext}from"#execution/runtime-context.js";import{parseNdjsonStream}from"#execution/ndjson-stream.js";const WORKFLOW_ENTRY_NAME=`workflowEntry`,TURN_WORKFLOW_NAME=`turnWorkflow`,EVE_PACKAGE_INFO=resolveInstalledPackageInfo(),LATEST_DEPLOYMENT_UNSUPPORTED_MESSAGE=`deploymentId 'latest' requires a World that implements resolveLatestDeploymentId()`,STABLE_WORKFLOW_NAMES=new Set([WORKFLOW_ENTRY_NAME,TURN_WORKFLOW_NAME]),STABLE_ID_BASE=EVE_PACKAGE_INFO.name,log=createLogger(`execution.workflow-runtime`),workflowEntryReference={workflowId:`workflow//${STABLE_ID_BASE}//${WORKFLOW_ENTRY_NAME}`},turnWorkflowReference={workflowId:`workflow//${STABLE_ID_BASE}//${TURN_WORKFLOW_NAME}`};function createWorkflowRuntime(e){return{async run(n){let r=await getCompiledRuntimeAgentBundle({compiledArtifactsSource:e.compiledArtifactsSource,nodeId:e.nodeId}),i=serializeContext(buildRunContext({bundle:r,run:n})),a=readParentLineage(i),o=a.sessionId===void 0?buildSessionAttributes({inputMessage:n.title??n.input.message,serializedContext:i}):buildSubagentRootAttributes({identity:{nodeId:r.nodeId??ROOT_RUNTIME_AGENT_NODE_ID},parentCallId:a.callId,parentSessionId:a.sessionId,parentTurnId:a.turnId,rootSessionId:a.rootSessionId??a.sessionId,serializedContext:i}),s;try{s=await startWorkflowPreferLatest(workflowEntryReference,[{input:n.input,limits:n.limits,serializedContext:i}],{allowReservedAttributes:!0,attributes:normalizeEveAttributes(o)})}catch(e){throw logError(log,`failed to start workflow run`,e,{continuationToken:n.continuationToken}),e}let c,getEvents=()=>(c??=parseNdjsonStream(()=>getRun(s.runId).getReadable()),c);return{continuationToken:n.continuationToken??s.runId,get events(){return getEvents()},sessionId:s.runId}},async cancelTurn(e){return await requestWorkflowTurnCancellation(e)},async terminateSession(e){try{return await cancelRun(await getWorld(),e.sessionId,{cancelReason:e.reason??`Session reset by channel`}),{status:`terminated`}}catch(e){if(isAlreadyTerminalSessionError(e))return{status:`already_terminal`};throw e}},async deliver(e){let r={auth:e.auth,kind:`deliver`,payloads:[e.payload],requestId:e.requestId};try{return{sessionId:normalizeWorkflowHook(await resumeHook(e.continuationToken,r)).runId}}catch(r){throw HookNotFoundError.is(r)?new RuntimeNoActiveSessionError(e.continuationToken):(logError(log,`failed to deliver to active session`,r,{continuationToken:e.continuationToken}),r)}},async getEventStream(e,t){return parseNdjsonStream(()=>getRun(e).getReadable({startIndex:t?.startIndex}))},async getStreamTailIndex(e){let t=getRun(e).getReadable();try{return await t.getTailIndex()}finally{await t.cancel().catch(()=>{})}},async resolveSession(e){try{return{sessionId:(await getHookByToken(e)).runId}}catch(n){if(HookNotFoundError.is(n))return;throw logError(log,`failed to resolve session by continuation token`,n,{continuationToken:e}),n}}}}async function requestWorkflowTurnCancellation(e){let t=e.turnId===void 0?{}:{turnId:e.turnId};try{return await resumeHook(sessionCancelHookToken(e.sessionId),t),{status:`accepted`}}catch(e){if(isInactiveCancelTarget(e))return{status:`no_active_turn`};throw e}}function isInactiveCancelTarget(e){return HookNotFoundError.is(e)||WorkflowRunNotFoundError.is(e)||RunExpiredError.is(e)||EntityConflictError.is(e)}function isAlreadyTerminalSessionError(e){for(let t of walkCauseChain(e))if(WorkflowRunNotFoundError.is(t)||RunExpiredError.is(t)||EntityConflictError.is(t))return!0;return!1}async function startWorkflowPreferLatest(e,t,n){if(!shouldRouteToLatestDeployment())return n===void 0?await start(e,t):await start(e,t,n);try{return await start(e,t,{...n,deploymentId:`latest`})}catch(r){if(!isLatestDeploymentUnsupportedError(r))throw r;return n===void 0?await start(e,t):await start(e,t,n)}}function shouldRouteToLatestDeployment(){return process.env.VERCEL_ENV===`production`||isEveDevEnvironment()}function isLatestDeploymentUnsupportedError(e){return e instanceof Error&&e.message.includes(`deploymentId 'latest' requires a World that implements resolveLatestDeploymentId()`)}function normalizeWorkflowHook(e){if(typeof e!=`object`||!e||!(`runId`in e))throw Error(`Workflow hook did not include a run id.`);let t=e.runId;if(typeof t!=`string`||t.length===0)throw Error(`Workflow hook did not include a run id.`);return{runId:t}}export{LATEST_DEPLOYMENT_UNSUPPORTED_MESSAGE,STABLE_WORKFLOW_NAMES,createWorkflowRuntime,requestWorkflowTurnCancellation,startWorkflowPreferLatest,turnWorkflowReference,workflowEntryReference};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createActionResultEvent,createActionsRequestedEvent,createMessageAppendedEvent,createMessageCompletedEvent,createMessageReceivedEvent,createReasoningAppendedEvent,createReasoningCompletedEvent,createSessionCompletedEvent,createSessionFailedEvent,createSessionStartedEvent,createSessionWaitingEvent,createStepFailedEvent,createStepStartedEvent,createTurnCompletedEvent,createTurnFailedEvent,createTurnStartedEvent}from"#protocol/message.js";import{createRuntimeActionRequestFromToolCall
|
|
1
|
+
import{createActionResultEvent,createActionsRequestedEvent,createMessageAppendedEvent,createMessageCompletedEvent,createMessageReceivedEvent,createReasoningAppendedEvent,createReasoningCompletedEvent,createSessionCompletedEvent,createSessionFailedEvent,createSessionStartedEvent,createSessionWaitingEvent,createStepFailedEvent,createStepStartedEvent,createTurnCompletedEvent,createTurnFailedEvent,createTurnStartedEvent}from"#protocol/message.js";import{createRuntimeActionRequestFromToolCall}from"#harness/runtime-actions.js";import{hasEmptyDeliverySentinel}from"#shared/empty-delivery.js";import{createRuntimeToolResultFromStepResult,createRuntimeToolResultFromToolError,createToolResultMessagePartFromToolError}from"#harness/action-result-helpers.js";import{createInvalidToolCallInputError,isInvalidToolCall,resolveProviderToolCallRequest}from"#harness/tool-call-input-errors.js";import{createProviderStreamActionBatch}from"#harness/stream-actions.js";import{normalizeModelStreamError}from"#harness/model-call-error.js";import{createOrderedStreamEmitter}from"#harness/ordered-stream-emitter.js";import{interruptStreamOnFailure}from"#harness/interruptible-stream.js";import{isInlineAuthorizationToolResult}from"#harness/inline-tool-authorization.js";const HARNESS_EMISSION_STATE_KEY=`eve.harness.emission`,DEFAULT_EMISSION_STATE={sessionStarted:!1,sequence:0,stepIndex:0,turnId:``};function getHarnessEmissionState(e){return e?.[HARNESS_EMISSION_STATE_KEY]??DEFAULT_EMISSION_STATE}function isHarnessBetweenTurns(e){return getHarnessEmissionState(e.state).turnId===``}function setHarnessEmissionState(e,t){return{...e,state:{...e.state,[HARNESS_EMISSION_STATE_KEY]:t}}}async function emitTurnPreamble(e,t,n,r){let a=`turn_${n.sequence}`;return n.sessionStarted||await e(createSessionStartedEvent({runtime:r})),await e(createTurnStartedEvent({sequence:n.sequence,turnId:a})),t.message!==void 0&&await e(createMessageReceivedEvent({message:t.message,sequence:n.sequence,turnId:a})),{sessionStarted:!0,sequence:n.sequence,stepIndex:0,turnId:a}}async function emitStepStarted(e,t,n){await e(createStepStartedEvent({sequence:t.sequence,stepIndex:t.stepIndex,turnId:t.turnId}),n)}async function emitStepAndTurnFailed(e,t,n){await e(createStepFailedEvent({...n,sequence:t.sequence,stepIndex:t.stepIndex,turnId:t.turnId})),await e(createTurnFailedEvent({...n,sequence:t.sequence,turnId:t.turnId}))}async function emitFailedStep(e,t,n){await emitStepAndTurnFailed(e,t,n),await e(createSessionFailedEvent(n))}async function emitRecoverableFailedTurn(e,t,n){return await emitStepAndTurnFailed(e,t,n),await e(createSessionWaitingEvent(n.continuationToken)),{sessionStarted:t.sessionStarted,sequence:t.sequence+1,stepIndex:0,turnId:``}}function advanceStep(e){return{...e,stepIndex:e.stepIndex+1}}async function emitTurnEpilogue(e,t,n,r){return await e(createTurnCompletedEvent({sequence:t.sequence,turnId:t.turnId})),n===`conversation`?await e(createSessionWaitingEvent(r)):await e(createSessionCompletedEvent()),{sessionStarted:t.sessionStarted,sequence:t.sequence+1,stepIndex:0,turnId:``}}function normalizeAssistantStepFinishReason(e){switch(e){case`content-filter`:case`error`:case`length`:case`stop`:case`tool-calls`:return e;default:return`other`}}async function emitStreamContent(e,t,n,r){let i=createOrderedStreamEmitter(e),a=createProviderStreamActionBatch({emitFn:i.emit,state:t});try{return await consumeStreamContent(i.emit,t,interruptStreamOnFailure(n,i.failureSignal),a,r)}finally{try{await a.cancel()}finally{await i.closeAndDrain()}}}async function consumeStreamContent(i,o,s,c,l){let u=``,d=``,f=`stop`,p,m=new Set,h=new Set,g=new Set,_=new Set,v=new Set,y=new Set,b=[],x=[],flushCurrentMessage=async()=>{d.length!==0&&(await i(createMessageCompletedEvent({finishReason:`tool-calls`,message:d,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),d=``)},emitActionRequest=async e=>{h.has(e.callId)||(d.trim().length>0&&await flushCurrentMessage(),h.add(e.callId),await i(createActionsRequestedEvent({actions:[e],sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})))},collectProviderToolCall=async e=>{if(_.has(e.toolCallId)||(_.add(e.toolCallId),h.has(e.toolCallId)))return;h.add(e.toolCallId),d.trim().length>0&&await flushCurrentMessage();let t=resolveProviderToolCallRequest(e);if(t.toolError!==void 0){y.add(e.toolCallId),await emitActionResult(createRuntimeToolResultFromToolError(t.toolError)),v.add(e.toolCallId);return}c.observe(t.request)},emitActionResult=async t=>{g.has(t.callId)||(g.add(t.callId),await i(createActionResultEvent({result:t,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})))},emitToolCall=async e=>{if(isInvalidToolCall(e)){y.add(e.toolCallId);return}if(!(l===void 0||l.excludedActionToolNames.has(e.toolName)))try{await emitActionRequest(createRuntimeActionRequestFromToolCall({toolCall:e,tools:l.tools}))}catch(t){if(t instanceof TypeError){let n=createInvalidToolCallInputError({error:t,toolCall:e});y.add(e.toolCallId),d.trim().length>0&&await flushCurrentMessage(),await emitActionResult(createRuntimeToolResultFromToolError(n)),v.add(e.toolCallId),x.push(createToolResultMessagePartFromToolError(n));return}throw t}};for await(let e of s)if(p===void 0)switch(e.type){case`reasoning-delta`:await c.flush(),u+=e.text,await i(createReasoningAppendedEvent({reasoningDelta:e.text,reasoningSoFar:u,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId}));break;case`text-delta`:await c.flush(),u.trim().length>0&&(await i(createReasoningCompletedEvent({reasoning:u,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),u=``),d+=e.text,await i(createMessageAppendedEvent({messageDelta:e.text,messageSoFar:d,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId}));break;case`tool-call`:{let t=e;m.add(t.toolCallId),t.providerExecuted===!0?await collectProviderToolCall(t):(await c.flush(),await emitToolCall(t));break}case`tool-result`:{let t=e;if(t.preliminary===!0)break;if(t.providerExecuted===!0){await collectProviderToolCall({input:`input`in t?t.input:void 0,toolCallId:t.toolCallId,toolName:t.toolName}),await c.flush(),await emitActionResult(createRuntimeToolResultFromStepResult(t));break}if(m.has(e.toolCallId)){if(isInlineAuthorizationToolResult(t))break;h.has(e.toolCallId)&&(await emitActionResult(createRuntimeToolResultFromStepResult(t)),v.add(e.toolCallId));break}if(await c.flush(),await flushCurrentMessage(),isInlineAuthorizationToolResult(t)){v.add(e.toolCallId),b.push(t);break}await emitActionResult(createRuntimeToolResultFromStepResult(t)),v.add(e.toolCallId);break}case`tool-error`:{let t=e;t.providerExecuted===!0?(await collectProviderToolCall(t),await c.flush(),await emitActionResult(createRuntimeToolResultFromToolError(t))):h.has(t.toolCallId)&&(await emitActionResult(createRuntimeToolResultFromToolError(t)),v.add(t.toolCallId),x.push(createToolResultMessagePartFromToolError(t)));break}case`finish-step`:f=normalizeAssistantStepFinishReason(e.finishReason),await c.flush();break;case`error`:p=normalizeModelStreamError(e.error);break;case`abort`:throw new DOMException(e.reason??`The model stream was aborted.`,`AbortError`);default:break}if(await c.flush(),p!==void 0)throw p;return u.trim().length>0&&await i(createReasoningCompletedEvent({reasoning:u,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),f!==`tool-calls`&&hasEmptyDeliverySentinel(d)?await i(createMessageCompletedEvent({finishReason:f,message:null,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})):d.trim().length>0&&await i(createMessageCompletedEvent({finishReason:f,message:d,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),{emittedActionCallIds:h,handledInlineToolResultCallIds:v,invalidInputToolCallIds:y,inlineAuthorizationResults:b,trailingInlineToolResultParts:x}}export{advanceStep,emitFailedStep,emitRecoverableFailedTurn,emitStepStarted,emitStreamContent,emitTurnEpilogue,emitTurnPreamble,getHarnessEmissionState,isHarnessBetweenTurns,normalizeAssistantStepFinishReason,setHarnessEmissionState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveTextToResponses}from"#channel/resolve-text.js";import{
|
|
1
|
+
import{resolveTextToResponses}from"#channel/resolve-text.js";import{resolveToolCallInputObject}from"#harness/runtime-actions.js";import{coalesceTurnInputs}from"#harness/messages.js";import{isSessionLimitContinuationRequest,resolveSessionLimitContinuation}from"#harness/session-limit-continuation.js";const PENDING_INPUT_BATCH_KEY=`eve.runtime.pendingInputBatch`,APPROVED_TOOLS_KEY=`eve.runtime.hitl.approvedTools`,DEFERRED_STEP_INPUT_KEY=`eve.runtime.deferredStepInput`,TOOL_EXECUTION_DENIED_MESSAGE=`Tool execution was denied.`;function hasStepInput(e){return e===void 0?!1:e.message!==void 0||(e.inputResponses?.length??0)>0}function consumeDeferredStepInput(e){let t=getDeferredStepInput(e.session);if(t===void 0)return e;let r=clearDeferredStepInput(e.session);return e.input===void 0?{input:t,session:r}:{input:coalesceTurnInputs(t,e.input),session:r}}function hasDeferredStepInput(e){return getDeferredStepInput(e)!==void 0}function resolvePendingInput(e){let{stepInput:t}=e,n=e.session,r=[...e.history??n.history],a=getPendingInputBatch(n.state);if(a===void 0)return{outcome:`continue`,messages:r,session:n};let o=resolveTextMessageInput(a,t),s=o?.inputResponses??[],c=a.requests.some(e=>isApprovalRequest(e));if(s.length===0&&o?.message===void 0)return{outcome:`unresolved`,messages:r,session:n};if(c&&hasUnansweredApproval({pendingBatch:a,responses:s}))return n=queueDeferredStepInput(n,compactStepInput(o)),{deferredMessage:!0,outcome:`unresolved`,messages:r,session:n};if(s.length===0&&o?.message!==void 0){let e=buildToolResponseParts(a,[]),t=[...r,...a.responseMessages];e.length>0&&t.push({content:e,role:`tool`});let i=buildRejectedActionBatch(a,[]);return n=clearPendingInputBatch(n),{consumedMessage:o?.messageConsumed,outcome:`resolved`,messages:t,rejectedActions:i,session:n}}let l=resolveSessionLimitContinuation({requests:a.requests,responses:s});n=recordApprovedTools({pendingBatch:a,resolveApprovalKey:e.resolveApprovalKey,responses:s,session:n});let u=buildToolResponseParts(a,s),d=[...r,...a.responseMessages];u.length>0&&d.push({content:u,role:`tool`});let f=buildRejectedActionBatch(a,s);if(n=clearPendingInputBatch(n),c){let e={};if((o?.context?.length??0)>0&&(e.context=o?.context),o?.message!==void 0&&(e.message=o.message),e.context!==void 0||e.message!==void 0)return n=queueDeferredStepInput(n,e),{consumedMessage:o?.messageConsumed,deferredContext:e.context===void 0?void 0:!0,deferredMessage:e.message===void 0?void 0:!0,limitContinuation:l,outcome:`resolved`,messages:d,rejectedActions:f,session:n}}return{consumedMessage:o?.messageConsumed,limitContinuation:l,outcome:`resolved`,messages:d,rejectedActions:f,session:n}}function resolveTextMessageInput(t,n){if(typeof n?.message!=`string`||(n.inputResponses?.length??0)>0)return n;let r=resolveTextToResponses(n.message,t.requests);return r.length===0?n:compactStepInput({...n,inputResponses:r,messageConsumed:!0,message:void 0})}function compactStepInput(e){if(e===void 0)return{};let t={};return(e.context?.length??0)>0&&(t.context=e.context),(e.inputResponses?.length??0)>0&&(t.inputResponses=e.inputResponses),e.message!==void 0&&(t.message=e.message),e.messageConsumed===!0&&(t.messageConsumed=!0),e.outputSchema!==void 0&&(t.outputSchema=e.outputSchema),t}function hasUnansweredApproval(e){let t=new Set(e.responses.map(e=>e.requestId));return e.pendingBatch.requests.some(e=>isApprovalRequest(e)&&!t.has(e.requestId))}function hasPendingInputBatch(e){return getPendingInputBatch(e)!==void 0}function getPendingInputRequestIds(e){return new Set(getPendingInputBatch(e)?.requests.map(e=>e.requestId))}function getPendingInputBatch(e){let t=e?.[PENDING_INPUT_BATCH_KEY];if(typeof t!=`object`||!t)return;let n=t;if(!(!Array.isArray(n.requests)||!Array.isArray(n.responseMessages)))return n}function setPendingInputBatch(e){let t={...e.session.state};return t[PENDING_INPUT_BATCH_KEY]={event:e.event,requests:[...e.requests],responseMessages:[...e.responseMessages]},{...e.session,state:t}}function clearPendingInputBatch(e){if(e.state?.[PENDING_INPUT_BATCH_KEY]===void 0)return e;let t={...e.state};return delete t[PENDING_INPUT_BATCH_KEY],{...e,state:Object.keys(t).length>0?t:void 0}}function getDeferredStepInput(e){return e.state?.[DEFERRED_STEP_INPUT_KEY]}function queueDeferredStepInput(e,t){let r=getDeferredStepInput(e),i=r===void 0?t:coalesceTurnInputs(r,t),a={...e.state};return a[DEFERRED_STEP_INPUT_KEY]=i,{...e,state:a}}function clearDeferredStepInput(e){if(e.state?.[DEFERRED_STEP_INPUT_KEY]===void 0)return e;let t={...e.state};return delete t[DEFERRED_STEP_INPUT_KEY],{...e,state:Object.keys(t).length>0?t:void 0}}function getApprovedTools(e){let t=e.state?.[APPROVED_TOOLS_KEY];return Array.isArray(t)?new Set(t):new Set}function recordApprovedTools(e){let t=new Set(e.responses.filter(e=>e.optionId===`approve`).map(e=>e.requestId)),n=e.pendingBatch.requests.filter(e=>t.has(e.requestId)).map(t=>e.resolveApprovalKey?.(t)??t.action.toolName);if(n.length===0)return e.session;let r=getApprovedTools(e.session),i=[...new Set([...r,...n])],a={...e.session.state};return a[APPROVED_TOOLS_KEY]=i,{...e.session,state:a}}function resolveApprovalOutcome(e){return e===void 0?{approved:!1,reason:`Ignored because the user continued without responding.`,status:`ignored`}:e.optionId===`approve`?{approved:!0,reason:void 0,status:`approved`}:e.optionId===`deny`?{approved:!1,reason:TOOL_EXECUTION_DENIED_MESSAGE,status:`denied`}:{approved:!1,reason:`Invalid approval response.`,status:`invalid`}}function buildRejectedActionBatch(e,t){if(e.event===void 0)return;let n=new Map(t.map(e=>[e.requestId,e])),r=[];for(let t of e.requests){if(!isApprovalRequest(t))continue;let{approved:e,reason:i,status:a}=resolveApprovalOutcome(n.get(t.requestId));e||r.push({callId:t.action.callId,isError:!0,kind:`tool-result`,output:{approval:{requestId:t.requestId,status:a},code:`TOOL_EXECUTION_DENIED`,message:i??TOOL_EXECUTION_DENIED_MESSAGE,tool:{result:`not_run`}},toolName:t.action.toolName})}return r.length>0?{event:e.event,results:r}:void 0}function buildToolResponseParts(e,t){let n=new Map(t.map(e=>[e.requestId,e])),r=[];for(let t of e.requests)r.push(...buildToolResponsePartsForRequest(t,n.get(t.requestId)));return r}function buildToolResponsePartsForRequest(e,t){if(isSessionLimitContinuationRequest(e))return[];if(isApprovalRequest(e)){let{approved:n,reason:r}=resolveApprovalOutcome(t),i=[{approvalId:e.requestId,approved:n,reason:r,type:`tool-approval-response`}];return n||i.push({output:{type:`execution-denied`,reason:r},toolCallId:e.action.callId,toolName:e.action.toolName,type:`tool-result`}),i}return[{output:{type:`json`,value:t===void 0?{status:`ignored`}:{optionId:t.optionId,text:t.text,status:`answered`}},toolCallId:e.action.callId,toolName:e.action.toolName,type:`tool-result`}]}function isApprovalRequest(e){return e.options?.length===2&&e.options[0]?.id===`approve`&&e.options[1]?.id===`deny`}function createRuntimeToolCallActionFromToolCall(e){return{callId:e.toolCall.toolCallId,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`tool-call`,toolName:e.toolCall.toolName}}export{consumeDeferredStepInput,createRuntimeToolCallActionFromToolCall,getApprovedTools,getPendingInputRequestIds,hasDeferredStepInput,hasPendingInputBatch,hasStepInput,isApprovalRequest,resolvePendingInput,setPendingInputBatch};
|
|
@@ -94,6 +94,10 @@ export declare function createRuntimeActionRequestFromToolCall(input: {
|
|
|
94
94
|
* Coerces an AI SDK tool-call `input` into the runtime-action `JsonObject`
|
|
95
95
|
* contract, throwing a `TypeError` (with the original as `cause`) that names
|
|
96
96
|
* the offending tool when the payload is not a JSON object.
|
|
97
|
+
*
|
|
98
|
+
* String inputs are parsed as JSON first: the model protocol carries tool
|
|
99
|
+
* arguments as text, and provider-executed tool calls can surface that raw
|
|
100
|
+
* string — or an empty string when the model sends no arguments.
|
|
97
101
|
*/
|
|
98
102
|
export declare function resolveToolCallInputObject(value: unknown, context: {
|
|
99
103
|
readonly callId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createActionResultEvent}from"#protocol/message.js";import{parseJsonObject}from"#shared/json.js";import{clearProxyInputRequestsForChild}from"#harness/proxy-input-requests.js";import{accumulateSessionUsage,getTurnUsageState,setTurnUsageState}from"#harness/turn-tag-state.js";import{getRuntimeActionRequestKey,getRuntimeActionResultKey}from"#runtime/actions/keys.js";const PENDING_RUNTIME_ACTION_BATCH_KEY=`eve.runtime.pendingActionBatch`;function getPendingRuntimeActionBatch(e){let t=e?.[PENDING_RUNTIME_ACTION_BATCH_KEY];if(typeof t!=`object`||!t)return;let n=t;if(!(!Array.isArray(n.actions)||!Array.isArray(n.responseMessages)||typeof n.event!=`object`||n.event===null))return n}function hasPendingRuntimeActionBatch(e){return getPendingRuntimeActionBatch(e)!==void 0}function clearPendingRuntimeActionBatch(e){if(e.state?.[PENDING_RUNTIME_ACTION_BATCH_KEY]===void 0)return e;let t={...e.state};return delete t[PENDING_RUNTIME_ACTION_BATCH_KEY],{...e,state:Object.keys(t).length>0?t:void 0}}function setPendingRuntimeActionBatch(e){let t={...e.session.state};return t[PENDING_RUNTIME_ACTION_BATCH_KEY]={actions:[...e.actions],event:e.event,responseMessages:[...e.responseMessages]},{...e.session,state:t}}function recordPendingSubagentChild(e){let t=getPendingRuntimeActionBatch(e.session.state);if(t===void 0)return e.session;let n={...e.session.state};return n[PENDING_RUNTIME_ACTION_BATCH_KEY]={...t,...e.child.kind===`local`?{childContinuationTokens:{...t.childContinuationTokens,[e.callId]:e.child.continuationToken}}:{},childSessionIds:{...t.childSessionIds,[e.callId]:e.child.sessionId}},{...e.session,state:n}}function resolveReadyRuntimeActionResults(e){let t=getPendingRuntimeActionBatch(e.session.state);if(t!==void 0)return resolveRuntimeActionResultsForBatch({batch:t,results:e.results})}function resolveRuntimeActionResultsForBatch(e){return resolveRuntimeActionResultsForKeys({pendingKeys:e.batch.actions.map(e=>getRuntimeActionRequestKey(e)),results:e.results})}function resolveRuntimeActionResultsForKeys(e){let t=new Set(e.pendingKeys),n=new Map;for(let r of e.results){let e=getRuntimeActionResultKey(r);t.has(e)&&n.set(e,r)}let r=[];for(let t of e.pendingKeys){let e=n.get(t);if(e===void 0)return;r.push(e)}return r}async function resolvePendingRuntimeActions(t){let i=getPendingRuntimeActionBatch(t.session.state);if(i===void 0)return{messages:[...t.session.history],outcome:`continue`,session:t.session};let a=resolveReadyRuntimeActionResults({results:t.stepInput?.runtimeActionResults??[],session:t.session});if(a===void 0)return{messages:[...t.session.history],outcome:`unresolved`,session:t.session};if(t.emit!==void 0)for(let n of a)n.kind===`subagent-result`&&n.isError!==!0&&await t.emit({data:{callId:n.callId,output:typeof n.output==`string`?n.output:JSON.stringify(n.output),subagentName:n.subagentName},type:`subagent.completed`}),await t.emit(createActionResultEvent({result:n,sequence:i.event.sequence,stepIndex:i.event.stepIndex,turnId:i.event.turnId}));let o={...t.session.state};delete o[PENDING_RUNTIME_ACTION_BATCH_KEY];let s={...t.session,state:Object.keys(o).length>0?o:void 0},c=i.childContinuationTokens;if(c!==void 0)for(let e of a){if(e.kind!==`subagent-result`)continue;let t=c[e.callId];t!==void 0&&(s=clearProxyInputRequestsForChild(s,t))}for(let e of a)e.kind!==`subagent-result`||e.usage===void 0||(s=setTurnUsageState(s,accumulateSessionUsage({previous:getTurnUsageState(s.state),usage:e.usage})));let l=a.map(e=>{switch(e.kind){case`load-skill-result`:return{output:toToolResultOutput(e),toolCallId:e.callId,toolName:`load_skill`,type:`tool-result`};case`subagent-result`:return{output:toToolResultOutput(e),toolCallId:e.callId,toolName:e.subagentName,type:`tool-result`};case`tool-result`:return{output:toToolResultOutput(e),toolCallId:e.callId,toolName:e.toolName,type:`tool-result`}}throw Error(`Unsupported runtime action result kind "${String(e)}".`)}),u=[...s.history,...i.responseMessages];return l.length>0&&u.push({content:l,role:`tool`}),{messages:u,outcome:`resolved`,session:s}}function createRuntimeActionRequestFromToolCall(e){let t=e.tools.get(e.toolCall.toolName);return t?.runtimeAction?.kind===`subagent-call`?{callId:e.toolCall.toolCallId,description:t.description,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`subagent-call`,name:t.name,nodeId:t.runtimeAction.nodeId,subagentName:t.runtimeAction.subagentName}:t?.runtimeAction?.kind===`remote-agent-call`?{callId:e.toolCall.toolCallId,description:t.description,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`remote-agent-call`,name:t.name,nodeId:t.runtimeAction.nodeId,remoteAgentName:t.runtimeAction.remoteAgentName??t.name}:{callId:e.toolCall.toolCallId,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`tool-call`,toolName:e.toolCall.toolName}}function resolveToolCallInputObject(e,n){if(e==null)return{};try{return parseJsonObject(e)}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`Failed to parse tool-call arguments for "${n.toolName}" (${n.callId}): ${t}`,{cause:e})}}function toToolResultOutput(e){return typeof e.output==`string`?e.isError===!0?{type:`error-text`,value:e.output}:{type:`text`,value:e.output}:e.isError===!0?{type:`error-json`,value:toMutableJsonValue(e.output)}:{type:`json`,value:toMutableJsonValue(e.output)}}function toMutableJsonValue(e){if(e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e))return e.map(e=>toMutableJsonValue(e));let t={};for(let[n,r]of Object.entries(e))t[n]=toMutableJsonValue(r);return t}export{clearPendingRuntimeActionBatch,createRuntimeActionRequestFromToolCall,getPendingRuntimeActionBatch,hasPendingRuntimeActionBatch,recordPendingSubagentChild,resolvePendingRuntimeActions,resolveRuntimeActionResultsForKeys,resolveToolCallInputObject,setPendingRuntimeActionBatch};
|
|
1
|
+
import{createActionResultEvent}from"#protocol/message.js";import{parseJsonObject}from"#shared/json.js";import{clearProxyInputRequestsForChild}from"#harness/proxy-input-requests.js";import{accumulateSessionUsage,getTurnUsageState,setTurnUsageState}from"#harness/turn-tag-state.js";import{getRuntimeActionRequestKey,getRuntimeActionResultKey}from"#runtime/actions/keys.js";const PENDING_RUNTIME_ACTION_BATCH_KEY=`eve.runtime.pendingActionBatch`;function getPendingRuntimeActionBatch(e){let t=e?.[PENDING_RUNTIME_ACTION_BATCH_KEY];if(typeof t!=`object`||!t)return;let n=t;if(!(!Array.isArray(n.actions)||!Array.isArray(n.responseMessages)||typeof n.event!=`object`||n.event===null))return n}function hasPendingRuntimeActionBatch(e){return getPendingRuntimeActionBatch(e)!==void 0}function clearPendingRuntimeActionBatch(e){if(e.state?.[PENDING_RUNTIME_ACTION_BATCH_KEY]===void 0)return e;let t={...e.state};return delete t[PENDING_RUNTIME_ACTION_BATCH_KEY],{...e,state:Object.keys(t).length>0?t:void 0}}function setPendingRuntimeActionBatch(e){let t={...e.session.state};return t[PENDING_RUNTIME_ACTION_BATCH_KEY]={actions:[...e.actions],event:e.event,responseMessages:[...e.responseMessages]},{...e.session,state:t}}function recordPendingSubagentChild(e){let t=getPendingRuntimeActionBatch(e.session.state);if(t===void 0)return e.session;let n={...e.session.state};return n[PENDING_RUNTIME_ACTION_BATCH_KEY]={...t,...e.child.kind===`local`?{childContinuationTokens:{...t.childContinuationTokens,[e.callId]:e.child.continuationToken}}:{},childSessionIds:{...t.childSessionIds,[e.callId]:e.child.sessionId}},{...e.session,state:n}}function resolveReadyRuntimeActionResults(e){let t=getPendingRuntimeActionBatch(e.session.state);if(t!==void 0)return resolveRuntimeActionResultsForBatch({batch:t,results:e.results})}function resolveRuntimeActionResultsForBatch(e){return resolveRuntimeActionResultsForKeys({pendingKeys:e.batch.actions.map(e=>getRuntimeActionRequestKey(e)),results:e.results})}function resolveRuntimeActionResultsForKeys(e){let t=new Set(e.pendingKeys),n=new Map;for(let r of e.results){let e=getRuntimeActionResultKey(r);t.has(e)&&n.set(e,r)}let r=[];for(let t of e.pendingKeys){let e=n.get(t);if(e===void 0)return;r.push(e)}return r}async function resolvePendingRuntimeActions(t){let i=getPendingRuntimeActionBatch(t.session.state);if(i===void 0)return{messages:[...t.session.history],outcome:`continue`,session:t.session};let a=resolveReadyRuntimeActionResults({results:t.stepInput?.runtimeActionResults??[],session:t.session});if(a===void 0)return{messages:[...t.session.history],outcome:`unresolved`,session:t.session};if(t.emit!==void 0)for(let n of a)n.kind===`subagent-result`&&n.isError!==!0&&await t.emit({data:{callId:n.callId,output:typeof n.output==`string`?n.output:JSON.stringify(n.output),subagentName:n.subagentName},type:`subagent.completed`}),await t.emit(createActionResultEvent({result:n,sequence:i.event.sequence,stepIndex:i.event.stepIndex,turnId:i.event.turnId}));let o={...t.session.state};delete o[PENDING_RUNTIME_ACTION_BATCH_KEY];let s={...t.session,state:Object.keys(o).length>0?o:void 0},c=i.childContinuationTokens;if(c!==void 0)for(let e of a){if(e.kind!==`subagent-result`)continue;let t=c[e.callId];t!==void 0&&(s=clearProxyInputRequestsForChild(s,t))}for(let e of a)e.kind!==`subagent-result`||e.usage===void 0||(s=setTurnUsageState(s,accumulateSessionUsage({previous:getTurnUsageState(s.state),usage:e.usage})));let l=a.map(e=>{switch(e.kind){case`load-skill-result`:return{output:toToolResultOutput(e),toolCallId:e.callId,toolName:`load_skill`,type:`tool-result`};case`subagent-result`:return{output:toToolResultOutput(e),toolCallId:e.callId,toolName:e.subagentName,type:`tool-result`};case`tool-result`:return{output:toToolResultOutput(e),toolCallId:e.callId,toolName:e.toolName,type:`tool-result`}}throw Error(`Unsupported runtime action result kind "${String(e)}".`)}),u=[...s.history,...i.responseMessages];return l.length>0&&u.push({content:l,role:`tool`}),{messages:u,outcome:`resolved`,session:s}}function createRuntimeActionRequestFromToolCall(e){let t=e.tools.get(e.toolCall.toolName);return t?.runtimeAction?.kind===`subagent-call`?{callId:e.toolCall.toolCallId,description:t.description,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`subagent-call`,name:t.name,nodeId:t.runtimeAction.nodeId,subagentName:t.runtimeAction.subagentName}:t?.runtimeAction?.kind===`remote-agent-call`?{callId:e.toolCall.toolCallId,description:t.description,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`remote-agent-call`,name:t.name,nodeId:t.runtimeAction.nodeId,remoteAgentName:t.runtimeAction.remoteAgentName??t.name}:{callId:e.toolCall.toolCallId,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`tool-call`,toolName:e.toolCall.toolName}}function resolveToolCallInputObject(e,n){if(e==null||typeof e==`string`&&e.trim()===``)return{};try{return parseJsonObject(typeof e==`string`?parseJsonStringInput(e):e)}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`Failed to parse tool-call arguments for "${n.toolName}" (${n.callId}): ${t}`,{cause:e})}}function parseJsonStringInput(e){try{return JSON.parse(e)}catch{return e}}function toToolResultOutput(e){return typeof e.output==`string`?e.isError===!0?{type:`error-text`,value:e.output}:{type:`text`,value:e.output}:e.isError===!0?{type:`error-json`,value:toMutableJsonValue(e.output)}:{type:`json`,value:toMutableJsonValue(e.output)}}function toMutableJsonValue(e){if(e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e))return e.map(e=>toMutableJsonValue(e));let t={};for(let[n,r]of Object.entries(e))t[n]=toMutableJsonValue(r);return t}export{clearPendingRuntimeActionBatch,createRuntimeActionRequestFromToolCall,getPendingRuntimeActionBatch,hasPendingRuntimeActionBatch,recordPendingSubagentChild,resolvePendingRuntimeActions,resolveRuntimeActionResultsForKeys,resolveToolCallInputObject,setPendingRuntimeActionBatch};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ToolSet, TypedToolCall, TypedToolError } from "ai";
|
|
2
|
+
import type { RuntimeToolCallActionRequest } from "#runtime/actions/types.js";
|
|
2
3
|
/**
|
|
3
4
|
* Returns true when the AI SDK marked the tool call `invalid` (typically
|
|
4
5
|
* because the model emitted unparsable JSON or targeted an unknown tool).
|
|
@@ -14,6 +15,25 @@ export declare function createInvalidToolCallInputError(input: {
|
|
|
14
15
|
readonly error: unknown;
|
|
15
16
|
readonly toolCall: TypedToolCall<ToolSet>;
|
|
16
17
|
}): TypedToolError<ToolSet>;
|
|
18
|
+
/**
|
|
19
|
+
* Resolves a provider-executed tool call into an observable runtime-action
|
|
20
|
+
* request, or the synthesized tool error when the model emitted arguments
|
|
21
|
+
* that cannot satisfy the JSON-object contract.
|
|
22
|
+
*
|
|
23
|
+
* Provider-executed calls skip the AI SDK's input validation, so malformed
|
|
24
|
+
* JSON argument text reaches the harness only here.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveProviderToolCallRequest(toolCall: {
|
|
27
|
+
readonly input?: unknown;
|
|
28
|
+
readonly toolCallId: string;
|
|
29
|
+
readonly toolName: string;
|
|
30
|
+
}): {
|
|
31
|
+
readonly request: RuntimeToolCallActionRequest;
|
|
32
|
+
readonly toolError?: undefined;
|
|
33
|
+
} | {
|
|
34
|
+
readonly request?: undefined;
|
|
35
|
+
readonly toolError: TypedToolError<ToolSet>;
|
|
36
|
+
};
|
|
17
37
|
export declare function getInvalidToolCallInputError(input: {
|
|
18
38
|
readonly toolCall: TypedToolCall<ToolSet>;
|
|
19
39
|
}): TypedToolError<ToolSet> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveToolCallInputObject}from"#harness/runtime-actions.js";function isInvalidToolCall(e){return e.invalid===!0}function createInvalidToolCallInputError(e){let{toolCall:t}=e,n={type:`tool-error`,toolCallId:t.toolCallId,toolName:t.toolName,input:t.input,error:e.error};return t.dynamic===!0&&(n.dynamic=!0),t.providerExecuted===!0&&(n.providerExecuted=!0),t.providerMetadata!==void 0&&(n.providerMetadata=t.providerMetadata),t.toolMetadata!==void 0&&(n.toolMetadata=t.toolMetadata),n}function getInvalidToolCallInputError(t){let{toolCall:n}=t;if(!isInvalidToolCall(n))try{resolveToolCallInputObject(n.input,{callId:n.toolCallId,toolName:n.toolName});return}catch(e){if(e instanceof TypeError)return createInvalidToolCallInputError({error:e,toolCall:n});throw e}}export{createInvalidToolCallInputError,getInvalidToolCallInputError,isInvalidToolCall};
|
|
1
|
+
import{resolveToolCallInputObject}from"#harness/runtime-actions.js";function isInvalidToolCall(e){return e.invalid===!0}function createInvalidToolCallInputError(e){let{toolCall:t}=e,n={type:`tool-error`,toolCallId:t.toolCallId,toolName:t.toolName,input:t.input,error:e.error};return t.dynamic===!0&&(n.dynamic=!0),t.providerExecuted===!0&&(n.providerExecuted=!0),t.providerMetadata!==void 0&&(n.providerMetadata=t.providerMetadata),t.toolMetadata!==void 0&&(n.toolMetadata=t.toolMetadata),n}function resolveProviderToolCallRequest(t){try{return{request:{callId:t.toolCallId,input:resolveToolCallInputObject(t.input,{callId:t.toolCallId,toolName:t.toolName}),kind:`tool-call`,toolName:t.toolName}}}catch(e){if(!(e instanceof TypeError))throw e;return{toolError:createInvalidToolCallInputError({error:e,toolCall:{input:t.input,providerExecuted:!0,toolCallId:t.toolCallId,toolName:t.toolName,type:`tool-call`}})}}}function getInvalidToolCallInputError(t){let{toolCall:n}=t;if(!isInvalidToolCall(n))try{resolveToolCallInputObject(n.input,{callId:n.toolCallId,toolName:n.toolName});return}catch(e){if(e instanceof TypeError)return createInvalidToolCallInputError({error:e,toolCall:n});throw e}}export{createInvalidToolCallInputError,getInvalidToolCallInputError,isInvalidToolCall,resolveProviderToolCallRequest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join,resolve}from"node:path";import{mkdir,rm}from"node:fs/promises";import{resolveOutputDirectory}from"#internal/application/paths.js";import{randomUUID}from"node:crypto";import{VERCEL_EVE_AGENT_SUMMARY_OUTPUT_PATH}from"#internal/vercel-agent-summary.js";async function createApplicationBuildWorkspace(t,n){let r=resolve(t),i=join(r,`.eve`,`builds`,`${Date.now().toString(36)}-${randomUUID()}`),a=join(i,`compiler`),o={appRoot:r,compiler:{artifactsDir:join(a,`.eve`),rootDir:a},host:{artifactsDir:join(i,`host`)},nitro:{buildDir:join(i,`nitro`)
|
|
1
|
+
import{join,resolve}from"node:path";import{mkdir,rm}from"node:fs/promises";import{resolveOutputDirectory}from"#internal/application/paths.js";import{randomUUID}from"node:crypto";import{VERCEL_EVE_AGENT_SUMMARY_OUTPUT_PATH}from"#internal/vercel-agent-summary.js";async function createApplicationBuildWorkspace(t,n){let r=resolve(t),i=join(r,`.eve`,`builds`,`${Date.now().toString(36)}-${randomUUID()}`),a=join(i,`compiler`),o={appRoot:r,compiler:{artifactsDir:join(a,`.eve`),rootDir:a},host:{artifactsDir:join(i,`host`)},nitro:{buildDir:join(i,`nitro`)},publication:{output:{finalDir:n??resolveOutputDirectory(r),stagedDir:join(i,`output`)},summary:{finalPath:join(r,VERCEL_EVE_AGENT_SUMMARY_OUTPUT_PATH),stagedPath:join(i,`agent-summary.json`)}},rootDir:i,workflow:{buildDir:join(i,`workflow`)}};return await mkdir(i,{recursive:!0}),o}async function removeApplicationBuildWorkspace(e){await rm(e.rootDir,{force:!0,recursive:!0})}export{createApplicationBuildWorkspace,removeApplicationBuildWorkspace};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.27.
|
|
1
|
+
import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.27.8`,WORKFLOW_MODULE_ALIASES={"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let n=e;for(;;){if(existsSync(join(n,`package.json`))&&!isBuildOutputPackageRoot(n))return n;let r=dirname(n);if(r===n)throw Error(`Failed to resolve package root from "${e}".`);n=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let r=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(r?.name===t)return r}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function readWorkflowVersionFromManifest(e){let t=e;for(let e of[t.devDependencies,t.dependencies,t.peerDependencies]){let t=e?.[`@workflow/core`];if(typeof t==`string`&&t.trim().length>0)return t}}function resolveExpectedWorkflowVersion(){let e=tryResolvePackageRoot();if(e!==void 0)try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(join(e,`package.json`),`utf8`)))}catch{}try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),`utf8`)))}catch{return}}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/api`||e===`workflow/runtime`)return resolvePackageSourceFilePath(`src/internal/workflow/runtime.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveExpectedWorkflowVersion,resolveInstalledPackageInfo,resolvePackageCompiledFilePath,resolvePackageDependencyPath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { NitroBuildSurface } from "#internal/nitro/host/types.js";
|
|
2
1
|
export declare const EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV = "EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY";
|
|
3
2
|
export declare const EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV = "EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY";
|
|
4
3
|
export interface ApplicationInfo {
|
|
@@ -21,12 +20,8 @@ export declare function isVercelBuildEnvironment(): boolean;
|
|
|
21
20
|
/**
|
|
22
21
|
* Resolves the programmatic Nitro build directory for an app.
|
|
23
22
|
*/
|
|
24
|
-
export declare function resolveNitroBuildDirectory(appRoot: string
|
|
23
|
+
export declare function resolveNitroBuildDirectory(appRoot: string): string;
|
|
25
24
|
export declare function resolveApplicationHostArtifactsDirectory(appRoot: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Resolves the staged Nitro output directory for one isolated build surface.
|
|
28
|
-
*/
|
|
29
|
-
export declare function resolveNitroSurfaceOutputDirectory(appRoot: string, surface: Exclude<NitroBuildSurface, "all">): string;
|
|
30
25
|
/**
|
|
31
26
|
* Resolves the package-owned Workflow DevKit bundle directory for a target app.
|
|
32
27
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveInstalledPackageInfo,resolvePackageRoot,resolvePackageSourceDirectoryPath}from"#internal/application/package.js";import{existsSync,readFileSync,readdirSync,rmSync}from"node:fs";import{join,resolve}from"node:path";import{createHash}from"node:crypto";import{workflowEntryReference}from"#execution/workflow-runtime.js";const EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV=`EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY`,EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV=`EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY`;function resolveApplicationRoot(e=process.cwd()){return resolve(e)}function getWorkflowBuildCacheKey(e){return createHash(`sha256`).update(e).digest(`hex`).slice(0,12)}function isVercelBuildEnvironment(){return!!process.env.VERCEL}function resolveNitroBuildDirectory(e
|
|
1
|
+
import{resolveInstalledPackageInfo,resolvePackageRoot,resolvePackageSourceDirectoryPath}from"#internal/application/package.js";import{existsSync,readFileSync,readdirSync,rmSync}from"node:fs";import{join,resolve}from"node:path";import{createHash}from"node:crypto";import{workflowEntryReference}from"#execution/workflow-runtime.js";const EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV=`EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY`,EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV=`EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY`;function resolveApplicationRoot(e=process.cwd()){return resolve(e)}function getWorkflowBuildCacheKey(e){return createHash(`sha256`).update(e).digest(`hex`).slice(0,12)}function isVercelBuildEnvironment(){return!!process.env.VERCEL}function resolveNitroBuildDirectory(e){return join(e,`.eve`,`nitro`)}function resolveApplicationHostArtifactsDirectory(e){return join(e,`.eve`,`host`)}function resolveWorkflowBuildDirectory(e){let n=join(resolvePackageRoot(),`.eve`,`workflow-cache`);return pruneStaleWorkflowCacheSiblings(n),join(n,getWorkflowBuildCacheKey(e))}function pruneStaleWorkflowCacheSiblings(t){if(!existsSync(t))return;let n=resolveInstalledPackageInfo().version,i;try{i=readdirSync(t)}catch{return}for(let e of i){let r=join(t,e),i=join(r,`eve-cache.json`);if(existsSync(i))try{let e=JSON.parse(readFileSync(i,`utf8`));typeof e.eveVersion==`string`&&e.eveVersion!==n&&rmSync(r,{force:!0,recursive:!0})}catch{}}}function resolveSandboxCacheDirectory(e){return join(e,`.eve`,`sandbox-cache`)}function resolveOutputDirectory(e){return isVercelBuildEnvironment()?join(e,`.vercel`,`output`):join(e,`.output`)}function getApplicationInfo(e){return{appRoot:e,outputDir:resolveOutputDirectory(e),workflowId:workflowEntryReference.workflowId,workflowBuildDir:resolveWorkflowBuildDirectory(e),workflowSourceDir:resolvePackageSourceDirectoryPath(`src/execution`)}}export{EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY_ENV,EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY_ENV,getApplicationInfo,isVercelBuildEnvironment,resolveApplicationHostArtifactsDirectory,resolveApplicationRoot,resolveNitroBuildDirectory,resolveOutputDirectory,resolveSandboxCacheDirectory,resolveWorkflowBuildDirectory};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolvePackageRoot,resolvePackageSourceFilePath}from"#internal/application/package.js";import{dirname,isAbsolute,join,relative,resolve,sep}from"node:path";import{tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{readFile}from"node:fs/promises";import{toErrorMessage}from"#shared/errors.js";import{resolveDiscoveryProject}from"#discover/project.js";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{build,copyPublicAssets,prepare,prerender}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createApplicationBuildWorkspace,removeApplicationBuildWorkspace}from"#internal/application/build-workspace.js";import{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{WorkflowBundleBuilder}from"#internal/workflow-bundle/builder.js";import{normalizeEveVercelFunctionOutput}from"#internal/workflow-bundle/vercel-workflow-output.js";import{createProductionApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{emitVercelAgentSummary}from"#internal/nitro/host/build-vercel-agent-summary.js";import{copyHostMiddlewareFunctions}from"#internal/nitro/host/copy-host-middleware.js";import{prepareProductionApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{runVercelBuildPrewarm}from"#internal/nitro/host/vercel-build-prewarm.js";import{findClosestVercelOutputDirectory}from"#shared/vercel-output-directory.js";function trimTrailingSlash(e){return e.replace(/[\\/]+$/,``)}async function measureBuildPhase(e,t,n){return e===void 0?n():e.measure(t,n)}function isPathInside(e,t){let n=relative(e,t);return n.length===0||!n.startsWith(`..${sep}`)&&n!==`..`&&!isAbsolute(n)}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(e,t){let r=Array.from(new Set([resolve(e),resolve(t)])),a=await findClosestVercelOutputDirectory(e);if(a!==void 0)try{let e=JSON.parse(await readFile(join(a,`config.json`),`utf8`)),t=resolveCoDeployedEveServicePrefix({appRoots:r,configRoot:await resolveVercelOutputConfigRoot(a),config:e});if(t!==void 0)return t}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let s=e;for(;;){for(let e of[join(s,`vercel.json`),join(s,`.vercel`,`output`,`config.json`)])try{let t=JSON.parse(await readFile(e,`utf8`)),i=resolveCoDeployedEveServicePrefix({appRoots:r,configRoot:e.endsWith(`vercel.json`)?s:await resolveVercelOutputConfigRoot(dirname(e)),config:t});if(i!==void 0)return i}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let e=dirname(s);if(e===s)return;s=e}}async function readVercelServerRuntime(e){try{return JSON.parse(await readFile(join(e,`functions`,`__server.func`,`.vc-config.json`),`utf8`)).runtime}catch{return}}async function resolveVercelOutputConfigRoot(e){let t=dirname(dirname(e));try{let e=JSON.parse(await readFile(join(t,`.vercel`,`project.json`),`utf8`));if(isRecord(e)&&isRecord(e.settings)&&typeof e.settings.rootDirectory==`string`&&e.settings.rootDirectory.trim().length>0)return resolve(t,e.settings.rootDirectory)}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}return t}async function emitVercelWorkflowFunctions(t){let n=new WorkflowBundleBuilder({agentName:t.agentName,appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifactsBootstrapPath,outDir:t.workflowBuildDir,publicRoutePrefix:t.publicRoutePrefix,rootDir:resolvePackageRoot(),watch:!1}),r=await readVercelServerRuntime(t.outputDir);await n.buildVercelOutput({flowNitroOutputDir:t.flowNitroOutputDir,outputDir:t.outputDir,runtime:r})}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 buildVercelNitroSurface(e,t,n,r){let a=`nitro.${n}`,o=await measureBuildPhase(r,`${a}.create`,()=>createProductionApplicationNitro(e,{buildDir:join(t.nitro.buildDir,n),outputDir:join(t.nitro.surfaceOutputDir,n),surface:n}));try{return await buildNitroOutput(o,r,a)}finally{await measureBuildPhase(r,`${a}.close`,()=>o.close())}}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 a=await measureBuildPhase(r,`project.resolve`,()=>resolveDiscoveryProject(e)),s=await measureBuildPhase(r,`workspace.create`,()=>createApplicationBuildWorkspace(a.appRoot,t.vercelServiceOutput?.serviceOutputDirectory)),l=!1,u;try{u=await buildApplicationInWorkspace(s,t,r)}catch(e){throw l=e instanceof RecoverablePublicationError,e}finally{l||await measureBuildPhase(r,`workspace.remove`,()=>removeApplicationBuildWorkspace(s))}return r!==void 0&&n!==void 0&&await writeOptionalApplicationBuildProfile({outputDirectory:u,profileOutputPath:n,profiler:r}),u}async function buildApplicationInWorkspace(e,n,r){let a=await measureBuildPhase(r,`host.prepare`,()=>prepareProductionApplicationHost(e));if(!process.env.VERCEL){let t=await measureBuildPhase(r,`nitro.all.create`,()=>createProductionApplicationNitro(a,{buildDir:e.nitro.buildDir,outputDir:e.publication.output.stagedDir,surface:`all`}));try{await buildNitroOutput(t,r,`nitro.all`),await measureBuildPhase(r,`agent-summary.emit`,()=>emitVercelAgentSummary({manifest:a.compileResult.manifest,outputPath:e.publication.summary.stagedPath})),await measureBuildPhase(r,`compiler-artifacts.stage`,()=>stageProductionCompilerArtifacts({compilerArtifactsRoot:e.compiler.artifactsDir,outputDir:e.publication.output.stagedDir}))}finally{await measureBuildPhase(r,`nitro.all.close`,()=>t.close())}return await measureBuildPhase(r,`output.publish`,()=>publishCompletedApplicationBuild(e)),e.publication.output.finalDir}let o=await measureBuildPhase(r,`vercel.service-prefix.resolve`,()=>resolveCoDeployedEveServicePrefixForVercelFunctionOutput(a.appRoot,a.compileResult.project.agentRoot)),s=await measureBuildPhase(r,`nitro.app.create`,()=>createProductionApplicationNitro(a,{buildDir:join(e.nitro.buildDir,`app`),outputDir:e.publication.output.stagedDir,surface:`app`}));try{await buildNitroOutput(s,r,`nitro.app`),n.skipVercelSandboxPrewarm||await measureBuildPhase(r,`sandbox.prewarm`,()=>runVercelBuildPrewarm({appRoot:a.appRoot,compiledArtifactsSource:createDiskRuntimeCompiledArtifactsSource(e.compiler.rootDir,{moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:a.appRoot}),log(e){console.log(e)}}));let i=await buildVercelNitroSurface(a,e,`flow`,r);await measureBuildPhase(r,`workflow.emit`,()=>emitVercelWorkflowFunctions({agentName:a.compileResult.manifest.config.name,appRoot:a.appRoot,compiledArtifactsBootstrapPath:a.compiledArtifacts.bootstrapPath,flowNitroOutputDir:i,outputDir:e.publication.output.stagedDir,publicRoutePrefix:n.publicRoutePrefix,workflowBuildDir:e.workflow.buildDir})),o!==void 0&&await measureBuildPhase(r,`vercel.functions.normalize`,()=>normalizeEveVercelFunctionOutput(e.publication.output.stagedDir,{servicePrefix:o}));let c=n.vercelServiceOutput;c!==void 0&&await measureBuildPhase(r,`vercel.host-middleware.copy`,()=>copyHostMiddlewareFunctions({hostOutputDirectory:c.hostOutputDirectory,serviceOutputDirectory:e.publication.output.stagedDir})),await measureBuildPhase(r,`agent-summary.emit`,()=>emitVercelAgentSummary({manifest:a.compileResult.manifest,outputPath:e.publication.summary.stagedPath}))}finally{await measureBuildPhase(r,`nitro.app.close`,()=>s.close())}return await measureBuildPhase(r,`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
|
+
import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{dirname,isAbsolute,join,relative,resolve,sep}from"node:path";import{tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{readFile}from"node:fs/promises";import{toErrorMessage}from"#shared/errors.js";import{resolveDiscoveryProject}from"#discover/project.js";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{build,copyPublicAssets,prepare,prerender}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{createApplicationBuildWorkspace,removeApplicationBuildWorkspace}from"#internal/application/build-workspace.js";import{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{normalizeEveVercelFunctionOutput}from"#internal/workflow-bundle/vercel-workflow-output.js";import{createProductionApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{emitVercelAgentSummary}from"#internal/nitro/host/build-vercel-agent-summary.js";import{copyHostMiddlewareFunctions}from"#internal/nitro/host/copy-host-middleware.js";import{prepareProductionApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{runVercelBuildPrewarm}from"#internal/nitro/host/vercel-build-prewarm.js";import{findClosestVercelOutputDirectory}from"#shared/vercel-output-directory.js";function trimTrailingSlash(e){return e.replace(/[\\/]+$/,``)}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(e,n){let i=Array.from(new Set([resolve(e),resolve(n)])),o=await findClosestVercelOutputDirectory(e);if(o!==void 0)try{let e=JSON.parse(await readFile(join(o,`config.json`),`utf8`)),t=resolveCoDeployedEveServicePrefix({appRoots:i,configRoot:await resolveVercelOutputConfigRoot(o),config:e});if(t!==void 0)return t}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let s=e;for(;;){for(let e of[join(s,`vercel.json`),join(s,`.vercel`,`output`,`config.json`)])try{let n=JSON.parse(await readFile(e,`utf8`)),r=resolveCoDeployedEveServicePrefix({appRoots:i,configRoot:e.endsWith(`vercel.json`)?s:await resolveVercelOutputConfigRoot(dirname(e)),config:n});if(r!==void 0)return r}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let e=dirname(s);if(e===s)return;s=e}}async function resolveVercelOutputConfigRoot(e){let n=dirname(dirname(e));try{let e=JSON.parse(await readFile(join(n,`.vercel`,`project.json`),`utf8`));if(isRecord(e)&&isRecord(e.settings)&&typeof e.settings.rootDirectory==`string`&&e.settings.rootDirectory.trim().length>0)return resolve(n,e.settings.rootDirectory)}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}return n}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(t,n,r){let i=await measureBuildPhase(r,`host.prepare`,()=>prepareProductionApplicationHost(t)),a=!!process.env.VERCEL,o=a?await measureBuildPhase(r,`vercel.service-prefix.resolve`,()=>resolveCoDeployedEveServicePrefixForVercelFunctionOutput(i.appRoot,i.compileResult.project.agentRoot)):void 0,s=await measureBuildPhase(r,`nitro.create`,()=>createProductionApplicationNitro(i,{buildDir:t.nitro.buildDir,outputDir:t.publication.output.stagedDir,publicRoutePrefix:n.publicRoutePrefix}));try{a&&!n.skipVercelSandboxPrewarm&&await measureBuildPhase(r,`sandbox.prewarm`,()=>runVercelBuildPrewarm({appRoot:i.appRoot,compiledArtifactsSource:createDiskRuntimeCompiledArtifactsSource(t.compiler.rootDir,{moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:i.appRoot}),log(e){console.log(e)}})),await buildNitroOutput(s,r,`nitro`),o!==void 0&&await measureBuildPhase(r,`vercel.functions.normalize`,()=>normalizeEveVercelFunctionOutput(t.publication.output.stagedDir,{servicePrefix:o}));let c=n.vercelServiceOutput;c!==void 0&&await measureBuildPhase(r,`vercel.host-middleware.copy`,()=>copyHostMiddlewareFunctions({hostOutputDirectory:c.hostOutputDirectory,serviceOutputDirectory:t.publication.output.stagedDir})),await measureBuildPhase(r,`agent-summary.emit`,()=>emitVercelAgentSummary({manifest:i.compileResult.manifest,outputPath:t.publication.summary.stagedPath})),a||await measureBuildPhase(r,`compiler-artifacts.stage`,()=>stageProductionCompilerArtifacts({compilerArtifactsRoot:t.compiler.artifactsDir,outputDir:t.publication.output.stagedDir}))}finally{await measureBuildPhase(r,`nitro.close`,()=>s.close())}return await measureBuildPhase(r,`output.publish`,()=>publishCompletedApplicationBuild(t)),t.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,12 +1,12 @@
|
|
|
1
1
|
import type { Nitro } from "nitro/types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PreparedApplicationHost } from "#internal/nitro/host/types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Wires eve's package-owned app, channel, workflow inspection, dev-control,
|
|
5
5
|
* and Workflow SDK endpoints into one development Nitro candidate.
|
|
6
6
|
*/
|
|
7
7
|
export declare function configureDevelopmentNitroRoutes(nitro: Nitro, preparedHost: PreparedApplicationHost): Promise<void>;
|
|
8
8
|
/**
|
|
9
|
-
* Wires
|
|
10
|
-
*
|
|
9
|
+
* Wires eve's package-owned app, channel, and Workflow SDK endpoints into the
|
|
10
|
+
* production Nitro host.
|
|
11
11
|
*/
|
|
12
|
-
export declare function configureProductionNitroRoutes(nitro: Nitro, preparedHost: PreparedApplicationHost
|
|
12
|
+
export declare function configureProductionNitroRoutes(nitro: Nitro, preparedHost: PreparedApplicationHost): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH,EVE_HEALTH_ROUTE_PATH}from"#protocol/routes.js";import{resolvePackageRoot,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{dirname,join,relative}from"node:path";import{mkdir,writeFile}from"node:fs/promises";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{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{computeChannelRouteRegistrations,registerChannelVirtualHandlers}from"#internal/nitro/host/channel-routes.js";
|
|
1
|
+
import{EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH,EVE_HEALTH_ROUTE_PATH}from"#protocol/routes.js";import{resolvePackageRoot,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{dirname,join,relative}from"node:path";import{mkdir,writeFile}from"node:fs/promises";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{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{computeChannelRouteRegistrations,registerChannelVirtualHandlers}from"#internal/nitro/host/channel-routes.js";import{EVE_WORKFLOW_FLOW_ROUTE_PATH}from"#internal/nitro/host/vercel-build-output-config.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
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(e,t){let n=join(resolveNitroWorkflowBuildDirectory(e),`${t.bundleName}-handler.mjs`),r=dirname(n),i=createRelativeImportSpecifier(r,t.bundlePath),a=t.directHandlers??[],s=a.length>0&&t.workflowWorldPluginPath!==void 0?createRelativeImportSpecifier(r,t.workflowWorldPluginPath):void 0,c=a.map(e=>{let t=createRelativeImportSpecifier(r,e.bundlePath);return{importSpecifier:t,isOwnBundle:t===i,queuePrefix:e.queuePrefix}});await mkdir(r,{recursive:!0}),await writeFile(n,buildWorkflowFileHandlerSource({bundlePath:i,directHandlers:c,runtimeImportSpecifier:t.runtimeImportSpecifier,workflowWorldPluginImportSpecifier:s})),e.options.handlers.push({handler:n,route:t.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,r){addFrameworkVirtualHandler(e,{args:JSON.stringify({agentName:t.compileResult.manifest.config.name}),handlerExport:`handleHomePageRequest`,method:`GET`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/index.ts`),route:`/`});for(let t of[`GET`,`HEAD`])registerHandler(e,{handlerPath:resolvePackageSourceFilePath(`src/internal/nitro/routes/health.ts`),method:t,route:EVE_HEALTH_ROUTE_PATH});registerChannelVirtualHandlers(e,{artifactsConfig:r,registrations:computeChannelRouteRegistrations(t)})}function registerDevelopmentControlRoutes(n,r){addFrameworkVirtualHandler(n,{args:JSON.stringify({appRoot:r.appRoot}),handlerExport:`handleDevRuntimeArtifactsRequest`,method:`GET`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-runtime-artifacts.ts`),route:EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}),addFrameworkVirtualHandler(n,{args:JSON.stringify(r),handlerExport:`handleDevScheduleDispatchRequest`,method:`POST`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-schedule-dispatch.ts`),route:EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN})}function createWorkflowDirectHandlerEntry(e,t){return{bundlePath:t,queuePrefix:deriveEveWorkflowQueuePrefix(e.compileResult.manifest.config.name)}}async function registerWorkflowRoute(e,t,n,r){await addWorkflowFileHandler(e,{bundleName:`workflows`,bundlePath:n,directHandlers:r,route
|
|
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,r){addFrameworkVirtualHandler(e,{args:JSON.stringify({agentName:t.compileResult.manifest.config.name}),handlerExport:`handleHomePageRequest`,method:`GET`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/index.ts`),route:`/`});for(let t of[`GET`,`HEAD`])registerHandler(e,{handlerPath:resolvePackageSourceFilePath(`src/internal/nitro/routes/health.ts`),method:t,route:EVE_HEALTH_ROUTE_PATH});registerChannelVirtualHandlers(e,{artifactsConfig:r,registrations:computeChannelRouteRegistrations(t)})}function registerDevelopmentControlRoutes(n,r){addFrameworkVirtualHandler(n,{args:JSON.stringify({appRoot:r.appRoot}),handlerExport:`handleDevRuntimeArtifactsRequest`,method:`GET`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-runtime-artifacts.ts`),route:EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}),addFrameworkVirtualHandler(n,{args:JSON.stringify(r),handlerExport:`handleDevScheduleDispatchRequest`,method:`POST`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-schedule-dispatch.ts`),route:EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN})}function createWorkflowDirectHandlerEntry(e,t){return{bundlePath:t,queuePrefix:deriveEveWorkflowQueuePrefix(e.compileResult.manifest.config.name)}}async function registerWorkflowRoute(e,t,n,r){await addWorkflowFileHandler(e,{bundleName:`workflows`,bundlePath:n,directHandlers:r,route:EVE_WORKFLOW_FLOW_ROUTE_PATH,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 a=createDevelopmentNitroArtifactsConfig({appRoot:t.appRoot,configuredWorld:t.compileResult.manifest.config.experimental?.workflow?.world});registerApplicationRoutes(e,t,a),registerDevelopmentControlRoutes(e,a);let o=join(n,`workflows.mjs`),s=[];usesParentDevelopmentWorkflowWorld(t.compileResult.manifest.config.experimental?.workflow?.world)||s.push(createWorkflowDirectHandlerEntry(t,o)),await registerWorkflowRoute(e,t,o,s),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`)})}),registerApplicationRoutes(e,t,createProductionNitroArtifactsConfig());let i=join(t.workflowBuildDir,`workflows.mjs`),a=t.compileResult.manifest.config.experimental?.workflow?.world!==void 0;await registerWorkflowRoute(e,t,i,!isVercelBuildEnvironment()&&a?[createWorkflowDirectHandlerEntry(t,i)]:[]),e.routing.sync()}export{configureDevelopmentNitroRoutes,configureProductionNitroRoutes};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Nitro } from "nitro/types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PreparedApplicationHost, PreparedDevelopmentApplicationHost } from "#internal/nitro/host/types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Hosted Vercel builds can prune local sandbox backends only when the
|
|
5
5
|
* app did not explicitly configure one. Omitted backends resolve through
|
|
@@ -17,14 +17,18 @@ export declare function createDevelopmentApplicationNitro(preparedHost: Prepared
|
|
|
17
17
|
interface ProductionApplicationNitroOptions {
|
|
18
18
|
readonly buildDir: string;
|
|
19
19
|
readonly outputDir: string;
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Agent's resolved public route prefix, baked into the Vercel flow
|
|
22
|
+
* function's environment for callback-URL minting behind a per-agent mount.
|
|
23
|
+
*/
|
|
24
|
+
readonly publicRoutePrefix?: string;
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
23
|
-
* Creates a build-mode Nitro host for one production
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* `outputDir` place all
|
|
27
|
-
* workspace.
|
|
27
|
+
* Creates a build-mode Nitro host for one production build. Every route group
|
|
28
|
+
* (application, workflow, schedules) is registered in the same host; on Vercel
|
|
29
|
+
* the workflow flow route additionally becomes its own queue-triggered function
|
|
30
|
+
* through the preset's `functionRules`. `buildDir`/`outputDir` place all
|
|
31
|
+
* bundler state inside the invocation-owned build workspace.
|
|
28
32
|
*/
|
|
29
33
|
export declare function createProductionApplicationNitro(preparedHost: PreparedApplicationHost, options: ProductionApplicationNitroOptions): Promise<Nitro>;
|
|
30
34
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{dirname,isAbsolute,join,relative,resolve}from"node:path";import{readFile}from"node:fs/promises";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{createExtensionScopePlugin}from"#internal/bundler/extension-scope-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";import{transformDynamicToolExecute}from"#internal/workflow-bundle/dynamic-tool-transform.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 includesApplicationSurface(e){return e===`all`||e===`app`}function includesWorkflowSurface(e){return e===`all`||e===`flow`}function includesWorkflowStepRegistrations(e){return includesWorkflowSurface(e)}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,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.config.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(e,t){let n=await readFile(e,`utf8`),r=new Set;for(let i of parseImportedModuleSpecifiers(n)){let n=resolveNitroImportPath(t,i,e);n!==null&&r.add(normalizeStepTransformComparisonPath(n))}return r}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 c=relative(r,i).replaceAll(`\\`,`/`);if(c.startsWith(`../`)&&(c=c.split(`/`).filter(e=>e!==`..`).join(`/`)),c.includes(`:`)||c.startsWith(`/`)){let e=i.split(`/`).pop();return e===void 0||e.length===0?`unknown.ts`:e}return c}function createPackageRelativeTransformFilename(t){let n=normalizePath(resolvePackageRoot()).replace(/\/$/,``),r=normalizePath(t),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 addDynamicToolTransformPlugin(e){e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({async transform(e,t){if(!t.includes(`/tools/`))return null;let n=await transformDynamicToolExecute(t,e);return n===null?null:{code:n.code,map:null}},name:`eve:dynamic-tool-transform`})})}function addInstrumentationModuleSideEffectsPlugin(e,t){let n=normalizePath(t);e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({name:`eve:instrumentation-module-side-effects`,resolveId(e){return normalizePath(e)===n?{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.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,n){if(addNitroRoutingImportSpecifierPlugin(e),includesWorkflowSurface(n)){let n=resolveWorkflowAliases();for(let[t,r]of Object.entries(n))e.options.alias[t]=r;addWorkflowModuleSideEffectsPlugin(e,t.workflowBuildDir),patchWorkflowTransformExcludePath(e,t.workflowBuildDir)}addDynamicToolTransformPlugin(e),t.compiledArtifacts.instrumentationSourcePath!==void 0&&addInstrumentationModuleSideEffectsPlugin(e,t.compiledArtifacts.instrumentationSourcePath)}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 n=e.workspace.nitroBuildDir,r=createApplicationNitroBundlerConfiguration(e,void 0),i=createApplicationNitroPlugins(e);await prepareEveVersionedCacheDirectory(n);let a=await createNitro({_cli:{command:`dev`},buildDir:n,dev:!0,features:{websocket:!0},logLevel:1,output:{dir:e.workspace.nitroOutputDir},plugins:i,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:r.nitroRolldownConfig,rollupConfig:r.nitroRollupConfig,rootDir:e.appRoot,serverDir:!1,traceDeps:r.tracedAppDependencies,vercel:createEveVercelOptions(!1),watchOptions:createDevelopmentWatchOptions(e.appRoot)},{watch:!0});await writeEveVersionedCacheMetadata(n);let s=join(a.options.buildDir,`workflow`,`steps.mjs`);configureSharedApplicationNitro(a,e,`all`);let c=configureNitroStepPlugins(a,s);return a.hooks.hook(`dev:reload`,()=>{for(let e of c)e()}),externalizeDevelopmentWorkflowBundle(a,e),await configureDevelopmentNitroRoutes(a,e),await addNitroStepNoExternals(a,s),a}async function createProductionApplicationNitro(e,r){let i=resolveProductionNitroPreset(),a=createApplicationNitroBundlerConfiguration(e,i),s=createApplicationNitroPlugins(e);s.push(resolvePackageSourceFilePath(`src/internal/nitro/host/sandbox-shutdown-plugin.ts`)),await prepareEveVersionedCacheDirectory(r.buildDir);let c=await createNitro({_cli:{command:`build`},buildDir:r.buildDir,dev:!1,features:{websocket:includesApplicationSurface(r.surface)&&manifestHasWebSocketChannel(e.compileResult.manifest)},output:{dir:r.outputDir},preset:i,plugins:s,publicAssets:[],scanDirs:includesWorkflowStepRegistrations(r.surface)?[resolvePackageSourceDirectoryPath(`src/execution`)]:void 0,rolldownConfig:a.nitroRolldownConfig,rollupConfig:a.nitroRollupConfig,rootDir:e.appRoot,serverDir:!1,traceDeps:a.tracedAppDependencies,vercel:createEveVercelOptions(i===`vercel`&&includesApplicationSurface(r.surface))});return await writeEveVersionedCacheMetadata(r.buildDir),configureSharedApplicationNitro(c,e,r.surface),includesWorkflowStepRegistrations(r.surface)&&configureNitroStepPlugins(c,join(e.workflowBuildDir,`steps.mjs`)),includesApplicationSurface(r.surface)&&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,r.surface),includesWorkflowStepRegistrations(r.surface)&&await addNitroStepNoExternals(c,join(e.workflowBuildDir,`steps.mjs`)),c}export{createDevelopmentApplicationNitro,createProductionApplicationNitro,shouldPruneLocalSandboxBackends};
|
|
1
|
+
import{resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{dirname,isAbsolute,join,relative,resolve}from"node:path";import{readFile}from"node:fs/promises";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{createExtensionScopePlugin}from"#internal/bundler/extension-scope-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";import{transformDynamicToolExecute}from"#internal/workflow-bundle/dynamic-tool-transform.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,...e.compileResult.manifest.subagents.map(e=>e.agent)].flatMap(e=>e.config.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(e,t){let n=await readFile(e,`utf8`),r=new Set;for(let i of parseImportedModuleSpecifiers(n)){let n=resolveNitroImportPath(t,i,e);n!==null&&r.add(normalizeStepTransformComparisonPath(n))}return r}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 c=relative(r,i).replaceAll(`\\`,`/`);if(c.startsWith(`../`)&&(c=c.split(`/`).filter(e=>e!==`..`).join(`/`)),c.includes(`:`)||c.startsWith(`/`)){let e=i.split(`/`).pop();return e===void 0||e.length===0?`unknown.ts`:e}return c}function createPackageRelativeTransformFilename(t){let n=normalizePath(resolvePackageRoot()).replace(/\/$/,``),r=normalizePath(t),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 addDynamicToolTransformPlugin(e){e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({async transform(e,t){if(!t.includes(`/tools/`))return null;let n=await transformDynamicToolExecute(t,e);return n===null?null:{code:n.code,map:null}},name:`eve:dynamic-tool-transform`})})}function addInstrumentationModuleSideEffectsPlugin(e,t){let n=normalizePath(t);e.hooks.hook(`rollup:before`,(e,t)=>{Array.isArray(t.plugins)&&t.plugins.unshift({name:`eve:instrumentation-module-side-effects`,resolveId(e){return normalizePath(e)===n?{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.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),addDynamicToolTransformPlugin(e),t.compiledArtifacts.instrumentationSourcePath!==void 0&&addInstrumentationModuleSideEffectsPlugin(e,t.compiledArtifacts.instrumentationSourcePath)}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 n=e.workspace.nitroBuildDir,r=createApplicationNitroBundlerConfiguration(e,void 0),i=createApplicationNitroPlugins(e);await prepareEveVersionedCacheDirectory(n);let a=await createNitro({_cli:{command:`dev`},buildDir:n,dev:!0,features:{websocket:!0},logLevel:1,output:{dir:e.workspace.nitroOutputDir},plugins:i,publicAssets:[],scanDirs:[resolvePackageSourceDirectoryPath(`src/execution`)],rolldownConfig:r.nitroRolldownConfig,rollupConfig:r.nitroRollupConfig,rootDir:e.appRoot,serverDir:!1,traceDeps:r.tracedAppDependencies,vercel:createEveVercelOptions({agentName:e.compileResult.manifest.config.name,enabled:!1}),watchOptions:createDevelopmentWatchOptions(e.appRoot)},{watch:!0});await writeEveVersionedCacheMetadata(n);let s=join(a.options.buildDir,`workflow`,`steps.mjs`);configureSharedApplicationNitro(a,e);let c=configureNitroStepPlugins(a,s);return a.hooks.hook(`dev:reload`,()=>{for(let e of c)e()}),externalizeDevelopmentWorkflowBundle(a,e),await configureDevelopmentNitroRoutes(a,e),await addNitroStepNoExternals(a,s),a}async function createProductionApplicationNitro(e,r){let i=resolveProductionNitroPreset(),a=createApplicationNitroBundlerConfiguration(e,i),s=createApplicationNitroPlugins(e);s.push(resolvePackageSourceFilePath(`src/internal/nitro/host/sandbox-shutdown-plugin.ts`)),await prepareEveVersionedCacheDirectory(r.buildDir);let c=await createNitro({_cli:{command:`build`},buildDir:r.buildDir,dev:!1,features:{websocket:manifestHasWebSocketChannel(e.compileResult.manifest)},output:{dir:r.outputDir},preset:i,plugins:s,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:r.publicRoutePrefix})});return await writeEveVersionedCacheMetadata(r.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};
|
|
@@ -6,10 +6,6 @@ import type { DevBootProgressReporter } from "#internal/dev-boot-progress.js";
|
|
|
6
6
|
import type { DevelopmentGeneration } from "#internal/nitro/development-generation.js";
|
|
7
7
|
import type { DevelopmentHostWorkspace } from "#internal/nitro/host/dev-host-workspace.js";
|
|
8
8
|
import type { DevelopmentWorkspaceExtension } from "#internal/nitro/host/dev-workspace-extensions.js";
|
|
9
|
-
/**
|
|
10
|
-
* Route surface included in one programmatic Nitro host build.
|
|
11
|
-
*/
|
|
12
|
-
export type NitroBuildSurface = "all" | "app" | "flow";
|
|
13
9
|
/** Options for one production application build. */
|
|
14
10
|
export interface ApplicationBuildOptions {
|
|
15
11
|
/** Absolute path for an optional machine-readable profile of a successful build. */
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/** Route Nitro's Vercel preset emits as the queue-triggered workflow function. */
|
|
2
|
+
export declare const EVE_WORKFLOW_FLOW_ROUTE_PATH = "/.well-known/workflow/v1/flow";
|
|
3
|
+
/**
|
|
4
|
+
* Builds eve's Vercel preset options.
|
|
5
|
+
*
|
|
6
|
+
* The flow route's `functionRules` entry makes Nitro emit a dedicated
|
|
7
|
+
* `flow.func` from the same build output, carrying the agent's queue trigger,
|
|
8
|
+
* an extended execution window, and the environment the deployed workflow
|
|
9
|
+
* runtime needs. Every other function setting (runtime, memory, streaming) is
|
|
10
|
+
* inherited from the base server function config.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createEveVercelOptions(input: {
|
|
13
|
+
agentName: string;
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
publicRoutePrefix?: string;
|
|
16
|
+
}): {
|
|
2
17
|
config: {
|
|
3
18
|
version: 3;
|
|
4
19
|
framework: {
|
|
@@ -6,4 +21,17 @@ export declare function createEveVercelOptions(enabled: boolean): {
|
|
|
6
21
|
version: string;
|
|
7
22
|
};
|
|
8
23
|
};
|
|
24
|
+
functionRules: {
|
|
25
|
+
"/.well-known/workflow/v1/flow": {
|
|
26
|
+
maxDuration: "max";
|
|
27
|
+
experimentalTriggers: {
|
|
28
|
+
type: "queue/v2beta";
|
|
29
|
+
topic: string;
|
|
30
|
+
consumer: string;
|
|
31
|
+
retryAfterSeconds: number;
|
|
32
|
+
initialDelaySeconds: number;
|
|
33
|
+
}[];
|
|
34
|
+
environment: Record<string, string>;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
9
37
|
} | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";function createEveVercelOptions(e){if(e)return{config:{version:3,framework:{slug:EVE_PACKAGE_NAME,version:resolveInstalledPackageInfo().version}}}}export{createEveVercelOptions};
|
|
1
|
+
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{EVE_PUBLIC_ROUTE_PREFIX_ENV,normalizePublicRoutePrefix}from"#shared/public-route-prefix.js";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{createEveWorkflowQueueTrigger}from"#internal/workflow/queue-namespace.js";const EVE_WORKFLOW_FLOW_ROUTE_PATH=`/.well-known/workflow/v1/flow`;function createEveVercelOptions(e){if(!e.enabled)return;let t={WORKFLOW_PRECONDITION_GUARD:`1`},n=normalizePublicRoutePrefix(e.publicRoutePrefix);return n!==void 0&&(t[EVE_PUBLIC_ROUTE_PREFIX_ENV]=n),{config:{version:3,framework:{slug:EVE_PACKAGE_NAME,version:resolveInstalledPackageInfo().version}},functionRules:{[EVE_WORKFLOW_FLOW_ROUTE_PATH]:{maxDuration:`max`,experimentalTriggers:[createEveWorkflowQueueTrigger(e.agentName)],environment:t}}}}export{EVE_WORKFLOW_FLOW_ROUTE_PATH,createEveVercelOptions};
|
|
@@ -5,5 +5,13 @@ export declare function deriveEveWorkflowQueueNamespace(agentName: string): stri
|
|
|
5
5
|
export declare function deriveEveWorkflowQueuePrefix(agentName: string): string;
|
|
6
6
|
/** Derives the queue topic registered for an eve agent's workflow handler. */
|
|
7
7
|
export declare function deriveEveWorkflowQueueTopic(agentName: string): string;
|
|
8
|
+
/** Builds the Vercel queue trigger that invokes an eve agent's flow function. */
|
|
9
|
+
export declare function createEveWorkflowQueueTrigger(agentName: string): {
|
|
10
|
+
type: "queue/v2beta";
|
|
11
|
+
topic: string;
|
|
12
|
+
consumer: string;
|
|
13
|
+
retryAfterSeconds: number;
|
|
14
|
+
initialDelaySeconds: number;
|
|
15
|
+
};
|
|
8
16
|
/** Installs the agent-scoped namespace used by Workflow runtime operations. */
|
|
9
17
|
export declare function installEveWorkflowQueueNamespace(agentName: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const WORKFLOW_QUEUE_NAMESPACE_ENV=`WORKFLOW_QUEUE_NAMESPACE`;function deriveEveWorkflowQueueNamespace(e){return`eve${Array.from(new TextEncoder().encode(e),e=>e.toString(16).padStart(2,`0`)).join(``)}`}function deriveEveWorkflowQueuePrefix(e){return`__${deriveEveWorkflowQueueNamespace(e)}_wkf_workflow_`}function deriveEveWorkflowQueueTopic(e){return`${deriveEveWorkflowQueuePrefix(e)}*`}function installEveWorkflowQueueNamespace(t){let n=deriveEveWorkflowQueueNamespace(t);return process.env[WORKFLOW_QUEUE_NAMESPACE_ENV]=n,n}export{WORKFLOW_QUEUE_NAMESPACE_ENV,deriveEveWorkflowQueueNamespace,deriveEveWorkflowQueuePrefix,deriveEveWorkflowQueueTopic,installEveWorkflowQueueNamespace};
|
|
1
|
+
const WORKFLOW_QUEUE_NAMESPACE_ENV=`WORKFLOW_QUEUE_NAMESPACE`;function deriveEveWorkflowQueueNamespace(e){return`eve${Array.from(new TextEncoder().encode(e),e=>e.toString(16).padStart(2,`0`)).join(``)}`}function deriveEveWorkflowQueuePrefix(e){return`__${deriveEveWorkflowQueueNamespace(e)}_wkf_workflow_`}function deriveEveWorkflowQueueTopic(e){return`${deriveEveWorkflowQueuePrefix(e)}*`}function createEveWorkflowQueueTrigger(e){return{type:`queue/v2beta`,topic:deriveEveWorkflowQueueTopic(e),consumer:`default`,retryAfterSeconds:5,initialDelaySeconds:0}}function installEveWorkflowQueueNamespace(t){let n=deriveEveWorkflowQueueNamespace(t);return process.env[WORKFLOW_QUEUE_NAMESPACE_ENV]=n,n}export{WORKFLOW_QUEUE_NAMESPACE_ENV,createEveWorkflowQueueTrigger,deriveEveWorkflowQueueNamespace,deriveEveWorkflowQueuePrefix,deriveEveWorkflowQueueTopic,installEveWorkflowQueueNamespace};
|
|
@@ -5,11 +5,6 @@ export interface WorkflowBundleBuilderOptions {
|
|
|
5
5
|
appRoot: string;
|
|
6
6
|
compiledArtifactsBootstrapPath: string;
|
|
7
7
|
outDir: string;
|
|
8
|
-
/**
|
|
9
|
-
* The agent's resolved public route prefix, baked into every emitted Vercel
|
|
10
|
-
* workflow function's environment for callback-URL minting.
|
|
11
|
-
*/
|
|
12
|
-
publicRoutePrefix?: string;
|
|
13
8
|
rootDir: string;
|
|
14
9
|
watch: boolean;
|
|
15
10
|
/** Test-harness-only: also scans `src/internal/testing/`. */
|
|
@@ -18,9 +18,4 @@ export declare class WorkflowBundleBuilder {
|
|
|
18
18
|
manifestDir: string;
|
|
19
19
|
workflowBundlePath: string;
|
|
20
20
|
}): Promise<string | undefined>;
|
|
21
|
-
buildVercelOutput(options: {
|
|
22
|
-
flowNitroOutputDir: string;
|
|
23
|
-
outputDir: string;
|
|
24
|
-
runtime?: string;
|
|
25
|
-
}): Promise<void>;
|
|
26
21
|
}
|