eve 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/src/channel/adapter.d.ts +3 -7
  3. package/dist/src/compiler/manifest.d.ts +16 -26
  4. package/dist/src/compiler/manifest.js +1 -1
  5. package/dist/src/compiler/normalize-agent-config.js +1 -1
  6. package/dist/src/compiler/normalize-hook.d.ts +2 -2
  7. package/dist/src/compiler/normalize-instructions.d.ts +3 -3
  8. package/dist/src/compiler/normalize-instructions.js +1 -1
  9. package/dist/src/compiler/normalize-skill.js +1 -1
  10. package/dist/src/compiler/normalize-tool.d.ts +2 -2
  11. package/dist/src/context/container.d.ts +2 -0
  12. package/dist/src/context/dynamic-model-lifecycle.d.ts +19 -0
  13. package/dist/src/context/dynamic-model-lifecycle.js +1 -0
  14. package/dist/src/context/keys.d.ts +13 -1
  15. package/dist/src/context/keys.js +1 -1
  16. package/dist/src/discover/manifest.d.ts +8 -0
  17. package/dist/src/evals/cli/eval.js +2 -2
  18. package/dist/src/evals/reporters/index.d.ts +1 -0
  19. package/dist/src/evals/reporters/index.js +1 -1
  20. package/dist/src/evals/runner/reporters/console.d.ts +10 -11
  21. package/dist/src/evals/runner/reporters/console.js +1 -1
  22. package/dist/src/execution/node-step.js +1 -1
  23. package/dist/src/execution/sandbox/bindings/microsandbox-options.d.ts +2 -2
  24. package/dist/src/execution/sandbox/bindings/microsandbox.d.ts +2 -2
  25. package/dist/src/execution/sandbox/ensure.js +1 -1
  26. package/dist/src/execution/session.js +2 -2
  27. package/dist/src/execution/workflow-steps.js +1 -1
  28. package/dist/src/harness/emission.d.ts +1 -0
  29. package/dist/src/harness/emission.js +1 -1
  30. package/dist/src/harness/input-extraction.d.ts +1 -0
  31. package/dist/src/harness/input-extraction.js +1 -1
  32. package/dist/src/harness/input-requests.js +1 -1
  33. package/dist/src/harness/step-hooks.d.ts +4 -1
  34. package/dist/src/harness/step-hooks.js +1 -1
  35. package/dist/src/harness/tool-call-input-errors.d.ts +8 -0
  36. package/dist/src/harness/tool-call-input-errors.js +1 -0
  37. package/dist/src/harness/tool-loop.js +1 -1
  38. package/dist/src/harness/types.d.ts +9 -0
  39. package/dist/src/internal/application/package.js +1 -1
  40. package/dist/src/internal/authored-definition/core.js +1 -1
  41. package/dist/src/internal/authored-definition/schema-backed.js +1 -1
  42. package/dist/src/internal/nitro/host/sandbox-shutdown-plugin.js +1 -1
  43. package/dist/src/internal/nitro/host/types.d.ts +2 -2
  44. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.d.ts +2 -2
  45. package/dist/src/internal/nitro/routes/agent-info/load-agent-info-data.d.ts +4 -4
  46. package/dist/src/internal/runtime-model.d.ts +1 -1
  47. package/dist/src/protocol/message.d.ts +1 -0
  48. package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +1 -1
  49. package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
  50. package/dist/src/public/channels/discord/discordChannel.d.ts +2 -2
  51. package/dist/src/public/channels/discord/discordChannel.js +1 -1
  52. package/dist/src/public/channels/eve.d.ts +1 -1
  53. package/dist/src/public/channels/eve.js +1 -1
  54. package/dist/src/public/channels/github/dispatch.d.ts +1 -1
  55. package/dist/src/public/channels/github/githubChannel.d.ts +2 -2
  56. package/dist/src/public/channels/github/githubChannel.js +1 -1
  57. package/dist/src/public/channels/index.d.ts +2 -2
  58. package/dist/src/public/channels/index.js +1 -1
  59. package/dist/src/public/channels/linear/linearChannel.d.ts +1 -1
  60. package/dist/src/public/channels/linear/linearChannel.js +1 -1
  61. package/dist/src/public/channels/slack/interactions.d.ts +1 -1
  62. package/dist/src/public/channels/slack/slackChannel.d.ts +2 -2
  63. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  64. package/dist/src/public/channels/teams/teamsChannel.d.ts +2 -2
  65. package/dist/src/public/channels/teams/teamsChannel.js +1 -1
  66. package/dist/src/public/channels/telegram/telegramChannel.d.ts +2 -2
  67. package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
  68. package/dist/src/public/channels/twilio/twilioChannel.d.ts +2 -2
  69. package/dist/src/public/channels/twilio/twilioChannel.js +1 -1
  70. package/dist/src/public/definitions/agent.d.ts +1 -1
  71. package/dist/src/public/definitions/channel.d.ts +99 -0
  72. package/dist/src/public/definitions/channel.js +1 -1
  73. package/dist/src/public/definitions/hook.d.ts +3 -10
  74. package/dist/src/public/definitions/instructions.d.ts +2 -18
  75. package/dist/src/public/definitions/schedule.d.ts +4 -17
  76. package/dist/src/public/definitions/tool.d.ts +10 -4
  77. package/dist/src/public/definitions/tool.js +1 -1
  78. package/dist/src/public/hooks/index.d.ts +1 -1
  79. package/dist/src/public/hooks/index.js +1 -1
  80. package/dist/src/public/index.d.ts +2 -0
  81. package/dist/src/public/index.js +1 -1
  82. package/dist/src/public/sandbox/backends/default.d.ts +2 -2
  83. package/dist/src/public/sandbox/backends/microsandbox.d.ts +2 -2
  84. package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +1 -1
  85. package/dist/src/public/sandbox/microsandbox.d.ts +1 -1
  86. package/dist/src/runtime/agent/bootstrap.d.ts +8 -0
  87. package/dist/src/runtime/agent/bootstrap.js +1 -1
  88. package/dist/src/runtime/agent/resolve-model.d.ts +16 -1
  89. package/dist/src/runtime/agent/resolve-model.js +1 -1
  90. package/dist/src/runtime/hooks/registry.d.ts +2 -1
  91. package/dist/src/runtime/prompt/compose.d.ts +2 -2
  92. package/dist/src/runtime/resolve-agent.js +1 -1
  93. package/dist/src/runtime/schedules/register.d.ts +2 -2
  94. package/dist/src/runtime/schedules/resolve-schedule.d.ts +4 -4
  95. package/dist/src/runtime/types.d.ts +7 -4
  96. package/dist/src/setup/scaffold/create/project.js +1 -1
  97. package/dist/src/shared/agent-definition.d.ts +30 -7
  98. package/dist/src/shared/agent-definition.js +1 -1
  99. package/dist/src/shared/channel-definition.d.ts +92 -0
  100. package/dist/src/shared/channel-definition.js +1 -0
  101. package/dist/src/shared/dynamic-tool-definition.d.ts +18 -8
  102. package/dist/src/shared/dynamic-tool-definition.js +1 -1
  103. package/dist/src/shared/hook-definition.d.ts +36 -0
  104. package/dist/src/shared/hook-definition.js +1 -0
  105. package/dist/src/shared/instructions-definition.d.ts +26 -0
  106. package/dist/src/shared/instructions-definition.js +1 -0
  107. package/dist/src/shared/schedule-definition.d.ts +34 -0
  108. package/dist/src/shared/schedule-definition.js +1 -0
  109. package/dist/src/source-change/apply-model-name.js +1 -1
  110. package/docs/agent-config.md +44 -0
  111. package/docs/guides/dynamic-capabilities.md +18 -2
  112. package/package.json +1 -1
  113. package/dist/src/public/definitions/defineChannel.d.ts +0 -157
  114. package/dist/src/public/definitions/defineChannel.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # eve
2
2
 
3
+ ## 0.22.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2958abf: feat(eve): add `konsistent` with initial config to enforce structural conventions
8
+
9
+ ### Patch Changes
10
+
11
+ - b7d1089: Add `defineDynamic({ fallback, events })` support for scoped dynamic agent model selection. Agents can choose a model once per session, once per turn, or per model step while keeping a compiled fallback for metadata and unset scopes.
12
+ - bd287b1: fix(eve): pass error messages when tool call input is invalid back to model instead of throwing so that it can try again
13
+
14
+ ## 0.21.1
15
+
16
+ ### Patch Changes
17
+
18
+ - 0b42ba1: `eve eval` now shuts down tracked sandbox handles after a local one-shot eval run completes. This prevents local sandbox compute, including microsandbox sessions, from outliving the eval process.
19
+
3
20
  ## 0.21.0
4
21
 
5
22
  ### Minor Changes
@@ -3,6 +3,7 @@ import type { StepInput } from "#harness/types.js";
3
3
  import type { HandleMessageStreamEvent } from "#protocol/message.js";
4
4
  import type { SessionHandle } from "#channel/session.js";
5
5
  import type { DeliverPayload } from "#channel/types.js";
6
+ import type { FetchFileResult, FetchFileFunction } from "#shared/channel-definition.js";
6
7
  /**
7
8
  * Context available to every adapter handler (`deliver` and event handlers).
8
9
  *
@@ -70,11 +71,7 @@ export type ChannelEventHandlers<TCtx extends ChannelAdapterContext<any> = Chann
70
71
  * When fields are provided, staging prefers them over the values the
71
72
  * channel populated at ingestion time.
72
73
  */
73
- export interface FetchFileResult {
74
- readonly bytes: Buffer;
75
- readonly mediaType?: string;
76
- readonly filename?: string;
77
- }
74
+ export type { FetchFileResult };
78
75
  export type ChannelInstrumentationMetadata = Readonly<Record<string, unknown>>;
79
76
  export type ChannelInstrumentationMetadataProjector = (state: Record<string, unknown> | undefined) => ChannelInstrumentationMetadata;
80
77
  /**
@@ -123,7 +120,7 @@ export type ChannelAdapter<TCtx extends ChannelAdapterContext<any> = ChannelAdap
123
120
  * Credentials should be captured in the closure at channel
124
121
  * construction time.
125
122
  */
126
- readonly fetchFile?: (url: string) => Promise<Buffer | FetchFileResult | null>;
123
+ readonly fetchFile?: FetchFileFunction;
127
124
  /**
128
125
  * Framework-owned observability projection for the active channel.
129
126
  *
@@ -157,4 +154,3 @@ export declare function getAdapterKind(adapter: ChannelAdapter): string;
157
154
  * failure does not corrupt the event stream write path.
158
155
  */
159
156
  export declare function callAdapterEventHandler(adapter: ChannelAdapter, event: HandleMessageStreamEvent, ctx: ChannelAdapterContext): Promise<HandleMessageStreamEvent>;
160
- export {};
@@ -3,6 +3,7 @@ import { type DiscoverDiagnosticsSummary } from "#discover/diagnostics.js";
3
3
  import { type CompiledRemoteAgentNode } from "#compiler/remote-agent-node.js";
4
4
  import type { ChannelRouteMethod } from "#public/definitions/channel.js";
5
5
  import type { NormalizedChannelCorsOptions } from "#channel/cors.js";
6
+ import type { InternalInstructionsDefinition } from "#shared/instructions-definition.js";
6
7
  import type { Node } from "#shared/node.js";
7
8
  import type { MarkdownSourceRef, ModuleSourceRef, SkillPackageSourceRef } from "#shared/source-ref.js";
8
9
  import type { NamedSkillDefinition } from "#shared/skill-definition.js";
@@ -19,7 +20,7 @@ export declare const ROOT_COMPILED_AGENT_NODE_ID = "__root__";
19
20
  /**
20
21
  * Current compiled manifest schema version.
21
22
  */
22
- export declare const COMPILED_AGENT_MANIFEST_VERSION = 32;
23
+ export declare const COMPILED_AGENT_MANIFEST_VERSION = 33;
23
24
  /**
24
25
  * Compiled channel entry preserved in the compiled manifest.
25
26
  */
