eve 0.47.6 → 0.47.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/src/channel/adapter.js +1 -1
- package/dist/src/channel/session.js +1 -1
- package/dist/src/chunks/{use-eve-agent-DjYwFJF7.js → use-eve-agent-B5zw1dwj.js} +0 -1
- package/dist/src/chunks/{use-eve-agent-DkUB0Ok4.js → use-eve-agent-Dg5S44kG.js} +0 -1
- package/dist/src/cli/commands/registry-declared-setups.js +1 -1
- package/dist/src/cli/commands/registry-install-transaction.d.ts +23 -0
- package/dist/src/cli/commands/registry-install-transaction.js +1 -0
- package/dist/src/cli/commands/registry-package.js +1 -1
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/commands/setup-headless.d.ts +6 -0
- package/dist/src/cli/commands/setup-headless.js +1 -1
- package/dist/src/cli/dev/run-interactive-ui.js +1 -1
- package/dist/src/cli/dev/tui/line-editor.d.ts +4 -0
- package/dist/src/cli/dev/tui/line-editor.js +3 -3
- package/dist/src/cli/dev/tui/runner.d.ts +2 -0
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/stream-format.d.ts +8 -0
- package/dist/src/cli/dev/tui/stream-format.js +2 -2
- package/dist/src/cli/dev/tui/subagent-pump.d.ts +3 -0
- package/dist/src/cli/dev/tui/subagent-pump.js +1 -1
- package/dist/src/cli/dev/tui/tui.js +1 -1
- package/dist/src/client/agent-info-schema.d.ts +0 -1
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +2 -2
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.d.ts +7 -17
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/normalize-tool.d.ts +0 -1
- package/dist/src/compiler/normalize-tool.js +1 -1
- package/dist/src/context/build-dynamic-tools.d.ts +2 -2
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/container.d.ts +7 -0
- package/dist/src/context/container.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.d.ts +16 -9
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/context/dynamic-tool-metadata.d.ts +44 -0
- package/dist/src/context/dynamic-tool-metadata.js +1 -0
- package/dist/src/context/keys.d.ts +11 -14
- package/dist/src/context/keys.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.d.ts +0 -1
- package/dist/src/eve-channel/request.js +2 -2
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/delegation-tool.d.ts +1 -2
- package/dist/src/execution/delegation-tool.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +8 -3
- package/dist/src/execution/dispatch-runtime-actions-shared.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +1 -1
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/pending-turn-state.js +1 -1
- package/dist/src/execution/prepared-agent-action.d.ts +7 -0
- package/dist/src/execution/prepared-agent-action.js +1 -0
- package/dist/src/execution/subagent-start-local.d.ts +3 -0
- package/dist/src/execution/subagent-start-local.js +1 -1
- package/dist/src/execution/subagent-tool.d.ts +1 -0
- package/dist/src/execution/subagent-tool.js +1 -1
- package/dist/src/execution/tasks/child/update.d.ts +3 -2
- package/dist/src/execution/tasks/parent/control-shared.d.ts +5 -4
- package/dist/src/execution/tasks/parent/dispatch-task-step.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch.d.ts +4 -3
- package/dist/src/execution/tasks/parent/dispatch.js +1 -1
- package/dist/src/execution/tools/subagent/local.d.ts +3 -4
- package/dist/src/execution/tools/subagent/local.js +1 -1
- package/dist/src/execution/tools/subagent/remote.d.ts +4 -1
- package/dist/src/execution/tools/subagent/remote.js +1 -1
- package/dist/src/execution/workflow-entry-finalization.d.ts +22 -0
- package/dist/src/execution/workflow-entry-finalization.js +1 -0
- package/dist/src/execution/workflow-entry.d.ts +1 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/framework/sources/registry.js +1 -1
- package/dist/src/harness/advertised-tools.d.ts +3 -0
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/approval-delivery-coordinator.d.ts +6 -0
- package/dist/src/harness/approval-delivery-coordinator.js +1 -1
- package/dist/src/harness/background-tools.d.ts +2 -0
- package/dist/src/harness/execute-tool.d.ts +2 -28
- package/dist/src/harness/hitl/pending-input-resolution.js +1 -1
- package/dist/src/harness/input-extraction.d.ts +3 -0
- package/dist/src/harness/input-extraction.js +1 -1
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/runtime-actions.d.ts +9 -3
- package/dist/src/harness/runtime-actions.js +1 -1
- package/dist/src/harness/stale-input-responses.d.ts +2 -1
- package/dist/src/harness/stale-input-responses.js +1 -1
- package/dist/src/harness/subagent-depth.d.ts +3 -4
- package/dist/src/harness/subagent-depth.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/tools.d.ts +0 -2
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/harness/types.d.ts +6 -7
- package/dist/src/harness/workflow-runtime-action-state.d.ts +3 -3
- package/dist/src/harness/workflow-runtime-action-state.js +1 -1
- package/dist/src/harness/workflow-sandbox.js +1 -1
- package/dist/src/harness/workflow-subagent-limit.d.ts +4 -4
- package/dist/src/instrumentation/ai-sdk-telemetry.d.ts +1 -0
- package/dist/src/instrumentation/ai-sdk-telemetry.js +1 -1
- package/dist/src/instrumentation/runtime.d.ts +3 -0
- package/dist/src/instrumentation/runtime.js +1 -1
- package/dist/src/internal/application/build-output-environment.d.ts +2 -0
- package/dist/src/internal/application/build-output-environment.js +1 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/paths.d.ts +1 -2
- package/dist/src/internal/application/paths.js +1 -1
- package/dist/src/internal/authored-definition/schema-backed.d.ts +6 -2
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/internal/client-context.d.ts +2 -0
- package/dist/src/internal/client-context.js +1 -0
- package/dist/src/internal/nitro/dev-client-address.d.ts +2 -0
- package/dist/src/internal/nitro/dev-client-address.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.d.ts +2 -2
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/packages/eve-catalog/src/index.js +1 -1
- package/dist/src/protocol/routes.d.ts +2 -2
- package/dist/src/public/local-dev.d.ts +9 -0
- package/dist/src/public/local-dev.js +1 -0
- package/dist/src/public/next/vercel-output-config.js +1 -1
- package/dist/src/runtime/actions/keys.d.ts +3 -0
- package/dist/src/runtime/actions/keys.js +1 -1
- package/dist/src/runtime/agent/bootstrap.js +1 -1
- package/dist/src/runtime/loaders/bundled-artifacts.js +1 -1
- package/dist/src/runtime/local-dev-capability.d.ts +55 -0
- package/dist/src/runtime/local-dev-capability.js +1 -0
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/resolve-tool.js +1 -1
- package/dist/src/runtime/sessions/runtime-session.d.ts +1 -0
- package/dist/src/runtime/sessions/runtime-session.js +1 -1
- package/dist/src/runtime/sessions/turn.d.ts +3 -0
- package/dist/src/runtime/subagents/registry.js +1 -1
- package/dist/src/runtime/tools/registry.d.ts +1 -0
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/runtime/types.d.ts +2 -2
- package/dist/src/services/dev-client/client-options.d.ts +1 -0
- package/dist/src/services/dev-client/client-options.js +1 -1
- package/dist/src/services/dev-client/runtime-artifacts.d.ts +2 -0
- package/dist/src/services/dev-client/runtime-artifacts.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/dispatch-action.d.ts +24 -0
- package/dist/src/shared/dispatch-action.js +1 -0
- package/dist/src/shared/workflow-sandbox.d.ts +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tasks/json.js +1 -1
- package/dist/src/tools/behavior.d.ts +55 -0
- package/dist/src/tools/behavior.js +1 -0
- package/dist/src/tools/durable-callbacks.d.ts +1 -0
- package/dist/src/tools/framework/agent.d.ts +2 -11
- package/dist/src/tools/framework/agent.js +1 -1
- package/dist/src/tools/framework/ask-question.d.ts +2 -14
- package/dist/src/tools/framework/ask-question.js +1 -1
- package/dist/src/tools/framework/task-cancel.d.ts +2 -7
- package/dist/src/tools/framework/task-cancel.js +1 -1
- package/dist/src/tools/framework/task-contract.d.ts +0 -2
- package/dist/src/tools/framework/task-contract.js +1 -1
- package/dist/src/tools/framework/task-update.d.ts +2 -7
- package/dist/src/tools/framework/task-update.js +1 -1
- package/dist/src/tools/native-definition.d.ts +6 -0
- package/dist/src/tools/native-definition.js +1 -0
- package/dist/src/tools/provided/load-skill.js +1 -1
- package/dist/src/tracing/agent-approval-instrumentation.js +1 -1
- package/dist/src/tracing/agent-channel-delivery-instrumentation.js +1 -1
- package/dist/src/tracing/agent-otel-provider.js +1 -1
- package/dist/src/tracing/agent-tool-instrumentation.js +1 -1
- package/dist/src/tracing/install-instrumentation-runtime.js +1 -1
- package/dist/src/tracing/otel-registration.d.ts +2 -0
- package/dist/src/tracing/otel-registration.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/reference/typescript-api.md +24 -0
- package/package.json +6 -1
- package/dist/src/execution/tools/tasks.d.ts +0 -18
- package/dist/src/execution/tools/tasks.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{expectObjectRecord}from"#internal/authored-module.js";import{ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{validateCompiledModuleMap}from"#compiler/validate-artifact.js";import{createRuntimeSubagentRegistry}from"#runtime/subagents/registry.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{createRuntimeToolRegistry}from"#runtime/tools/registry.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{WORKFLOW_TOOL_NAME}from"#shared/workflow-sandbox.js";import{loadResolvedModuleExport}from"#runtime/resolve-helpers.js";import{createResolvedRuntimeTurnAgent}from"#runtime/agent/bootstrap.js";import{createWorkspacePromptSection}from"#runtime/workspace/spec.js";import{createRuntimeHookRegistry}from"#runtime/hooks/registry.js";import{resolveAgent}from"#runtime/resolve-agent.js";import{resolveDynamicSubagentDefinition}from"#runtime/resolve-dynamic-subagent.js";import{createRuntimeSandboxRegistry}from"#runtime/sandbox/registry.js";var ResolveRuntimeAgentGraphError=class extends Error{logicalPath;nodeId;sourceId;constructor(e,t={}){super(e),this.name=`ResolveRuntimeAgentGraphError`,t.logicalPath!==void 0&&(this.logicalPath=t.logicalPath),t.nodeId!==void 0&&(this.nodeId=t.nodeId),t.sourceId!==void 0&&(this.sourceId=t.sourceId)}};async function resolveRuntimeAgentGraph(e){validateCompiledModuleMap(e.manifest,e.moduleMap);let r=new Map,i=createChildNodeIdsByParentNodeId(e.manifest),a=new Map(e.manifest.subagents.map(e=>[e.nodeId,e])),o=await resolveRuntimeAgentNode({childNodeIdsByParentNodeId:i,manifest:e.manifest,moduleMap:e.moduleMap,nodeId:ROOT_COMPILED_AGENT_NODE_ID,nodesByNodeId:r,subagentNodesById:a});return attachInheritedSandboxWorkspaceResources({manifest:e.manifest,nodesByNodeId:r}),{nodesByNodeId:r,root:o}}async function resolveRuntimeAgentNode(e){let t=toRuntimeNodeId(e.nodeId);if(e.nodesByNodeId.has(t))throw new ResolveRuntimeAgentGraphError(`Found multiple runtime agent nodes for node id "${t}".`,{nodeId:t,sourceId:e.sourceId});let n=await resolveAgent({manifest:e.manifest,moduleMap:e.moduleMap,nodeId:e.nodeId}),o=await createRuntimeToolRegistry({tools:n.tools},{reservedToolNames:[WORKFLOW_TOOL_NAME]}),s=createRuntimeSandboxRegistry({sandbox:n.sandbox,workspaceResourceRoot:n.workspaceResourceRoot}),c=createRuntimeSubagentRegistry({reservedToolNames:[LOAD_SKILL_TOOL_NAME,...o.preparedTools.map(e=>e.name)],subagents:await resolveRuntimeSubagents({childNodeIdsByParentNodeId:e.childNodeIdsByParentNodeId,manifest:e.manifest,moduleMap:e.moduleMap,nodesByNodeId:e.nodesByNodeId,parentNodeId:e.nodeId,subagentNodesById:e.subagentNodesById})}),l={agent:n,channels:n.channels,hookRegistry:createRuntimeHookRegistry(n.hooks),nodeId:t,sandboxRegistry:s,sourceId:e.sourceId,subagentRegistry:c,toolRegistry:o,turnAgent:createResolvedRuntimeTurnAgent({agent:n,id:e.agentId,nodeId:t,tools:[...o.preparedTools,...c.preparedTools]})};return e.nodesByNodeId.set(t,l),l}async function resolveRuntimeSubagents(e){let t=[],n=e.childNodeIdsByParentNodeId.get(e.parentNodeId)??[];for(let r of n){let n=e.subagentNodesById.get(r);if(n===void 0)throw new ResolveRuntimeAgentGraphError(`Missing compiled subagent node "${r}" while resolving runtime subagents.`,{nodeId:toRuntimeNodeId(e.parentNodeId),sourceId:r});t.push(await resolveRuntimeSubagent({childNodeIdsByParentNodeId:e.childNodeIdsByParentNodeId,moduleMap:e.moduleMap,nodesByNodeId:e.nodesByNodeId,sourceRef:n,subagentNodesById:e.subagentNodesById}))}for(let n of e.manifest.remoteAgents)t.push(await resolveRuntimeRemoteAgent({moduleMap:e.moduleMap,nodeScopeId:e.parentNodeId,sourceRef:n}));return t}async function resolveRuntimeSubagent(e){let t={...e.sourceRef.configResolver===void 0?{description:e.sourceRef.description}:{dynamic:await resolveDynamicSubagentDefinition({definition:e.sourceRef.configResolver,moduleMap:e.moduleMap,nodeId:e.sourceRef.nodeId})},kind:`subagent`,logicalPath:e.sourceRef.logicalPath,name:e.sourceRef.name,nodeId:toRuntimeNodeId(e.sourceRef.nodeId),sourceId:e.sourceRef.sourceId,sourceKind:`module`};return await resolveRuntimeAgentNode({agentId:e.sourceRef.name,childNodeIdsByParentNodeId:e.childNodeIdsByParentNodeId,manifest:e.sourceRef.agent,moduleMap:e.moduleMap,nodeId:e.sourceRef.nodeId,nodesByNodeId:e.nodesByNodeId,sourceId:e.sourceRef.sourceId,subagentNodesById:e.subagentNodesById}),t}async function resolveRuntimeRemoteAgent(t){let n=expectObjectRecord(await loadResolvedModuleExport({definition:t.sourceRef,kindLabel:`remote agent`,moduleMap:t.moduleMap,nodeId:t.nodeScopeId}),`Expected remote agent source "${t.sourceRef.logicalPath}" to export an object.`),r={description:t.sourceRef.description,kind:`remote`,logicalPath:t.sourceRef.logicalPath,name:t.sourceRef.name,nodeId:toRuntimeNodeId(t.sourceRef.nodeId),outputSchema:t.sourceRef.outputSchema,path:t.sourceRef.path,sourceId:t.sourceRef.sourceId,sourceKind:`module`,url:await resolveRemoteAgentUrl({bakedUrl:t.sourceRef.url,logicalPath:t.sourceRef.logicalPath,resolvedUrl:n.url})};typeof n.auth==`function`&&(r.auth=n.auth),n.forwardPrincipal===!0&&(r.forwardPrincipal=!0);let i=resolveRemoteAgentHeaders(n.headers);return i!==void 0&&(r.headers=i),r}async function resolveRemoteAgentUrl(e){if(typeof e.resolvedUrl==`function`){let t=await e.resolvedUrl();if(typeof t!=`string`||t.length===0)throw Error(`Remote agent "${e.logicalPath}" url function must return a non-empty string.`);return t}let t=e.bakedUrl??(typeof e.resolvedUrl==`string`?e.resolvedUrl:``);if(t.length===0)throw Error(`Remote agent "${e.logicalPath}" is missing a url.`);return t}function resolveRemoteAgentHeaders(e){if(e===void 0)return;if(typeof e==`function`)return e;if(typeof e!=`object`||!e||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}function attachInheritedSandboxWorkspaceResources(e){let t=new Map(e.manifest.subagents.map(e=>[e.nodeId,e.parentNodeId]));for(let[n,r]of e.nodesByNodeId){if(r.sandboxRegistry.sandbox.definition.inheritsParent!==!0)continue;if(r.agent.dynamicSkillResolvers.length>0)throw new ResolveRuntimeAgentGraphError(`Sandbox "${r.sandboxRegistry.sandbox.definition.logicalPath}" selects parent.sandbox but agent node "${n}" defines dynamic skills. Remove the child dynamic skills or give the child its own sandbox.`,{nodeId:n});let i=t.get(n);if(i===void 0)throw new ResolveRuntimeAgentGraphError(`Sandbox "${r.sandboxRegistry.sandbox.definition.logicalPath}" selects parent.sandbox but agent node "${n}" has no parent.`,{nodeId:n});let a=resolveSandboxOwnerNode({nodeId:i,nodesByNodeId:e.nodesByNodeId,parentNodeIdByChildNodeId:t});r.sandboxRegistry.sandbox.inheritance={definition:a.sandboxRegistry.sandbox.definition,nodeId:a.nodeId,workspaceResourceRoot:a.sandboxRegistry.sandbox.workspaceResourceRoot};let o=createWorkspacePromptSection(a.agent.workspaceSpec);o!==void 0&&(r.turnAgent.instructions=[...r.turnAgent.instructions,o])}}function resolveSandboxOwnerNode(e){let t=e.nodesByNodeId.get(toRuntimeNodeId(e.nodeId));if(t===void 0)throw new ResolveRuntimeAgentGraphError(`Missing parent runtime node "${e.nodeId}".`,{nodeId:e.nodeId});if(t.sandboxRegistry.sandbox.definition.inheritsParent!==!0)return t;let n=e.parentNodeIdByChildNodeId.get(e.nodeId);if(n===void 0)throw new ResolveRuntimeAgentGraphError(`Inherited sandbox node "${e.nodeId}" has no parent.`,{nodeId:e.nodeId});return resolveSandboxOwnerNode({...e,nodeId:n})}function createChildNodeIdsByParentNodeId(e){let t=new Map;for(let n of e.subagents){let e=t.get(n.parentNodeId);if(e===void 0){t.set(n.parentNodeId,[n.nodeId]);continue}e.push(n.nodeId)}return t}function toRuntimeNodeId(e){return e===ROOT_COMPILED_AGENT_NODE_ID?ROOT_RUNTIME_AGENT_NODE_ID:e}export{resolveRuntimeAgentGraph};
|
|
1
|
+
import{expectObjectRecord}from"#internal/authored-module.js";import{ROOT_COMPILED_AGENT_NODE_ID}from"#compiler/manifest.js";import{validateCompiledModuleMap}from"#compiler/validate-artifact.js";import{createRuntimeSubagentRegistry}from"#runtime/subagents/registry.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{createRuntimeToolRegistry}from"#runtime/tools/registry.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{WORKFLOW_TOOL_NAME}from"#shared/workflow-sandbox.js";import{loadResolvedModuleExport}from"#runtime/resolve-helpers.js";import{createResolvedRuntimeTurnAgent}from"#runtime/agent/bootstrap.js";import{createWorkspacePromptSection}from"#runtime/workspace/spec.js";import{createRuntimeHookRegistry}from"#runtime/hooks/registry.js";import{resolveAgent}from"#runtime/resolve-agent.js";import{resolveDynamicSubagentDefinition}from"#runtime/resolve-dynamic-subagent.js";import{createRuntimeSandboxRegistry}from"#runtime/sandbox/registry.js";var ResolveRuntimeAgentGraphError=class extends Error{logicalPath;nodeId;sourceId;constructor(e,t={}){super(e),this.name=`ResolveRuntimeAgentGraphError`,t.logicalPath!==void 0&&(this.logicalPath=t.logicalPath),t.nodeId!==void 0&&(this.nodeId=t.nodeId),t.sourceId!==void 0&&(this.sourceId=t.sourceId)}};async function resolveRuntimeAgentGraph(e){validateCompiledModuleMap(e.manifest,e.moduleMap);let r=new Map,i=createChildNodeIdsByParentNodeId(e.manifest),a=new Map(e.manifest.subagents.map(e=>[e.nodeId,e])),o=await resolveRuntimeAgentNode({childNodeIdsByParentNodeId:i,manifest:e.manifest,moduleMap:e.moduleMap,nodeId:ROOT_COMPILED_AGENT_NODE_ID,nodesByNodeId:r,subagentNodesById:a});return attachInheritedSandboxWorkspaceResources({manifest:e.manifest,nodesByNodeId:r}),{nodesByNodeId:r,root:o}}async function resolveRuntimeAgentNode(e){let t=toRuntimeNodeId(e.nodeId);if(e.nodesByNodeId.has(t))throw new ResolveRuntimeAgentGraphError(`Found multiple runtime agent nodes for node id "${t}".`,{nodeId:t,sourceId:e.sourceId});let n=await resolveAgent({manifest:e.manifest,moduleMap:e.moduleMap,nodeId:e.nodeId}),o=await createRuntimeToolRegistry({tools:n.tools},{nodeId:t,reservedToolNames:[WORKFLOW_TOOL_NAME]}),s=createRuntimeSandboxRegistry({sandbox:n.sandbox,workspaceResourceRoot:n.workspaceResourceRoot}),c=createRuntimeSubagentRegistry({reservedToolNames:[LOAD_SKILL_TOOL_NAME,...o.preparedTools.map(e=>e.name)],subagents:await resolveRuntimeSubagents({childNodeIdsByParentNodeId:e.childNodeIdsByParentNodeId,manifest:e.manifest,moduleMap:e.moduleMap,nodesByNodeId:e.nodesByNodeId,parentNodeId:e.nodeId,subagentNodesById:e.subagentNodesById})}),l={agent:n,channels:n.channels,hookRegistry:createRuntimeHookRegistry(n.hooks),nodeId:t,sandboxRegistry:s,sourceId:e.sourceId,subagentRegistry:c,toolRegistry:o,turnAgent:createResolvedRuntimeTurnAgent({agent:n,id:e.agentId,nodeId:t,tools:[...o.preparedTools,...c.preparedTools]})};return e.nodesByNodeId.set(t,l),l}async function resolveRuntimeSubagents(e){let t=[],n=e.childNodeIdsByParentNodeId.get(e.parentNodeId)??[];for(let r of n){let n=e.subagentNodesById.get(r);if(n===void 0)throw new ResolveRuntimeAgentGraphError(`Missing compiled subagent node "${r}" while resolving runtime subagents.`,{nodeId:toRuntimeNodeId(e.parentNodeId),sourceId:r});t.push(await resolveRuntimeSubagent({childNodeIdsByParentNodeId:e.childNodeIdsByParentNodeId,moduleMap:e.moduleMap,nodesByNodeId:e.nodesByNodeId,sourceRef:n,subagentNodesById:e.subagentNodesById}))}for(let n of e.manifest.remoteAgents)t.push(await resolveRuntimeRemoteAgent({moduleMap:e.moduleMap,nodeScopeId:e.parentNodeId,sourceRef:n}));return t}async function resolveRuntimeSubagent(e){let t={...e.sourceRef.configResolver===void 0?{description:e.sourceRef.description}:{dynamic:await resolveDynamicSubagentDefinition({definition:e.sourceRef.configResolver,moduleMap:e.moduleMap,nodeId:e.sourceRef.nodeId})},kind:`subagent`,logicalPath:e.sourceRef.logicalPath,name:e.sourceRef.name,nodeId:toRuntimeNodeId(e.sourceRef.nodeId),sourceId:e.sourceRef.sourceId,sourceKind:`module`};return await resolveRuntimeAgentNode({agentId:e.sourceRef.name,childNodeIdsByParentNodeId:e.childNodeIdsByParentNodeId,manifest:e.sourceRef.agent,moduleMap:e.moduleMap,nodeId:e.sourceRef.nodeId,nodesByNodeId:e.nodesByNodeId,sourceId:e.sourceRef.sourceId,subagentNodesById:e.subagentNodesById}),t}async function resolveRuntimeRemoteAgent(t){let n=expectObjectRecord(await loadResolvedModuleExport({definition:t.sourceRef,kindLabel:`remote agent`,moduleMap:t.moduleMap,nodeId:t.nodeScopeId}),`Expected remote agent source "${t.sourceRef.logicalPath}" to export an object.`),r={description:t.sourceRef.description,kind:`remote`,logicalPath:t.sourceRef.logicalPath,name:t.sourceRef.name,nodeId:toRuntimeNodeId(t.sourceRef.nodeId),outputSchema:t.sourceRef.outputSchema,path:t.sourceRef.path,sourceId:t.sourceRef.sourceId,sourceKind:`module`,url:await resolveRemoteAgentUrl({bakedUrl:t.sourceRef.url,logicalPath:t.sourceRef.logicalPath,resolvedUrl:n.url})};typeof n.auth==`function`&&(r.auth=n.auth),n.forwardPrincipal===!0&&(r.forwardPrincipal=!0);let i=resolveRemoteAgentHeaders(n.headers);return i!==void 0&&(r.headers=i),r}async function resolveRemoteAgentUrl(e){if(typeof e.resolvedUrl==`function`){let t=await e.resolvedUrl();if(typeof t!=`string`||t.length===0)throw Error(`Remote agent "${e.logicalPath}" url function must return a non-empty string.`);return t}let t=e.bakedUrl??(typeof e.resolvedUrl==`string`?e.resolvedUrl:``);if(t.length===0)throw Error(`Remote agent "${e.logicalPath}" is missing a url.`);return t}function resolveRemoteAgentHeaders(e){if(e===void 0)return;if(typeof e==`function`)return e;if(typeof e!=`object`||!e||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}function attachInheritedSandboxWorkspaceResources(e){let t=new Map(e.manifest.subagents.map(e=>[e.nodeId,e.parentNodeId]));for(let[n,r]of e.nodesByNodeId){if(r.sandboxRegistry.sandbox.definition.inheritsParent!==!0)continue;if(r.agent.dynamicSkillResolvers.length>0)throw new ResolveRuntimeAgentGraphError(`Sandbox "${r.sandboxRegistry.sandbox.definition.logicalPath}" selects parent.sandbox but agent node "${n}" defines dynamic skills. Remove the child dynamic skills or give the child its own sandbox.`,{nodeId:n});let i=t.get(n);if(i===void 0)throw new ResolveRuntimeAgentGraphError(`Sandbox "${r.sandboxRegistry.sandbox.definition.logicalPath}" selects parent.sandbox but agent node "${n}" has no parent.`,{nodeId:n});let a=resolveSandboxOwnerNode({nodeId:i,nodesByNodeId:e.nodesByNodeId,parentNodeIdByChildNodeId:t});r.sandboxRegistry.sandbox.inheritance={definition:a.sandboxRegistry.sandbox.definition,nodeId:a.nodeId,workspaceResourceRoot:a.sandboxRegistry.sandbox.workspaceResourceRoot};let o=createWorkspacePromptSection(a.agent.workspaceSpec);o!==void 0&&(r.turnAgent.instructions=[...r.turnAgent.instructions,o])}}function resolveSandboxOwnerNode(e){let t=e.nodesByNodeId.get(toRuntimeNodeId(e.nodeId));if(t===void 0)throw new ResolveRuntimeAgentGraphError(`Missing parent runtime node "${e.nodeId}".`,{nodeId:e.nodeId});if(t.sandboxRegistry.sandbox.definition.inheritsParent!==!0)return t;let n=e.parentNodeIdByChildNodeId.get(e.nodeId);if(n===void 0)throw new ResolveRuntimeAgentGraphError(`Inherited sandbox node "${e.nodeId}" has no parent.`,{nodeId:e.nodeId});return resolveSandboxOwnerNode({...e,nodeId:n})}function createChildNodeIdsByParentNodeId(e){let t=new Map;for(let n of e.subagents){let e=t.get(n.parentNodeId);if(e===void 0){t.set(n.parentNodeId,[n.nodeId]);continue}e.push(n.nodeId)}return t}function toRuntimeNodeId(e){return e===ROOT_COMPILED_AGENT_NODE_ID?ROOT_RUNTIME_AGENT_NODE_ID:e}export{resolveRuntimeAgentGraph};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveConnectionDefinition}from"#runtime/resolve-connection.js";import{ResolveAgentError,createResolvedModuleSourceRef}from"#runtime/resolve-helpers.js";import{resolveChannelDefinition}from"#runtime/resolve-channel.js";import{resolveDynamicConnectionDefinition}from"#runtime/resolve-dynamic-connection.js";import{resolveHookDefinition}from"#runtime/resolve-hook.js";import{resolveSandboxDefinition}from"#runtime/resolve-sandbox.js";import{resolveDynamicInstructionsDefinition}from"#runtime/resolve-dynamic-instructions.js";import{resolveDynamicSkillDefinition}from"#runtime/resolve-dynamic-skill.js";import{resolveDynamicToolDefinition}from"#runtime/resolve-dynamic-tool.js";import{resolveToolDefinition}from"#runtime/resolve-tool.js";import{resolveMemoryDefinition}from"#runtime/resolve-memory.js";async function resolveAgent(t){let n=t.manifest.skills.map(e=>({...e,owner:requireCompiledSourceOwner(t.manifest,e),metadata:e.metadata===void 0?void 0:{...e.metadata}})),i=await Promise.all(t.manifest.channelRoutes.effective.map(e=>resolveChannelDefinition(e,t.moduleMap,t.nodeId))),a=await Promise.all(t.manifest.tools.map(e=>resolveToolDefinition(e,t.moduleMap,t.nodeId,requireBindingOwner(t.manifest,e.sourceId)))),o=await Promise.all(t.manifest.dynamicConnections.map(e=>resolveDynamicConnectionDefinition(e,t.moduleMap,t.nodeId))),s=await Promise.all((t.manifest.dynamicInstructions??[]).map(e=>resolveDynamicInstructionsDefinition(e,t.moduleMap,t.nodeId))),c=await Promise.all((t.manifest.dynamicSkills??[]).map(e=>resolveDynamicSkillDefinition(e,t.moduleMap,t.nodeId))),l=await Promise.all(t.manifest.dynamicTools.map(e=>resolveDynamicToolDefinition(e,t.moduleMap,t.nodeId))),u=await Promise.all(t.manifest.hooks.map(e=>resolveHookDefinition(e,t.moduleMap,t.nodeId))),d=await Promise.all(t.manifest.connections.map(n=>resolveConnectionDefinition(n,t.moduleMap,t.nodeId))),f=await Promise.all(t.manifest.memories.map(e=>resolveMemoryDefinition(e,t.moduleMap,t.nodeId))),p=await resolveSandboxDefinition(t.manifest.sandbox,t.moduleMap,t.nodeId),m=t.manifest.instructions.map(e=>createResolvedInstructionsDefinition(t.manifest,e)),h=t.manifest.workspaceResourceRoot,g={channels:i,connections:d,dynamicConnectionResolvers:o,workflowTool:t.manifest.workflowTool===void 0?void 0:{maxSubagents:t.manifest.workflowTool.maxSubagents},
|
|
1
|
+
import{resolveConnectionDefinition}from"#runtime/resolve-connection.js";import{ResolveAgentError,createResolvedModuleSourceRef}from"#runtime/resolve-helpers.js";import{resolveChannelDefinition}from"#runtime/resolve-channel.js";import{resolveDynamicConnectionDefinition}from"#runtime/resolve-dynamic-connection.js";import{resolveHookDefinition}from"#runtime/resolve-hook.js";import{resolveSandboxDefinition}from"#runtime/resolve-sandbox.js";import{resolveDynamicInstructionsDefinition}from"#runtime/resolve-dynamic-instructions.js";import{resolveDynamicSkillDefinition}from"#runtime/resolve-dynamic-skill.js";import{resolveDynamicToolDefinition}from"#runtime/resolve-dynamic-tool.js";import{resolveToolDefinition}from"#runtime/resolve-tool.js";import{resolveMemoryDefinition}from"#runtime/resolve-memory.js";async function resolveAgent(t){let n=t.manifest.skills.map(e=>({...e,owner:requireCompiledSourceOwner(t.manifest,e),metadata:e.metadata===void 0?void 0:{...e.metadata}})),i=await Promise.all(t.manifest.channelRoutes.effective.map(e=>resolveChannelDefinition(e,t.moduleMap,t.nodeId))),a=await Promise.all(t.manifest.tools.map(e=>resolveToolDefinition(e,t.moduleMap,t.nodeId,requireBindingOwner(t.manifest,e.sourceId)))),o=await Promise.all(t.manifest.dynamicConnections.map(e=>resolveDynamicConnectionDefinition(e,t.moduleMap,t.nodeId))),s=await Promise.all((t.manifest.dynamicInstructions??[]).map(e=>resolveDynamicInstructionsDefinition(e,t.moduleMap,t.nodeId))),c=await Promise.all((t.manifest.dynamicSkills??[]).map(e=>resolveDynamicSkillDefinition(e,t.moduleMap,t.nodeId))),l=await Promise.all(t.manifest.dynamicTools.map(e=>resolveDynamicToolDefinition(e,t.moduleMap,t.nodeId))),u=await Promise.all(t.manifest.hooks.map(e=>resolveHookDefinition(e,t.moduleMap,t.nodeId))),d=await Promise.all(t.manifest.connections.map(n=>resolveConnectionDefinition(n,t.moduleMap,t.nodeId))),f=await Promise.all(t.manifest.memories.map(e=>resolveMemoryDefinition(e,t.moduleMap,t.nodeId))),p=await resolveSandboxDefinition(t.manifest.sandbox,t.moduleMap,t.nodeId),m=t.manifest.instructions.map(e=>createResolvedInstructionsDefinition(t.manifest,e)),h=t.manifest.workspaceResourceRoot,g={channels:i,connections:d,dynamicConnectionResolvers:o,workflowTool:t.manifest.workflowTool===void 0?void 0:{maxSubagents:t.manifest.workflowTool.maxSubagents},dynamicInstructionsResolvers:s,dynamicSkillResolvers:c,dynamicToolResolvers:l,hooks:u,instructions:m,metadata:{agentRoot:t.manifest.agentRoot,appRoot:t.manifest.appRoot,diagnosticsSummary:t.manifest.diagnosticsSummary},memories:f,sandbox:p,workspaceResourceRoot:h,skills:n,tools:a,workspaceSpec:{rootEntries:[...h.rootEntries]}};return`config`in t.manifest?{...g,config:createResolvedAgentConfig(t.manifest)}:g}function requireBindingOwner(e,t){let n=e.bindings[t];if(n===void 0)throw Error(`Compiled source "${t}" has no binding.`);return n.owner}function createResolvedInstructionsDefinition(e,t){return{content:t.content,name:t.name,owner:requireCompiledSourceOwner(e,t),logicalPath:t.logicalPath,role:t.role,sourceId:t.sourceId,sourceKind:t.sourceKind}}function requireCompiledSourceOwner(e,t){let n=e.bindings[t.sourceId]?.owner??t.owner;if(n===void 0)throw Error(`Compiled source "${t.sourceId}" has no owner.`);return n}function createResolvedAgentConfig(e){let t={name:e.config.name};if(e.config.compaction!==void 0){let n={};e.config.compaction.model!==void 0&&(n.model=e.config.compaction.model.source===void 0?{contextWindowTokens:e.config.compaction.model.contextWindowTokens,id:e.config.compaction.model.id,maxOutputTokens:e.config.compaction.model.maxOutputTokens,providerOptions:e.config.compaction.model.providerOptions}:{contextWindowTokens:e.config.compaction.model.contextWindowTokens,id:e.config.compaction.model.id,maxOutputTokens:e.config.compaction.model.maxOutputTokens,providerOptions:e.config.compaction.model.providerOptions,source:{exportName:e.config.compaction.model.source.exportName,sourceKind:`module`,logicalPath:e.config.compaction.model.source.logicalPath,sourceId:e.config.compaction.model.source.sourceId}}),e.config.compaction.thresholdPercent!==void 0&&(n.thresholdPercent=e.config.compaction.thresholdPercent),t.compaction=n}if(e.config.experimental!==void 0&&(t.experimental={instrumentationProviders:e.config.experimental.instrumentationProviders,tasks:e.config.experimental.tasks,workflow:e.config.experimental.workflow===void 0?void 0:{world:e.config.experimental.workflow.world}}),e.config.outputSchema!==void 0&&(t.outputSchema=e.config.outputSchema),e.config.reasoning!==void 0&&(t.reasoning=e.config.reasoning),e.config.source!==void 0&&(t.source=createResolvedModuleSourceRef(e.config.source)),e.config.limits!==void 0&&(t.limits={maxInputTokensPerSession:e.config.limits.maxInputTokensPerSession,maxOutputTokensPerSession:e.config.limits.maxOutputTokensPerSession,sessionTimeoutMs:e.config.limits.sessionTimeoutMs}),e.config.dynamicModel!==void 0)return{...t,dynamicModel:{...createResolvedModuleSourceRef(e.config.dynamicModel),eventNames:[...e.config.dynamicModel.eventNames]}};let r=e.config.model;return{...t,model:r.source===void 0?{id:r.id,contextWindowTokens:r.contextWindowTokens,maxOutputTokens:r.maxOutputTokens,providerOptions:r.providerOptions}:{contextWindowTokens:r.contextWindowTokens,id:r.id,maxOutputTokens:r.maxOutputTokens,providerOptions:r.providerOptions,source:{exportName:r.source.exportName,sourceKind:`module`,logicalPath:r.source.logicalPath,sourceId:r.source.sourceId}}}}export{ResolveAgentError,resolveAgent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{expectFunction,expectObjectRecord}from"#internal/authored-module.js";import{toErrorMessage}from"#shared/errors.js";import{isToolSchema,toInputSchema,toOutputSchema}from"#tools/schema.js";import{registerDefinitionSource,stampDefinitionKey}from"#internal/authored-definition/source-identity.js";import{normalizeApproval}from"#internal/authored-definition/approval.js";import{ResolveAgentError,loadResolvedModuleExport}from"#runtime/resolve-helpers.js";async function resolveToolDefinition(i,o,s,c){if(!i.hasExecute)return{description:i.description,inputSchema:toInputSchema(i.inputSchema),logicalPath:i.logicalPath,name:i.name,outputSchema:toOutputSchema(i.outputSchema),owner:c,sourceId:i.sourceId,sourceKind:`module`};try{let n=expectObjectRecord(await loadResolvedModuleExport({definition:i,kindLabel:`tool`,moduleMap:o,nodeId:s}),describe(i,`to return an object`)),a={kind:`tool`,logicalPath:i.logicalPath,name:i.name,owner:c},l=`tool-source:${i.sourceId}`;stampDefinitionKey(n,l),registerDefinitionSource(l,a),registerDefinitionSource(`tool:${n.description}`,a);let u=expectFunction(n.execute,describe(i,`to provide an execute function`)),d=isToolSchema(n.inputSchema)?n.inputSchema:toInputSchema(i.inputSchema),f=isToolSchema(n.outputSchema)?n.outputSchema:toOutputSchema(i.outputSchema);return{description:i.description,execute:u,execution:i.execution,exportName:i.exportName,inputSchema:d,logicalPath:i.logicalPath,name:i.name,owner:c,outputSchema:f,sourceId:i.sourceId,sourceKind:`module`,...extractOptionalHooks(n,i)}}catch(e){throw e instanceof ResolveAgentError?e:new ResolveAgentError(`Failed to attach the tool execute function from "${i.logicalPath}": ${toErrorMessage(e)}`,{logicalPath:i.logicalPath,sourceId:i.sourceId})}}function extractOptionalHooks(t,n){let r={};return t.approval!==void 0&&(r.approval=normalizeApproval(t.approval,describe(n,`to provide a valid approval definition`))),t.toModelOutput!==void 0&&(r.toModelOutput=expectFunction(t.toModelOutput,describe(n,`to provide a toModelOutput function`))),r}function describe(e,t){return`Expected the tool export "${e.exportName??`default`}" from "${e.logicalPath}" ${t}.`}export{resolveToolDefinition};
|
|
1
|
+
import{expectFunction,expectObjectRecord}from"#internal/authored-module.js";import{toErrorMessage}from"#shared/errors.js";import{isToolSchema,toInputSchema,toOutputSchema}from"#tools/schema.js";import{registerDefinitionSource,stampDefinitionKey}from"#internal/authored-definition/source-identity.js";import{normalizeApproval}from"#internal/authored-definition/approval.js";import{ResolveAgentError,loadResolvedModuleExport}from"#runtime/resolve-helpers.js";async function resolveToolDefinition(i,o,s,c){if(!i.hasExecute)return{behavior:i.behavior,description:i.description,inputSchema:toInputSchema(i.inputSchema),logicalPath:i.logicalPath,name:i.name,outputSchema:toOutputSchema(i.outputSchema),owner:c,sourceId:i.sourceId,sourceKind:`module`};try{let n=expectObjectRecord(await loadResolvedModuleExport({definition:i,kindLabel:`tool`,moduleMap:o,nodeId:s}),describe(i,`to return an object`)),a={kind:`tool`,logicalPath:i.logicalPath,name:i.name,owner:c},l=`tool-source:${i.sourceId}`;stampDefinitionKey(n,l),registerDefinitionSource(l,a),registerDefinitionSource(`tool:${n.description}`,a);let u=expectFunction(n.execute,describe(i,`to provide an execute function`)),d=isToolSchema(n.inputSchema)?n.inputSchema:toInputSchema(i.inputSchema),f=isToolSchema(n.outputSchema)?n.outputSchema:toOutputSchema(i.outputSchema);return{behavior:i.behavior,description:i.description,execute:u,execution:i.execution,exportName:i.exportName,inputSchema:d,logicalPath:i.logicalPath,name:i.name,owner:c,outputSchema:f,sourceId:i.sourceId,sourceKind:`module`,...extractOptionalHooks(n,i)}}catch(e){throw e instanceof ResolveAgentError?e:new ResolveAgentError(`Failed to attach the tool execute function from "${i.logicalPath}": ${toErrorMessage(e)}`,{logicalPath:i.logicalPath,sourceId:i.sourceId})}}function extractOptionalHooks(t,n){let r={};return t.approval!==void 0&&(r.approval=normalizeApproval(t.approval,describe(n,`to provide a valid approval definition`))),t.toModelOutput!==void 0&&(r.toModelOutput=expectFunction(t.toModelOutput,describe(n,`to provide a toModelOutput function`))),r}function describe(e,t){return`Expected the tool export "${e.exportName??`default`}" from "${e.logicalPath}" ${t}.`}export{resolveToolDefinition};
|
|
@@ -35,6 +35,7 @@ export interface RuntimeSession {
|
|
|
35
35
|
* Creates a fresh, empty runtime session.
|
|
36
36
|
*/
|
|
37
37
|
export declare function createRuntimeSession(id?: string): RuntimeSession;
|
|
38
|
+
export declare function setRuntimeSessionCompiledArtifacts(session: RuntimeSession, input: BundledCompiledArtifacts): void;
|
|
38
39
|
/**
|
|
39
40
|
* Returns the runtime session that should be consulted for the current call.
|
|
40
41
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AsyncLocalStorage}from"node:async_hooks";function createRuntimeSession(e=`test-session`){return{bundleCache:new Map,bundleCacheKeyBySourceKey:new Map,compiledArtifacts:null,id:e}}const RUNTIME_SESSION_STORAGE_GLOBAL_KEY=Symbol.for(`eve.runtime-session-storage`),RUNTIME_SESSION_DEFAULT_GLOBAL_KEY=Symbol.for(`eve.runtime-session-default`),globalContainer=globalThis;globalContainer[RUNTIME_SESSION_STORAGE_GLOBAL_KEY]===void 0&&(globalContainer[RUNTIME_SESSION_STORAGE_GLOBAL_KEY]=new AsyncLocalStorage);const runtimeSessionStorage=globalContainer[RUNTIME_SESSION_STORAGE_GLOBAL_KEY];function resolveProcessDefaultSession(){return globalContainer[RUNTIME_SESSION_DEFAULT_GLOBAL_KEY]===void 0&&(globalContainer[RUNTIME_SESSION_DEFAULT_GLOBAL_KEY]=createRuntimeSession(`process-default`)),globalContainer[RUNTIME_SESSION_DEFAULT_GLOBAL_KEY]}function getActiveRuntimeSession(){return runtimeSessionStorage.getStore()??resolveProcessDefaultSession()}async function withRuntimeSession(e,t){return await runtimeSessionStorage.run(e,async()=>await t())}export{createRuntimeSession,getActiveRuntimeSession,withRuntimeSession};
|
|
1
|
+
import{AsyncLocalStorage}from"node:async_hooks";function createRuntimeSession(e=`test-session`){return{bundleCache:new Map,bundleCacheKeyBySourceKey:new Map,compiledArtifacts:null,id:e}}function setRuntimeSessionCompiledArtifacts(e,t){let n=e.compiledArtifacts;(n===null||!isSameCompiledArtifactSnapshot(n,t))&&(e.bundleCache.clear(),e.bundleCacheKeyBySourceKey.clear()),e.compiledArtifacts=t}function isSameCompiledArtifactSnapshot(e,t){let n=e.metadata?.discovery.sourceGraphHash,r=t.metadata?.discovery.sourceGraphHash;return n&&r?n===r:e.manifest===t.manifest&&e.moduleMap===t.moduleMap&&e.metadata===t.metadata}const RUNTIME_SESSION_STORAGE_GLOBAL_KEY=Symbol.for(`eve.runtime-session-storage`),RUNTIME_SESSION_DEFAULT_GLOBAL_KEY=Symbol.for(`eve.runtime-session-default`),globalContainer=globalThis;globalContainer[RUNTIME_SESSION_STORAGE_GLOBAL_KEY]===void 0&&(globalContainer[RUNTIME_SESSION_STORAGE_GLOBAL_KEY]=new AsyncLocalStorage);const runtimeSessionStorage=globalContainer[RUNTIME_SESSION_STORAGE_GLOBAL_KEY];function resolveProcessDefaultSession(){return globalContainer[RUNTIME_SESSION_DEFAULT_GLOBAL_KEY]===void 0&&(globalContainer[RUNTIME_SESSION_DEFAULT_GLOBAL_KEY]=createRuntimeSession(`process-default`)),globalContainer[RUNTIME_SESSION_DEFAULT_GLOBAL_KEY]}function getActiveRuntimeSession(){return runtimeSessionStorage.getStore()??resolveProcessDefaultSession()}async function withRuntimeSession(e,t){return await runtimeSessionStorage.run(e,async()=>await t())}export{createRuntimeSession,getActiveRuntimeSession,setRuntimeSessionCompiledArtifacts,withRuntimeSession};
|
|
@@ -2,15 +2,18 @@ import type { Node } from "#shared/node.js";
|
|
|
2
2
|
import type { SourceRef } from "#shared/source-ref.js";
|
|
3
3
|
import type { InternalToolDefinition } from "#tools/definition.js";
|
|
4
4
|
import type { AgentSourceOwner } from "#compiler/source-graph.js";
|
|
5
|
+
import type { PreparedToolBehavior } from "#tools/behavior.js";
|
|
5
6
|
/**
|
|
6
7
|
* Serializable authored tool descriptor prepared by the runtime for one
|
|
7
8
|
* harness turn.
|
|
8
9
|
*/
|
|
9
10
|
export type PreparedRuntimeAuthoredTool = Readonly<InternalToolDefinition & SourceRef & {
|
|
11
|
+
behavior?: PreparedToolBehavior;
|
|
10
12
|
kind: "authored-tool";
|
|
11
13
|
owner: AgentSourceOwner;
|
|
12
14
|
}>;
|
|
13
15
|
type PreparedRuntimeDelegationToolBase<TKind extends "remote" | "subagent"> = Readonly<InternalToolDefinition & SourceRef & Node & {
|
|
16
|
+
behavior: PreparedToolBehavior;
|
|
14
17
|
kind: TKind;
|
|
15
18
|
}>;
|
|
16
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{serializeInputSchema}from"#tools/schema.js";import{SUBAGENT_TOOL_INPUT_SCHEMA}from"#tools/framework/agent-contract.js";import{RuntimeRegistry,RuntimeRegistryError}from"#internal/runtime-registry.js";const SUBAGENT_TOOL_INPUT_JSON_SCHEMA=serializeInputSchema(SUBAGENT_TOOL_INPUT_SCHEMA);function createRuntimeSubagentRegistry(e){let t=[],i=new Set,a=[],o=new RuntimeRegistry(`subagent`,e.reservedToolNames??[]),s=new Map;for(let n of e.subagents){let e={logicalPath:n.logicalPath,sourceId:n.sourceId};if(s.has(n.nodeId))throw new RuntimeRegistryError(`subagent`,`Found multiple runtime subagents mapped to node id "${n.nodeId}".`,{...e,entryName:n.name});let c,l=n.kind===`subagent`?n.dynamic:void 0;if(l===void 0){let r=createPreparedRuntimeSubagentTool(n);c={definition:n,prepared:r},o.register(n.name,c,{location:e,duplicateMessage:`Found multiple subagents named "${n.name}". Subagent names must be unique at runtime.`,reservedMessage:`Subagent "${n.name}" collides with another runtime-visible tool name.`}),t.push(r)}else i.add(n.nodeId),a.push({...l,kind:`subagent`,logicalPath:n.logicalPath,name:n.name,nodeId:n.nodeId,sourceId:n.sourceId,sourceKind:`module`}),c={definition:n};s.set(n.nodeId,c)}return{dynamicNodeIds:i,dynamicResolvers:a,preparedTools:t,subagentsByName:o.asMap(),subagentsByNodeId:s}}function createPreparedRuntimeSubagentTool(e,t=SUBAGENT_TOOL_INPUT_JSON_SCHEMA){if(e.description===void 0)throw Error(`Static subagent "${e.name}" is missing a description.`);return{description:e.description,inputSchema:t,kind:e.kind,logicalPath:e.logicalPath,name:e.name,nodeId:e.nodeId,outputSchema:e.kind===`remote`?e.outputSchema:void 0,sourceId:e.sourceId}}export{createPreparedRuntimeSubagentTool,createRuntimeSubagentRegistry};
|
|
1
|
+
import{serializeInputSchema}from"#tools/schema.js";import{SUBAGENT_TOOL_INPUT_SCHEMA}from"#tools/framework/agent-contract.js";import{RuntimeRegistry,RuntimeRegistryError}from"#internal/runtime-registry.js";const SUBAGENT_TOOL_INPUT_JSON_SCHEMA=serializeInputSchema(SUBAGENT_TOOL_INPUT_SCHEMA);function createRuntimeSubagentRegistry(e){let t=[],i=new Set,a=[],o=new RuntimeRegistry(`subagent`,e.reservedToolNames??[]),s=new Map;for(let n of e.subagents){let e={logicalPath:n.logicalPath,sourceId:n.sourceId};if(s.has(n.nodeId))throw new RuntimeRegistryError(`subagent`,`Found multiple runtime subagents mapped to node id "${n.nodeId}".`,{...e,entryName:n.name});let c,l=n.kind===`subagent`?n.dynamic:void 0;if(l===void 0){let r=createPreparedRuntimeSubagentTool(n);c={definition:n,prepared:r},o.register(n.name,c,{location:e,duplicateMessage:`Found multiple subagents named "${n.name}". Subagent names must be unique at runtime.`,reservedMessage:`Subagent "${n.name}" collides with another runtime-visible tool name.`}),t.push(r)}else i.add(n.nodeId),a.push({...l,kind:`subagent`,logicalPath:n.logicalPath,name:n.name,nodeId:n.nodeId,sourceId:n.sourceId,sourceKind:`module`}),c={definition:n};s.set(n.nodeId,c)}return{dynamicNodeIds:i,dynamicResolvers:a,preparedTools:t,subagentsByName:o.asMap(),subagentsByNodeId:s}}function createPreparedRuntimeSubagentTool(e,t=SUBAGENT_TOOL_INPUT_JSON_SCHEMA){if(e.description===void 0)throw Error(`Static subagent "${e.name}" is missing a description.`);return{behavior:{availability:[],handling:{kind:`dispatch`,target:e.kind===`remote`?{kind:`remote-agent-call`,nodeId:e.nodeId,remoteAgentName:e.name}:{kind:`subagent-call`,nodeId:e.nodeId,subagentName:e.name}}},description:e.description,inputSchema:t,kind:e.kind,logicalPath:e.logicalPath,name:e.name,nodeId:e.nodeId,outputSchema:e.kind===`remote`?e.outputSchema:void 0,sourceId:e.sourceId}}export{createPreparedRuntimeSubagentTool,createRuntimeSubagentRegistry};
|
|
@@ -21,6 +21,7 @@ export interface RuntimeToolRegistry {
|
|
|
21
21
|
export declare function createRuntimeToolRegistry(definitions: {
|
|
22
22
|
readonly tools: readonly ResolvedToolDefinition[];
|
|
23
23
|
}, input?: {
|
|
24
|
+
readonly nodeId?: string;
|
|
24
25
|
readonly reservedToolNames?: readonly string[];
|
|
25
26
|
}): Promise<RuntimeToolRegistry>;
|
|
26
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{serializeInputSchema,serializeOutputSchema}from"#tools/schema.js";import{RuntimeRegistry}from"#internal/runtime-registry.js";async function createRuntimeToolRegistry(e,t={}){let r=[],i=new RuntimeRegistry(`tool`,t.reservedToolNames??[]);for(let
|
|
1
|
+
import{serializeInputSchema,serializeOutputSchema}from"#tools/schema.js";import{RuntimeRegistry}from"#internal/runtime-registry.js";async function createRuntimeToolRegistry(e,t={}){let r=[],i=new RuntimeRegistry(`tool`,t.reservedToolNames??[]);for(let n of e.tools){let e=await createPreparedRuntimeTool(n,t.nodeId);i.register(n.name,{definition:n,prepared:e},{location:{logicalPath:n.logicalPath,sourceId:n.sourceId},duplicateMessage:`Found multiple authored tools named "${n.name}". Tool names must be unique at runtime.`,reservedMessage:`Tool "${n.name}" collides with another runtime-visible tool name.`}),r.push(e)}return{preparedTools:r,toolsByName:i.asMap()}}function findRegisteredRuntimeTool(e,t){return e.toolsByName.get(t)??null}async function createPreparedRuntimeTool(n,r){return{behavior:prepareToolBehavior(n.behavior,r),description:n.description,inputSchema:serializeInputSchema(n.inputSchema),kind:`authored-tool`,logicalPath:n.logicalPath,name:n.name,owner:n.owner,outputSchema:serializeOutputSchema(n.outputSchema),sourceId:n.sourceId}}function prepareToolBehavior(e,t){if(e===void 0)return;if(e.handling===void 0)return{availability:e.availability,presentation:e.presentation};if(e.handling.kind!==`dispatch`)return{...e,handling:e.handling};let n;switch(e.handling.action){case`self-agent`:if(t===void 0)throw Error(`The self-agent tool requires a concrete runtime node id.`);n={kind:`self-agent-call`,nodeId:t,subagentName:`agent`};break;case`task-cancel`:n={kind:`task-cancel`};break;case`task-update`:n={kind:`task-update`};break;default:return e.handling.action}return{...e,handling:{kind:`dispatch`,target:n}}}export{createRuntimeToolRegistry,findRegisteredRuntimeTool};
|
|
@@ -23,7 +23,7 @@ import type { NamedSkillDefinition } from "#shared/skill-definition.js";
|
|
|
23
23
|
import type { InternalAgentDefinition } from "#shared/agent-definition.js";
|
|
24
24
|
import type { RuntimeDynamicModelReference } from "#runtime/agent/bootstrap.js";
|
|
25
25
|
import type { InternalToolDefinitionWithExecuteFn } from "#tools/definition.js";
|
|
26
|
-
import type {
|
|
26
|
+
import type { CompiledToolBehavior } from "#tools/behavior.js";
|
|
27
27
|
import type { SandboxBackend } from "#shared/sandbox-backend.js";
|
|
28
28
|
import type { SandboxBootstrapContext, SandboxSessionContext } from "#shared/sandbox-definition.js";
|
|
29
29
|
import type { ToolSchema } from "#tools/schema.js";
|
|
@@ -134,6 +134,7 @@ export type ResolvedSandboxDefinition = ResolvedModuleSourceRef & {
|
|
|
134
134
|
* A tool without `execute` is surfaced to the client and never executed by eve.
|
|
135
135
|
*/
|
|
136
136
|
export type ResolvedToolDefinition = Readonly<Omit<Optional<InternalToolDefinitionWithExecuteFn<unknown, unknown>, "execute">, "inputSchema" | "outputSchema">> & ResolvedModuleSourceRef & {
|
|
137
|
+
readonly behavior?: CompiledToolBehavior;
|
|
137
138
|
readonly owner: AgentSourceOwner;
|
|
138
139
|
/**
|
|
139
140
|
* Validated runtime input schema. Compiled and durable JSON Schemas are
|
|
@@ -365,7 +366,6 @@ export interface ResolvedAgent {
|
|
|
365
366
|
readonly maxSubagents?: number;
|
|
366
367
|
};
|
|
367
368
|
/** AI Gateway provider selected for the framework `web_search` tool. */
|
|
368
|
-
readonly webSearchProvider?: WebSearchProvider;
|
|
369
369
|
readonly dynamicInstructionsResolvers: readonly ResolvedDynamicInstructionsResolver[];
|
|
370
370
|
readonly dynamicSkillResolvers: readonly ResolvedDynamicSkillResolver[];
|
|
371
371
|
readonly dynamicToolResolvers: readonly ResolvedDynamicToolResolver[];
|
|
@@ -12,6 +12,7 @@ export declare function resolveDevelopmentClientOptions(serverUrl: string): Clie
|
|
|
12
12
|
/** Builds a non-redirecting local client, using ambient bearer auth only when it owns Authorization. */
|
|
13
13
|
export declare function resolveLocalDevelopmentClientOptions(input: {
|
|
14
14
|
readonly headers?: DevelopmentClientHeaders;
|
|
15
|
+
readonly interactiveClient?: boolean;
|
|
15
16
|
readonly serverUrl: string;
|
|
16
17
|
readonly token: () => Promise<string>;
|
|
17
18
|
}): ClientOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER}from"#client/types.js";function hasDevelopmentAuthorizationHeader(e){return e!==void 0&&Object.keys(e).some(e=>e.toLowerCase()===`authorization`)}async function resolveRemoteHeaders(t){if(!t.includeTrustedOidcHeader)return{...await t.credentials.resolveBypassHeaders(),...t.headers};let[n,r]=await Promise.all([t.credentials.resolveBypassHeaders(),t.credentials.resolveToken()]),i={...n,...t.headers},a=r.trim();return a.length>0&&(i[VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER]=a),i}function resolveDevelopmentClientOptions(e){return{host:e}}function resolveLocalDevelopmentClientOptions(e){let
|
|
1
|
+
import{VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER}from"#client/types.js";import{LOCAL_DEV_INTERACTIVE_CLIENT_HEADER}from"#runtime/local-dev-capability.js";function hasDevelopmentAuthorizationHeader(e){return e!==void 0&&Object.keys(e).some(e=>e.toLowerCase()===`authorization`)}async function resolveRemoteHeaders(t){if(!t.includeTrustedOidcHeader)return{...await t.credentials.resolveBypassHeaders(),...t.headers};let[n,r]=await Promise.all([t.credentials.resolveBypassHeaders(),t.credentials.resolveToken()]),i={...n,...t.headers},a=r.trim();return a.length>0&&(i[VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER]=a),i}function resolveDevelopmentClientOptions(e){return{host:e}}function resolveLocalDevelopmentClientOptions(e){let n=e.interactiveClient===!0?{...e.headers,[LOCAL_DEV_INTERACTIVE_CLIENT_HEADER]:`1`}:e.headers,r={host:e.serverUrl,redirect:`manual`};if(hasDevelopmentAuthorizationHeader(n))return{...r,headers:n};let i={...r,auth:{bearer:e.token}};return n===void 0?i:{...i,headers:n}}function resolveRemoteDevelopmentClientOptions(e){let t=new URL(e.serverUrl).origin;if(e.credentials.serverOrigin!==t)throw Error(`Credential gate origin ${e.credentials.serverOrigin} does not match client origin ${t}.`);return hasDevelopmentAuthorizationHeader(e.headers)?{headers:()=>resolveRemoteHeaders({credentials:e.credentials,headers:e.headers,includeTrustedOidcHeader:!0}),host:e.serverUrl,redirect:`manual`}:{auth:{vercelOidc:{token:()=>e.credentials.resolveToken()}},headers:e.headers===void 0?e.credentials.resolveBypassHeaders:()=>resolveRemoteHeaders({credentials:e.credentials,headers:e.headers,includeTrustedOidcHeader:!1}),host:e.serverUrl,redirect:`manual`}}export{hasDevelopmentAuthorizationHeader,resolveDevelopmentClientOptions,resolveLocalDevelopmentClientOptions,resolveRemoteDevelopmentClientOptions};
|
|
@@ -14,9 +14,11 @@ export declare function readDevelopmentRuntimeArtifactsRevision(input: {
|
|
|
14
14
|
readonly timeoutMs?: number;
|
|
15
15
|
}): Promise<string | undefined>;
|
|
16
16
|
export declare function suspendDevelopmentRuntimeArtifacts(input: {
|
|
17
|
+
readonly leaseId: string;
|
|
17
18
|
readonly serverUrl: string;
|
|
18
19
|
}): Promise<boolean>;
|
|
19
20
|
export declare function resumeDevelopmentRuntimeArtifacts(input: {
|
|
21
|
+
readonly leaseId: string;
|
|
20
22
|
readonly serverUrl: string;
|
|
21
23
|
readonly silent?: boolean;
|
|
22
24
|
}): Promise<string | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH,EVE_DEV_RUNTIME_ARTIFACTS_RESUME_ROUTE_PATH,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH,EVE_DEV_RUNTIME_ARTIFACTS_SUSPEND_ROUTE_PATH}from"#protocol/routes.js";async function readDevelopmentRuntimeArtifactsRevision(e){try{let t=new URL(EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH,e.serverUrl),r=e.timeoutMs===void 0?void 0:AbortSignal.timeout(e.timeoutMs),i=e.signal===void 0?r:r===void 0?e.signal:AbortSignal.any([e.signal,r]),a={redirect:`error`};return i!==void 0&&(a.signal=i),await parseDevelopmentRuntimeArtifactsRevision(await fetch(t,a))}catch{return}}async function suspendDevelopmentRuntimeArtifacts(e){return await changeDevelopmentRuntimeArtifacts(e.serverUrl,EVE_DEV_RUNTIME_ARTIFACTS_SUSPEND_ROUTE_PATH)}async function resumeDevelopmentRuntimeArtifacts(e){try{let n=new URL(EVE_DEV_RUNTIME_ARTIFACTS_RESUME_ROUTE_PATH,e.serverUrl);return e.silent===!0&&n.searchParams.set(`silent`,`1`),await parseDevelopmentRuntimeArtifactsRevision(await fetch(n,{method:`POST`}))}catch{return}}async function changeDevelopmentRuntimeArtifacts(e,t){try{
|
|
1
|
+
import{EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH,EVE_DEV_RUNTIME_ARTIFACTS_RESUME_ROUTE_PATH,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH,EVE_DEV_RUNTIME_ARTIFACTS_SUSPEND_ROUTE_PATH}from"#protocol/routes.js";async function readDevelopmentRuntimeArtifactsRevision(e){try{let t=new URL(EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH,e.serverUrl),r=e.timeoutMs===void 0?void 0:AbortSignal.timeout(e.timeoutMs),i=e.signal===void 0?r:r===void 0?e.signal:AbortSignal.any([e.signal,r]),a={redirect:`error`};return i!==void 0&&(a.signal=i),await parseDevelopmentRuntimeArtifactsRevision(await fetch(t,a))}catch{return}}async function suspendDevelopmentRuntimeArtifacts(e){return await changeDevelopmentRuntimeArtifacts(e.serverUrl,EVE_DEV_RUNTIME_ARTIFACTS_SUSPEND_ROUTE_PATH,e.leaseId)}async function resumeDevelopmentRuntimeArtifacts(e){try{let n=new URL(EVE_DEV_RUNTIME_ARTIFACTS_RESUME_ROUTE_PATH,e.serverUrl);return n.searchParams.set(`lease`,e.leaseId),e.silent===!0&&n.searchParams.set(`silent`,`1`),await parseDevelopmentRuntimeArtifactsRevision(await fetch(n,{method:`POST`}))}catch{return}}async function changeDevelopmentRuntimeArtifacts(e,t,n){try{let r=new URL(t,e);return r.searchParams.set(`lease`,n),(await fetch(r,{method:`POST`})).ok}catch{return!1}}async function rebuildDevelopmentRuntimeArtifacts(t){try{let n=new URL(EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH,t.serverUrl);return t.force===!0&&n.searchParams.set(`force`,`1`),await parseDevelopmentRuntimeArtifactsRevision(await fetch(n,{method:`POST`}))}catch{return}}async function parseDevelopmentRuntimeArtifactsRevision(e){if(!e.ok)return;let t=await e.json();return typeof t.revision==`string`&&t.revision.length>0?t.revision:void 0}export{readDevelopmentRuntimeArtifactsRevision,rebuildDevelopmentRuntimeArtifacts,resumeDevelopmentRuntimeArtifacts,suspendDevelopmentRuntimeArtifacts};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{pinnedNodeEngineMajor}from"../../node-engine.js";import{parseChatGptModelSelection}from"../../../shared/chatgpt-model.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{pathExists,writeTextFile}from"../files.js";import{blockingCreateInPlaceEntries}from"../create-in-place.js";import{resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_APP_TEMPLATE_FILES}from"./web-template.js";import{mkdir,readdir,stat}from"node:fs/promises";import{basename,join,resolve}from"node:path";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,DEFAULT_AI_PACKAGE_VERSION=`^7.0.82`,DEFAULT_CONNECT_PACKAGE_VERSION=`1.0.0`,DEFAULT_ZOD_PACKAGE_VERSION=`4.5.4`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.47.
|
|
1
|
+
import{pinnedNodeEngineMajor}from"../../node-engine.js";import{parseChatGptModelSelection}from"../../../shared/chatgpt-model.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{pathExists,writeTextFile}from"../files.js";import{blockingCreateInPlaceEntries}from"../create-in-place.js";import{resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_APP_TEMPLATE_FILES}from"./web-template.js";import{mkdir,readdir,stat}from"node:fs/promises";import{basename,join,resolve}from"node:path";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,DEFAULT_AI_PACKAGE_VERSION=`^7.0.82`,DEFAULT_CONNECT_PACKAGE_VERSION=`1.0.0`,DEFAULT_ZOD_PACKAGE_VERSION=`4.5.4`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.47.7`,nodeEngine:`>=24`};function resolveEvePackageContract(e=DEFAULT_EVE_PACKAGE_CONTRACT){return{version:resolveVersionToken(`evePackage.version`,e.version),nodeEngine:resolveVersionToken(`evePackage.nodeEngine`,e.nodeEngine)}}function modelProviderSlug(e){let t=(e.split(`/`)[0]??``).replaceAll(/[^A-Za-z0-9._-]/gu,``);return t.length>0?t:`anthropic`}function byokProviderEnvVar(e){let t=modelProviderSlug(e).toUpperCase().replaceAll(/[^A-Z0-9]/gu,`_`);return`${/^[0-9]/.test(t)?`_`:``}${t}_API_KEY`}function agentTemplateFiles(e,t){return{"agent/agent.ts":renderAgentTemplate(e,t),"agent/channels/eve.ts":WEB_APP_TEMPLATE_FILES[`agent/channels/eve.ts`],"agent/instructions.md":AGENT_INSTRUCTIONS_TEMPLATE}}function renderAgentTemplate(e,n){let r=parseChatGptModelSelection(e);return r===void 0?BASE_AGENT_TEMPLATE.replaceAll(`__EVE_INIT_MODEL__`,e).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(n)):`import { defineAgent } from "eve";\nimport { chatgpt } from "eve/models/openai";\n\nexport default defineAgent({\n model: chatgpt(${JSON.stringify(r)}),\n${reasoningTemplateLine(n)}});\n`}function reasoningTemplateLine(e){return e===void 0||e===`provider-default`?``:` reasoning: "${e}",\n`}function renderTemplate(e,n){return e===BASE_AGENT_TEMPLATE&&parseChatGptModelSelection(n.model)!==void 0?renderAgentTemplate(n.model,n.reasoning):e.replaceAll(`__EVE_INIT_APP_NAME__`,n.appName).replaceAll(`__EVE_INIT_MODEL__`,n.model).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(n.reasoning)).replaceAll(`__EVE_INIT_BYOK_PROVIDER__`,modelProviderSlug(n.model)).replaceAll(`__EVE_INIT_BYOK_ENV_VAR__`,byokProviderEnvVar(n.model)).replaceAll(`__EVE_INIT_PACKAGE_VERSION__`,formatEveDependencySpecifier(n.eveVersion)).replaceAll(`__EVE_INIT_AI_SDK_VERSION__`,n.aiPackageVersion).replaceAll(`__EVE_INIT_CONNECT_VERSION__`,n.connectPackageVersion).replaceAll(`__EVE_INIT_ZOD_VERSION__`,n.zodPackageVersion).replaceAll(`__EVE_INIT_TYPESCRIPT_VERSION__`,n.typescriptPackageVersion).replaceAll(`__EVE_INIT_TYPES_NODE_VERSION__`,n.nodeTypesVersion).replaceAll(`__EVE_INIT_NODE_ENGINE__`,n.nodeEngine)}function formatEveDependencySpecifier(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/.test(e)?`^${e}`:e}const BASE_AGENT_TEMPLATE=`import { defineAgent } from "eve";
|
|
2
2
|
|
|
3
3
|
export default defineAgent({
|
|
4
4
|
model: "__EVE_INIT_MODEL__",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { JsonObject } from "#shared/json.js";
|
|
2
|
+
import type { PreparedDispatchTarget } from "#tools/behavior.js";
|
|
3
|
+
/** One model tool call selected for durable execution outside the harness. */
|
|
4
|
+
export interface PendingDispatchAction {
|
|
5
|
+
readonly callId: string;
|
|
6
|
+
readonly description: string;
|
|
7
|
+
readonly input: JsonObject;
|
|
8
|
+
readonly target: PreparedDispatchTarget;
|
|
9
|
+
readonly toolName: string;
|
|
10
|
+
}
|
|
11
|
+
/** Pending action that delegates work to a prepared agent identity. */
|
|
12
|
+
export type PendingAgentDispatchAction = PendingDispatchAction & {
|
|
13
|
+
readonly target: Extract<PreparedDispatchTarget, {
|
|
14
|
+
readonly kind: "remote-agent-call" | "self-agent-call" | "subagent-call";
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
/** Pending action that mutates the durable task lifecycle. */
|
|
18
|
+
export type PendingTaskControlAction = PendingDispatchAction & {
|
|
19
|
+
readonly target: Extract<PreparedDispatchTarget, {
|
|
20
|
+
readonly kind: "task-cancel" | "task-update";
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
/** Fields common to task-control dispatch and its result projection helpers. */
|
|
24
|
+
export type TaskControlInvocation = Pick<PendingDispatchAction, "callId" | "input" | "toolName">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -18,8 +18,8 @@ export declare function createWorkflowSandboxTool(input: {
|
|
|
18
18
|
readonly hostTools: ToolSet;
|
|
19
19
|
}): Promise<ToolSet[string]>;
|
|
20
20
|
export declare function requestWorkflowSandboxInterrupt(input: {
|
|
21
|
+
readonly dispatchTarget: unknown;
|
|
21
22
|
readonly kind: string;
|
|
22
|
-
readonly runtimeAction: unknown;
|
|
23
23
|
readonly toolInput: unknown;
|
|
24
24
|
readonly toolName: string;
|
|
25
25
|
}): Promise<unknown>;
|
package/dist/src/svelte/index.js
CHANGED
package/dist/src/tasks/json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{readSubagentTaskMetadata}from"#tasks/types.js";import{TASK_VIEW_JSON_SCHEMA}from"#tools/framework/task-contract.js";function taskViewToJson(t){let n=readSubagentTaskMetadata(t),r=n===void 0?t.metadata:{agentId:n.agentId,kind:n.kind,mode:n.mode,name:n.name};return TASK_VIEW_JSON_SCHEMA.parse({...t,metadata:r})}function taskViewsToJson(e){return{tasks:e.map(e=>taskViewToJson(e))}}export{taskViewToJson,taskViewsToJson};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { WebSearchProvider } from "#shared/web-search.js";
|
|
2
|
+
/** Session facts that can hide a selected tool without changing source composition. */
|
|
3
|
+
export type ToolAvailabilityCondition = "delegated-task-child" | "requires-request-input" | "root-session";
|
|
4
|
+
/** Native behavior declared by a selected compiled tool. */
|
|
5
|
+
export type CompiledToolHandling = {
|
|
6
|
+
readonly kind: "dispatch";
|
|
7
|
+
readonly action: "self-agent" | "task-cancel" | "task-update";
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: "provider-tool";
|
|
10
|
+
readonly provider: WebSearchProvider;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: "request-input";
|
|
13
|
+
readonly request: "question";
|
|
14
|
+
};
|
|
15
|
+
/** Closed, serializable behavior carried by one selected compiled tool. */
|
|
16
|
+
export interface CompiledToolBehavior {
|
|
17
|
+
readonly availability: readonly ToolAvailabilityCondition[];
|
|
18
|
+
readonly handling?: CompiledToolHandling;
|
|
19
|
+
readonly presentation?: "load-skill";
|
|
20
|
+
}
|
|
21
|
+
/** Concrete dispatch identity prepared before a tool reaches the harness. */
|
|
22
|
+
export type PreparedDispatchTarget = {
|
|
23
|
+
readonly kind: "remote-agent-call";
|
|
24
|
+
readonly nodeId: string;
|
|
25
|
+
readonly remoteAgentName: string;
|
|
26
|
+
} | {
|
|
27
|
+
readonly kind: "self-agent-call";
|
|
28
|
+
readonly nodeId: string;
|
|
29
|
+
readonly subagentName: string;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: "subagent-call";
|
|
32
|
+
readonly nodeId: string;
|
|
33
|
+
readonly subagentName: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "task-cancel";
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "task-update";
|
|
38
|
+
};
|
|
39
|
+
/** Runtime-prepared handling consumed by the harness and execution boundary. */
|
|
40
|
+
export type PreparedToolHandling = {
|
|
41
|
+
readonly kind: "dispatch";
|
|
42
|
+
readonly target: PreparedDispatchTarget;
|
|
43
|
+
} | Extract<CompiledToolHandling, {
|
|
44
|
+
readonly kind: "provider-tool" | "request-input";
|
|
45
|
+
}>;
|
|
46
|
+
/** Runtime-prepared behavior carried by one harness-visible tool. */
|
|
47
|
+
export interface PreparedToolBehavior {
|
|
48
|
+
readonly availability: readonly ToolAvailabilityCondition[];
|
|
49
|
+
readonly handling?: PreparedToolHandling;
|
|
50
|
+
readonly presentation?: CompiledToolBehavior["presentation"];
|
|
51
|
+
}
|
|
52
|
+
/** Attaches internal behavior without adding a public string-keyed definition field. */
|
|
53
|
+
export declare function attachToolBehavior<TDefinition extends object>(definition: TDefinition, behavior: CompiledToolBehavior): TDefinition;
|
|
54
|
+
/** Reads internal behavior from a framework-owned definition. */
|
|
55
|
+
export declare function readToolBehavior(value: unknown): CompiledToolBehavior | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const TOOL_BEHAVIOR=Symbol.for(`eve.tool-behavior`);function attachToolBehavior(e,t){return Object.defineProperty(e,TOOL_BEHAVIOR,{configurable:!1,enumerable:!1,value:t,writable:!1}),e}function readToolBehavior(e){if(!(typeof e!=`object`||!e))return e[TOOL_BEHAVIOR]}export{attachToolBehavior,readToolBehavior};
|
|
@@ -9,6 +9,7 @@ export type DurableDynamicCallbackFn = (closure: JsonObject, ...args: never[]) =
|
|
|
9
9
|
*/
|
|
10
10
|
export interface DurableDynamicCallbackReference {
|
|
11
11
|
readonly closure: JsonObject;
|
|
12
|
+
readonly stepId?: never;
|
|
12
13
|
}
|
|
13
14
|
export interface DurableDynamicToolCallbacks {
|
|
14
15
|
readonly execute: DurableDynamicCallbackReference;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const agent: import("#tools/definition.js").ToolDefinition<{
|
|
1
|
+
export declare const agent: import("#tools/native-definition.js").NativeToolDefinition<{
|
|
3
2
|
agentId?: string | null | undefined;
|
|
4
3
|
message: string;
|
|
5
4
|
outputSchema?: {
|
|
6
5
|
[x: string]: unknown;
|
|
7
6
|
} | undefined;
|
|
8
|
-
},
|
|
9
|
-
execute(input: {
|
|
10
|
-
agentId?: string | null | undefined;
|
|
11
|
-
message: string;
|
|
12
|
-
outputSchema?: {
|
|
13
|
-
[x: string]: unknown;
|
|
14
|
-
} | undefined;
|
|
15
|
-
}, ctx: import("#tools/definition.js").ToolContext): never;
|
|
16
|
-
};
|
|
7
|
+
}, unknown>;
|
|
17
8
|
export default agent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{AGENT_TOOL_DESCRIPTION,SUBAGENT_TOOL_INPUT_SCHEMA}from"#tools/framework/agent-contract.js";import{defineNativeTool}from"#tools/native-definition.js";const agent=defineNativeTool({description:AGENT_TOOL_DESCRIPTION,inputSchema:SUBAGENT_TOOL_INPUT_SCHEMA},{availability:[`root-session`],handling:{action:`self-agent`,kind:`dispatch`}});export{agent,agent as default};
|
|
@@ -21,8 +21,7 @@ export declare const ASK_QUESTION_OUTPUT_SCHEMA: z.ZodObject<{
|
|
|
21
21
|
}>;
|
|
22
22
|
text: z.ZodOptional<z.ZodString>;
|
|
23
23
|
}, z.core.$strict>;
|
|
24
|
-
|
|
25
|
-
export declare const askQuestion: import("#tools/definition.js").ToolDefinition<{
|
|
24
|
+
export declare const askQuestion: import("#tools/native-definition.js").NativeToolDefinition<{
|
|
26
25
|
allowFreeform?: boolean | undefined;
|
|
27
26
|
options?: {
|
|
28
27
|
description?: string | undefined;
|
|
@@ -35,16 +34,5 @@ export declare const askQuestion: import("#tools/definition.js").ToolDefinition<
|
|
|
35
34
|
optionId?: string | undefined;
|
|
36
35
|
status: "answered" | "ignored";
|
|
37
36
|
text?: string | undefined;
|
|
38
|
-
}
|
|
39
|
-
execute(input: {
|
|
40
|
-
allowFreeform?: boolean | undefined;
|
|
41
|
-
options?: {
|
|
42
|
-
description?: string | undefined;
|
|
43
|
-
id: string;
|
|
44
|
-
label: string;
|
|
45
|
-
style?: "danger" | "default" | "primary" | undefined;
|
|
46
|
-
}[] | undefined;
|
|
47
|
-
prompt: string;
|
|
48
|
-
}, ctx: import("#tools/definition.js").ToolContext): never;
|
|
49
|
-
};
|
|
37
|
+
}>;
|
|
50
38
|
export default askQuestion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import{inputRequestSchema}from"#shared/input.js";import{
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{inputRequestSchema}from"#shared/input.js";import{defineNativeTool}from"#tools/native-definition.js";const ASK_QUESTION_INPUT_SCHEMA=inputRequestSchema.omit({action:!0,display:!0,kind:!0,requestId:!0}),ASK_QUESTION_OUTPUT_SCHEMA=z.object({optionId:z.string().optional(),status:z.enum([`answered`,`ignored`]),text:z.string().optional()}).strict(),askQuestion=defineNativeTool({description:`Ask the user a question and wait for their response before continuing. Use this when you need clarification or a choice from the user.`,inputSchema:ASK_QUESTION_INPUT_SCHEMA,outputSchema:ASK_QUESTION_OUTPUT_SCHEMA},{availability:[`requires-request-input`],handling:{kind:`request-input`,request:`question`}});export{ASK_QUESTION_INPUT_SCHEMA,ASK_QUESTION_OUTPUT_SCHEMA,askQuestion,askQuestion as default};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const taskCancel: import("#tools/definition.js").ToolDefinition<{
|
|
1
|
+
export declare const taskCancel: import("#tools/native-definition.js").NativeToolDefinition<{
|
|
3
2
|
taskIds: string[];
|
|
4
3
|
}, {
|
|
5
4
|
tasks: {
|
|
@@ -21,9 +20,5 @@ export declare const taskCancel: import("#tools/definition.js").ToolDefinition<{
|
|
|
21
20
|
status: "cancelled" | "completed" | "failed" | "input_required" | "working";
|
|
22
21
|
taskId: string;
|
|
23
22
|
}[];
|
|
24
|
-
}
|
|
25
|
-
execute(input: {
|
|
26
|
-
taskIds: string[];
|
|
27
|
-
}, ctx: import("#tools/definition.js").ToolContext): never;
|
|
28
|
-
};
|
|
23
|
+
}>;
|
|
29
24
|
export default taskCancel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{TASK_CANCEL_INPUT_SCHEMA,TASK_VIEWS_OUTPUT_SCHEMA}from"#tools/framework/task-contract.js";import{defineNativeTool}from"#tools/native-definition.js";const taskCancel=defineNativeTool({description:`Request cooperative cancellation of one or more background tasks. Cancellation is final: a task that finishes after you cancel it stays cancelled. Cancelling an already-finished task changes nothing.`,inputSchema:TASK_CANCEL_INPUT_SCHEMA,outputSchema:TASK_VIEWS_OUTPUT_SCHEMA},{availability:[`root-session`],handling:{action:`task-cancel`,kind:`dispatch`}});export{taskCancel as default,taskCancel};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { z } from "#compiled/zod/index.js";
|
|
2
2
|
export declare const TASK_CANCEL_TOOL_NAME = "task_cancel";
|
|
3
3
|
export declare const TASK_UPDATE_TOOL_NAME = "task_update";
|
|
4
|
-
/** Transitional PR 1 task-tool names used by the existing dispatch mechanics. */
|
|
5
|
-
export declare const TASK_TOOL_NAMES: ReadonlySet<string>;
|
|
6
4
|
export declare const TASK_CANCEL_INPUT_SCHEMA: z.ZodObject<{
|
|
7
5
|
taskIds: z.ZodArray<z.ZodString>;
|
|
8
6
|
}, z.core.$strict>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import{jsonValueSchema}from"#shared/json-schemas.js";const TASK_CANCEL_TOOL_NAME=`task_cancel`,TASK_UPDATE_TOOL_NAME=`task_update`,
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{jsonValueSchema}from"#shared/json-schemas.js";const TASK_CANCEL_TOOL_NAME=`task_cancel`,TASK_UPDATE_TOOL_NAME=`task_update`,TASK_IDS_SCHEMA=z.array(z.string().min(1)).min(1).describe(`Task ids from earlier subagent task receipts.`),TASK_CANCEL_INPUT_SCHEMA=z.strictObject({taskIds:TASK_IDS_SCHEMA}),TASK_UPDATE_INPUT_SCHEMA=z.strictObject({message:z.string().min(1).describe(`Brief description of what this task is currently doing.`)}),taskMetadataJsonSchema=z.union([z.object({agentId:z.string(),kind:z.literal(`subagent`),mode:z.enum([`local`,`remote`]),name:z.string()}),z.object({kind:z.string(),name:z.string()})]),taskOutputJsonSchema=z.object({data:jsonValueSchema,type:z.enum([`result`,`error`])}),taskViewJsonBaseShape={metadata:taskMetadataJsonSchema,taskId:z.string()},TASK_VIEW_JSON_SCHEMA=z.discriminatedUnion(`status`,[z.object({...taskViewJsonBaseShape,status:z.literal(`working`)}),z.object({...taskViewJsonBaseShape,inputRequests:z.array(jsonValueSchema).readonly(),status:z.literal(`input_required`)}),z.object({...taskViewJsonBaseShape,lastOutput:taskOutputJsonSchema.extend({type:z.literal(`result`)}),status:z.literal(`completed`)}),z.object({...taskViewJsonBaseShape,lastOutput:taskOutputJsonSchema.extend({type:z.literal(`error`)}),status:z.literal(`failed`)}),z.object({...taskViewJsonBaseShape,status:z.literal(`cancelled`)})]),TASK_VIEW_OUTPUT_SCHEMA=z.object({inputRequests:z.array(z.unknown()).optional(),lastOutput:z.object({data:z.unknown(),type:z.enum([`result`,`error`])}).optional(),metadata:z.union([z.object({agentId:z.string(),kind:z.literal(`subagent`),mode:z.enum([`local`,`remote`]),name:z.string()}),z.object({data:z.record(z.string(),z.unknown()).optional(),kind:z.string(),name:z.string()})]),status:z.enum([`working`,`input_required`,`completed`,`failed`,`cancelled`]),taskId:z.string()}),TASK_VIEWS_OUTPUT_SCHEMA=z.object({tasks:z.array(TASK_VIEW_OUTPUT_SCHEMA)}),SUBAGENT_TASK_RECEIPT_OUTPUT_SCHEMA=z.strictObject({agentId:z.string(),status:z.literal(`working`),taskId:z.string()});export{SUBAGENT_TASK_RECEIPT_OUTPUT_SCHEMA,TASK_CANCEL_INPUT_SCHEMA,TASK_CANCEL_TOOL_NAME,TASK_UPDATE_INPUT_SCHEMA,TASK_UPDATE_TOOL_NAME,TASK_VIEWS_OUTPUT_SCHEMA,TASK_VIEW_JSON_SCHEMA,TASK_VIEW_OUTPUT_SCHEMA};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const taskUpdate: import("#tools/definition.js").ToolDefinition<{
|
|
1
|
+
export declare const taskUpdate: import("#tools/native-definition.js").NativeToolDefinition<{
|
|
3
2
|
message: string;
|
|
4
|
-
},
|
|
5
|
-
execute(input: {
|
|
6
|
-
message: string;
|
|
7
|
-
}, ctx: import("#tools/definition.js").ToolContext): never;
|
|
8
|
-
};
|
|
3
|
+
}, unknown>;
|
|
9
4
|
export default taskUpdate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{TASK_UPDATE_INPUT_SCHEMA}from"#tools/framework/task-contract.js";import{defineNativeTool}from"#tools/native-definition.js";const taskUpdate=defineNativeTool({description:`Briefly tell the parent agent what this background task is currently doing. Report activity, not preliminary findings or results.`,inputSchema:TASK_UPDATE_INPUT_SCHEMA},{availability:[`delegated-task-child`],handling:{action:`task-update`,kind:`dispatch`}});export{taskUpdate as default,taskUpdate};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PublicToolDefinition } from "#tools/definition.js";
|
|
2
|
+
import { type CompiledToolBehavior } from "#tools/behavior.js";
|
|
3
|
+
/** Framework-only tool definition whose implementation is owned outside an executor. */
|
|
4
|
+
export type NativeToolDefinition<TInput = unknown, TOutput = unknown> = PublicToolDefinition<TInput, TOutput>;
|
|
5
|
+
/** Defines an execute-less framework tool with closed internal behavior. */
|
|
6
|
+
export declare function defineNativeTool<TInput = unknown, TOutput = unknown>(definition: NativeToolDefinition<TInput, TOutput>, behavior: CompiledToolBehavior): NativeToolDefinition<TInput, TOutput>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{attachToolBehavior}from"#tools/behavior.js";function defineNativeTool(e,t){return attachToolBehavior(e,t)}export{defineNativeTool};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineTool}from"#tools/definition.js";import{SKILL_INPUT_SCHEMA,SKILL_OUTPUT_SCHEMA,executeLoadSkill}from"#execution/tools/load-skill.js";const loadSkill=defineTool({description:[`Load the full instructions for one available skill by name or id.`,`Use this tool when the request clearly matches a listed skill description or when the user explicitly asks for that skill.`,`Loading adds the skill instructions to the current turn.`,`Choose the "skill" value from the Available skills block.`].join(` `),execute:executeLoadSkill,inputSchema:SKILL_INPUT_SCHEMA,outputSchema:SKILL_OUTPUT_SCHEMA});export{loadSkill as default,loadSkill};
|
|
1
|
+
import{defineTool}from"#tools/definition.js";import{attachToolBehavior}from"#tools/behavior.js";import{SKILL_INPUT_SCHEMA,SKILL_OUTPUT_SCHEMA,executeLoadSkill}from"#execution/tools/load-skill.js";const loadSkill=attachToolBehavior(defineTool({description:[`Load the full instructions for one available skill by name or id.`,`Use this tool when the request clearly matches a listed skill description or when the user explicitly asks for that skill.`,`Loading adds the skill instructions to the current turn.`,`Choose the "skill" value from the Available skills block.`].join(` `),execute:executeLoadSkill,inputSchema:SKILL_INPUT_SCHEMA,outputSchema:SKILL_OUTPUT_SCHEMA}),{availability:[],presentation:`load-skill`});export{loadSkill as default,loadSkill};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizeChannelAudience}from"#shared/channel-audience.js";import{ROOT_CONTEXT,SpanStatusCode,trace}from"#compiled/@opentelemetry/api/index.js";import{contentAttribute}from"#tracing/agent-otel-content.js";function createAgentApprovalInstrumentation(n){return{"input.requested":async(t,r)=>{if(t.kind!==`tool-approval`||readState(r.state.get())!==void 0)return;let a=await n.actionContextFor(t.scope.sessionId,t.scope.turnId,t.action.callId);if(a===void 0)return;let o={actionCallId:t.action.callId,actionName:t.action.name,attemptIndex:t.scope.attemptIndex,channelAudience:normalizeChannelAudience(t.scope.channelAudience),parent:{spanId:a.spanContext.spanId,traceFlags:a.spanContext.traceFlags,traceId:a.spanContext.traceId},requestId:t.requestId,rootSessionId:t.scope.rootSessionId??t.scope.sessionId,sessionId:t.scope.sessionId,startTimeMs:Date.now(),stepIndex:t.scope.stepIndex,turnId:t.scope.turnId},s=contentAttribute(t.request,!1);s!==void 0&&(o.requestAttribute=s),r.state.set(o)},"input.resolved":(e,
|
|
1
|
+
import{normalizeChannelAudience}from"#shared/channel-audience.js";import{ROOT_CONTEXT,SpanStatusCode,trace}from"#compiled/@opentelemetry/api/index.js";import{contentAttribute}from"#tracing/agent-otel-content.js";import{withChannelAudience}from"#tracing/channel-audience-context.js";function createAgentApprovalInstrumentation(n){return{"input.requested":async(t,r)=>{if(t.kind!==`tool-approval`||readState(r.state.get())!==void 0)return;let a=await n.actionContextFor(t.scope.sessionId,t.scope.turnId,t.action.callId);if(a===void 0)return;let o={actionCallId:t.action.callId,actionName:t.action.name,attemptIndex:t.scope.attemptIndex,channelAudience:normalizeChannelAudience(t.scope.channelAudience),parent:{spanId:a.spanContext.spanId,traceFlags:a.spanContext.traceFlags,traceId:a.spanContext.traceId},requestId:t.requestId,rootSessionId:t.scope.rootSessionId??t.scope.sessionId,sessionId:t.scope.sessionId,startTimeMs:Date.now(),stepIndex:t.scope.stepIndex,turnId:t.scope.turnId},s=contentAttribute(t.request,!1);s!==void 0&&(o.requestAttribute=s),r.state.set(o)},"input.resolved":(e,o)=>{let s=readState(o.state.get());if(s===void 0)return;let c=n.idGenerator.withSpanId(n.idGenerator.deriveSpanId(`approval:${e.idempotencyKey}`),()=>n.tracer.startSpan(`agent.approval`,{attributes:{"agent.action.call_id":s.actionCallId,"agent.action.name":s.actionName,"agent.approval.kind":`tool-approval`,"agent.approval.outcome":e.outcome,"agent.approval.request_id":s.requestId,"agent.framework.name":`eve`,"agent.framework.version":n.frameworkVersion,"agent.session.id":s.sessionId,"agent.step.attempt":s.attemptIndex,"agent.step.index":s.stepIndex,"agent.turn.id":s.turnId},startTime:s.startTimeMs},withChannelAudience(trace.setSpan(ROOT_CONTEXT,trace.wrapSpanContext({...s.parent,isRemote:!1})),s.channelAudience)));if(s.requestAttribute!==void 0&&c.setAttribute(`agent.approval.request`,s.requestAttribute),e.response!==void 0){let t=contentAttribute(e.response,!1);t!==void 0&&c.setAttribute(`agent.approval.response`,t)}e.outcome===`failed`&&recordError(c,e.error),c.end()}}}function readState(t){if(typeof t!=`object`||!t||Array.isArray(t))return;let n=t,r=n.parent;if(typeof r!=`object`||!r||Array.isArray(r))return;let i=r;if(typeof n.actionCallId!=`string`||typeof n.actionName!=`string`||typeof n.attemptIndex!=`number`||typeof i.spanId!=`string`||typeof i.traceFlags!=`number`||typeof i.traceId!=`string`||typeof n.requestId!=`string`||typeof n.rootSessionId!=`string`||typeof n.sessionId!=`string`||typeof n.startTimeMs!=`number`||typeof n.stepIndex!=`number`||typeof n.turnId!=`string`)return;let a=n.requestAttribute;if(!(a!==void 0&&typeof a!=`string`))return{actionCallId:n.actionCallId,actionName:n.actionName,attemptIndex:n.attemptIndex,channelAudience:normalizeChannelAudience(n.channelAudience),parent:{isRemote:!1,spanId:i.spanId,traceFlags:i.traceFlags,traceId:i.traceId},requestAttribute:a,requestId:n.requestId,rootSessionId:n.rootSessionId,sessionId:n.sessionId,startTimeMs:n.startTimeMs,stepIndex:n.stepIndex,turnId:n.turnId}}function recordError(e,t){t instanceof Error?(e.recordException(t),e.setStatus({code:SpanStatusCode.ERROR,message:t.message})):e.setStatus({code:SpanStatusCode.ERROR})}export{createAgentApprovalInstrumentation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizeChannelAudience}from"#shared/channel-audience.js";import{isSampledTrace}from"#tracing/sampled-trace.js";import{ROOT_CONTEXT,SpanKind,SpanStatusCode,trace}from"#compiled/@opentelemetry/api/index.js";import{sessionIdempotencyKey}from"#instrumentation/lifecycle.js";import{contentAttribute}from"#tracing/agent-otel-content.js";function createAgentChannelDeliveryInstrumentation(n){let onStarted=async(r,i)=>{let a=await n.ensureSessionContext({agentName:r.agentName,channelAudience:r.delivery.channelAudience,channelKind:r.delivery.channelKind,idempotencyKey:sessionIdempotencyKey(r.sessionId),parentTraceContext:r.parentTraceContext,rootSessionId:r.rootSessionId,sessionId:r.sessionId,traceSeed:r.traceSeed,type:`session.started`});if(!isSampledTrace(a.context))return;let c=n.recordInputs?contentAttribute(r.input,!1):void 0,l={channelAudience:normalizeChannelAudience(r.delivery.channelAudience),parent:{isRemote:a.context.isRemote??!1,spanId:a.context.spanId,traceFlags:a.context.traceFlags,traceId:a.context.traceId},spanId:n.idGenerator.deriveSpanId(`channel-delivery:${r.idempotencyKey}`),startTimeMs:Date.now()};c!==void 0&&(l.inputAttribute=c),r.delivery.requestTraceContext!==void 0&&(l.requestTraceContext={spanId:r.delivery.requestTraceContext.spanId,traceFlags:r.delivery.requestTraceContext.traceFlags,traceId:r.delivery.requestTraceContext.traceId}),i.state.set(l)},onTerminal=async(e,t)=>{let i=readState(t.state.get());if(i===void 0)return;let a=e.turnId===void 0?void 0:await n.stateStore.getTurn(e.sessionId,e.turnId),o=a===void 0?i.startTimeMs:Math.max(i.startTimeMs,a.startTimeMs),s=i.requestTraceContext,
|
|
1
|
+
import{normalizeChannelAudience}from"#shared/channel-audience.js";import{isSampledTrace}from"#tracing/sampled-trace.js";import{ROOT_CONTEXT,SpanKind,SpanStatusCode,trace}from"#compiled/@opentelemetry/api/index.js";import{sessionIdempotencyKey}from"#instrumentation/lifecycle.js";import{contentAttribute}from"#tracing/agent-otel-content.js";import{withChannelAudience}from"#tracing/channel-audience-context.js";function createAgentChannelDeliveryInstrumentation(n){let onStarted=async(r,i)=>{let a=await n.ensureSessionContext({agentName:r.agentName,channelAudience:r.delivery.channelAudience,channelKind:r.delivery.channelKind,idempotencyKey:sessionIdempotencyKey(r.sessionId),parentTraceContext:r.parentTraceContext,rootSessionId:r.rootSessionId,sessionId:r.sessionId,traceSeed:r.traceSeed,type:`session.started`});if(!isSampledTrace(a.context))return;let c=n.recordInputs?contentAttribute(r.input,!1):void 0,l={channelAudience:normalizeChannelAudience(r.delivery.channelAudience),parent:{isRemote:a.context.isRemote??!1,spanId:a.context.spanId,traceFlags:a.context.traceFlags,traceId:a.context.traceId},spanId:n.idGenerator.deriveSpanId(`channel-delivery:${r.idempotencyKey}`),startTimeMs:Date.now()};c!==void 0&&(l.inputAttribute=c),r.delivery.requestTraceContext!==void 0&&(l.requestTraceContext={spanId:r.delivery.requestTraceContext.spanId,traceFlags:r.delivery.requestTraceContext.traceFlags,traceId:r.delivery.requestTraceContext.traceId}),i.state.set(l)},onTerminal=async(e,t)=>{let i=readState(t.state.get());if(i===void 0)return;let a=e.turnId===void 0?void 0:await n.stateStore.getTurn(e.sessionId,e.turnId),o=a===void 0?i.startTimeMs:Math.max(i.startTimeMs,a.startTimeMs),s=i.requestTraceContext,l=n.idGenerator.withSpanId(i.spanId,()=>n.tracer.startSpan(`agent.channel.delivery`,{attributes:{"agent.channel.delivery.id":e.delivery.deliveryId,"agent.channel.delivery.outcome":e.outcome,"agent.channel.kind":e.delivery.channelKind,"agent.channel.name":e.delivery.channelName,"agent.channel.request.id":e.delivery.requestId,"agent.framework.name":`eve`,"agent.framework.version":n.frameworkVersion,"agent.name":e.agentName,"agent.session.id":e.sessionId,"agent.turn.id":e.turnId,"agent.turn.sequence":e.sequence},kind:SpanKind.CONSUMER,links:s===void 0?void 0:[{attributes:{"eve.link.type":`channel.request`},context:s}],startTime:o},withChannelAudience(contextFromSpanContext(i.parent),i.channelAudience)));if(l.addEvent(`channel.delivery.started`,void 0,o),l.addEvent(e.type),i.inputAttribute!==void 0&&l.setAttribute(`agent.channel.delivery.input`,i.inputAttribute),e.outcome===`failed`){let t=e.errorCode??(e.error instanceof Error?e.error.name:`Error`);l.setAttribute(`error.type`,t),e.errorCode!==void 0&&l.setAttribute(`agent.channel.delivery.error.code`,e.errorCode),recordError(l,e.error)}l.end(),a!==void 0&&e.turnId!==void 0&&a.parentSpanId===i.parent.spanId&&a.context.traceId===i.parent.traceId&&await n.stateStore.updateTurn(e.sessionId,e.turnId,e=>e.parentSpanId===i.parent.spanId&&e.context.traceId===i.parent.traceId?{...e,parentIsRemote:!1,parentSpanId:i.spanId}:e)};return{"channel.delivery.cancelled":onTerminal,"channel.delivery.completed":onTerminal,"channel.delivery.failed":onTerminal,"channel.delivery.started":onStarted}}function readState(t){if(!isRecord(t)||!isSpanContext(t.parent)||typeof t.spanId!=`string`||typeof t.startTimeMs!=`number`)return;let n=isSpanContext(t.requestTraceContext)?t.requestTraceContext:void 0;return{channelAudience:normalizeChannelAudience(t.channelAudience),inputAttribute:typeof t.inputAttribute==`string`?t.inputAttribute:void 0,parent:t.parent,requestTraceContext:n,spanId:t.spanId,startTimeMs:t.startTimeMs}}function isSpanContext(e){return isRecord(e)&&typeof e.spanId==`string`&&typeof e.traceFlags==`number`&&typeof e.traceId==`string`}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function contextFromSpanContext(e){return trace.setSpan(ROOT_CONTEXT,trace.wrapSpanContext(e))}function recordError(e,t){t instanceof Error?(e.recordException(t),e.setStatus({code:SpanStatusCode.ERROR,message:t.message})):e.setStatus({code:SpanStatusCode.ERROR})}export{createAgentChannelDeliveryInstrumentation};
|