eve 0.24.5 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/src/channel/cancel.d.ts +8 -0
  3. package/dist/src/channel/cancel.js +1 -0
  4. package/dist/src/channel/routes.d.ts +25 -4
  5. package/dist/src/channel/session.d.ts +10 -1
  6. package/dist/src/channel/session.js +1 -1
  7. package/dist/src/channel/types.d.ts +8 -0
  8. package/dist/src/chunks/{use-eve-agent-8rerxDHY.js → use-eve-agent-CQIeqmKc.js} +73 -66
  9. package/dist/src/chunks/{use-eve-agent-DhgdHzDG.js → use-eve-agent-Cy73lgA6.js} +73 -66
  10. package/dist/src/cli/commands/agent-instructions.js +1 -1
  11. package/dist/src/cli/commands/channels.js +1 -1
  12. package/dist/src/cli/commands/extension-build.d.ts +1 -1
  13. package/dist/src/cli/commands/extension-build.js +1 -1
  14. package/dist/src/client/output-schema.d.ts +0 -7
  15. package/dist/src/client/output-schema.js +1 -1
  16. package/dist/src/client/session.d.ts +6 -2
  17. package/dist/src/client/session.js +1 -1
  18. package/dist/src/compiler/extension-compatibility.d.ts +56 -0
  19. package/dist/src/compiler/extension-compatibility.js +1 -0
  20. package/dist/src/compiler/normalize-agent-config.js +1 -1
  21. package/dist/src/compiler/normalize-subagent.js +1 -1
  22. package/dist/src/context/build-dynamic-tools.js +1 -1
  23. package/dist/src/context/dynamic-tool-lifecycle.d.ts +1 -1
  24. package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
  25. package/dist/src/discover/discover-agent.d.ts +29 -7
  26. package/dist/src/discover/discover-agent.js +1 -1
  27. package/dist/src/discover/extensions.d.ts +43 -8
  28. package/dist/src/discover/extensions.js +1 -1
  29. package/dist/src/discover/filesystem.d.ts +3 -1
  30. package/dist/src/discover/filesystem.js +1 -1
  31. package/dist/src/discover/named-source-directory.js +1 -1
  32. package/dist/src/discover/skills.js +1 -1
  33. package/dist/src/evals/autoevals-client.js +2 -2
  34. package/dist/src/execution/node-step.js +1 -1
  35. package/dist/src/execution/sandbox/bindings/docker.js +1 -1
  36. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.d.ts +1 -1
  37. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -1
  38. package/dist/src/execution/sandbox/bindings/microsandbox-templates.js +1 -1
  39. package/dist/src/execution/sandbox/development-cleanup.d.ts +1 -1
  40. package/dist/src/execution/sandbox/development-cleanup.js +1 -1
  41. package/dist/src/execution/sandbox/development-run.d.ts +0 -3
  42. package/dist/src/execution/sandbox/development-run.js +1 -1
  43. package/dist/src/execution/sandbox/ensure.js +1 -1
  44. package/dist/src/execution/subagent-tool.js +1 -1
  45. package/dist/src/execution/workflow-runtime.js +1 -1
  46. package/dist/src/harness/emission.js +1 -1
  47. package/dist/src/harness/input-extraction.d.ts +10 -1
  48. package/dist/src/harness/input-extraction.js +1 -1
  49. package/dist/src/harness/input-requests.d.ts +12 -2
  50. package/dist/src/harness/input-requests.js +1 -1
  51. package/dist/src/harness/messages.d.ts +8 -1
  52. package/dist/src/harness/messages.js +1 -1
  53. package/dist/src/harness/stale-input-responses.d.ts +26 -0
  54. package/dist/src/harness/stale-input-responses.js +3 -0
  55. package/dist/src/harness/step-hooks.d.ts +1 -12
  56. package/dist/src/harness/step-hooks.js +1 -1
  57. package/dist/src/harness/tool-call-input-errors.d.ts +11 -0
  58. package/dist/src/harness/tool-call-input-errors.js +1 -1
  59. package/dist/src/harness/tool-loop.js +2 -2
  60. package/dist/src/harness/workflow-sandbox.d.ts +1 -1
  61. package/dist/src/harness/workflow-sandbox.js +1 -1
  62. package/dist/src/internal/application/optional-package-install.d.ts +5 -0
  63. package/dist/src/internal/application/optional-package-install.js +1 -1
  64. package/dist/src/internal/application/package.js +1 -1
  65. package/dist/src/internal/authored-definition/schema-backed.js +1 -1
  66. package/dist/src/internal/authored-module-loader.d.ts +17 -0
  67. package/dist/src/internal/authored-module-loader.js +2 -2
  68. package/dist/src/internal/authored-module-map-loader.js +1 -1
  69. package/dist/src/internal/authored-package-boundary.d.ts +8 -0
  70. package/dist/src/internal/authored-package-boundary.js +1 -1
  71. package/dist/src/internal/nitro/dev-runtime-source-snapshot.d.ts +4 -0
  72. package/dist/src/internal/nitro/dev-runtime-source-snapshot.js +1 -1
  73. package/dist/src/internal/nitro/host/build-extension.d.ts +6 -21
  74. package/dist/src/internal/nitro/host/build-extension.js +2 -4
  75. package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.js +1 -1
  76. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
  77. package/dist/src/internal/nitro/host/dev-workspace-extensions.d.ts +18 -0
  78. package/dist/src/internal/nitro/host/dev-workspace-extensions.js +1 -0
  79. package/dist/src/internal/nitro/host/extension-build-config.d.ts +18 -0
  80. package/dist/src/internal/nitro/host/extension-build-config.js +1 -0
  81. package/dist/src/internal/nitro/host/extension-capability-requirements.d.ts +10 -0
  82. package/dist/src/internal/nitro/host/extension-capability-requirements.js +1 -0
  83. package/dist/src/internal/nitro/host/extension-declarations.d.ts +10 -0
  84. package/dist/src/internal/nitro/host/extension-declarations.js +2 -0
  85. package/dist/src/internal/nitro/host/extension-distribution.d.ts +32 -0
  86. package/dist/src/internal/nitro/host/extension-distribution.js +3 -0
  87. package/dist/src/internal/nitro/host/extension-state-usage.d.ts +7 -0
  88. package/dist/src/internal/nitro/host/extension-state-usage.js +1 -0
  89. package/dist/src/internal/nitro/host/prepare-application-host.d.ts +5 -1
  90. package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
  91. package/dist/src/internal/nitro/host/start-development-server.js +2 -2
  92. package/dist/src/internal/nitro/host/types.d.ts +2 -0
  93. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
  94. package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
  95. package/dist/src/public/channels/index.d.ts +1 -1
  96. package/dist/src/public/definitions/channel.d.ts +1 -1
  97. package/dist/src/public/definitions/tool.d.ts +2 -2
  98. package/dist/src/public/tools/internal.js +1 -1
  99. package/dist/src/runtime/agent/mock-model-fixtures.js +2 -2
  100. package/dist/src/runtime/connections/openapi-client.js +1 -1
  101. package/dist/src/runtime/framework-tools/ask-question.d.ts +23 -9
  102. package/dist/src/runtime/framework-tools/ask-question.js +1 -1
  103. package/dist/src/runtime/framework-tools/bash.d.ts +10 -3
  104. package/dist/src/runtime/framework-tools/bash.js +1 -1
  105. package/dist/src/runtime/framework-tools/connection-search-dynamic.js +1 -1
  106. package/dist/src/runtime/framework-tools/final-output.d.ts +1 -1
  107. package/dist/src/runtime/framework-tools/final-output.js +1 -1
  108. package/dist/src/runtime/framework-tools/glob.d.ts +12 -3
  109. package/dist/src/runtime/framework-tools/glob.js +1 -1
  110. package/dist/src/runtime/framework-tools/grep.d.ts +16 -3
  111. package/dist/src/runtime/framework-tools/grep.js +1 -1
  112. package/dist/src/runtime/framework-tools/read-file.d.ts +13 -3
  113. package/dist/src/runtime/framework-tools/read-file.js +1 -1
  114. package/dist/src/runtime/framework-tools/skill.d.ts +5 -2
  115. package/dist/src/runtime/framework-tools/skill.js +1 -1
  116. package/dist/src/runtime/framework-tools/todo.d.ts +57 -10
  117. package/dist/src/runtime/framework-tools/todo.js +3 -3
  118. package/dist/src/runtime/framework-tools/web-fetch.d.ts +16 -3
  119. package/dist/src/runtime/framework-tools/web-fetch.js +1 -1
  120. package/dist/src/runtime/framework-tools/write-file.d.ts +9 -3
  121. package/dist/src/runtime/framework-tools/write-file.js +1 -1
  122. package/dist/src/runtime/loaders/compile-metadata.js +1 -1
  123. package/dist/src/runtime/loaders/manifest.js +1 -1
  124. package/dist/src/runtime/loaders/module-map.js +1 -1
  125. package/dist/src/runtime/resolve-tool.d.ts +4 -5
  126. package/dist/src/runtime/resolve-tool.js +1 -1
  127. package/dist/src/runtime/subagents/registry.d.ts +6 -3
  128. package/dist/src/runtime/subagents/registry.js +1 -1
  129. package/dist/src/runtime/tools/registry.js +1 -1
  130. package/dist/src/runtime/types.d.ts +7 -9
  131. package/dist/src/setup/boxes/deploy-project.d.ts +11 -1
  132. package/dist/src/setup/boxes/deploy-project.js +1 -1
  133. package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
  134. package/dist/src/setup/scaffold/create/extension.js +2 -2
  135. package/dist/src/setup/scaffold/create/project.js +2 -2
  136. package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
  137. package/dist/src/setup/scaffold/create/web-template.js +1 -0
  138. package/dist/src/setup/scaffold/update/channels.js +2 -2
  139. package/dist/src/setup/scaffold/update/connections.js +1 -1
  140. package/dist/src/setup/vercel-project-framework.d.ts +4 -2
  141. package/dist/src/shared/extension-package-contract.d.ts +11 -0
  142. package/dist/src/shared/extension-package-contract.js +1 -0
  143. package/dist/src/shared/json.d.ts +4 -0
  144. package/dist/src/shared/json.js +1 -1
  145. package/dist/src/shared/tool-schema.d.ts +52 -0
  146. package/dist/src/shared/tool-schema.js +1 -0
  147. package/dist/src/svelte/index.js +1 -1
  148. package/dist/src/svelte/use-eve-agent.js +1 -1
  149. package/dist/src/vue/index.js +1 -1
  150. package/dist/src/vue/use-eve-agent.js +1 -1
  151. package/docs/channels/custom.mdx +32 -2
  152. package/docs/concepts/sessions-runs-and-streaming.md +8 -0
  153. package/docs/extensions.md +22 -6
  154. package/docs/reference/cli.md +2 -2
  155. package/package.json +2 -2
  156. package/dist/src/internal/json-schema.d.ts +0 -1
  157. package/dist/src/internal/json-schema.js +0 -1
  158. package/dist/src/setup/boxes/reconcile-host-framework-preset.d.ts +0 -26
  159. package/dist/src/setup/boxes/reconcile-host-framework-preset.js +0 -1
  160. package/dist/src/shared/json-schema.d.ts +0 -9
  161. package/dist/src/shared/json-schema.js +0 -1