@@ -73,6 +74,13 @@ interface DisabledCompiledChannelEntry {
73
74
  export type CompiledRuntimeModelReference = InternalAgentModelDefinition & {
74
75
  routing: ModelRouting;
75
76
  };
77
+ /**
78
+ * Dynamic model resolver source preserved in the compiled manifest; the
79
+ * compiled `config.model` remains the fallback model.
80
+ */
81
+ export type CompiledDynamicModelDefinition = ModuleSourceRef & {
82
+ readonly eventNames: readonly string[];
83
+ };
76
84
  /**
77
85
  * Normalized authored compaction configuration preserved in the compiled
78
86
  * manifest.
@@ -86,12 +94,13 @@ type CompiledAgentCompactionDefinition = Omit<InternalAgentCompactionDefinition,
86
94
  export type CompiledAgentDefinition = Omit<InternalAgentDefinition, "model" | "compaction"> & {
87
95
  model: CompiledRuntimeModelReference;
88
96
  compaction?: CompiledAgentCompactionDefinition;
97
+ dynamicModel?: CompiledDynamicModelDefinition;
89
98
  };
90
99
  /**
91
100
  * Normalized authored instructions prompt preserved in the compiled
92
101
  * manifest.
93
102
  */
94
- export type CompiledInstructions = z.infer<typeof compiledInstructionsSchema>;
103
+ export type CompiledInstructionsDefinition = InternalInstructionsDefinition & (Omit<MarkdownSourceRef<undefined>, "definition"> | Omit<ModuleSourceRef, "exportName">);
95
104
  /**
96
105
  * Normalized authored skill preserved in the compiled manifest.
97
106
  */
@@ -193,13 +202,6 @@ export interface CompiledSubagentEdge {
193
202
  * Versioned compiled manifest emitted by the compiler and loaded by runtime.
194
203
  */
195
204
  export type CompiledAgentManifest = z.infer<typeof compiledAgentManifestSchema>;
196
- declare const compiledInstructionsSchema: z.ZodObject<{
197
- name: z.ZodString;
198
- logicalPath: z.ZodString;
199
- markdown: z.ZodString;
200
- sourceId: z.ZodString;
201
- sourceKind: z.ZodUnion<readonly [z.ZodLiteral<"markdown">, z.ZodLiteral<"module">]>;
202
- }, z.core.$strict>;
203
205
  declare const compiledScheduleDefinitionSchema: z.ZodObject<{
204
206
  cron: z.ZodString;
205
207
  hasRun: z.ZodBoolean;
@@ -323,13 +325,7 @@ declare const compiledAgentNodeManifestSchema: z.ZodObject<{
323
325
  url: string;
324
326
  }>, unknown>>>;
325
327
  skills: z.ZodReadonly<z.ZodArray<z.ZodType<CompiledSkillDefinition, unknown, z.core.$ZodTypeInternals<CompiledSkillDefinition, unknown>>>>;
326
- instructions: z.ZodOptional<z.ZodObject<{
327
- name: z.ZodString;
328
- logicalPath: z.ZodString;
329
- markdown: z.ZodString;
330
- sourceId: z.ZodString;
331
- sourceKind: z.ZodUnion<readonly [z.ZodLiteral<"markdown">, z.ZodLiteral<"module">]>;
332
- }, z.core.$strict>>;
328
+ instructions: z.ZodOptional<z.ZodType<CompiledInstructionsDefinition, unknown, z.core.$ZodTypeInternals<CompiledInstructionsDefinition, unknown>>>;
333
329
  tools: z.ZodArray<z.ZodObject<{
334
330
  description: z.ZodString;
335
331
  exportName: z.ZodOptional<z.ZodString>;
@@ -438,13 +434,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
438
434
  name: string;
439
435
  rootPath: string;
440
436
  }>, unknown>>>;
441
- instructions: z.ZodOptional<z.ZodObject<{
442
- name: z.ZodString;
443
- logicalPath: z.ZodString;
444
- markdown: z.ZodString;
445
- sourceId: z.ZodString;
446
- sourceKind: z.ZodUnion<readonly [z.ZodLiteral<"markdown">, z.ZodLiteral<"module">]>;
447
- }, z.core.$strict>>;
437
+ instructions: z.ZodOptional<z.ZodType<CompiledInstructionsDefinition, unknown, z.core.$ZodTypeInternals<CompiledInstructionsDefinition, unknown>>>;
448
438
  tools: z.ZodArray<z.ZodObject<{
449
439
  description: z.ZodString;
450
440
  exportName: z.ZodOptional<z.ZodString>;
@@ -455,7 +445,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
455
445
  sourceId: z.ZodString;
456
446
  sourceKind: z.ZodLiteral<"module">;
457
447
  }, z.core.$strict>>;
458
- version: z.ZodLiteral<32>;
448
+ version: z.ZodLiteral<33>;
459
449
  workspaceResourceRoot: z.ZodObject<{
460
450
  contentHash: z.ZodOptional<z.ZodString>;
461
451
  logicalPath: z.ZodString;
@@ -483,7 +473,7 @@ export declare function createCompiledAgentNodeManifest(input: {
483
473
  readonly sandboxWorkspaces?: readonly CompiledSandboxWorkspace[];
484
474
  readonly schedules?: readonly CompiledScheduleDefinition[];
485
475
  readonly skills?: readonly CompiledSkillDefinition[];
486
- readonly instructions?: CompiledInstructions;
476
+ readonly instructions?: CompiledInstructionsDefinition;
487
477
  readonly tools?: readonly CompiledToolDefinition[];
488
478
  readonly workspaceResourceRoot?: CompiledWorkspaceResourceRoot;
489
479
  }): CompiledAgentNodeManifest;
@@ -526,6 +516,6 @@ export declare function createCompiledAgentManifest(input: {
526
516
  readonly skills?: readonly CompiledSkillDefinition[];
527
517
  readonly subagentEdges?: readonly CompiledSubagentEdge[];
528
518
  readonly subagents?: readonly CompiledSubagentNode[];
529
- readonly instructions?: CompiledInstructions;
519
+ readonly instructions?: CompiledInstructionsDefinition;
530
520
  readonly tools?: readonly CompiledToolDefinition[];
531
521
  }): CompiledAgentManifest;
@@ -1 +1 @@
1
- import{z}from"#compiled/zod/index.js";import{discoverDiagnosticsSummarySchema}from"#discover/diagnostics.js";import{compiledRemoteAgentNodeSchema}from"#compiler/remote-agent-node.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const COMPILED_AGENT_MANIFEST_KIND=`eve-agent-compiled-manifest`,ROOT_COMPILED_AGENT_NODE_ID=`__root__`,COMPILED_AGENT_MANIFEST_VERSION=32,moduleSourceRefSchema=z.object({exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),channelMethodSchema=z.union([z.literal(`GET`),z.literal(`POST`),z.literal(`PUT`),z.literal(`PATCH`),z.literal(`DELETE`),z.literal(`WEBSOCKET`)]),compiledChannelCorsSchema=z.object({origin:z.union([z.literal(`*`),z.literal(`null`),z.array(z.string())]).optional(),methods:z.union([z.literal(`*`),z.array(z.string())]).optional(),allowHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),exposeHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),credentials:z.boolean().optional(),maxAge:z.union([z.string(),z.literal(!1)]).optional(),preflight:z.object({statusCode:z.number().int().min(100).max(599).optional()}).strict().optional()}).strict(),compiledChannelDefinitionSchema=z.object({kind:z.literal(`channel`),name:z.string(),logicalPath:z.string(),method:channelMethodSchema,urlPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional(),adapterKind:z.string().optional(),cors:compiledChannelCorsSchema.optional()}).strict(),disabledCompiledChannelEntrySchema=z.object({kind:z.literal(`disabled`),name:z.string(),logicalPath:z.string()}).strict(),compiledChannelEntrySchema=z.union([compiledChannelDefinitionSchema,disabledCompiledChannelEntrySchema]),modelRoutingSchema=z.union([z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}).strict(),z.object({kind:z.literal(`external`),provider:z.string()}).strict()]),compiledRuntimeModelReferenceSchema=z.object({contextWindowTokens:z.number().int().positive().optional(),id:z.string(),source:moduleSourceRefSchema.optional(),providerOptions:z.record(z.string(),jsonObjectSchema).optional(),routing:modelRoutingSchema}).strict(),compiledAgentBuildDefinitionSchema=z.object({externalDependencies:z.array(z.string()).optional()}).strict(),compiledAgentWorkflowWorldDefinitionSchema=z.string(),compiledAgentWorkflowDefinitionSchema=z.object({world:compiledAgentWorkflowWorldDefinitionSchema.optional()}).strict(),compiledAgentCompactionDefinitionSchema=z.object({model:compiledRuntimeModelReferenceSchema.optional(),thresholdPercent:z.number().finite().min(0).max(1).optional()}).strict(),sessionTokenLimitSchema=z.union([z.number().int().positive(),z.literal(!1)]),compiledAgentLimitsDefinitionSchema=z.object({maxSubagentDepth:z.number().int().positive().optional(),maxSubagents:z.number().int().positive().optional(),maxInputTokensPerSession:sessionTokenLimitSchema.optional(),maxOutputTokensPerSession:sessionTokenLimitSchema.optional()}).strict(),compiledAgentConfigSchema=z.object({build:compiledAgentBuildDefinitionSchema.optional(),compaction:compiledAgentCompactionDefinitionSchema.optional(),description:z.string().optional(),experimental:z.object({workflow:compiledAgentWorkflowDefinitionSchema.optional()}).strict().optional(),model:compiledRuntimeModelReferenceSchema,name:z.string(),outputSchema:jsonObjectSchema.optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional(),source:moduleSourceRefSchema.optional(),limits:compiledAgentLimitsDefinitionSchema.optional()}).strict(),compiledInstructionsSchema=z.object({name:z.string(),logicalPath:z.string(),markdown:z.string(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSkillBaseFields={name:z.string(),description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional(),sourceId:z.string(),logicalPath:z.string()},compiledSkillSourceSchema=z.discriminatedUnion(`sourceKind`,[z.object({...compiledSkillBaseFields,sourceKind:z.literal(`markdown`)}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`skill-package`),skillId:z.string(),skillFilePath:z.string(),rootPath:z.string(),assetsPath:z.string().optional(),referencesPath:z.string().optional(),scriptsPath:z.string().optional()}).strict()]),compiledScheduleDefinitionSchema=z.object({cron:z.string(),hasRun:z.boolean(),name:z.string(),logicalPath:z.string(),markdown:z.string().optional(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSandboxDefinitionSchema=z.object({backendName:z.string().optional(),description:z.string().optional(),exportName:z.string().optional(),logicalPath:z.string(),revalidationKey:z.string().optional(),sourceHash:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSandboxWorkspaceSchema=z.object({logicalPath:z.string(),rootEntries:z.array(z.string()).readonly(),sourceId:z.string(),sourcePath:z.string()}).strict(),compiledWorkspaceResourceRootSchema=z.object({contentHash:z.string().optional(),logicalPath:z.string(),rootEntries:z.array(z.string()).readonly()}).strict(),compiledConnectionDefinitionSchema=z.object({connectionName:z.string(),description:z.string(),exportName:z.string().optional(),logicalPath:z.string(),protocol:z.enum([`mcp`,`openapi`]).default(`mcp`),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string(),vercelConnect:z.object({connector:z.string()}).strict().optional()}).strict(),compiledToolDefinitionSchema=z.object({description:z.string(),exportName:z.string().optional(),inputSchema:jsonObjectSchema.nullable(),logicalPath:z.string(),name:z.string(),outputSchema:jsonObjectSchema.optional(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicToolDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicSkillDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicInstructionsDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledHookDefinitionSchema=z.object({exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledAgentNodeManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowEnabled:z.boolean().default(!1),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),remoteAgents:z.array(compiledRemoteAgentNodeSchema),skills:z.array(compiledSkillSourceSchema).readonly(),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict(),compiledSubagentNodeSchema=z.object({agent:compiledAgentNodeManifestSchema,description:z.string(),entryPath:z.string(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),compiledSubagentEdgeSchema=z.object({childNodeId:z.string(),parentNodeId:z.string()}).strict(),compiledAgentManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowEnabled:z.boolean().default(!1),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),kind:z.literal(COMPILED_AGENT_MANIFEST_KIND),remoteAgents:z.array(compiledRemoteAgentNodeSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),skills:z.array(compiledSkillSourceSchema).readonly(),subagentEdges:z.array(compiledSubagentEdgeSchema),subagents:z.array(compiledSubagentNodeSchema),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),version:z.literal(32),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict();function createCompiledAgentNodeManifest(e){let t={agentRoot:e.agentRoot,appRoot:e.appRoot,channels:[...e.channels??[]],connections:[...e.connections??[]],config:{build:e.config.build===void 0?void 0:{externalDependencies:e.config.build.externalDependencies===void 0?void 0:[...e.config.build.externalDependencies]},compaction:{model:e.config.compaction?.model===void 0?void 0:cloneCompiledRuntimeModelReference(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,experimental:e.config.experimental===void 0?void 0:{workflow:e.config.experimental.workflow===void 0?void 0:{world:e.config.experimental.workflow.world}},model:cloneCompiledRuntimeModelReference(e.config.model),name:e.config.name,outputSchema:e.config.outputSchema,reasoning:e.config.reasoning,limits:e.config.limits===void 0?void 0:{maxInputTokensPerSession:e.config.limits.maxInputTokensPerSession,maxOutputTokensPerSession:e.config.limits.maxOutputTokensPerSession,maxSubagentDepth:e.config.limits.maxSubagentDepth,maxSubagents:e.config.limits.maxSubagents},source:e.config.source===void 0?void 0:{...e.config.source}},diagnosticsSummary:e.diagnosticsSummary??{errors:0,warnings:0},disabledFrameworkTools:[...e.disabledFrameworkTools??[]],workflowEnabled:e.workflowEnabled??!1,dynamicInstructions:[...e.dynamicInstructions??[]],dynamicSkills:[...e.dynamicSkills??[]],dynamicTools:[...e.dynamicTools??[]],hooks:[...e.hooks??[]],remoteAgents:[...e.remoteAgents??[]],sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],workspaceResourceRoot:e.workspaceResourceRoot??{logicalPath:``,rootEntries:deriveResourceRootEntries({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function deriveResourceRootEntries(e){let t=new Set;for(let n of e.sandboxWorkspaces??[])for(let e of n.rootEntries)t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function createCompiledSubagentNodeId(e,t){return e===`__root__`?t:`${e}::${t}`}function createCompiledAgentManifest(e){return{...createCompiledAgentNodeManifest(e),kind:COMPILED_AGENT_MANIFEST_KIND,subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:32}}function cloneCompiledRuntimeModelReference(e){let t={id:e.id,routing:cloneModelRouting(e.routing)};return e.contextWindowTokens!==void 0&&(t.contextWindowTokens=e.contextWindowTokens),e.providerOptions!==void 0&&(t.providerOptions={...e.providerOptions}),e.source!==void 0&&(t.source={...e.source}),t}function cloneModelRouting(e){return e.kind===`external`?{kind:`external`,provider:e.provider}:e.byok===void 0?{kind:`gateway`,target:e.target}:{kind:`gateway`,target:e.target,byok:e.byok}}export{COMPILED_AGENT_MANIFEST_KIND,COMPILED_AGENT_MANIFEST_VERSION,ROOT_COMPILED_AGENT_NODE_ID,compiledAgentManifestSchema,createCompiledAgentManifest,createCompiledAgentNodeManifest,createCompiledSubagentNodeId,deriveResourceRootEntries};
1
+ import{z}from"#compiled/zod/index.js";import{discoverDiagnosticsSummarySchema}from"#discover/diagnostics.js";import{compiledRemoteAgentNodeSchema}from"#compiler/remote-agent-node.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const COMPILED_AGENT_MANIFEST_KIND=`eve-agent-compiled-manifest`,ROOT_COMPILED_AGENT_NODE_ID=`__root__`,COMPILED_AGENT_MANIFEST_VERSION=33,moduleSourceRefSchema=z.object({exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),compiledDynamicModelDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),channelMethodSchema=z.union([z.literal(`GET`),z.literal(`POST`),z.literal(`PUT`),z.literal(`PATCH`),z.literal(`DELETE`),z.literal(`WEBSOCKET`)]),compiledChannelCorsSchema=z.object({origin:z.union([z.literal(`*`),z.literal(`null`),z.array(z.string())]).optional(),methods:z.union([z.literal(`*`),z.array(z.string())]).optional(),allowHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),exposeHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),credentials:z.boolean().optional(),maxAge:z.union([z.string(),z.literal(!1)]).optional(),preflight:z.object({statusCode:z.number().int().min(100).max(599).optional()}).strict().optional()}).strict(),compiledChannelDefinitionSchema=z.object({kind:z.literal(`channel`),name:z.string(),logicalPath:z.string(),method:channelMethodSchema,urlPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional(),adapterKind:z.string().optional(),cors:compiledChannelCorsSchema.optional()}).strict(),disabledCompiledChannelEntrySchema=z.object({kind:z.literal(`disabled`),name:z.string(),logicalPath:z.string()}).strict(),compiledChannelEntrySchema=z.union([compiledChannelDefinitionSchema,disabledCompiledChannelEntrySchema]),modelRoutingSchema=z.union([z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}).strict(),z.object({kind:z.literal(`external`),provider:z.string()}).strict()]),compiledRuntimeModelReferenceSchema=z.object({contextWindowTokens:z.number().int().positive().optional(),id:z.string(),source:moduleSourceRefSchema.optional(),providerOptions:z.record(z.string(),jsonObjectSchema).optional(),routing:modelRoutingSchema}).strict(),compiledAgentBuildDefinitionSchema=z.object({externalDependencies:z.array(z.string()).optional()}).strict(),compiledAgentWorkflowWorldDefinitionSchema=z.string(),compiledAgentWorkflowDefinitionSchema=z.object({world:compiledAgentWorkflowWorldDefinitionSchema.optional()}).strict(),compiledAgentCompactionDefinitionSchema=z.object({model:compiledRuntimeModelReferenceSchema.optional(),thresholdPercent:z.number().finite().min(0).max(1).optional()}).strict(),sessionTokenLimitSchema=z.union([z.number().int().positive(),z.literal(!1)]),compiledAgentLimitsDefinitionSchema=z.object({maxSubagentDepth:z.number().int().positive().optional(),maxSubagents:z.number().int().positive().optional(),maxInputTokensPerSession:sessionTokenLimitSchema.optional(),maxOutputTokensPerSession:sessionTokenLimitSchema.optional()}).strict(),compiledAgentConfigSchema=z.object({build:compiledAgentBuildDefinitionSchema.optional(),compaction:compiledAgentCompactionDefinitionSchema.optional(),description:z.string().optional(),dynamicModel:compiledDynamicModelDefinitionSchema.optional(),experimental:z.object({workflow:compiledAgentWorkflowDefinitionSchema.optional()}).strict().optional(),model:compiledRuntimeModelReferenceSchema,name:z.string(),outputSchema:jsonObjectSchema.optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional(),source:moduleSourceRefSchema.optional(),limits:compiledAgentLimitsDefinitionSchema.optional()}).strict(),compiledInstructionsSchema=z.object({name:z.string(),logicalPath:z.string(),markdown:z.string(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSkillBaseFields={name:z.string(),description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional(),sourceId:z.string(),logicalPath:z.string()},compiledSkillSourceSchema=z.discriminatedUnion(`sourceKind`,[z.object({...compiledSkillBaseFields,sourceKind:z.literal(`markdown`)}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`skill-package`),skillId:z.string(),skillFilePath:z.string(),rootPath:z.string(),assetsPath:z.string().optional(),referencesPath:z.string().optional(),scriptsPath:z.string().optional()}).strict()]),compiledScheduleDefinitionSchema=z.object({cron:z.string(),hasRun:z.boolean(),name:z.string(),logicalPath:z.string(),markdown:z.string().optional(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSandboxDefinitionSchema=z.object({backendName:z.string().optional(),description:z.string().optional(),exportName:z.string().optional(),logicalPath:z.string(),revalidationKey:z.string().optional(),sourceHash:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSandboxWorkspaceSchema=z.object({logicalPath:z.string(),rootEntries:z.array(z.string()).readonly(),sourceId:z.string(),sourcePath:z.string()}).strict(),compiledWorkspaceResourceRootSchema=z.object({contentHash:z.string().optional(),logicalPath:z.string(),rootEntries:z.array(z.string()).readonly()}).strict(),compiledConnectionDefinitionSchema=z.object({connectionName:z.string(),description:z.string(),exportName:z.string().optional(),logicalPath:z.string(),protocol:z.enum([`mcp`,`openapi`]).default(`mcp`),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string(),vercelConnect:z.object({connector:z.string()}).strict().optional()}).strict(),compiledToolDefinitionSchema=z.object({description:z.string(),exportName:z.string().optional(),inputSchema:jsonObjectSchema.nullable(),logicalPath:z.string(),name:z.string(),outputSchema:jsonObjectSchema.optional(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicToolDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicSkillDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicInstructionsDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledHookDefinitionSchema=z.object({exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledAgentNodeManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowEnabled:z.boolean().default(!1),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),remoteAgents:z.array(compiledRemoteAgentNodeSchema),skills:z.array(compiledSkillSourceSchema).readonly(),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict(),compiledSubagentNodeSchema=z.object({agent:compiledAgentNodeManifestSchema,description:z.string(),entryPath:z.string(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),compiledSubagentEdgeSchema=z.object({childNodeId:z.string(),parentNodeId:z.string()}).strict(),compiledAgentManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowEnabled:z.boolean().default(!1),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),kind:z.literal(COMPILED_AGENT_MANIFEST_KIND),remoteAgents:z.array(compiledRemoteAgentNodeSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),skills:z.array(compiledSkillSourceSchema).readonly(),subagentEdges:z.array(compiledSubagentEdgeSchema),subagents:z.array(compiledSubagentNodeSchema),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),version:z.literal(33),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict();function createCompiledAgentNodeManifest(e){let t={agentRoot:e.agentRoot,appRoot:e.appRoot,channels:[...e.channels??[]],connections:[...e.connections??[]],config:{build:e.config.build===void 0?void 0:{externalDependencies:e.config.build.externalDependencies===void 0?void 0:[...e.config.build.externalDependencies]},compaction:{model:e.config.compaction?.model===void 0?void 0:cloneCompiledRuntimeModelReference(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,dynamicModel:e.config.dynamicModel===void 0?void 0:{...e.config.dynamicModel},experimental:e.config.experimental===void 0?void 0:{workflow:e.config.experimental.workflow===void 0?void 0:{world:e.config.experimental.workflow.world}},model:cloneCompiledRuntimeModelReference(e.config.model),name:e.config.name,outputSchema:e.config.outputSchema,reasoning:e.config.reasoning,limits:e.config.limits===void 0?void 0:{maxInputTokensPerSession:e.config.limits.maxInputTokensPerSession,maxOutputTokensPerSession:e.config.limits.maxOutputTokensPerSession,maxSubagentDepth:e.config.limits.maxSubagentDepth,maxSubagents:e.config.limits.maxSubagents},source:e.config.source===void 0?void 0:{...e.config.source}},diagnosticsSummary:e.diagnosticsSummary??{errors:0,warnings:0},disabledFrameworkTools:[...e.disabledFrameworkTools??[]],workflowEnabled:e.workflowEnabled??!1,dynamicInstructions:[...e.dynamicInstructions??[]],dynamicSkills:[...e.dynamicSkills??[]],dynamicTools:[...e.dynamicTools??[]],hooks:[...e.hooks??[]],remoteAgents:[...e.remoteAgents??[]],sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],workspaceResourceRoot:e.workspaceResourceRoot??{logicalPath:``,rootEntries:deriveResourceRootEntries({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function deriveResourceRootEntries(e){let t=new Set;for(let n of e.sandboxWorkspaces??[])for(let e of n.rootEntries)t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function createCompiledSubagentNodeId(e,t){return e===`__root__`?t:`${e}::${t}`}function createCompiledAgentManifest(e){return{...createCompiledAgentNodeManifest(e),kind:COMPILED_AGENT_MANIFEST_KIND,subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:33}}function cloneCompiledRuntimeModelReference(e){let t={id:e.id,routing:cloneModelRouting(e.routing)};return e.contextWindowTokens!==void 0&&(t.contextWindowTokens=e.contextWindowTokens),e.providerOptions!==void 0&&(t.providerOptions={...e.providerOptions}),e.source!==void 0&&(t.source={...e.source}),t}function cloneModelRouting(e){return e.kind===`external`?{kind:`external`,provider:e.provider}:e.byok===void 0?{kind:`gateway`,target:e.target}:{kind:`gateway`,target:e.target,byok:e.byok}}export{COMPILED_AGENT_MANIFEST_KIND,COMPILED_AGENT_MANIFEST_VERSION,ROOT_COMPILED_AGENT_NODE_ID,compiledAgentManifestSchema,createCompiledAgentManifest,createCompiledAgentNodeManifest,createCompiledSubagentNodeId,deriveResourceRootEntries};
@@ -1 +1 @@
1
- import{isAbsolute,join,relative,resolve}from"node:path";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{toErrorMessage}from"#shared/errors.js";import{normalizeJsonSchemaDefinition}from"#shared/json-schema.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{classifyModelRouting}from"#internal/classify-model-routing.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{parseJsonObject}from"#shared/json.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";async function compileAgentConfig(e,t){let n=e.configModule,r=n===void 0?void 0:formatAgentConfigModulePath(e,n),a=normalizeAgentDefinition(n===void 0?{model:DEFAULT_AGENT_MODEL_ID}:await loadModuleBackedDefinition({agentRoot:e.agentRoot,displayPath:r,kind:`agent config`,source:n}),n===void 0?`Expected the default agent config to match the public eve shape.`:`Expected the agent config export "${n.exportName??`default`}" from "${r}" to match the public eve shape.`),o=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the primary compaction trigger model`,contextWindowTokens:a.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:a.model}),s={},c={compaction:s,model:o,name:e.agentId};a.description!==void 0&&(c.description=a.description);let l=normalizeExperimentalDefinition(a.experimental);return l!==void 0&&(c.experimental=l),a.build!==void 0&&(c.build={externalDependencies:a.build.externalDependencies===void 0?void 0:[...a.build.externalDependencies]}),a.outputSchema!==void 0&&(c.outputSchema=normalizeJsonSchemaDefinition(a.outputSchema,`output`)),a.reasoning!==void 0&&(c.reasoning=a.reasoning),a.limits!==void 0&&(c.limits={maxSubagentDepth:a.limits.maxSubagentDepth,maxSubagents:a.limits.maxSubagents,maxInputTokensPerSession:a.limits.maxInputTokensPerSession,maxOutputTokensPerSession:a.limits.maxOutputTokensPerSession}),n!==void 0&&(c.source={exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId}),a.compaction?.model!==void 0&&(s.model=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the compaction summary model`,contextWindowTokens:a.compaction.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:a.compaction.model})),a.compaction?.thresholdPercent!==void 0&&(s.thresholdPercent=a.compaction.thresholdPercent),c}function normalizeExperimentalDefinition(e){if(e===void 0)return;let t={};return e.workflow!==void 0&&(t.workflow={world:e.workflow.world}),t}async function normalizeAuthoredModelReference(e){if(typeof e.value==`string`)return await withCompiledRuntimeModelLimits({id:formatLanguageModelGatewayId(e.value),providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(e.value,e.providerOptions)},e);let t=e.source;if(t===void 0)throw Error(`Expected ${e.purpose} to provide a valid AI SDK language model reference.`);let n=e.value,r=n.specificationVersion;if(r!==`v2`&&r!==`v3`&&r!==`v4`||typeof n.provider!=`string`||typeof n.modelId!=`string`||typeof n.doGenerate!=`function`||typeof n.doStream!=`function`)throw Error(`Expected the authored agent config export "${t.exportName??`default`}" from "${e.sourcePath??t.logicalPath}" to provide a valid AI SDK language model.`);let i={id:formatLanguageModelGatewayId(n),source:{exportName:t.exportName,sourceKind:`module`,logicalPath:t.logicalPath,sourceId:t.sourceId},providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(n,e.providerOptions)};if(e.contextWindowTokens===void 0){let t=await e.modelCatalog.getByProviderModelId(n.provider,n.modelId);if(t)return{...i,id:t.slug,contextWindowTokens:t.limits.contextWindowTokens}}return await withCompiledRuntimeModelLimits(i,e)}function formatAgentConfigModulePath(e,r){let i=join(e.agentRoot,r.logicalPath);return normalizeLogicalPath(relative(resolveTopLevelAgentRoot(e),i))}function resolveTopLevelAgentRoot(e){let t=resolve(e.appRoot),n=resolve(t,`agent`);return isPathInsideOrEqual(n,resolve(e.agentRoot))?n:t}function isPathInsideOrEqual(t,r){let i=relative(t,r);return i===``||!i.startsWith(`..`)&&!isAbsolute(i)}async function withCompiledRuntimeModelLimits(e,t){if(t.contextWindowTokens!==void 0)return{...e,contextWindowTokens:t.contextWindowTokens};let n;try{n=await t.modelCatalog.getModelLimits(e.id)}catch(n){throw Error(`Failed to load AI Gateway model metadata for ${t.purpose} "${e.id}". ${toErrorMessage(n)}`)}if(n===null)throw Error(`Cannot compile agent compaction because ${t.purpose} "${e.id}" does not have known AI Gateway context window metadata.`);return{...e,contextWindowTokens:n.contextWindowTokens}}function parseProviderOptionsRecord(e){if(e===void 0)return;let t={};for(let[n,r]of Object.entries(e))t[n]=parseJsonObject(r);return t}export{compileAgentConfig};
1
+ import{isAbsolute,join,relative,resolve}from"node:path";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{toErrorMessage}from"#shared/errors.js";import{normalizeJsonSchemaDefinition}from"#shared/json-schema.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{classifyModelRouting}from"#internal/classify-model-routing.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{parseJsonObject}from"#shared/json.js";import{isDynamicModelDefinition}from"#shared/agent-definition.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";async function compileAgentConfig(e,t){let n=e.configModule,r=n===void 0?void 0:formatAgentConfigModulePath(e,n),a=normalizeAgentDefinition(n===void 0?{model:DEFAULT_AGENT_MODEL_ID}:await loadModuleBackedDefinition({agentRoot:e.agentRoot,displayPath:r,kind:`agent config`,source:n}),n===void 0?`Expected the default agent config to match the public eve shape.`:`Expected the agent config export "${n.exportName??`default`}" from "${r}" to match the public eve shape.`),o=isDynamicModelDefinition(a.model)?a.model.fallback:a.model,s=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the primary compaction trigger model`,contextWindowTokens:a.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:o}),c={},l={compaction:c,model:s,name:e.agentId};if(a.description!==void 0&&(l.description=a.description),isDynamicModelDefinition(a.model)){if(n===void 0)throw Error(`Expected dynamic model definitions to be authored in agent.ts.`);l.dynamicModel={eventNames:Object.keys(a.model.events),exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId}}let u=normalizeExperimentalDefinition(a.experimental);return u!==void 0&&(l.experimental=u),a.build!==void 0&&(l.build={externalDependencies:a.build.externalDependencies===void 0?void 0:[...a.build.externalDependencies]}),a.outputSchema!==void 0&&(l.outputSchema=normalizeJsonSchemaDefinition(a.outputSchema,`output`)),a.reasoning!==void 0&&(l.reasoning=a.reasoning),a.limits!==void 0&&(l.limits={maxSubagentDepth:a.limits.maxSubagentDepth,maxSubagents:a.limits.maxSubagents,maxInputTokensPerSession:a.limits.maxInputTokensPerSession,maxOutputTokensPerSession:a.limits.maxOutputTokensPerSession}),n!==void 0&&(l.source={exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId}),a.compaction?.model!==void 0&&(c.model=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the compaction summary model`,contextWindowTokens:a.compaction.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:a.compaction.model})),a.compaction?.thresholdPercent!==void 0&&(c.thresholdPercent=a.compaction.thresholdPercent),l}function normalizeExperimentalDefinition(e){if(e===void 0)return;let t={};return e.workflow!==void 0&&(t.workflow={world:e.workflow.world}),t}async function normalizeAuthoredModelReference(e){if(typeof e.value==`string`)return await withCompiledRuntimeModelLimits({id:formatLanguageModelGatewayId(e.value),providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(e.value,e.providerOptions)},e);let t=e.source;if(t===void 0)throw Error(`Expected ${e.purpose} to provide a valid AI SDK language model reference.`);let n=e.value,r=n.specificationVersion;if(r!==`v2`&&r!==`v3`&&r!==`v4`||typeof n.provider!=`string`||typeof n.modelId!=`string`||typeof n.doGenerate!=`function`||typeof n.doStream!=`function`)throw Error(`Expected the authored agent config export "${t.exportName??`default`}" from "${e.sourcePath??t.logicalPath}" to provide a valid AI SDK language model.`);let i={id:formatLanguageModelGatewayId(n),source:{exportName:t.exportName,sourceKind:`module`,logicalPath:t.logicalPath,sourceId:t.sourceId},providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(n,e.providerOptions)};if(e.contextWindowTokens===void 0){let t=await e.modelCatalog.getByProviderModelId(n.provider,n.modelId);if(t)return{...i,id:t.slug,contextWindowTokens:t.limits.contextWindowTokens}}return await withCompiledRuntimeModelLimits(i,e)}function formatAgentConfigModulePath(e,r){let i=join(e.agentRoot,r.logicalPath);return normalizeLogicalPath(relative(resolveTopLevelAgentRoot(e),i))}function resolveTopLevelAgentRoot(e){let t=resolve(e.appRoot),n=resolve(t,`agent`);return isPathInsideOrEqual(n,resolve(e.agentRoot))?n:t}function isPathInsideOrEqual(t,r){let i=relative(t,r);return i===``||!i.startsWith(`..`)&&!isAbsolute(i)}async function withCompiledRuntimeModelLimits(e,t){if(t.contextWindowTokens!==void 0)return{...e,contextWindowTokens:t.contextWindowTokens};let n;try{n=await t.modelCatalog.getModelLimits(e.id)}catch(n){throw Error(`Failed to load AI Gateway model metadata for ${t.purpose} "${e.id}". ${toErrorMessage(n)}`)}if(n===null)throw Error(`Cannot compile agent compaction because ${t.purpose} "${e.id}" does not have known AI Gateway context window metadata.`);return{...e,contextWindowTokens:n.contextWindowTokens}}function parseProviderOptionsRecord(e){if(e===void 0)return;let t={};for(let[n,r]of Object.entries(e))t[n]=parseJsonObject(r);return t}export{compileAgentConfig};
@@ -1,4 +1,4 @@
1
- import type { ModuleSourceRef } from "../shared/source-ref.js";
1
+ import type { HookSourceRef } from "#discover/manifest.js";
2
2
  import type { CompiledHookDefinition } from "./manifest.js";
3
3
  /**
4
4
  * Compiles one authored hook module into the manifest entry stored on
@@ -9,4 +9,4 @@ import type { CompiledHookDefinition } from "./manifest.js";
9
9
  * path-relative slug used for diagnostics and ordering. Per-handler
10
10
  * validation lives in the runtime resolver.
11
11
  */
12
- export declare function compileHookEntry(source: ModuleSourceRef): CompiledHookDefinition;
12
+ export declare function compileHookEntry(source: HookSourceRef): CompiledHookDefinition;
@@ -1,5 +1,5 @@
1
1
  import type { InstructionsSourceRef } from "#discover/manifest.js";
2
- import type { CompiledDynamicInstructionsDefinition, CompiledInstructions } from "#compiler/manifest.js";
2
+ import type { CompiledDynamicInstructionsDefinition, CompiledInstructionsDefinition } from "#compiler/manifest.js";
3
3
  import { type ModuleBackedDefinitionLoadOptions } from "#compiler/normalize-helpers.js";
4
4
  /**
5
5
  * Compiled instructions entry produced from one authored `instructions/*`
@@ -10,7 +10,7 @@ import { type ModuleBackedDefinitionLoadOptions } from "#compiler/normalize-help
10
10
  */
11
11
  export type CompiledInstructionsEntry = {
12
12
  readonly kind: "instructions";
13
- readonly definition: CompiledInstructions;
13
+ readonly definition: CompiledInstructionsDefinition;
14
14
  } | {
15
15
  readonly kind: "dynamic-instructions";
16
16
  readonly definition: CompiledDynamicInstructionsDefinition;
@@ -33,4 +33,4 @@ export declare function compileInstructionsEntry(agentRoot: string, source: Inst
33
33
  * @deprecated Use {@link compileInstructionsEntry} instead. Kept for
34
34
  * backwards compatibility with callers that pass a single source.
35
35
  */
36
- export declare function compileInstructions(agentRoot: string, source: InstructionsSourceRef, options?: ModuleBackedDefinitionLoadOptions): Promise<CompiledInstructions>;
36
+ export declare function compileInstructions(agentRoot: string, source: InstructionsSourceRef, options?: ModuleBackedDefinitionLoadOptions): Promise<CompiledInstructionsDefinition>;
@@ -1 +1 @@
1
- import{stripLogicalPathExtension}from"#discover/filesystem.js";import{normalizeInstructionsDefinition}from"#internal/authored-definition/core.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{isDynamicSentinel}from"#shared/dynamic-tool-definition.js";async function compileInstructionsEntry(i,a,o={}){if(a.sourceKind===`markdown`){let n=normalizeInstructionsDefinition(a.definition,`Expected the compiled instructions definition at "${a.logicalPath}" to match the public eve shape.`);return{kind:`instructions`,definition:{name:stripLogicalPathExtension(a.logicalPath),logicalPath:a.logicalPath,markdown:n.markdown,sourceId:a.sourceId,sourceKind:a.sourceKind}}}let s=await loadModuleBackedDefinition({agentRoot:i,externalDependencies:o.externalDependencies,kind:`instructions`,source:a});if(isDynamicSentinel(s)){let t=stripLogicalPathExtension(a.logicalPath).replace(/^instructions\//,``);return{kind:`dynamic-instructions`,definition:{eventNames:Object.keys(s.events),exportName:a.exportName,logicalPath:a.logicalPath,slug:t,sourceId:a.sourceId,sourceKind:`module`}}}let c=normalizeInstructionsDefinition(s,`Expected the instructions export "${a.exportName??`default`}" from "${a.logicalPath}" to match the public eve shape.`);return{kind:`instructions`,definition:{name:stripLogicalPathExtension(a.logicalPath),logicalPath:a.logicalPath,markdown:c.markdown,sourceId:a.sourceId,sourceKind:a.sourceKind}}}async function compileInstructions(e,t,n={}){let r=await compileInstructionsEntry(e,t,n);if(r.kind===`dynamic-instructions`)throw Error(`Expected static instructions from "${t.logicalPath}" but got a dynamic resolver. Use compileInstructionsEntry instead.`);return r.definition}export{compileInstructions,compileInstructionsEntry};
1
+ import{stripLogicalPathExtension}from"#discover/filesystem.js";import{normalizeInstructionsDefinition}from"#internal/authored-definition/core.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{isDynamicSentinel,rejectDynamicSentinelFallback}from"#shared/dynamic-tool-definition.js";async function compileInstructionsEntry(i,a,o={}){if(a.sourceKind===`markdown`){let n=normalizeInstructionsDefinition(a.definition,`Expected the compiled instructions definition at "${a.logicalPath}" to match the public eve shape.`);return{kind:`instructions`,definition:{name:stripLogicalPathExtension(a.logicalPath),logicalPath:a.logicalPath,markdown:n.markdown,sourceId:a.sourceId,sourceKind:a.sourceKind}}}let s=await loadModuleBackedDefinition({agentRoot:i,externalDependencies:o.externalDependencies,kind:`instructions`,source:a});if(isDynamicSentinel(s)){rejectDynamicSentinelFallback(s,`Expected the instructions export "${a.exportName??`default`}" from "${a.logicalPath}" to match the public eve shape.`);let t=stripLogicalPathExtension(a.logicalPath).replace(/^instructions\//,``);return{kind:`dynamic-instructions`,definition:{eventNames:Object.keys(s.events),exportName:a.exportName,logicalPath:a.logicalPath,slug:t,sourceId:a.sourceId,sourceKind:`module`}}}let c=normalizeInstructionsDefinition(s,`Expected the instructions export "${a.exportName??`default`}" from "${a.logicalPath}" to match the public eve shape.`);return{kind:`instructions`,definition:{name:stripLogicalPathExtension(a.logicalPath),logicalPath:a.logicalPath,markdown:c.markdown,sourceId:a.sourceId,sourceKind:a.sourceKind}}}async function compileInstructions(e,t,n={}){let r=await compileInstructionsEntry(e,t,n);if(r.kind===`dynamic-instructions`)throw Error(`Expected static instructions from "${t.logicalPath}" but got a dynamic resolver. Use compileInstructionsEntry instead.`);return r.definition}export{compileInstructions,compileInstructionsEntry};
@@ -1 +1 @@
1
- import{stripLogicalPathExtension}from"#discover/filesystem.js";import{normalizeSkillDefinition}from"#internal/authored-definition/core.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{isDynamicSentinel}from"#shared/dynamic-tool-definition.js";async function compileSkillSource(r,i,a={}){if(i.sourceKind===`skill-package`)return{kind:`skill`,definition:compileSkillPackageSource(i)};if(i.sourceKind===`markdown`){let n=normalizeSkillDefinition(i.definition,`Expected the compiled skill definition at "${i.logicalPath}" to match the public eve shape.`);return{kind:`skill`,definition:{description:n.description,files:n.files,license:n.license,logicalPath:i.logicalPath,markdown:n.markdown,metadata:n.metadata===void 0?void 0:{...n.metadata},name:stripLogicalPathExtension(i.logicalPath).replace(/^skills\//,``),sourceId:i.sourceId,sourceKind:i.sourceKind}}}let o=await loadModuleBackedDefinition({agentRoot:r,externalDependencies:a.externalDependencies,kind:`skill`,source:i});if(isDynamicSentinel(o)){let t=stripLogicalPathExtension(i.logicalPath).replace(/^skills\//,``);return{kind:`dynamic-skill`,definition:{eventNames:Object.keys(o.events),exportName:i.exportName,logicalPath:i.logicalPath,slug:t,sourceId:i.sourceId,sourceKind:`module`}}}let s=normalizeSkillDefinition(o,`Expected the skill export "${i.exportName??`default`}" from "${i.logicalPath}" to match the public eve shape.`);return{kind:`skill`,definition:{description:s.description,files:s.files,license:s.license,logicalPath:i.logicalPath,markdown:s.markdown,metadata:s.metadata===void 0?void 0:{...s.metadata},name:stripLogicalPathExtension(i.logicalPath).replace(/^skills\//,``),sourceId:i.sourceId,sourceKind:i.sourceKind}}}function compileSkillPackageSource(e){return{assetsPath:e.assetsPath,description:e.description,license:e.license,logicalPath:e.logicalPath,markdown:e.markdown,metadata:e.metadata===void 0?void 0:{...e.metadata},name:e.name,referencesPath:e.referencesPath,rootPath:e.rootPath,scriptsPath:e.scriptsPath,skillId:e.skillId,skillFilePath:e.skillFilePath,sourceId:e.sourceId,sourceKind:`skill-package`}}export{compileSkillSource};
1
+ import{stripLogicalPathExtension}from"#discover/filesystem.js";import{normalizeSkillDefinition}from"#internal/authored-definition/core.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{isDynamicSentinel,rejectDynamicSentinelFallback}from"#shared/dynamic-tool-definition.js";async function compileSkillSource(r,i,a={}){if(i.sourceKind===`skill-package`)return{kind:`skill`,definition:compileSkillPackageSource(i)};if(i.sourceKind===`markdown`){let n=normalizeSkillDefinition(i.definition,`Expected the compiled skill definition at "${i.logicalPath}" to match the public eve shape.`);return{kind:`skill`,definition:{description:n.description,files:n.files,license:n.license,logicalPath:i.logicalPath,markdown:n.markdown,metadata:n.metadata===void 0?void 0:{...n.metadata},name:stripLogicalPathExtension(i.logicalPath).replace(/^skills\//,``),sourceId:i.sourceId,sourceKind:i.sourceKind}}}let o=await loadModuleBackedDefinition({agentRoot:r,externalDependencies:a.externalDependencies,kind:`skill`,source:i});if(isDynamicSentinel(o)){rejectDynamicSentinelFallback(o,`Expected the skill export "${i.exportName??`default`}" from "${i.logicalPath}" to match the public eve shape.`);let t=stripLogicalPathExtension(i.logicalPath).replace(/^skills\//,``);return{kind:`dynamic-skill`,definition:{eventNames:Object.keys(o.events),exportName:i.exportName,logicalPath:i.logicalPath,slug:t,sourceId:i.sourceId,sourceKind:`module`}}}let s=normalizeSkillDefinition(o,`Expected the skill export "${i.exportName??`default`}" from "${i.logicalPath}" to match the public eve shape.`);return{kind:`skill`,definition:{description:s.description,files:s.files,license:s.license,logicalPath:i.logicalPath,markdown:s.markdown,metadata:s.metadata===void 0?void 0:{...s.metadata},name:stripLogicalPathExtension(i.logicalPath).replace(/^skills\//,``),sourceId:i.sourceId,sourceKind:i.sourceKind}}}function compileSkillPackageSource(e){return{assetsPath:e.assetsPath,description:e.description,license:e.license,logicalPath:e.logicalPath,markdown:e.markdown,metadata:e.metadata===void 0?void 0:{...e.metadata},name:e.name,referencesPath:e.referencesPath,rootPath:e.rootPath,scriptsPath:e.scriptsPath,skillId:e.skillId,skillFilePath:e.skillFilePath,sourceId:e.sourceId,sourceKind:`skill-package`}}export{compileSkillSource};
@@ -1,4 +1,4 @@
1
- import type { ModuleSourceRef } from "#shared/source-ref.js";
1
+ import type { ToolSourceRef } from "#discover/manifest.js";
2
2
  import type { CompiledToolDefinition, CompiledDynamicToolDefinition } from "#compiler/manifest.js";
3
3
  import { type ModuleBackedDefinitionLoadOptions } from "#compiler/normalize-helpers.js";
4
4
  /**
@@ -32,4 +32,4 @@ export type CompiledToolEntry = {
32
32
  * directories into a slug-safe single segment. Authored `name` fields
33
33
  * are rejected by the normalizer.
34
34
  */
35
- export declare function compileToolEntry(agentRoot: string, source: ModuleSourceRef, options?: ModuleBackedDefinitionLoadOptions): Promise<CompiledToolEntry>;
35
+ export declare function compileToolEntry(agentRoot: string, source: ToolSourceRef, options?: ModuleBackedDefinitionLoadOptions): Promise<CompiledToolEntry>;
@@ -16,6 +16,8 @@ export interface AlsContext extends ContextAccessor {
16
16
  * Used by the serialization layer to persist context at step boundaries.
17
17
  */
18
18
  entries(): Iterable<readonly [ContextKey<unknown>, unknown]>;
19
+ /** Stores a step-local value that shadows the durable value and is never serialized. */
20
+ setVirtualContext<T>(key: ContextKey<T>, value: T): void;
19
21
  }
20
22
  /**
21
23
  * Default mutable implementation of {@link AlsContext}.
@@ -0,0 +1,19 @@
1
+ import type { ModelMessage } from "ai";
2
+ import type { AlsContext } from "#context/container.js";
3
+ import type { ContextKey } from "#context/key.js";
4
+ import { type LiveDynamicModelSelection } from "#context/keys.js";
5
+ import type { HandleMessageStreamEvent } from "#protocol/message.js";
6
+ import type { RuntimeDynamicModelReference, RuntimeModelReference } from "#runtime/agent/bootstrap.js";
7
+ import { type RuntimeModelResolutionScope } from "#runtime/agent/resolve-model.js";
8
+ export type ActiveDynamicModelSelection = LiveDynamicModelSelection;
9
+ export declare function getActiveDynamicModelSelection(ctx: {
10
+ get<T>(key: ContextKey<T>): T | undefined;
11
+ }): ActiveDynamicModelSelection | null;
12
+ export declare function dispatchDynamicModelEvent(input: {
13
+ readonly ctx: AlsContext;
14
+ readonly dynamicModel: RuntimeDynamicModelReference | undefined;
15
+ readonly event: HandleMessageStreamEvent;
16
+ readonly fallback: RuntimeModelReference;
17
+ readonly messages: readonly ModelMessage[];
18
+ readonly scope: RuntimeModelResolutionScope;
19
+ }): Promise<void>;
@@ -0,0 +1 @@
1
+ import{createLogger}from"#internal/logging.js";import{LiveStepDynamicModelSelectionKey,SessionDynamicModelReferenceKey,TurnDynamicModelReferenceKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{buildResolveContext}from"#context/dynamic-resolve-context.js";import{loadDynamicRuntimeModelDefinition,normalizeDynamicRuntimeModelResult,shouldMockAuthoredRuntimeModels}from"#runtime/agent/resolve-model.js";const log=createLogger(`dynamic-models`),ALLOWED_DYNAMIC_MODEL_EVENTS=new Set([`session.started`,`turn.started`,`step.started`]);function isDynamicModelEventName(e){return ALLOWED_DYNAMIC_MODEL_EVENTS.has(e)}function durableKeyForEvent(e){switch(e){case`session.started`:return SessionDynamicModelReferenceKey;case`turn.started`:return TurnDynamicModelReferenceKey;case`step.started`:return}}function getActiveDynamicModelSelection(e){let i=e.get(LiveStepDynamicModelSelectionKey);if(i!=null)return i;let a=e.get(TurnDynamicModelReferenceKey);if(a!=null)return{reference:a};let o=e.get(SessionDynamicModelReferenceKey);return o==null?null:{reference:o}}async function dispatchDynamicModelEvent(e){if(e.dynamicModel!==void 0&&isDynamicModelEventName(e.event.type)&&e.dynamicModel.eventNames.includes(e.event.type))try{let t=(await loadDynamicRuntimeModelDefinition({dynamicModel:e.dynamicModel,scope:e.scope})).events[e.event.type];if(t===void 0){setSelectionForEvent(e.ctx,e.event.type,null);return}let n=await t(e.event,buildResolveContext(e.ctx,e.messages)),r=n==null?null:normalizeDynamicRuntimeModelResult({fallback:e.fallback,result:n});if(r!==null&&e.event.type!==`step.started`&&r.model!==void 0){log.error(`Dynamic model resolver (${e.event.type}) returned a provider object, but session- and turn-scoped model selections must be serializable. Return a model id string for this scope, or use "step.started".`),setSelectionForEvent(e.ctx,e.event.type,null);return}setSelectionForEvent(e.ctx,e.event.type,r)}catch(t){log.error(`Dynamic model resolver (${e.event.type}) threw - skipping.`,{error:toErrorMessage(t)}),setSelectionForEvent(e.ctx,e.event.type,null)}}function setSelectionForEvent(e,n,r){if(n===`step.started`){let n=r!==null&&r.model!==void 0&&shouldMockAuthoredRuntimeModels()?{reference:r.reference}:r;e.setVirtualContext(LiveStepDynamicModelSelectionKey,n);return}let i=durableKeyForEvent(n);i!==void 0&&e.set(i,r?.reference??null)}export{dispatchDynamicModelEvent,getActiveDynamicModelSelection};
@@ -3,12 +3,13 @@
3
3
  * tier. Codec-carrying keys (`ChannelKey`, `BundleKey`) live in
4
4
  * `#runtime/sessions/runtime-context-keys.ts`.
5
5
  */
6
- import type { SystemModelMessage } from "ai";
6
+ import type { LanguageModel, SystemModelMessage } from "ai";
7
7
  import type { JsonObject } from "#shared/json.js";
8
8
  import type { ChannelInstrumentationProjection, SessionAuthContext, SessionCallback, SessionCapabilities, SessionParent, SessionTurn } from "#channel/types.js";
9
9
  import { ContextKey } from "#context/key.js";
10
10
  import type { SandboxAccess } from "#sandbox/state.js";
11
11
  import type { RunMode } from "#shared/run-mode.js";
12
+ import type { RuntimeModelReference } from "#runtime/agent/bootstrap.js";
12
13
  export type { SessionAuthContext, SessionParent, SessionTurn } from "#channel/types.js";
13
14
  /**
14
15
  * Auth metadata on the active session.
@@ -55,6 +56,17 @@ export declare const CapabilitiesKey: ContextKey<SessionCapabilities>;
55
56
  export declare const SessionCallbackKey: ContextKey<SessionCallback>;
56
57
  export declare const SessionKey: ContextKey<Session>;
57
58
  export declare const SandboxKey: ContextKey<SandboxAccess>;
59
+ /** Session-scoped dynamic model selection (from `session.started`). */
60
+ export declare const SessionDynamicModelReferenceKey: ContextKey<Readonly<import("../shared/agent-definition.ts").InternalAgentModelDefinition> | null>;
61
+ /** Turn-scoped dynamic model selection (from `turn.started`). */
62
+ export declare const TurnDynamicModelReferenceKey: ContextKey<Readonly<import("../shared/agent-definition.ts").InternalAgentModelDefinition> | null>;
63
+ export interface LiveDynamicModelSelection {
64
+ /** Live provider instance; absent for string selections, which resolve through the reference. */
65
+ readonly model?: LanguageModel;
66
+ readonly reference: RuntimeModelReference;
67
+ }
68
+ /** Virtual step-scoped dynamic model selection (from `step.started`); never serialized. */
69
+ export declare const LiveStepDynamicModelSelectionKey: ContextKey<LiveDynamicModelSelection | null>;
58
70
  export interface DurableDynamicToolMetadata {
59
71
  readonly name: string;
60
72
  readonly description: string;
@@ -1 +1 @@
1
- import{ContextKey}from"#context/key.js";const AuthKey=new ContextKey(`eve.auth`),InitiatorAuthKey=new ContextKey(`eve.initiatorAuth`),SessionIdKey=new ContextKey(`eve.sessionId`),ContinuationTokenKey=new ContextKey(`eve.continuationToken`),ChannelRequestIdKey=new ContextKey(`eve.channelRequestId`),ChannelInstrumentationKey=new ContextKey(`eve.channelInstrumentation`),ModeKey=new ContextKey(`eve.mode`),ParentSessionKey=new ContextKey(`eve.parentSession`),SubagentDepthKey=new ContextKey(`eve.subagentDepth`),CapabilitiesKey=new ContextKey(`eve.capabilities`),SessionCallbackKey=new ContextKey(`eve.sessionCallback`),SessionKey=new ContextKey(`eve.session`),SandboxKey=new ContextKey(`eve.sandbox`),SessionDynamicToolMetadataKey=new ContextKey(`eve.sessionDynamicToolMetadata`),TurnDynamicToolMetadataKey=new ContextKey(`eve.turnDynamicToolMetadata`),LiveStepToolsKey=new ContextKey(`eve.liveStepTools`),DynamicSkillManifestKey=new ContextKey(`eve.dynamicSkillManifest`),SessionDynamicInstructionsKey=new ContextKey(`eve.sessionDynamicInstructions`),TurnDynamicInstructionsKey=new ContextKey(`eve.turnDynamicInstructions`);export{AuthKey,CapabilitiesKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationTokenKey,DynamicSkillManifestKey,InitiatorAuthKey,LiveStepToolsKey,ModeKey,ParentSessionKey,SandboxKey,SessionCallbackKey,SessionDynamicInstructionsKey,SessionDynamicToolMetadataKey,SessionIdKey,SessionKey,SubagentDepthKey,TurnDynamicInstructionsKey,TurnDynamicToolMetadataKey};
1
+ import{ContextKey}from"#context/key.js";const AuthKey=new ContextKey(`eve.auth`),InitiatorAuthKey=new ContextKey(`eve.initiatorAuth`),SessionIdKey=new ContextKey(`eve.sessionId`),ContinuationTokenKey=new ContextKey(`eve.continuationToken`),ChannelRequestIdKey=new ContextKey(`eve.channelRequestId`),ChannelInstrumentationKey=new ContextKey(`eve.channelInstrumentation`),ModeKey=new ContextKey(`eve.mode`),ParentSessionKey=new ContextKey(`eve.parentSession`),SubagentDepthKey=new ContextKey(`eve.subagentDepth`),CapabilitiesKey=new ContextKey(`eve.capabilities`),SessionCallbackKey=new ContextKey(`eve.sessionCallback`),SessionKey=new ContextKey(`eve.session`),SandboxKey=new ContextKey(`eve.sandbox`),SessionDynamicModelReferenceKey=new ContextKey(`eve.sessionDynamicModelReference`),TurnDynamicModelReferenceKey=new ContextKey(`eve.turnDynamicModelReference`),LiveStepDynamicModelSelectionKey=new ContextKey(`eve.liveStepDynamicModelSelection`),SessionDynamicToolMetadataKey=new ContextKey(`eve.sessionDynamicToolMetadata`),TurnDynamicToolMetadataKey=new ContextKey(`eve.turnDynamicToolMetadata`),LiveStepToolsKey=new ContextKey(`eve.liveStepTools`),DynamicSkillManifestKey=new ContextKey(`eve.dynamicSkillManifest`),SessionDynamicInstructionsKey=new ContextKey(`eve.sessionDynamicInstructions`),TurnDynamicInstructionsKey=new ContextKey(`eve.turnDynamicInstructions`);export{AuthKey,CapabilitiesKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationTokenKey,DynamicSkillManifestKey,InitiatorAuthKey,LiveStepDynamicModelSelectionKey,LiveStepToolsKey,ModeKey,ParentSessionKey,SandboxKey,SessionCallbackKey,SessionDynamicInstructionsKey,SessionDynamicModelReferenceKey,SessionDynamicToolMetadataKey,SessionIdKey,SessionKey,SubagentDepthKey,TurnDynamicInstructionsKey,TurnDynamicModelReferenceKey,TurnDynamicToolMetadataKey};
@@ -30,6 +30,10 @@ export interface ConnectionSourceRef extends ModuleSourceRef {
30
30
  */
31
31
  readonly connectionName: string;
32
32
  }
33
+ /**
34
+ * Hook source reference preserved by the discovery manifest.
35
+ */
36
+ export type HookSourceRef = ModuleSourceRef;
33
37
  /**
34
38
  * Instructions source reference preserved by discovery for compiler
35
39
  * normalization.
@@ -39,6 +43,10 @@ export type InstructionsSourceRef = MarkdownSourceRef<InstructionsDefinition> |
39
43
  * Skill source reference preserved by the discovery manifest.
40
44
  */
41
45
  export type SkillSourceRef = MarkdownSourceRef<SkillDefinition> | ModuleSourceRef | (NamedSkillDefinition & SkillPackageSourceRef);
46
+ /**
47
+ * Tool source reference preserved by the discovery manifest.
48
+ */
49
+ export type ToolSourceRef = ModuleSourceRef;
42
50
  /**
43
51
  * Recursive manifest entry for a local subagent package.
44
52
  */
@@ -1,4 +1,4 @@
1
- import{basename,join}from"node:path";import{readFile}from"node:fs/promises";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{createDevelopmentServer}from"#internal/nitro/host.js";import{createEvalClient}from"#evals/cli/eval-client.js";import{discoverAndImportEvals,discoverEvalConfig,findMisplacedEvalDirs}from"#evals/runner/discover.js";import{runEvals}from"#evals/runner/run-evals.js";import{ConsoleReporter}from"#evals/runner/reporters/console.js";import{JUnit}from"#evals/runner/reporters/junit.js";import{resolveEvalTargetHandle}from"#evals/target.js";async function runEvalCommand(e,t,n){let o=resolveApplicationRoot();loadDevelopmentEnvironmentFiles(o);let s=e.length>0?e:void 0,c=await discoverAndImportEvals(o,s);if(c.length===0){let e=await findMisplacedEvalDirs(o);e.length>0?n.error(`No evals found under evals/, but eval files are present inside agent/:
1
+ import{basename,join}from"node:path";import{readFile}from"node:fs/promises";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{shutdownActiveSandboxHandles}from"#execution/sandbox/active-handles.js";import{createDevelopmentServer}from"#internal/nitro/host.js";import{createEvalClient}from"#evals/cli/eval-client.js";import{discoverAndImportEvals,discoverEvalConfig,findMisplacedEvalDirs}from"#evals/runner/discover.js";import{runEvals}from"#evals/runner/run-evals.js";import{Console}from"#evals/runner/reporters/console.js";import{JUnit}from"#evals/runner/reporters/junit.js";import{resolveEvalTargetHandle}from"#evals/target.js";async function runEvalCommand(e,t,n){let o=resolveApplicationRoot();loadDevelopmentEnvironmentFiles(o);let s=e.length>0?e:void 0,c=await discoverAndImportEvals(o,s);if(c.length===0){let e=await findMisplacedEvalDirs(o);e.length>0?n.error(`No evals found under evals/, but eval files are present inside agent/:
2
2
  `+e.map(e=>` - ${e}`).join(`
3
3
  `)+`
4
- eve eval only scans the top-level evals/ directory (a sibling of agent/). Move these files there.`):s?n.error(`No evals found matching: ${s.join(`, `)}`):n.error(`No evals found. Create files under evals/ with the *.eval.ts extension.`),process.exitCode=2;return}let l=filterEvalsByTag(c,t.tag??[]);if(l.length===0){n.error(`No evals matched the provided tags (${(t.tag??[]).join(`, `)}).`),process.exitCode=2;return}let u,d;try{u=parsePositiveInteger(t.maxConcurrency,`--max-concurrency`),d=parseNonNegativeInteger(t.timeout,`--timeout`)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}if(t.list===!0){printEvalList(l,t.json===!0,n);return}let f;try{f=await discoverEvalConfig(o)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}let p,m,h;try{if(t.url)h=await createEvalClient({kind:`remote`,url:t.url},{workspaceRoot:o}),m=await resolveEvalTargetHandle({client:h,expectedAgentName:await readExpectedAgentName(o),kind:`remote`,url:t.url});else{p=createDevelopmentServer(o,{host:`127.0.0.1`,port:0});let e=await p.start();h=await createEvalClient({kind:`local`,url:e.url}),m=await resolveEvalTargetHandle({client:h,expectedAgentName:await readExpectedAgentName(o),kind:`local`,url:e.url})}let e=t.json===!0?[]:[new ConsoleReporter];t.junit!==void 0&&e.push(JUnit({filePath:t.junit}));let r=await runEvals({evaluations:l,config:f,target:m,client:h,appRoot:o,reporters:e,includeEvalReporters:t.skipReport!==!0,maxConcurrency:u,timeoutMs:d,onEvalLog:t.verbose===!0?(e,t)=>n.log(`[${e}] ${t}`):void 0});t.json&&n.log(JSON.stringify(r,null,2));let i=r.failed>0,a=t.strict===!0&&r.scored>0;(i||a)&&(process.exitCode=1)}finally{p&&await p.close()}let g=typeof process.exitCode==`number`?process.exitCode:0;process.exit(g)}function parsePositiveInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<1)throw Error(`${t} must be a positive integer; got "${e}".`);return n}function parseNonNegativeInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw Error(`${t} must be a non-negative integer; got "${e}".`);return n}function filterEvalsByTag(e,t){return t.length===0?[...e]:e.filter(e=>e.tags?.some(e=>t.includes(e))??!1)}function printEvalList(e,t,n){if(t){let t=e.map(e=>({id:e.id,description:e.description,tags:e.tags}));n.log(JSON.stringify(t,null,2));return}for(let t of e){let e=t.description===void 0?``:` — ${t.description}`,r=t.tags!==void 0&&t.tags.length>0?` [${t.tags.join(`, `)}]`:``;n.log(`${t.id}${r}${e}`)}}async function readExpectedAgentName(r){try{let i=JSON.parse(await readFile(join(r,`package.json`),`utf8`));return typeof i.name==`string`&&i.name.length>0?i.name:basename(r)}catch{return basename(r)}}export{runEvalCommand};
4
+ eve eval only scans the top-level evals/ directory (a sibling of agent/). Move these files there.`):s?n.error(`No evals found matching: ${s.join(`, `)}`):n.error(`No evals found. Create files under evals/ with the *.eval.ts extension.`),process.exitCode=2;return}let l=filterEvalsByTag(c,t.tag??[]);if(l.length===0){n.error(`No evals matched the provided tags (${(t.tag??[]).join(`, `)}).`),process.exitCode=2;return}let u,d;try{u=parsePositiveInteger(t.maxConcurrency,`--max-concurrency`),d=parseNonNegativeInteger(t.timeout,`--timeout`)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}if(t.list===!0){printEvalList(l,t.json===!0,n);return}let f;try{f=await discoverEvalConfig(o)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}let p,m,h;try{if(t.url)h=await createEvalClient({kind:`remote`,url:t.url},{workspaceRoot:o}),m=await resolveEvalTargetHandle({client:h,expectedAgentName:await readExpectedAgentName(o),kind:`remote`,url:t.url});else{p=createDevelopmentServer(o,{host:`127.0.0.1`,port:0});let e=await p.start();h=await createEvalClient({kind:`local`,url:e.url}),m=await resolveEvalTargetHandle({client:h,expectedAgentName:await readExpectedAgentName(o),kind:`local`,url:e.url})}let e=t.json===!0?[]:[Console()];t.junit!==void 0&&e.push(JUnit({filePath:t.junit}));let r=await runEvals({evaluations:l,config:f,target:m,client:h,appRoot:o,reporters:e,includeEvalReporters:t.skipReport!==!0,maxConcurrency:u,timeoutMs:d,onEvalLog:t.verbose===!0?(e,t)=>n.log(`[${e}] ${t}`):void 0});t.json&&n.log(JSON.stringify(r,null,2));let i=r.failed>0,a=t.strict===!0&&r.scored>0;(i||a)&&(process.exitCode=1)}finally{p&&(await p.close(),await shutdownActiveSandboxHandles({log:e=>n.error(e)}))}let g=typeof process.exitCode==`number`?process.exitCode:0;process.exit(g)}function parsePositiveInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<1)throw Error(`${t} must be a positive integer; got "${e}".`);return n}function parseNonNegativeInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw Error(`${t} must be a non-negative integer; got "${e}".`);return n}function filterEvalsByTag(e,t){return t.length===0?[...e]:e.filter(e=>e.tags?.some(e=>t.includes(e))??!1)}function printEvalList(e,t,n){if(t){let t=e.map(e=>({id:e.id,description:e.description,tags:e.tags}));n.log(JSON.stringify(t,null,2));return}for(let t of e){let e=t.description===void 0?``:` — ${t.description}`,r=t.tags!==void 0&&t.tags.length>0?` [${t.tags.join(`, `)}]`:``;n.log(`${t.id}${r}${e}`)}}async function readExpectedAgentName(r){try{let i=JSON.parse(await readFile(join(r,`package.json`),`utf8`));return typeof i.name==`string`&&i.name.length>0?i.name:basename(r)}catch{return basename(r)}}export{runEvalCommand};
@@ -1,3 +1,4 @@
1
1
  export { Braintrust, type BraintrustReporterConfig } from "#evals/runner/reporters/braintrust.js";
2
+ export { Console, type ConsoleReporterConfig } from "#evals/runner/reporters/console.js";
2
3
  export { JUnit, type JUnitReporterConfig } from "#evals/runner/reporters/junit.js";
3
4
  export type { EvalReporter } from "#evals/runner/reporters/types.js";
@@ -1 +1 @@
1
- import{JUnit}from"#evals/runner/reporters/junit.js";import{Braintrust}from"#evals/runner/reporters/braintrust.js";export{Braintrust,JUnit};
1
+ import{Console}from"#evals/runner/reporters/console.js";import{JUnit}from"#evals/runner/reporters/junit.js";import{Braintrust}from"#evals/runner/reporters/braintrust.js";export{Braintrust,Console,JUnit};
@@ -1,15 +1,14 @@
1
- import type { EveEval, EveEvalResult, EveEvalRunSummary, EveEvalTarget } from "#evals/types.js";
2
1
  import type { EvalReporter } from "#evals/runner/reporters/types.js";
3
2
  /**
4
- * Console reporter that prints eval progress and results to stdout.
3
+ * Configuration for the console reporter. Every field is optional.
5
4
  */
6
- export declare class ConsoleReporter implements EvalReporter {
7
- #private;
8
- constructor(options?: {
9
- log?: (message: string) => void;
10
- color?: boolean;
11
- });
12
- onRunStart(evaluations: readonly EveEval[], target: EveEvalTarget): void;
13
- onEvalComplete(result: EveEvalResult): void;
14
- onRunComplete(summary: EveEvalRunSummary): void;
5
+ export interface ConsoleReporterConfig {
6
+ /** Function to print console log messages. */
7
+ log?: (message: string) => void;
8
+ /** Whether to log with colored output. */
9
+ color?: boolean;
15
10
  }
11
+ /**
12
+ * Creates a {@link ConsoleReporter}.
13
+ */
14
+ export declare function Console(config?: ConsoleReporterConfig): EvalReporter;
@@ -1 +1 @@
1
- import picocolors from"#compiled/picocolors/index.js";var ConsoleReporter=class{#e;#t;constructor(t){this.#e=t?.log??console.log,this.#t=picocolors.createColors(t?.color??!!process.stdout.isTTY)}onRunStart(e,t){this.#e(``),this.#e(`${this.#t.bold(this.#t.cyan(`EVALS`))} ${this.#t.bold(String(e.length))}`),this.#e(`${this.#t.dim(`target`)} ${t.kind===`local`?this.#t.green(t.url):this.#t.blue(t.url)}`),this.#e(``)}onEvalComplete(e){let{assertions:t,verdict:n,error:r,skipReason:i}=e,a=t.filter(e=>e.severity===`gate`),o=t.filter(e=>e.severity===`soft`),s=this.#n(n),c=a.length>0?this.#r(a.filter(e=>e.passed).length,a.length):``,l=o.map(e=>this.#i(e.name,e.score)).join(` `),u=[s,this.#t.dim(e.id),c,l].filter(Boolean).join(` `);this.#e(u);for(let e of t){if(e.passed)continue;let t=e.message===void 0?``:`: ${e.message}`;this.#e(` ${this.#t.red(`✗ ${e.name}${t}`)}`)}r&&this.#e(` ${this.#t.red(r)}`),i&&this.#e(` ${this.#t.dim(i)}`)}onRunComplete(e){this.#e(``);let{passed:t,failed:n,scored:r,skipped:i,results:a}=e,o=a.length,s=[];t>0&&s.push(this.#t.green(`${t} passed`)),n>0&&s.push(this.#t.red(`${n} failed`)),r>0&&s.push(this.#t.yellow(`${r} scored`)),i>0&&s.push(this.#t.dim(`${i} skipped`)),s.length===0&&s.push(this.#t.dim(`0 evals`)),this.#e(`${this.#t.bold(`Results:`)} ${s.join(`, `)} ${this.#t.dim(`(${o} total)`)}`);let c=this.#a(a);if(c.total>0){let e=this.#t.green(`${c.passed} passed`),t=c.failed>0?`, ${this.#t.red(`${c.failed} failed`)}`:``;this.#e(`${this.#t.bold(`Gates:`)} ${e}${t}`)}let l=this.#o(a);if(l.length>0){this.#e(``);for(let{name:e,avg:t,count:n}of l){let r=this.#i(e,t);this.#e(` ${r} ${this.#t.dim(`(${n} evals)`)}`)}}let u=computeDurationMs(e.startedAt,e.completedAt);this.#e(``),this.#e(this.#t.dim(`Completed in ${formatDuration(u)}`)),this.#e(``)}#n(e){switch(e){case`passed`:return this.#t.green(`✓`);case`failed`:return this.#t.red(`✗`);case`scored`:return this.#t.yellow(`○`);case`skipped`:return this.#t.dim(`–`)}}#r(e,t){let n=`gates ${e}/${t}`;return e===t?this.#t.green(n):this.#t.red(n)}#i(e,t){let n=`${e}: ${Math.round(t*100)}%`;return t===1?this.#t.green(n):t===0?this.#t.red(n):this.#t.yellow(n)}#a(e){let t=0,n=0;for(let r of e)for(let e of gatesOf(r))e.passed?t+=1:n+=1;return{passed:t,failed:n,total:t+n}}#o(e){let t=new Map;for(let n of e)for(let e of n.assertions){if(e.severity!==`soft`)continue;let n=t.get(e.name);n?(n.sum+=e.score,n.count+=1):t.set(e.name,{sum:e.score,count:1})}return[...t.entries()].map(([e,{sum:t,count:n}])=>({name:e,avg:t/n,count:n}))}};function gatesOf(e){return e.assertions.filter(e=>e.severity===`gate`)}function computeDurationMs(e,t){return new Date(t).getTime()-new Date(e).getTime()}function formatDuration(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${(e%6e4/1e3).toFixed(0)}s`}export{ConsoleReporter};
1
+ import picocolors from"#compiled/picocolors/index.js";function Console(e={}){return new ConsoleReporter(e)}var ConsoleReporter=class{#e;#t;constructor(t){this.#e=t?.log??console.log,this.#t=picocolors.createColors(t?.color??!!process.stdout.isTTY)}onRunStart(e,t){this.#e(``),this.#e(`${this.#t.bold(this.#t.cyan(`EVALS`))} ${this.#t.bold(String(e.length))}`),this.#e(`${this.#t.dim(`target`)} ${t.kind===`local`?this.#t.green(t.url):this.#t.blue(t.url)}`),this.#e(``)}onEvalComplete(e){let{assertions:t,verdict:n,error:r,skipReason:i}=e,a=t.filter(e=>e.severity===`gate`),o=t.filter(e=>e.severity===`soft`),s=this.#n(n),c=a.length>0?this.#r(a.filter(e=>e.passed).length,a.length):``,l=o.map(e=>this.#i(e.name,e.score)).join(` `),u=[s,this.#t.dim(e.id),c,l].filter(Boolean).join(` `);this.#e(u);for(let e of t){if(e.passed)continue;let t=e.message===void 0?``:`: ${e.message}`;this.#e(` ${this.#t.red(`✗ ${e.name}${t}`)}`)}r&&this.#e(` ${this.#t.red(r)}`),i&&this.#e(` ${this.#t.dim(i)}`)}onRunComplete(e){this.#e(``);let{passed:t,failed:n,scored:r,skipped:i,results:a}=e,o=a.length,s=[];t>0&&s.push(this.#t.green(`${t} passed`)),n>0&&s.push(this.#t.red(`${n} failed`)),r>0&&s.push(this.#t.yellow(`${r} scored`)),i>0&&s.push(this.#t.dim(`${i} skipped`)),s.length===0&&s.push(this.#t.dim(`0 evals`)),this.#e(`${this.#t.bold(`Results:`)} ${s.join(`, `)} ${this.#t.dim(`(${o} total)`)}`);let c=this.#a(a);if(c.total>0){let e=this.#t.green(`${c.passed} passed`),t=c.failed>0?`, ${this.#t.red(`${c.failed} failed`)}`:``;this.#e(`${this.#t.bold(`Gates:`)} ${e}${t}`)}let l=this.#o(a);if(l.length>0){this.#e(``);for(let{name:e,avg:t,count:n}of l){let r=this.#i(e,t);this.#e(` ${r} ${this.#t.dim(`(${n} evals)`)}`)}}let u=computeDurationMs(e.startedAt,e.completedAt);this.#e(``),this.#e(this.#t.dim(`Completed in ${formatDuration(u)}`)),this.#e(``)}#n(e){switch(e){case`passed`:return this.#t.green(`✓`);case`failed`:return this.#t.red(`✗`);case`scored`:return this.#t.yellow(`○`);case`skipped`:return this.#t.dim(`–`)}}#r(e,t){let n=`gates ${e}/${t}`;return e===t?this.#t.green(n):this.#t.red(n)}#i(e,t){let n=`${e}: ${Math.round(t*100)}%`;return t===1?this.#t.green(n):t===0?this.#t.red(n):this.#t.yellow(n)}#a(e){let t=0,n=0;for(let r of e)for(let e of gatesOf(r))e.passed?t+=1:n+=1;return{passed:t,failed:n,total:t+n}}#o(e){let t=new Map;for(let n of e)for(let e of n.assertions){if(e.severity!==`soft`)continue;let n=t.get(e.name);n?(n.sum+=e.score,n.count+=1):t.set(e.name,{sum:e.score,count:1})}return[...t.entries()].map(([e,{sum:t,count:n}])=>({name:e,avg:t/n,count:n}))}};function gatesOf(e){return e.assertions.filter(e=>e.severity===`gate`)}function computeDurationMs(e,t){return new Date(t).getTime()-new Date(e).getTime()}function formatDuration(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${(e%6e4/1e3).toFixed(0)}s`}export{Console};
@@ -1 +1 @@
1
- import{createLogger}from"#internal/logging.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{jsonSchema}from"ai";import{createToolLoopHarness}from"#harness/tool-loop.js";import{resolveRuntimeModelReference}from"#runtime/agent/resolve-model.js";import{findRegisteredRuntimeTool}from"#runtime/tools/registry.js";import{SUBAGENT_TOOL_INPUT_SCHEMA}from"#runtime/subagents/registry.js";import{preserveFrameworkStateOnCompaction}from"#execution/compaction.js";import{createToolExecuteWithAuth}from"#execution/tool-auth.js";const log=createLogger(`execution.node-step`),BUILT_IN_AGENT_TOOL_DESCRIPTION=[`Delegate a focused subtask to a fresh copy of yourself.`,`Use it to isolate complex work or split a large task into independent pieces.`,"Issue multiple `agent` calls in one response to run a small fixed set in parallel.","Each child has fresh history and state but shares your tools and sandbox, so include essential context in `message` and give parallel writers non-overlapping scopes."].join(` `);function createExecutionNodeStep(e){let t=createRuntimeModelResolver(e.modelResolutionScope),n=createNodeHarnessTools({node:e.node});return createToolLoopHarness({abortSignal:e.abortSignal,capabilities:e.capabilities,workflow:e.node.agent.workflowEnabled===!0,workflowMaxSubagents:e.workflowMaxSubagents,handleEvent:e.handleEvent,mode:e.mode,onCompaction:preserveFrameworkStateOnCompaction,resolveModel:t,runtimeIdentity:buildRuntimeIdentity(e.node),tools:n})}function buildRuntimeIdentity(e){let n=resolveInstalledPackageInfo(),r={agentId:e.turnAgent.id,agentName:e.agent.config?.name,eveVersion:n.version,modelId:e.turnAgent.model.id},i=process.env.VERCEL_GIT_COMMIT_SHA?.trim(),a=process.env.VERCEL_GIT_COMMIT_REF?.trim(),o=process.env.VERCEL_DEPLOYMENT_CREATED_AT?.trim();return i||a||o?{...r,build:{deployedAt:o||void 0,gitBranch:a||void 0,gitSha:i||void 0}}:r}function createRuntimeModelResolver(e){return t=>resolveRuntimeModelReference(t,e)}function createNodeHarnessTools(e){let t=new Map;for(let n of e.node.turnAgent.tools){let r=resolveHarnessToolDefinition({node:e.node,tool:n});r!==null&&t.set(n.name,r)}return t.has(`agent`)||t.set(`agent`,{description:BUILT_IN_AGENT_TOOL_DESCRIPTION,inputSchema:jsonSchema(SUBAGENT_TOOL_INPUT_SCHEMA),name:`agent`,runtimeAction:{kind:`subagent-call`,nodeId:e.node.nodeId,subagentName:`agent`}}),t}function resolveHarnessToolDefinition(e){if(e.tool.kind===`subagent`)return{description:e.tool.description??``,inputSchema:jsonSchema(e.tool.inputSchema??{}),name:e.tool.name,outputSchema:e.tool.outputSchema===void 0?void 0:jsonSchema(e.tool.outputSchema),runtimeAction:{kind:`subagent-call`,nodeId:e.tool.nodeId,subagentName:e.tool.name}};if(e.tool.kind===`remote`)return{description:e.tool.description??``,inputSchema:jsonSchema(e.tool.inputSchema??{}),name:e.tool.name,outputSchema:e.tool.outputSchema===void 0?void 0:jsonSchema(e.tool.outputSchema),runtimeAction:{kind:`remote-agent-call`,nodeId:e.tool.nodeId,remoteAgentName:e.tool.name,subagentName:e.tool.name}};let t=findRegisteredRuntimeTool(e.node.toolRegistry,e.tool.name);if(t===null)return log.warn(`declared tool is not registered — omitting from toolset`,{toolName:e.tool.name,nodeId:e.node.nodeId}),null;let r=t.definition,i=r.sourceId.startsWith(`eve:`),o=r.execute;return{approvalKey:r.approvalKey,description:r.description,execute:resolveAuthoredExecute({isFrameworkTool:i,rawExecute:o,scope:r.name}),inputSchema:r.inputStandardSchema??jsonSchema(r.inputSchema??{}),name:r.name,approval:r.approval,outputSchema:r.outputStandardSchema??maybeJsonSchema(r.outputSchema),toModelOutput:r.toModelOutput}}function resolveAuthoredExecute(e){let{isFrameworkTool:t,rawExecute:n,scope:r}=e;return n===void 0?void 0:t?n:createToolExecuteWithAuth({execute:n,scope:r})}function maybeJsonSchema(e){return e===void 0?void 0:jsonSchema(e)}export{createExecutionNodeStep,createNodeHarnessTools};
1
+ import{createLogger}from"#internal/logging.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{jsonSchema}from"ai";import{resolveRuntimeModelReference}from"#runtime/agent/resolve-model.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{createToolLoopHarness}from"#harness/tool-loop.js";import{findRegisteredRuntimeTool}from"#runtime/tools/registry.js";import{SUBAGENT_TOOL_INPUT_SCHEMA}from"#runtime/subagents/registry.js";import{preserveFrameworkStateOnCompaction}from"#execution/compaction.js";import{createToolExecuteWithAuth}from"#execution/tool-auth.js";const log=createLogger(`execution.node-step`),BUILT_IN_AGENT_TOOL_DESCRIPTION=[`Delegate a focused subtask to a fresh copy of yourself.`,`Use it to isolate complex work or split a large task into independent pieces.`,"Issue multiple `agent` calls in one response to run a small fixed set in parallel.","Each child has fresh history and state but shares your tools and sandbox, so include essential context in `message` and give parallel writers non-overlapping scopes."].join(` `);function createExecutionNodeStep(e){let t=createRuntimeModelResolver(e.modelResolutionScope),n=e.node.turnAgent.dynamicModel===void 0?void 0:createRuntimeDynamicModelEventDispatcher(e.modelResolutionScope,e.node.turnAgent.dynamicModel),r=createNodeHarnessTools({node:e.node});return createToolLoopHarness({abortSignal:e.abortSignal,capabilities:e.capabilities,workflow:e.node.agent.workflowEnabled===!0,workflowMaxSubagents:e.workflowMaxSubagents,handleEvent:e.handleEvent,mode:e.mode,onCompaction:preserveFrameworkStateOnCompaction,dispatchDynamicModelEvent:n,resolveModel:t,runtimeIdentity:buildRuntimeIdentity(e.node),tools:r})}function buildRuntimeIdentity(e){let n=resolveInstalledPackageInfo(),r={agentId:e.turnAgent.id,agentName:e.agent.config?.name,eveVersion:n.version,modelId:e.turnAgent.dynamicModel===void 0?e.turnAgent.model.id:`dynamic:${e.turnAgent.model.id}`},i=process.env.VERCEL_GIT_COMMIT_SHA?.trim(),a=process.env.VERCEL_GIT_COMMIT_REF?.trim(),o=process.env.VERCEL_DEPLOYMENT_CREATED_AT?.trim();return i||a||o?{...r,build:{deployedAt:o||void 0,gitBranch:a||void 0,gitSha:i||void 0}}:r}function createRuntimeModelResolver(e){return t=>resolveRuntimeModelReference(t,e)}function createRuntimeDynamicModelEventDispatcher(e,t){return n=>dispatchDynamicModelEvent({ctx:n.ctx,dynamicModel:t,event:n.event,fallback:n.fallback,messages:n.messages,scope:e})}function createNodeHarnessTools(e){let t=new Map;for(let n of e.node.turnAgent.tools){let r=resolveHarnessToolDefinition({node:e.node,tool:n});r!==null&&t.set(n.name,r)}return t.has(`agent`)||t.set(`agent`,{description:BUILT_IN_AGENT_TOOL_DESCRIPTION,inputSchema:jsonSchema(SUBAGENT_TOOL_INPUT_SCHEMA),name:`agent`,runtimeAction:{kind:`subagent-call`,nodeId:e.node.nodeId,subagentName:`agent`}}),t}function resolveHarnessToolDefinition(e){if(e.tool.kind===`subagent`)return{description:e.tool.description??``,inputSchema:jsonSchema(e.tool.inputSchema??{}),name:e.tool.name,outputSchema:e.tool.outputSchema===void 0?void 0:jsonSchema(e.tool.outputSchema),runtimeAction:{kind:`subagent-call`,nodeId:e.tool.nodeId,subagentName:e.tool.name}};if(e.tool.kind===`remote`)return{description:e.tool.description??``,inputSchema:jsonSchema(e.tool.inputSchema??{}),name:e.tool.name,outputSchema:e.tool.outputSchema===void 0?void 0:jsonSchema(e.tool.outputSchema),runtimeAction:{kind:`remote-agent-call`,nodeId:e.tool.nodeId,remoteAgentName:e.tool.name,subagentName:e.tool.name}};let t=findRegisteredRuntimeTool(e.node.toolRegistry,e.tool.name);if(t===null)return log.warn(`declared tool is not registered — omitting from toolset`,{toolName:e.tool.name,nodeId:e.node.nodeId}),null;let r=t.definition,i=r.sourceId.startsWith(`eve:`),a=r.execute;return{approvalKey:r.approvalKey,description:r.description,execute:resolveAuthoredExecute({isFrameworkTool:i,rawExecute:a,scope:r.name}),inputSchema:r.inputStandardSchema??jsonSchema(r.inputSchema??{}),name:r.name,approval:r.approval,outputSchema:r.outputStandardSchema??maybeJsonSchema(r.outputSchema),toModelOutput:r.toModelOutput}}function resolveAuthoredExecute(e){let{isFrameworkTool:t,rawExecute:n,scope:r}=e;return n===void 0?void 0:t?n:createToolExecuteWithAuth({execute:n,scope:r})}function maybeJsonSchema(e){return e===void 0?void 0:jsonSchema(e)}export{createExecutionNodeStep,createNodeHarnessTools};
@@ -1,4 +1,4 @@
1
- import type { MicrosandboxCreateOptions } from "#public/sandbox/microsandbox-sandbox.js";
1
+ import type { MicrosandboxSandboxCreateOptions } from "#public/sandbox/microsandbox-sandbox.js";
2
2
  import type { SandboxNetworkPolicy } from "#shared/sandbox-network-policy.js";
3
3
  export declare const MICROSANDBOX_DEFAULT_IMAGE = "ghcr.io/vercel/eve:latest";
4
4
  export declare const MICROSANDBOX_DEFAULT_CPUS = 1;
@@ -25,7 +25,7 @@ export interface ResolvedMicrosandboxOptions {
25
25
  /**
26
26
  * Applies defaults to `microsandbox(opts)`.
27
27
  */
28
- export declare function resolveMicrosandboxOptions(options: MicrosandboxCreateOptions | undefined): ResolvedMicrosandboxOptions;
28
+ export declare function resolveMicrosandboxOptions(options: MicrosandboxSandboxCreateOptions | undefined): ResolvedMicrosandboxOptions;
29
29
  /**
30
30
  * The subset of options that participates in template/session
31
31
  * compatibility hashing. Setup behavior intentionally stays out: how
@@ -1,5 +1,5 @@
1
1
  import type { SandboxBackend } from "#public/definitions/sandbox-backend.js";
2
- import type { MicrosandboxBootstrapUseOptions, MicrosandboxCreateOptions, MicrosandboxSessionUseOptions } from "#public/sandbox/microsandbox-sandbox.js";
2
+ import type { MicrosandboxBootstrapUseOptions, MicrosandboxSandboxCreateOptions, MicrosandboxSessionUseOptions } from "#public/sandbox/microsandbox-sandbox.js";
3
3
  export { pruneMicrosandboxTemplates } from "#execution/sandbox/bindings/microsandbox-templates.js";
4
4
  /**
5
5
  * Stable backend name. Participates in template/session key derivation
@@ -12,7 +12,7 @@ export declare const MICROSANDBOX_BACKEND_NAME = "microsandbox";
12
12
  * under `eve/sandbox`.
13
13
  */
14
14
  export interface CreateMicrosandboxSandboxBackendInput {
15
- readonly createOptions?: MicrosandboxCreateOptions;
15
+ readonly createOptions?: MicrosandboxSandboxCreateOptions;
16
16
  }
17
17
  /**
18
18
  * Creates the microsandbox sandbox backend: lightweight local VMs with
@@ -1 +1 @@
1
- import{waitForDevelopmentSandboxPrewarm}from"#execution/sandbox/development-prewarm.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{isEveDevEnvironment}from"#internal/application/optional-package-install.js";import{markDevelopmentSandboxBackendInitialized}from"#execution/sandbox/development-run.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";import{createRuntimeSandboxKeys}from"#runtime/sandbox/keys.js";import{createRuntimeSandboxTemplatePlan}from"#runtime/sandbox/template-plan.js";import{trackActiveSandboxHandle}from"#execution/sandbox/active-handles.js";import{prewarmAppSandboxes}from"#execution/sandbox/prewarm.js";import{waitForSandboxTemplatePrewarmLock}from"#execution/sandbox/template-prewarm-lock.js";async function ensureSandboxAccess(n){let i=n.state?.initialized??!1,o=n.state?.session??null,s=getRuntimeCompiledArtifactsSandboxAppRoot(n.compiledArtifactsSource)??process.cwd(),c=n.registry.sandbox,l;function getHandle(){return l===void 0&&(l=createHandle().catch(e=>{throw l=void 0,e})),l}async function createHandle(){if(c===null)return null;let a=c.definition,l=a.backend,u=createRuntimeSandboxTemplatePlan({definition:a,workspaceResourceRoot:c.workspaceResourceRoot}),d=await createRuntimeSandboxKeys({backendName:l.name,compiledArtifactsSource:n.compiledArtifactsSource,nodeId:n.nodeId,sessionId:n.sessionId,sourceId:a.sourceId,templatePlan:u});d.templateKey!==null&&(await waitForDevelopmentSandboxPrewarm({appRoot:s,compiledArtifactsSource:n.compiledArtifactsSource,log:e=>logDevelopmentSandbox(`eve: sandbox template "${formatNodeLabel(n.nodeId)}" (${l.name}): ${e}`)}),await waitForSandboxTemplatePrewarmLock({appRoot:s,backendName:l.name,log:e=>logDevelopmentSandbox(`eve: sandbox template "${formatNodeLabel(n.nodeId)}" (${l.name}): ${e}`),templateKey:d.templateKey}));let f={existingMetadata:o?.backendName===l.name&&o.sessionKey===d.sessionKey?o.metadata:void 0,runtimeContext:{appRoot:s},sessionKey:d.sessionKey,tags:n.tags,templateKey:d.templateKey},p=await withDevelopmentSandboxProgress(`eve: opening sandbox session "${formatNodeLabel(n.nodeId)}" on backend "${l.name}"...`,`eve: opening sandbox session "${formatNodeLabel(n.nodeId)}" on backend "${l.name}"`,async()=>await createBackendHandleWithPrewarmRetry({appRoot:s,backend:l,compiledArtifactsSource:n.compiledArtifactsSource,createInput:f}));return markDevelopmentSandboxBackendInitialized(l.name),trackActiveSandboxHandle({backendName:l.name,handle:p,sessionKey:d.sessionKey}),i||=(await runOnSession(async()=>{await a.onSession?.({ctx:buildCallbackContext(),use:p.useSessionFn})}),!0),p}async function runOnSession(e){if(n.runOnSession!==void 0){await n.runOnSession(e);return}await e()}return{async captureState(){if(l!==void 0){let e=await l;e!==null&&(o=await e.captureState())}return{initialized:i,session:o}},async get(){return(await getHandle())?.session??null}}}async function createBackendHandleWithPrewarmRetry(e){try{return await e.backend.create(e.createInput)}catch(t){if(e.createInput.templateKey===null||e.compiledArtifactsSource.kind!==`disk`||!SandboxTemplateNotProvisionedError.is(t))throw t;return await prewarmAppSandboxes({appRoot:e.appRoot,compiledArtifactsSource:e.compiledArtifactsSource,log:e=>logDevelopmentSandbox(e)}),await waitForSandboxTemplatePrewarmLock({appRoot:e.appRoot,backendName:e.backend.name,log:e=>logDevelopmentSandbox(`eve: ${e}`),templateKey:e.createInput.templateKey}),logDevelopmentSandbox(`eve: sandbox template is ready; retrying sandbox creation...`),await e.backend.create(e.createInput)}}function logDevelopmentSandbox(e){isEveDevEnvironment()&&console.log(e)}async function withDevelopmentSandboxProgress(e,t,r){if(logDevelopmentSandbox(e),!isEveDevEnvironment())return await r();let i=Date.now(),a=setInterval(()=>{logDevelopmentSandbox(`${t} (${Math.round((Date.now()-i)/1e3)}s elapsed)...`)},5e3);a.unref?.();try{return await r()}finally{clearInterval(a)}}function formatNodeLabel(e){return e===`__root__`?`root`:e}export{ensureSandboxAccess};
1
+ import{waitForDevelopmentSandboxPrewarm}from"#execution/sandbox/development-prewarm.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{trackActiveSandboxHandle}from"#execution/sandbox/active-handles.js";import{isEveDevEnvironment}from"#internal/application/optional-package-install.js";import{markDevelopmentSandboxBackendInitialized}from"#execution/sandbox/development-run.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";import{createRuntimeSandboxKeys}from"#runtime/sandbox/keys.js";import{createRuntimeSandboxTemplatePlan}from"#runtime/sandbox/template-plan.js";import{prewarmAppSandboxes}from"#execution/sandbox/prewarm.js";import{waitForSandboxTemplatePrewarmLock}from"#execution/sandbox/template-prewarm-lock.js";async function ensureSandboxAccess(r){let a=r.state?.initialized??!1,s=r.state?.session??null,c=getRuntimeCompiledArtifactsSandboxAppRoot(r.compiledArtifactsSource)??process.cwd(),l=r.registry.sandbox,u;function getHandle(){return u===void 0&&(u=createHandle().catch(e=>{throw u=void 0,e})),u}async function createHandle(){if(l===null)return null;let o=l.definition,u=o.backend,d=createRuntimeSandboxTemplatePlan({definition:o,workspaceResourceRoot:l.workspaceResourceRoot}),f=await createRuntimeSandboxKeys({backendName:u.name,compiledArtifactsSource:r.compiledArtifactsSource,nodeId:r.nodeId,sessionId:r.sessionId,sourceId:o.sourceId,templatePlan:d});f.templateKey!==null&&(await waitForDevelopmentSandboxPrewarm({appRoot:c,compiledArtifactsSource:r.compiledArtifactsSource,log:e=>logDevelopmentSandbox(`eve: sandbox template "${formatNodeLabel(r.nodeId)}" (${u.name}): ${e}`)}),await waitForSandboxTemplatePrewarmLock({appRoot:c,backendName:u.name,log:e=>logDevelopmentSandbox(`eve: sandbox template "${formatNodeLabel(r.nodeId)}" (${u.name}): ${e}`),templateKey:f.templateKey}));let p={existingMetadata:s?.backendName===u.name&&s.sessionKey===f.sessionKey?s.metadata:void 0,runtimeContext:{appRoot:c},sessionKey:f.sessionKey,tags:r.tags,templateKey:f.templateKey},m=await withDevelopmentSandboxProgress(`eve: opening sandbox session "${formatNodeLabel(r.nodeId)}" on backend "${u.name}"...`,`eve: opening sandbox session "${formatNodeLabel(r.nodeId)}" on backend "${u.name}"`,async()=>await createBackendHandleWithPrewarmRetry({appRoot:c,backend:u,compiledArtifactsSource:r.compiledArtifactsSource,createInput:p}));return markDevelopmentSandboxBackendInitialized(u.name),trackActiveSandboxHandle({backendName:u.name,handle:m,sessionKey:f.sessionKey}),a||=(await runOnSession(async()=>{await o.onSession?.({ctx:buildCallbackContext(),use:m.useSessionFn})}),!0),m}async function runOnSession(e){if(r.runOnSession!==void 0){await r.runOnSession(e);return}await e()}return{async captureState(){if(u!==void 0){let e=await u;e!==null&&(s=await e.captureState())}return{initialized:a,session:s}},async get(){return(await getHandle())?.session??null}}}async function createBackendHandleWithPrewarmRetry(e){try{return await e.backend.create(e.createInput)}catch(t){if(e.createInput.templateKey===null||e.compiledArtifactsSource.kind!==`disk`||!SandboxTemplateNotProvisionedError.is(t))throw t;return await prewarmAppSandboxes({appRoot:e.appRoot,compiledArtifactsSource:e.compiledArtifactsSource,log:e=>logDevelopmentSandbox(e)}),await waitForSandboxTemplatePrewarmLock({appRoot:e.appRoot,backendName:e.backend.name,log:e=>logDevelopmentSandbox(`eve: ${e}`),templateKey:e.createInput.templateKey}),logDevelopmentSandbox(`eve: sandbox template is ready; retrying sandbox creation...`),await e.backend.create(e.createInput)}}function logDevelopmentSandbox(e){isEveDevEnvironment()&&console.log(e)}async function withDevelopmentSandboxProgress(e,t,n){if(logDevelopmentSandbox(e),!isEveDevEnvironment())return await n();let i=Date.now(),a=setInterval(()=>{logDevelopmentSandbox(`${t} (${Math.round((Date.now()-i)/1e3)}s elapsed)...`)},5e3);a.unref?.();try{return await n()}finally{clearInterval(a)}}function formatNodeLabel(e){return e===`__root__`?`root`:e}export{ensureSandboxAccess};