eve 0.66.0 → 0.66.2

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 (193) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/src/channel/forwarded-principal.d.ts +26 -6
  3. package/dist/src/channel/forwarded-principal.js +1 -1
  4. package/dist/src/chunks/{use-eve-agent-BUeSjwIk.js → use-eve-agent-Di1u2zKu.js} +24 -4
  5. package/dist/src/chunks/{use-eve-agent-ydPlURM4.js → use-eve-agent-PbSMyJ6e.js} +24 -4
  6. package/dist/src/cli/commands/deploy.d.ts +3 -1
  7. package/dist/src/cli/commands/deploy.js +1 -1
  8. package/dist/src/cli/commands/extension-build.js +1 -1
  9. package/dist/src/cli/commands/integration-connect.js +1 -1
  10. package/dist/src/cli/commands/register-project-commands.js +1 -1
  11. package/dist/src/cli/commands/registry-project.d.ts +2 -1
  12. package/dist/src/cli/commands/registry-project.js +2 -2
  13. package/dist/src/cli/commands/registry.js +1 -1
  14. package/dist/src/cli/commands/trace-detail.d.ts +5 -25
  15. package/dist/src/cli/commands/trace-detail.js +1 -1
  16. package/dist/src/cli/commands/trace.js +2 -2
  17. package/dist/src/cli/commands/vercel-non-interactive.d.ts +7 -0
  18. package/dist/src/cli/commands/vercel-non-interactive.js +1 -1
  19. package/dist/src/cli/dev/run-interactive-ui.js +1 -1
  20. package/dist/src/cli/dev/tui/argument-typeahead.d.ts +1 -1
  21. package/dist/src/cli/dev/tui/argument-typeahead.js +1 -1
  22. package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
  23. package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
  24. package/dist/src/cli/dev/tui/registry-result-message.js +1 -1
  25. package/dist/src/cli/dev/tui/remote-auth.js +1 -1
  26. package/dist/src/cli/dev/tui/runner.d.ts +2 -2
  27. package/dist/src/cli/dev/tui/runner.js +1 -1
  28. package/dist/src/cli/dev/tui/setup-commands.d.ts +3 -1
  29. package/dist/src/cli/dev/tui/setup-commands.js +1 -1
  30. package/dist/src/cli/dev/tui/setup-panel.d.ts +14 -0
  31. package/dist/src/cli/dev/tui/setup-panel.js +4 -4
  32. package/dist/src/cli/dev/tui/subagent-pump.d.ts +2 -10
  33. package/dist/src/cli/dev/tui/subagent-pump.js +1 -1
  34. package/dist/src/cli/dev/tui/terminal-renderer.d.ts +2 -2
  35. package/dist/src/cli/dev/tui/terminal-renderer.js +10 -10
  36. package/dist/src/cli/dev/tui/traces/trace-conversation.js +1 -1
  37. package/dist/src/cli/dev/tui/tui.js +1 -1
  38. package/dist/src/client/client-error.js +1 -1
  39. package/dist/src/client/open-stream.d.ts +3 -2
  40. package/dist/src/client/open-stream.js +1 -1
  41. package/dist/src/client/session.d.ts +16 -1
  42. package/dist/src/client/session.js +1 -1
  43. package/dist/src/compiled/.vendor-stamp.json +1 -1
  44. package/dist/src/discover/filesystem.d.ts +2 -0
  45. package/dist/src/discover/filesystem.js +1 -1
  46. package/dist/src/discover/grammar.d.ts +4 -2
  47. package/dist/src/discover/grammar.js +1 -1
  48. package/dist/src/discover/sandbox.js +1 -1
  49. package/dist/src/evals/session.d.ts +3 -2
  50. package/dist/src/evals/session.js +1 -1
  51. package/dist/src/evals/types.d.ts +8 -2
  52. package/dist/src/eve-channel/index.js +1 -1
  53. package/dist/src/eve-channel/types.d.ts +12 -4
  54. package/dist/src/execution/cancel-indexed-session-tasks-step.js +1 -1
  55. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  56. package/dist/src/execution/proxied-deliver-step.js +1 -1
  57. package/dist/src/execution/route-child-delivery.js +2 -2
  58. package/dist/src/execution/session/admission.js +1 -1
  59. package/dist/src/execution/session/finalization.js +1 -1
  60. package/dist/src/execution/session/handoff-steps.js +1 -1
  61. package/dist/src/execution/session/input-queue.d.ts +12 -10
  62. package/dist/src/execution/session/input-queue.js +1 -1
  63. package/dist/src/execution/session/next-input.js +1 -1
  64. package/dist/src/execution/session/program.js +1 -1
  65. package/dist/src/execution/session/turn-step-result.d.ts +3 -1
  66. package/dist/src/execution/session/turn-step-result.js +1 -1
  67. package/dist/src/execution/session/turn-step-types.d.ts +7 -2
  68. package/dist/src/execution/session/turn-step.js +1 -1
  69. package/dist/src/execution/session/turn.js +1 -1
  70. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  71. package/dist/src/execution/tasks/parent/control-shared.js +1 -1
  72. package/dist/src/execution/tasks/parent/dispatch.js +1 -1
  73. package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +1 -0
  74. package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
  75. package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
  76. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  77. package/dist/src/execution/tools/ask-question-workflow.js +1 -1
  78. package/dist/src/execution/tools/sleep-workflow.js +1 -1
  79. package/dist/src/execution/tools/subagent/accept-event-step.js +1 -1
  80. package/dist/src/execution/tools/subagent/invoke-preparation.js +1 -1
  81. package/dist/src/execution/tools/subagent/invoke-step.js +1 -1
  82. package/dist/src/execution/tools/subagent/task-cancel.d.ts +1 -1
  83. package/dist/src/execution/tools/subagent/task-cancel.js +1 -1
  84. package/dist/src/harness/session-limit-enforcement.js +1 -1
  85. package/dist/src/harness/tool-loop.js +2 -2
  86. package/dist/src/harness/turn-tag-state.d.ts +2 -2
  87. package/dist/src/harness/workflow-tool-runs.d.ts +33 -5
  88. package/dist/src/harness/workflow-tool-runs.js +1 -1
  89. package/dist/src/internal/application/package.js +1 -1
  90. package/dist/src/internal/instrumentation-layout.js +1 -1
  91. package/dist/src/internal/model-auth/vercel-cli.d.ts +2 -0
  92. package/dist/src/internal/model-auth/vercel-cli.js +1 -1
  93. package/dist/src/internal/nitro/host/build-extension.js +1 -1
  94. package/dist/src/internal/nitro/host/extension-build-lock.d.ts +9 -0
  95. package/dist/src/internal/nitro/host/extension-build-lock.js +1 -0
  96. package/dist/src/internal/nitro/host/extension-capability-requirements.d.ts +1 -0
  97. package/dist/src/internal/nitro/host/extension-capability-requirements.js +1 -1
  98. package/dist/src/internal/nitro/host/extension-declarations.js +1 -1
  99. package/dist/src/internal/nitro/host/extension-distribution.js +1 -1
  100. package/dist/src/internal/nitro/host/extension-state-usage.d.ts +2 -2
  101. package/dist/src/internal/nitro/host/extension-state-usage.js +1 -1
  102. package/dist/src/internal/nitro/host/prepare-application-host.d.ts +5 -4
  103. package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
  104. package/dist/src/internal/nitro/host/types.d.ts +2 -2
  105. package/dist/src/internal/nitro/host/workspace-extensions.d.ts +31 -0
  106. package/dist/src/internal/nitro/host/workspace-extensions.js +1 -0
  107. package/dist/src/public/next/index.d.ts +10 -7
  108. package/dist/src/public/next/index.js +1 -1
  109. package/dist/src/public/next/server.d.ts +3 -0
  110. package/dist/src/public/next/server.js +2 -2
  111. package/dist/src/self-modification/extension/local-only.d.ts +5 -0
  112. package/dist/src/self-modification/extension/local-only.js +1 -0
  113. package/dist/src/self-modification/extension/subagents/agent/instructions.js +6 -6
  114. package/dist/src/self-modification/extension/subagents/agent/skills/trace_analysis.d.ts +10 -0
  115. package/dist/src/self-modification/extension/subagents/agent/skills/trace_analysis.js +19 -0
  116. package/dist/src/self-modification/extension/subagents/agent/tools/inspect_trace.d.ts +128 -0
  117. package/dist/src/self-modification/extension/subagents/agent/tools/inspect_trace.js +1 -0
  118. package/dist/src/self-modification/extension/subagents/agent/tools/inspect_trace_spans.d.ts +80 -0
  119. package/dist/src/self-modification/extension/subagents/agent/tools/inspect_trace_spans.js +1 -0
  120. package/dist/src/self-modification/extension/subagents/agent/tools/registry_add.js +1 -1
  121. package/dist/src/self-modification/extension/subagents/agent/tools/search_traces.d.ts +53 -0
  122. package/dist/src/self-modification/extension/subagents/agent/tools/search_traces.js +1 -0
  123. package/dist/src/self-modification/extension/trace-inspection.d.ts +15 -0
  124. package/dist/src/self-modification/extension/trace-inspection.js +1 -0
  125. package/dist/src/self-modification/sandbox.js +1 -1
  126. package/dist/src/setup/ask.d.ts +2 -0
  127. package/dist/src/setup/ask.js +1 -1
  128. package/dist/src/setup/boxes/link-project.d.ts +2 -0
  129. package/dist/src/setup/boxes/link-project.js +1 -1
  130. package/dist/src/setup/cli/option-row.d.ts +3 -1
  131. package/dist/src/setup/cli/option-row.js +1 -1
  132. package/dist/src/setup/flows/deploy.d.ts +1 -0
  133. package/dist/src/setup/flows/deploy.js +1 -1
  134. package/dist/src/setup/flows/install-vercel-cli.js +1 -1
  135. package/dist/src/setup/flows/login.js +1 -1
  136. package/dist/src/setup/flows/model-login-connection.js +1 -1
  137. package/dist/src/setup/flows/model-login.d.ts +4 -0
  138. package/dist/src/setup/flows/model-login.js +1 -1
  139. package/dist/src/setup/flows/vercel-model-login.js +1 -1
  140. package/dist/src/setup/integrations/runner.js +1 -1
  141. package/dist/src/setup/integrations/web/setup.d.ts +15 -10
  142. package/dist/src/setup/integrations/web/setup.js +30 -1
  143. package/dist/src/setup/scaffold/create/project.js +2 -2
  144. package/dist/src/setup/scaffold/create/web-template.d.ts +7 -3
  145. package/dist/src/setup/scaffold/create/web-template.js +39 -20
  146. package/dist/src/setup/scaffold/update/channels.js +2 -2
  147. package/dist/src/setup/slackbot.js +1 -1
  148. package/dist/src/setup/vercel-project.d.ts +2 -0
  149. package/dist/src/setup/vercel-project.js +0 -0
  150. package/dist/src/setup/vercel-trace-sampling.d.ts +3 -0
  151. package/dist/src/setup/vercel-trace-sampling.js +1 -0
  152. package/dist/src/subagents/parent-notification.d.ts +1 -1
  153. package/dist/src/subagents/remote-dispatch.d.ts +1 -0
  154. package/dist/src/subagents/remote-dispatch.js +1 -1
  155. package/dist/src/svelte/index.js +1 -1
  156. package/dist/src/svelte/use-eve-agent.js +1 -1
  157. package/dist/src/tasks/delivery-context.js +2 -2
  158. package/dist/src/tasks/notification.d.ts +6 -0
  159. package/dist/src/tasks/notification.js +1 -1
  160. package/dist/src/tracing/agent-trace-context-store.js +1 -1
  161. package/dist/src/tracing/local-trace-analysis.d.ts +51 -0
  162. package/dist/src/tracing/local-trace-analysis.js +1 -0
  163. package/dist/src/tracing/local-trace-discovery-index.d.ts +15 -0
  164. package/dist/src/tracing/local-trace-discovery-index.js +1 -0
  165. package/dist/src/tracing/local-trace-operations.d.ts +13 -0
  166. package/dist/src/tracing/local-trace-operations.js +1 -0
  167. package/dist/src/tracing/local-trace-query.d.ts +17 -0
  168. package/dist/src/tracing/local-trace-query.js +1 -0
  169. package/dist/src/tracing/local-trace-span-processor.js +1 -1
  170. package/dist/src/tracing/local-trace-summary.d.ts +31 -0
  171. package/dist/src/tracing/local-trace-summary.js +1 -0
  172. package/dist/src/vue/index.js +1 -1
  173. package/dist/src/vue/use-eve-agent.js +1 -1
  174. package/docs/concepts/project-structure.mdx +2 -4
  175. package/docs/concepts/sessions-runs-and-streaming.md +2 -2
  176. package/docs/evals/cases.mdx +1 -0
  177. package/docs/extensions.md +3 -1
  178. package/docs/guides/auth-and-route-protection.md +33 -1
  179. package/docs/guides/client/streaming.mdx +26 -0
  180. package/docs/guides/deployment/vercel.mdx +5 -5
  181. package/docs/guides/frontend/nextjs.mdx +20 -7
  182. package/docs/guides/frontend/overview.mdx +1 -1
  183. package/docs/guides/instrumentation/agent-runs.mdx +4 -4
  184. package/docs/guides/remote-agents.md +3 -1
  185. package/docs/install-integrations.mdx +1 -1
  186. package/docs/reference/agent-files.md +16 -0
  187. package/docs/reference/cli.md +1 -1
  188. package/docs/subagents/index.mdx +8 -2
  189. package/package.json +1 -1
  190. package/dist/src/internal/nitro/host/dev-workspace-extensions.d.ts +0 -18
  191. package/dist/src/internal/nitro/host/dev-workspace-extensions.js +0 -1
  192. package/dist/src/tasks/session-task-cohorts.d.ts +0 -7
  193. package/dist/src/tasks/session-task-cohorts.js +0 -1