@@ -0,0 +1,56 @@
1
+ /** Stable kind for an extension distribution compatibility manifest. */
2
+ export declare const EXTENSION_COMPATIBILITY_MANIFEST_KIND = "eve-extension";
3
+ /** Current compatibility-manifest JSON format. */
4
+ export declare const EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION = 1;
5
+ /** Filename emitted at the root of an extension's agent-shaped dist tree. */
6
+ export declare const EXTENSION_COMPATIBILITY_MANIFEST_FILENAME = "_manifest.json";
7
+ /** Current producer contract version for each extension-facing capability. */
8
+ export declare const EXTENSION_CAPABILITY_VERSIONS: {
9
+ readonly extension: 1;
10
+ readonly tool: 1;
11
+ readonly dynamicTool: 1;
12
+ readonly connection: 1;
13
+ readonly hook: 1;
14
+ readonly skill: 1;
15
+ readonly dynamicSkill: 1;
16
+ readonly instructions: 1;
17
+ readonly dynamicInstructions: 1;
18
+ readonly config: 1;
19
+ readonly state: 1;
20
+ };
21
+ /** One independently versioned extension-facing contract. */
22
+ export type ExtensionCapability = keyof typeof EXTENSION_CAPABILITY_VERSIONS;
23
+ /** Capability requirements stamped by one extension build. */
24
+ export type ExtensionCapabilityRequirements = Partial<Record<ExtensionCapability, number>>;
25
+ /**
26
+ * Capability contract versions this eve release can consume. Derived from
27
+ * {@link EXTENSION_CAPABILITY_VERSIONS} so the version this release stamps is
28
+ * always one it accepts.
29
+ */
30
+ export declare const EXTENSION_CAPABILITY_SUPPORT: Readonly<Record<ExtensionCapability, readonly number[]>>;
31
+ /** Consumer support table used to validate one extension distribution. */
32
+ export type ExtensionCapabilitySupport = Readonly<Record<string, readonly number[]>>;
33
+ /** Compatibility-only metadata emitted by `eve extension build`. */
34
+ export interface ExtensionCompatibilityManifest {
35
+ readonly kind: typeof EXTENSION_COMPATIBILITY_MANIFEST_KIND;
36
+ readonly formatVersion: typeof EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION;
37
+ /** Diagnostic producer version; capability requirements decide compatibility. */
38
+ readonly builtWithEve: string;
39
+ readonly requires: Readonly<Record<string, number>>;
40
+ }
41
+ /** One requirement the consuming eve cannot satisfy. */
42
+ export interface UnsupportedExtensionCapability {
43
+ readonly capability: string;
44
+ readonly requiredVersion: number;
45
+ readonly supportedVersions: readonly number[];
46
+ }
47
+ /** Serializes a compatibility manifest deterministically. */
48
+ export declare function serializeExtensionCompatibilityManifest(manifest: ExtensionCompatibilityManifest): string;
49
+ /** Parses and validates compatibility-manifest JSON. */
50
+ export declare function parseExtensionCompatibilityManifest(raw: string, manifestPath: string): ExtensionCompatibilityManifest;
51
+ /** Reads and validates an extension compatibility manifest. */
52
+ export declare function readExtensionCompatibilityManifest(manifestPath: string): Promise<ExtensionCompatibilityManifest>;
53
+ /** Writes `_manifest.json` into an agent-shaped extension dist root. */
54
+ export declare function writeExtensionCompatibilityManifest(distRoot: string, manifest: ExtensionCompatibilityManifest): Promise<void>;
55
+ /** Finds unknown or unsupported capability requirements without executing extension code. */
56
+ export declare function findUnsupportedExtensionCapabilities(manifest: ExtensionCompatibilityManifest, support?: ExtensionCapabilitySupport): UnsupportedExtensionCapability[];
@@ -0,0 +1 @@
1
+ import{z}from"#compiled/zod/index.js";import{join}from"node:path";import{readFile,writeFile}from"node:fs/promises";import{formatValidationError}from"#runtime/validation.js";const EXTENSION_COMPATIBILITY_MANIFEST_KIND=`eve-extension`,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION=1,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME=`_manifest.json`,EXTENSION_CAPABILITY_VERSIONS={extension:1,tool:1,dynamicTool:1,connection:1,hook:1,skill:1,dynamicSkill:1,instructions:1,dynamicInstructions:1,config:1,state:1},ADDITIONAL_SUPPORTED_CAPABILITY_VERSIONS={};function deriveCapabilitySupport(){let e={};for(let t of Object.keys(EXTENSION_CAPABILITY_VERSIONS))e[t]=[...ADDITIONAL_SUPPORTED_CAPABILITY_VERSIONS[t]??[],EXTENSION_CAPABILITY_VERSIONS[t]];return e}const EXTENSION_CAPABILITY_SUPPORT=deriveCapabilitySupport(),extensionCompatibilityManifestSchema=z.object({kind:z.literal(EXTENSION_COMPATIBILITY_MANIFEST_KIND),formatVersion:z.literal(1),builtWithEve:z.string().min(1),requires:z.record(z.string(),z.number().int().positive())}).strict();function serializeExtensionCompatibilityManifest(e){return`${JSON.stringify(e,null,2)}\n`}function parseExtensionCompatibilityManifest(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`Extension compatibility manifest "${t}" is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}let r=extensionCompatibilityManifestSchema.safeParse(n);if(!r.success)throw Error(`Extension compatibility manifest "${t}" is invalid. ${formatValidationError(r.error)}`);return r.data}async function readExtensionCompatibilityManifest(e){return parseExtensionCompatibilityManifest(await readFile(e,`utf8`),e)}async function writeExtensionCompatibilityManifest(e,n){await writeFile(join(e,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME),serializeExtensionCompatibilityManifest(n),`utf8`)}function findUnsupportedExtensionCapabilities(e,t=EXTENSION_CAPABILITY_SUPPORT){return Object.entries(e.requires).flatMap(([e,n])=>{let r=Object.hasOwn(t,e)?t[e]??[]:[];return r.includes(n)?[]:[{capability:e,requiredVersion:n,supportedVersions:r}]}).sort((e,t)=>e.capability.localeCompare(t.capability))}export{EXTENSION_CAPABILITY_SUPPORT,EXTENSION_CAPABILITY_VERSIONS,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,findUnsupportedExtensionCapabilities,parseExtensionCompatibilityManifest,readExtensionCompatibilityManifest,serializeExtensionCompatibilityManifest,writeExtensionCompatibilityManifest};
@@ -1 +1 @@
1
- import{isAbsolute,join,relative,resolve}from"node:path";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{toErrorMessage}from"#shared/errors.js";import{normalizeJsonSchemaDefinition}from"#shared/json-schema.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{classifyModelRouting}from"#internal/classify-model-routing.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{parseJsonObject}from"#shared/json.js";import{isDynamicModelDefinition}from"#shared/agent-definition.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";async function compileAgentConfig(e,t){let n=e.configModule,r=n===void 0?void 0:formatAgentConfigModulePath(e,n),a=normalizeAgentDefinition(n===void 0?{model:DEFAULT_AGENT_MODEL_ID}:await loadModuleBackedDefinition({agentRoot:e.agentRoot,displayPath:r,kind:`agent config`,source:n}),n===void 0?`Expected the default agent config to match the public eve shape.`:`Expected the agent config export "${n.exportName??`default`}" from "${r}" to match the public eve shape.`),o=isDynamicModelDefinition(a.model)?a.model.fallback:a.model,s=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the primary compaction trigger model`,contextWindowTokens:a.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:o}),c={},l={compaction:c,model:s,name:e.agentId};if(a.description!==void 0&&(l.description=a.description),isDynamicModelDefinition(a.model)){if(n===void 0)throw Error(`Expected dynamic model definitions to be authored in agent.ts.`);l.dynamicModel={eventNames:Object.keys(a.model.events),exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId}}let u=normalizeExperimentalDefinition(a.experimental);return u!==void 0&&(l.experimental=u),a.build!==void 0&&(l.build={externalDependencies:a.build.externalDependencies===void 0?void 0:[...a.build.externalDependencies]}),a.outputSchema!==void 0&&(l.outputSchema=normalizeJsonSchemaDefinition(a.outputSchema,`output`)),a.reasoning!==void 0&&(l.reasoning=a.reasoning),a.limits!==void 0&&(l.limits={maxInputTokensPerSession:a.limits.maxInputTokensPerSession,maxOutputTokensPerSession:a.limits.maxOutputTokensPerSession}),n!==void 0&&(l.source={exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId}),a.compaction?.model!==void 0&&(c.model=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the compaction summary model`,contextWindowTokens:a.compaction.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:a.compaction.model})),a.compaction?.thresholdPercent!==void 0&&(c.thresholdPercent=a.compaction.thresholdPercent),l}function normalizeExperimentalDefinition(e){if(e===void 0)return;let t={};return e.workflow!==void 0&&(t.workflow={world:e.workflow.world}),t}async function normalizeAuthoredModelReference(e){if(typeof e.value==`string`)return await withCompiledRuntimeModelLimits({id:formatLanguageModelGatewayId(e.value),providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(e.value,e.providerOptions)},e);let t=e.source;if(t===void 0)throw Error(`Expected ${e.purpose} to provide a valid AI SDK language model reference.`);let n=e.value,r=n.specificationVersion;if(r!==`v2`&&r!==`v3`&&r!==`v4`||typeof n.provider!=`string`||typeof n.modelId!=`string`||typeof n.doGenerate!=`function`||typeof n.doStream!=`function`)throw Error(`Expected the authored agent config export "${t.exportName??`default`}" from "${e.sourcePath??t.logicalPath}" to provide a valid AI SDK language model.`);let i={id:formatLanguageModelGatewayId(n),source:{exportName:t.exportName,sourceKind:`module`,logicalPath:t.logicalPath,sourceId:t.sourceId},providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(n,e.providerOptions)};if(e.contextWindowTokens===void 0){let t=await e.modelCatalog.getByProviderModelId(n.provider,n.modelId);if(t)return{...i,id:t.slug,contextWindowTokens:t.limits.contextWindowTokens}}return await withCompiledRuntimeModelLimits(i,e)}function formatAgentConfigModulePath(e,r){let i=join(e.agentRoot,r.logicalPath);return normalizeLogicalPath(relative(resolveTopLevelAgentRoot(e),i))}function resolveTopLevelAgentRoot(e){let t=resolve(e.appRoot),n=resolve(t,`agent`);return isPathInsideOrEqual(n,resolve(e.agentRoot))?n:t}function isPathInsideOrEqual(t,r){let i=relative(t,r);return i===``||!i.startsWith(`..`)&&!isAbsolute(i)}async function withCompiledRuntimeModelLimits(e,t){if(t.contextWindowTokens!==void 0)return{...e,contextWindowTokens:t.contextWindowTokens};let n;try{n=await t.modelCatalog.getModelLimits(e.id)}catch(n){throw Error(`Failed to load AI Gateway model metadata for ${t.purpose} "${e.id}". ${toErrorMessage(n)}`)}if(n===null)throw Error(`Cannot compile agent compaction because ${t.purpose} "${e.id}" does not have known AI Gateway context window metadata.`);return{...e,contextWindowTokens:n.contextWindowTokens}}function parseProviderOptionsRecord(e){if(e===void 0)return;let t={};for(let[n,r]of Object.entries(e))t[n]=parseJsonObject(r);return t}export{compileAgentConfig};
1
+ import{isAbsolute,join,relative,resolve}from"node:path";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{toErrorMessage}from"#shared/errors.js";import{serializeOutputSchema}from"#shared/tool-schema.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{classifyModelRouting}from"#internal/classify-model-routing.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{parseJsonObject}from"#shared/json.js";import{isDynamicModelDefinition}from"#shared/agent-definition.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";async function compileAgentConfig(e,t){let n=e.configModule,r=n===void 0?void 0:formatAgentConfigModulePath(e,n),a=normalizeAgentDefinition(n===void 0?{model:DEFAULT_AGENT_MODEL_ID}:await loadModuleBackedDefinition({agentRoot:e.agentRoot,displayPath:r,kind:`agent config`,source:n}),n===void 0?`Expected the default agent config to match the public eve shape.`:`Expected the agent config export "${n.exportName??`default`}" from "${r}" to match the public eve shape.`),o=isDynamicModelDefinition(a.model)?a.model.fallback:a.model,s=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the primary compaction trigger model`,contextWindowTokens:a.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:o}),c={},l={compaction:c,model:s,name:e.agentId};if(a.description!==void 0&&(l.description=a.description),isDynamicModelDefinition(a.model)){if(n===void 0)throw Error(`Expected dynamic model definitions to be authored in agent.ts.`);l.dynamicModel={eventNames:Object.keys(a.model.events),exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId}}let u=normalizeExperimentalDefinition(a.experimental);return u!==void 0&&(l.experimental=u),a.build!==void 0&&(l.build={externalDependencies:a.build.externalDependencies===void 0?void 0:[...a.build.externalDependencies]}),a.outputSchema!==void 0&&(l.outputSchema=serializeOutputSchema(a.outputSchema)),a.reasoning!==void 0&&(l.reasoning=a.reasoning),a.limits!==void 0&&(l.limits={maxInputTokensPerSession:a.limits.maxInputTokensPerSession,maxOutputTokensPerSession:a.limits.maxOutputTokensPerSession}),n!==void 0&&(l.source={exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId}),a.compaction?.model!==void 0&&(c.model=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the compaction summary model`,contextWindowTokens:a.compaction.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:a.compaction.model})),a.compaction?.thresholdPercent!==void 0&&(c.thresholdPercent=a.compaction.thresholdPercent),l}function normalizeExperimentalDefinition(e){if(e===void 0)return;let t={};return e.workflow!==void 0&&(t.workflow={world:e.workflow.world}),t}async function normalizeAuthoredModelReference(e){if(typeof e.value==`string`)return await withCompiledRuntimeModelLimits({id:formatLanguageModelGatewayId(e.value),providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(e.value,e.providerOptions)},e);let t=e.source;if(t===void 0)throw Error(`Expected ${e.purpose} to provide a valid AI SDK language model reference.`);let n=e.value,r=n.specificationVersion;if(r!==`v2`&&r!==`v3`&&r!==`v4`||typeof n.provider!=`string`||typeof n.modelId!=`string`||typeof n.doGenerate!=`function`||typeof n.doStream!=`function`)throw Error(`Expected the authored agent config export "${t.exportName??`default`}" from "${e.sourcePath??t.logicalPath}" to provide a valid AI SDK language model.`);let i={id:formatLanguageModelGatewayId(n),source:{exportName:t.exportName,sourceKind:`module`,logicalPath:t.logicalPath,sourceId:t.sourceId},providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(n,e.providerOptions)};if(e.contextWindowTokens===void 0){let t=await e.modelCatalog.getByProviderModelId(n.provider,n.modelId);if(t)return{...i,id:t.slug,contextWindowTokens:t.limits.contextWindowTokens}}return await withCompiledRuntimeModelLimits(i,e)}function formatAgentConfigModulePath(e,r){let i=join(e.agentRoot,r.logicalPath);return normalizeLogicalPath(relative(resolveTopLevelAgentRoot(e),i))}function resolveTopLevelAgentRoot(e){let t=resolve(e.appRoot),n=resolve(t,`agent`);return isPathInsideOrEqual(n,resolve(e.agentRoot))?n:t}function isPathInsideOrEqual(t,r){let i=relative(t,r);return i===``||!i.startsWith(`..`)&&!isAbsolute(i)}async function withCompiledRuntimeModelLimits(e,t){if(t.contextWindowTokens!==void 0)return{...e,contextWindowTokens:t.contextWindowTokens};let n;try{n=await t.modelCatalog.getModelLimits(e.id)}catch(n){throw Error(`Failed to load AI Gateway model metadata for ${t.purpose} "${e.id}". ${toErrorMessage(n)}`)}if(n===null)throw Error(`Cannot compile agent compaction because ${t.purpose} "${e.id}" does not have known AI Gateway context window metadata.`);return{...e,contextWindowTokens:n.contextWindowTokens}}function parseProviderOptionsRecord(e){if(e===void 0)return;let t={};for(let[n,r]of Object.entries(e))t[n]=parseJsonObject(r);return t}export{compileAgentConfig};
@@ -1 +1 @@
1
- import{expectObjectRecord,expectOnlyKnownKeys,expectString}from"#internal/authored-module.js";import{EVE_CREATE_SESSION_ROUTE_PATH}from"#protocol/routes.js";import{normalizeJsonSchemaDefinition}from"#shared/json-schema.js";import{createCompiledSubagentNodeId}from"#compiler/manifest.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{createPathDerivedSourceId}from"#discover/manifest.js";async function compileSubagentGraph(e){let t=[],n=[],r=[];for(let i of e.subagents){let a=await compileSubagentDefinition({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:e.externalDependencies,parentNodeId:e.parentNodeId,source:i});if(a.kind===`remote`){r.push(a.node);continue}t.push(a.node,...a.descendants.nodes),n.push({childNodeId:a.node.nodeId,parentNodeId:e.parentNodeId},...a.descendants.edges)}return{edges:n,nodes:t,remoteAgents:r}}async function compileSubagentDefinition(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Subagent "${e.source.logicalPath}" is missing an agent config module.`);let n=createSubagentConfigModuleSourceRef(e.source,t),r=await loadModuleBackedDefinition({agentRoot:e.source.manifest.agentRoot,displayPath:n.logicalPath,externalDependencies:e.externalDependencies,kind:`subagent config`,source:t});return readAgentDefinitionKind(r)===`remote`?{kind:`remote`,node:compileRemoteAgent({source:e.source,value:r})}:{kind:`local`,...await compileLocalSubagent(e)}}async function compileSubagent(e){let t=createCompiledSubagentNodeId(e.parentNodeId,e.source.sourceId),n=e.source.subagentId,r=await e.compileAgentNodeManifest({...e.source.manifest,appRoot:e.appRoot},e.context,{allowWorkflowConfig:!1,externalDependencies:e.externalDependencies}),i=r.config.description;if(!i)throw Error(`Local subagent "${e.source.logicalPath}" is missing a "description" field on its agent config. Add \`description\` to \`defineAgent({ ... })\` so the parent agent can decide when to delegate to this subagent.`);let o=await compileSubagentGraph({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:r.config.build?.externalDependencies,parentNodeId:t,subagents:e.source.manifest.subagents});return{descendants:o,node:{agent:{...r,remoteAgents:[...o.remoteAgents]},description:i,entryPath:e.source.entryPath,logicalPath:e.source.logicalPath,name:n,nodeId:t,rootPath:e.source.rootPath,sourceId:e.source.sourceId,sourceKind:`module`}}}const compileLocalSubagent=compileSubagent;function compileRemoteAgent(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Remote agent "${e.source.logicalPath}" is missing a config module.`);assertRemoteAgentDefinitionHasNoLocalPackageEntries(e.source);let n=createSubagentConfigModuleSourceRef(e.source,t),r=normalizeRemoteAgentDefinition(e.value,`Expected the remote agent config export "${t.exportName??`default`}" from "${n.logicalPath}" to match the public eve shape.`),i={...n,description:r.description,entryPath:e.source.entryPath,name:e.source.subagentId,nodeId:e.source.sourceId,outputSchema:r.outputSchema,path:r.path,rootPath:e.source.rootPath};return r.url===void 0?i:{...i,url:r.url}}function createSubagentConfigModuleSourceRef(e,t){let n=e.logicalPath===t.logicalPath?t.logicalPath:`${e.logicalPath}/${t.logicalPath}`,r={logicalPath:n,sourceId:createPathDerivedSourceId(n),sourceKind:`module`};return t.exportName!==void 0&&(r.exportName=t.exportName),r}function readAgentDefinitionKind(e){return typeof e!=`object`||!e?`local`:e.kind===`remote`?`remote`:`local`}function normalizeRemoteAgentDefinition(a,o){let s=expectObjectRecord(a,o);if(expectOnlyKnownKeys(s,[`auth`,`description`,`headers`,`kind`,`outputSchema`,`path`,`url`],o),s.kind!==`remote`)throw Error(`${o} Expected "kind" to be "remote".`);return{description:expectString(s.description,o),outputSchema:s.outputSchema===void 0?void 0:normalizeJsonSchemaDefinition(s.outputSchema,`output`),path:s.path===void 0?EVE_CREATE_SESSION_ROUTE_PATH:expectString(s.path,o),url:typeof s.url==`function`?void 0:expectString(s.url,o)}}function assertRemoteAgentDefinitionHasNoLocalPackageEntries(e){let t=e.manifest,n=[t.connections.length>0?`connections/`:void 0,t.hooks.length>0?`hooks/`:void 0,t.instructions.length>0?`instructions`:void 0,t.lib.length>0?`lib/`:void 0,t.sandbox===null?void 0:`sandbox/`,t.sandboxWorkspaces.length>0?`sandbox/workspace/`:void 0,t.schedules.length>0?`schedules/`:void 0,t.skills.length>0?`skills/`:void 0,t.subagents.length>0?`subagents/`:void 0,t.tools.length>0?`tools/`:void 0].filter(e=>e!==void 0);if(n.length!==0)throw Error(`Remote subagent definition "${e.logicalPath}" cannot include local package entries. Remove unsupported entries: ${n.join(`, `)}.`)}export{compileSubagentGraph};
1
+ import{expectObjectRecord,expectOnlyKnownKeys,expectString}from"#internal/authored-module.js";import{EVE_CREATE_SESSION_ROUTE_PATH}from"#protocol/routes.js";import{serializeOutputSchema}from"#shared/tool-schema.js";import{createCompiledSubagentNodeId}from"#compiler/manifest.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{createPathDerivedSourceId}from"#discover/manifest.js";async function compileSubagentGraph(e){let t=[],n=[],r=[];for(let i of e.subagents){let a=await compileSubagentDefinition({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:e.externalDependencies,parentNodeId:e.parentNodeId,source:i});if(a.kind===`remote`){r.push(a.node);continue}t.push(a.node,...a.descendants.nodes),n.push({childNodeId:a.node.nodeId,parentNodeId:e.parentNodeId},...a.descendants.edges)}return{edges:n,nodes:t,remoteAgents:r}}async function compileSubagentDefinition(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Subagent "${e.source.logicalPath}" is missing an agent config module.`);let n=createSubagentConfigModuleSourceRef(e.source,t),r=await loadModuleBackedDefinition({agentRoot:e.source.manifest.agentRoot,displayPath:n.logicalPath,externalDependencies:e.externalDependencies,kind:`subagent config`,source:t});return readAgentDefinitionKind(r)===`remote`?{kind:`remote`,node:compileRemoteAgent({source:e.source,value:r})}:{kind:`local`,...await compileLocalSubagent(e)}}async function compileSubagent(e){let t=createCompiledSubagentNodeId(e.parentNodeId,e.source.sourceId),n=e.source.subagentId,r=await e.compileAgentNodeManifest({...e.source.manifest,appRoot:e.appRoot},e.context,{allowWorkflowConfig:!1,externalDependencies:e.externalDependencies}),i=r.config.description;if(!i)throw Error(`Local subagent "${e.source.logicalPath}" is missing a "description" field on its agent config. Add \`description\` to \`defineAgent({ ... })\` so the parent agent can decide when to delegate to this subagent.`);let o=await compileSubagentGraph({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:r.config.build?.externalDependencies,parentNodeId:t,subagents:e.source.manifest.subagents});return{descendants:o,node:{agent:{...r,remoteAgents:[...o.remoteAgents]},description:i,entryPath:e.source.entryPath,logicalPath:e.source.logicalPath,name:n,nodeId:t,rootPath:e.source.rootPath,sourceId:e.source.sourceId,sourceKind:`module`}}}const compileLocalSubagent=compileSubagent;function compileRemoteAgent(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Remote agent "${e.source.logicalPath}" is missing a config module.`);assertRemoteAgentDefinitionHasNoLocalPackageEntries(e.source);let n=createSubagentConfigModuleSourceRef(e.source,t),r=normalizeRemoteAgentDefinition(e.value,`Expected the remote agent config export "${t.exportName??`default`}" from "${n.logicalPath}" to match the public eve shape.`),i={...n,description:r.description,entryPath:e.source.entryPath,name:e.source.subagentId,nodeId:e.source.sourceId,outputSchema:r.outputSchema,path:r.path,rootPath:e.source.rootPath};return r.url===void 0?i:{...i,url:r.url}}function createSubagentConfigModuleSourceRef(e,t){let n=e.logicalPath===t.logicalPath?t.logicalPath:`${e.logicalPath}/${t.logicalPath}`,r={logicalPath:n,sourceId:createPathDerivedSourceId(n),sourceKind:`module`};return t.exportName!==void 0&&(r.exportName=t.exportName),r}function readAgentDefinitionKind(e){return typeof e!=`object`||!e?`local`:e.kind===`remote`?`remote`:`local`}function normalizeRemoteAgentDefinition(a,o){let s=expectObjectRecord(a,o);if(expectOnlyKnownKeys(s,[`auth`,`description`,`headers`,`kind`,`outputSchema`,`path`,`url`],o),s.kind!==`remote`)throw Error(`${o} Expected "kind" to be "remote".`);return{description:expectString(s.description,o),outputSchema:serializeOutputSchema(s.outputSchema),path:s.path===void 0?EVE_CREATE_SESSION_ROUTE_PATH:expectString(s.path,o),url:typeof s.url==`function`?void 0:expectString(s.url,o)}}function assertRemoteAgentDefinitionHasNoLocalPackageEntries(e){let t=e.manifest,n=[t.connections.length>0?`connections/`:void 0,t.hooks.length>0?`hooks/`:void 0,t.instructions.length>0?`instructions`:void 0,t.lib.length>0?`lib/`:void 0,t.sandbox===null?void 0:`sandbox/`,t.sandboxWorkspaces.length>0?`sandbox/workspace/`:void 0,t.schedules.length>0?`schedules/`:void 0,t.skills.length>0?`skills/`:void 0,t.subagents.length>0?`subagents/`:void 0,t.tools.length>0?`tools/`:void 0].filter(e=>e!==void 0);if(n.length!==0)throw Error(`Remote subagent definition "${e.logicalPath}" cannot include local package entries. Remove unsupported entries: ${n.join(`, `)}.`)}export{compileSubagentGraph};
@@ -1 +1 @@
1
- import{createLogger}from"#internal/logging.js";import{LiveStepToolsKey,SessionDynamicToolMetadataKey,TurnDynamicToolMetadataKey}from"#context/keys.js";import{jsonSchema}from"ai";import{buildBaseToolContext}from"#context/build-base-tool-context.js";const log=createLogger(`dynamic-tools`);function lookupStepFunction(e){try{let t=globalThis[Symbol.for(`@workflow/core//registeredSteps`)];return t===void 0?null:t.get(e)||null}catch{return null}}function replayTools(e){let t=[];for(let n of e){if(!n.executeStepFnName||!n.closureVars){log.warn(`Dynamic tool "${n.name}" has no registered step function — skipping on this step. The bundler transform may not have processed this tool file.`);continue}let e=lookupStepFunction(n.executeStepFnName);if(!e){log.warn(`Dynamic tool "${n.name}" references step function "${n.executeStepFnName}" which is not registered — skipping on this step.`);continue}t.push({description:n.description,execute:(t,r)=>e(n.closureVars,t,buildBaseToolContext({options:r,toolName:n.name})),inputSchema:jsonSchema(n.inputSchema),name:n.name,approval:buildReplayedApproval(n),outputSchema:n.outputSchema===void 0?void 0:jsonSchema(n.outputSchema)})}return t}function buildReplayedApproval(e){if(e.approvalStepFnName===void 0)return;let t=lookupStepFunction(e.approvalStepFnName);return t===null?(log.warn(`Dynamic tool "${e.name}" references approval function "${e.approvalStepFnName}" which is not registered — requiring approval by default.`),()=>`user-approval`):async n=>await t(e.closureVars??{},n)}function buildDynamicTools(e){let i=e.get(LiveStepToolsKey)??[],a=replayTools(e.get(TurnDynamicToolMetadataKey)??[]),o=replayTools(e.get(SessionDynamicToolMetadataKey)??[]);return[...i,...a,...o]}export{buildDynamicTools};
1
+ import{createLogger}from"#internal/logging.js";import{LiveStepToolsKey,SessionDynamicToolMetadataKey,TurnDynamicToolMetadataKey}from"#context/keys.js";import{toInputSchema,toOutputSchema}from"#shared/tool-schema.js";import{buildBaseToolContext}from"#context/build-base-tool-context.js";const log=createLogger(`dynamic-tools`);function lookupStepFunction(e){try{let t=globalThis[Symbol.for(`@workflow/core//registeredSteps`)];return t===void 0?null:t.get(e)||null}catch{return null}}function replayTools(e){let t=[];for(let n of e){if(!n.executeStepFnName||!n.closureVars){log.warn(`Dynamic tool "${n.name}" has no registered step function — skipping on this step. The bundler transform may not have processed this tool file.`);continue}let e=lookupStepFunction(n.executeStepFnName);if(!e){log.warn(`Dynamic tool "${n.name}" references step function "${n.executeStepFnName}" which is not registered — skipping on this step.`);continue}t.push({description:n.description,execute:(t,r)=>e(n.closureVars,t,buildBaseToolContext({options:r,toolName:n.name})),inputSchema:toInputSchema(n.inputSchema),name:n.name,approval:buildReplayedApproval(n),outputSchema:toOutputSchema(n.outputSchema)})}return t}function buildReplayedApproval(e){if(e.approvalStepFnName===void 0)return;let t=lookupStepFunction(e.approvalStepFnName);return t===null?(log.warn(`Dynamic tool "${e.name}" references approval function "${e.approvalStepFnName}" which is not registered — requiring approval by default.`),()=>`user-approval`):async n=>await t(e.closureVars??{},n)}function buildDynamicTools(e){let i=e.get(LiveStepToolsKey)??[],a=replayTools(e.get(TurnDynamicToolMetadataKey)??[]),o=replayTools(e.get(SessionDynamicToolMetadataKey)??[]);return[...i,...a,...o]}export{buildDynamicTools};
@@ -1,4 +1,4 @@
1
- import { type ModelMessage } from "ai";
1
+ import type { ModelMessage } from "ai";
2
2
  import type { HarnessToolDefinition } from "#harness/execute-tool.js";
3
3
  import type { HandleMessageStreamEvent } from "#protocol/message.js";
4
4
  import type { ResolvedDynamicToolResolver } from "#runtime/types.js";
@@ -1 +1 @@
1
- import{createLogger}from"#internal/logging.js";import{LiveStepToolsKey,SessionDynamicToolMetadataKey,TurnDynamicToolMetadataKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{ALLOWED_DYNAMIC_TOOL_EVENTS,isBrandedToolEntry}from"#shared/dynamic-tool-definition.js";import{jsonSchema,zodSchema}from"ai";import{buildBaseToolContext}from"#context/build-base-tool-context.js";import{buildResolveContext}from"#context/dynamic-resolve-context.js";import{normalizeJsonSchemaDefinition}from"#internal/json-schema.js";const log=createLogger(`dynamic-tools`);function toHarnessToolDefinition(e,t){return{description:t.description,execute:(n,r)=>t.execute(n,buildBaseToolContext({options:r,toolName:e})),inputSchema:convertInputSchema(t.inputSchema),name:e,approval:t.approval,outputSchema:convertOptionalOutputSchema(t.outputSchema),...t.toModelOutput===void 0?{}:{toModelOutput:t.toModelOutput}}}function convertInputSchema(e){return typeof e==`object`&&e&&`~standard`in e?zodSchema(e):jsonSchema(e)}function convertOptionalOutputSchema(e){if(e!==void 0)return typeof e==`object`&&e&&`~standard`in e?zodSchema(e):jsonSchema(e)}function qualifyDynamicToolNames(e,t,n){let r=Object.keys(n),i=[];if(r.length===0)return i;if(t)return i.push({name:e.slug,entryKey:r[0],entry:n[r[0]]}),i;let a=e.extensionNamespace===void 0?``:`${e.extensionNamespace}__`;for(let e of r)i.push({name:`${a}${e}`,entryKey:e,entry:n[e]});return i}function replayDynamicSessionTools(e,t){let n=[];for(let t of e){if(!t.executeStepFnName||!t.closureVars){log.warn(`Dynamic tool "${t.name}" has no registered step function — skipping on this step. The bundler transform may not have processed this tool file.`);continue}let e=lookupStepFunction(t.executeStepFnName);if(!e){log.warn(`Dynamic tool "${t.name}" references step function "${t.executeStepFnName}" which is not registered — skipping on this step.`);continue}n.push({description:t.description,execute:(n,r)=>e(t.closureVars,n,buildBaseToolContext({options:r,toolName:t.name})),inputSchema:jsonSchema(t.inputSchema),name:t.name,outputSchema:t.outputSchema===void 0?void 0:jsonSchema(t.outputSchema)})}return n}function getStepRegistry(){let e=Symbol.for(`@workflow/core//registeredSteps`),t=globalThis,n=t[e];return n===void 0&&(n=new Map,t[e]=n),n}function lookupStepFunction(e){try{return getStepRegistry().get(e)||null}catch{return null}}function registerStepFunction(e,t){getStepRegistry().set(e,t)}function safeSerialize(e){try{return JSON.parse(JSON.stringify(e))}catch{return{}}}function durableKeyForEvent(e){switch(e){case`session.started`:return SessionDynamicToolMetadataKey;case`turn.started`:return TurnDynamicToolMetadataKey;default:return}}async function resolveToolsFromEvent(e,t,n,r){let a=await Promise.allSettled(t.map(async t=>{let i=t.events[n.type];if(i===void 0)return null;let a=await i(n,buildResolveContext(e,r));if(a==null)return null;let s,c;return isBrandedToolEntry(a)?(s={_single:a},c=!0):(s=a,c=!1),{resolver:t,entries:s,isSingle:c}})),s=[],c=[],l=new Map;for(let e of a){if(e.status===`rejected`){log.error(`Dynamic tool resolver (${n.type}) threw — skipping.`,{error:toErrorMessage(e.reason)});continue}if(e.value===null)continue;let{resolver:t,entries:r,isSingle:a}=e.value,o=qualifyDynamicToolNames(t,a,r);for(let{name:e,entryKey:r,entry:i}of o){let a=l.get(e);if(a!==void 0&&a!==t.slug)throw Error(`Dynamic tool "${e}" from resolver "${t.slug}" collides with dynamic resolver "${a}". Namespace the map key manually, e.g. "${t.slug}__${e}".`);if(l.set(e,t.slug),c.push(toHarnessToolDefinition(e,i)),n.type===`step.started`)continue;let o=`__executeStepFn`in i?i.__executeStepFn:void 0,u=`__closureVars`in i?i.__closureVars:void 0,f=o?.stepId,p=u===void 0?void 0:safeSerialize(u);if(f===void 0){let e=`eve:framework-dynamic:${t.slug}:${r}`,n=i.execute.bind(i);registerStepFunction(e,(e,t,r)=>n(t,r)),f=e,p={}}let m;if(i.approval!==void 0){m=`eve:dynamic-tool-approval:${t.slug}:${r}`;let e=i.approval.bind(i);registerStepFunction(m,(t,n)=>e(n))}s.push({name:e,description:i.description,inputSchema:normalizeJsonSchemaDefinition(i.inputSchema),outputSchema:i.outputSchema===void 0?void 0:normalizeJsonSchemaDefinition(i.outputSchema,`output`),resolverSlug:t.slug,entryKey:r,executeStepFnName:f,approvalStepFnName:m,closureVars:p})}}return{metadata:s,liveTools:c}}async function dispatchDynamicToolEvent(e){let{ctx:n,resolvers:r,event:i,messages:o}=e;if(!ALLOWED_DYNAMIC_TOOL_EVENTS.has(i.type))return;let s=r.filter(e=>e.eventNames.includes(i.type));if(s.length===0)return;let{metadata:c,liveTools:l}=await resolveToolsFromEvent(n,s,i,o);if(i.type===`step.started`){n.setVirtualContext(LiveStepToolsKey,l);return}let u=durableKeyForEvent(i.type);if(u===void 0)return;let d=new Set(s.map(e=>e.slug)),f=(n.get(u)??[]).filter(e=>!d.has(e.resolverSlug));n.set(u,[...f,...c])}export{dispatchDynamicToolEvent,replayDynamicSessionTools};
1
+ import{createLogger}from"#internal/logging.js";import{LiveStepToolsKey,SessionDynamicToolMetadataKey,TurnDynamicToolMetadataKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{serializeInputSchema,serializeOutputSchema,toInputSchema,toOutputSchema}from"#shared/tool-schema.js";import{ALLOWED_DYNAMIC_TOOL_EVENTS,isBrandedToolEntry}from"#shared/dynamic-tool-definition.js";import{buildBaseToolContext}from"#context/build-base-tool-context.js";import{buildResolveContext}from"#context/dynamic-resolve-context.js";const log=createLogger(`dynamic-tools`);function toHarnessToolDefinition(e,t){return{description:t.description,execute:(n,r)=>t.execute(n,buildBaseToolContext({options:r,toolName:e})),inputSchema:toInputSchema(t.inputSchema),name:e,approval:t.approval,outputSchema:toOutputSchema(t.outputSchema),...t.toModelOutput===void 0?{}:{toModelOutput:t.toModelOutput}}}function qualifyDynamicToolNames(e,t,n){let r=Object.keys(n),i=[];if(r.length===0)return i;if(t)return i.push({name:e.slug,entryKey:r[0],entry:n[r[0]]}),i;let a=e.extensionNamespace===void 0?``:`${e.extensionNamespace}__`;for(let e of r)i.push({name:`${a}${e}`,entryKey:e,entry:n[e]});return i}function replayDynamicSessionTools(e,t){let n=[];for(let t of e){if(!t.executeStepFnName||!t.closureVars){log.warn(`Dynamic tool "${t.name}" has no registered step function — skipping on this step. The bundler transform may not have processed this tool file.`);continue}let e=lookupStepFunction(t.executeStepFnName);if(!e){log.warn(`Dynamic tool "${t.name}" references step function "${t.executeStepFnName}" which is not registered — skipping on this step.`);continue}n.push({description:t.description,execute:(n,r)=>e(t.closureVars,n,buildBaseToolContext({options:r,toolName:t.name})),inputSchema:toInputSchema(t.inputSchema),name:t.name,outputSchema:toOutputSchema(t.outputSchema)})}return n}function getStepRegistry(){let e=Symbol.for(`@workflow/core//registeredSteps`),t=globalThis,n=t[e];return n===void 0&&(n=new Map,t[e]=n),n}function lookupStepFunction(e){try{return getStepRegistry().get(e)||null}catch{return null}}function registerStepFunction(e,t){getStepRegistry().set(e,t)}function safeSerialize(e){try{return JSON.parse(JSON.stringify(e))}catch{return{}}}function durableKeyForEvent(e){switch(e){case`session.started`:return SessionDynamicToolMetadataKey;case`turn.started`:return TurnDynamicToolMetadataKey;default:return}}async function resolveToolsFromEvent(e,t,n,r){let s=await Promise.allSettled(t.map(async t=>{let i=t.events[n.type];if(i===void 0)return null;let a=await i(n,buildResolveContext(e,r));if(a==null)return null;let o,s;return isBrandedToolEntry(a)?(o={_single:a},s=!0):(o=a,s=!1),{resolver:t,entries:o,isSingle:s}})),c=[],l=[],d=new Map;for(let e of s){if(e.status===`rejected`){log.error(`Dynamic tool resolver (${n.type}) threw — skipping.`,{error:toErrorMessage(e.reason)});continue}if(e.value===null)continue;let{resolver:t,entries:r,isSingle:s}=e.value,u=qualifyDynamicToolNames(t,s,r);for(let{name:e,entryKey:r,entry:i}of u){let s=d.get(e);if(s!==void 0&&s!==t.slug)throw Error(`Dynamic tool "${e}" from resolver "${t.slug}" collides with dynamic resolver "${s}". Namespace the map key manually, e.g. "${t.slug}__${e}".`);if(d.set(e,t.slug),l.push(toHarnessToolDefinition(e,i)),n.type===`step.started`)continue;let u=`__executeStepFn`in i?i.__executeStepFn:void 0,f=`__closureVars`in i?i.__closureVars:void 0,p=u?.stepId,m=f===void 0?void 0:safeSerialize(f);if(p===void 0){let e=`eve:framework-dynamic:${t.slug}:${r}`,n=i.execute.bind(i);registerStepFunction(e,(e,t,r)=>n(t,r)),p=e,m={}}let h;if(i.approval!==void 0){h=`eve:dynamic-tool-approval:${t.slug}:${r}`;let e=i.approval.bind(i);registerStepFunction(h,(t,n)=>e(n))}c.push({name:e,description:i.description,inputSchema:serializeInputSchema(i.inputSchema),outputSchema:serializeOutputSchema(i.outputSchema),resolverSlug:t.slug,entryKey:r,executeStepFnName:p,approvalStepFnName:h,closureVars:m})}}return{metadata:c,liveTools:l}}async function dispatchDynamicToolEvent(e){let{ctx:n,resolvers:r,event:i,messages:a}=e;if(!ALLOWED_DYNAMIC_TOOL_EVENTS.has(i.type))return;let o=r.filter(e=>e.eventNames.includes(i.type));if(o.length===0)return;let{metadata:s,liveTools:c}=await resolveToolsFromEvent(n,o,i,a);if(i.type===`step.started`){n.setVirtualContext(LiveStepToolsKey,c);return}let u=durableKeyForEvent(i.type);if(u===void 0)return;let d=new Set(o.map(e=>e.slug)),f=(n.get(u)??[]).filter(e=>!d.has(e.resolverSlug));n.set(u,[...f,...s])}export{dispatchDynamicToolEvent,replayDynamicSessionTools};
@@ -1,5 +1,5 @@
1
1
  import { type DiscoverDiagnostic } from "#discover/diagnostics.js";
2
- import { type AgentSourceManifest } from "#discover/manifest.js";
2
+ import { type AgentSourceManifest, type ExtensionSourceRef } from "#discover/manifest.js";
3
3
  import { type ProjectSource } from "#discover/project-source.js";
4
4
  /**
5
5
  * Input for discovering the authored agent source graph from resolved roots.
@@ -21,12 +21,6 @@ interface DiscoverAgentInput {
21
21
  * not resolve further extensions (transitive mounting is a non-goal).
22
22
  */
23
23
  role?: "agent" | "extension";
24
- /**
25
- * The app's eve version, checked against each mounted extension's
26
- * `peerDependencies.eve`. Defaults to the running eve's version; injectable
27
- * for tests.
28
- */
29
- eveVersion?: string;
30
24
  }
31
25
  /**
32
26
  * Result of discovering one authored agent source graph.
@@ -40,4 +34,32 @@ interface DiscoverAgentResult {
40
34
  * modules.
41
35
  */
42
36
  export declare function discoverAgent(input: DiscoverAgentInput): Promise<DiscoverAgentResult>;
37
+ /**
38
+ * One extension mount discovered under `agent/extensions/`, in either the flat
39
+ * file form (`extensions/crm.ts`) or the directory form
40
+ * (`extensions/crm/extension.ts` with optional override slots).
41
+ */
42
+ export interface ExtensionMountDescriptor {
43
+ /** Mount namespace prefixed onto every composed contribution. */
44
+ readonly namespace: string;
45
+ /** Module ref for the mount declaration the package specifier is read from. */
46
+ readonly mountRef: ExtensionSourceRef;
47
+ /**
48
+ * Absolute path to the mount directory when this is the directory form.
49
+ * Its override slots are discovered as an agent-shaped source. Absent for
50
+ * the flat file form.
51
+ */
52
+ readonly overridesRoot?: string;
53
+ }
54
+ /**
55
+ * Discovers extension mount declarations without resolving or inspecting their
56
+ * package distributions. Development uses this before building local mounts.
57
+ */
58
+ export declare function discoverExtensionMountDeclarations(input: {
59
+ readonly agentRoot: string;
60
+ readonly source?: ProjectSource;
61
+ }): Promise<{
62
+ diagnostics: DiscoverDiagnostic[];
63
+ mounts: ExtensionMountDescriptor[];
64
+ }>;
43
65
  export {};
@@ -1 +1 @@
1
- import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{join,resolve}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS,classifyAgentRootEntry,normalizeLogicalPath}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";import{DISCOVER_EXTENSION_AGENT_CONFIG_UNSUPPORTED,DISCOVER_EXTENSION_MOUNT_AMBIGUOUS,DISCOVER_EXTENSION_MOUNT_MISSING_DECLARATION,DISCOVER_EXTENSION_NESTED_MOUNT_UNSUPPORTED,DISCOVER_EXTENSION_OVERRIDE_OUTSIDE_MOUNT,DISCOVER_EXTENSION_SANDBOX_UNSUPPORTED,DISCOVER_EXTENSION_SCHEDULE_UNSUPPORTED,locateExtensionMount,mountNamespace}from"#discover/extensions.js";import{createAgentSourceManifest,createModuleSourceRef}from"#discover/manifest.js";import{DISCOVER_CHANNELS_DIRECTORY_INVALID,DISCOVER_EXTENSIONS_DIRECTORY_INVALID,DISCOVER_HOOKS_DIRECTORY_INVALID,DISCOVER_TOOLS_DIRECTORY_INVALID,createChannelNameDiagnostic,createExtensionNameDiagnostic,createHookNameDiagnostic,createToolNameDiagnostic,createUnsupportedRootDirectoryDiagnostics,discoverFlatModuleSource,discoverInstructionsSource,discoverNamedSourceDirectory,readSortedDirectoryEntries}from"#discover/grammar.js";import{discoverConnectionSources}from"#discover/connections.js";import{discoverSubagents}from"#discover/discover-subagent.js";import{discoverLibSources}from"#discover/lib.js";import{discoverSandboxSource}from"#discover/sandbox.js";import{discoverScheduleSources}from"#discover/schedules.js";import{discoverSkills}from"#discover/skills.js";import{stripNpmPackageScope}from"#shared/package-name.js";async function discoverAgent(i){let o=i.source??createDiskProjectSource(),l=resolve(i.appRoot),u=resolve(i.agentRoot),f=i.role??`agent`,h=i.eveVersion??resolveInstalledPackageInfo().version,g=[],_=await tryReadPackageJsonName(o,l),v=await readSortedDirectoryEntries(o,u);g.push(...createUnsupportedRootDirectoryDiagnostics({classifyEntry:classifyAgentRootEntry,createUnsupportedDirectoryMessage(e){return`Ignoring unsupported directory "${e}/" in the agent root.`},rootEntries:v,rootPath:u}));let y=await discoverInstructionsSource({rootEntries:v,rootPath:u,source:o,required:f!==`extension`});g.push(...y.diagnostics);let b=discoverFlatModuleSource({rootEntries:v,rootPath:u,slotName:`agent`});g.push(...b.diagnostics);let x=await discoverNamedSourceDirectory({directoryName:`channels`,invalidDirectoryCode:DISCOVER_CHANNELS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(u,`channels`)}" to be a directory of authored channels.`,recursive:!0,rootEntries:v,rootPath:u,source:o,validateSegment:createChannelNameDiagnostic});g.push(...x.diagnostics);let S=await discoverLibSources({agentRoot:u,rootEntries:v,source:o});g.push(...S.diagnostics);let C=await discoverScheduleSources({agentRoot:u,rootEntries:v,source:o});g.push(...C.diagnostics);let w=await discoverConnectionSources({rootEntries:v,rootPath:u,source:o});g.push(...w.diagnostics);let T=await discoverSandboxSource({rootEntries:v,rootPath:u,source:o});if(g.push(...T.diagnostics),f===`extension`){b.module!==void 0&&g.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_AGENT_CONFIG_UNSUPPORTED,message:`An extension may not declare agent config (agent.ts) — model, limits, and sandbox are the consuming agent's to own.`,sourcePath:join(u,b.module.logicalPath)})),T.sandbox!==null&&g.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_SANDBOX_UNSUPPORTED,message:`An extension may not declare a sandbox — it is the consuming agent's to own.`,sourcePath:join(u,T.sandbox.logicalPath)}));let[e]=C.schedules;e!==void 0&&g.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_SCHEDULE_UNSUPPORTED,message:`An extension may not declare schedules — background scheduling runs on the consuming agent's deployment under its limits, so it is the consuming agent's to own.`,sourcePath:join(u,e.logicalPath)}))}let E=await discoverNamedSourceDirectory({directoryName:`tools`,invalidDirectoryCode:DISCOVER_TOOLS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(u,`tools`)}" to be a directory of authored tools.`,recursive:!0,rootEntries:v,rootPath:u,source:o,validateSegment:createToolNameDiagnostic});g.push(...E.diagnostics);let D=await discoverNamedSourceDirectory({directoryName:`hooks`,invalidDirectoryCode:DISCOVER_HOOKS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(u,`hooks`)}" to be a directory of authored hooks.`,recursive:!0,rootEntries:v,rootPath:u,source:o,validateSegment:createHookNameDiagnostic});g.push(...D.diagnostics);let O=await discoverNamedSourceDirectory({directoryName:`extensions`,invalidDirectoryCode:DISCOVER_EXTENSIONS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(u,`extensions`)}" to be a directory of extension mounts.`,recursive:!1,rootEntries:v,rootPath:u,source:o,validateSegment:createExtensionNameDiagnostic});g.push(...O.diagnostics);let k=await discoverSkills({agentRoot:u,source:o});g.push(...k.diagnostics);let A=await discoverSubagents({agentRoot:u,appRoot:l,source:o});g.push(...A.diagnostics);let j=await collectExtensionMounts({agentRoot:u,fileMounts:O.sources,rootEntries:v,source:o});g.push(...j.diagnostics),g.push(...detectRootNamespaceCollisions({agentRoot:u,namespaces:j.mounts.map(e=>e.namespace),sources:[...E.sources,...w.connections,...k.skills,...C.schedules]}));let M=[];if(f!==`agent`)for(let e of j.mounts)g.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_NESTED_MOUNT_UNSUPPORTED,message:`"${e.mountRef.logicalPath}" mounts an extension from inside an extension, which is not supported yet. Extensions cannot mount other extensions; remove the "extensions/" slot.`,sourcePath:join(u,e.mountRef.logicalPath)}));else for(let e of j.mounts){let t=await locateExtensionMount({source:o,agentRoot:u,appRoot:l,mount:e.mountRef,namespace:e.namespace,eveVersion:h});if(g.push(...t.diagnostics),t.location===void 0)continue;let n=await discoverAgent({agentRoot:t.location.sourceRoot,appRoot:t.location.packageRoot,source:o,role:`extension`});g.push(...n.diagnostics);let r;if(e.overridesRoot!==void 0){let t=await discoverAgent({agentRoot:e.overridesRoot,appRoot:l,source:o,role:`extension`});g.push(...t.diagnostics),r=t.manifest}let i={namespace:t.location.namespace,specifier:t.location.specifier,packageName:t.location.packageName,packageRoot:t.location.packageRoot,sourceRoot:t.location.sourceRoot,manifest:n.manifest};r!==void 0&&(i.overrides=r),M.push(i)}let N={agentRoot:u,appRoot:l,channels:x.sources,connections:w.connections,packageName:_,diagnostics:g,extensions:j.mounts.map(e=>e.mountRef),resolvedExtensions:M,hooks:D.sources,lib:S.lib,instructions:y.instructions,sandbox:T.sandbox,sandboxWorkspaces:T.sandboxWorkspace===null?[]:[T.sandboxWorkspace],schedules:C.schedules,skills:k.skills,tools:E.sources,subagents:A.subagents};return b.module!==void 0&&(N.configModule=b.module),{diagnostics:g,manifest:createAgentSourceManifest(N)}}async function collectExtensionMounts(e){let n=[],i=join(e.agentRoot,`extensions`),a=e.fileMounts.map(e=>({namespace:mountNamespace(e.logicalPath),mountRef:e})),s=new Set(a.map(e=>e.namespace)),c=e.rootEntries.find(e=>e.name===`extensions`),d=[],f=new Set;if(c?.isDirectory()===!0){let a=await readSortedDirectoryEntries(e.source,i);for(let c of a){if(!c.isDirectory())continue;let a=c.name,l=join(i,a),p=createExtensionNameDiagnostic(a,l);if(p!==null){n.push(p);continue}let m=discoverFlatModuleSource({rootEntries:await readSortedDirectoryEntries(e.source,l),rootPath:l,slotName:`extension`});if(n.push(...m.diagnostics),m.module===void 0){n.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_MISSING_DECLARATION,message:`Extension mount directory "extensions/${a}/" must declare its mount in "extension.ts" (or another supported module extension).`,sourcePath:l}));continue}s.has(a)&&f.add(a),d.push({namespace:a,mountRef:createModuleSourceRef({logicalPath:normalizeLogicalPath(join(`extensions`,a,m.module.logicalPath))}),overridesRoot:l})}}for(let e of f)n.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_AMBIGUOUS,message:`Extension namespace "${e}" is claimed by both a file mount ("extensions/${e}.ts") and a directory mount ("extensions/${e}/"). Keep only one.`,sourcePath:i}));return{diagnostics:n,mounts:[...a,...d].filter(e=>!f.has(e.namespace))}}function detectRootNamespaceCollisions(e){if(e.namespaces.length===0)return[];let n=[];for(let i of e.sources){let a=rootContributionName(i.logicalPath),o=e.namespaces.find(e=>a.startsWith(`${e}__`));o!==void 0&&n.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_OVERRIDE_OUTSIDE_MOUNT,message:`"${i.logicalPath}" uses the "${o}__" prefix reserved for the mounted extension "${o}". Override an extension's contributions inside its mount directory ("extensions/${o}/…"), not at the agent root.`,sourcePath:join(e.agentRoot,i.logicalPath)}))}return n}function rootContributionName(e){let t=e.slice(e.indexOf(`/`)+1),n=t.split(`/`)[0]??t;for(let e of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(n.toLowerCase().endsWith(e))return n.slice(0,n.length-e.length);return n}async function tryReadPackageJsonName(e,n){try{let r=join(n,`package.json`),i=JSON.parse(await e.readTextFile(r)).name;return typeof i!=`string`||i.length===0?void 0:stripNpmPackageScope(i)}catch{return}}export{discoverAgent};
1
+ import{join,resolve}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS,classifyAgentRootEntry,normalizeLogicalPath}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";import{DISCOVER_EXTENSION_AGENT_CONFIG_UNSUPPORTED,DISCOVER_EXTENSION_MOUNT_AMBIGUOUS,DISCOVER_EXTENSION_MOUNT_MISSING_DECLARATION,DISCOVER_EXTENSION_NESTED_MOUNT_UNSUPPORTED,DISCOVER_EXTENSION_OVERRIDE_OUTSIDE_MOUNT,DISCOVER_EXTENSION_SANDBOX_UNSUPPORTED,DISCOVER_EXTENSION_SCHEDULE_UNSUPPORTED,locateExtensionMount,mountNamespace}from"#discover/extensions.js";import{createAgentSourceManifest,createModuleSourceRef}from"#discover/manifest.js";import{DISCOVER_CHANNELS_DIRECTORY_INVALID,DISCOVER_EXTENSIONS_DIRECTORY_INVALID,DISCOVER_HOOKS_DIRECTORY_INVALID,DISCOVER_TOOLS_DIRECTORY_INVALID,createChannelNameDiagnostic,createExtensionNameDiagnostic,createHookNameDiagnostic,createToolNameDiagnostic,createUnsupportedRootDirectoryDiagnostics,discoverFlatModuleSource,discoverInstructionsSource,discoverNamedSourceDirectory,readSortedDirectoryEntries}from"#discover/grammar.js";import{discoverConnectionSources}from"#discover/connections.js";import{discoverSubagents}from"#discover/discover-subagent.js";import{discoverLibSources}from"#discover/lib.js";import{discoverSandboxSource}from"#discover/sandbox.js";import{discoverScheduleSources}from"#discover/schedules.js";import{discoverSkills}from"#discover/skills.js";import{stripNpmPackageScope}from"#shared/package-name.js";async function discoverAgent(r){let a=r.source??createDiskProjectSource(),c=resolve(r.appRoot),l=resolve(r.agentRoot),d=r.role??`agent`,h=[],g=await tryReadPackageJsonName(a,c),_=await readSortedDirectoryEntries(a,l);h.push(...createUnsupportedRootDirectoryDiagnostics({classifyEntry:classifyAgentRootEntry,createUnsupportedDirectoryMessage(e){return`Ignoring unsupported directory "${e}/" in the agent root.`},rootEntries:_,rootPath:l}));let v=await discoverInstructionsSource({rootEntries:_,rootPath:l,source:a,required:d!==`extension`});h.push(...v.diagnostics);let y=discoverFlatModuleSource({rootEntries:_,rootPath:l,slotName:`agent`});h.push(...y.diagnostics);let b=await discoverNamedSourceDirectory({directoryName:`channels`,invalidDirectoryCode:DISCOVER_CHANNELS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(l,`channels`)}" to be a directory of authored channels.`,recursive:!0,rootEntries:_,rootPath:l,source:a,validateSegment:createChannelNameDiagnostic});h.push(...b.diagnostics);let x=await discoverLibSources({agentRoot:l,rootEntries:_,source:a});h.push(...x.diagnostics);let S=await discoverScheduleSources({agentRoot:l,rootEntries:_,source:a});h.push(...S.diagnostics);let C=await discoverConnectionSources({rootEntries:_,rootPath:l,source:a});h.push(...C.diagnostics);let w=await discoverSandboxSource({rootEntries:_,rootPath:l,source:a});if(h.push(...w.diagnostics),d===`extension`){y.module!==void 0&&h.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_AGENT_CONFIG_UNSUPPORTED,message:`An extension may not declare agent config (agent.ts) — model, limits, and sandbox are the consuming agent's to own.`,sourcePath:join(l,y.module.logicalPath)})),w.sandbox!==null&&h.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_SANDBOX_UNSUPPORTED,message:`An extension may not declare a sandbox — it is the consuming agent's to own.`,sourcePath:join(l,w.sandbox.logicalPath)}));let[t]=S.schedules;t!==void 0&&h.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_SCHEDULE_UNSUPPORTED,message:`An extension may not declare schedules — background scheduling runs on the consuming agent's deployment under its limits, so it is the consuming agent's to own.`,sourcePath:join(l,t.logicalPath)}))}let T=await discoverNamedSourceDirectory({directoryName:`tools`,invalidDirectoryCode:DISCOVER_TOOLS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(l,`tools`)}" to be a directory of authored tools.`,recursive:!0,rootEntries:_,rootPath:l,source:a,validateSegment:createToolNameDiagnostic});h.push(...T.diagnostics);let E=await discoverNamedSourceDirectory({directoryName:`hooks`,invalidDirectoryCode:DISCOVER_HOOKS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(l,`hooks`)}" to be a directory of authored hooks.`,recursive:!0,rootEntries:_,rootPath:l,source:a,validateSegment:createHookNameDiagnostic});h.push(...E.diagnostics);let D=await discoverNamedSourceDirectory({directoryName:`extensions`,invalidDirectoryCode:DISCOVER_EXTENSIONS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(l,`extensions`)}" to be a directory of extension mounts.`,recursive:!1,rootEntries:_,rootPath:l,source:a,validateSegment:createExtensionNameDiagnostic});h.push(...D.diagnostics);let O=await discoverSkills({agentRoot:l,source:a});h.push(...O.diagnostics);let k=await discoverSubagents({agentRoot:l,appRoot:c,source:a});h.push(...k.diagnostics);let A=await collectExtensionMounts({agentRoot:l,fileMounts:D.sources,rootEntries:_,source:a});h.push(...A.diagnostics),h.push(...detectRootNamespaceCollisions({agentRoot:l,namespaces:A.mounts.map(e=>e.namespace),sources:[...T.sources,...C.connections,...O.skills,...S.schedules]}));let j=[];if(d!==`agent`)for(let t of A.mounts)h.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_NESTED_MOUNT_UNSUPPORTED,message:`"${t.mountRef.logicalPath}" mounts an extension from inside an extension, which is not supported yet. Extensions cannot mount other extensions; remove the "extensions/" slot.`,sourcePath:join(l,t.mountRef.logicalPath)}));else for(let e of A.mounts){let t=await locateExtensionMount({source:a,agentRoot:l,appRoot:c,mount:e.mountRef,namespace:e.namespace});if(h.push(...t.diagnostics),t.location===void 0)continue;let n=await discoverAgent({agentRoot:t.location.sourceRoot,appRoot:t.location.packageRoot,source:a,role:`extension`});h.push(...n.diagnostics);let r;if(e.overridesRoot!==void 0){let t=await discoverAgent({agentRoot:e.overridesRoot,appRoot:c,source:a,role:`extension`});h.push(...t.diagnostics),r=t.manifest}let i={namespace:t.location.namespace,specifier:t.location.specifier,packageName:t.location.packageName,packageRoot:t.location.packageRoot,sourceRoot:t.location.sourceRoot,manifest:n.manifest};r!==void 0&&(i.overrides=r),j.push(i)}let M={agentRoot:l,appRoot:c,channels:b.sources,connections:C.connections,packageName:g,diagnostics:h,extensions:A.mounts.map(e=>e.mountRef),resolvedExtensions:j,hooks:E.sources,lib:x.lib,instructions:v.instructions,sandbox:w.sandbox,sandboxWorkspaces:w.sandboxWorkspace===null?[]:[w.sandboxWorkspace],schedules:S.schedules,skills:O.skills,tools:T.sources,subagents:k.subagents};return y.module!==void 0&&(M.configModule=y.module),{diagnostics:h,manifest:createAgentSourceManifest(M)}}async function discoverExtensionMountDeclarations(n){let r=n.source??createDiskProjectSource(),i=resolve(n.agentRoot),a=await readSortedDirectoryEntries(r,i),s=await discoverNamedSourceDirectory({directoryName:`extensions`,invalidDirectoryCode:DISCOVER_EXTENSIONS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(i,`extensions`)}" to be a directory of extension mounts.`,recursive:!1,rootEntries:a,rootPath:i,source:r,validateSegment:createExtensionNameDiagnostic}),c=await collectExtensionMounts({agentRoot:i,fileMounts:s.sources,rootEntries:a,source:r});return{diagnostics:[...s.diagnostics,...c.diagnostics],mounts:c.mounts}}async function collectExtensionMounts(t){let r=[],i=join(t.agentRoot,`extensions`),o=t.fileMounts.map(e=>({namespace:mountNamespace(e.logicalPath),mountRef:e})),s=new Set(o.map(e=>e.namespace)),u=t.rootEntries.find(e=>e.name===`extensions`),d=[],f=new Set;if(u?.isDirectory()===!0){let o=await readSortedDirectoryEntries(t.source,i);for(let c of o){if(!c.isDirectory())continue;let o=c.name,u=join(i,o),p=createExtensionNameDiagnostic(o,u);if(p!==null){r.push(p);continue}let m=discoverFlatModuleSource({rootEntries:await readSortedDirectoryEntries(t.source,u),rootPath:u,slotName:`extension`});if(r.push(...m.diagnostics),m.module===void 0){r.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_MISSING_DECLARATION,message:`Extension mount directory "extensions/${o}/" must declare its mount in "extension.ts" (or another supported module extension).`,sourcePath:u}));continue}s.has(o)&&f.add(o),d.push({namespace:o,mountRef:createModuleSourceRef({logicalPath:normalizeLogicalPath(join(`extensions`,o,m.module.logicalPath))}),overridesRoot:u})}}for(let e of f)r.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_AMBIGUOUS,message:`Extension namespace "${e}" is claimed by both a file mount ("extensions/${e}.ts") and a directory mount ("extensions/${e}/"). Keep only one.`,sourcePath:i}));return{diagnostics:r,mounts:[...o,...d].filter(e=>!f.has(e.namespace))}}function detectRootNamespaceCollisions(t){if(t.namespaces.length===0)return[];let r=[];for(let i of t.sources){let a=rootContributionName(i.logicalPath),o=t.namespaces.find(e=>a.startsWith(`${e}__`));o!==void 0&&r.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_OVERRIDE_OUTSIDE_MOUNT,message:`"${i.logicalPath}" uses the "${o}__" prefix reserved for the mounted extension "${o}". Override an extension's contributions inside its mount directory ("extensions/${o}/…"), not at the agent root.`,sourcePath:join(t.agentRoot,i.logicalPath)}))}return r}function rootContributionName(e){let t=e.slice(e.indexOf(`/`)+1),n=t.split(`/`)[0]??t;for(let e of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(n.toLowerCase().endsWith(e))return n.slice(0,n.length-e.length);return n}async function tryReadPackageJsonName(t,n){try{let r=join(n,`package.json`),i=JSON.parse(await t.readTextFile(r)).name;return typeof i!=`string`||i.length===0?void 0:stripNpmPackageScope(i)}catch{return}}export{discoverAgent,discoverExtensionMountDeclarations};
@@ -32,11 +32,15 @@ export declare const DISCOVER_EXTENSION_OVERRIDE_OUTSIDE_MOUNT = "discover/exten
32
32
  */
