eve 0.15.3 → 0.15.5
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 +15 -0
- package/dist/src/chunks/{use-eve-agent-8X2UMr8q.js → use-eve-agent-BEOUv37s.js} +70 -0
- package/dist/src/chunks/{use-eve-agent-9ZNiSFMb.js → use-eve-agent-C25KOe9i.js} +70 -0
- package/dist/src/client/authorization-message-parts.d.ts +4 -0
- package/dist/src/client/authorization-message-parts.js +1 -0
- package/dist/src/client/index.d.ts +2 -2
- package/dist/src/client/message-reducer-types.d.ts +40 -1
- package/dist/src/client/message-reducer.d.ts +3 -5
- package/dist/src/client/message-reducer.js +1 -1
- package/dist/src/evals/index.d.ts +2 -0
- package/dist/src/evals/index.js +1 -1
- package/dist/src/evals/mock-model.d.ts +93 -0
- package/dist/src/evals/mock-model.js +1 -0
- package/dist/src/execution/sandbox/prewarm.js +2 -2
- package/dist/src/internal/application/compiled-artifacts.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +2 -2
- package/dist/src/internal/workflow/queue-namespace.d.ts +8 -3
- package/dist/src/internal/workflow/queue-namespace.js +1 -1
- package/dist/src/internal/workflow/runtime.d.ts +0 -1
- package/dist/src/internal/workflow/runtime.js +1 -1
- package/dist/src/internal/workflow-bundle/builder-support.d.ts +11 -0
- package/dist/src/internal/workflow-bundle/builder-support.js +2 -2
- package/dist/src/internal/workflow-bundle/builder.d.ts +1 -11
- package/dist/src/internal/workflow-bundle/builder.js +3 -3
- package/dist/src/internal/workflow-bundle/workflow-builders.d.ts +6 -6
- package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
- package/dist/src/protocol/message.d.ts +14 -10
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/defaults.js +3 -3
- package/dist/src/public/channels/slack/limits.d.ts +5 -3
- package/dist/src/public/channels/slack/limits.js +1 -1
- package/dist/src/react/index.d.ts +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
- package/dist/src/setup/scaffold/create/web-template.js +105 -1
- package/dist/src/svelte/index.d.ts +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.d.ts +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/evals/overview.mdx +38 -0
- package/docs/guides/frontend/overview.mdx +34 -4
- package/docs/reference/typescript-api.md +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# eve
|
|
2
2
|
|
|
3
|
+
## 0.15.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8078807: Render authorization prompts in the default web chat projection. Scaffolded web UIs now show OAuth sign-in affordances from `authorization.required` events and update them when authorization completes.
|
|
8
|
+
|
|
9
|
+
## 0.15.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- da83b03: Slack assistant-thread status text now strips lightweight Markdown before calling Slack, so model progress updates like `**Considering turbo tasks**` display without literal formatting markers.
|
|
14
|
+
- 5b31627: Add a deterministic `mockModel` eval helper with static, prompt-aware, and tool-calling responses.
|
|
15
|
+
- 2e00da7: Scope workflow queue prefixes to each eve agent so multiple uniquely named agents can deploy in the same project without consuming one another's workflow messages.
|
|
16
|
+
- 86ae773: Clarify Vercel build failures when an agent pins the Docker or microsandbox sandbox backend. The error now explains those local backends are unavailable on Vercel and directs users to `defaultBackend()` or an explicit Vercel-compatible backend.
|
|
17
|
+
|
|
3
18
|
## 0.15.3
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -1111,6 +1111,52 @@ function toTerminalStreamFailureError(event) {
|
|
|
1111
1111
|
return error;
|
|
1112
1112
|
}
|
|
1113
1113
|
|
|
1114
|
+
//#endregion
|
|
1115
|
+
//#region src/client/authorization-message-parts.ts
|
|
1116
|
+
function createAuthorizationRequiredPart(event) {
|
|
1117
|
+
const displayName = event.data.authorization?.displayName ?? formatAuthorizationDisplayName(event.data.name);
|
|
1118
|
+
return {
|
|
1119
|
+
authorization: event.data.authorization,
|
|
1120
|
+
description: normalizeAuthorizationDescription(event.data.description, event.data.name, displayName),
|
|
1121
|
+
displayName,
|
|
1122
|
+
name: event.data.name,
|
|
1123
|
+
state: "required",
|
|
1124
|
+
stepIndex: event.data.stepIndex,
|
|
1125
|
+
turnId: event.data.turnId,
|
|
1126
|
+
type: "authorization"
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
function createAuthorizationCompletedPart(event, existing) {
|
|
1130
|
+
const displayName = event.data.authorization?.displayName ?? existing?.displayName ?? formatAuthorizationDisplayName(event.data.name);
|
|
1131
|
+
return {
|
|
1132
|
+
authorization: existing?.authorization || event.data.authorization ? {
|
|
1133
|
+
...existing?.authorization,
|
|
1134
|
+
...event.data.authorization
|
|
1135
|
+
} : void 0,
|
|
1136
|
+
description: existing?.description ?? buildCompletedAuthorizationDescription(displayName, event.data.outcome, event.data.reason),
|
|
1137
|
+
displayName,
|
|
1138
|
+
name: event.data.name,
|
|
1139
|
+
outcome: event.data.outcome,
|
|
1140
|
+
reason: event.data.reason,
|
|
1141
|
+
state: "completed",
|
|
1142
|
+
stepIndex: existing?.stepIndex ?? event.data.stepIndex,
|
|
1143
|
+
turnId: existing?.turnId ?? event.data.turnId,
|
|
1144
|
+
type: "authorization"
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
function buildCompletedAuthorizationDescription(displayName, outcome, reason) {
|
|
1148
|
+
if (outcome === "authorized") return `${displayName} connected.`;
|
|
1149
|
+
return `${displayName} authorization ${outcome}${reason !== void 0 ? ` (${reason})` : ""}.`;
|
|
1150
|
+
}
|
|
1151
|
+
function normalizeAuthorizationDescription(description, name, displayName) {
|
|
1152
|
+
if (description === `Authorization required for ${name}`) return `Authorization required for ${displayName}`;
|
|
1153
|
+
return description;
|
|
1154
|
+
}
|
|
1155
|
+
function formatAuthorizationDisplayName(name) {
|
|
1156
|
+
if (name.length === 0) return name;
|
|
1157
|
+
return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1114
1160
|
//#endregion
|
|
1115
1161
|
//#region src/client/message-reducer.ts
|
|
1116
1162
|
function defaultMessageReducer() {
|
|
@@ -1253,6 +1299,8 @@ function reduceMessageData(data, event) {
|
|
|
1253
1299
|
if (existing !== void 0) return updateToolPart(data, event.data.result.callId, nextPart);
|
|
1254
1300
|
return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), nextPart));
|
|
1255
1301
|
}
|
|
1302
|
+
case "authorization.required": return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), createAuthorizationRequiredPart(event)));
|
|
1303
|
+
case "authorization.completed": return completeAuthorization(data, event);
|
|
1256
1304
|
case "message.appended": return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), {
|
|
1257
1305
|
state: "streaming",
|
|
1258
1306
|
stepIndex: event.data.stepIndex,
|
|
@@ -1360,9 +1408,30 @@ function updateToolPart(data, toolCallId, next) {
|
|
|
1360
1408
|
if (!message) return data;
|
|
1361
1409
|
return upsertMessage(data, upsertPart(message, next));
|
|
1362
1410
|
}
|
|
1411
|
+
function completeAuthorization(data, event) {
|
|
1412
|
+
const existing = findLatestPendingAuthorizationPart(data, event.data.name);
|
|
1413
|
+
const next = createAuthorizationCompletedPart(event, existing);
|
|
1414
|
+
if (existing !== void 0) return updateAuthorizationPart(data, existing, next);
|
|
1415
|
+
return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), next));
|
|
1416
|
+
}
|
|
1417
|
+
function updateAuthorizationPart(data, existing, next) {
|
|
1418
|
+
const message = data.messages.find((candidate) => candidate.role === "assistant" && candidate.parts.some((part) => part === existing));
|
|
1419
|
+
if (!message) return data;
|
|
1420
|
+
return upsertMessage(data, upsertPart(message, next));
|
|
1421
|
+
}
|
|
1363
1422
|
function findToolPart(data, toolCallId) {
|
|
1364
1423
|
for (const message of data.messages) for (const part of message.parts) if (part.type === "dynamic-tool" && part.toolCallId === toolCallId) return part;
|
|
1365
1424
|
}
|
|
1425
|
+
function findLatestPendingAuthorizationPart(data, name) {
|
|
1426
|
+
for (let messageIndex = data.messages.length - 1; messageIndex >= 0; messageIndex -= 1) {
|
|
1427
|
+
const message = data.messages[messageIndex];
|
|
1428
|
+
if (message?.role !== "assistant") continue;
|
|
1429
|
+
for (let partIndex = message.parts.length - 1; partIndex >= 0; partIndex -= 1) {
|
|
1430
|
+
const part = message.parts[partIndex];
|
|
1431
|
+
if (part?.type === "authorization" && part.state === "required" && part.name === name) return part;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1366
1435
|
function findToolPartByApprovalId(data, approvalId) {
|
|
1367
1436
|
for (const message of data.messages) for (const part of message.parts) if (part.type === "dynamic-tool" && part.approval?.id === approvalId) return part;
|
|
1368
1437
|
}
|
|
@@ -1371,6 +1440,7 @@ function partKey(part) {
|
|
|
1371
1440
|
case "text": return `text:${part.stepIndex ?? 0}`;
|
|
1372
1441
|
case "reasoning": return `reasoning:${part.stepIndex ?? 0}`;
|
|
1373
1442
|
case "step-start": return "step-start";
|
|
1443
|
+
case "authorization": return `authorization:${part.turnId}:${part.stepIndex}:${part.name}`;
|
|
1374
1444
|
case "dynamic-tool": return `dynamic-tool:${part.toolCallId}`;
|
|
1375
1445
|
}
|
|
1376
1446
|
}
|
|
@@ -1111,6 +1111,52 @@ function toTerminalStreamFailureError(event) {
|
|
|
1111
1111
|
return error;
|
|
1112
1112
|
}
|
|
1113
1113
|
|
|
1114
|
+
//#endregion
|
|
1115
|
+
//#region src/client/authorization-message-parts.ts
|
|
1116
|
+
function createAuthorizationRequiredPart(event) {
|
|
1117
|
+
const displayName = event.data.authorization?.displayName ?? formatAuthorizationDisplayName(event.data.name);
|
|
1118
|
+
return {
|
|
1119
|
+
authorization: event.data.authorization,
|
|
1120
|
+
description: normalizeAuthorizationDescription(event.data.description, event.data.name, displayName),
|
|
1121
|
+
displayName,
|
|
1122
|
+
name: event.data.name,
|
|
1123
|
+
state: "required",
|
|
1124
|
+
stepIndex: event.data.stepIndex,
|
|
1125
|
+
turnId: event.data.turnId,
|
|
1126
|
+
type: "authorization"
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
function createAuthorizationCompletedPart(event, existing) {
|
|
1130
|
+
const displayName = event.data.authorization?.displayName ?? existing?.displayName ?? formatAuthorizationDisplayName(event.data.name);
|
|
1131
|
+
return {
|
|
1132
|
+
authorization: existing?.authorization || event.data.authorization ? {
|
|
1133
|
+
...existing?.authorization,
|
|
1134
|
+
...event.data.authorization
|
|
1135
|
+
} : void 0,
|
|
1136
|
+
description: existing?.description ?? buildCompletedAuthorizationDescription(displayName, event.data.outcome, event.data.reason),
|
|
1137
|
+
displayName,
|
|
1138
|
+
name: event.data.name,
|
|
1139
|
+
outcome: event.data.outcome,
|
|
1140
|
+
reason: event.data.reason,
|
|
1141
|
+
state: "completed",
|
|
1142
|
+
stepIndex: existing?.stepIndex ?? event.data.stepIndex,
|
|
1143
|
+
turnId: existing?.turnId ?? event.data.turnId,
|
|
1144
|
+
type: "authorization"
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
function buildCompletedAuthorizationDescription(displayName, outcome, reason) {
|
|
1148
|
+
if (outcome === "authorized") return `${displayName} connected.`;
|
|
1149
|
+
return `${displayName} authorization ${outcome}${reason !== void 0 ? ` (${reason})` : ""}.`;
|
|
1150
|
+
}
|
|
1151
|
+
function normalizeAuthorizationDescription(description, name, displayName) {
|
|
1152
|
+
if (description === `Authorization required for ${name}`) return `Authorization required for ${displayName}`;
|
|
1153
|
+
return description;
|
|
1154
|
+
}
|
|
1155
|
+
function formatAuthorizationDisplayName(name) {
|
|
1156
|
+
if (name.length === 0) return name;
|
|
1157
|
+
return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1114
1160
|
//#endregion
|
|
1115
1161
|
//#region src/client/message-reducer.ts
|
|
1116
1162
|
function defaultMessageReducer() {
|
|
@@ -1253,6 +1299,8 @@ function reduceMessageData(data, event) {
|
|
|
1253
1299
|
if (existing !== void 0) return updateToolPart(data, event.data.result.callId, nextPart);
|
|
1254
1300
|
return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), nextPart));
|
|
1255
1301
|
}
|
|
1302
|
+
case "authorization.required": return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), createAuthorizationRequiredPart(event)));
|
|
1303
|
+
case "authorization.completed": return completeAuthorization(data, event);
|
|
1256
1304
|
case "message.appended": return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), {
|
|
1257
1305
|
state: "streaming",
|
|
1258
1306
|
stepIndex: event.data.stepIndex,
|
|
@@ -1360,9 +1408,30 @@ function updateToolPart(data, toolCallId, next) {
|
|
|
1360
1408
|
if (!message) return data;
|
|
1361
1409
|
return upsertMessage(data, upsertPart(message, next));
|
|
1362
1410
|
}
|
|
1411
|
+
function completeAuthorization(data, event) {
|
|
1412
|
+
const existing = findLatestPendingAuthorizationPart(data, event.data.name);
|
|
1413
|
+
const next = createAuthorizationCompletedPart(event, existing);
|
|
1414
|
+
if (existing !== void 0) return updateAuthorizationPart(data, existing, next);
|
|
1415
|
+
return updateAssistantMessage(data, event.data.turnId, (message) => upsertPart(ensureStepStartPart(message, event.data.stepIndex), next));
|
|
1416
|
+
}
|
|
1417
|
+
function updateAuthorizationPart(data, existing, next) {
|
|
1418
|
+
const message = data.messages.find((candidate) => candidate.role === "assistant" && candidate.parts.some((part) => part === existing));
|
|
1419
|
+
if (!message) return data;
|
|
1420
|
+
return upsertMessage(data, upsertPart(message, next));
|
|
1421
|
+
}
|
|
1363
1422
|
function findToolPart(data, toolCallId) {
|
|
1364
1423
|
for (const message of data.messages) for (const part of message.parts) if (part.type === "dynamic-tool" && part.toolCallId === toolCallId) return part;
|
|
1365
1424
|
}
|
|
1425
|
+
function findLatestPendingAuthorizationPart(data, name) {
|
|
1426
|
+
for (let messageIndex = data.messages.length - 1; messageIndex >= 0; messageIndex -= 1) {
|
|
1427
|
+
const message = data.messages[messageIndex];
|
|
1428
|
+
if (message?.role !== "assistant") continue;
|
|
1429
|
+
for (let partIndex = message.parts.length - 1; partIndex >= 0; partIndex -= 1) {
|
|
1430
|
+
const part = message.parts[partIndex];
|
|
1431
|
+
if (part?.type === "authorization" && part.state === "required" && part.name === name) return part;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1366
1435
|
function findToolPartByApprovalId(data, approvalId) {
|
|
1367
1436
|
for (const message of data.messages) for (const part of message.parts) if (part.type === "dynamic-tool" && part.approval?.id === approvalId) return part;
|
|
1368
1437
|
}
|
|
@@ -1371,6 +1440,7 @@ function partKey(part) {
|
|
|
1371
1440
|
case "text": return `text:${part.stepIndex ?? 0}`;
|
|
1372
1441
|
case "reasoning": return `reasoning:${part.stepIndex ?? 0}`;
|
|
1373
1442
|
case "step-start": return "step-start";
|
|
1443
|
+
case "authorization": return `authorization:${part.turnId}:${part.stepIndex}:${part.name}`;
|
|
1374
1444
|
case "dynamic-tool": return `dynamic-tool:${part.toolCallId}`;
|
|
1375
1445
|
}
|
|
1376
1446
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AuthorizationCompletedStreamEvent, AuthorizationRequiredStreamEvent } from "#protocol/message.js";
|
|
2
|
+
import type { EveAuthorizationPart } from "#client/message-reducer-types.js";
|
|
3
|
+
export declare function createAuthorizationRequiredPart(event: AuthorizationRequiredStreamEvent): EveAuthorizationPart;
|
|
4
|
+
export declare function createAuthorizationCompletedPart(event: AuthorizationCompletedStreamEvent, existing?: EveAuthorizationPart): EveAuthorizationPart;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function createAuthorizationRequiredPart(e){let t=e.data.authorization?.displayName??formatAuthorizationDisplayName(e.data.name);return{authorization:e.data.authorization,description:normalizeAuthorizationDescription(e.data.description,e.data.name,t),displayName:t,name:e.data.name,state:`required`,stepIndex:e.data.stepIndex,turnId:e.data.turnId,type:`authorization`}}function createAuthorizationCompletedPart(e,t){let n=e.data.authorization?.displayName??t?.displayName??formatAuthorizationDisplayName(e.data.name);return{authorization:t?.authorization||e.data.authorization?{...t?.authorization,...e.data.authorization}:void 0,description:t?.description??buildCompletedAuthorizationDescription(n,e.data.outcome,e.data.reason),displayName:n,name:e.data.name,outcome:e.data.outcome,reason:e.data.reason,state:`completed`,stepIndex:t?.stepIndex??e.data.stepIndex,turnId:t?.turnId??e.data.turnId,type:`authorization`}}function buildCompletedAuthorizationDescription(e,t,n){return t===`authorized`?`${e} connected.`:`${e} authorization ${t}${n===void 0?``:` (${n})`}.`}function normalizeAuthorizationDescription(e,t,n){return e===`Authorization required for ${t}`?`Authorization required for ${n}`:e}function formatAuthorizationDisplayName(e){return e.length===0?e:`${e.charAt(0).toUpperCase()}${e.slice(1)}`}export{createAuthorizationCompletedPart,createAuthorizationRequiredPart};
|
|
@@ -9,8 +9,8 @@ export { ClientSession } from "#client/session.js";
|
|
|
9
9
|
export type { EveAgentStoreCallbacks, EveAgentStoreInit, EveAgentStoreSnapshot, EveAgentStoreStatus, PrepareSend, } from "#client/eve-agent-store.js";
|
|
10
10
|
export type { AgentInfoEntry, AgentInfoChannelEntry, AgentInfoChannels, AgentInfoConnectionEntry, AgentInfoDynamicResolverEntry, AgentInfoFrameworkChannelEntry, AgentInfoFrameworkToolEntry, AgentInfoHookEntry, AgentInfoInstructions, AgentInfoInstructionsEntry, AgentInfoResult, AgentInfoSandboxEntry, AgentInfoScheduleEntry, AgentInfoSkillEntry, AgentInfoSource, AgentInfoSubagentEntry, AgentInfoToolEntry, AgentInfoTools, ClientAuth, ClientOptions, ClientRedirectPolicy, HeadersValue, HealthResult, MessageResult, SendTurnInput, SendTurnPayload, SessionState, StreamOptions, TokenValue, } from "#client/types.js";
|
|
11
11
|
export type { EveAgentReducer, EveAgentReducerEvent, ClientInputRespondedEvent, ClientMessageFailedEvent, ClientMessageSubmittedEvent, } from "#client/reducer.js";
|
|
12
|
-
export type { EveMessageData, EveDynamicToolPart, EveMessageInputRequest, EveMessage, EveMessageMetadata, EveMessagePart, EveMessageToolMetadata, } from "#client/message-reducer.js";
|
|
13
|
-
export type { ActionResultStreamEvent, ActionsRequestedStreamEvent, AssistantStepFinishReason, CompactionCompletedStreamEvent, CompactionRequestedStreamEvent, AuthorizationCompletedStreamEvent, ConnectionAuthorizationOutcome, AuthorizationRequiredStreamEvent, HandleMessageStreamEvent, InputRequestedStreamEvent, MessageAppendedStreamEvent, MessageCompletedStreamEvent, MessageReceivedStreamEvent, ReasoningAppendedStreamEvent, ReasoningCompletedStreamEvent, ResultCompletedStreamEvent, SessionCompletedStreamEvent, SessionFailedStreamEvent, SessionStartedStreamEvent, SessionWaitingStreamEvent, StepCompletedStreamEvent, StepFailedStreamEvent, StepStartedStreamEvent, SubagentCalledStreamEvent, SubagentChildEventStreamEvent, SubagentCompletedStreamEvent, SubagentStartedStreamEvent, TurnCompletedStreamEvent, TurnFailedStreamEvent, TurnStartedStreamEvent, TurnFailureStreamEvent, } from "#protocol/message.js";
|
|
12
|
+
export type { EveAuthorizationChallenge, EveAuthorizationOutcome, EveAuthorizationPart, EveMessageData, EveDynamicToolPart, EveMessageInputRequest, EveMessage, EveMessageMetadata, EveMessagePart, EveMessageToolMetadata, } from "#client/message-reducer.js";
|
|
13
|
+
export type { ActionResultStreamEvent, ActionsRequestedStreamEvent, AssistantStepFinishReason, AuthorizationOutcome, CompactionCompletedStreamEvent, CompactionRequestedStreamEvent, AuthorizationCompletedStreamEvent, ConnectionAuthorizationOutcome, AuthorizationRequiredStreamEvent, HandleMessageStreamEvent, InputRequestedStreamEvent, MessageAppendedStreamEvent, MessageCompletedStreamEvent, MessageReceivedStreamEvent, ReasoningAppendedStreamEvent, ReasoningCompletedStreamEvent, ResultCompletedStreamEvent, SessionCompletedStreamEvent, SessionFailedStreamEvent, SessionStartedStreamEvent, SessionWaitingStreamEvent, StepCompletedStreamEvent, StepFailedStreamEvent, StepStartedStreamEvent, SubagentCalledStreamEvent, SubagentChildEventStreamEvent, SubagentCompletedStreamEvent, SubagentStartedStreamEvent, TurnCompletedStreamEvent, TurnFailedStreamEvent, TurnStartedStreamEvent, TurnFailureStreamEvent, } from "#protocol/message.js";
|
|
14
14
|
export { isCurrentTurnBoundaryEvent, isTurnFailureEvent } from "#protocol/message.js";
|
|
15
15
|
export type { InputOption, InputRequest, InputResponse } from "#runtime/input/types.js";
|
|
16
16
|
export { inputOptionSchema, inputRequestSchema, inputResponseSchema, isInputRequest, isInputResponse, } from "#runtime/input/types.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { InputResponse } from "#runtime/input/types.js";
|
|
2
|
+
import type { AuthorizationOutcome } from "#protocol/message.js";
|
|
2
3
|
/**
|
|
3
4
|
* UIMessage-compatible eve message projection for chat and agent UIs.
|
|
4
5
|
*/
|
|
@@ -52,7 +53,45 @@ export type EveMessagePart = {
|
|
|
52
53
|
readonly type: "reasoning";
|
|
53
54
|
} | {
|
|
54
55
|
readonly type: "step-start";
|
|
55
|
-
} | EveDynamicToolPart;
|
|
56
|
+
} | EveAuthorizationPart | EveDynamicToolPart;
|
|
57
|
+
/**
|
|
58
|
+
* User-facing authorization challenge projected from an
|
|
59
|
+
* `authorization.required` stream event. These fields are safe to render in a
|
|
60
|
+
* browser UI; the model-facing tool output never receives the URL or code.
|
|
61
|
+
*/
|
|
62
|
+
export interface EveAuthorizationChallenge {
|
|
63
|
+
readonly displayName?: string;
|
|
64
|
+
readonly expiresAt?: string;
|
|
65
|
+
readonly instructions?: string;
|
|
66
|
+
readonly url?: string;
|
|
67
|
+
readonly userCode?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Outcome of a completed user authorization flow.
|
|
71
|
+
*/
|
|
72
|
+
export type EveAuthorizationOutcome = AuthorizationOutcome;
|
|
73
|
+
/**
|
|
74
|
+
* An authorization prompt or result. The default reducer projects
|
|
75
|
+
* `authorization.required` into a pending part so browser chat UIs can render a
|
|
76
|
+
* sign-in affordance, then updates it when `authorization.completed` arrives.
|
|
77
|
+
*/
|
|
78
|
+
export type EveAuthorizationPart = {
|
|
79
|
+
readonly authorization?: EveAuthorizationChallenge;
|
|
80
|
+
readonly description: string;
|
|
81
|
+
readonly displayName: string;
|
|
82
|
+
readonly name: string;
|
|
83
|
+
readonly stepIndex: number;
|
|
84
|
+
readonly turnId: string;
|
|
85
|
+
readonly type: "authorization";
|
|
86
|
+
} & ({
|
|
87
|
+
readonly outcome?: never;
|
|
88
|
+
readonly reason?: never;
|
|
89
|
+
readonly state: "required";
|
|
90
|
+
} | {
|
|
91
|
+
readonly outcome: EveAuthorizationOutcome;
|
|
92
|
+
readonly reason?: string;
|
|
93
|
+
readonly state: "completed";
|
|
94
|
+
});
|
|
56
95
|
/**
|
|
57
96
|
* A tool-call part of an assistant message, following the AI SDK `dynamic-tool`
|
|
58
97
|
* convention. `state` advances through the lifecycle: `"input-streaming"` and
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import type { EveAgentReducer } from "#client/reducer.js";
|
|
2
2
|
import type { EveMessageData } from "#client/message-reducer-types.js";
|
|
3
|
-
export type { EveMessageData, EveDynamicToolPart, EveMessageInputRequest, EveMessage, EveMessageMetadata, EveMessagePart, EveMessageToolMetadata, } from "#client/message-reducer-types.js";
|
|
3
|
+
export type { EveAuthorizationChallenge, EveAuthorizationOutcome, EveAuthorizationPart, EveMessageData, EveDynamicToolPart, EveMessageInputRequest, EveMessage, EveMessageMetadata, EveMessagePart, EveMessageToolMetadata, } from "#client/message-reducer-types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Creates a UIMessage-compatible eve reducer for chat and agent UIs.
|
|
6
6
|
*
|
|
7
7
|
* The returned projection keeps eve-owned types while following the AI SDK
|
|
8
8
|
* `messages[].parts[]` rendering convention used by AI Elements. It projects
|
|
9
|
-
* text, reasoning, tool calls, tool results, tool approvals,
|
|
10
|
-
*
|
|
11
|
-
* custom reducers through the reducer event contract until eve has a dedicated
|
|
12
|
-
* message-part shape for authorization UI.
|
|
9
|
+
* text, reasoning, tool calls, tool results, tool approvals, submitted HITL
|
|
10
|
+
* responses, and authorization prompts.
|
|
13
11
|
*/
|
|
14
12
|
export declare function defaultMessageReducer(): EveAgentReducer<EveMessageData>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function defaultMessageReducer(){return{initial(){return{messages:[]}},reduce(e,t){return reduceMessageData(e,t)}}}function reduceMessageData(e,
|
|
1
|
+
import{createAuthorizationCompletedPart,createAuthorizationRequiredPart}from"#client/authorization-message-parts.js";function defaultMessageReducer(){return{initial(){return{messages:[]}},reduce(e,t){return reduceMessageData(e,t)}}}function reduceMessageData(e,n){switch(n.type){case`client.message.submitted`:return upsertMessage(e,{id:optimisticUserMessageId(n.data.submissionId),metadata:{optimistic:!0,status:`submitted`},parts:[{type:`text`,text:n.data.message}],role:`user`});case`client.message.failed`:return upsertMessage(e,{id:optimisticUserMessageId(n.data.submissionId),metadata:{optimistic:!0,status:`failed`},parts:[{type:`text`,text:n.data.message}],role:`user`});case`client.input.responded`:{let t=e;for(let e of n.data.responses)t=respondToInputRequest(t,e);return t}case`message.received`:return upsertMessage(e,{id:`${n.data.turnId}:user`,metadata:{status:`complete`,turnId:n.data.turnId},parts:[{type:`text`,text:n.data.message,state:`done`}],role:`user`});case`step.started`:return updateAssistantMessage(e,n.data.turnId,e=>ensureStepStartPart(e,n.data.stepIndex));case`reasoning.appended`:return updateAssistantMessage(e,n.data.turnId,e=>upsertPart(ensureStepStartPart(e,n.data.stepIndex),{state:`streaming`,stepIndex:n.data.stepIndex,text:n.data.reasoningSoFar,type:`reasoning`}));case`reasoning.completed`:return updateAssistantMessage(e,n.data.turnId,e=>upsertPart(ensureStepStartPart(e,n.data.stepIndex),{state:`done`,stepIndex:n.data.stepIndex,text:n.data.reasoning,type:`reasoning`}));case`actions.requested`:{let t=e;for(let e of n.data.actions){let r=normalizeActionRequest(e);t=updateAssistantMessage(t,n.data.turnId,t=>upsertPart(ensureStepStartPart(t,n.data.stepIndex),{input:`input`in e?e.input:void 0,state:`input-available`,stepIndex:n.data.stepIndex,toolCallId:e.callId,toolMetadata:createToolMetadata(r),toolName:r.toolName,type:`dynamic-tool`}))}return t}case`input.requested`:{let t=e;for(let e of n.data.requests){let r=normalizeActionRequest(e.action);t=updateAssistantMessage(t,n.data.turnId,t=>upsertPart(ensureStepStartPart(t,n.data.stepIndex),{approval:{id:e.requestId},input:e.action.input,state:`approval-requested`,stepIndex:n.data.stepIndex,toolCallId:e.action.callId,toolMetadata:createToolMetadata(r,{inputRequest:toMessageInputRequest(e)}),toolName:r.toolName,type:`dynamic-tool`}))}return t}case`action.result`:{let t=normalizeActionResult(n.data.result),r=findToolPart(e,n.data.result.callId),i=n.data.error?.code===`TOOL_EXECUTION_DENIED`,a=n.data.status===`failed`&&!i,o=r?.approval?.id??n.data.result.callId,s=mergeToolMetadata(r?.toolMetadata,createToolMetadata(t)),c={input:r?.input,stepIndex:n.data.stepIndex,toolCallId:n.data.result.callId,toolMetadata:s,toolName:r?.toolName??t.toolName,type:`dynamic-tool`},l;return l=i?{...c,approval:{approved:!1,id:o,reason:n.data.error?.message},state:`output-denied`}:a?{...c,approval:approvedApproval(r),errorText:n.data.error?.message??stringifyUnknown(n.data.result.output),state:`output-error`}:{...c,approval:approvedApproval(r),output:n.data.result.output,state:`output-available`},r===void 0?updateAssistantMessage(e,n.data.turnId,e=>upsertPart(ensureStepStartPart(e,n.data.stepIndex),l)):updateToolPart(e,n.data.result.callId,l)}case`authorization.required`:return updateAssistantMessage(e,n.data.turnId,e=>upsertPart(ensureStepStartPart(e,n.data.stepIndex),createAuthorizationRequiredPart(n)));case`authorization.completed`:return completeAuthorization(e,n);case`message.appended`:return updateAssistantMessage(e,n.data.turnId,e=>upsertPart(ensureStepStartPart(e,n.data.stepIndex),{state:`streaming`,stepIndex:n.data.stepIndex,text:n.data.messageSoFar,type:`text`}));case`message.completed`:return updateAssistantMessage(e,n.data.turnId,e=>n.data.message===null?removeTextPart(e,n.data.stepIndex):upsertPart(ensureStepStartPart(e,n.data.stepIndex),{state:`done`,stepIndex:n.data.stepIndex,text:n.data.message,type:`text`}));case`result.completed`:return updateAssistantMetadata(e,n.data.turnId,{result:n.data.result});case`turn.completed`:return updateAssistantMetadata(e,n.data.turnId,{status:`complete`});case`turn.failed`:case`session.failed`:return e;default:return e}}function respondToInputRequest(e,t){let n=findToolPartByApprovalId(e,t.requestId);if(!n)return e;let r={id:t.requestId};return t.text!==void 0&&(r.reason=t.text),updateToolPart(e,n.toolCallId,{approval:r,input:n.input,state:`approval-responded`,stepIndex:n.stepIndex,toolCallId:n.toolCallId,toolMetadata:mergeToolMetadata(n.toolMetadata,{eve:{inputResponse:t,kind:n.toolMetadata?.eve?.kind??`unknown`,name:n.toolMetadata?.eve?.name??n.toolName}}),toolName:n.toolName,type:`dynamic-tool`})}function updateAssistantMessage(e,t,n){return upsertMessage(e,n(e.messages.find(e=>e.role===`assistant`&&e.metadata?.turnId===t)??createAssistantMessage(t)))}function updateAssistantMetadata(e,t,n){return updateAssistantMessage(e,t,e=>({...e,metadata:{...e.metadata,...n}}))}function createAssistantMessage(e){return{id:`${e}:assistant`,metadata:{status:`streaming`,turnId:e},parts:[],role:`assistant`}}function ensureStepStartPart(e,t){let n=e.parts.filter(e=>e.type===`step-start`).length;if(n>t)return e;let r=t-n+1;return{...e,parts:[...e.parts,...Array.from({length:r},()=>({type:`step-start`}))]}}function upsertPart(e,t){let n=e.parts.findIndex(e=>partKey(e)===partKey(t)),r=n===-1?[...e.parts,t]:[...e.parts.slice(0,n),t,...e.parts.slice(n+1)];return{...e,metadata:{...e.metadata,status:t.type===`text`&&t.state===`done`?`complete`:`streaming`},parts:r}}function removeTextPart(e,t){let n=e.parts.filter(e=>e.type!==`text`||e.stepIndex!==t);return n.length===e.parts.length?e:{...e,metadata:{...e.metadata,status:`complete`},parts:n}}function updateToolPart(e,t,n){let r=e.messages.find(e=>e.role===`assistant`&&e.parts.some(e=>e.type===`dynamic-tool`&&e.toolCallId===t));return r?upsertMessage(e,upsertPart(r,n)):e}function completeAuthorization(t,n){let r=findLatestPendingAuthorizationPart(t,n.data.name),i=createAuthorizationCompletedPart(n,r);return r===void 0?updateAssistantMessage(t,n.data.turnId,e=>upsertPart(ensureStepStartPart(e,n.data.stepIndex),i)):updateAuthorizationPart(t,r,i)}function updateAuthorizationPart(e,t,n){let r=e.messages.find(e=>e.role===`assistant`&&e.parts.some(e=>e===t));return r?upsertMessage(e,upsertPart(r,n)):e}function findToolPart(e,t){for(let n of e.messages)for(let e of n.parts)if(e.type===`dynamic-tool`&&e.toolCallId===t)return e}function findLatestPendingAuthorizationPart(e,t){for(let n=e.messages.length-1;n>=0;--n){let r=e.messages[n];if(r?.role===`assistant`)for(let e=r.parts.length-1;e>=0;--e){let n=r.parts[e];if(n?.type===`authorization`&&n.state===`required`&&n.name===t)return n}}}function findToolPartByApprovalId(e,t){for(let n of e.messages)for(let e of n.parts)if(e.type===`dynamic-tool`&&e.approval?.id===t)return e}function partKey(e){switch(e.type){case`text`:return`text:${e.stepIndex??0}`;case`reasoning`:return`reasoning:${e.stepIndex??0}`;case`step-start`:return`step-start`;case`authorization`:return`authorization:${e.turnId}:${e.stepIndex}:${e.name}`;case`dynamic-tool`:return`dynamic-tool:${e.toolCallId}`}}function upsertMessage(e,t){let n=e.messages.findIndex(e=>e.id===t.id);return n===-1?{messages:[...e.messages,t]}:{messages:[...e.messages.slice(0,n),t,...e.messages.slice(n+1)]}}function toMessageInputRequest(e){return{allowFreeform:e.allowFreeform,display:e.display,options:e.options,prompt:e.prompt,requestId:e.requestId}}function createToolMetadata(e,t){return{eve:{inputRequest:t?.inputRequest,kind:e.kind,name:e.name}}}function mergeToolMetadata(e,t){let n=t.eve?.kind??e?.eve?.kind??`unknown`,r=t.eve?.name??e?.eve?.name??`unknown`;return{eve:{...e?.eve,...t.eve,inputRequest:t.eve?.inputRequest??e?.eve?.inputRequest,inputResponse:t.eve?.inputResponse??e?.eve?.inputResponse,kind:n,name:r}}}function approvedApproval(e){if(e?.approval?.id)return{approved:!0,id:e.approval.id,isAutomatic:e.approval.isAutomatic,reason:e.approval.reason}}function normalizeActionRequest(e){switch(e.kind){case`load-skill`:return{kind:`load-skill`,name:`load_skill`,toolName:`eve:load-skill`};case`tool-call`:return{kind:`tool-call`,name:e.toolName,toolName:e.toolName};case`subagent-call`:return{kind:`subagent-call`,name:e.subagentName,toolName:`eve:subagent:${e.subagentName}`};case`remote-agent-call`:return{kind:`subagent-call`,name:e.remoteAgentName,toolName:`eve:subagent:${e.remoteAgentName}`}}}function normalizeActionResult(e){switch(e.kind){case`load-skill-result`:return{kind:`load-skill`,name:e.name??`load_skill`,toolName:`eve:load-skill`};case`tool-result`:return{kind:`tool-call`,name:e.toolName,toolName:e.toolName};case`subagent-result`:return{kind:`subagent-call`,name:e.subagentName,toolName:`eve:subagent:${e.subagentName}`}}}function optimisticUserMessageId(e){return`optimistic:${e}:user`}function stringifyUnknown(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return`Action failed.`}}export{defaultMessageReducer};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { defineEval } from "#evals/define-eval.js";
|
|
2
2
|
export { defineEvalConfig } from "#evals/define-eval-config.js";
|
|
3
3
|
export { EveEvalTurnFailedError } from "#evals/session.js";
|
|
4
|
+
export { mockModel } from "#evals/mock-model.js";
|
|
4
5
|
export type { RuntimeIdentity } from "#protocol/message.js";
|
|
5
6
|
export type { InputRequest } from "#runtime/input/types.js";
|
|
6
7
|
export type { EveEvalEventMatch, EveEvalInputRequestMatchOptions, EveEvalValueMatcher, EveEvalToolCallMatchOptions, EveEvalSkillLoadMatchOptions, EveEvalSubagentCallMatchOptions, } from "#evals/match.js";
|
|
7
8
|
export type { Assertion, AssertionHandle, AssertionResult, AssertionSeverity, AutoevalsJudges, EveEvalActionStatus, EveEvalAssertions, EveEvalContext, EveEvalDerivedFacts, EveEvalJudgeConfig, EveEvalRunSummary, EveEvalSession, EveEvalSessionResult, EveEvalScheduleDispatchResult, EveEvalSubagentCall, EveEval, EveEvalConfig, EveEvalConfigInput, EveEvalDefinition, EveEvalInput, EveEvalResult, EveEvalTarget, EveEvalTargetCapabilities, EveEvalTargetHandle, EveEvalTaskResult, EveEvalToolCall, EveEvalTurn, EveEvalVerdict, JudgeContext, JudgeOpts, } from "#evals/types.js";
|
|
9
|
+
export type { MockModelMessage, MockModelOptions, MockModelRequest, MockModelResponder, MockModelResponse, MockModelTool, MockModelToolCall, MockModelToolResult, MockModelUsage, } from "#evals/mock-model.js";
|
package/dist/src/evals/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EveEvalTurnFailedError}from"#evals/session.js";import{defineEval}from"#evals/define-eval.js";import{defineEvalConfig}from"#evals/define-eval-config.js";export{EveEvalTurnFailedError,defineEval,defineEvalConfig};
|
|
1
|
+
import{EveEvalTurnFailedError}from"#evals/session.js";import{defineEval}from"#evals/define-eval.js";import{defineEvalConfig}from"#evals/define-eval-config.js";import{mockModel}from"#evals/mock-model.js";export{EveEvalTurnFailedError,defineEval,defineEvalConfig,mockModel};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { LanguageModel } from "ai";
|
|
2
|
+
/** A text-only view of one message passed to a mock model. */
|
|
3
|
+
export interface MockModelMessage {
|
|
4
|
+
/** The message author. */
|
|
5
|
+
readonly role: "assistant" | "system" | "tool" | "user";
|
|
6
|
+
/** Text extracted from the message's content parts. */
|
|
7
|
+
readonly text: string;
|
|
8
|
+
}
|
|
9
|
+
/** A tool available to a mock model call. */
|
|
10
|
+
export interface MockModelTool {
|
|
11
|
+
/** Tool name exposed to the model. */
|
|
12
|
+
readonly name: string;
|
|
13
|
+
/** Authored tool description, when present. */
|
|
14
|
+
readonly description?: string;
|
|
15
|
+
/** JSON Schema describing the tool input, when present. */
|
|
16
|
+
readonly inputSchema?: unknown;
|
|
17
|
+
}
|
|
18
|
+
/** A completed tool call present in the model prompt. */
|
|
19
|
+
export interface MockModelToolResult {
|
|
20
|
+
/** Tool-call identifier. */
|
|
21
|
+
readonly id: string;
|
|
22
|
+
/** Name of the tool that produced the result. */
|
|
23
|
+
readonly name: string;
|
|
24
|
+
/** Normalized tool output. */
|
|
25
|
+
readonly output: unknown;
|
|
26
|
+
/** Whether the tool execution failed or was denied. */
|
|
27
|
+
readonly isError: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** Normalized input supplied to a {@link MockModelResponder}. */
|
|
30
|
+
export interface MockModelRequest {
|
|
31
|
+
/** Every prompt message in order, with text content extracted. */
|
|
32
|
+
readonly messages: readonly MockModelMessage[];
|
|
33
|
+
/** All user-message text in order. */
|
|
34
|
+
readonly userMessages: readonly string[];
|
|
35
|
+
/** The latest user-message text, or `null` before the first user message. */
|
|
36
|
+
readonly lastUserMessage: string | null;
|
|
37
|
+
/** Number of user messages in the prompt. */
|
|
38
|
+
readonly userMessageCount: number;
|
|
39
|
+
/** Tools available for this model call. */
|
|
40
|
+
readonly tools: readonly MockModelTool[];
|
|
41
|
+
/** Tool results already present in the prompt. */
|
|
42
|
+
readonly toolResults: readonly MockModelToolResult[];
|
|
43
|
+
}
|
|
44
|
+
/** One tool call emitted by a mock model response. */
|
|
45
|
+
export interface MockModelToolCall {
|
|
46
|
+
/** Name of the tool to call. */
|
|
47
|
+
readonly name: string;
|
|
48
|
+
/** JSON-serializable tool input. Defaults to an empty object. */
|
|
49
|
+
readonly input?: unknown;
|
|
50
|
+
/** Stable call id. eve derives one when omitted. */
|
|
51
|
+
readonly id?: string;
|
|
52
|
+
}
|
|
53
|
+
/** Optional token counts reported by a mock response. */
|
|
54
|
+
export interface MockModelUsage {
|
|
55
|
+
/** Prompt tokens. eve estimates this value when omitted. */
|
|
56
|
+
readonly inputTokens?: number;
|
|
57
|
+
/** Generated tokens. eve estimates this value when omitted. */
|
|
58
|
+
readonly outputTokens?: number;
|
|
59
|
+
}
|
|
60
|
+
/** Advanced response shape for text, tool calls, and explicit token usage. */
|
|
61
|
+
export interface MockModelResponse {
|
|
62
|
+
/** Assistant text. May be combined with tool calls. */
|
|
63
|
+
readonly text?: string;
|
|
64
|
+
/** Tool calls emitted by the model. */
|
|
65
|
+
readonly toolCalls?: readonly MockModelToolCall[];
|
|
66
|
+
/** Token counts to report instead of eve's deterministic estimates. */
|
|
67
|
+
readonly usage?: MockModelUsage;
|
|
68
|
+
}
|
|
69
|
+
/** Produces the next deterministic mock-model response. */
|
|
70
|
+
export type MockModelResponder = (request: MockModelRequest) => MockModelResponse | Promise<MockModelResponse | string> | string;
|
|
71
|
+
/** Advanced configuration for {@link mockModel}. */
|
|
72
|
+
export interface MockModelOptions {
|
|
73
|
+
/** Model id exposed to the agent runtime. Defaults to `"model"`. */
|
|
74
|
+
readonly modelId?: string;
|
|
75
|
+
/** Provider id exposed to the agent runtime. Defaults to `"eve-mock"`. */
|
|
76
|
+
readonly provider?: string;
|
|
77
|
+
/** Static response or callback used for each model call. */
|
|
78
|
+
readonly respond?: MockModelResponder | string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates a deterministic local language model for an eve eval fixture.
|
|
82
|
+
*
|
|
83
|
+
* Pass a string for a static reply, a callback for prompt-aware behavior, or
|
|
84
|
+
* an options object when the model identity or advanced responses need to be
|
|
85
|
+
* customized. Calling `mockModel()` returns `"Mock response"`.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* mockModel("Hello from the test agent");
|
|
90
|
+
* mockModel(({ lastUserMessage }) => `Echo: ${lastUserMessage}`);
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function mockModel(input?: MockModelOptions | MockModelResponder | string): LanguageModel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{MockLanguageModelV3}from"ai/test";const RESPONSE_TIMESTAMP=Date.parse(`2026-01-01T00:00:00.000Z`);function mockModel(t={}){let n=normalizeOptions(t),r=normalizeResponder(n.respond),i=n.modelId??`model`;return new MockLanguageModelV3({modelId:i,provider:n.provider??`eve-mock`,doGenerate:async e=>createGenerateResult(await r(createRequest(e)),e,i),doStream:async e=>createStreamResult(createGenerateResult(await r(createRequest(e)),e,i))})}function normalizeOptions(e){return typeof e==`string`||typeof e==`function`?{respond:e}:e}function normalizeResponder(e){if(typeof e==`function`)return e;let t=e??`Mock response`;return()=>t}function createRequest(e){let t=e.prompt.map(e=>({role:e.role,text:extractMessageText(e)})),n=t.filter(e=>e.role===`user`).map(e=>e.text);return{lastUserMessage:n.at(-1)??null,messages:t,toolResults:extractToolResults(e),tools:extractTools(e),userMessageCount:n.length,userMessages:n}}function extractMessageText(e){return typeof e.content==`string`?e.content:e.content.flatMap(e=>{switch(e.type){case`reasoning`:case`text`:return[e.text];case`tool-result`:return[formatValue(normalizeToolOutput(e.output))];default:return[]}}).join(``)}function extractTools(e){return(e.tools??[]).map(e=>e.type===`function`?{description:e.description,inputSchema:e.inputSchema,name:e.name}:{name:e.name})}function extractToolResults(e){return e.prompt.flatMap(e=>typeof e.content==`string`?[]:e.content.flatMap(e=>e.type===`tool-result`?[{id:e.toolCallId,isError:e.output.type===`error-json`||e.output.type===`error-text`||e.output.type===`execution-denied`,name:e.toolName,output:normalizeToolOutput(e.output)}]:[]))}function normalizeToolOutput(e){switch(e.type){case`error-json`:case`error-text`:case`json`:case`text`:return e.value;case`execution-denied`:return e.reason??`Tool execution denied`;case`content`:return e.value}}function createGenerateResult(e,n,r){let i=typeof e==`string`?{text:e}:e,a=i.toolCalls??[];if(!(`text`in i)&&a.length===0)throw Error(`mockModel responders must return text or at least one item in "toolCalls".`);let o=[];i.text!==void 0&&o.push({text:i.text,type:`text`});for(let[e,t]of a.entries())o.push({input:JSON.stringify(t.input??{}),toolCallId:t.id??`mock-tool-call-${countUserMessages(n)}-${countToolResults(n)}-${e+1}`,toolName:t.name,type:`tool-call`});let s=n.prompt.map(e=>extractMessageText(e)).join(` `),c=[i.text??``,...a.map(e=>formatValue(e.input??{}))].join(` `),l=i.usage?.inputTokens??estimateTokens(s),u=i.usage?.outputTokens??estimateTokens(c);return{content:o,finishReason:{raw:void 0,unified:a.length>0?`tool-calls`:`stop`},response:{id:`mock-response-${countUserMessages(n)}-${countToolResults(n)}`,modelId:r,timestamp:new Date(RESPONSE_TIMESTAMP)},usage:{inputTokens:{cacheRead:0,cacheWrite:0,noCache:l,total:l},outputTokens:{reasoning:0,text:u,total:u}},warnings:[]}}function createStreamResult(e){let t=[{type:`stream-start`,warnings:e.warnings}];e.response!==void 0&&t.push({...e.response,type:`response-metadata`});let n=0;for(let r of e.content){if(r.type===`text`){let e=`mock-text-${n}`;n+=1,t.push({id:e,type:`text-start`}),r.text.length>0&&t.push({delta:r.text,id:e,type:`text-delta`}),t.push({id:e,type:`text-end`});continue}r.type===`tool-call`&&t.push(r)}return t.push({finishReason:e.finishReason,type:`finish`,usage:e.usage}),{stream:new ReadableStream({start(e){for(let n of t)e.enqueue(n);e.close()}})}}function countUserMessages(e){return e.prompt.filter(e=>e.role===`user`).length}function countToolResults(e){return extractToolResults(e).length}function estimateTokens(e){return Math.max(1,Math.ceil(e.trim().length/4))}function formatValue(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}export{mockModel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{withSandboxTemplatePrewarmLock}from"./template-prewarm-lock.js";import{toErrorMessage}from"#shared/errors.js";import{createBundledRuntimeCompiledArtifactsSource,getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";import{loadCompiledModuleMapFromAuthoredSource}from"#internal/authored-module-map-loader.js";import{createAuthoredSourceRuntimeCompiledArtifactsSource}from"#internal/application/runtime-compiled-artifacts-source.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{loadCompileMetadata}from"#runtime/loaders/compile-metadata.js";import{withBundledCompiledArtifacts}from"#runtime/loaders/bundled-artifacts.js";import{loadCompiledManifest}from"#runtime/loaders/manifest.js";import{resolveRuntimeCompilerArtifactPaths}from"#runtime/loaders/artifact-paths.js";import{resolveRuntimeAgentGraph}from"#runtime/resolve-agent-graph.js";import{createRuntimeSandboxTemplateKey}from"#runtime/sandbox/keys.js";import{createRuntimeSandboxTemplatePlan}from"#runtime/sandbox/template-plan.js";import{materializeWorkspaceDirectory}from"#runtime/workspace/seed-files.js";async function prewarmSandboxes(n){let r=await collectPrewarmTargets(n);if(r.length===0)return;let i=createPrewarmSignature(r);if(n.shouldPrewarmSignature?.(i)===!1)return;let a=n.dispatch??(async({backend:e,input:t})=>await e.prewarm(t));n.log?.(`eve: initializing ${formatSandboxTemplateCount(r.length)}...`);let o=(await Promise.all(r.map(async({backend:r,label:i,input:o})=>{let logBackendProgress=e=>{shouldLogSandboxPrewarmProgress(e)&&n.log?.(`eve: sandbox template "${i}" (${r.name}): ${e}`)},s;try{s=await withSandboxTemplatePrewarmLock({appRoot:o.runtimeContext.appRoot,backendName:r.name,templateKey:o.templateKey},async()=>await a({backend:r,input:{...o,log:n.log===void 0?void 0:logBackendProgress}}))}catch(e){throw n.log?.(`eve: failed to initialize sandbox template "${i}" on backend "${r.name}": ${toErrorMessage(
|
|
2
|
-
`)}function formatSandboxTemplateCount(e){return`${e} sandbox ${e===1?`template`:`templates`}`}function shouldLogSandboxPrewarmProgress(e){return!e.startsWith(`checking `)&&!e.startsWith(`reusing `)&&e!==`loading microsandbox runtime`&&e!==`microsandbox runtime ready`}export{prewarmAppSandboxes,prewarmBuiltAppSandboxes,prewarmSandboxes};
|
|
1
|
+
import{withSandboxTemplatePrewarmLock}from"./template-prewarm-lock.js";import{toErrorMessage}from"#shared/errors.js";import{createBundledRuntimeCompiledArtifactsSource,getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";import{loadCompiledModuleMapFromAuthoredSource}from"#internal/authored-module-map-loader.js";import{createAuthoredSourceRuntimeCompiledArtifactsSource}from"#internal/application/runtime-compiled-artifacts-source.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{loadCompileMetadata}from"#runtime/loaders/compile-metadata.js";import{withBundledCompiledArtifacts}from"#runtime/loaders/bundled-artifacts.js";import{loadCompiledManifest}from"#runtime/loaders/manifest.js";import{resolveRuntimeCompilerArtifactPaths}from"#runtime/loaders/artifact-paths.js";import{resolveRuntimeAgentGraph}from"#runtime/resolve-agent-graph.js";import{createRuntimeSandboxTemplateKey}from"#runtime/sandbox/keys.js";import{createRuntimeSandboxTemplatePlan}from"#runtime/sandbox/template-plan.js";import{materializeWorkspaceDirectory}from"#runtime/workspace/seed-files.js";async function prewarmSandboxes(n){let r=await collectPrewarmTargets(n);if(r.length===0)return;let i=createPrewarmSignature(r);if(n.shouldPrewarmSignature?.(i)===!1)return;let a=n.dispatch??(async({backend:e,input:t})=>await e.prewarm(t));n.log?.(`eve: initializing ${formatSandboxTemplateCount(r.length)}...`);let o=(await Promise.all(r.map(async({backend:r,label:i,input:o})=>{let logBackendProgress=e=>{shouldLogSandboxPrewarmProgress(e)&&n.log?.(`eve: sandbox template "${i}" (${r.name}): ${e}`)},s;try{s=await withSandboxTemplatePrewarmLock({appRoot:o.runtimeContext.appRoot,backendName:r.name,templateKey:o.templateKey},async()=>await a({backend:r,input:{...o,log:n.log===void 0?void 0:logBackendProgress}}))}catch(e){let a=formatPrewarmFailureForEnvironment({backendName:r.name,error:e});throw n.log?.(`eve: failed to initialize sandbox template "${i}" on backend "${r.name}": ${toErrorMessage(a)}`),a}return s}))).filter(e=>e.reused).length;n.log?.(`eve: initialized ${formatSandboxTemplateCount(r.length)} (${o} reused, ${r.length-o} built).`),n.onPrewarmSignature?.(i)}async function prewarmAppSandboxes(e){let t=e.compiledArtifactsSource??createAuthoredSourceRuntimeCompiledArtifactsSource(e.appRoot);if(t.kind!==`disk`)throw Error(`prewarmAppSandboxes requires disk-backed compiled artifacts.`);let n=await(e.loadAgentGraph??loadGraphFromArtifacts)({compiledArtifactsSource:t});await prewarmSandboxes({appRoot:getRuntimeCompiledArtifactsSandboxAppRoot(t)??e.appRoot,compiledArtifactsSource:t,dispatch:e.dispatch,graph:n,log:e.log,onPrewarmSignature:e.onPrewarmSignature,shouldPrewarmSignature:e.shouldPrewarmSignature})}async function prewarmBuiltAppSandboxes(e){let t=createAuthoredSourceRuntimeCompiledArtifactsSource(e.appRoot),[r,o,l]=await Promise.all([loadCompileMetadata({compiledArtifactsSource:t}),loadCompiledManifest({compiledArtifactsSource:t}),loadCompiledModuleMapFromAuthoredSource({compiledArtifactsSource:t})]);await withBundledCompiledArtifacts({manifest:o,metadata:r??void 0,moduleMap:l,sessionId:`built-app-prewarm`},async()=>{let t=createBundledRuntimeCompiledArtifactsSource(),r=await resolveRuntimeAgentGraph({manifest:o,moduleMap:l});await prewarmSandboxes({appRoot:e.appRoot,compiledArtifactsSource:t,dispatch:e.dispatch,graph:r,log:e.log})})}async function collectPrewarmTargets(e){let t=resolveRuntimeCompilerArtifactPaths(e.appRoot).compileDirectoryPath,n={appRoot:e.appRoot},r=[];return await Promise.all(collectNodeSandboxes(e.graph).map(async({definition:i,nodeId:a,workspaceResourceRoot:o})=>{let s=createRuntimeSandboxTemplatePlan({definition:i,workspaceResourceRoot:o}),c=await createRuntimeSandboxTemplateKey({backendName:i.backend.name,compiledArtifactsSource:e.compiledArtifactsSource,nodeId:a,sourceId:i.sourceId,templatePlan:s});c!==null&&r.push({backend:i.backend,label:formatLabel(a),input:{bootstrap:i.bootstrap,seedFiles:await loadResourceRootSeedFiles({compileDirectoryPath:t,workspaceResourceRoot:o}),runtimeContext:n,templateKey:c},signature:`${i.backend.name}:${a}:${c}`})})),r.sort((e,t)=>e.label.localeCompare(t.label))}async function loadResourceRootSeedFiles(e){return e.workspaceResourceRoot.rootEntries.length===0?[]:(await materializeWorkspaceDirectory(`${e.compileDirectoryPath}/${e.workspaceResourceRoot.logicalPath}`)).map(e=>({content:e.content,path:e.path}))}async function loadGraphFromArtifacts(e){let[t,n]=await Promise.all([loadCompiledManifest({compiledArtifactsSource:e.compiledArtifactsSource}),loadCompiledModuleMapFromAuthoredSource({compiledArtifactsSource:e.compiledArtifactsSource})]);return await resolveRuntimeAgentGraph({manifest:t,moduleMap:n})}function collectNodeSandboxes(e){return[...e.nodesByNodeId.entries()].flatMap(([e,t])=>{let n=t.sandboxRegistry.sandbox;return n===null?[]:[{...n,nodeId:e}]})}function formatLabel(e){return e===ROOT_RUNTIME_AGENT_NODE_ID?`root`:e}function createPrewarmSignature(e){return e.map(e=>e.signature).sort().join(`
|
|
2
|
+
`)}function formatSandboxTemplateCount(e){return`${e} sandbox ${e===1?`template`:`templates`}`}function shouldLogSandboxPrewarmProgress(e){return!e.startsWith(`checking `)&&!e.startsWith(`reusing `)&&e!==`loading microsandbox runtime`&&e!==`microsandbox runtime ready`}function formatPrewarmFailureForEnvironment(e){return!isVercelEnvironment()||!isLocalSandboxBackend(e.backendName)?e.error:Error(`The ${e.backendName} sandbox backend is not available when deploying on Vercel. Vercel build containers cannot run local Docker containers or microsandbox VMs. Use defaultBackend() so eve selects Vercel Sandbox on Vercel, or configure a Vercel-compatible backend explicitly, such as vercel(). Original ${e.backendName} error: ${toErrorMessage(e.error)}`,{cause:e.error})}function isVercelEnvironment(){return!!process.env.VERCEL?.trim()}function isLocalSandboxBackend(e){return e===`docker`||e===`microsandbox`}export{prewarmAppSandboxes,prewarmBuiltAppSandboxes,prewarmSandboxes};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{existsSync}from"node:fs";import{join}from"node:path";import{mkdir,writeFile}from"node:fs/promises";import{createCompiledModuleMapSource}from"#compiler/module-map.js";import{stringifyEsmImportSpecifier}from"#internal/application/import-specifier.js";async function writeCompiledArtifactsFiles(t){let a=join(t.outDir,`compiled-artifacts-bootstrap.mjs`),o=join(t.outDir,`compiled-artifacts-instrumentation.mjs`),s=resolveInstrumentationModule(t.compileResult.manifest.agentRoot);await mkdir(t.outDir,{recursive:!0}),await writeFile(a,await createCompiledArtifactsBootstrapSource({compileResult:t.compileResult,installModulePath:resolvePackageSourceFilePath(`src/runtime/loaders/bundled-artifacts.ts`),moduleMapPath:a,metadata:t.compileResult.metadata})),s!==void 0&&await writeFile(o,createInstrumentationPluginSource({agentName:t.compileResult.manifest.config.name,instrumentationPath:s,registerConfigPath:resolvePackageSourceFilePath(`src/harness/instrumentation-config.ts`)}));let c={bootstrapPath:a};return s!==void 0&&(c.instrumentationPluginPath=o,c.instrumentationSourcePath=s),c}const INSTRUMENTATION_EXTENSIONS=[`.ts`,`.mts`,`.js`,`.mjs`];function resolveInstrumentationModule(e){for(let r of INSTRUMENTATION_EXTENSIONS){let i=join(e,`instrumentation${r}`);if(existsSync(i))return i}}function stripCompiledModuleMapExports(e){return e.replace(/^export const moduleMap = /m,`const moduleMap = `).replace(/\nexport default moduleMap;\n?$/,`
|
|
2
|
-
`)}async function createCompiledArtifactsBootstrapSource(
|
|
2
|
+
`)}async function createCompiledArtifactsBootstrapSource(t){let n=t.compileResult.manifest.config.experimental?.workflow?.world,r=t.compileResult.manifest.config.name,i=stripCompiledModuleMapExports(createCompiledModuleMapSource({importSpecifierStyle:`absolute`,manifest:t.compileResult.manifest,moduleMapPath:t.moduleMapPath})).trim();return[`// Generated by eve. Do not edit by hand.`,`import { installBundledCompiledArtifacts } from ${stringifyEsmImportSpecifier(t.installModulePath)};`,`import { installEveWorkflowQueueNamespace } from ${stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/queue-namespace.ts`))};`,...createWorkflowWorldBootstrapImports(n),``,`installEveWorkflowQueueNamespace(${JSON.stringify(r)});`,``,i,``,`const metadata = ${JSON.stringify(t.metadata,null,2)};`,``,`const manifest = ${JSON.stringify(t.compileResult.manifest,null,2)};`,``,`export function installCompiledArtifactsBootstrap() {`,` installBundledCompiledArtifacts({`,` manifest,`,` metadata,`,` moduleMap,`,` });`,`}`,``,`installCompiledArtifactsBootstrap();`,...createWorkflowWorldBootstrapBody(n),``,`// Default export satisfies the Nitro plugin contract so this file`,`// can be used directly as a Nitro plugin without a separate wrapper.`,`export default function installCompiledArtifactsPlugin() {`,` // Already installed on import above.`,`}`,``,`export async function __eveInstallCompiledArtifactsStep() {`,` "use step";`,` return null;`,`}`,``].join(`
|
|
3
3
|
`)}function createWorkflowWorldBootstrapImports(t){return t===void 0?[]:[`import * as workflowWorldModule from ${stringifyEsmImportSpecifier(t)};`,`import { installConfiguredWorkflowWorld } from ${stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/configure-world.ts`))};`]}function createWorkflowWorldBootstrapBody(e){return e===void 0?[]:[``,`await installConfiguredWorkflowWorld({ module: workflowWorldModule, packageName: ${JSON.stringify(e)} });`]}function createInstrumentationPluginSource(e){return[`// Generated by eve. Do not edit by hand.`,`import * as instrumentationModule from ${stringifyEsmImportSpecifier(e.instrumentationPath)};`,`import { registerInstrumentationConfig } from ${stringifyEsmImportSpecifier(e.registerConfigPath)};`,``,`if (instrumentationModule.default != null) {`,` registerInstrumentationConfig(instrumentationModule.default, { agentName: ${JSON.stringify(e.agentName)} });`,`}`,``,`// Default export satisfies the Nitro plugin contract so this file`,`// can be used directly as a Nitro plugin without a separate wrapper.`,`export default function installInstrumentationPlugin() {}`,``].join(`
|
|
4
4
|
`)}export{createCompiledArtifactsBootstrapSource,writeCompiledArtifactsFiles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.15.
|
|
1
|
+
import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.15.5`,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,resolvePackageDependencyPath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolvePackageRoot}from"#internal/application/package.js";import{dirname,join,resolve}from"node:path";import{readFile}from"node:fs/promises";import{resolveNitroSurfaceOutputDirectory}from"#internal/application/paths.js";import{build,copyPublicAssets,prepare,prerender}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{WorkflowBundleBuilder}from"#internal/workflow-bundle/builder.js";import{normalizeEveVercelFunctionOutput}from"#internal/workflow-bundle/vercel-workflow-output.js";import{createApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{emitVercelAgentSummary}from"#internal/nitro/host/build-vercel-agent-summary.js";import{prepareApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{runVercelBuildPrewarm}from"#internal/nitro/host/vercel-build-prewarm.js";import{findClosestVercelOutputDirectory}from"#shared/vercel-output-directory.js";function trimTrailingSlash(e){return e.replace(/[\\/]+$/,``)}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function normalizeEntrypoint(e,t){return typeof t!=`string`||t.trim().length===0?null:resolve(e,t)}function 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 resolveCoDeployedEveServicePrefix(e){if(!isRecord(e.config)||!isRecord(e.config.experimentalServices))return;let t=!1,n;for(let r of Object.values(e.config.experimentalServices)){if(!isRecord(r))continue;if(r.framework!==`eve`){t=!0;continue}let i=normalizeEntrypoint(e.configRoot,r.entrypoint),a=normalizeServicePrefix(r);i===e.appRoot&&a.length>0&&a!==`/`&&(n=a)}return t?n:void 0}async function resolveCoDeployedEveServicePrefixForVercelFunctionOutput(e){let r=await findClosestVercelOutputDirectory(e);if(r!==void 0)try{let t=resolveCoDeployedEveServicePrefix({appRoot:e,configRoot:e,config:JSON.parse(await readFile(join(r,`config.json`),`utf8`))});if(t!==void 0)return t}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let a=e;for(;;){for(let t of[join(a,`vercel.json`),join(a,`.vercel`,`output`,`config.json`)])try{let n=JSON.parse(await readFile(t,`utf8`)),r=resolveCoDeployedEveServicePrefix({appRoot:e,configRoot:t.endsWith(`vercel.json`)?a:e,config:n});if(r!==void 0)return r}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let r=dirname(a);if(r===a)return;a=r}}async function readVercelServerRuntime(e){try{return JSON.parse(await readFile(join(e,`functions`,`__server.func`,`.vc-config.json`),`utf8`)).runtime}catch{return}}async function emitVercelWorkflowFunctions(t){let n=new WorkflowBundleBuilder({appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifactsBootstrapPath,outDir:t.workflowBuildDir,rootDir:resolvePackageRoot(),watch:!1}),r=await readVercelServerRuntime(t.outputDir);await n.buildVercelOutput({flowNitroOutputDir:t.flowNitroOutputDir,outputDir:t.outputDir,runtime:r})}async function buildNitroOutput(e){let t=trimTrailingSlash(e.options.output.dir);return await prepareEveVersionedCacheDirectory(t),await prepare(e),await copyPublicAssets(e),await prerender(e),await build(e),await writeEveVersionedCacheMetadata(t),t}async function buildVercelNitroSurface(e,t){let n=await createApplicationNitro(e,!1,{outputDir:resolveNitroSurfaceOutputDirectory(e.appRoot,t),surface:t});try{return await buildNitroOutput(n)}finally{await n.close()}}async function buildApplication(e){let t=await prepareApplicationHost(e);if(!process.env.VERCEL){let e=await createApplicationNitro(t,!1);try{let n=await buildNitroOutput(e);return await emitVercelAgentSummary({manifest:t.compileResult.manifest,appRoot:t.appRoot}),n}finally{await e.close()}}let n=await resolveCoDeployedEveServicePrefixForVercelFunctionOutput(t.appRoot),r=await createApplicationNitro(t,!1,{surface:`app`});try{let e=await buildNitroOutput(r);await runVercelBuildPrewarm({appRoot:t.appRoot,log(e){console.log(e)}});let i=await buildVercelNitroSurface(t,`flow`);return await emitVercelWorkflowFunctions({appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifacts.bootstrapPath,flowNitroOutputDir:i,outputDir:e,workflowBuildDir:t.workflowBuildDir}),n!==void 0&&await normalizeEveVercelFunctionOutput(e,{servicePrefix:n}),await emitVercelAgentSummary({manifest:t.compileResult.manifest,appRoot:t.appRoot}),e}finally{await r.close()}}export{buildApplication};
|
|
1
|
+
import{resolvePackageRoot}from"#internal/application/package.js";import{dirname,join,resolve}from"node:path";import{readFile}from"node:fs/promises";import{resolveNitroSurfaceOutputDirectory}from"#internal/application/paths.js";import{build,copyPublicAssets,prepare,prerender}from"nitro/builder";import{prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata}from"#internal/application/cache-metadata.js";import{WorkflowBundleBuilder}from"#internal/workflow-bundle/builder.js";import{normalizeEveVercelFunctionOutput}from"#internal/workflow-bundle/vercel-workflow-output.js";import{createApplicationNitro}from"#internal/nitro/host/create-application-nitro.js";import{emitVercelAgentSummary}from"#internal/nitro/host/build-vercel-agent-summary.js";import{prepareApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{runVercelBuildPrewarm}from"#internal/nitro/host/vercel-build-prewarm.js";import{findClosestVercelOutputDirectory}from"#shared/vercel-output-directory.js";function trimTrailingSlash(e){return e.replace(/[\\/]+$/,``)}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function normalizeEntrypoint(e,t){return typeof t!=`string`||t.trim().length===0?null:resolve(e,t)}function 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 resolveCoDeployedEveServicePrefix(e){if(!isRecord(e.config)||!isRecord(e.config.experimentalServices))return;let t=!1,n;for(let r of Object.values(e.config.experimentalServices)){if(!isRecord(r))continue;if(r.framework!==`eve`){t=!0;continue}let i=normalizeEntrypoint(e.configRoot,r.entrypoint),a=normalizeServicePrefix(r);i===e.appRoot&&a.length>0&&a!==`/`&&(n=a)}return t?n:void 0}async function resolveCoDeployedEveServicePrefixForVercelFunctionOutput(e){let r=await findClosestVercelOutputDirectory(e);if(r!==void 0)try{let t=resolveCoDeployedEveServicePrefix({appRoot:e,configRoot:e,config:JSON.parse(await readFile(join(r,`config.json`),`utf8`))});if(t!==void 0)return t}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let a=e;for(;;){for(let t of[join(a,`vercel.json`),join(a,`.vercel`,`output`,`config.json`)])try{let n=JSON.parse(await readFile(t,`utf8`)),r=resolveCoDeployedEveServicePrefix({appRoot:e,configRoot:t.endsWith(`vercel.json`)?a:e,config:n});if(r!==void 0)return r}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}let r=dirname(a);if(r===a)return;a=r}}async function readVercelServerRuntime(e){try{return JSON.parse(await readFile(join(e,`functions`,`__server.func`,`.vc-config.json`),`utf8`)).runtime}catch{return}}async function emitVercelWorkflowFunctions(t){let n=new WorkflowBundleBuilder({agentName:t.agentName,appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifactsBootstrapPath,outDir:t.workflowBuildDir,rootDir:resolvePackageRoot(),watch:!1}),r=await readVercelServerRuntime(t.outputDir);await n.buildVercelOutput({flowNitroOutputDir:t.flowNitroOutputDir,outputDir:t.outputDir,runtime:r})}async function buildNitroOutput(e){let t=trimTrailingSlash(e.options.output.dir);return await prepareEveVersionedCacheDirectory(t),await prepare(e),await copyPublicAssets(e),await prerender(e),await build(e),await writeEveVersionedCacheMetadata(t),t}async function buildVercelNitroSurface(e,t){let n=await createApplicationNitro(e,!1,{outputDir:resolveNitroSurfaceOutputDirectory(e.appRoot,t),surface:t});try{return await buildNitroOutput(n)}finally{await n.close()}}async function buildApplication(e){let t=await prepareApplicationHost(e);if(!process.env.VERCEL){let e=await createApplicationNitro(t,!1);try{let n=await buildNitroOutput(e);return await emitVercelAgentSummary({manifest:t.compileResult.manifest,appRoot:t.appRoot}),n}finally{await e.close()}}let n=await resolveCoDeployedEveServicePrefixForVercelFunctionOutput(t.appRoot),r=await createApplicationNitro(t,!1,{surface:`app`});try{let e=await buildNitroOutput(r);await runVercelBuildPrewarm({appRoot:t.appRoot,log(e){console.log(e)}});let i=await buildVercelNitroSurface(t,`flow`);return await emitVercelWorkflowFunctions({agentName:t.compileResult.manifest.config.name,appRoot:t.appRoot,compiledArtifactsBootstrapPath:t.compiledArtifacts.bootstrapPath,flowNitroOutputDir:i,outputDir:e,workflowBuildDir:t.workflowBuildDir}),n!==void 0&&await normalizeEveVercelFunctionOutput(e,{servicePrefix:n}),await emitVercelAgentSummary({manifest:t.compileResult.manifest,appRoot:t.appRoot}),e}finally{await r.close()}}export{buildApplication};
|