@@ -1,6 +1,6 @@
1
1
  import type { DevelopmentExtensionSelection } from "#compiler/development-extensions.js";
2
2
  import type { ApplicationBuildWorkspace } from "#internal/application/build-workspace.js";
3
- import { type DevelopmentWorkspaceExtension } from "#internal/nitro/host/dev-workspace-extensions.js";
3
+ import { type WorkspaceExtension } from "#internal/nitro/host/workspace-extensions.js";
4
4
  import type { PreparedApplicationHost, PreparedDevelopmentApplicationHost } from "#internal/nitro/host/types.js";
5
5
  /**
6
6
  * Compiles one authored app and stages an isolated runtime generation and host
@@ -9,11 +9,12 @@ import type { PreparedApplicationHost, PreparedDevelopmentApplicationHost } from
9
9
  export declare function prepareDevelopmentApplicationHost(appRoot: string, options?: {
10
10
  readonly changedPaths?: readonly string[];
11
11
  readonly developmentExtensions?: DevelopmentExtensionSelection;
12
- readonly previousExtensions?: readonly DevelopmentWorkspaceExtension[];
12
+ readonly previousExtensions?: readonly WorkspaceExtension[];
13
13
  }): Promise<PreparedDevelopmentApplicationHost>;
14
14
  /**
15
- * Compiles one authored app into an invocation-owned build workspace and
16
- * stages the package-owned artifacts the production Nitro build needs.
15
+ * Builds mounted source-backed workspace extensions, then compiles one
16
+ * authored app into an invocation-owned build workspace and stages the
17
+ * package-owned artifacts the production Nitro build needs.
17
18
  * Compiler artifacts are written inside the workspace but their recorded
18
19
  * locations point at the published output (`<finalDir>/.eve`), where
19
20
  * publication later installs them.
@@ -1 +1 @@
1
- import{join}from"node:path";import{createDevelopmentHostWorkspace,removeDevelopmentHostWorkspace}from"#internal/nitro/host/dev-host-workspace.js";import{discardDevelopmentGeneration,stageDevelopmentGeneration}from"#internal/nitro/development-generation.js";import{createScheduleRegistrations}from"#runtime/schedules/register.js";import{resolveSchedules}from"#runtime/schedules/resolve-schedule.js";import{compileAgentInWorkspace}from"#compiler/compile-agent.js";import{writeCompiledArtifactsFiles,writeDevelopmentCompiledArtifactsFiles}from"#internal/application/compiled-artifacts.js";import{prepareDevelopmentWorkspaceExtensions}from"#internal/nitro/host/dev-workspace-extensions.js";async function prepareDevelopmentApplicationHost(e,t={}){let n={appRoot:e};t.changedPaths!==void 0&&(n.changedPaths=t.changedPaths),t.previousExtensions!==void 0&&(n.previousExtensions=t.previousExtensions);let r=await prepareDevelopmentWorkspaceExtensions(n),i=await createDevelopmentHostWorkspace(e),a;try{let n=await compileAgentInWorkspace({artifactLocations:{publishedRoot:join(e,`.eve`),writeRoot:i.compilerArtifactsDir},developmentExtensions:t.developmentExtensions,startPath:e}),o=await resolveSchedules({manifest:n.manifest});return a=await stageDevelopmentGeneration(n),{...createPreparedApplicationHost({compileResult:n,compiledArtifacts:await writeDevelopmentCompiledArtifactsFiles({authoredWorkflowModules:a.authoredWorkflowModules,compileResult:n,outDir:i.artifactsDir,runtimeAppRoot:a.runtimeAppRoot}),schedules:o,workflowBuildDir:i.workflowBuildDir}),generation:a,workspaceExtensions:r,workspace:i}}catch(e){let t=[removeDevelopmentHostWorkspace(i)];a!==void 0&&t.push(discardDevelopmentGeneration(a));let n=(await Promise.allSettled(t)).flatMap(e=>e.status===`rejected`?[e.reason]:[]);throw n.length>0?AggregateError([e,...n],`Failed to prepare and discard a development host candidate.`,{cause:e}):e}}async function prepareProductionApplicationHost(e){let t=await compileAgentInWorkspace({artifactLocations:{publishedRoot:join(e.publication.output.finalDir,`.eve`),writeRoot:e.compiler.artifactsDir},startPath:e.appRoot}),n=await resolveSchedules({manifest:t.manifest});return createPreparedApplicationHost({compileResult:t,compiledArtifacts:await writeCompiledArtifactsFiles({compileResult:t,defaultWorkflowWorld:resolveProductionWorkflowWorldTarget(),outDir:e.host.artifactsDir}),schedules:n,workflowBuildDir:e.workflow.buildDir})}async function refreshProductionCompiledArtifacts(e,t){await writeCompiledArtifactsFiles({compileResult:e.compileResult,defaultWorkflowWorld:resolveProductionWorkflowWorldTarget(),outDir:t})}function createPreparedApplicationHost(e){return{appRoot:e.compileResult.project.appRoot,compileResult:e.compileResult,compiledArtifacts:e.compiledArtifacts,scheduleRegistrations:createScheduleRegistrations(e.schedules),schedules:e.schedules,workflowBuildDir:e.workflowBuildDir}}function resolveProductionWorkflowWorldTarget(){return process.env.VERCEL?`vercel`:`local`}export{prepareDevelopmentApplicationHost,prepareProductionApplicationHost,refreshProductionCompiledArtifacts};
1
+ import{join}from"node:path";import{createDevelopmentHostWorkspace,removeDevelopmentHostWorkspace}from"#internal/nitro/host/dev-host-workspace.js";import{discardDevelopmentGeneration,stageDevelopmentGeneration}from"#internal/nitro/development-generation.js";import{createScheduleRegistrations}from"#runtime/schedules/register.js";import{resolveSchedules}from"#runtime/schedules/resolve-schedule.js";import{compileAgentInWorkspace}from"#compiler/compile-agent.js";import{writeCompiledArtifactsFiles,writeDevelopmentCompiledArtifactsFiles}from"#internal/application/compiled-artifacts.js";import{buildWorkspaceExtensions,prepareDevelopmentWorkspaceExtensions}from"#internal/nitro/host/workspace-extensions.js";async function prepareDevelopmentApplicationHost(e,t={}){let n={appRoot:e};t.changedPaths!==void 0&&(n.changedPaths=t.changedPaths),t.previousExtensions!==void 0&&(n.previousExtensions=t.previousExtensions);let r=await prepareDevelopmentWorkspaceExtensions(n),i=await createDevelopmentHostWorkspace(e),a;try{let n=await compileAgentInWorkspace({artifactLocations:{publishedRoot:join(e,`.eve`),writeRoot:i.compilerArtifactsDir},developmentExtensions:t.developmentExtensions,startPath:e}),o=await resolveSchedules({manifest:n.manifest});return a=await stageDevelopmentGeneration(n),{...createPreparedApplicationHost({compileResult:n,compiledArtifacts:await writeDevelopmentCompiledArtifactsFiles({authoredWorkflowModules:a.authoredWorkflowModules,compileResult:n,outDir:i.artifactsDir,runtimeAppRoot:a.runtimeAppRoot}),schedules:o,workflowBuildDir:i.workflowBuildDir}),generation:a,workspaceExtensions:r,workspace:i}}catch(e){let t=[removeDevelopmentHostWorkspace(i)];a!==void 0&&t.push(discardDevelopmentGeneration(a));let n=(await Promise.allSettled(t)).flatMap(e=>e.status===`rejected`?[e.reason]:[]);throw n.length>0?AggregateError([e,...n],`Failed to prepare and discard a development host candidate.`,{cause:e}):e}}async function prepareProductionApplicationHost(e){await buildWorkspaceExtensions(e.appRoot);let t=await compileAgentInWorkspace({artifactLocations:{publishedRoot:join(e.publication.output.finalDir,`.eve`),writeRoot:e.compiler.artifactsDir},startPath:e.appRoot}),n=await resolveSchedules({manifest:t.manifest});return createPreparedApplicationHost({compileResult:t,compiledArtifacts:await writeCompiledArtifactsFiles({compileResult:t,defaultWorkflowWorld:resolveProductionWorkflowWorldTarget(),outDir:e.host.artifactsDir}),schedules:n,workflowBuildDir:e.workflow.buildDir})}async function refreshProductionCompiledArtifacts(e,t){await writeCompiledArtifactsFiles({compileResult:e.compileResult,defaultWorkflowWorld:resolveProductionWorkflowWorldTarget(),outDir:t})}function createPreparedApplicationHost(e){return{appRoot:e.compileResult.project.appRoot,compileResult:e.compileResult,compiledArtifacts:e.compiledArtifacts,scheduleRegistrations:createScheduleRegistrations(e.schedules),schedules:e.schedules,workflowBuildDir:e.workflowBuildDir}}function resolveProductionWorkflowWorldTarget(){return process.env.VERCEL?`vercel`:`local`}export{prepareDevelopmentApplicationHost,prepareProductionApplicationHost,refreshProductionCompiledArtifacts};
@@ -6,7 +6,7 @@ import type { DevBootProgressReporter } from "#internal/dev-boot-progress.js";
6
6
  import type { DevelopmentExtensionSelection } from "#compiler/development-extensions.js";
7
7
  import type { DevelopmentGeneration } from "#internal/nitro/development-generation.js";
8
8
  import type { DevelopmentHostWorkspace } from "#internal/nitro/host/dev-host-workspace.js";
9
- import type { DevelopmentWorkspaceExtension } from "#internal/nitro/host/dev-workspace-extensions.js";
9
+ import type { WorkspaceExtension } from "#internal/nitro/host/workspace-extensions.js";
10
10
  /** Options for one production application build. */