33
33
  export declare const DISCOVER_EXTENSION_PACKAGE_INVALID = "discover/extension-package-invalid";
34
34
  /**
35
- * Emitted when the app's eve version does not satisfy an extension's declared
36
- * `peerDependencies.eve` range — the tie between an extension and the eve it was
37
- * built for.
35
+ * Emitted when an extension distribution's compatibility manifest is missing
36
+ * or malformed.
38
37
  */
39
- export declare const DISCOVER_EXTENSION_EVE_INCOMPATIBLE = "discover/extension-eve-incompatible";
38
+ export declare const DISCOVER_EXTENSION_COMPATIBILITY_INVALID = "discover/extension-compatibility-invalid";
39
+ /**
40
+ * Emitted when this eve cannot consume one of the extension capabilities the
41
+ * distribution requires.
42
+ */
43
+ export declare const DISCOVER_EXTENSION_CAPABILITY_INCOMPATIBLE = "discover/extension-capability-incompatible";
40
44
  /**
41
45
  * Emitted when an extension source tree declares agent-level config (`agent.ts`),
42
46
  * which is the consuming agent's to own.
@@ -65,9 +69,28 @@ export interface ExtensionMountLocation {
65
69
  readonly packageName: string;
66
70
  /** Absolute path to the resolved package root. */