11
11
  export interface ApplicationBuildOptions {
12
12
  /** Absolute path for an optional machine-readable profile of a successful build. */
@@ -84,6 +84,6 @@ export interface PreparedApplicationHost {
84
84
  }
85
85
  export interface PreparedDevelopmentApplicationHost extends PreparedApplicationHost {
86
86
  generation: DevelopmentGeneration;
87
- workspaceExtensions: readonly DevelopmentWorkspaceExtension[];
87
+ workspaceExtensions: readonly WorkspaceExtension[];
88
88
  workspace: DevelopmentHostWorkspace;
89
89
  }
@@ -0,0 +1,31 @@
1
+ import { type ExtensionBuildConfig } from "#internal/nitro/host/build-extension.js";
2
+ /**
3
+ * A mounted extension package whose authored source lives in the consuming
4
+ * agent's workspace. Dev hosts retain it to scope extension HMR rebuilds.
5
+ */
6
+ export interface WorkspaceExtension {
7
+ readonly config: ExtensionBuildConfig;
8
+ /** Canonical package root, with workspace links resolved. */
9
+ readonly packageRoot: string;
10
+ /** Non-source inputs that affect publisher output, such as tsconfig files. */
11
+ readonly buildConfigPaths: readonly string[];
12
+ }
13
+ /**
14
+ * Builds mounted source-backed workspace extensions before the consuming agent
15
+ * compiles and returns the inputs needed to scope the next development rebuild.
16
+ */
17
+ export declare function prepareDevelopmentWorkspaceExtensions(input: {
18
+ readonly appRoot: string;
19
+ readonly changedPaths?: readonly string[];
20
+ readonly previousExtensions?: readonly WorkspaceExtension[];
21
+ }): Promise<readonly WorkspaceExtension[]>;
22
+ /**
23
+ * Builds mounted source-backed workspace extensions before a production agent
24
+ * build. Package manager lifecycle hooks such as `prepare` do not reliably run
25
+ * (no-op installs and `--ignore-scripts` skip them), so production builds must
26
+ * not assume an extension's gitignored distribution already exists. Extensions
27
+ * whose distribution is newer than every build input are skipped. Builds hold
28
+ * a per-package lock and recheck freshness under it, so parallel agent builds
29
+ * that share an extension build it once.
30
+ */
31
+ export declare function buildWorkspaceExtensions(appRoot: string): Promise<void>;
@@ -0,0 +1 @@
1
+ import{readdir,realpath,stat}from"node:fs/promises";import{basename,dirname,join,resolve,sep}from"node:path";import{resolveDiscoveryProject}from"#discover/project.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{discoverExtensionMountDeclarations}from"#discover/discover-agent.js";import{buildExtensionPackage,tryReadExtensionBuildConfig}from"#internal/nitro/host/build-extension.js";import{withExtensionBuildLock}from"#internal/nitro/host/extension-build-lock.js";import{toErrorMessage}from"#shared/errors.js";import{locateExtensionMountPackage}from"#discover/extensions.js";import{createDiskProjectSource}from"#discover/project-source.js";import{EXTENSION_COMPATIBILITY_MANIFEST_FILENAME,readExtensionCompatibilityManifest}from"#compiler/extension-compatibility.js";import{isAuthoredSourcePath,resolveDevelopmentSourceRoot}from"#internal/nitro/dev-runtime-source-snapshot.js";import{resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";async function prepareDevelopmentWorkspaceExtensions(e){let t=await discoverWorkspaceExtensions(e.appRoot),n=new Map(e.previousExtensions?.map(e=>[e.packageRoot,e])),r=e.changedPaths===void 0?void 0:await Promise.all(e.changedPaths.map(async e=>await toCanonicalPath(e))),i=e.previousExtensions===void 0||r?.length===0;return await Promise.all(t.map(async e=>{let t=n.get(e.packageRoot);(i===!0||t===void 0||!sameBuildInputs(t,e)||r?.some(t=>affectsExtensionBuild(t,e))===!0)&&await withExtensionBuildLock(e.packageRoot,async()=>{await buildExtensionPackage(e.packageRoot,e.config)})})),t}async function buildWorkspaceExtensions(e){let t=await discoverWorkspaceExtensions(e);await Promise.all(t.map(async e=>{if(!await isExtensionDistributionCurrent(e))try{await withExtensionBuildLock(e.packageRoot,async()=>{await isExtensionDistributionCurrent(e)||await buildExtensionPackage(e.packageRoot,e.config)})}catch(t){throw Error(`Failed to build workspace extension "${e.config.packageName}" at ${e.packageRoot}. Fix the error below, then rebuild the agent, or run \`eve extension build\` in that package directory to build it on its own.\n${toErrorMessage(t)}`)}}))}async function discoverWorkspaceExtensions(e){let t=resolve(e),n=await resolveDiscoveryProject(t),r=createDiskProjectSource(),i=await discoverExtensionMountGraph({agentRoot:n.agentRoot,source:r}),a=await toCanonicalPath(resolveDevelopmentSourceRoot(t)),o=new Map;for(let e of i){let n=await resolveWorkspaceExtension({appRoot:t,agentRoot:e.agentRoot,mount:e.mount,source:r,workspaceSourceRoot:a});n!==void 0&&o.set(n.packageRoot,n)}return[...o.values()].sort((e,t)=>e.packageRoot.localeCompare(t.packageRoot))}async function isExtensionDistributionCurrent(e){let t=join(e.config.distRoot,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME),n;try{if((await readExtensionCompatibilityManifest(t)).builtWithEve!==resolveInstalledPackageInfo().version)return!1;n=(await stat(t)).mtimeMs}catch{return!1}let r=await readdir(e.config.sourceRoot,{recursive:!0}),i=[e.config.sourceRoot,...r.map(t=>join(e.config.sourceRoot,t)),...e.buildConfigPaths];return(await Promise.all(i.map(async e=>(await stat(e).catch(()=>void 0))?.mtimeMs??0))).every(e=>e<=n)}async function discoverExtensionMountGraph(e){let t=(await discoverExtensionMountDeclarations(e)).mounts.map(t=>({agentRoot:e.agentRoot,mount:t})),n=join(e.agentRoot,`subagents`);if(await e.source.stat(n)!==`directory`)return t;let r=await e.source.readDirectory(n),i=await Promise.all(r.filter(e=>e.isDirectory()).map(async t=>await discoverExtensionMountGraph({agentRoot:join(n,t.name),source:e.source})));return[...t,...i.flat()]}async function resolveWorkspaceExtension(e){let t=(await locateExtensionMountPackage({source:e.source,agentRoot:e.agentRoot,appRoot:e.appRoot,mount:e.mount.mountRef,namespace:e.mount.namespace})).location;if(t?.authoredSourceRoot===void 0)return;let n=await realpath(t.packageRoot).catch(()=>void 0);if(n===void 0||!isAuthoredSourcePath(n,e.workspaceSourceRoot)||(await stat(t.authoredSourceRoot).catch(()=>void 0))?.isDirectory()!==!0)return;let r=await tryReadExtensionBuildConfig(n);if(r===null)return;let i=[join(n,`package.json`),join(n,`tsconfig.json`),...await resolveTsConfigDependencyPaths(n)];return{config:r,packageRoot:n,buildConfigPaths:[...new Set(i.map(e=>resolve(e)))].sort((e,t)=>e.localeCompare(t))}}function affectsExtensionBuild(e,t){return isPathInsideOrEqual(e,t.config.sourceRoot)||t.buildConfigPaths.includes(e)}function sameBuildConfig(e,t){return e.sourceRoot===t.sourceRoot&&e.distRoot===t.distRoot&&e.outDir===t.outDir&&e.packageName===t.packageName&&e.shortName===t.shortName&&e.runtimeDependencies.length===t.runtimeDependencies.length&&e.runtimeDependencies.every((e,n)=>e===t.runtimeDependencies[n])}function sameBuildInputs(e,t){return sameBuildConfig(e.config,t.config)&&e.buildConfigPaths.length===t.buildConfigPaths.length&&e.buildConfigPaths.every((e,n)=>e===t.buildConfigPaths[n])}function isPathInsideOrEqual(e,t){let n=resolve(e),r=resolve(t);return n===r||n.startsWith(`${r}${sep}`)}async function toCanonicalPath(e){let t=resolve(e),n=[];for(;;)try{return join(await realpath(t),...n.reverse())}catch{let r=dirname(t);if(r===t)return resolve(e);n.push(basename(t)),t=r}}export{buildWorkspaceExtensions,prepareDevelopmentWorkspaceExtensions};
@@ -76,18 +76,19 @@ export interface WithEveOptions {
76
76
  */
77
77
  readonly devServerTimeoutMs?: number;
78
78
  /**
79
- * Path to the eve application root, relative to `process.cwd()` unless
80
- * absolute. Defaults to the Next.js app root when it is not an eve workspace.
79
+ * Path to an eve project root, relative to the Next.js app root unless
80
+ * absolute. The root may contain one `agent/` or an `agents/` workspace.
81
+ * Defaults to the Next.js app root.
81
82
  */
82
83
  readonly eveRoot?: string;
83
84
  /**
84
85
  * Named eve agents to mount under `/eve/<name>/v1/*`.
85
86
  *
86
87
  * Use this when one Next.js app needs to talk to multiple eve agents outside
87
- * a project-level `agents/` workspace. When unset, withEve discovers that
88
- * workspace's members automatically. Do not combine with {@link eveRoot};
89
- * the single-agent form remains the shorthand for one unnamed agent mounted
90
- * at `/eve/v1/*`.
88
+ * a project-level `agents/` workspace. When unset, withEve discovers a
89
+ * workspace at the Next.js app root automatically. Do not combine with
90
+ * {@link eveRoot}; the single-agent form remains the shorthand for one
91
+ * unnamed agent mounted at `/eve/v1/*`.
91
92
  */
92
93
  readonly agents?: WithEveAgentsConfig;
93
94
  /**
@@ -112,7 +113,9 @@ export interface WithEveOptions {
112
113
  * service.
113
114
  *
114
115
  * In development, starts `eve dev --no-ui --port 0` for the eve app and
115
- * rewrites eve protocol endpoints to that local URL. In Vercel production,
116
+ * rewrites eve protocol endpoints to that local URL. During `next build`,
117
+ * builds each agent's mounted source-backed workspace extensions so the
118
+ * Next.js type check can resolve them. In Vercel production,
116
119
  * writes Build Output service routes so Vercel sends eve protocol endpoints to
117
120
  * the eve service directly.
118
121
  * Outside Vercel production, serves an existing `.output/server/index.mjs` build
@@ -1 +1 @@
1
- import{resolveEveDestinationPrefix}from"./server.js";import{ensureEveVercelOutputConfig}from"./vercel-output-config.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{joinEveRoutePath}from"#shared/eve-route-path.js";import{isAbsolute,resolve}from"node:path";import{findEveProjectContext}from"#internal/project-context.js";import{assertValidPublicAgentName}from"#internal/agent-name.js";import{quoteVercelShellArgument,toVercelRelativePath}from"#internal/vercel/build-command.js";import{resolveEveBinaryPath}from"#shared/resolve-eve-binary.js";const EVE_NEXT_SERVICE_PREFIX=`/_eve_internal/eve`,EVE_NEXT_PRODUCTION_PORT_ENV=`EVE_NEXT_PRODUCTION_PORT`;function resolveApplicationRoot(e){return e===void 0||e.length===0?process.cwd():isAbsolute(e)?e:resolve(process.cwd(),e)}function resolveDevServerTimeout(e){if(e!==void 0){if(!Number.isFinite(e)||e<=0)throw Error(`eve Next.js development server timeout must be a positive number.`);return e}}function normalizeRoutePrefix(e){let t=(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/,``);if(t.length===0)throw Error(`eve Next.js service prefix cannot resolve to the root route.`);return t}function joinRoutePrefix(e,t){return`${e.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`}function createNamedAgentRoutePrefix(e){return joinRoutePrefix(`/eve`,e)}function createNamedAgentServicePrefix(e,t){return joinRoutePrefix(e,t)}function createAgentRewriteSource(e){return joinEveRoutePath(e,`${EVE_ROUTE_PREFIX}/:path+`)}function normalizeOrigin(e){return new URL(e.trim()).origin}function readLocalProductionPort(e){let t=process.env[EVE_NEXT_PRODUCTION_PORT_ENV],n=t===void 0||t.trim().length===0?4274:Number.parseInt(t,10);if(t!==void 0&&t.trim().length>0&&String(n)!==t.trim())throw Error(`${EVE_NEXT_PRODUCTION_PORT_ENV} must be an integer between 1 and 65535.`);let r=n+e;if(r<1||r>65535)throw Error(`${EVE_NEXT_PRODUCTION_PORT_ENV} plus the eve agent count exceeds 65535.`);return r}function resolveProductionDestination(e){if(process.env.VERCEL)return{destinationPrefix:e.servicePrefix};let t=process.env.EVE_NEXT_PRODUCTION_ORIGIN;if(t!==void 0&&t.trim().length>0)return{destinationPrefix:joinRoutePrefix(normalizeOrigin(t),e.servicePrefix)};let n=`http://127.0.0.1:${String(readLocalProductionPort(e.localProductionPortOffset))}`;return{destinationPrefix:n,localServerOrigin:n}}function createEveRewriteRule(e){let t=createAgentRewriteSource(e.publicRoutePrefix);return{destination:joinRoutePrefix(e.destinationPrefix,`${EVE_ROUTE_PREFIX}/:path+`),source:t}}async function resolveExistingRewrites(e){return await e?.()}function mergeRewriteRules(e,t){return e===void 0?{beforeFiles:t}:isRewriteSections(e)?{...e,beforeFiles:[...t,...e.beforeFiles??[]]}:{afterFiles:e,beforeFiles:t}}function isRewriteSections(e){return!Array.isArray(e)}async function resolveNextConfig(e,t,n){return typeof e==`function`?await e(t,n):e}function assertValidAgentName(e){assertValidPublicAgentName(e,`eve Next.js agent name`)}function assertValidWithEveOptions(e){if(e.agents===void 0)return;if(e.eveRoot!==void 0)throw Error(`withEve cannot combine eveRoot with agents. Use one configuration form.`);let t=Object.keys(e.agents);if(t.length===0)throw Error(`withEve agents must contain at least one named eve agent.`);for(let e of t)assertValidAgentName(e)}function createDefaultBuildCommand(e){let t=toVercelRelativePath(e.agentRoot,resolveEveBinaryPath(e.agentRoot));return`node ${quoteVercelShellArgument(t)} build`}async function normalizeAgentsConfig(e,t){let n=normalizeRoutePrefix(e.servicePrefix??`/_eve_internal/eve`),resolveBuildCommand=(t,n)=>n??e.eveBuildCommand??createDefaultBuildCommand({agentRoot:t});if(e.agents===void 0){if(e.eveRoot===void 0){let e=await findEveProjectContext(t);if(e?.kind===`workspace`&&e.workspace.root===t&&e.workspace.members.length>0)return e.workspace.members.map((e,t)=>({appRoot:e.appRoot,buildCommand:resolveBuildCommand(e.appRoot,void 0),localProductionPortOffset:t,name:e.name,publicRoutePrefix:createNamedAgentRoutePrefix(e.name),servicePrefix:createNamedAgentServicePrefix(n,e.name),workspaceMember:!0}))}let r=resolveApplicationRoot(e.eveRoot);return[{appRoot:r,buildCommand:resolveBuildCommand(r,void 0),localProductionPortOffset:0,publicRoutePrefix:``,servicePrefix:n}]}let r=Object.entries(e.agents);if(r.length===0)throw Error(`withEve agents must contain at least one named eve agent.`);return r.map(([e,t],r)=>{assertValidAgentName(e);let i=typeof t==`string`?{root:t}:t,a=resolveApplicationRoot(i.root);return{appRoot:a,buildCommand:resolveBuildCommand(a,i.buildCommand),localProductionPortOffset:r,name:e,publicRoutePrefix:createNamedAgentRoutePrefix(e),servicePrefix:normalizeRoutePrefix(i.servicePrefix??createNamedAgentServicePrefix(n,e))}})}function withEve(e,t={}){let n=process.cwd(),r=resolveDevServerTimeout(t.devServerTimeoutMs);return assertValidWithEveOptions(t),async function(i,a){let[o,s]=await Promise.all([normalizeAgentsConfig(t,n),resolveNextConfig(e,i,a)]),c=s.rewrites,l=await ensureEveVercelOutputConfig({agents:o.map(e=>{let t={appRoot:e.appRoot,buildCommand:e.buildCommand,name:e.name,publicRoutePrefix:e.publicRoutePrefix,servicePrefix:e.servicePrefix};return e.workspaceMember===!0&&(t.workspaceMember=!0),t}),nextRoot:n});if(process.env.VERCEL)return s;let u=new Map(l.agents.map(e=>[e.name,e])),d=o.map(e=>{let t=u.get(e.name),n=resolveProductionDestination({localProductionPortOffset:e.localProductionPortOffset,servicePrefix:t?.servicePrefix??e.servicePrefix});return{...e,productionDestination:n}});return{...s,async rewrites(){let[e,t]=await Promise.all([resolveExistingRewrites(c),Promise.all(d.map(async e=>createEveRewriteRule({destinationPrefix:await resolveEveDestinationPrefix({appRoot:e.appRoot,devServerTimeoutMs:r,logLabel:e.name,phase:i,productionDestinationPrefix:e.productionDestination.destinationPrefix,productionServerOrigin:e.productionDestination.localServerOrigin}),publicRoutePrefix:e.publicRoutePrefix})))]);return mergeRewriteRules(e,t)}}}}export{EVE_NEXT_SERVICE_PREFIX,withEve};
1
+ import{resolveEveDestinationPrefix}from"./server.js";import{ensureEveVercelOutputConfig}from"./vercel-output-config.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{joinEveRoutePath}from"#shared/eve-route-path.js";import{resolve}from"node:path";import{findEveProjectContext}from"#internal/project-context.js";import{assertValidPublicAgentName}from"#internal/agent-name.js";import{quoteVercelShellArgument,toVercelRelativePath}from"#internal/vercel/build-command.js";import{resolveEveBinaryPath}from"#shared/resolve-eve-binary.js";const EVE_NEXT_SERVICE_PREFIX=`/_eve_internal/eve`,EVE_NEXT_PRODUCTION_PORT_ENV=`EVE_NEXT_PRODUCTION_PORT`;function resolveApplicationRoot(e){return e===void 0||e.length===0?process.cwd():resolve(process.cwd(),e)}function resolveDevServerTimeout(e){if(e!==void 0){if(!Number.isFinite(e)||e<=0)throw Error(`eve Next.js development server timeout must be a positive number.`);return e}}function normalizeRoutePrefix(e){let t=(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/,``);if(t.length===0)throw Error(`eve Next.js service prefix cannot resolve to the root route.`);return t}function joinRoutePrefix(e,t){return`${e.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`}function createNamedAgentRoutePrefix(e){return joinRoutePrefix(`/eve`,e)}function createNamedAgentServicePrefix(e,t){return joinRoutePrefix(e,t)}function createAgentRewriteSource(e){return joinEveRoutePath(e,`${EVE_ROUTE_PREFIX}/:path+`)}function normalizeOrigin(e){return new URL(e.trim()).origin}function readLocalProductionPort(e){let t=process.env[EVE_NEXT_PRODUCTION_PORT_ENV],n=t===void 0||t.trim().length===0?4274:Number.parseInt(t,10);if(t!==void 0&&t.trim().length>0&&String(n)!==t.trim())throw Error(`${EVE_NEXT_PRODUCTION_PORT_ENV} must be an integer between 1 and 65535.`);let r=n+e;if(r<1||r>65535)throw Error(`${EVE_NEXT_PRODUCTION_PORT_ENV} plus the eve agent count exceeds 65535.`);return r}function resolveProductionDestination(e){if(process.env.VERCEL)return{destinationPrefix:e.servicePrefix};let t=process.env.EVE_NEXT_PRODUCTION_ORIGIN;if(t!==void 0&&t.trim().length>0)return{destinationPrefix:joinRoutePrefix(normalizeOrigin(t),e.servicePrefix)};let n=`http://127.0.0.1:${String(readLocalProductionPort(e.localProductionPortOffset))}`;return{destinationPrefix:n,localServerOrigin:n}}function createEveRewriteRule(e){let t=createAgentRewriteSource(e.publicRoutePrefix);return{destination:joinRoutePrefix(e.destinationPrefix,`${EVE_ROUTE_PREFIX}/:path+`),source:t}}async function resolveExistingRewrites(e){return await e?.()}function mergeRewriteRules(e,t){return e===void 0?{beforeFiles:t}:isRewriteSections(e)?{...e,beforeFiles:[...t,...e.beforeFiles??[]]}:{afterFiles:e,beforeFiles:t}}function isRewriteSections(e){return!Array.isArray(e)}async function resolveNextConfig(e,t,n){return typeof e==`function`?await e(t,n):e}function assertValidAgentName(e){assertValidPublicAgentName(e,`eve Next.js agent name`)}function assertValidWithEveOptions(e){if(e.eveRoot!==void 0&&e.agents!==void 0)throw Error(`withEve cannot combine eveRoot with agents. Use one configuration form.`);if(e.agents===void 0)return;let t=Object.keys(e.agents);if(t.length===0)throw Error(`withEve agents must contain at least one named eve agent.`);for(let e of t)assertValidAgentName(e)}function createDefaultBuildCommand(e){let t=toVercelRelativePath(e.agentRoot,resolveEveBinaryPath(e.agentRoot));return`node ${quoteVercelShellArgument(t)} build`}async function normalizeAgentsConfig(e){let t=normalizeRoutePrefix(e.servicePrefix??`/_eve_internal/eve`),resolveBuildCommand=(t,n)=>n??e.eveBuildCommand??createDefaultBuildCommand({agentRoot:t});if(e.agents===void 0){let n=resolveApplicationRoot(e.eveRoot),r=await findEveProjectContext(n);if(r?.kind===`workspace`&&r.workspace.root===n&&r.workspace.members.length>0)return r.workspace.members.map((e,n)=>({appRoot:e.appRoot,buildCommand:resolveBuildCommand(e.appRoot,void 0),localProductionPortOffset:n,name:e.name,publicRoutePrefix:createNamedAgentRoutePrefix(e.name),servicePrefix:createNamedAgentServicePrefix(t,e.name),workspaceMember:!0}));let i=n;return[{appRoot:i,buildCommand:resolveBuildCommand(i,void 0),localProductionPortOffset:0,publicRoutePrefix:``,servicePrefix:t}]}let n=Object.entries(e.agents);if(n.length===0)throw Error(`withEve agents must contain at least one named eve agent.`);return n.map(([e,n],r)=>{assertValidAgentName(e);let i=typeof n==`string`?{root:n}:n,a=resolveApplicationRoot(i.root);return{appRoot:a,buildCommand:resolveBuildCommand(a,i.buildCommand),localProductionPortOffset:r,name:e,publicRoutePrefix:createNamedAgentRoutePrefix(e),servicePrefix:normalizeRoutePrefix(i.servicePrefix??createNamedAgentServicePrefix(t,e))}})}async function buildAgentWorkspaceExtensions(e){let[{buildWorkspaceExtensions:t},{DiscoveryProjectResolutionError:n}]=await Promise.all([import(`#internal/nitro/host/workspace-extensions.js`),import(`#discover/project.js`)]);for(let r of e)try{await t(r.appRoot)}catch(e){if(e instanceof n)continue;throw e}}function withEve(e,t={}){let n=process.cwd(),r=resolveDevServerTimeout(t.devServerTimeoutMs);return assertValidWithEveOptions(t),async function(i,a){let[o,s]=await Promise.all([normalizeAgentsConfig(t),resolveNextConfig(e,i,a)]);i===`phase-production-build`&&await buildAgentWorkspaceExtensions(o);let c=s.rewrites,l=await ensureEveVercelOutputConfig({agents:o.map(e=>{let t={appRoot:e.appRoot,buildCommand:e.buildCommand,name:e.name,publicRoutePrefix:e.publicRoutePrefix,servicePrefix:e.servicePrefix};return e.workspaceMember===!0&&(t.workspaceMember=!0),t}),nextRoot:n});if(process.env.VERCEL)return s;let u=new Map(l.agents.map(e=>[e.name,e])),d=o.map(e=>{let t=u.get(e.name),n=resolveProductionDestination({localProductionPortOffset:e.localProductionPortOffset,servicePrefix:t?.servicePrefix??e.servicePrefix});return{...e,productionDestination:n}});return{...s,async rewrites(){let[e,t]=await Promise.all([resolveExistingRewrites(c),Promise.all(d.map(async e=>createEveRewriteRule({destinationPrefix:await resolveEveDestinationPrefix({appRoot:e.appRoot,devServerTimeoutMs:r,logLabel:e.name,phase:i,productionDestinationPrefix:e.productionDestination.destinationPrefix,productionServerOrigin:e.productionDestination.localServerOrigin,workspaceAgentName:e.workspaceMember===!0?e.name:void 0}),publicRoutePrefix:e.publicRoutePrefix})))]);return mergeRewriteRules(e,t)}}}}export{EVE_NEXT_SERVICE_PREFIX,withEve};
@@ -1,3 +1,4 @@
1
+ export declare const NEXT_PHASE_PRODUCTION_BUILD = "phase-production-build";
1
2
  export declare function resolveEveDestinationPrefix(input: {
2
3
  readonly appRoot: string;
3
4
  readonly devServerTimeoutMs?: number;
@@ -5,4 +6,6 @@ export declare function resolveEveDestinationPrefix(input: {
5
6
  readonly phase: string;
6
7
  readonly productionDestinationPrefix: string;
7
8
  readonly productionServerOrigin?: string;
9
+ /** Workspace member selected when spawning the local eve dev server. */
10
+ readonly workspaceAgentName?: string;
8
11
  }): Promise<string>;