67
71
  readonly packageRoot: string;
68
- /** Absolute path to the extension's agent-shaped source root. */
72
+ /** Absolute path to the extension's agent-shaped distribution root. */
69
73
  readonly sourceRoot: string;
70
74
  }
75
+ /**
76
+ * Package roots resolved from one extension mount before its distribution is
77
+ * inspected. Development uses this to build a mounted workspace extension
78
+ * before the consumer requires its dist tree to exist.
79
+ */
80
+ export interface ExtensionMountPackageLocation {
81
+ /** Mount namespace derived from the mount filename. */
82
+ readonly namespace: string;
83
+ /** Package specifier read from the mount declaration. */
84
+ readonly specifier: string;
85
+ /** Package name from the resolved package manifest. */
86
+ readonly packageName: string;
87
+ /** Absolute path to the resolved package root. */
88
+ readonly packageRoot: string;
89
+ /** Absolute authoring root when the package publishes a source-backed contract. */
90
+ readonly authoredSourceRoot?: string;
91
+ /** Absolute path to the agent-shaped distribution root. */
92
+ readonly distRoot: string;
93
+ }
71
94
  /**
72
95
  * Derives the mount namespace from an `extensions/<name>.<ext>` logical path.
73
96
  */
@@ -89,7 +112,7 @@ export declare function packageStateNamespace(packageName: string): string;
89
112
  * Resolves one extension mount to its package and agent-shaped source root