@@ -1,2 +1,2 @@
1
- import{mkdir,open,readFile,rm,stat,writeFile}from"node:fs/promises";import{join}from"node:path";import{resolvePackageRoot}from"#internal/application/package.js";import{existsSync}from"node:fs";import{spawn}from"node:child_process";import{readDevelopmentRuntimeArtifactsRevision}from"#services/dev-client/runtime-artifacts.js";const DEFAULT_SERVER_READY_TIMEOUT_MS=18e4,ANSI_ESCAPE_PATTERN=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`),SERVER_URL_CANDIDATE_PATTERN=/https?:\/\/[^\s"'<>]+/g,globalStateSymbol=Symbol.for(`eve.next.state`);function getGlobalState(){let e=globalThis;return e[globalStateSymbol]??={servers:new Map},e[globalStateSymbol]}function normalizeOrigin(e){return new URL(e).origin}function readEveBaseUrlEnvironment(){let e=process.env.EVE_BASE_URL;if(e!==void 0&&e.trim().length!==0)return normalizeOrigin(e)}function isNodeErrorWithCode(e,t){return e instanceof Error&&`code`in e&&e.code===t}function delay(e){return new Promise(t=>setTimeout(t,e))}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function resolveEveCacheDirectory(e){return join(e,`.eve`)}function resolveEveDevServerRegistryPath(e){return join(resolveEveCacheDirectory(e),`next-dev-server.json`)}function resolveEveDevServerLockPath(e){return join(resolveEveCacheDirectory(e),`next-dev-server.lock`)}function normalizeDevServerRegistry(e){if(isRecord(e)&&typeof e.appRoot==`string`&&typeof e.origin==`string`&&typeof e.updatedAt==`string`&&(e.pid===null||typeof e.pid==`number`))try{return{appRoot:e.appRoot,origin:normalizeOrigin(e.origin),pid:e.pid,updatedAt:e.updatedAt}}catch{return}}async function readUsableEveDevServerRegistry(e){try{let t=normalizeDevServerRegistry(JSON.parse(await readFile(resolveEveDevServerRegistryPath(e),`utf8`)));return t===void 0||t.appRoot!==e||await readDevelopmentRuntimeArtifactsRevision({serverUrl:t.origin,timeoutMs:1e3})===void 0?void 0:t.origin}catch(e){if(isNodeErrorWithCode(e,`ENOENT`))return;throw e}}async function writeEveDevServerRegistry(e,t){await mkdir(resolveEveCacheDirectory(e),{recursive:!0}),await writeFile(resolveEveDevServerRegistryPath(e),`${JSON.stringify({appRoot:e,origin:t.origin,pid:t.process?.pid??null,updatedAt:new Date().toISOString()},null,2)}\n`)}async function removeStaleEveDevServerLock(e){try{let t=await stat(e);Date.now()-t.mtimeMs>3e4&&await rm(e,{force:!0})}catch(e){if(!isNodeErrorWithCode(e,`ENOENT`))throw e}}async function acquireEveDevServerLock(e,t){let n=resolveEveCacheDirectory(e),r=resolveEveDevServerLockPath(e),i=Date.now()+t;for(await mkdir(n,{recursive:!0});;)try{let e=await open(r,`wx`);return await e.writeFile(`${String(process.pid)}\n`),await e.close(),async()=>{await rm(r,{force:!0})}}catch(n){if(!isNodeErrorWithCode(n,`EEXIST`))throw n;if(await readUsableEveDevServerRegistry(e)!==void 0)return async()=>{};if(await removeStaleEveDevServerLock(r),Date.now()>i)throw Error(`Timed out after ${t}ms waiting for another Next.js process to start eve.`);await delay(100)}}function createEveBinaryPath(){return join(resolvePackageRoot(),`bin`,`eve.js`)}function isLoopbackHostname(e){return e===`localhost`||e===`::1`||e===`[::1]`||/^127(?:\.\d{1,3}){3}$/.test(e)}function parseLocalServerOrigin(e){let t=URL.parse(e);if(!(t===null||t.protocol!==`http:`&&t.protocol!==`https:`||!isLoopbackHostname(t.hostname)||t.port.length===0))return t.origin}function findLocalServerOrigin(e){for(let t of e.matchAll(SERVER_URL_CANDIDATE_PATTERN)){let e=t[0],n=parseLocalServerOrigin(e);if(n!==void 0)return n}}function formatEveDevOutputLine(e,t){let n=e.replace(/\r$/,``),r=n.replace(ANSI_ESCAPE_PATTERN,``).trim();if(r.length===0||/^☰eve\b/.test(r)||r===`CONFIGURATION_FIELD_CONFLICT`||r.startsWith(`[CONFIGURATION_FIELD_CONFLICT]`))return;let i=t===void 0?`[eve:dev]`:`[eve:dev:${t}]`,a=/server listening at\s+(https?:\/\/[^\s]+)/i.exec(n);return a===null?`${i} ${n}`:`${i} server listening at ${a[1]}`}function createEveDevOutputWriter(e){let t=``,writeLine=t=>{let n=formatEveDevOutputLine(t,e.logLabel);n!==void 0&&e.stream.write(`${n}\n`)};return{flush(){t.length!==0&&(writeLine(t),t=``)},write(e){t+=e.toString(`utf8`);let n=t.split(`
2
- `);t=n.pop()??``;for(let e of n)writeLine(e)}}}function startServerProcess(e){return new Promise((t,n)=>{let r=spawn(e.command,e.args,{cwd:e.cwd,env:{...process.env,...e.env},stdio:[`ignore`,`pipe`,`pipe`]}),i=createEveDevOutputWriter({logLabel:e.logLabel,stream:process.stderr}),a=createEveDevOutputWriter({logLabel:e.logLabel,stream:process.stdout}),o=setTimeout(()=>{r.kill(),n(Error(`Timed out after ${e.timeoutMs??DEFAULT_SERVER_READY_TIMEOUT_MS}ms waiting for eve to print its server URL.`))},e.timeoutMs??DEFAULT_SERVER_READY_TIMEOUT_MS),cleanup=()=>{clearTimeout(o),r.off(`error`,handleError),r.off(`exit`,handleEarlyExit)},flushOutput=()=>{a.flush(),i.flush()},handleError=e=>{flushOutput(),cleanup(),n(e)},handleEarlyExit=(e,t)=>{flushOutput(),cleanup(),n(Error(`eve server process exited before printing its server URL (code ${String(e)}, signal ${String(t)}).`))},handleOutput=e=>{let n=findLocalServerOrigin(e.toString(`utf8`));n!==void 0&&(cleanup(),t({origin:n,process:r}))};r.once(`error`,handleError),r.once(`exit`,handleEarlyExit),r.stdout.on(`data`,e=>{a.write(e),handleOutput(e)}),r.stderr.on(`data`,e=>{i.write(e),handleOutput(e)})})}function installProcessShutdown(e){let t=e.process;if(t===void 0)return e;let close=()=>{t.killed||t.kill()};return process.once(`beforeExit`,close),process.once(`exit`,close),e}function startEveDevServer(e,t,n){return startServerProcess({args:[createEveBinaryPath(),`dev`,`--no-ui`,`--port`,`0`],command:process.execPath,cwd:e,logLabel:n,timeoutMs:t}).then(e=>installProcessShutdown(e))}function startEveProductionServer(e){let t=new URL(e.origin),n=t.port,r=join(e.appRoot,`.output`,`server`,`index.mjs`);if(!existsSync(r))throw Error(`eve production output is missing at ${r}. Run eve build from ${e.appRoot} before starting Next.js.`);return startServerProcess({args:[r],command:process.execPath,cwd:e.appRoot,env:{HOST:t.hostname,NITRO_HOST:t.hostname,NITRO_PORT:n,PORT:n}}).then(installProcessShutdown)}async function resolveSharedEveDevServer(e,t,n){let r=await readUsableEveDevServerRegistry(e);if(r!==void 0)return{origin:r};let i=await acquireEveDevServerLock(e,t);try{let r=await readUsableEveDevServerRegistry(e);if(r!==void 0)return{origin:r};let i=await startEveDevServer(e,t,n);return await writeEveDevServerRegistry(e,i),i}finally{await i()}}async function resolveEveDestinationPrefix(e){let t=getGlobalState();if(process.env.NODE_ENV===`production`){if(e.phase===`phase-production-build`)return e.productionDestinationPrefix;let n=`production:${e.appRoot}`,r=t.servers.get(n);return r===void 0&&(r=process.env.VERCEL||e.productionServerOrigin===void 0?void 0:startEveProductionServer({appRoot:e.appRoot,origin:e.productionServerOrigin}),r!==void 0&&(r=r.catch(e=>{throw t.servers.delete(n),e}),t.servers.set(n,r))),r===void 0?e.productionDestinationPrefix:(await r).origin}let n=readEveBaseUrlEnvironment();if(n!==void 0)return n;if(process.env.NODE_ENV!==`development`)return e.productionDestinationPrefix;let r=`dev:${e.appRoot}`,i=t.servers.get(r);return i===void 0&&(i=resolveSharedEveDevServer(e.appRoot,e.devServerTimeoutMs??18e4,e.logLabel).catch(e=>{throw t.servers.delete(r),e}),t.servers.set(r,i)),(await i).origin}export{resolveEveDestinationPrefix};
1
+ import{mkdir,open,readFile,rm,stat,writeFile}from"node:fs/promises";import{join}from"node:path";import{resolvePackageRoot}from"#internal/application/package.js";import{existsSync}from"node:fs";import{spawn}from"node:child_process";import{readDevelopmentRuntimeArtifactsRevision}from"#services/dev-client/runtime-artifacts.js";const DEFAULT_SERVER_READY_TIMEOUT_MS=18e4,ANSI_ESCAPE_PATTERN=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`),SERVER_URL_CANDIDATE_PATTERN=/https?:\/\/[^\s"'<>]+/g,NEXT_PHASE_PRODUCTION_BUILD=`phase-production-build`,globalStateSymbol=Symbol.for(`eve.next.state`);function getGlobalState(){let e=globalThis;return e[globalStateSymbol]??={servers:new Map},e[globalStateSymbol]}function normalizeOrigin(e){return new URL(e).origin}function readEveBaseUrlEnvironment(){let e=process.env.EVE_BASE_URL;if(e!==void 0&&e.trim().length!==0)return normalizeOrigin(e)}function isNodeErrorWithCode(e,t){return e instanceof Error&&`code`in e&&e.code===t}function delay(e){return new Promise(t=>setTimeout(t,e))}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function resolveEveCacheDirectory(e){return join(e,`.eve`)}function resolveEveDevServerRegistryPath(e){return join(resolveEveCacheDirectory(e),`next-dev-server.json`)}function resolveEveDevServerLockPath(e){return join(resolveEveCacheDirectory(e),`next-dev-server.lock`)}function normalizeDevServerRegistry(e){if(isRecord(e)&&typeof e.appRoot==`string`&&typeof e.origin==`string`&&typeof e.updatedAt==`string`&&(e.pid===null||typeof e.pid==`number`))try{return{appRoot:e.appRoot,origin:normalizeOrigin(e.origin),pid:e.pid,updatedAt:e.updatedAt}}catch{return}}async function readUsableEveDevServerRegistry(e){try{let t=normalizeDevServerRegistry(JSON.parse(await readFile(resolveEveDevServerRegistryPath(e),`utf8`)));return t===void 0||t.appRoot!==e||await readDevelopmentRuntimeArtifactsRevision({serverUrl:t.origin,timeoutMs:1e3})===void 0?void 0:t.origin}catch(e){if(isNodeErrorWithCode(e,`ENOENT`))return;throw e}}async function writeEveDevServerRegistry(e,t){await mkdir(resolveEveCacheDirectory(e),{recursive:!0}),await writeFile(resolveEveDevServerRegistryPath(e),`${JSON.stringify({appRoot:e,origin:t.origin,pid:t.process?.pid??null,updatedAt:new Date().toISOString()},null,2)}\n`)}async function removeStaleEveDevServerLock(e){try{let t=await stat(e);Date.now()-t.mtimeMs>3e4&&await rm(e,{force:!0})}catch(e){if(!isNodeErrorWithCode(e,`ENOENT`))throw e}}async function acquireEveDevServerLock(e,t){let n=resolveEveCacheDirectory(e),r=resolveEveDevServerLockPath(e),i=Date.now()+t;for(await mkdir(n,{recursive:!0});;)try{let e=await open(r,`wx`);return await e.writeFile(`${String(process.pid)}\n`),await e.close(),async()=>{await rm(r,{force:!0})}}catch(n){if(!isNodeErrorWithCode(n,`EEXIST`))throw n;if(await readUsableEveDevServerRegistry(e)!==void 0)return async()=>{};if(await removeStaleEveDevServerLock(r),Date.now()>i)throw Error(`Timed out after ${t}ms waiting for another Next.js process to start eve.`);await delay(100)}}function createEveBinaryPath(){return join(resolvePackageRoot(),`bin`,`eve.js`)}function isLoopbackHostname(e){return e===`localhost`||e===`::1`||e===`[::1]`||/^127(?:\.\d{1,3}){3}$/.test(e)}function parseLocalServerOrigin(e){let t=URL.parse(e);if(!(t===null||t.protocol!==`http:`&&t.protocol!==`https:`||!isLoopbackHostname(t.hostname)||t.port.length===0))return t.origin}function findLocalServerOrigin(e){for(let t of e.matchAll(SERVER_URL_CANDIDATE_PATTERN)){let e=t[0],n=parseLocalServerOrigin(e);if(n!==void 0)return n}}function formatEveDevOutputLine(e,t){let n=e.replace(/\r$/,``),r=n.replace(ANSI_ESCAPE_PATTERN,``).trim();if(r.length===0||/^☰eve\b/.test(r)||r===`CONFIGURATION_FIELD_CONFLICT`||r.startsWith(`[CONFIGURATION_FIELD_CONFLICT]`))return;let i=t===void 0?`[eve:dev]`:`[eve:dev:${t}]`,a=/server listening at\s+(https?:\/\/[^\s]+)/i.exec(n);return a===null?`${i} ${n}`:`${i} server listening at ${a[1]}`}function createEveDevOutputWriter(e){let t=``,writeLine=t=>{let n=formatEveDevOutputLine(t,e.logLabel);n!==void 0&&e.stream.write(`${n}\n`)};return{flush(){t.length!==0&&(writeLine(t),t=``)},write(e){t+=e.toString(`utf8`);let n=t.split(`
2
+ `);t=n.pop()??``;for(let e of n)writeLine(e)}}}function startServerProcess(e){return new Promise((t,n)=>{let r=spawn(e.command,e.args,{cwd:e.cwd,env:{...process.env,...e.env},stdio:[`ignore`,`pipe`,`pipe`]}),i=createEveDevOutputWriter({logLabel:e.logLabel,stream:process.stderr}),a=createEveDevOutputWriter({logLabel:e.logLabel,stream:process.stdout}),o=setTimeout(()=>{r.kill(),n(Error(`Timed out after ${e.timeoutMs??DEFAULT_SERVER_READY_TIMEOUT_MS}ms waiting for eve to print its server URL.`))},e.timeoutMs??DEFAULT_SERVER_READY_TIMEOUT_MS),cleanup=()=>{clearTimeout(o),r.off(`error`,handleError),r.off(`exit`,handleEarlyExit)},flushOutput=()=>{a.flush(),i.flush()},handleError=e=>{flushOutput(),cleanup(),n(e)},handleEarlyExit=(e,t)=>{flushOutput(),cleanup(),n(Error(`eve server process exited before printing its server URL (code ${String(e)}, signal ${String(t)}).`))},handleOutput=e=>{let n=findLocalServerOrigin(e.toString(`utf8`));n!==void 0&&(cleanup(),t({origin:n,process:r}))};r.once(`error`,handleError),r.once(`exit`,handleEarlyExit),r.stdout.on(`data`,e=>{a.write(e),handleOutput(e)}),r.stderr.on(`data`,e=>{i.write(e),handleOutput(e)})})}function installProcessShutdown(e){let t=e.process;if(t===void 0)return e;let close=()=>{t.killed||t.kill()};return process.once(`beforeExit`,close),process.once(`exit`,close),e}function startEveDevServer(e,t,n,r){return startServerProcess({args:[createEveBinaryPath(),`dev`,`--no-ui`,`--port`,`0`,...r===void 0?[]:[`--agent`,r]],command:process.execPath,cwd:e,logLabel:n,timeoutMs:t}).then(e=>installProcessShutdown(e))}function startEveProductionServer(e){let t=new URL(e.origin),n=t.port,r=join(e.appRoot,`.output`,`server`,`index.mjs`);if(!existsSync(r))throw Error(`eve production output is missing at ${r}. Run eve build from ${e.appRoot} before starting Next.js.`);return startServerProcess({args:[r],command:process.execPath,cwd:e.appRoot,env:{HOST:t.hostname,NITRO_HOST:t.hostname,NITRO_PORT:n,PORT:n}}).then(installProcessShutdown)}async function resolveSharedEveDevServer(e,t,n,r){let i=await readUsableEveDevServerRegistry(e);if(i!==void 0)return{origin:i};let a=await acquireEveDevServerLock(e,t);try{let i=await readUsableEveDevServerRegistry(e);if(i!==void 0)return{origin:i};let a=await startEveDevServer(e,t,n,r);return await writeEveDevServerRegistry(e,a),a}finally{await a()}}async function resolveEveDestinationPrefix(e){let t=getGlobalState();if(process.env.NODE_ENV===`production`){if(e.phase===`phase-production-build`)return e.productionDestinationPrefix;let n=`production:${e.appRoot}`,r=t.servers.get(n);return r===void 0&&(r=process.env.VERCEL||e.productionServerOrigin===void 0?void 0:startEveProductionServer({appRoot:e.appRoot,origin:e.productionServerOrigin}),r!==void 0&&(r=r.catch(e=>{throw t.servers.delete(n),e}),t.servers.set(n,r))),r===void 0?e.productionDestinationPrefix:(await r).origin}let n=readEveBaseUrlEnvironment();if(n!==void 0)return n;if(process.env.NODE_ENV!==`development`)return e.productionDestinationPrefix;let r=`dev:${e.appRoot}`,i=t.servers.get(r);return i===void 0&&(i=resolveSharedEveDevServer(e.appRoot,e.devServerTimeoutMs??18e4,e.logLabel,e.workspaceAgentName).catch(e=>{throw t.servers.delete(r),e}),t.servers.set(r,i)),(await i).origin}export{NEXT_PHASE_PRODUCTION_BUILD,resolveEveDestinationPrefix};
@@ -0,0 +1,5 @@
1
+ import { type ResolvedSelfModificationConfig } from "../config.js";
2
+ /** Returns a definition only when self-modification is running locally. */
3
+ export declare function resolveLocalOnly<T>(config: ResolvedSelfModificationConfig, definition: T): T | null;
4
+ /** Creates a dynamic definition that is absent from deployed self-modification. */
5
+ export declare function defineLocalOnlyDynamic<T>(definition: T): import("#dynamic/definition.js").DynamicSentinel<Awaited<T> | null>;
@@ -0,0 +1 @@
1
+ import{resolveSelfModificationConfig}from"../config.js";import extension_default from"./extension.js";import{resolveSelfModificationMode}from"../mode.js";import{defineDynamic}from"#dynamic/definition.js";function resolveLocalOnly(e,t){return resolveSelfModificationMode(e)===`local`?t:null}function defineLocalOnlyDynamic(e){return defineDynamic({events:{"session.started":()=>resolveLocalOnly(resolveSelfModificationConfig(extension_default.config),e)}})}export{defineLocalOnlyDynamic,resolveLocalOnly};
@@ -1,14 +1,14 @@
1
- import{resolveSelfModificationConfig}from"../../../config.js";import extension_default from"../../extension.js";import{resolveSelfModificationMode}from"../../../mode.js";import{defineDynamic,defineInstructions}from"eve/instructions";function readTrace(e){return e.data?.trace}function localTraceGuidance(e){let t=readTrace(e);return t===void 0?``:`The invoking trace has ID ${t.traceId}. ${(t.traceFlags&1)==1?`If local segments were captured,`:`This trace was not sampled, so local segments may be absent. If any are present,`} inspect them at /traces/${t.traceId}.`}function renderInstructions(e){return e.filter(e=>e.length>0).join(`
1
+ import{resolveSelfModificationConfig}from"../../../config.js";import extension_default from"../../extension.js";import{resolveSelfModificationMode}from"../../../mode.js";import{defineDynamic,defineInstructions}from"eve/instructions";function renderInstructions(e){return e.filter(e=>e.length>0).join(`
2
2
 
3
- `)}var instructions_default=defineDynamic({events:{"session.started":e=>{let t=resolveSelfModificationMode(resolveSelfModificationConfig(extension_default.config));return t!==`local`&&t!==`deployed`?null:defineInstructions({markdown:renderInstructions([`## Role
3
+ `)}var instructions_default=defineDynamic({events:{"session.started":()=>{let e=resolveSelfModificationMode(resolveSelfModificationConfig(extension_default.config));return e!==`local`&&e!==`deployed`?null:defineInstructions({markdown:renderInstructions([`## Role
4
4
 
5
5
  You are an expert coding assistant operating inside of an eve agent. You help users by reading files, editing code, and writing new files that shape the behavior of the agent itself.`,`## Source workspace
6
6
 
7
7
  The source code of the eve agent is mounted read-write at /source. /source is the authored agent directory. Locate source files with bash. Read source contents with read_file, not shell commands. Before generating an overwrite, ensure read_file has succeeded for that path. Shell reads do not satisfy write_file's read-before-write requirement. edit_file instead validates exact matches against current contents. Never modify source files with bash, sed, awk, redirection, or scripting.
8
8
 
9
- Resolve named tools by filename under /source/tools before searching contents. Tool identifiers derive from filenames and may not occur in the implementation.`,`## Configure this subagent
9
+ Resolve named tools by filename under /source/tools before searching contents. Tool identifiers derive from filenames and may not occur in the implementation.`,`## Changing this subagent
10
10
 
11
- Configure this self-modification subagent's model, reasoning, and policy only through its authored mount. Check /source/extensions/self-modification.ts and /source/extensions/self-modification/extension.ts; modify whichever exists. If neither file exists, this subagent is the bundled eve development default and is using the default settings: first call registry_add with the exact address eve/self-modification to scaffold the authored mount. This known scaffold does not require search_registry.
11
+ When the user explicitly asks to change the self-modification subagent's model, reasoning, or policy, make edits only through its authored mount. For such requests, check /source/extensions/self-modification.ts and /source/extensions/self-modification/extension.ts; modify whichever exists. If neither file exists, this subagent is the bundled eve development default and is using the default settings: first call registry_add with the exact address eve/self-modification to scaffold the authored mount. This known scaffold does not require search_registry.
12
12
 
13
13
  After registry_add reports successful installation, try to read /source/extensions/self-modification.ts and /source/extensions/self-modification/extension.ts. If either is available, modify it. If neither is yet available, you may need to wait for the next turn, by asking the requester to confirm.`,`## Implement changes
14
14
 
@@ -26,11 +26,11 @@ Modifying the behavior of an existing skill or tool does not require a registry
26
26
 
27
27
  Registry installation is outside the source sandbox.`,`## Consult documentation
28
28
 
29
- The eve framework documentation is mounted read-only at /eve-docs. Prefer source and existing local patterns. Before reading docs, identify the specific unresolved API question. Search the relevant file for its heading or term, then read only the bounded surrounding section. Do not concatenate wildcard files or read a full page when a section answers the question. Stop when the question is resolved.`,t===`local`?"## Local environment\n\nThe registry_add tool will complete installation for items that need no setup. In the local dev TUI, a `needs-terminal` result from the tool call automatically opens the existing setup panel for the user to complete setup there. In headless development, if a `needs-terminal` result includes `nextCommand`, present that exact value as the only shell command in your response. Never infer, construct, or rewrite a command: installing an item uses `eve add <item>`; `eve registry add` configures registry namespace mappings and does not install items.\n\nLocal eve dev logs are available read-only at /logs.\nLocal trace segments are mounted read-only at /traces when available. Inspect other traces only when the user asks about another session or broader behavior.\n\nThe application package.json is not mounted. Do not search outside /source for application files. You cannot run host binaries such as git, node, pnpm, or tsc. Use existing imports and registry_add for supported registry installations.":"## Deployed environment\n\nThe registry_add tool may return `completed`, `input-required`, `external-action-required`, `cancelled`, or `failed`. Supply only non-secret structured answers when continuing an `input-required` setup; set `installed: true` so the continuation does not reinstall source. Never request, accept, or repeat secret values. External authorization and secret binding are incomplete follow-up boundaries, not evidence that an integration is active.\n\nThe configured target branch is checked out as a disposable workspace under /workspace/repository. Make ordinary changes through /source, which is the writable view of the configured application's agent/ directory. Publication validates the final repository snapshot, including registry, manifest, and lockfile changes. Never modify Git refs, access GitHub directly, or use shell commands to write files. The sandbox has no reusable GitHub credential after checkout.\n\nComplete all edits and registry installations before publication, and call publish by itself. Before publication, review and summarize the complete intended scope. Call publish once with a concise title and summary. A successful result is only a draft pull request. Return its URL and changed paths, and state that merge and deployment have not occurred.",t===`local`?localTraceGuidance(e):``,`## Work efficiently
29
+ The eve framework documentation is mounted read-only at /eve-docs. Prefer source and existing local patterns. Before reading docs, identify the specific unresolved API question. Search the relevant file for its heading or term, then read only the bounded surrounding section. Do not concatenate wildcard files or read a full page when a section answers the question. Stop when the question is resolved.`,e===`local`?"## Local environment\n\nThe registry_add tool will complete installation for items that need no setup. In the local dev TUI, a `needs-terminal` result from the tool call automatically opens the existing setup panel for the user to complete setup there. In headless development, if a `needs-terminal` result includes `nextCommand`, present that exact value as the only shell command in your response. Never infer, construct, or rewrite a command: installing an item uses `eve add <item>`; `eve registry add` configures registry namespace mappings and does not install items.\n\nLocal eve dev logs are mounted read-only at /logs. Local trace segments are mounted read-only at /traces when available. For latency, failure, token, or behavior analysis, load and follow the `trace_analysis` skill. Trace searches are scoped to the invoking conversation and exclude the current investigation by default.\n\nThe application package.json is not mounted. Do not search outside /source for application files. You cannot run host binaries such as git, node, pnpm, or tsc. Use existing imports and registry_add for supported registry installations.":"## Deployed environment\n\nThe registry_add tool may return `completed`, `input-required`, `external-action-required`, `cancelled`, or `failed`. Supply only non-secret structured answers when continuing an `input-required` setup; set `installed: true` so the continuation does not reinstall source. Never request, accept, or repeat secret values. External authorization and secret binding are incomplete follow-up boundaries, not evidence that an integration is active.\n\nThe configured target branch is checked out as a disposable workspace under /workspace/repository. Make ordinary changes through /source, which is the writable view of the configured application's agent/ directory. Publication validates the final repository snapshot, including registry, manifest, and lockfile changes. Never modify Git refs, access GitHub directly, or use shell commands to write files. The sandbox has no reusable GitHub credential after checkout.\n\nComplete all edits and registry installations before publication, and call publish by itself. Before publication, review and summarize the complete intended scope. Call publish once with a concise title and summary. A successful result is only a draft pull request. Return its URL and changed paths, and state that merge and deployment have not occurred.",`## Work efficiently
30
30
 
31
31
  Skip task lists for simple work - only use them for complex actions. Never spend a turn only reporting status or updating the task list - batch them with other calls.
32
32
 
33
- Treat a successful file-edit tool result as confirmation; do not reread a file solely to verify that the edit succeeded. Do not approximate unavailable build or test commands with broad source searches.`,t===`local`?`## Report results
33
+ Treat a successful file-edit tool result as confirmation; do not reread a file solely to verify that the edit succeeded. Do not approximate unavailable build or test commands with broad source searches.`,e===`local`?`## Report results
34
34
 
35
35
  For source-modification tasks, return a concise handoff to the caller. Use at most four short bullets covering changed paths and behavior, and any required setup or unresolved issues.
36
36
 
@@ -0,0 +1,10 @@
1
+ import type { ResolvedSelfModificationConfig } from "../../../../config.js";
2
+ export declare function resolveTraceAnalysisSkill(config: ResolvedSelfModificationConfig): {
3
+ description: string;
4
+ markdown: string;
5
+ } | null;
6
+ declare const _default: import("eve/skills").DynamicSentinel<{
7
+ description: string;
8
+ markdown: string;
9
+ } | null>;
10
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import{defineLocalOnlyDynamic,resolveLocalOnly}from"../../../local-only.js";import{defineSkill}from"eve/skills";const traceAnalysisSkill=defineSkill({description:`Analyze local eve traces for latency, token usage, failures, repeated tool calls, and discovery inefficiency with a bounded, conversation-scoped investigation.`,markdown:`# Trace analysis
2
+
3
+ Use this workflow when the user asks to review, diagnose, or optimize behavior from local traces.
4
+
5
+ ## Keep the investigation bounded
6
+
7
+ 1. Call \`search_traces\` once with \`limit\` no greater than 5. It is already scoped to the invoking conversation, including its child-agent traces, and excludes the current investigation by default.
8
+ 2. Rank findings across correctness, latency, token usage, and tool-call efficiency. Follow the user's stated priority; do not assume that "improve" means only fixing errors.
9
+ 3. Call \`inspect_trace\` only for the one or two traces needed to explain a high-impact signal. Set \`limit\` to the smallest useful bound, normally 20–40. Its timeline includes bounded argument previews and \`availableFields\` for each span.
10
+ 4. Use \`inspect_trace_spans\` only with span ids returned by a timeline. Include only the required payload fields and batch related spans in one call. An empty \`availableFields\` list means none are recorded, not that the call failed.
11
+ 5. Use the read-only \`/logs\` mount only to corroborate a specific runtime error that the structural trace cannot explain. Search a literal diagnostic fragment with bounded output before reading a file. With no observed failure, skip broad log searches and speculative web searches for possible failures.
12
+ 6. Inspect \`/source\` or \`/eve-docs\` only when evidence points to a persistent authored change or an unresolved API question.
13
+
14
+ Prefer three analysis rounds or fewer. Do not read raw trace segments, search the whole filesystem, or enumerate broad documentation when the bounded tools answer the question.
15
+
16
+ Search and inspection share the same summary. Its durationMs is elapsed time; inspection's modelWorkMs and toolWorkMs sum operation time and may exceed elapsed time when calls overlap. errorSpanCount counts error-bearing spans, not independent failures or final activation outcome; failures ranking uses this count. Token totals sum step usage without counting repeated model counters.
17
+
18
+ For latency, distinguish tool execution time from model round-trip time. Repeated tool counts are leads, not proof that calls are independent; inspect the compact timeline before recommending batching. Report the highest-impact opportunities first.
19
+ `});function resolveTraceAnalysisSkill(e){return resolveLocalOnly(e,traceAnalysisSkill)}var trace_analysis_default=defineLocalOnlyDynamic(traceAnalysisSkill);export{trace_analysis_default as default,resolveTraceAnalysisSkill};
@@ -0,0 +1,128 @@
1
+ import type { ResolvedSelfModificationConfig } from "../../../../config.js";
2
+ export declare function resolveInspectTraceTool(config: ResolvedSelfModificationConfig): (import("eve/tools").ToolDefinition<Record<string, unknown>, {
3
+ traceId: string;
4
+ offset: number;
5
+ timeline: {
6
+ actionDurationMs?: number;
7
+ actionName?: string;
8
+ callId?: string;
9
+ category: "model" | "other" | "tool";
10
+ durationMs: number;
11
+ endOffsetMs: number;
12
+ error?: string;
13
+ model?: string;
14
+ outcome: "completed" | "failed";
15
+ parentSpanId?: string;
16
+ sessionId?: string;
17
+ spanId: string;
18
+ startOffsetMs: number;
19
+ toolName?: string;
20
+ turnId?: string;
21
+ usage?: import("#tracing/local-trace-analysis.js").TraceTokenUsage;
22
+ availableFields: ("arguments" | "error" | "result")[];
23
+ argumentsPreview?: string | undefined;
24
+ }[];
25
+ summary: import("../../../../../tracing/local-trace-summary.ts").LocalTraceSummary;
26
+ modelWorkMs: number;
27
+ toolWorkMs: number;
28
+ groups: readonly import("#tracing/local-trace-analysis.js").TraceAnalysisGroup[];
29
+ total: number;
30
+ hasMore: boolean;
31
+ truncated: boolean;
32
+ }> & {
33
+ execute(input: Record<string, unknown>, ctx: import("eve/tools").ToolContext): Promise<{
34
+ traceId: string;
35
+ offset: number;
36
+ timeline: {
37
+ actionDurationMs?: number;
38
+ actionName?: string;
39
+ callId?: string;
40
+ category: "model" | "other" | "tool";
41
+ durationMs: number;
42
+ endOffsetMs: number;
43
+ error?: string;
44
+ model?: string;
45
+ outcome: "completed" | "failed";
46
+ parentSpanId?: string;
47
+ sessionId?: string;
48
+ spanId: string;
49
+ startOffsetMs: number;
50
+ toolName?: string;
51
+ turnId?: string;
52
+ usage?: import("#tracing/local-trace-analysis.js").TraceTokenUsage;
53
+ availableFields: ("arguments" | "error" | "result")[];
54
+ argumentsPreview?: string | undefined;
55
+ }[];
56
+ summary: import("../../../../../tracing/local-trace-summary.ts").LocalTraceSummary;
57
+ modelWorkMs: number;
58
+ toolWorkMs: number;
59
+ groups: readonly import("#tracing/local-trace-analysis.js").TraceAnalysisGroup[];
60
+ total: number;
61
+ hasMore: boolean;
62
+ truncated: boolean;
63
+ }>;
64
+ }) | null;
65
+ declare const _default: import("eve/tools").DynamicSentinel<(import("eve/tools").ToolDefinition<Record<string, unknown>, {
66
+ traceId: string;
67
+ offset: number;
68
+ timeline: {
69
+ actionDurationMs?: number;
70
+ actionName?: string;
71
+ callId?: string;
72
+ category: "model" | "other" | "tool";
73
+ durationMs: number;
74
+ endOffsetMs: number;
75
+ error?: string;
76
+ model?: string;
77
+ outcome: "completed" | "failed";
78
+ parentSpanId?: string;
79
+ sessionId?: string;
80
+ spanId: string;
81
+ startOffsetMs: number;
82
+ toolName?: string;
83
+ turnId?: string;
84
+ usage?: import("#tracing/local-trace-analysis.js").TraceTokenUsage;
85
+ availableFields: ("arguments" | "error" | "result")[];
86
+ argumentsPreview?: string | undefined;
87
+ }[];
88
+ summary: import("../../../../../tracing/local-trace-summary.ts").LocalTraceSummary;
89
+ modelWorkMs: number;
90
+ toolWorkMs: number;
91
+ groups: readonly import("#tracing/local-trace-analysis.js").TraceAnalysisGroup[];
92
+ total: number;
93
+ hasMore: boolean;
94
+ truncated: boolean;
95
+ }> & {
96
+ execute(input: Record<string, unknown>, ctx: import("eve/tools").ToolContext): Promise<{
97
+ traceId: string;
98
+ offset: number;
99
+ timeline: {
100
+ actionDurationMs?: number;
101
+ actionName?: string;
102
+ callId?: string;
103
+ category: "model" | "other" | "tool";
104
+ durationMs: number;
105
+ endOffsetMs: number;
106
+ error?: string;
107
+ model?: string;
108
+ outcome: "completed" | "failed";
109
+ parentSpanId?: string;
110
+ sessionId?: string;
111
+ spanId: string;
112
+ startOffsetMs: number;
113
+ toolName?: string;
114
+ turnId?: string;
115
+ usage?: import("#tracing/local-trace-analysis.js").TraceTokenUsage;
116
+ availableFields: ("arguments" | "error" | "result")[];
117
+ argumentsPreview?: string | undefined;
118
+ }[];
119
+ summary: import("../../../../../tracing/local-trace-summary.ts").LocalTraceSummary;
120
+ modelWorkMs: number;
121
+ toolWorkMs: number;
122
+ groups: readonly import("#tracing/local-trace-analysis.js").TraceAnalysisGroup[];
123
+ total: number;
124
+ hasMore: boolean;
125
+ truncated: boolean;
126
+ }>;
127
+ }) | null>;
128
+ export default _default;
@@ -0,0 +1 @@
1
+ import{defineLocalOnlyDynamic,resolveLocalOnly}from"../../../local-only.js";import{TRACE_ID,boundedText,detailFields,readTraceSources}from"../../../trace-inspection.js";import{defineTool}from"eve/tools";import{analyzeLocalTrace}from"#tracing/local-trace-analysis.js";const MAX_OFFSET=1e5,inspectTraceTool=defineTool({description:`Inspect one trace as a bounded structural timeline. Use offset to page through larger traces. Tool records include a short argument preview and availableFields; use inspect_trace_spans only for selected raw tool payloads.`,inputSchema:{type:`object`,additionalProperties:!1,properties:{limit:{type:`integer`,minimum:1,maximum:200},offset:{type:`integer`,minimum:0,maximum:MAX_OFFSET,description:`Zero-based record offset for paging through larger traces.`},traceId:{type:`string`,pattern:`^[0-9a-f]{32}$`}},required:[`traceId`]},outputSchema:{type:`object`,additionalProperties:!0},async execute(e,t){let{limit:n,offset:r,traceId:i}=parseInput(e),a=await readTraceSources(i,t),o=analyzeLocalTrace(i,a.map(({span:e})=>e)),s=new Map(a.map(e=>[e.span.spanId,e])),c=o.records.slice(r,r+n).map(e=>{let t=s.get(e.spanId),n=t===void 0?void 0:detailFields(t),r=n===void 0?[]:[`arguments`,`result`,`error`].filter(e=>typeof n[e]==`string`),i=n?.arguments;return{...boundedRecord(e),availableFields:r,...e.category===`tool`&&typeof i==`string`?{argumentsPreview:boundedText(i,200)}:{}}});return{traceId:i,offset:r,timeline:c,summary:o.summary,modelWorkMs:o.modelWorkMs,toolWorkMs:o.toolWorkMs,groups:o.groups,total:o.records.length,hasMore:r+c.length<o.records.length,truncated:r+c.length<o.records.length}}});function resolveInspectTraceTool(e){return resolveLocalOnly(e,inspectTraceTool)}var inspect_trace_default=defineLocalOnlyDynamic(inspectTraceTool);function parseInput(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Trace inspection input must be an object.`);let t=e;if(typeof t.traceId!=`string`||!TRACE_ID.test(t.traceId))throw Error(`traceId must be a lowercase 32-character hex id.`);if(t.limit!==void 0&&(typeof t.limit!=`number`||!Number.isInteger(t.limit)||t.limit<1||t.limit>200))throw Error(`limit must be an integer between 1 and 200.`);if(t.offset!==void 0&&(typeof t.offset!=`number`||!Number.isInteger(t.offset)||t.offset<0||t.offset>MAX_OFFSET))throw Error(`offset must be an integer between 0 and ${MAX_OFFSET}.`);return{limit:t.limit??40,offset:t.offset??0,traceId:t.traceId}}function boundedRecord(e){return e.error===void 0?e:{...e,error:boundedText(e.error,500)}}export{inspect_trace_default as default,resolveInspectTraceTool};
@@ -0,0 +1,80 @@
1
+ import type { ResolvedSelfModificationConfig } from "../../../../config.js";
2
+ export declare function resolveInspectTraceSpansTool(config: ResolvedSelfModificationConfig): (import("eve/tools").ToolDefinition<Record<string, unknown>, {
3
+ traceId: string;
4
+ spans: ({
5
+ spanId: string;
6
+ found: boolean;
7
+ availableFields?: undefined;
8
+ fields?: undefined;
9
+ rawPath?: undefined;
10
+ truncated?: undefined;
11
+ } | {
12
+ spanId: string;
13
+ found: boolean;
14
+ availableFields: ("arguments" | "error" | "result")[];
15
+ fields: Record<string, string>;
16
+ rawPath: string;
17
+ truncated: boolean;
18
+ })[];
19
+ truncated: boolean;
20
+ }> & {
21
+ execute(input: Record<string, unknown>, ctx: import("eve/tools").ToolContext): Promise<{
22
+ traceId: string;
23
+ spans: ({
24
+ spanId: string;
25
+ found: boolean;
26
+ availableFields?: undefined;
27
+ fields?: undefined;
28
+ rawPath?: undefined;
29
+ truncated?: undefined;
30
+ } | {
31
+ spanId: string;
32
+ found: boolean;
33
+ availableFields: ("arguments" | "error" | "result")[];
34
+ fields: Record<string, string>;
35
+ rawPath: string;
36
+ truncated: boolean;
37
+ })[];
38
+ truncated: boolean;
39
+ }>;
40
+ }) | null;
41
+ declare const _default: import("eve/tools").DynamicSentinel<(import("eve/tools").ToolDefinition<Record<string, unknown>, {
42
+ traceId: string;
43
+ spans: ({
44
+ spanId: string;
45
+ found: boolean;
46
+ availableFields?: undefined;
47
+ fields?: undefined;
48
+ rawPath?: undefined;
49
+ truncated?: undefined;
50
+ } | {
51
+ spanId: string;
52
+ found: boolean;
53
+ availableFields: ("arguments" | "error" | "result")[];
54
+ fields: Record<string, string>;
55
+ rawPath: string;
56
+ truncated: boolean;
57
+ })[];
58
+ truncated: boolean;
59
+ }> & {
60
+ execute(input: Record<string, unknown>, ctx: import("eve/tools").ToolContext): Promise<{
61
+ traceId: string;
62
+ spans: ({
63
+ spanId: string;
64
+ found: boolean;
65
+ availableFields?: undefined;
66
+ fields?: undefined;
67
+ rawPath?: undefined;
68
+ truncated?: undefined;
69
+ } | {
70
+ spanId: string;
71
+ found: boolean;
72
+ availableFields: ("arguments" | "error" | "result")[];
73
+ fields: Record<string, string>;
74
+ rawPath: string;
75
+ truncated: boolean;
76
+ })[];
77
+ truncated: boolean;
78
+ }>;
79
+ }) | null>;
80
+ export default _default;
@@ -0,0 +1 @@
1
+ import{defineLocalOnlyDynamic,resolveLocalOnly}from"../../../local-only.js";import{SPAN_ID,TRACE_ID,detailFields,readTraceSources}from"../../../trace-inspection.js";import{defineTool}from"eve/tools";const FIELDS=[`arguments`,`result`,`error`],inputSchema={type:`object`,additionalProperties:!1,properties:{include:{type:`array`,minItems:1,maxItems:FIELDS.length,items:{enum:FIELDS,type:`string`}},spanIds:{type:`array`,minItems:1,maxItems:10,items:{type:`string`,pattern:`^[0-9a-f]{16}$`}},traceId:{type:`string`,pattern:`^[0-9a-f]{32}$`}},required:[`traceId`,`spanIds`,`include`]},inspectTraceSpansTool=defineTool({description:`Return bounded arguments, results, or errors for selected spans in one trace. First use inspect_trace to choose spanIds and see availableFields.`,inputSchema,outputSchema:{type:`object`,additionalProperties:!0},async execute(e,t){let{include:n,spanIds:r,traceId:i}=parseInput(e),a=new Map((await readTraceSources(i,t)).map(e=>[e.span.spanId,e])),o=32768,s=!1;return{traceId:i,spans:r.map(e=>{let t=a.get(e);if(t===void 0)return{spanId:e,found:!1};let r=detailFields(t),c=FIELDS.filter(e=>typeof r[e]==`string`),l={},u=!1;for(let e of n){let t=r[e];if(typeof t!=`string`)continue;let n=Math.min(16384,o);l[e]=t.slice(0,n),o-=l[e].length,t.length>n&&(u=!0)}return s||=u,{spanId:e,found:!0,availableFields:c,fields:l,rawPath:`/traces/${i}/segments/${t.segmentFile}`,truncated:u}}),truncated:s}}});function resolveInspectTraceSpansTool(e){return resolveLocalOnly(e,inspectTraceSpansTool)}var inspect_trace_spans_default=defineLocalOnlyDynamic(inspectTraceSpansTool);function parseInput(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Trace span inspection input must be an object.`);let t=e;if(typeof t.traceId!=`string`||!TRACE_ID.test(t.traceId))throw Error(`traceId must be a lowercase 32-character hex id.`);if(!Array.isArray(t.spanIds)||t.spanIds.length===0||t.spanIds.length>10||t.spanIds.some(e=>typeof e!=`string`||!SPAN_ID.test(e)))throw Error(`spanIds must contain between 1 and 10 lowercase span ids.`);if(!Array.isArray(t.include)||t.include.length===0||t.include.length>FIELDS.length||t.include.some(e=>!FIELDS.includes(e)))throw Error(`include must contain arguments, result, or error.`);return{include:t.include,spanIds:[...new Set(t.spanIds)],traceId:t.traceId}}export{inspect_trace_spans_default as default,resolveInspectTraceSpansTool};
@@ -1 +1 @@
1
- import{resolveSelfModificationConfig}from"../../../../config.js";import{classifyCatalogEntry}from"../../../classify-registry-item.js";import{runEveAdd}from"../../../eve-add.js";import extension_default from"../../../extension.js";import{assertOfficialRegistryAddress,installProductionRegistryItem}from"../../../production-registry-add.js";import{resolveSelfModificationMode}from"../../../../mode.js";import{readPreparedSelfModificationWorkspace}from"../../../../git-workspace.js";import{withSelfModificationWorkspaceLock}from"../../../../workspace-lock.js";import{loadRegistryIndex,officialRegistryIndexUrl,resolveRegistryIndexUrl}from"./search_registry.js";import{defineDynamic,defineTool}from"eve/tools";import{once}from"eve/tools/approval";import{getLocalDevCapability}from"eve/local-dev";const localInputSchema={type:`object`,additionalProperties:!1,properties:{address:{type:`string`,minLength:1,maxLength:200,description:"Exact address of an item in the configured eve registry, for example `channel/slack` or `extension/browserbase`."}},required:[`address`]},localOutputSchema={type:`object`,additionalProperties:!1,properties:{status:{type:`string`,enum:[`installed`,`needs-terminal`,`failed`]},address:{type:`string`},title:{type:`string`},envVars:{type:`array`,items:{type:`string`},description:`Environment variables the item needs that are not set. The item is installed but will not work until the developer sets them. Never ask for or repeat their values.`},reason:{type:`string`,description:`Why the item was not installed here.`},changed:{type:`array`,items:{type:`string`},description:`Project-relative paths a failed install could not restore.`},nextCommand:{type:`string`,description:"The command that completes a `needs-terminal` item."},message:{type:`string`,description:`One-line summary to relay to the developer.`}},required:[`status`,`address`,`message`]},productionInputSchema={type:`object`,additionalProperties:!1,properties:{address:{type:`string`,minLength:1,maxLength:200,description:"Exact official eve registry address, for example `channel/slack` or `extension/browserbase`."},answers:{type:`object`,additionalProperties:!0,description:`Non-secret answers to the setup question returned by the previous call.`},installed:{type:`boolean`,description:`Set to true with answers when the previous input-required result installed the source.`}},required:[`address`]},productionOutputSchema={type:`object`,additionalProperties:!1,properties:{status:{type:`string`,enum:[`completed`,`input-required`,`external-action-required`,`failed`,`cancelled`]},address:{type:`string`},changedPaths:{type:`array`,items:{type:`string`},description:`Repository-relative paths installed into the proposal.`},completedItems:{type:`array`,items:{type:`string`}},deploymentRequired:{type:`boolean`},installed:{type:`boolean`,description:`Whether source installation completed before setup paused.`},question:{type:`object`,additionalProperties:!0,description:`The current setup question. Supply only its non-secret answer on the next call.`},message:{type:`string`},url:{type:`string`,description:`External authorization URL the developer must open.`},userCode:{type:`string`}},required:[`status`,`address`]};function unsetEnvVars(e,t=process.env){return(e.envVars??[]).filter(e=>{let n=t[e];return n===void 0||n===``})}function handoffMessage(e){if(e.interactiveClient)return{message:`${e.title} was not installed by this tool. ${e.reason} Continue in the setup panel that opens here; do not ask the developer to run another command.`};let t=`eve add ${e.address}`;return{message:`${e.title} was not installed. ${e.reason} Run \`${t}\` in a terminal to finish it.`,nextCommand:t}}async function addLocalRegistryItem(e,t={}){let n=(t.getCapability??getLocalDevCapability)();if(n===void 0)throw Error("Registry items can only be installed while `eve dev` is running. Report the item address to the developer instead of installing it.");let r=(await loadRegistryIndex({nowMs:Date.now(),signal:t.signal,url:resolveRegistryIndexUrl()})).find(t=>t.address===e);if(r===void 0)throw Error(`No item in the configured eve registry is published at "${e}". Check the address before trying again.`);let i=classifyCatalogEntry(r);if(i.kind===`needs-terminal`){let t=handoffMessage({address:e,interactiveClient:n.interactiveClient,reason:i.reason,title:r.title});return{address:e,reason:i.reason,status:`needs-terminal`,title:r.title,...t}}let a=await withSelfModificationWorkspaceLock(`local:${n.appRoot}`,async()=>n.withSuspendedSource(()=>runEveAdd({address:e,appRoot:n.appRoot,signal:t.signal,spawn:t.spawn})));if(a.kind===`blocked`){let t=handoffMessage({address:e,interactiveClient:n.interactiveClient,reason:a.message,title:r.title});return{address:e,reason:a.message,status:`needs-terminal`,title:r.title,...t}}if(a.kind===`failed`)return a.changed===void 0?{address:e,status:`failed`,title:r.title,reason:a.message,message:a.message}:{address:e,status:`failed`,title:r.title,reason:a.message,message:a.message,changed:a.changed};let o=unsetEnvVars(r);return{address:e,envVars:[...o],message:o.length===0?`Installed ${r.title}.`:`Installed ${r.title}. It will not work until ${o.join(`, `)} ${o.length===1?`is`:`are`} set.`,status:`installed`,title:r.title}}async function addProductionRegistryItem(e,t,n,r){if(assertOfficialRegistryAddress(e),(await loadRegistryIndex({nowMs:Date.now(),signal:t.abortSignal,url:officialRegistryIndexUrl()})).find(t=>t.address===e)===void 0)throw Error(`No official eve registry item is published at "${e}".`);let i=await t.getSandbox(),a=await withSelfModificationWorkspaceLock(`sandbox:${t.session.id}`,async()=>{let a=await readPreparedSelfModificationWorkspace({...n,sandbox:i});return await installProductionRegistryItem({address:e,answers:r.answers,installed:r.installed,sandbox:i,signal:t.abortSignal,workspace:a})});return a.kind===`completed`?{address:e,...a,status:`completed`}:a.kind===`input-required`?{address:e,...a,status:`input-required`}:a.kind===`external-action-required`?{address:e,...a,status:`external-action-required`}:{address:e,...a,status:a.kind}}function localRegistryAddTool(){return defineTool({approval:once(),description:`Install an item from the configured eve registry into this project. Items that need setup are handed to the local setup flow instead. Search first, then call this with the exact item address.`,inputSchema:localInputSchema,outputSchema:localOutputSchema,async execute(e,t){let{address:n}=e;if(typeof n!=`string`||n.length===0)throw Error(`address must be an exact item address from the configured eve registry.`);return await addLocalRegistryItem(n,{signal:t.abortSignal})}})}function productionRegistryAddTool(e){return defineTool({approval:once(),description:`Install an exact item from the official eve registry into the current production change proposal. If setup pauses, call this tool again with the non-secret answers and the installed state from its result. External authorization and secret binding must be completed by the developer.`,inputSchema:productionInputSchema,outputSchema:productionOutputSchema,async execute(t,n){let{address:r}=t;if(typeof r!=`string`||r.length===0)throw Error(`address must be an exact item address from the official eve registry.`);return await addProductionRegistryItem(r,n,e,{answers:`answers`in t&&typeof t.answers==`object`&&t.answers!==null&&!Array.isArray(t.answers)?t.answers:void 0,installed:`installed`in t&&t.installed===!0})}})}function resolveRegistryAddTool(e){let t=resolveSelfModificationMode(e);return t===`local`?localRegistryAddTool():t===`deployed`&&e.deployed!==void 0?productionRegistryAddTool(e.deployed):null}var registry_add_default=defineDynamic({events:{"session.started":()=>resolveRegistryAddTool(resolveSelfModificationConfig(extension_default.config))}});export{addLocalRegistryItem,registry_add_default as default,handoffMessage,resolveRegistryAddTool,unsetEnvVars};
1
+ import{resolveSelfModificationConfig}from"../../../../config.js";import{classifyCatalogEntry}from"../../../classify-registry-item.js";import{runEveAdd}from"../../../eve-add.js";import extension_default from"../../../extension.js";import{resolveSelfModificationMode}from"../../../../mode.js";import{assertOfficialRegistryAddress,installProductionRegistryItem}from"../../../production-registry-add.js";import{readPreparedSelfModificationWorkspace}from"../../../../git-workspace.js";import{withSelfModificationWorkspaceLock}from"../../../../workspace-lock.js";import{loadRegistryIndex,officialRegistryIndexUrl,resolveRegistryIndexUrl}from"./search_registry.js";import{defineDynamic,defineTool}from"eve/tools";import{once}from"eve/tools/approval";import{getLocalDevCapability}from"eve/local-dev";const localInputSchema={type:`object`,additionalProperties:!1,properties:{address:{type:`string`,minLength:1,maxLength:200,description:"Exact address of an item in the configured eve registry, for example `channel/slack` or `extension/browserbase`."}},required:[`address`]},localOutputSchema={type:`object`,additionalProperties:!1,properties:{status:{type:`string`,enum:[`installed`,`needs-terminal`,`failed`]},address:{type:`string`},title:{type:`string`},envVars:{type:`array`,items:{type:`string`},description:`Environment variables the item needs that are not set. The item is installed but will not work until the developer sets them. Never ask for or repeat their values.`},reason:{type:`string`,description:`Why the item was not installed here.`},changed:{type:`array`,items:{type:`string`},description:`Project-relative paths a failed install could not restore.`},nextCommand:{type:`string`,description:"The command that completes a `needs-terminal` item."},message:{type:`string`,description:`One-line summary to relay to the developer.`}},required:[`status`,`address`,`message`]},productionInputSchema={type:`object`,additionalProperties:!1,properties:{address:{type:`string`,minLength:1,maxLength:200,description:"Exact official eve registry address, for example `channel/slack` or `extension/browserbase`."},answers:{type:`object`,additionalProperties:!0,description:`Non-secret answers to the setup question returned by the previous call.`},installed:{type:`boolean`,description:`Set to true with answers when the previous input-required result installed the source.`}},required:[`address`]},productionOutputSchema={type:`object`,additionalProperties:!1,properties:{status:{type:`string`,enum:[`completed`,`input-required`,`external-action-required`,`failed`,`cancelled`]},address:{type:`string`},changedPaths:{type:`array`,items:{type:`string`},description:`Repository-relative paths installed into the proposal.`},completedItems:{type:`array`,items:{type:`string`}},deploymentRequired:{type:`boolean`},installed:{type:`boolean`,description:`Whether source installation completed before setup paused.`},question:{type:`object`,additionalProperties:!0,description:`The current setup question. Supply only its non-secret answer on the next call.`},message:{type:`string`},url:{type:`string`,description:`External authorization URL the developer must open.`},userCode:{type:`string`}},required:[`status`,`address`]};function unsetEnvVars(e,t=process.env){return(e.envVars??[]).filter(e=>{let n=t[e];return n===void 0||n===``})}function handoffMessage(e){if(e.interactiveClient)return{message:`${e.title} was not installed by this tool. ${e.reason} Continue in the setup panel that opens here; do not ask the developer to run another command.`};let t=`eve add ${e.address}`;return{message:`${e.title} was not installed. ${e.reason} Run \`${t}\` in a terminal to finish it.`,nextCommand:t}}async function addLocalRegistryItem(e,t={}){let n=(t.getCapability??getLocalDevCapability)();if(n===void 0)throw Error("Registry items can only be installed while `eve dev` is running. Report the item address to the developer instead of installing it.");let r=(await loadRegistryIndex({nowMs:Date.now(),signal:t.signal,url:resolveRegistryIndexUrl()})).find(t=>t.address===e);if(r===void 0)throw Error(`No item in the configured eve registry is published at "${e}". Check the address before trying again.`);let i=classifyCatalogEntry(r);if(i.kind===`needs-terminal`){let t=handoffMessage({address:e,interactiveClient:n.interactiveClient,reason:i.reason,title:r.title});return{address:e,reason:i.reason,status:`needs-terminal`,title:r.title,...t}}let a=await withSelfModificationWorkspaceLock(`local:${n.appRoot}`,async()=>n.withSuspendedSource(()=>runEveAdd({address:e,appRoot:n.appRoot,signal:t.signal,spawn:t.spawn})));if(a.kind===`blocked`){let t=handoffMessage({address:e,interactiveClient:n.interactiveClient,reason:a.message,title:r.title});return{address:e,reason:a.message,status:`needs-terminal`,title:r.title,...t}}if(a.kind===`failed`)return a.changed===void 0?{address:e,status:`failed`,title:r.title,reason:a.message,message:a.message}:{address:e,status:`failed`,title:r.title,reason:a.message,message:a.message,changed:a.changed};let o=unsetEnvVars(r);return{address:e,envVars:[...o],message:o.length===0?`Installed ${r.title}.`:`Installed ${r.title}. It will not work until ${o.join(`, `)} ${o.length===1?`is`:`are`} set.`,status:`installed`,title:r.title}}async function addProductionRegistryItem(e,t,n,r){if(assertOfficialRegistryAddress(e),(await loadRegistryIndex({nowMs:Date.now(),signal:t.abortSignal,url:officialRegistryIndexUrl()})).find(t=>t.address===e)===void 0)throw Error(`No official eve registry item is published at "${e}".`);let i=await t.getSandbox(),a=await withSelfModificationWorkspaceLock(`sandbox:${t.session.id}`,async()=>{let a=await readPreparedSelfModificationWorkspace({...n,sandbox:i});return await installProductionRegistryItem({address:e,answers:r.answers,installed:r.installed,sandbox:i,signal:t.abortSignal,workspace:a})});return a.kind===`completed`?{address:e,...a,status:`completed`}:a.kind===`input-required`?{address:e,...a,status:`input-required`}:a.kind===`external-action-required`?{address:e,...a,status:`external-action-required`}:{address:e,...a,status:a.kind}}function localRegistryAddTool(){return defineTool({approval:once(),description:`Install an item from the configured eve registry into this project. Items that need setup are handed to the local setup flow instead. Search first, then call this with the exact item address.`,inputSchema:localInputSchema,outputSchema:localOutputSchema,async execute(e,t){let{address:n}=e;if(typeof n!=`string`||n.length===0)throw Error(`address must be an exact item address from the configured eve registry.`);return await addLocalRegistryItem(n,{signal:t.abortSignal})}})}function productionRegistryAddTool(e){return defineTool({approval:once(),description:`Install an exact item from the official eve registry into the current production change proposal. If setup pauses, call this tool again with the non-secret answers and the installed state from its result. External authorization and secret binding must be completed by the developer.`,inputSchema:productionInputSchema,outputSchema:productionOutputSchema,async execute(t,n){let{address:r}=t;if(typeof r!=`string`||r.length===0)throw Error(`address must be an exact item address from the official eve registry.`);return await addProductionRegistryItem(r,n,e,{answers:`answers`in t&&typeof t.answers==`object`&&t.answers!==null&&!Array.isArray(t.answers)?t.answers:void 0,installed:`installed`in t&&t.installed===!0})}})}function resolveRegistryAddTool(e){let t=resolveSelfModificationMode(e);return t===`local`?localRegistryAddTool():t===`deployed`&&e.deployed!==void 0?productionRegistryAddTool(e.deployed):null}var registry_add_default=defineDynamic({events:{"session.started":()=>resolveRegistryAddTool(resolveSelfModificationConfig(extension_default.config))}});export{addLocalRegistryItem,registry_add_default as default,handoffMessage,resolveRegistryAddTool,unsetEnvVars};