90
113
  * without importing the mount module. Reads the mount source text to extract
91
114
  * the package specifier, resolves the package, and reads
92
- * `package.json#eve.extension` for the source root.
115
+ * `package.json#eve.extension.dist` for the agent-shaped distribution root.
93
116
  */
94
117
  export declare function locateExtensionMount(input: {
95
118
  readonly source: ProjectSource;
@@ -101,9 +124,21 @@ export declare function locateExtensionMount(input: {
101
124
  * the file and directory mount forms name it at different path positions.
102
125
  */
103
126
  readonly namespace: string;
104
- /** The app's eve version, checked against the extension's `peerDependencies.eve`. */
105
- readonly eveVersion: string;
106
127
  }): Promise<{
107
128
  location?: ExtensionMountLocation;
108
129
  diagnostics: DiscoverDiagnostic[];
109
130
  }>;
131
+ /**
132
+ * Resolves one extension mount through its package manifest without requiring
133
+ * a built distribution or compatibility manifest.
134
+ */
135
+ export declare function locateExtensionMountPackage(input: {
136
+ readonly source: ProjectSource;
137
+ readonly agentRoot: string;
138
+ readonly appRoot: string;
139
+ readonly mount: ExtensionSourceRef;
140
+ readonly namespace: string;
141
+ }): Promise<{
142
+ location?: ExtensionMountPackageLocation;
143
+ diagnostics: DiscoverDiagnostic[];
144
+ }>;
@@ -1 +1 @@
1
- import{dirname,isAbsolute,join,resolve}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"#discover/filesystem.js";import semver from"#compiled/semver/index.js";import{parseExtensionMountSpecifier}from"#discover/extension-specifier.js";const DISCOVER_EXTENSION_MOUNT_UNRESOLVED=`discover/extension-mount-unresolved`,DISCOVER_EXTENSION_MOUNT_AMBIGUOUS=`discover/extension-mount-ambiguous`,DISCOVER_EXTENSION_MOUNT_MISSING_DECLARATION=`discover/extension-mount-missing-declaration`,DISCOVER_EXTENSION_NESTED_MOUNT_UNSUPPORTED=`discover/extension-nested-mount-unsupported`,DISCOVER_EXTENSION_OVERRIDE_OUTSIDE_MOUNT=`discover/extension-override-outside-mount`,DISCOVER_EXTENSION_PACKAGE_INVALID=`discover/extension-package-invalid`,DISCOVER_EXTENSION_EVE_INCOMPATIBLE=`discover/extension-eve-incompatible`,DISCOVER_EXTENSION_AGENT_CONFIG_UNSUPPORTED=`discover/extension-agent-config-unsupported`,DISCOVER_EXTENSION_SANDBOX_UNSUPPORTED=`discover/extension-sandbox-unsupported`,DISCOVER_EXTENSION_SCHEDULE_UNSUPPORTED=`discover/extension-schedule-unsupported`;function mountNamespace(e){let t=e.slice(e.lastIndexOf(`/`)+1);for(let e of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(t.toLowerCase().endsWith(e))return t.slice(0,t.length-e.length);return t}function mountRefNamespace(e){let t=e.replace(/^extensions\//,``),n=t.indexOf(`/`);return n===-1?mountNamespace(e):t.slice(0,n)}function packageStateNamespace(e){return e.replace(/^@/,``).replace(/[^a-zA-Z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)||`extension`}async function locateExtensionMount(t){let a=join(t.agentRoot,t.mount.logicalPath),{namespace:s}=t,c;try{c=await t.source.readTextFile(a)}catch{return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_UNRESOLVED,message:`Could not read extension mount "${t.mount.logicalPath}".`,sourcePath:a})]}}let l=parseExtensionMountSpecifier(c);if(l===null)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_UNRESOLVED,message:`Extension mount "${t.mount.logicalPath}" must default-export a mounted extension, e.g. \`export default crm({ ... })\` or \`export { default } from "@acme/crm"\`.`,sourcePath:a})]};let u=await resolvePackageRoot({source:t.source,appRoot:t.appRoot,mountDirectory:dirname(a),specifier:l});if(u===null)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_UNRESOLVED,message:`Could not resolve extension package "${l}" mounted by "${t.mount.logicalPath}".`,sourcePath:a})]};let d=join(u,`package.json`),f;try{f=JSON.parse(await t.source.readTextFile(d))}catch{return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_PACKAGE_INVALID,message:`Extension package "${l}" has no readable package.json at "${d}".`,sourcePath:d})]}}let p=f.eve?.extension;if(typeof p!=`string`||p.length===0)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_PACKAGE_INVALID,message:`Package "${l}" is not an eve extension: its package.json is missing the \`eve.extension\` source-root field.`,sourcePath:d})]};let m=typeof f.name==`string`&&f.name.length>0?f.name:l,h=f.peerDependencies?.eve;return typeof h==`string`&&semver.validRange(h)!==null&&!semver.intersects(t.eveVersion,h)?{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_EVE_INCOMPATIBLE,message:`Extension "${m}" requires eve "${h}", but this app uses eve ${t.eveVersion}. Upgrade the extension to a version that supports this eve, or align your eve version.`,sourcePath:d})]}:{location:{namespace:s,specifier:l,packageName:m,packageRoot:u,sourceRoot:resolve(u,p)},diagnostics:[]}}async function resolvePackageRoot(i){if(i.specifier.startsWith(`.`)){let e=resolve(i.mountDirectory,i.specifier);return await hasPackageJson(i.source,e)?e:null}if(isAbsolute(i.specifier))return await hasPackageJson(i.source,i.specifier)?i.specifier:null;let a=bareSpecifierPackagePath(i.specifier),o=resolve(i.appRoot);for(;;){let t=join(o,`node_modules`,a);if(await hasPackageJson(i.source,t))return t;let r=dirname(o);if(r===o)return null;o=r}}function bareSpecifierPackagePath(e){let t=e.split(`/`);return e.startsWith(`@`)?t.slice(0,2).join(`/`):t[0]??e}async function hasPackageJson(e,t){return await e.stat(join(t,`package.json`))===`file`}export{DISCOVER_EXTENSION_AGENT_CONFIG_UNSUPPORTED,DISCOVER_EXTENSION_EVE_INCOMPATIBLE,DISCOVER_EXTENSION_MOUNT_AMBIGUOUS,DISCOVER_EXTENSION_MOUNT_MISSING_DECLARATION,DISCOVER_EXTENSION_MOUNT_UNRESOLVED,DISCOVER_EXTENSION_NESTED_MOUNT_UNSUPPORTED,DISCOVER_EXTENSION_OVERRIDE_OUTSIDE_MOUNT,DISCOVER_EXTENSION_PACKAGE_INVALID,DISCOVER_EXTENSION_SANDBOX_UNSUPPORTED,DISCOVER_EXTENSION_SCHEDULE_UNSUPPORTED,locateExtensionMount,mountNamespace,mountRefNamespace,packageStateNamespace};
1
+ import{dirname,isAbsolute,join,resolve}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"#discover/filesystem.js";import{EXTENSION_COMPATIBILITY_MANIFEST_FILENAME,findUnsupportedExtensionCapabilities,parseExtensionCompatibilityManifest}from"#compiler/extension-compatibility.js";import{parseExtensionMountSpecifier}from"#discover/extension-specifier.js";import{parseExtensionPackageRoots}from"#shared/extension-package-contract.js";const DISCOVER_EXTENSION_MOUNT_UNRESOLVED=`discover/extension-mount-unresolved`,DISCOVER_EXTENSION_MOUNT_AMBIGUOUS=`discover/extension-mount-ambiguous`,DISCOVER_EXTENSION_MOUNT_MISSING_DECLARATION=`discover/extension-mount-missing-declaration`,DISCOVER_EXTENSION_NESTED_MOUNT_UNSUPPORTED=`discover/extension-nested-mount-unsupported`,DISCOVER_EXTENSION_OVERRIDE_OUTSIDE_MOUNT=`discover/extension-override-outside-mount`,DISCOVER_EXTENSION_PACKAGE_INVALID=`discover/extension-package-invalid`,DISCOVER_EXTENSION_COMPATIBILITY_INVALID=`discover/extension-compatibility-invalid`,DISCOVER_EXTENSION_CAPABILITY_INCOMPATIBLE=`discover/extension-capability-incompatible`,DISCOVER_EXTENSION_AGENT_CONFIG_UNSUPPORTED=`discover/extension-agent-config-unsupported`,DISCOVER_EXTENSION_SANDBOX_UNSUPPORTED=`discover/extension-sandbox-unsupported`,DISCOVER_EXTENSION_SCHEDULE_UNSUPPORTED=`discover/extension-schedule-unsupported`;function mountNamespace(e){let t=e.slice(e.lastIndexOf(`/`)+1);for(let e of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(t.toLowerCase().endsWith(e))return t.slice(0,t.length-e.length);return t}function mountRefNamespace(e){let t=e.replace(/^extensions\//,``),n=t.indexOf(`/`);return n===-1?mountNamespace(e):t.slice(0,n)}function packageStateNamespace(e){return e.replace(/^@/,``).replace(/[^a-zA-Z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)||`extension`}async function locateExtensionMount(e){let t=await locateExtensionMountPackage(e);if(t.location===void 0)return{diagnostics:t.diagnostics};let{location:r}=t,a=join(r.distRoot,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME),l;try{l=parseExtensionCompatibilityManifest(await e.source.readTextFile(a),a)}catch(e){return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_COMPATIBILITY_INVALID,message:`Extension "${r.packageName}" has no valid compatibility manifest at "${a}". Rebuild or reinstall the extension. ${e instanceof Error?e.message:String(e)}`,sourcePath:a})]}}let u=findUnsupportedExtensionCapabilities(l);return u.length>0?{diagnostics:u.map(e=>createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_CAPABILITY_INCOMPATIBLE,message:`Extension "${r.packageName}" requires ${e.capability} contract v${e.requiredVersion}, but this eve supports ${e.capability} contract ${formatSupportedVersions(e.supportedVersions)}. Upgrade eve or install an extension release that requires a supported ${e.capability} contract.`,sourcePath:a}))}:{location:{namespace:r.namespace,specifier:r.specifier,packageName:r.packageName,packageRoot:r.packageRoot,sourceRoot:r.distRoot},diagnostics:[]}}async function locateExtensionMountPackage(t){let a=join(t.agentRoot,t.mount.logicalPath),{namespace:o}=t,s;try{s=await t.source.readTextFile(a)}catch{return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_UNRESOLVED,message:`Could not read extension mount "${t.mount.logicalPath}".`,sourcePath:a})]}}let c=parseExtensionMountSpecifier(s);if(c===null)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_UNRESOLVED,message:`Extension mount "${t.mount.logicalPath}" must default-export a mounted extension, e.g. \`export default crm({ ... })\` or \`export { default } from "@acme/crm"\`.`,sourcePath:a})]};let d=await resolvePackageRoot({source:t.source,appRoot:t.appRoot,mountDirectory:dirname(a),specifier:c});if(d===null)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_UNRESOLVED,message:`Could not resolve extension package "${c}" mounted by "${t.mount.logicalPath}".`,sourcePath:a})]};let f=join(d,`package.json`),p;try{p=JSON.parse(await t.source.readTextFile(f))}catch{return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_PACKAGE_INVALID,message:`Extension package "${c}" has no readable package.json at "${f}".`,sourcePath:f})]}}let m=parseExtensionPackageRoots(p.eve?.extension);return m===null?{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_PACKAGE_INVALID,message:`Package "${c}" is not an eve extension: its package.json must declare \`eve.extension.dist\`.`,sourcePath:f})]}:{location:{namespace:o,specifier:c,packageName:typeof p.name==`string`&&p.name.length>0?p.name:c,packageRoot:d,...m.source===void 0?{}:{authoredSourceRoot:resolve(d,m.source)},distRoot:resolve(d,m.dist)},diagnostics:[]}}function formatSupportedVersions(e){return e.length===0?`versions: none`:`versions: ${e.map(e=>`v${e}`).join(`, `)}`}async function resolvePackageRoot(i){if(i.specifier.startsWith(`.`)){let e=resolve(i.mountDirectory,i.specifier);return await hasPackageJson(i.source,e)?e:null}if(isAbsolute(i.specifier))return await hasPackageJson(i.source,i.specifier)?i.specifier:null;let a=bareSpecifierPackagePath(i.specifier),o=resolve(i.appRoot);for(;;){let t=join(o,`node_modules`,a);if(await hasPackageJson(i.source,t))return t;let r=dirname(o);if(r===o)return null;o=r}}function bareSpecifierPackagePath(e){let t=e.split(`/`);return e.startsWith(`@`)?t.slice(0,2).join(`/`):t[0]??e}async function hasPackageJson(e,t){return await e.stat(join(t,`package.json`))===`file`}export{DISCOVER_EXTENSION_AGENT_CONFIG_UNSUPPORTED,DISCOVER_EXTENSION_CAPABILITY_INCOMPATIBLE,DISCOVER_EXTENSION_COMPATIBILITY_INVALID,DISCOVER_EXTENSION_MOUNT_AMBIGUOUS,DISCOVER_EXTENSION_MOUNT_MISSING_DECLARATION,DISCOVER_EXTENSION_MOUNT_UNRESOLVED,DISCOVER_EXTENSION_NESTED_MOUNT_UNSUPPORTED,DISCOVER_EXTENSION_OVERRIDE_OUTSIDE_MOUNT,DISCOVER_EXTENSION_PACKAGE_INVALID,DISCOVER_EXTENSION_SANDBOX_UNSUPPORTED,DISCOVER_EXTENSION_SCHEDULE_UNSUPPORTED,locateExtensionMount,locateExtensionMountPackage,mountNamespace,mountRefNamespace,packageStateNamespace};
@@ -27,7 +27,7 @@ export type SkillPackageEntryKind = "skill-assets-directory" | "skill-markdown"
27
27
  /**
28
28
  * Classified top-level entry inside `skills/`.
29
29
  */
30
- export type SkillsDirectoryEntryKind = "flat-skill-markdown" | "flat-skill-module" | "skill-package-directory" | "unknown";
30
+ export type SkillsDirectoryEntryKind = "flat-skill-markdown" | "flat-skill-module" | "ignored-declaration" | "skill-package-directory" | "unknown";
31
31
  /**
32
32
  * Returns the normalized entry type for a Node filesystem dirent.
33
33
  */
@@ -61,6 +61,8 @@ export declare function normalizeLogicalPath(input: string): string;
61
61
  * extension.
62
62
  */
63
63
  export declare function getSupportedModuleBaseName(name: string): string | null;
64
+ /** Returns whether a filename is a TypeScript declaration module. */
65
+ export declare function isTypeScriptDeclarationFileName(name: string): boolean;
64
66
  /**
65
67
  * Returns whether the file name matches one supported authored module basename.
66
68
  */
@@ -1 +1 @@
1
- import{sep}from"node:path";const SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS=[`.cts`,`.mts`,`.cjs`,`.mjs`,`.ts`,`.js`],PROJECT_MARKER_FILE_NAMES=[`package.json`,`vercel.json`],PROJECT_MARKER_FILE_NAME_SET=new Set(PROJECT_MARKER_FILE_NAMES),GENERATED_AGENT_DIRECTORY_NAMES=new Set([`.eve`,`.next`,`.output`,`.vercel`,`node_modules`]);function getDirectoryEntryType(e){return e.isDirectory()?`directory`:e.isFile()?`file`:`other`}function isProjectMarkerEntry(e,t){return t===`file`&&PROJECT_MARKER_FILE_NAME_SET.has(e)}function classifyAgentRootEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e.toLowerCase()===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e.toLowerCase()===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(GENERATED_AGENT_DIRECTORY_NAMES.has(e))return`ignored-directory`;if(e===`channels`)return`channels-directory`;if(e===`connections`)return`connections-directory`;if(e===`extensions`)return`extensions-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`instructions`)return`instructions-directory`;if(e===`lib`)return`lib-directory`;if(e===`skills`)return`skills-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`tools`)return`tools-directory`;if(e===`schedules`)return`schedules-directory`;if(e===`subagents`)return`subagents-directory`}return`unknown`}function classifyLocalSubagentEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e.toLowerCase()===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e.toLowerCase()===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(GENERATED_AGENT_DIRECTORY_NAMES.has(e))return`ignored-directory`;if(e===`connections`)return`connections-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`instructions`)return`instructions-directory`;if(e===`lib`)return`lib-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`skills`)return`skills-directory`;if(e===`tools`)return`tools-directory`;if(e===`subagents`)return`subagents-directory`;if(e===`schedules`)return`invalid-schedules-directory`}return`unknown`}function classifySkillPackageEntry(e,t){if(t===`file`)return e.toLowerCase()===`skill.md`?`skill-markdown`:`skill-resource`;if(t===`directory`){if(e===`scripts`)return`skill-scripts-directory`;if(e===`references`)return`skill-references-directory`;if(e===`assets`)return`skill-assets-directory`}return`skill-resource`}function classifySkillsDirectoryEntry(e,t){if(t===`directory`)return`skill-package-directory`;if(t===`file`){if(e.toLowerCase().endsWith(`.md`))return`flat-skill-markdown`;if(getSupportedModuleBaseName(e)!==null)return`flat-skill-module`}return`unknown`}function normalizeLogicalPath(t){return t.replaceAll(sep,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function getSupportedModuleBaseName(e){for(let n of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(e.endsWith(n)&&e.length>n.length)return e.slice(0,-n.length);return null}function matchesSupportedModuleBaseName(e,t){return getSupportedModuleBaseName(e)===t}function stripLogicalPathExtension(e){let t=normalizeLogicalPath(e),n=t.lastIndexOf(`/`),r=t.lastIndexOf(`.`);return r===-1||r<n?t:t.slice(0,r)}export{PROJECT_MARKER_FILE_NAMES,SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS,classifyAgentRootEntry,classifyLocalSubagentEntry,classifySkillPackageEntry,classifySkillsDirectoryEntry,getDirectoryEntryType,getSupportedModuleBaseName,isProjectMarkerEntry,matchesSupportedModuleBaseName,normalizeLogicalPath,stripLogicalPathExtension};
1
+ import{sep}from"node:path";const SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS=[`.cts`,`.mts`,`.cjs`,`.mjs`,`.ts`,`.js`],PROJECT_MARKER_FILE_NAMES=[`package.json`,`vercel.json`],PROJECT_MARKER_FILE_NAME_SET=new Set(PROJECT_MARKER_FILE_NAMES),GENERATED_AGENT_DIRECTORY_NAMES=new Set([`.eve`,`.next`,`.output`,`.vercel`,`node_modules`]);function getDirectoryEntryType(e){return e.isDirectory()?`directory`:e.isFile()?`file`:`other`}function isProjectMarkerEntry(e,t){return t===`file`&&PROJECT_MARKER_FILE_NAME_SET.has(e)}function classifyAgentRootEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e.toLowerCase()===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e.toLowerCase()===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(GENERATED_AGENT_DIRECTORY_NAMES.has(e))return`ignored-directory`;if(e===`channels`)return`channels-directory`;if(e===`connections`)return`connections-directory`;if(e===`extensions`)return`extensions-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`instructions`)return`instructions-directory`;if(e===`lib`)return`lib-directory`;if(e===`skills`)return`skills-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`tools`)return`tools-directory`;if(e===`schedules`)return`schedules-directory`;if(e===`subagents`)return`subagents-directory`}return`unknown`}function classifyLocalSubagentEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e.toLowerCase()===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e.toLowerCase()===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(GENERATED_AGENT_DIRECTORY_NAMES.has(e))return`ignored-directory`;if(e===`connections`)return`connections-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`instructions`)return`instructions-directory`;if(e===`lib`)return`lib-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`skills`)return`skills-directory`;if(e===`tools`)return`tools-directory`;if(e===`subagents`)return`subagents-directory`;if(e===`schedules`)return`invalid-schedules-directory`}return`unknown`}function classifySkillPackageEntry(e,t){if(t===`file`)return e.toLowerCase()===`skill.md`?`skill-markdown`:`skill-resource`;if(t===`directory`){if(e===`scripts`)return`skill-scripts-directory`;if(e===`references`)return`skill-references-directory`;if(e===`assets`)return`skill-assets-directory`}return`skill-resource`}function classifySkillsDirectoryEntry(e,t){if(t===`directory`)return`skill-package-directory`;if(t===`file`){if(isTypeScriptDeclarationFileName(e))return`ignored-declaration`;if(e.toLowerCase().endsWith(`.md`))return`flat-skill-markdown`;if(getSupportedModuleBaseName(e)!==null)return`flat-skill-module`}return`unknown`}function normalizeLogicalPath(t){return t.replaceAll(sep,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function getSupportedModuleBaseName(e){if(isTypeScriptDeclarationFileName(e))return null;for(let n of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(e.endsWith(n)&&e.length>n.length)return e.slice(0,-n.length);return null}function isTypeScriptDeclarationFileName(e){return/\.d\.(?:cts|mts|ts)$/.test(e)}function matchesSupportedModuleBaseName(e,t){return getSupportedModuleBaseName(e)===t}function stripLogicalPathExtension(e){let t=normalizeLogicalPath(e),n=t.lastIndexOf(`/`),r=t.lastIndexOf(`.`);return r===-1||r<n?t:t.slice(0,r)}export{PROJECT_MARKER_FILE_NAMES,SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS,classifyAgentRootEntry,classifyLocalSubagentEntry,classifySkillPackageEntry,classifySkillsDirectoryEntry,getDirectoryEntryType,getSupportedModuleBaseName,isProjectMarkerEntry,isTypeScriptDeclarationFileName,matchesSupportedModuleBaseName,normalizeLogicalPath,stripLogicalPathExtension};
@@ -1 +1 @@
1
- import{join}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{getDirectoryEntryType,getSupportedModuleBaseName,normalizeLogicalPath}from"#discover/filesystem.js";import{createModuleSourceRef}from"#discover/manifest.js";import{createModuleSlotCollisionDiagnostic,createSlotCollisionDiagnostic,readSortedDirectoryEntries}from"#discover/grammar.js";import{collectNamedSlotCandidates}from"#discover/slots.js";import{discoverMarkdownSource}from"#discover/markdown.js";async function discoverNamedSourceDirectory(n){let r=join(n.rootPath,n.directoryName),i=n.rootEntries.find(e=>e.name===n.directoryName);if(i===void 0)return{diagnostics:[],sources:[]};if(!i.isDirectory())return{diagnostics:[createDiscoverErrorDiagnostic({code:n.invalidDirectoryCode,message:n.invalidDirectoryMessage,sourcePath:r})],sources:[]};let a=[],o=[];return await walkNamedSourceDirectory({allowMarkdown:n.allowMarkdown===!0,diagnostics:a,markdownLowerer:n.allowMarkdown===!0?n.markdownLowerer:void 0,projectSource:n.source,recursive:n.recursive,relativeDirectory:n.directoryName,rootDirectoryPath:r,sources:o,subdirectoryRelative:``,unsupportedEntryCode:n.unsupportedEntryCode,unsupportedEntryMessage:n.unsupportedEntryMessage,unsupportedFileCode:n.unsupportedFileCode,unsupportedFileMessage:n.unsupportedFileMessage,validateSegment:n.validateSegment}),{diagnostics:a,sources:o}}async function walkNamedSourceDirectory(t){let n=t.subdirectoryRelative===``?t.rootDirectoryPath:join(t.rootDirectoryPath,t.subdirectoryRelative),r=await readSortedDirectoryEntries(t.projectSource,n);t.recursive&&await walkSubdirectories(t,r,n),(t.unsupportedFileCode!==void 0||t.unsupportedEntryCode!==void 0)&&emitUnsupportedLeafDiagnostics(t,r,n),await collectLeafSources(t,r,n)}async function walkSubdirectories(t,n,r){for(let i of n){if(!i.isDirectory())continue;let n=join(r,i.name);if(t.validateSegment!==void 0){let e=t.validateSegment(i.name,n);if(e!==null){t.diagnostics.push(e);continue}}await walkNamedSourceDirectory({allowMarkdown:t.allowMarkdown,diagnostics:t.diagnostics,markdownLowerer:t.markdownLowerer,projectSource:t.projectSource,recursive:t.recursive,relativeDirectory:t.relativeDirectory,rootDirectoryPath:t.rootDirectoryPath,sources:t.sources,subdirectoryRelative:t.subdirectoryRelative===``?i.name:join(t.subdirectoryRelative,i.name),unsupportedEntryCode:t.unsupportedEntryCode,unsupportedEntryMessage:t.unsupportedEntryMessage,unsupportedFileCode:t.unsupportedFileCode,unsupportedFileMessage:t.unsupportedFileMessage,validateSegment:t.validateSegment})}}function emitUnsupportedLeafDiagnostics(i,a,o){for(let s of a){let a=getDirectoryEntryType(s),c=join(o,s.name);if(a===`directory`)continue;if(a===`other`){i.unsupportedEntryCode!==void 0&&i.diagnostics.push(createDiscoverErrorDiagnostic({code:i.unsupportedEntryCode,message:i.unsupportedEntryMessage?.(c,i.relativeDirectory)??`Expected "${c}" to be a regular file or directory within "${i.relativeDirectory}/".`,sourcePath:c}));continue}if(i.unsupportedFileCode===void 0)continue;let l=getSupportedModuleBaseName(s.name)!==null,u=i.allowMarkdown&&s.name.endsWith(`.md`);l||u||i.diagnostics.push(createDiscoverErrorDiagnostic({code:i.unsupportedFileCode,message:i.unsupportedFileMessage?.(c,i.relativeDirectory)??`Expected "${c}" to be a supported authored source within "${i.relativeDirectory}/".`,sourcePath:c}))}}async function collectLeafSources(t,n,r){for(let c of collectNamedSlotCandidates(n,{allowMarkdown:t.allowMarkdown,allowModules:!0})){let n=t.subdirectoryRelative===``?c.slotName:join(t.subdirectoryRelative,c.slotName),l=normalizeLogicalPath(join(t.relativeDirectory,n));if(t.validateSegment!==void 0){let n=c.markdownFileName??c.moduleFileNames[0]??c.slotName,i=t.validateSegment(c.slotName,join(r,n));if(i!==null){t.diagnostics.push(i);continue}}if(c.markdownFileName!==void 0&&c.moduleFileNames.length>0){t.diagnostics.push(createSlotCollisionDiagnostic(r,l,[c.markdownFileName,...c.moduleFileNames]));continue}if(c.moduleFileNames.length>1){t.diagnostics.push(createModuleSlotCollisionDiagnostic(r,l,c.moduleFileNames));continue}if(c.markdownFileName!==void 0){let n=t.subdirectoryRelative===``?c.markdownFileName:join(t.subdirectoryRelative,c.markdownFileName),r=normalizeLogicalPath(join(t.relativeDirectory,n));if(t.markdownLowerer===void 0)continue;let a=await discoverMarkdownSource({logicalPath:r,lower:t.markdownLowerer,source:t.projectSource,sourcePath:join(t.rootDirectoryPath,n)});t.sources.push(a);continue}let[d]=c.moduleFileNames;if(d===void 0)continue;let f=t.subdirectoryRelative===``?d:join(t.subdirectoryRelative,d);t.sources.push(createModuleSourceRef({logicalPath:normalizeLogicalPath(join(t.relativeDirectory,f))}))}}export{discoverNamedSourceDirectory};
1
+ import{join}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{getDirectoryEntryType,getSupportedModuleBaseName,isTypeScriptDeclarationFileName,normalizeLogicalPath}from"#discover/filesystem.js";import{createModuleSourceRef}from"#discover/manifest.js";import{createModuleSlotCollisionDiagnostic,createSlotCollisionDiagnostic,readSortedDirectoryEntries}from"#discover/grammar.js";import{collectNamedSlotCandidates}from"#discover/slots.js";import{discoverMarkdownSource}from"#discover/markdown.js";async function discoverNamedSourceDirectory(n){let r=join(n.rootPath,n.directoryName),i=n.rootEntries.find(e=>e.name===n.directoryName);if(i===void 0)return{diagnostics:[],sources:[]};if(!i.isDirectory())return{diagnostics:[createDiscoverErrorDiagnostic({code:n.invalidDirectoryCode,message:n.invalidDirectoryMessage,sourcePath:r})],sources:[]};let a=[],o=[];return await walkNamedSourceDirectory({allowMarkdown:n.allowMarkdown===!0,diagnostics:a,markdownLowerer:n.allowMarkdown===!0?n.markdownLowerer:void 0,projectSource:n.source,recursive:n.recursive,relativeDirectory:n.directoryName,rootDirectoryPath:r,sources:o,subdirectoryRelative:``,unsupportedEntryCode:n.unsupportedEntryCode,unsupportedEntryMessage:n.unsupportedEntryMessage,unsupportedFileCode:n.unsupportedFileCode,unsupportedFileMessage:n.unsupportedFileMessage,validateSegment:n.validateSegment}),{diagnostics:a,sources:o}}async function walkNamedSourceDirectory(t){let n=t.subdirectoryRelative===``?t.rootDirectoryPath:join(t.rootDirectoryPath,t.subdirectoryRelative),r=await readSortedDirectoryEntries(t.projectSource,n);t.recursive&&await walkSubdirectories(t,r,n),(t.unsupportedFileCode!==void 0||t.unsupportedEntryCode!==void 0)&&emitUnsupportedLeafDiagnostics(t,r,n),await collectLeafSources(t,r,n)}async function walkSubdirectories(t,n,r){for(let i of n){if(!i.isDirectory())continue;let n=join(r,i.name);if(t.validateSegment!==void 0){let e=t.validateSegment(i.name,n);if(e!==null){t.diagnostics.push(e);continue}}await walkNamedSourceDirectory({allowMarkdown:t.allowMarkdown,diagnostics:t.diagnostics,markdownLowerer:t.markdownLowerer,projectSource:t.projectSource,recursive:t.recursive,relativeDirectory:t.relativeDirectory,rootDirectoryPath:t.rootDirectoryPath,sources:t.sources,subdirectoryRelative:t.subdirectoryRelative===``?i.name:join(t.subdirectoryRelative,i.name),unsupportedEntryCode:t.unsupportedEntryCode,unsupportedEntryMessage:t.unsupportedEntryMessage,unsupportedFileCode:t.unsupportedFileCode,unsupportedFileMessage:t.unsupportedFileMessage,validateSegment:t.validateSegment})}}function emitUnsupportedLeafDiagnostics(a,o,s){for(let c of o){let o=getDirectoryEntryType(c),l=join(s,c.name);if(o===`directory`)continue;if(o===`other`){a.unsupportedEntryCode!==void 0&&a.diagnostics.push(createDiscoverErrorDiagnostic({code:a.unsupportedEntryCode,message:a.unsupportedEntryMessage?.(l,a.relativeDirectory)??`Expected "${l}" to be a regular file or directory within "${a.relativeDirectory}/".`,sourcePath:l}));continue}if(a.unsupportedFileCode===void 0||isTypeScriptDeclarationFileName(c.name))continue;let u=getSupportedModuleBaseName(c.name)!==null,d=a.allowMarkdown&&c.name.endsWith(`.md`);u||d||a.diagnostics.push(createDiscoverErrorDiagnostic({code:a.unsupportedFileCode,message:a.unsupportedFileMessage?.(l,a.relativeDirectory)??`Expected "${l}" to be a supported authored source within "${a.relativeDirectory}/".`,sourcePath:l}))}}async function collectLeafSources(t,n,r){for(let i of collectNamedSlotCandidates(n,{allowMarkdown:t.allowMarkdown,allowModules:!0})){let n=t.subdirectoryRelative===``?i.slotName:join(t.subdirectoryRelative,i.slotName),l=normalizeLogicalPath(join(t.relativeDirectory,n));if(t.validateSegment!==void 0){let n=i.markdownFileName??i.moduleFileNames[0]??i.slotName,a=t.validateSegment(i.slotName,join(r,n));if(a!==null){t.diagnostics.push(a);continue}}if(i.markdownFileName!==void 0&&i.moduleFileNames.length>0){t.diagnostics.push(createSlotCollisionDiagnostic(r,l,[i.markdownFileName,...i.moduleFileNames]));continue}if(i.moduleFileNames.length>1){t.diagnostics.push(createModuleSlotCollisionDiagnostic(r,l,i.moduleFileNames));continue}if(i.markdownFileName!==void 0){let n=t.subdirectoryRelative===``?i.markdownFileName:join(t.subdirectoryRelative,i.markdownFileName),r=normalizeLogicalPath(join(t.relativeDirectory,n));if(t.markdownLowerer===void 0)continue;let o=await discoverMarkdownSource({logicalPath:r,lower:t.markdownLowerer,source:t.projectSource,sourcePath:join(t.rootDirectoryPath,n)});t.sources.push(o);continue}let[u]=i.moduleFileNames;if(u===void 0)continue;let f=t.subdirectoryRelative===``?u:join(t.subdirectoryRelative,u);t.sources.push(createModuleSourceRef({logicalPath:normalizeLogicalPath(join(t.relativeDirectory,f))}))}}export{discoverNamedSourceDirectory};
@@ -1 +1 @@
1
- import{join,relative,resolve}from"node:path";import{toErrorMessage}from"#shared/errors.js";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{classifySkillPackageEntry,classifySkillsDirectoryEntry,getDirectoryEntryType,getSupportedModuleBaseName,normalizeLogicalPath}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";import{createModuleSourceRef,createPathDerivedSourceId,createSkillPackageSourceRef}from"#discover/manifest.js";import{readSortedDirectoryEntries}from"#discover/grammar.js";import{lowerSkillMarkdown}from"#internal/helpers/markdown.js";const DISCOVER_SKILLS_DIRECTORY_INVALID=`discover/skills-directory-invalid`,DISCOVER_SKILL_COLLISION=`discover/skill-collision`,DISCOVER_SKILL_ENTRY_NOT_DIRECTORY=`discover/skill-entry-not-directory`,DISCOVER_SKILL_FRONTMATTER_INVALID=`discover/skill-frontmatter-invalid`,DISCOVER_SKILL_MARKDOWN_MISSING=`discover/skill-markdown-missing`;async function discoverSkills(r){let a=r.source??createDiskProjectSource(),o=resolve(r.agentRoot),c=resolve(r.skillsDirectoryPath??join(o,`skills`)),l=normalizeLogicalPath(r.skillsLogicalPath??relative(o,c)),u=await a.stat(c);if(u===`missing`)return{diagnostics:[],skills:[]};if(u!==`directory`)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILLS_DIRECTORY_INVALID,message:`Expected "${c}" to be a directory of authored skills.`,sourcePath:c})],skills:[]};let d=[],f=new Set,p=new Map,m=await readSortedDirectoryEntries(a,c);for(let t of m){let n=await discoverOneSkill({entryName:t.name,entryType:getDirectoryEntryType(t),skillsDirectoryPath:c,skillsLogicalPath:l,source:a});if(d.push(...n.diagnostics),n.skill===null||n.skillId===null||f.has(n.skillId))continue;let r=p.get(n.skillId);if(r!==void 0){d.push(createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_COLLISION,message:`Found conflicting authored skill sources for "${n.skillId}": "${r.logicalPath}" and "${n.logicalPath}".`,sourcePath:join(c,n.skillId)})),f.add(n.skillId),p.delete(n.skillId);continue}p.set(n.skillId,{logicalPath:n.logicalPath,skill:n.skill})}return{diagnostics:d,skills:[...p.values()].map(e=>e.skill)}}async function discoverOneSkill(t){let n=join(t.skillsDirectoryPath,t.entryName);switch(classifySkillsDirectoryEntry(t.entryName,t.entryType)){case`skill-package-directory`:return discoverPackagedSkill({logicalSkillsPath:t.skillsLogicalPath,skillId:t.entryName,skillRootPath:n,source:t.source});case`flat-skill-markdown`:return discoverFlatMarkdownSkill({logicalSkillsPath:t.skillsLogicalPath,skillFileName:t.entryName,skillFilePath:n,source:t.source});case`flat-skill-module`:return discoverFlatModuleSkill({logicalSkillsPath:t.skillsLogicalPath,skillFileName:t.entryName});default:return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_ENTRY_NOT_DIRECTORY,message:`Expected "${n}" to be a skill directory containing SKILL.md or a flat ".md", ".ts", ".cts", ".mts", ".js", ".cjs", or ".mjs" skill file.`,sourcePath:n})],logicalPath:normalizeLogicalPath(join(t.skillsLogicalPath,t.entryName)),skill:null,skillId:null}}}async function discoverPackagedSkill(t){let n=(await readSortedDirectoryEntries(t.source,t.skillRootPath)).find(e=>e.isFile()&&e.name.toLowerCase()===`skill.md`)?.name,r=join(t.skillRootPath,n??`SKILL.md`),a=normalizeLogicalPath(join(t.logicalSkillsPath,t.skillId,n??`SKILL.md`));if(n===void 0)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_MARKDOWN_MISSING,message:`Expected "${r}" to exist for the "${t.skillId}" skill.`,sourcePath:t.skillRootPath})],logicalPath:a,skill:null,skillId:null};let o;try{o=lowerSkillMarkdown(await t.source.readTextFile(r))}catch(e){return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_FRONTMATTER_INVALID,message:formatSkillDiscoveryError(r,e),sourcePath:r})],logicalPath:a,skill:null,skillId:null}}let s=await discoverSkillPackagePaths(t.source,t.skillRootPath),c={description:o.description,logicalPath:a,markdown:o.markdown,name:t.skillId,rootPath:t.skillRootPath,skillFilePath:r,skillId:t.skillId,sourceId:createPathDerivedSourceId(a)};return s.assetsPath!==void 0&&(c.assetsPath=s.assetsPath),o.license!==void 0&&(c.license=o.license),o.metadata!==void 0&&(c.metadata=o.metadata),s.referencesPath!==void 0&&(c.referencesPath=s.referencesPath),s.scriptsPath!==void 0&&(c.scriptsPath=s.scriptsPath),{diagnostics:[],logicalPath:a,skill:createSkillPackageSourceRef(c),skillId:t.skillId}}async function discoverFlatMarkdownSkill(t){let n=stripMarkdownExtension(t.skillFileName),r=normalizeLogicalPath(join(t.logicalSkillsPath,t.skillFileName)),a;try{a=lowerSkillMarkdown(await t.source.readTextFile(t.skillFilePath),{slug:n})}catch(e){return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_FRONTMATTER_INVALID,message:formatSkillDiscoveryError(t.skillFilePath,e),sourcePath:t.skillFilePath})],logicalPath:r,skill:null,skillId:null}}return{diagnostics:[],logicalPath:r,skill:{definition:a,sourceKind:`markdown`,logicalPath:r,sourceId:createPathDerivedSourceId(r)},skillId:n}}async function discoverFlatModuleSkill(t){let n=getSupportedModuleBaseName(t.skillFileName),r=normalizeLogicalPath(join(t.logicalSkillsPath,t.skillFileName));return n===null?{diagnostics:[],logicalPath:r,skill:null,skillId:null}:{diagnostics:[],logicalPath:r,skill:createModuleSourceRef({logicalPath:r}),skillId:n}}async function discoverSkillPackagePaths(t,n){let r=await t.readDirectory(n),i={};for(let t of r)if(t.isDirectory())switch(classifySkillPackageEntry(t.name,getDirectoryEntryType(t))){case`skill-assets-directory`:i.assetsPath=join(n,t.name);break;case`skill-references-directory`:i.referencesPath=join(n,t.name);break;case`skill-scripts-directory`:i.scriptsPath=join(n,t.name);break;default:break}return i}function formatSkillDiscoveryError(e,t){return`Invalid authored skill frontmatter in "${e}": ${toErrorMessage(t)}`}function stripMarkdownExtension(e){return e.toLowerCase().endsWith(`.md`)?e.slice(0,-3):e}export{DISCOVER_SKILLS_DIRECTORY_INVALID,DISCOVER_SKILL_COLLISION,DISCOVER_SKILL_ENTRY_NOT_DIRECTORY,DISCOVER_SKILL_FRONTMATTER_INVALID,DISCOVER_SKILL_MARKDOWN_MISSING,discoverSkills};
1
+ import{join,relative,resolve}from"node:path";import{toErrorMessage}from"#shared/errors.js";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{classifySkillPackageEntry,classifySkillsDirectoryEntry,getDirectoryEntryType,getSupportedModuleBaseName,normalizeLogicalPath}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";import{createModuleSourceRef,createPathDerivedSourceId,createSkillPackageSourceRef}from"#discover/manifest.js";import{readSortedDirectoryEntries}from"#discover/grammar.js";import{lowerSkillMarkdown}from"#internal/helpers/markdown.js";const DISCOVER_SKILLS_DIRECTORY_INVALID=`discover/skills-directory-invalid`,DISCOVER_SKILL_COLLISION=`discover/skill-collision`,DISCOVER_SKILL_ENTRY_NOT_DIRECTORY=`discover/skill-entry-not-directory`,DISCOVER_SKILL_FRONTMATTER_INVALID=`discover/skill-frontmatter-invalid`,DISCOVER_SKILL_MARKDOWN_MISSING=`discover/skill-markdown-missing`;async function discoverSkills(r){let a=r.source??createDiskProjectSource(),o=resolve(r.agentRoot),c=resolve(r.skillsDirectoryPath??join(o,`skills`)),l=normalizeLogicalPath(r.skillsLogicalPath??relative(o,c)),u=await a.stat(c);if(u===`missing`)return{diagnostics:[],skills:[]};if(u!==`directory`)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILLS_DIRECTORY_INVALID,message:`Expected "${c}" to be a directory of authored skills.`,sourcePath:c})],skills:[]};let d=[],f=new Set,p=new Map,m=await readSortedDirectoryEntries(a,c);for(let t of m){let n=await discoverOneSkill({entryName:t.name,entryType:getDirectoryEntryType(t),skillsDirectoryPath:c,skillsLogicalPath:l,source:a});if(d.push(...n.diagnostics),n.skill===null||n.skillId===null||f.has(n.skillId))continue;let r=p.get(n.skillId);if(r!==void 0){d.push(createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_COLLISION,message:`Found conflicting authored skill sources for "${n.skillId}": "${r.logicalPath}" and "${n.logicalPath}".`,sourcePath:join(c,n.skillId)})),f.add(n.skillId),p.delete(n.skillId);continue}p.set(n.skillId,{logicalPath:n.logicalPath,skill:n.skill})}return{diagnostics:d,skills:[...p.values()].map(e=>e.skill)}}async function discoverOneSkill(t){let n=join(t.skillsDirectoryPath,t.entryName);switch(classifySkillsDirectoryEntry(t.entryName,t.entryType)){case`skill-package-directory`:return discoverPackagedSkill({logicalSkillsPath:t.skillsLogicalPath,skillId:t.entryName,skillRootPath:n,source:t.source});case`flat-skill-markdown`:return discoverFlatMarkdownSkill({logicalSkillsPath:t.skillsLogicalPath,skillFileName:t.entryName,skillFilePath:n,source:t.source});case`flat-skill-module`:return discoverFlatModuleSkill({logicalSkillsPath:t.skillsLogicalPath,skillFileName:t.entryName});case`ignored-declaration`:return{diagnostics:[],logicalPath:normalizeLogicalPath(join(t.skillsLogicalPath,t.entryName)),skill:null,skillId:null};default:return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_ENTRY_NOT_DIRECTORY,message:`Expected "${n}" to be a skill directory containing SKILL.md or a flat ".md", ".ts", ".cts", ".mts", ".js", ".cjs", or ".mjs" skill file.`,sourcePath:n})],logicalPath:normalizeLogicalPath(join(t.skillsLogicalPath,t.entryName)),skill:null,skillId:null}}}async function discoverPackagedSkill(t){let n=(await readSortedDirectoryEntries(t.source,t.skillRootPath)).find(e=>e.isFile()&&e.name.toLowerCase()===`skill.md`)?.name,r=join(t.skillRootPath,n??`SKILL.md`),a=normalizeLogicalPath(join(t.logicalSkillsPath,t.skillId,n??`SKILL.md`));if(n===void 0)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_MARKDOWN_MISSING,message:`Expected "${r}" to exist for the "${t.skillId}" skill.`,sourcePath:t.skillRootPath})],logicalPath:a,skill:null,skillId:null};let o;try{o=lowerSkillMarkdown(await t.source.readTextFile(r))}catch(e){return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_FRONTMATTER_INVALID,message:formatSkillDiscoveryError(r,e),sourcePath:r})],logicalPath:a,skill:null,skillId:null}}let s=await discoverSkillPackagePaths(t.source,t.skillRootPath),c={description:o.description,logicalPath:a,markdown:o.markdown,name:t.skillId,rootPath:t.skillRootPath,skillFilePath:r,skillId:t.skillId,sourceId:createPathDerivedSourceId(a)};return s.assetsPath!==void 0&&(c.assetsPath=s.assetsPath),o.license!==void 0&&(c.license=o.license),o.metadata!==void 0&&(c.metadata=o.metadata),s.referencesPath!==void 0&&(c.referencesPath=s.referencesPath),s.scriptsPath!==void 0&&(c.scriptsPath=s.scriptsPath),{diagnostics:[],logicalPath:a,skill:createSkillPackageSourceRef(c),skillId:t.skillId}}async function discoverFlatMarkdownSkill(t){let n=stripMarkdownExtension(t.skillFileName),r=normalizeLogicalPath(join(t.logicalSkillsPath,t.skillFileName)),a;try{a=lowerSkillMarkdown(await t.source.readTextFile(t.skillFilePath),{slug:n})}catch(e){return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_FRONTMATTER_INVALID,message:formatSkillDiscoveryError(t.skillFilePath,e),sourcePath:t.skillFilePath})],logicalPath:r,skill:null,skillId:null}}return{diagnostics:[],logicalPath:r,skill:{definition:a,sourceKind:`markdown`,logicalPath:r,sourceId:createPathDerivedSourceId(r)},skillId:n}}async function discoverFlatModuleSkill(t){let n=getSupportedModuleBaseName(t.skillFileName),r=normalizeLogicalPath(join(t.logicalSkillsPath,t.skillFileName));return n===null?{diagnostics:[],logicalPath:r,skill:null,skillId:null}:{diagnostics:[],logicalPath:r,skill:createModuleSourceRef({logicalPath:r}),skillId:n}}async function discoverSkillPackagePaths(t,n){let r=await t.readDirectory(n),i={};for(let t of r)if(t.isDirectory())switch(classifySkillPackageEntry(t.name,getDirectoryEntryType(t))){case`skill-assets-directory`:i.assetsPath=join(n,t.name);break;case`skill-references-directory`:i.referencesPath=join(n,t.name);break;case`skill-scripts-directory`:i.scriptsPath=join(n,t.name);break;default:break}return i}function formatSkillDiscoveryError(e,t){return`Invalid authored skill frontmatter in "${e}": ${toErrorMessage(t)}`}function stripMarkdownExtension(e){return e.toLowerCase().endsWith(`.md`)?e.slice(0,-3):e}export{DISCOVER_SKILLS_DIRECTORY_INVALID,DISCOVER_SKILL_COLLISION,DISCOVER_SKILL_ENTRY_NOT_DIRECTORY,DISCOVER_SKILL_FRONTMATTER_INVALID,DISCOVER_SKILL_MARKDOWN_MISSING,discoverSkills};
@@ -1,2 +1,2 @@
1
- import"../node_modules/.pnpm/autoevals@0.0.132_ws@8.21.0/node_modules/autoevals/jsdist/index.js";import{generateText,jsonSchema}from"ai";function createAutoevalsClient(e){return{chat:{completions:{create:t=>createChatCompletion(t,e)}}}}async function createChatCompletion(t,n){let r=convertTools(t.tools),i=await generateText({model:n.languageModel,messages:convertMessages(t.messages??[]),tools:Object.keys(r).length>0?r:void 0,toolChoice:convertToolChoice(t.tool_choice),providerOptions:n.providerOptions}),a=i.toolCalls.map(e=>({id:e.toolCallId,type:`function`,function:{name:e.toolName,arguments:JSON.stringify(e.input??{})}}));return{choices:[{index:0,finish_reason:a.length>0?`tool_calls`:`stop`,message:{role:`assistant`,content:i.text||null,tool_calls:a.length>0?a:void 0}}]}}function convertMessages(e){return e.map(e=>{let t=contentToText(e.content);switch(e.role){case`assistant`:return{role:`assistant`,content:t};case`developer`:case`system`:return{role:`system`,content:t};default:return{role:`user`,content:t}}})}function contentToText(e){return e==null?``:typeof e==`string`?e:e.map(e=>e.text??``).filter(Boolean).join(`
2
- `)}function convertTools(e){let n={};for(let r of e??[])r.type!==`function`||r.function?.name===void 0||(n[r.function.name]={description:r.function.description,inputSchema:jsonSchema(r.function.parameters??{})});return n}function convertToolChoice(e){if(e!==void 0)return typeof e==`string`?e:{type:`tool`,toolName:e.function.name}}export{createAutoevalsClient};
1
+ import"../node_modules/.pnpm/autoevals@0.0.132_ws@8.21.0/node_modules/autoevals/jsdist/index.js";import{toInputSchema}from"#shared/tool-schema.js";import{generateText}from"ai";function createAutoevalsClient(e){return{chat:{completions:{create:t=>createChatCompletion(t,e)}}}}async function createChatCompletion(e,n){let r=convertTools(e.tools),i=await generateText({model:n.languageModel,messages:convertMessages(e.messages??[]),tools:Object.keys(r).length>0?r:void 0,toolChoice:convertToolChoice(e.tool_choice),providerOptions:n.providerOptions}),a=i.toolCalls.map(e=>({id:e.toolCallId,type:`function`,function:{name:e.toolName,arguments:JSON.stringify(e.input??{})}}));return{choices:[{index:0,finish_reason:a.length>0?`tool_calls`:`stop`,message:{role:`assistant`,content:i.text||null,tool_calls:a.length>0?a:void 0}}]}}function convertMessages(e){return e.map(e=>{let t=contentToText(e.content);switch(e.role){case`assistant`:return{role:`assistant`,content:t};case`developer`:case`system`:return{role:`system`,content:t};default:return{role:`user`,content:t}}})}function contentToText(e){return e==null?``:typeof e==`string`?e:e.map(e=>e.text??``).filter(Boolean).join(`
2
+ `)}function convertTools(t){let n={};for(let r of t??[])r.type!==`function`||r.function?.name===void 0||(n[r.function.name]={description:r.function.description,inputSchema:toInputSchema(r.function.parameters??{})});return n}function convertToolChoice(e){if(e!==void 0)return typeof e==`string`?e:{type:`tool`,toolName:e.function.name}}export{createAutoevalsClient};
@@ -1 +1 @@
1
- import{createLogger}from"#internal/logging.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{jsonSchema}from"ai";import{resolveRuntimeModelReference}from"#runtime/agent/resolve-model.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{createToolLoopHarness}from"#harness/tool-loop.js";import{AGENT_TOOL_DESCRIPTION,AGENT_TOOL_NAME}from"#runtime/framework-tools/agent.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{SUBAGENT_TOOL_INPUT_SCHEMA}from"#runtime/subagents/registry.js";import{findRegisteredRuntimeTool}from"#runtime/tools/registry.js";import{preserveFrameworkStateOnCompaction}from"#execution/compaction.js";import{createToolExecuteWithAuth}from"#execution/tool-auth.js";const log=createLogger(`execution.node-step`);function createExecutionNodeStep(e){let t=createRuntimeModelResolver(e.modelResolutionScope),n=e.node.turnAgent.dynamicModel===void 0?void 0:createRuntimeDynamicModelEventDispatcher(e.modelResolutionScope,e.node.turnAgent.dynamicModel),r=createNodeHarnessTools({node:e.node});return createToolLoopHarness({abortSignal:e.abortSignal,capabilities:e.capabilities,workflow:e.node.agent.workflowTool!==void 0,workflowMaxSubagents:e.workflowMaxSubagents,handleEvent:e.handleEvent,mode:e.mode,onCompaction:preserveFrameworkStateOnCompaction,dispatchDynamicModelEvent:n,resolveModel:t,runtimeIdentity:buildRuntimeIdentity(e.node),tools:r})}function buildRuntimeIdentity(e){let n=resolveInstalledPackageInfo(),r={agentId:e.turnAgent.id,agentName:e.agent.config?.name,eveVersion:n.version,modelId:e.turnAgent.dynamicModel===void 0?e.turnAgent.model.id:`dynamic:${e.turnAgent.model.id}`},i=process.env.VERCEL_GIT_COMMIT_SHA?.trim(),a=process.env.VERCEL_GIT_COMMIT_REF?.trim(),o=process.env.VERCEL_DEPLOYMENT_CREATED_AT?.trim();return i||a||o?{...r,build:{deployedAt:o||void 0,gitBranch:a||void 0,gitSha:i||void 0}}:r}function createRuntimeModelResolver(e){return t=>resolveRuntimeModelReference(t,e)}function createRuntimeDynamicModelEventDispatcher(e,t){return n=>dispatchDynamicModelEvent({ctx:n.ctx,dynamicModel:t,event:n.event,fallback:n.fallback,messages:n.messages,scope:e})}function createNodeHarnessTools(e){let t=new Map;for(let n of e.node.turnAgent.tools){let r=resolveHarnessToolDefinition({node:e.node,tool:n});r!==null&&t.set(n.name,r)}return e.node.nodeId===ROOT_RUNTIME_AGENT_NODE_ID&&!e.node.agent.disabledFrameworkTools.includes(AGENT_TOOL_NAME)&&!t.has(AGENT_TOOL_NAME)&&t.set(AGENT_TOOL_NAME,{description:AGENT_TOOL_DESCRIPTION,inputSchema:jsonSchema(SUBAGENT_TOOL_INPUT_SCHEMA),name:AGENT_TOOL_NAME,runtimeAction:{kind:`subagent-call`,nodeId:e.node.nodeId,subagentName:AGENT_TOOL_NAME}}),t}function resolveHarnessToolDefinition(e){if(e.tool.kind===`subagent`)return{description:e.tool.description??``,inputSchema:jsonSchema(e.tool.inputSchema??{}),name:e.tool.name,outputSchema:e.tool.outputSchema===void 0?void 0:jsonSchema(e.tool.outputSchema),runtimeAction:{kind:`subagent-call`,nodeId:e.tool.nodeId,subagentName:e.tool.name}};if(e.tool.kind===`remote`)return{description:e.tool.description??``,inputSchema:jsonSchema(e.tool.inputSchema??{}),name:e.tool.name,outputSchema:e.tool.outputSchema===void 0?void 0:jsonSchema(e.tool.outputSchema),runtimeAction:{kind:`remote-agent-call`,nodeId:e.tool.nodeId,remoteAgentName:e.tool.name,subagentName:e.tool.name}};let t=findRegisteredRuntimeTool(e.node.toolRegistry,e.tool.name);if(t===null)return log.warn(`declared tool is not registered — omitting from toolset`,{toolName:e.tool.name,nodeId:e.node.nodeId}),null;let r=t.definition,i=r.sourceId.startsWith(`eve:`),a=r.execute;return{approvalKey:r.approvalKey,description:r.description,execute:resolveAuthoredExecute({isFrameworkTool:i,rawExecute:a,scope:r.name}),inputSchema:r.inputStandardSchema??jsonSchema(r.inputSchema??{}),name:r.name,approval:r.approval,outputSchema:r.outputStandardSchema??maybeJsonSchema(r.outputSchema),toModelOutput:r.toModelOutput}}function resolveAuthoredExecute(e){let{isFrameworkTool:t,rawExecute:n,scope:r}=e;return n===void 0?void 0:t?n:createToolExecuteWithAuth({execute:n,scope:r})}function maybeJsonSchema(e){return e===void 0?void 0:jsonSchema(e)}export{createExecutionNodeStep,createNodeHarnessTools};
1
+ import{createLogger}from"#internal/logging.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{UNSPECIFIED_INPUT_SCHEMA,toInputSchema,toOutputSchema}from"#shared/tool-schema.js";import{resolveRuntimeModelReference}from"#runtime/agent/resolve-model.js";import{dispatchDynamicModelEvent}from"#context/dynamic-model-lifecycle.js";import{createToolLoopHarness}from"#harness/tool-loop.js";import{AGENT_TOOL_DESCRIPTION,AGENT_TOOL_NAME}from"#runtime/framework-tools/agent.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{SUBAGENT_TOOL_INPUT_SCHEMA}from"#runtime/subagents/registry.js";import{findRegisteredRuntimeTool}from"#runtime/tools/registry.js";import{preserveFrameworkStateOnCompaction}from"#execution/compaction.js";import{createToolExecuteWithAuth}from"#execution/tool-auth.js";const log=createLogger(`execution.node-step`);function createExecutionNodeStep(e){let t=createRuntimeModelResolver(e.modelResolutionScope),n=e.node.turnAgent.dynamicModel===void 0?void 0:createRuntimeDynamicModelEventDispatcher(e.modelResolutionScope,e.node.turnAgent.dynamicModel),r=createNodeHarnessTools({node:e.node});return createToolLoopHarness({abortSignal:e.abortSignal,capabilities:e.capabilities,workflow:e.node.agent.workflowTool!==void 0,workflowMaxSubagents:e.workflowMaxSubagents,handleEvent:e.handleEvent,mode:e.mode,onCompaction:preserveFrameworkStateOnCompaction,dispatchDynamicModelEvent:n,resolveModel:t,runtimeIdentity:buildRuntimeIdentity(e.node),tools:r})}function buildRuntimeIdentity(e){let n=resolveInstalledPackageInfo(),r={agentId:e.turnAgent.id,agentName:e.agent.config?.name,eveVersion:n.version,modelId:e.turnAgent.dynamicModel===void 0?e.turnAgent.model.id:`dynamic:${e.turnAgent.model.id}`},i=process.env.VERCEL_GIT_COMMIT_SHA?.trim(),a=process.env.VERCEL_GIT_COMMIT_REF?.trim(),o=process.env.VERCEL_DEPLOYMENT_CREATED_AT?.trim();return i||a||o?{...r,build:{deployedAt:o||void 0,gitBranch:a||void 0,gitSha:i||void 0}}:r}function createRuntimeModelResolver(e){return t=>resolveRuntimeModelReference(t,e)}function createRuntimeDynamicModelEventDispatcher(e,t){return n=>dispatchDynamicModelEvent({ctx:n.ctx,dynamicModel:t,event:n.event,fallback:n.fallback,messages:n.messages,scope:e})}function createNodeHarnessTools(e){let t=new Map;for(let n of e.node.turnAgent.tools){let r=resolveHarnessToolDefinition({node:e.node,tool:n});r!==null&&t.set(n.name,r)}return e.node.nodeId===ROOT_RUNTIME_AGENT_NODE_ID&&!e.node.agent.disabledFrameworkTools.includes(AGENT_TOOL_NAME)&&!t.has(AGENT_TOOL_NAME)&&t.set(AGENT_TOOL_NAME,{description:AGENT_TOOL_DESCRIPTION,inputSchema:SUBAGENT_TOOL_INPUT_SCHEMA,name:AGENT_TOOL_NAME,runtimeAction:{kind:`subagent-call`,nodeId:e.node.nodeId,subagentName:AGENT_TOOL_NAME}}),t}function resolveHarnessToolDefinition(e){if(e.tool.kind===`subagent`||e.tool.kind===`remote`){let t=e.tool.kind===`remote`?{kind:`remote-agent-call`,nodeId:e.tool.nodeId,remoteAgentName:e.tool.name,subagentName:e.tool.name}:{kind:`subagent-call`,nodeId:e.tool.nodeId,subagentName:e.tool.name};return{description:e.tool.description??``,inputSchema:toInputSchema(e.tool.inputSchema)??UNSPECIFIED_INPUT_SCHEMA,name:e.tool.name,outputSchema:toOutputSchema(e.tool.outputSchema),runtimeAction:t}}let t=findRegisteredRuntimeTool(e.node.toolRegistry,e.tool.name);if(t===null)return log.warn(`declared tool is not registered — omitting from toolset`,{toolName:e.tool.name,nodeId:e.node.nodeId}),null;let a=t.definition,o=a.sourceId.startsWith(`eve:`),s=a.execute;return{approvalKey:a.approvalKey,description:a.description,execute:resolveAuthoredExecute({isFrameworkTool:o,rawExecute:s,scope:a.name}),inputSchema:a.inputSchema??UNSPECIFIED_INPUT_SCHEMA,name:a.name,approval:a.approval,outputSchema:a.outputSchema,toModelOutput:a.toModelOutput}}function resolveAuthoredExecute(e){let{isFrameworkTool:t,rawExecute:n,scope:r}=e;return n===void 0?void 0:t?n:createToolExecuteWithAuth({execute:n,scope:r})}export{createExecutionNodeStep,createNodeHarnessTools};
@@ -1 +1 @@
1
- import{randomUUID}from"node:crypto";import{expectDockerSuccess}from"#execution/sandbox/bindings/docker-utils.js";import{markDevelopmentSandboxBackendInitialized}from"#execution/sandbox/development-run.js";import{writeSandboxSeedFiles}from"#execution/sandbox/bindings/local-backend-utils.js";import{assertDockerDaemonAvailable,createDockerCli}from"#execution/sandbox/bindings/docker-cli.js";import{DOCKER_SANDBOX_LABEL,runDockerBaseSetup,startDockerContainer,stopDockerContainerIfRunning}from"#execution/sandbox/bindings/docker-container.js";import{setDockerNetworkPolicy}from"#execution/sandbox/bindings/docker-network.js";import{createDockerSandboxOptionsHash,resolveDockerSandboxOptions}from"#execution/sandbox/bindings/docker-options.js";import{createDockerInternalSession}from"#execution/sandbox/bindings/docker-session.js";import{DOCKER_TEMPLATE_IMAGE_REPOSITORY,dockerImageExists,dockerTemplateImageReference,ensureDockerBaseImage,pruneDockerSandboxTemplates,resolveDockerTemplateMarkerPath,touchDockerTemplateMarker}from"#execution/sandbox/bindings/docker-templates.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";const DOCKER_BACKEND_NAME=`docker`;function createDockerSandboxBackend(c={}){let l=c.dockerCli??createDockerCli(),u=resolveDockerSandboxOptions(c.createOptions),d=createDockerSandboxOptionsHash(u),f;function ensureDaemon(){return f??=assertDockerDaemonAvailable(l).catch(e=>{throw f=void 0,e}),f}return{name:DOCKER_BACKEND_NAME,async prewarm(n){n.log?.(`checking Docker daemon`),await ensureDaemon();let i={optionsHash:d,templateKey:n.templateKey},a=dockerTemplateImageReference(i),o=resolveDockerTemplateMarkerPath(n.runtimeContext.appRoot,i);if(n.log?.(`checking cached template image "${a}"`),await dockerImageExists(l,a))return n.log?.(`reusing cached template image`),await touchDockerTemplateMarker(o,a),{reused:!0};n.log?.(`checking base image "${u.image}"`),await ensureDockerBaseImage(l,u);let s=`${n.templateKey}-build-${randomUUID().slice(0,8)}`;n.log?.(`starting template build container`),await startDockerContainer({cli:l,containerName:s,image:u.image,initialNetworkPolicy:`allow-all`,options:u,role:`template-build`});try{n.log?.(`preparing base runtime inside container`),await runDockerBaseSetup(l,s),u.networkPolicy!==`allow-all`&&(n.log?.(`applying network policy`),await setDockerNetworkPolicy(l,s,u.networkPolicy));let e=buildSandboxSession(createDockerInternalSession({cli:l,containerName:s,id:n.templateKey}),e=>setDockerNetworkPolicy(l,s,e));n.bootstrap!==void 0&&(n.log?.(`running sandbox bootstrap`),await n.bootstrap({use:async()=>createLoggingSandboxSession({log:n.log,session:e})})),n.seedFiles.length>0&&n.log?.(`writing ${n.seedFiles.length} seed file(s)`),await writeSandboxSeedFiles(e,n.seedFiles),n.log?.(`stopping template build container`),expectDockerSuccess(await l.run([`stop`,`-t`,`0`,s]),`stop template build container "${s}"`),n.log?.(`committing template image "${a}"`),expectDockerSuccess(await l.run([`commit`,`--change`,`LABEL ${DOCKER_SANDBOX_LABEL}=1`,`--change`,`LABEL ${DOCKER_SANDBOX_LABEL}.role=template`,`--change`,`LABEL ${DOCKER_SANDBOX_LABEL}.template-key=${n.templateKey}`,s,a]),`commit sandbox template image "${a}"`),await touchDockerTemplateMarker(o,a)}finally{await l.run([`rm`,`-f`,s]).catch(()=>{})}return{reused:!1}},async create(e){await ensureDaemon(),markDevelopmentSandboxBackendInitialized(DOCKER_BACKEND_NAME);let r=getDockerContainerName(e.existingMetadata)??e.sessionKey,i=await l.run([`container`,`inspect`,`--format`,`{{.State.Running}}`,r]);if(i.exitCode===0)i.stdout.trim()!==`true`&&expectDockerSuccess(await l.run([`start`,r]),`restart sandbox session container "${r}"`);else{let t;if(e.templateKey===null)await ensureDockerBaseImage(l,u),t=u.image;else{let n={optionsHash:d,templateKey:e.templateKey};if(t=dockerTemplateImageReference(n),!await dockerImageExists(l,t))throw new SandboxTemplateNotProvisionedError({backendName:DOCKER_BACKEND_NAME,templateKey:e.templateKey});await touchDockerTemplateMarker(resolveDockerTemplateMarkerPath(e.runtimeContext.appRoot,n),t)}try{await startDockerContainer({cli:l,containerName:r,image:t,initialNetworkPolicy:e.templateKey===null?`allow-all`:u.networkPolicy,options:u,role:`session`,tags:e.tags})}catch(t){throw e.templateKey===null?t:new SandboxTemplateNotProvisionedError({backendName:DOCKER_BACKEND_NAME,templateKey:e.templateKey})}e.templateKey===null&&(await runDockerBaseSetup(l,r),u.networkPolicy!==`allow-all`&&await setDockerNetworkPolicy(l,r,u.networkPolicy))}let a=buildSandboxSession(createDockerInternalSession({cli:l,containerName:r,id:e.sessionKey}),e=>setDockerNetworkPolicy(l,r,e));return{session:a,useSessionFn:async()=>a,async captureState(){return{backendName:DOCKER_BACKEND_NAME,metadata:{containerName:r},sessionKey:e.sessionKey}},async shutdown(){await stopDockerContainerIfRunning(l,r)}}}}}function getDockerContainerName(e){let t=e?.containerName;return typeof t==`string`?t:void 0}export{DOCKER_BACKEND_NAME,DOCKER_TEMPLATE_IMAGE_REPOSITORY,createDockerSandboxBackend,pruneDockerSandboxTemplates};
1
+ import{randomUUID}from"node:crypto";import{expectDockerSuccess}from"#execution/sandbox/bindings/docker-utils.js";import{writeSandboxSeedFiles}from"#execution/sandbox/bindings/local-backend-utils.js";import{assertDockerDaemonAvailable,createDockerCli}from"#execution/sandbox/bindings/docker-cli.js";import{DOCKER_SANDBOX_LABEL,runDockerBaseSetup,startDockerContainer,stopDockerContainerIfRunning}from"#execution/sandbox/bindings/docker-container.js";import{setDockerNetworkPolicy}from"#execution/sandbox/bindings/docker-network.js";import{createDockerSandboxOptionsHash,resolveDockerSandboxOptions}from"#execution/sandbox/bindings/docker-options.js";import{createDockerInternalSession}from"#execution/sandbox/bindings/docker-session.js";import{DOCKER_TEMPLATE_IMAGE_REPOSITORY,dockerImageExists,dockerTemplateImageReference,ensureDockerBaseImage,pruneDockerSandboxTemplates,resolveDockerTemplateMarkerPath,touchDockerTemplateMarker}from"#execution/sandbox/bindings/docker-templates.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";const DOCKER_BACKEND_NAME=`docker`;function createDockerSandboxBackend(c={}){let l=c.dockerCli??createDockerCli(),u=resolveDockerSandboxOptions(c.createOptions),d=createDockerSandboxOptionsHash(u),f;function ensureDaemon(){return f??=assertDockerDaemonAvailable(l).catch(e=>{throw f=void 0,e}),f}return{name:DOCKER_BACKEND_NAME,async prewarm(r){r.log?.(`checking Docker daemon`),await ensureDaemon();let i={optionsHash:d,templateKey:r.templateKey},a=dockerTemplateImageReference(i),o=resolveDockerTemplateMarkerPath(r.runtimeContext.appRoot,i);if(r.log?.(`checking cached template image "${a}"`),await dockerImageExists(l,a))return r.log?.(`reusing cached template image`),await touchDockerTemplateMarker(o,a),{reused:!0};r.log?.(`checking base image "${u.image}"`),await ensureDockerBaseImage(l,u);let s=`${r.templateKey}-build-${randomUUID().slice(0,8)}`;r.log?.(`starting template build container`),await startDockerContainer({cli:l,containerName:s,image:u.image,initialNetworkPolicy:`allow-all`,options:u,role:`template-build`});try{r.log?.(`preparing base runtime inside container`),await runDockerBaseSetup(l,s),u.networkPolicy!==`allow-all`&&(r.log?.(`applying network policy`),await setDockerNetworkPolicy(l,s,u.networkPolicy));let e=buildSandboxSession(createDockerInternalSession({cli:l,containerName:s,id:r.templateKey}),e=>setDockerNetworkPolicy(l,s,e));r.bootstrap!==void 0&&(r.log?.(`running sandbox bootstrap`),await r.bootstrap({use:async()=>createLoggingSandboxSession({log:r.log,session:e})})),r.seedFiles.length>0&&r.log?.(`writing ${r.seedFiles.length} seed file(s)`),await writeSandboxSeedFiles(e,r.seedFiles),r.log?.(`stopping template build container`),expectDockerSuccess(await l.run([`stop`,`-t`,`0`,s]),`stop template build container "${s}"`),r.log?.(`committing template image "${a}"`),expectDockerSuccess(await l.run([`commit`,`--change`,`LABEL ${DOCKER_SANDBOX_LABEL}=1`,`--change`,`LABEL ${DOCKER_SANDBOX_LABEL}.role=template`,`--change`,`LABEL ${DOCKER_SANDBOX_LABEL}.template-key=${r.templateKey}`,s,a]),`commit sandbox template image "${a}"`),await touchDockerTemplateMarker(o,a)}finally{await l.run([`rm`,`-f`,s]).catch(()=>{})}return{reused:!1}},async create(e){await ensureDaemon();let n=getDockerContainerName(e.existingMetadata)??e.sessionKey,r=await l.run([`container`,`inspect`,`--format`,`{{.State.Running}}`,n]);if(r.exitCode===0)r.stdout.trim()!==`true`&&expectDockerSuccess(await l.run([`start`,n]),`restart sandbox session container "${n}"`);else{let t;if(e.templateKey===null)await ensureDockerBaseImage(l,u),t=u.image;else{let n={optionsHash:d,templateKey:e.templateKey};if(t=dockerTemplateImageReference(n),!await dockerImageExists(l,t))throw new SandboxTemplateNotProvisionedError({backendName:DOCKER_BACKEND_NAME,templateKey:e.templateKey});await touchDockerTemplateMarker(resolveDockerTemplateMarkerPath(e.runtimeContext.appRoot,n),t)}try{await startDockerContainer({cli:l,containerName:n,image:t,initialNetworkPolicy:e.templateKey===null?`allow-all`:u.networkPolicy,options:u,role:`session`,tags:e.tags})}catch(t){throw e.templateKey===null?t:new SandboxTemplateNotProvisionedError({backendName:DOCKER_BACKEND_NAME,templateKey:e.templateKey})}e.templateKey===null&&(await runDockerBaseSetup(l,n),u.networkPolicy!==`allow-all`&&await setDockerNetworkPolicy(l,n,u.networkPolicy))}let i=buildSandboxSession(createDockerInternalSession({cli:l,containerName:n,id:e.sessionKey}),e=>setDockerNetworkPolicy(l,n,e));return{session:i,useSessionFn:async()=>i,async captureState(){return{backendName:DOCKER_BACKEND_NAME,metadata:{containerName:n},sessionKey:e.sessionKey}},async shutdown(){await stopDockerContainerIfRunning(l,n)}}}}}function getDockerContainerName(e){let t=e?.containerName;return typeof t==`string`?t:void 0}export{DOCKER_BACKEND_NAME,DOCKER_TEMPLATE_IMAGE_REPOSITORY,createDockerSandboxBackend,pruneDockerSandboxTemplates};
@@ -72,7 +72,7 @@ export declare function loadMicrosandboxModule(input: {
72
72
  * Loads microsandbox only when its package and runtime are already
73
73
  * present — used by cleanup paths that must never trigger installs.
74
74
  */
75
- export declare function loadMicrosandboxWithoutInstall(): Promise<MicrosandboxModule | null>;
75
+ export declare function loadMicrosandboxWithoutInstall(appRoot: string): Promise<MicrosandboxModule | null>;
76
76
  export declare function stopAndSnapshotMicrosandboxSandbox(module: MicrosandboxModule, sandboxName: string, snapshotName: string): Promise<void>;
77
77
  export declare function createProviderName(prefix: string, key: string, extra?: string): string;
78
78
  export declare function createStableHash(value: string): string;