eve 0.72.0 → 0.72.1

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # eve
2
2
 
3
+ ## 0.72.1
4
+
5
+ ### Patch Changes
6
+
7
+ - c230e94: MCP connections now ask the user to sign in only when the server asks for it. When a connection has `auth` but no token yet, eve connects without an `Authorization` header, so servers that allow anonymous `initialize` and `tools/list` have their tools listed by `connection_search` and run by `connection_execute` with no prompt. Sign-in starts when a call returns HTTP `401` or an error result with a `_meta["mcp/www_authenticate"]` challenge, and the call runs again with the token once the user signs in. Servers that reject every request without a token behave as before, and connections that already have a token are unchanged.
8
+ - e3c509f: `mockModel` responders see tool-result files again as `{ type: "file", data: { type: "data", data } }` parts in `toolResults[].output`. Since `ai@7.0.116`, they had received legacy `file-data` parts, so a scripted model that looked for an image from `toModelOutput` could miss it and keep calling the tool.
9
+
3
10
  ## 0.72.0
4
11
 
5
12
  ### Minor Changes
@@ -57,7 +57,7 @@
57
57
  "zod": "4.5.4",
58
58
  "zod-validation-error": "5.0.0"
59
59
  },
60
- "scriptHash": "e971a4272f96b82cd99d812a11a7721348e8d735f3f6d7508c93a860efccbc2d",
60
+ "scriptHash": "16b872c25e03df81bec4c645ab2674309f3188f3aae692fe7b7ee6d5ad0ac614",
61
61
  "toolVersions": {
62
62
  "rolldown": "1.2.9",
63
63
  "typescript": "7.0.2"
@@ -1 +1 @@
1
- import{markMockModel}from"#internal/mock-model-identity.js";import{MockLanguageModelV3}from"ai/test";import{TASKS_NOTE_LABEL,TASK_RESULT_TAG}from"#execution/tasks/render.js";import{isPendingApprovalsSnippet}from"#harness/hitl/approval-prompt.js";const RESPONSE_TIMESTAMP=Date.parse(`2026-01-01T00:00:00.000Z`);function mockModel(e={}){let t=normalizeOptions(e),n=normalizeResponder(t.respond),r=t.modelId??`model`;return markMockModel(new MockLanguageModelV3({modelId:r,provider:t.provider??`eve-mock`,doGenerate:async e=>createGenerateResult(await n(createRequest(e)),e,r),doStream:async e=>createStreamResult(createGenerateResult(await n(createRequest(e)),e,r))}))}function normalizeOptions(e){return typeof e==`string`||typeof e==`function`?{respond:e}:e}function normalizeResponder(e){if(typeof e==`function`)return e;let t=e??`Mock response`;return()=>t}function createRequest(e){let t=e.prompt.map(e=>({role:e.role,text:extractMessageText(e)})),n=t.filter(e=>e.role===`user`).map(e=>e.text).filter(e=>!isFrameworkScaffolding(e));return{lastUserMessage:n.at(-1)??null,messages:t,toolResults:extractToolResults(e),tools:extractTools(e),userMessageCount:n.length,userMessages:n}}function isFrameworkScaffolding(e){let t=e.trim();return t.startsWith(TASKS_NOTE_LABEL)||t.startsWith(TASK_RESULT_TAG)||isPendingApprovalsSnippet(t)}function extractMessageText(e){return typeof e.content==`string`?e.content:e.content.flatMap(e=>{switch(e.type){case`reasoning`:case`text`:return[e.text];case`tool-result`:return[formatValue(normalizeToolOutput(e.output))];default:return[]}}).join(``)}function extractTools(e){return(e.tools??[]).map(e=>e.type===`function`?{description:e.description,inputSchema:e.inputSchema,name:e.name}:{name:e.name})}function extractToolResults(e){return e.prompt.flatMap(e=>typeof e.content==`string`?[]:e.content.flatMap(e=>e.type===`tool-result`?[{id:e.toolCallId,isError:e.output.type===`error-json`||e.output.type===`error-text`||e.output.type===`execution-denied`,name:e.toolName,output:normalizeToolOutput(e.output)}]:[]))}function normalizeToolOutput(e){switch(e.type){case`error-json`:case`error-text`:case`json`:case`text`:return e.value;case`execution-denied`:return e.reason??`Tool execution denied`;case`content`:return e.value}}function createGenerateResult(e,t,n){let r=typeof e==`string`?{text:e}:e,i=r.toolCalls??[];if(!(`text`in r)&&i.length===0)throw Error(`mockModel responders must return text or at least one item in "toolCalls".`);let a=[];r.text!==void 0&&a.push({text:r.text,type:`text`});for(let[e,n]of i.entries())a.push({input:JSON.stringify(n.input??{}),toolCallId:n.id??`mock-tool-call-${countUserMessages(t)}-${countToolResults(t)}-${e+1}`,toolName:n.name,type:`tool-call`});let o=t.prompt.map(e=>extractMessageText(e)).join(` `),s=[r.text??``,...i.map(e=>formatValue(e.input??{}))].join(` `),c=r.usage?.inputTokens??estimateTokens(o),l=r.usage?.outputTokens??estimateTokens(s);return{content:a,finishReason:{raw:void 0,unified:i.length>0?`tool-calls`:`stop`},response:{id:`mock-response-${countUserMessages(t)}-${countToolResults(t)}`,modelId:n,timestamp:new Date(RESPONSE_TIMESTAMP)},usage:{inputTokens:{cacheRead:0,cacheWrite:0,noCache:c,total:c},outputTokens:{reasoning:0,text:l,total:l}},warnings:[]}}function createStreamResult(e){let t=[{type:`stream-start`,warnings:e.warnings}];e.response!==void 0&&t.push({...e.response,type:`response-metadata`});let n=0;for(let r of e.content){if(r.type===`text`){let e=`mock-text-${n}`;n+=1,t.push({id:e,type:`text-start`}),r.text.length>0&&t.push({delta:r.text,id:e,type:`text-delta`}),t.push({id:e,type:`text-end`});continue}r.type===`tool-call`&&t.push(r)}return t.push({finishReason:e.finishReason,type:`finish`,usage:e.usage}),{stream:new ReadableStream({start(e){for(let n of t)e.enqueue(n);e.close()}})}}function countUserMessages(e){return e.prompt.filter(e=>e.role===`user`).length}function countToolResults(e){return extractToolResults(e).length}function estimateTokens(e){return Math.max(1,Math.ceil(e.trim().length/4))}function formatValue(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}export{mockModel};
1
+ import{markMockModel}from"#internal/mock-model-identity.js";import{MockLanguageModelV4}from"ai/test";import{TASKS_NOTE_LABEL,TASK_RESULT_TAG}from"#execution/tasks/render.js";import{isPendingApprovalsSnippet}from"#harness/hitl/approval-prompt.js";const RESPONSE_TIMESTAMP=Date.parse(`2026-01-01T00:00:00.000Z`);function mockModel(e={}){let t=normalizeOptions(e),n=normalizeResponder(t.respond),r=t.modelId??`model`;return markMockModel(new MockLanguageModelV4({modelId:r,provider:t.provider??`eve-mock`,doGenerate:async e=>createGenerateResult(await n(createRequest(e)),e,r),doStream:async e=>createStreamResult(createGenerateResult(await n(createRequest(e)),e,r))}))}function normalizeOptions(e){return typeof e==`string`||typeof e==`function`?{respond:e}:e}function normalizeResponder(e){if(typeof e==`function`)return e;let t=e??`Mock response`;return()=>t}function createRequest(e){let t=e.prompt.map(e=>({role:e.role,text:extractMessageText(e)})),n=t.filter(e=>e.role===`user`).map(e=>e.text).filter(e=>!isFrameworkScaffolding(e));return{lastUserMessage:n.at(-1)??null,messages:t,toolResults:extractToolResults(e),tools:extractTools(e),userMessageCount:n.length,userMessages:n}}function isFrameworkScaffolding(e){let t=e.trim();return t.startsWith(TASKS_NOTE_LABEL)||t.startsWith(TASK_RESULT_TAG)||isPendingApprovalsSnippet(t)}function extractMessageText(e){return typeof e.content==`string`?e.content:e.content.flatMap(e=>{switch(e.type){case`reasoning`:case`text`:return[e.text];case`tool-result`:return[formatValue(normalizeToolOutput(e.output))];default:return[]}}).join(``)}function extractTools(e){return(e.tools??[]).map(e=>e.type===`function`?{description:e.description,inputSchema:e.inputSchema,name:e.name}:{name:e.name})}function extractToolResults(e){return e.prompt.flatMap(e=>typeof e.content==`string`?[]:e.content.flatMap(e=>e.type===`tool-result`?[{id:e.toolCallId,isError:e.output.type===`error-json`||e.output.type===`error-text`||e.output.type===`execution-denied`,name:e.toolName,output:normalizeToolOutput(e.output)}]:[]))}function normalizeToolOutput(e){switch(e.type){case`error-json`:case`error-text`:case`json`:case`text`:return e.value;case`execution-denied`:return e.reason??`Tool execution denied`;case`content`:return e.value}}function createGenerateResult(e,t,n){let r=typeof e==`string`?{text:e}:e,i=r.toolCalls??[];if(!(`text`in r)&&i.length===0)throw Error(`mockModel responders must return text or at least one item in "toolCalls".`);let a=[];r.text!==void 0&&a.push({text:r.text,type:`text`});for(let[e,n]of i.entries())a.push({input:JSON.stringify(n.input??{}),toolCallId:n.id??`mock-tool-call-${countUserMessages(t)}-${countToolResults(t)}-${e+1}`,toolName:n.name,type:`tool-call`});let o=t.prompt.map(e=>extractMessageText(e)).join(` `),s=[r.text??``,...i.map(e=>formatValue(e.input??{}))].join(` `),c=r.usage?.inputTokens??estimateTokens(o),l=r.usage?.outputTokens??estimateTokens(s);return{content:a,finishReason:{raw:void 0,unified:i.length>0?`tool-calls`:`stop`},response:{id:`mock-response-${countUserMessages(t)}-${countToolResults(t)}`,modelId:n,timestamp:new Date(RESPONSE_TIMESTAMP)},usage:{inputTokens:{cacheRead:0,cacheWrite:0,noCache:c,total:c},outputTokens:{reasoning:0,text:l,total:l}},warnings:[]}}function createStreamResult(e){let t=[{type:`stream-start`,warnings:e.warnings}];e.response!==void 0&&t.push({...e.response,type:`response-metadata`});let n=0;for(let r of e.content){if(r.type===`text`){let e=`mock-text-${n}`;n+=1,t.push({id:e,type:`text-start`}),r.text.length>0&&t.push({delta:r.text,id:e,type:`text-delta`}),t.push({id:e,type:`text-end`});continue}r.type===`tool-call`&&t.push(r)}return t.push({finishReason:e.finishReason,type:`finish`,usage:e.usage}),{stream:new ReadableStream({start(e){for(let n of t)e.enqueue(n);e.close()}})}}function countUserMessages(e){return e.prompt.filter(e=>e.role===`user`).length}function countToolResults(e){return extractToolResults(e).length}function estimateTokens(e){return Math.max(1,Math.ceil(e.trim().length/4))}function formatValue(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}export{mockModel};
@@ -1 +1 @@
1
- import{runJsProgram}from"#execution/dynamic-workflow/workflow.js";async function runWorkflowProgramTask(e,t){"use workflow";return runJsProgram(e.js,t,{maxSubagents:e.maxSubagents??0})}runWorkflowProgramTask.workflowId=`workflow//eve@0.72.0//runWorkflowProgramTask`;export{runWorkflowProgramTask};
1
+ import{runJsProgram}from"#execution/dynamic-workflow/workflow.js";async function runWorkflowProgramTask(e,t){"use workflow";return runJsProgram(e.js,t,{maxSubagents:e.maxSubagents??0})}runWorkflowProgramTask.workflowId=`workflow//eve@0.72.1//runWorkflowProgramTask`;export{runWorkflowProgramTask};
@@ -1 +1 @@
1
- import{decide}from"#ai/decide.js";async function runAgentRouterTask(e,t){"use workflow";let n=await chooseTarget(e.message,descriptions(t),t.abortSignal),{message:r,status:i}=await(await t.agent(n).send(e.message,{signal:t.abortSignal})).result();if(i===`failed`)throw Error(`Agent "${n}" failed to handle the task.`);return r??null}async function chooseTarget(e,t,n){"use step";let r=Object.keys(t);if(r.length===0)throw Error(`agentRouter requires at least one available agent with a description.`);return r.length===1?r[0]:(await decide({abortSignal:n,state:{message:e},questions:{route:{type:`choice`,instructions:`Which subagent should handle this task?`,criteria:t}}})).answers.route.choice}function descriptions(e){return Object.fromEntries(Object.entries(e.agents).flatMap(([e,t])=>{let n=t.description.trim();return n.length===0?[]:[[e,n]]}))}runAgentRouterTask.workflowId=`workflow//eve@0.72.0//runAgentRouterTask`;export{runAgentRouterTask};
1
+ import{decide}from"#ai/decide.js";async function runAgentRouterTask(e,t){"use workflow";let n=await chooseTarget(e.message,descriptions(t),t.abortSignal),{message:r,status:i}=await(await t.agent(n).send(e.message,{signal:t.abortSignal})).result();if(i===`failed`)throw Error(`Agent "${n}" failed to handle the task.`);return r??null}async function chooseTarget(e,t,n){"use step";let r=Object.keys(t);if(r.length===0)throw Error(`agentRouter requires at least one available agent with a description.`);return r.length===1?r[0]:(await decide({abortSignal:n,state:{message:e},questions:{route:{type:`choice`,instructions:`Which subagent should handle this task?`,criteria:t}}})).answers.route.choice}function descriptions(e){return Object.fromEntries(Object.entries(e.agents).flatMap(([e,t])=>{let n=t.description.trim();return n.length===0?[]:[[e,n]]}))}runAgentRouterTask.workflowId=`workflow//eve@0.72.1//runAgentRouterTask`;export{runAgentRouterTask};
@@ -1,2 +1,2 @@
1
1
  import{CONNECTION_EXECUTE_TOOL_NAME,findConnection,qualifiedToolName,readExecuteTarget,toolCallDisplayName}from"./connection-target.js";import{connectionExecuteApproval,releaseApprovalPin}from"./connection-approval.js";import{closestToolNames,rankConnectionTools}from"./connection-search-rank.js";import{createLogger}from"#internal/logging.js";import{isObject}from"#shared/guards.js";import{loadContext}from"#context/container.js";import{displayProperName}from"#shared/display-name.js";import{toErrorMessage}from"#shared/errors.js";import{defineJsonSchema}from"#tools/schema.js";import{defineDurableCallback}from"#tools/durable-callbacks.js";import{ConnectionRegistryKey}from"#context/providers/connection-key.js";import{frameworkTool}from"#tools/provided/framework-tool.js";import{isConnectionAuthorizationFailedError,isConnectionAuthorizationRequiredError}from"#connections/errors.js";import{getAuthorizationResults}from"#harness/authorization.js";import{createAuthorizationExecution}from"#runtime/connections/scoped-authorization.js";import{reportNestedToolAction}from"#harness/nested-actions.js";import{resolveConnectionAuthorization}from"#runtime/connections/resolve-authorization.js";import{connectionToolModelOutput,toConnectionToolResult}from"#runtime/connections/tool-result.js";import{renderToolSignature}from"#runtime/connections/tool-signature.js";import{supportsInteractiveAuthorization}from"#shared/connection-types.js";import{defineTool}from"#tools/definition.js";const log=createLogger(`framework.connection-tools`),CONNECTION_SEARCH_TOOL_NAME=`connection_search`,CONNECTION_SEARCH_DESCRIPTION=[`Find tools in your connected services (MCP servers and OpenAPI APIs).`,`Returns each matching tool's connection, name, description, and TypeScript signature.`,"Omit `query` to list a connection's tools. Call a found tool with connection_execute.","Connections the user has not signed in to are listed under `unavailable` with `requiresSignIn`;","when the request needs one, search it again with `connection` and `signIn: true` to ask the user to sign in.",`Prefer connected services over web search or general knowledge when a request relates to them.`].join(` `),CONNECTION_EXECUTE_DESCRIPTION=[`Call one tool from a connected service and return its result.`,"Use the exact `connection` and `tool` names returned by connection_search,","and pass `input` matching the tool's signature."].join(` `),CONNECTION_SEARCH_INPUT_SCHEMA={type:`object`,properties:{query:{type:`string`,description:`Words describing the capability, such as 'list open issues'. Omit to list every tool.`},connection:{type:`string`,description:`Only search this connection.`},signIn:{type:`boolean`,description:"Ask the user to sign in to `connection` first, then search it. Requires `connection`. Use only for a connection listed with `requiresSignIn` that the request needs."},limit:{type:`integer`,minimum:1,maximum:50,description:`Maximum results. Defaults to 10.`},offset:{type:`integer`,minimum:0,description:`Results to skip, for paging.`}},additionalProperties:!1},CONNECTION_EXECUTE_INPUT_SCHEMA={type:`object`,properties:{connection:{type:`string`,description:`Connection name from connection_search.`},tool:{type:`string`,description:`Tool name from connection_search.`},input:{type:`object`,description:`Arguments matching the tool's signature. Defaults to {}.`}},required:[`connection`,`tool`],additionalProperties:!1};function resolveConnectionTools(){let e=loadContext().get(ConnectionRegistryKey);if(e===void 0)return null;let t=e.getConnections().map(t=>e.getConnectionApproval(t.connectionName)).filter(e=>e!==void 0);return{[CONNECTION_SEARCH_TOOL_NAME]:frameworkTool(defineTool({description:CONNECTION_SEARCH_DESCRIPTION,inputSchema:CONNECTION_SEARCH_INPUT_SCHEMA,execute:defineDurableCallback({callback:searchConnectionTools,closure:{}}),label:{start:defineDurableCallback({callback:connectionSearchLabel,closure:{}})}})),[CONNECTION_EXECUTE_TOOL_NAME]:frameworkTool(defineTool({description:CONNECTION_EXECUTE_DESCRIPTION,inputSchema:CONNECTION_EXECUTE_INPUT_SCHEMA,execute:defineDurableCallback({callback:executeConnectionTool,closure:{}}),label:{start:defineDurableCallback({callback:connectionToolLabel,closure:{}})},toModelOutput:defineDurableCallback({callback:(e,t)=>connectionToolModelOutput(t),closure:{}}),...connectionExecuteApproval(t)}))}}function connectionToolLabel(e,t){return toolCallDisplayName(CONNECTION_EXECUTE_TOOL_NAME,t)}function connectionSearchLabel(e,t){let n=isObject(t)?t.connection:void 0;return typeof n!=`string`||n===``?`Search connected tools`:isObject(t)&&t.signIn===!0?`Connect ${displayProperName(n)}`:`Search ${displayProperName(n)} tools`}async function searchConnectionTools(e,t){let n=isObject(t)?t:{},r=requireRegistry(),i=n.connection===void 0||n.connection===``?void 0:n.connection;if(n.signIn===!0&&i===void 0)throw Error("connection_search with signIn: true requires `connection`. Ask the user to sign in to one connection at a time.");let a=i===void 0?r.getConnections():[requireConnection(r,i)],o=createAuthorizationExecution();await completePendingAuthorizations(r,a,o);let s=[],c=[];for(let e of a){let t=await listConnectionTools(r,e,o,n.signIn===!0);if(`signIn`in t)return t.signIn;if(`unavailable`in t)s.push(t.unavailable);else for(let n of t.tools)c.push({connection:e,tool:n})}let l=s.filter(e=>e.terminal);if(a.length>0&&l.length===a.length)throw Error(l.map(e=>e.error).join(`
2
- `));let u=rankConnectionTools(n.query??``,c),d=clampInteger(n.limit,1,50,10),f=clampInteger(n.offset,0,2**53-1,0),p={tools:u.slice(f,f+d).map(({connection:e,tool:t})=>({connection:e.connectionName,description:t.description,signature:renderToolSignature({inputSchema:t.inputSchema,name:t.name,outputSchema:t.outputSchema}),tool:t.name})),total:u.length};return s.length>0&&(p.unavailable=s.map(({terminal:e,...t})=>t)),p}async function listConnectionTools(e,t,n,r){let i=t.connectionName;try{return{tools:await e.getClient(i).getToolMetadata()}}catch(t){if(isConnectionAuthorizationRequiredError(t)){let a=await resolveInteractiveAuthorization(e,i);if(a!==void 0&&n.isJustAuthorized(a))return{unavailable:{connection:i,error:`Authorization failed for "${i}": the service rejected the token immediately after authorization.`,terminal:!0}};if(a===void 0){let e=`"${i}" requires authorization and cannot start interactive sign-in.`;if(r)throw Error(e);return{unavailable:{connection:i,error:e,terminal:!1}}}return r?{signIn:await n.handleError(t,a)}:{unavailable:{connection:i,error:`Sign-in required: the user has not signed in to "${i}", so its tools cannot be listed. If the request needs "${i}", call connection_search with connection "${i}" and signIn: true to ask the user to sign in.`,requiresSignIn:!0,terminal:!1}}}return log.warn(`failed to load connection tools`,{connection:i,error:t}),{unavailable:{connection:i,error:isConnectionAuthorizationFailedError(t)?`Authorization failed for "${i}": ${t.message}`:`Failed to load tools for "${i}": ${toErrorMessage(t)}`,terminal:!0}}}}function clampInteger(e,t,n,r){return typeof e!=`number`||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.trunc(e)))}async function executeConnectionTool(e,t,n){let r=readExecuteTarget(t);if(r===void 0)throw Error("connection_execute requires string `connection` and `tool` values.");let i=requireRegistry(),a=requireConnection(i,r.connection);releaseApprovalPin(n.callId,a),assertPendingAuthorizationInstances(i,[a]);let o=await resolveInteractiveAuthorization(i,a.connectionName),s=createAuthorizationExecution();o!==void 0&&await s.complete(o);let c=i.getClient(a.connectionName),l;try{l=await c.getToolMetadata()}catch(e){return await s.handleError(e,o)}let u=l.find(e=>e.name===r.tool);if(u===void 0)throw Error(unknownToolMessage(a,r.tool,l));let d=await validToolInput(a,u,r.input),f=qualifiedToolName(r),p;try{p=await c.executeTool(u.name,d,{abortSignal:n.abortSignal,callId:n.callId})}catch(e){if(isConnectionAuthorizationRequiredError(e))return await s.handleError(e,o);throw reportNestedToolAction(n.callId,{input:d,isError:!0,output:toErrorMessage(e),toolName:f}),e}let m=toConnectionToolResult(a.protocol,u,p);if(!m.ok)throw reportNestedToolAction(n.callId,{input:d,isError:!0,output:m.error,toolName:f}),Error(m.error);return reportNestedToolAction(n.callId,{input:d,output:m.value,toolName:f}),m.value}async function validToolInput(e,t,n){let r=await defineJsonSchema(t.inputSchema)[`~standard`].validate(n);if(r.issues===void 0)return r.value;let i=r.issues.map(e=>{let t=(e.path??[]).map(e=>String(typeof e==`object`?e.key:e)).join(`.`);return t.length>0?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(`Invalid input for "${t.name}" on connection "${e.connectionName}": ${i}. Signature: ${renderToolSignature({inputSchema:t.inputSchema,name:t.name,outputSchema:t.outputSchema})}`)}function unknownToolMessage(e,t,n){let r=closestToolNames(t,n,5),i=r.length>0?` Closest tools: ${r.join(`, `)}.`:` Use connection_search to find its tools.`;return`Connection "${e.connectionName}" has no tool named "${t}".${i}`}async function resolveInteractiveAuthorization(e,t){let n=findConnection(e,t);if(n===void 0)return;let r=await resolveConnectionAuthorization(n);if(r!==void 0&&supportsInteractiveAuthorization(r))return{scope:n.connectionName,instanceId:n.instanceId,connection:{url:n.url??``},authorization:r}}async function completePendingAuthorizations(e,t,n){assertPendingAuthorizationInstances(e,t);let r=getAuthorizationResults();for(let i of t){if(!r.some(e=>e.name===i.connectionName))continue;let t=await resolveInteractiveAuthorization(e,i.connectionName);t!==void 0&&await n.complete(t)}}function assertPendingAuthorizationInstances(e,t){let n=new Set(t.map(e=>e.connectionName));for(let t of getAuthorizationResults())if(t.instanceId!==void 0&&n.has(t.name)&&findConnection(e,t.name)?.instanceId!==t.instanceId)throw Error(`Authorization for "${t.name}" cannot complete because its resolved connection changed while sign-in was pending. Start sign-in again.`)}function requireRegistry(){let e=loadContext().get(ConnectionRegistryKey);if(e===void 0)throw Error(`This agent has no connections.`);return e}function requireConnection(e,t){let n=findConnection(e,t);if(n!==void 0)return n;let r=e.getConnectionNames();throw Error(r.length===0?`Connection "${t}" is not available. No connections are available right now.`:`Connection "${t}" is not available. Available connections: ${r.join(`, `)}.`)}export{CONNECTION_SEARCH_TOOL_NAME,resolveConnectionTools};
2
+ `));let u=rankConnectionTools(n.query??``,c),d=clampInteger(n.limit,1,50,10),f=clampInteger(n.offset,0,2**53-1,0),p={tools:u.slice(f,f+d).map(({connection:e,tool:t})=>({connection:e.connectionName,description:t.description,signature:renderToolSignature({inputSchema:t.inputSchema,name:t.name,outputSchema:t.outputSchema}),tool:t.name})),total:u.length};return s.length>0&&(p.unavailable=s.map(({terminal:e,...t})=>t)),p}async function listConnectionTools(e,t,n,r){let i=t.connectionName;try{return{tools:await e.getClient(i).getToolMetadata()}}catch(t){if(isConnectionAuthorizationRequiredError(t)){let a=await resolveInteractiveAuthorization(e,i);if(a!==void 0&&n.isJustAuthorized(a))return{unavailable:{connection:i,error:`Authorization failed for "${i}": the service rejected the token immediately after authorization.`,terminal:!0}};if(a===void 0){let e=`"${i}" requires authorization and cannot start interactive sign-in.`;if(r)throw Error(e);return{unavailable:{connection:i,error:e,terminal:!1}}}return r?{signIn:await n.handleError(t,a)}:{unavailable:{connection:i,error:`Sign-in required: the user has not signed in to "${i}", so its tools cannot be listed. If the request needs "${i}", call connection_search with connection "${i}" and signIn: true to ask the user to sign in.`,requiresSignIn:!0,terminal:!1}}}return log.warn(`failed to load connection tools`,{connection:i,error:t}),{unavailable:{connection:i,error:isConnectionAuthorizationFailedError(t)?`Authorization failed for "${i}": ${t.message}`:`Failed to load tools for "${i}": ${toErrorMessage(t)}`,terminal:!0}}}}function clampInteger(e,t,n,r){return typeof e!=`number`||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.trunc(e)))}async function executeConnectionTool(e,t,n){let r=readExecuteTarget(t);if(r===void 0)throw Error("connection_execute requires string `connection` and `tool` values.");let i=requireRegistry(),a=requireConnection(i,r.connection);releaseApprovalPin(n.callId,a),assertPendingAuthorizationInstances(i,[a]);let o=await resolveInteractiveAuthorization(i,a.connectionName),s=createAuthorizationExecution();o!==void 0&&await s.complete(o);let c=i.getClient(a.connectionName);o!==void 0&&s.isJustAuthorized(o)&&await c.close();let l;try{l=await c.getToolMetadata()}catch(e){return await s.handleError(e,o)}let u=l.find(e=>e.name===r.tool);if(u===void 0)throw Error(unknownToolMessage(a,r.tool,l));let d=await validToolInput(a,u,r.input),f=qualifiedToolName(r),p;try{p=await c.executeTool(u.name,d,{abortSignal:n.abortSignal,callId:n.callId})}catch(e){if(isConnectionAuthorizationRequiredError(e))return await s.handleError(e,o);throw reportNestedToolAction(n.callId,{input:d,isError:!0,output:toErrorMessage(e),toolName:f}),e}let m=toConnectionToolResult(a.protocol,u,p);if(!m.ok)throw reportNestedToolAction(n.callId,{input:d,isError:!0,output:m.error,toolName:f}),Error(m.error);return reportNestedToolAction(n.callId,{input:d,output:m.value,toolName:f}),m.value}async function validToolInput(e,t,n){let r=await defineJsonSchema(t.inputSchema)[`~standard`].validate(n);if(r.issues===void 0)return r.value;let i=r.issues.map(e=>{let t=(e.path??[]).map(e=>String(typeof e==`object`?e.key:e)).join(`.`);return t.length>0?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(`Invalid input for "${t.name}" on connection "${e.connectionName}": ${i}. Signature: ${renderToolSignature({inputSchema:t.inputSchema,name:t.name,outputSchema:t.outputSchema})}`)}function unknownToolMessage(e,t,n){let r=closestToolNames(t,n,5),i=r.length>0?` Closest tools: ${r.join(`, `)}.`:` Use connection_search to find its tools.`;return`Connection "${e.connectionName}" has no tool named "${t}".${i}`}async function resolveInteractiveAuthorization(e,t){let n=findConnection(e,t);if(n===void 0)return;let r=await resolveConnectionAuthorization(n);if(r!==void 0&&supportsInteractiveAuthorization(r))return{scope:n.connectionName,instanceId:n.instanceId,connection:{url:n.url??``},authorization:r}}async function completePendingAuthorizations(e,t,n){assertPendingAuthorizationInstances(e,t);let r=getAuthorizationResults();for(let i of t){if(!r.some(e=>e.name===i.connectionName))continue;let t=await resolveInteractiveAuthorization(e,i.connectionName);t!==void 0&&(await n.complete(t),n.isJustAuthorized(t)&&await e.getClient(i.connectionName).close())}}function assertPendingAuthorizationInstances(e,t){let n=new Set(t.map(e=>e.connectionName));for(let t of getAuthorizationResults())if(t.instanceId!==void 0&&n.has(t.name)&&findConnection(e,t.name)?.instanceId!==t.instanceId)throw Error(`Authorization for "${t.name}" cannot complete because its resolved connection changed while sign-in was pending. Start sign-in again.`)}function requireRegistry(){let e=loadContext().get(ConnectionRegistryKey);if(e===void 0)throw Error(`This agent has no connections.`);return e}function requireConnection(e,t){let n=findConnection(e,t);if(n!==void 0)return n;let r=e.getConnectionNames();throw Error(r.length===0?`Connection "${t}" is not available. No connections are available right now.`:`Connection "${t}" is not available. Available connections: ${r.join(`, `)}.`)}export{CONNECTION_SEARCH_TOOL_NAME,resolveConnectionTools};
@@ -1 +1 @@
1
- import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo,cachedPackageLocation;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.72.0`,WORKFLOW_MODULE_ALIASES={"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const packageRequire=createRequire(resolveCurrentModulePath());function tryResolveVerifiedPackageRoot(e){try{let t=realpathSync.native(e);return tryReadInstalledPackageInfo(t,EVE_PACKAGE_NAME)===void 0?void 0:dirname(t)}catch{return}}function findNearestVerifiedPackageRoot(e){let t=e;for(;;){let e=tryResolveVerifiedPackageRoot(join(t,`package.json`));if(e!==void 0)return e;let n=dirname(t);if(n===t)return;t=n}}function tryResolveDirectBuildLocation(e){let t=dirname(e);for(;;){if(basename(t)===`dist`){let e=tryResolveVerifiedPackageRoot(join(dirname(t),`package.json`));if(e!==void 0)return{packageBuildRoot:t,packageRoot:e}}let e=dirname(t);if(e===t)return;t=e}}function isSourceCheckout(e){return existsSync(join(e,`src`,`internal`,`application`,`package.ts`))}function tryCreatePackageLocation(e){if(isSourceCheckout(e))return{packageBuildRoot:null,packageRoot:e};let t=join(e,`dist`);if(existsSync(t))return{packageBuildRoot:t,packageRoot:e}}function resolveSelfPackageJsonPath(e){return createRequire(e).resolve(`${EVE_PACKAGE_NAME}/package.json`)}function resolvePackageLocationFromModulePath(e,t=resolveSelfPackageJsonPath){let n=realpathSync.native(e),r=tryResolveDirectBuildLocation(n);if(r!==void 0)return r;let i=findNearestVerifiedPackageRoot(dirname(n));if(i!==void 0&&isSourceCheckout(i))return{packageBuildRoot:null,packageRoot:i};try{let e=tryResolveVerifiedPackageRoot(t(n)),r=e===void 0?void 0:tryCreatePackageLocation(e);if(r!==void 0)return r}catch{}let a=i===void 0?void 0:tryCreatePackageLocation(i);if(a!==void 0)return a;throw Error(`Failed to resolve the eve package root from "${e}".`)}function resolvePackageLocation(){return cachedPackageLocation??=resolvePackageLocationFromModulePath(resolveCurrentModulePath()),cachedPackageLocation}function resolvePackageBuildRoot(){return resolvePackageLocation().packageBuildRoot}function resolvePackageRoot(){return resolvePackageLocation().packageRoot}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){try{return packageRequire.resolve(e)}catch(t){let n=tryResolvePackageRoot(),r=n===void 0||!isSourceCheckout(n)?void 0:resolveSourceCheckoutExport(n,e);if(r!==void 0)return r;throw t}}function resolveSourceCheckoutExport(e,t){if(t!==EVE_PACKAGE_NAME&&!t.startsWith(`${EVE_PACKAGE_NAME}/`))return;let n=t===EVE_PACKAGE_NAME?`.`:`.${t.slice(EVE_PACKAGE_NAME.length)}`;try{let t=JSON.parse(readFileSync(join(e,`package.json`),`utf8`)).exports?.[n],r=typeof t==`string`?t:t?.[`eve-source`]??t?.import??t?.default;if(r===void 0)return;let i=r.replace(/^\.\/dist\/src\//,`src/`).replace(/\.[cm]?js$/u,`.ts`),a=join(e,i);return existsSync(a)?a:void 0}catch{return}}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(typeof t.name==`string`&&typeof t.version==`string`)return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(packageRequire.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function readWorkflowVersionFromManifest(e){let t=e;for(let e of[t.devDependencies,t.dependencies,t.peerDependencies]){let t=e?.[`@workflow/core`];if(typeof t==`string`&&t.trim().length>0)return t}}function resolveExpectedWorkflowVersion(){let e=tryResolvePackageRoot();if(e!==void 0)try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(join(e,`package.json`),`utf8`)))}catch{}try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(packageRequire.resolve(`${EVE_PACKAGE_NAME}/package.json`),`utf8`)))}catch{return}}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/api`||e===`workflow/runtime`)return resolvePackageSourceFilePath(`src/internal/workflow/runtime.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?packageRequire.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveExpectedWorkflowVersion,resolveInstalledPackageInfo,resolvePackageCompiledFilePath,resolvePackageDependencyPath,resolvePackageLocationFromModulePath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
1
+ import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo,cachedPackageLocation;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.72.1`,WORKFLOW_MODULE_ALIASES={"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const packageRequire=createRequire(resolveCurrentModulePath());function tryResolveVerifiedPackageRoot(e){try{let t=realpathSync.native(e);return tryReadInstalledPackageInfo(t,EVE_PACKAGE_NAME)===void 0?void 0:dirname(t)}catch{return}}function findNearestVerifiedPackageRoot(e){let t=e;for(;;){let e=tryResolveVerifiedPackageRoot(join(t,`package.json`));if(e!==void 0)return e;let n=dirname(t);if(n===t)return;t=n}}function tryResolveDirectBuildLocation(e){let t=dirname(e);for(;;){if(basename(t)===`dist`){let e=tryResolveVerifiedPackageRoot(join(dirname(t),`package.json`));if(e!==void 0)return{packageBuildRoot:t,packageRoot:e}}let e=dirname(t);if(e===t)return;t=e}}function isSourceCheckout(e){return existsSync(join(e,`src`,`internal`,`application`,`package.ts`))}function tryCreatePackageLocation(e){if(isSourceCheckout(e))return{packageBuildRoot:null,packageRoot:e};let t=join(e,`dist`);if(existsSync(t))return{packageBuildRoot:t,packageRoot:e}}function resolveSelfPackageJsonPath(e){return createRequire(e).resolve(`${EVE_PACKAGE_NAME}/package.json`)}function resolvePackageLocationFromModulePath(e,t=resolveSelfPackageJsonPath){let n=realpathSync.native(e),r=tryResolveDirectBuildLocation(n);if(r!==void 0)return r;let i=findNearestVerifiedPackageRoot(dirname(n));if(i!==void 0&&isSourceCheckout(i))return{packageBuildRoot:null,packageRoot:i};try{let e=tryResolveVerifiedPackageRoot(t(n)),r=e===void 0?void 0:tryCreatePackageLocation(e);if(r!==void 0)return r}catch{}let a=i===void 0?void 0:tryCreatePackageLocation(i);if(a!==void 0)return a;throw Error(`Failed to resolve the eve package root from "${e}".`)}function resolvePackageLocation(){return cachedPackageLocation??=resolvePackageLocationFromModulePath(resolveCurrentModulePath()),cachedPackageLocation}function resolvePackageBuildRoot(){return resolvePackageLocation().packageBuildRoot}function resolvePackageRoot(){return resolvePackageLocation().packageRoot}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){try{return packageRequire.resolve(e)}catch(t){let n=tryResolvePackageRoot(),r=n===void 0||!isSourceCheckout(n)?void 0:resolveSourceCheckoutExport(n,e);if(r!==void 0)return r;throw t}}function resolveSourceCheckoutExport(e,t){if(t!==EVE_PACKAGE_NAME&&!t.startsWith(`${EVE_PACKAGE_NAME}/`))return;let n=t===EVE_PACKAGE_NAME?`.`:`.${t.slice(EVE_PACKAGE_NAME.length)}`;try{let t=JSON.parse(readFileSync(join(e,`package.json`),`utf8`)).exports?.[n],r=typeof t==`string`?t:t?.[`eve-source`]??t?.import??t?.default;if(r===void 0)return;let i=r.replace(/^\.\/dist\/src\//,`src/`).replace(/\.[cm]?js$/u,`.ts`),a=join(e,i);return existsSync(a)?a:void 0}catch{return}}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(typeof t.name==`string`&&typeof t.version==`string`)return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(packageRequire.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function readWorkflowVersionFromManifest(e){let t=e;for(let e of[t.devDependencies,t.dependencies,t.peerDependencies]){let t=e?.[`@workflow/core`];if(typeof t==`string`&&t.trim().length>0)return t}}function resolveExpectedWorkflowVersion(){let e=tryResolvePackageRoot();if(e!==void 0)try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(join(e,`package.json`),`utf8`)))}catch{}try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(packageRequire.resolve(`${EVE_PACKAGE_NAME}/package.json`),`utf8`)))}catch{return}}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/api`||e===`workflow/runtime`)return resolvePackageSourceFilePath(`src/internal/workflow/runtime.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?packageRequire.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveExpectedWorkflowVersion,resolveInstalledPackageInfo,resolvePackageCompiledFilePath,resolvePackageDependencyPath,resolvePackageLocationFromModulePath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
@@ -6,6 +6,12 @@ import type { ConnectionClient, ConnectionToolExecuteOptions, ConnectionToolMeta
6
6
  *
7
7
  * Created lazily per-connection per-session. Caches tool metadata after
8
8
  * the first `getToolMetadata()` call.
9
+ *
10
+ * When the connection declares `authorization` but no token is available
11
+ * yet (`getToken` throws {@link ConnectionAuthorizationRequiredError}), the
12
+ * client connects anonymously instead of failing. Sign-in is only requested
13
+ * once the server asks for it: an HTTP `401` on any request, or a tool
14
+ * result that carries an `mcp/www_authenticate` challenge.
9
15
  */
10
16
  export declare class McpConnectionClient implements ConnectionClient {
11
17
  #private;
@@ -35,7 +41,8 @@ export declare class McpConnectionClient implements ConnectionClient {
35
41
  * A `401`/`invalid_token` from the remote server is translated into
36
42
  * {@link ConnectionAuthorizationRequiredError} via {@link #rethrowClassified}
37
43
  * so callers re-enter the authorization flow instead of surfacing an
38
- * opaque transport error.
44
+ * opaque transport error. A tool error result carrying an
45
+ * `_meta["mcp/www_authenticate"]` challenge is treated the same way.
39
46
  */
40
47
  executeTool(toolName: string, args: unknown, options: ConnectionToolExecuteOptions): Promise<unknown>;
41
48
  close(): Promise<void>;
@@ -49,6 +56,16 @@ export declare class McpConnectionClient implements ConnectionClient {
49
56
  * left to propagate, since re-running the same grant would not help.)
50
57
  */
51
58
  export declare function isMcpAuthRequiredError(error: unknown): boolean;
59
+ /** `_meta` key a tool result uses to ask for sign-in (OpenAI Apps SDK convention). */
60
+ export declare const MCP_WWW_AUTHENTICATE_META_KEY = "mcp/www_authenticate";
61
+ /**
62
+ * Returns `true` for a `tools/call` error result that asks the client to
63
+ * sign in: `isError: true` plus a non-empty `_meta["mcp/www_authenticate"]`
64
+ * (a `WWW-Authenticate` challenge string or list of them). Servers that
65
+ * accept anonymous `initialize`/`tools/list` use this to protect individual
66
+ * tools without failing the whole HTTP request.
67
+ */
68
+ export declare function isMcpAuthChallengeResult(result: unknown): boolean;
52
69
  /**
53
70
  * Returns `true` when a tool name passes the configured filter.
54
71
  */
@@ -1 +1 @@
1
- import{isObject}from"#shared/guards.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{ConnectionAuthorizationRequiredError}from"#connections/errors.js";import{evictScopedToken,resolveScopedToken}from"#runtime/connections/scoped-authorization.js";import{resolveConnectionAuthorization}from"#runtime/connections/resolve-authorization.js";import{createMCPClient}from"#compiled/@ai-sdk/mcp/index.js";import{omitProvidedArgumentsFromSchema,resolveProvidedArguments}from"#runtime/connections/provided-arguments.js";import{createMcpTraceFetch,withMcpToolCallSpan,withMcpToolsListSpan}from"#runtime/connections/mcp-tracing.js";var McpConnectionClient=class{#e;#t;#n;#r;#i;constructor(e){this.#i=e}async connect(){if(this.#t!==void 0)return this.#t;if(this.#e!==void 0)return this.#e;this.#e=this.#a();try{return this.#t=await this.#e,this.#t}catch(e){throw this.#e=void 0,e}}async#a(){let e=await resolveHeaders(this.#i),t=this.#i.url,n=createMcpTraceFetch({connectionName:this.#i.connectionName,getProtocolVersion:()=>this.#t?.initializeResult?.protocolVersion});try{return await createMCPClient({protocolVersionDiscovery:this.#i.protocolVersionDiscovery,transport:{fetch:n,headers:e,type:`http`,url:t}})}catch(r){if(!isMcpHttpFallbackRetryableError(r))throw r;return await createMCPClient({protocolVersionDiscovery:this.#i.protocolVersionDiscovery,transport:{fetch:n,headers:e,type:`sse`,url:t}})}}async getToolMetadata(){return(await this.#o()).metadata}async executeTool(e,t,n){try{let{tools:r}=await this.#o(),i=r[e];if(i?.execute===void 0)throw Error(`Tool "${e}" not found in connection "${this.#i.connectionName}".`);let a=i.execute,o=await resolveProvidedArguments({args:t,callId:n.callId,connection:this.#i,toolName:e});return await withMcpToolCallSpan({arguments:t,connectionName:this.#i.connectionName,execute:async()=>await a(o,{abortSignal:n.abortSignal}),protocolVersion:this.#t?.initializeResult?.protocolVersion,toolName:e})}catch(e){return await this.#l(e)}}async#o(){if(this.#r!==void 0)return this.#r;if(this.#n!==void 0)return this.#n;this.#n=this.#s();try{return this.#r=await this.#n,this.#r}catch(e){throw this.#n=void 0,e}}async#s(){try{return await this.#c()}catch(e){return await this.#l(e)}}async#c(){let e=await this.connect(),t=await withMcpToolsListSpan({connectionName:this.#i.connectionName,execute:()=>e.listTools(),protocolVersion:e.initializeResult?.protocolVersion}),n=this.#i.tools,r=n===void 0?t.tools:t.tools.filter(e=>passesToolFilter(e.name,n)),i=Object.keys(this.#i.toolCall?.providedArguments??{}),a=r.map(e=>({...e,inputSchema:omitProvidedArgumentsFromSchema(e.inputSchema,i)})),o=e.toolsFromDefinitions({tools:a});return{metadata:a.map(e=>({annotations:e.annotations,description:e.description??``,inputSchema:e.inputSchema??{},name:e.name,outputSchema:`outputSchema`in e&&e.outputSchema!==void 0?e.outputSchema:void 0})),tools:o}}async close(){this.#t!==void 0&&(await this.#t.close(),this.#t=void 0),this.#e=void 0,this.#n=void 0,this.#r=void 0}async#l(e){throw isMcpAuthRequiredError(e)?(await this.#u(),await this.close(),new ConnectionAuthorizationRequiredError(this.#i.connectionName,{message:`Connection "${this.#i.connectionName}" requires authorization (the server rejected the token).`})):e}async#u(){let e=await resolveConnectionAuthorization(this.#i);e!==void 0&&await evictScopedToken({authorization:e,connection:{url:this.#i.url},instanceId:this.#i.instanceId,scope:this.#i.connectionName})}};function isMcpAuthRequiredError(e){return readHttpStatus(e)===401}function isMcpHttpFallbackRetryableError(e){let t=readHttpStatus(e);return t===400||t===404||t===405}function readHttpStatus(e){for(let t of walkErrorChain(e)){if(!isObject(t))continue;let e=readStatusField(t);if(e!==void 0)return e;let n=t.response;if(isObject(n)){let e=readStatusField(n);if(e!==void 0)return e}if(typeof t.message==`string`){let e=/\bHTTP\s+(\d{3})\b/u.exec(t.message);if(e?.[1]!==void 0)return Number(e[1])}}}function readStatusField(e){if(typeof e.status==`number`)return e.status;if(typeof e.statusCode==`number`)return e.statusCode}function*walkErrorChain(e){let t=e,n=new Set;for(;t!=null&&!n.has(t);){if(n.add(t),yield t,!isObject(t)||!(`cause`in t))return;t=t.cause}}function passesToolFilter(e,t){return t===void 0?!0:`allow`in t?t.allow.includes(e):!t.block.includes(e)}async function resolveHeaders(e){let t={},n,getCallbackContext=()=>n??=buildCallbackContext(),r=await resolveConnectionAuthorization(e,typeof e.authorization==`function`?getCallbackContext():void 0);if(r!==void 0&&(t.Authorization=`Bearer ${(await resolveToken(e,r)).token}`),e.headers!==void 0){let n=await resolveHeadersDefinition(e.headers,getCallbackContext);for(let[i,a]of Object.entries(n)){if(r!==void 0&&i.toLowerCase()===`authorization`)throw Error(`Connection "${e.connectionName}" headers must not include an "Authorization" key when "authorization" is also provided.`);t[i]=a}}return t}async function resolveToken(e,t){return await resolveScopedToken({authorization:t,connection:{url:e.url},instanceId:e.instanceId,scope:e.connectionName})}async function resolveHeadersDefinition(e,t){if(typeof e==`function`)return{...await e(t())};let n={},r=Object.entries(e);for(let[e,i]of r)n[e]=await resolveHeaderValue(i,t);return n}async function resolveHeaderValue(e,t){return typeof e==`function`?await e(t()):await e}export{McpConnectionClient,isMcpAuthRequiredError,passesToolFilter,resolveHeaders};
1
+ import{isObject}from"#shared/guards.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{ConnectionAuthorizationRequiredError,isConnectionAuthorizationRequiredError}from"#connections/errors.js";import{evictScopedToken,resolveScopedToken}from"#runtime/connections/scoped-authorization.js";import{resolveConnectionAuthorization}from"#runtime/connections/resolve-authorization.js";import{createMCPClient}from"#compiled/@ai-sdk/mcp/index.js";import{omitProvidedArgumentsFromSchema,resolveProvidedArguments}from"#runtime/connections/provided-arguments.js";import{createMcpTraceFetch,withMcpToolCallSpan,withMcpToolsListSpan}from"#runtime/connections/mcp-tracing.js";var McpConnectionClient=class{#e;#t;#n;#r;#i;#a=!1;constructor(e){this.#i=e}async connect(){if(this.#t!==void 0)return this.#t;if(this.#e!==void 0)return this.#e;this.#e=this.#o();try{return this.#t=await this.#e,this.#t}catch(e){throw this.#e=void 0,e}}async#o(){let{anonymous:e,headers:t}=await resolveConnectionHeaders(this.#i,{anonymousWhenAuthorizationRequired:!0});this.#a=e;let n=this.#i.url,r=createMcpTraceFetch({connectionName:this.#i.connectionName,getProtocolVersion:()=>this.#t?.initializeResult?.protocolVersion});try{return await createMCPClient({protocolVersionDiscovery:this.#i.protocolVersionDiscovery,transport:{fetch:r,headers:t,type:`http`,url:n}})}catch(e){if(!isMcpHttpFallbackRetryableError(e))throw e;return await createMCPClient({protocolVersionDiscovery:this.#i.protocolVersionDiscovery,transport:{fetch:r,headers:t,type:`sse`,url:n}})}}async getToolMetadata(){return(await this.#s()).metadata}async executeTool(e,t,n){let r;try{let{tools:i}=await this.#s(),a=i[e];if(a?.execute===void 0)throw Error(`Tool "${e}" not found in connection "${this.#i.connectionName}".`);let o=a.execute,s=await resolveProvidedArguments({args:t,callId:n.callId,connection:this.#i,toolName:e});r=await withMcpToolCallSpan({arguments:t,connectionName:this.#i.connectionName,execute:async()=>await o(s,{abortSignal:n.abortSignal}),protocolVersion:this.#t?.initializeResult?.protocolVersion,toolName:e})}catch(e){return await this.#u(e)}return isMcpAuthChallengeResult(r)?await this.#d(`the server asked for sign-in to call "${e}"`):r}async#s(){if(this.#r!==void 0)return this.#r;if(this.#n!==void 0)return this.#n;this.#n=this.#c();try{return this.#r=await this.#n,this.#r}catch(e){throw this.#n=void 0,e}}async#c(){try{return await this.#l()}catch(e){return await this.#u(e)}}async#l(){let e=await this.connect(),t=await withMcpToolsListSpan({connectionName:this.#i.connectionName,execute:()=>e.listTools(),protocolVersion:e.initializeResult?.protocolVersion}),n=this.#i.tools,r=n===void 0?t.tools:t.tools.filter(e=>passesToolFilter(e.name,n)),i=Object.keys(this.#i.toolCall?.providedArguments??{}),a=r.map(e=>({...e,inputSchema:omitProvidedArgumentsFromSchema(e.inputSchema,i)})),o=e.toolsFromDefinitions({tools:a});return{metadata:a.map(e=>({annotations:e.annotations,description:e.description??``,inputSchema:e.inputSchema??{},name:e.name,outputSchema:`outputSchema`in e&&e.outputSchema!==void 0?e.outputSchema:void 0})),tools:o}}async close(){this.#t!==void 0&&(await this.#t.close(),this.#t=void 0),this.#e=void 0,this.#n=void 0,this.#r=void 0,this.#a=!1}async#u(e){if(!isMcpAuthRequiredError(e))throw e;return await this.#d(this.#a?`the server requires sign-in`:`the server rejected the token`)}async#d(e){throw this.#a||await this.#f(),await this.close(),new ConnectionAuthorizationRequiredError(this.#i.connectionName,{message:`Connection "${this.#i.connectionName}" requires authorization (${e}).`})}async#f(){let e=await resolveConnectionAuthorization(this.#i);e!==void 0&&await evictScopedToken({authorization:e,connection:{url:this.#i.url},instanceId:this.#i.instanceId,scope:this.#i.connectionName})}};function isMcpAuthRequiredError(e){return readHttpStatus(e)===401}const MCP_WWW_AUTHENTICATE_META_KEY=`mcp/www_authenticate`;function isMcpAuthChallengeResult(e){if(!isObject(e)||e.isError!==!0||!isObject(e._meta))return!1;let t=e._meta[MCP_WWW_AUTHENTICATE_META_KEY];return(typeof t==`string`||Array.isArray(t))&&t.length>0}function isMcpHttpFallbackRetryableError(e){let t=readHttpStatus(e);return t===400||t===404||t===405}function readHttpStatus(e){for(let t of walkErrorChain(e)){if(!isObject(t))continue;let e=readStatusField(t);if(e!==void 0)return e;let n=t.response;if(isObject(n)){let e=readStatusField(n);if(e!==void 0)return e}if(typeof t.message==`string`){let e=/\bHTTP\s+(\d{3})\b/u.exec(t.message);if(e?.[1]!==void 0)return Number(e[1])}}}function readStatusField(e){if(typeof e.status==`number`)return e.status;if(typeof e.statusCode==`number`)return e.statusCode}function*walkErrorChain(e){let t=e,n=new Set;for(;t!=null&&!n.has(t);){if(n.add(t),yield t,!isObject(t)||!(`cause`in t))return;t=t.cause}}function passesToolFilter(e,t){return t===void 0?!0:`allow`in t?t.allow.includes(e):!t.block.includes(e)}async function resolveHeaders(e){let{headers:t}=await resolveConnectionHeaders(e,{anonymousWhenAuthorizationRequired:!1});return t}async function resolveConnectionHeaders(e,t){let n={},r=!1,i,getCallbackContext=()=>i??=buildCallbackContext(),a=await resolveConnectionAuthorization(e,typeof e.authorization==`function`?getCallbackContext():void 0);if(a!==void 0)try{n.Authorization=`Bearer ${(await resolveToken(e,a)).token}`}catch(e){if(!t.anonymousWhenAuthorizationRequired||!isConnectionAuthorizationRequiredError(e))throw e;r=!0}if(e.headers!==void 0){let t=await resolveHeadersDefinition(e.headers,getCallbackContext);for(let[r,i]of Object.entries(t)){if(a!==void 0&&r.toLowerCase()===`authorization`)throw Error(`Connection "${e.connectionName}" headers must not include an "Authorization" key when "authorization" is also provided.`);n[r]=i}}return{anonymous:r,headers:n}}async function resolveToken(e,t){return await resolveScopedToken({authorization:t,connection:{url:e.url},instanceId:e.instanceId,scope:e.connectionName})}async function resolveHeadersDefinition(e,t){if(typeof e==`function`)return{...await e(t())};let n={},r=Object.entries(e);for(let[e,i]of r)n[e]=await resolveHeaderValue(i,t);return n}async function resolveHeaderValue(e,t){return typeof e==`function`?await e(t()):await e}export{MCP_WWW_AUTHENTICATE_META_KEY,McpConnectionClient,isMcpAuthChallengeResult,isMcpAuthRequiredError,passesToolFilter,resolveHeaders};
@@ -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{DEFAULT_CONNECT_PACKAGE_VERSION,resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_CHANNEL_TEMPLATES}from"./web-template.js";import{AGENT_INSTRUCTIONS_TEMPLATE}from"./instructions-template.js";import{SCAFFOLDED_AGENT_PATHS}from"./agent-paths.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.128`,DEFAULT_ZOD_PACKAGE_VERSION=`4.5.4`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.72.0`,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{[SCAFFOLDED_AGENT_PATHS.config]:renderAgentTemplate(e,t),[SCAFFOLDED_AGENT_PATHS.channel]:WEB_CHANNEL_TEMPLATES.default,[SCAFFOLDED_AGENT_PATHS.instructions]:AGENT_INSTRUCTIONS_TEMPLATE}}function renderAgentTemplate(e,t){let n=parseChatGptModelSelection(e);return n===void 0?BASE_AGENT_TEMPLATE.replaceAll(`__EVE_INIT_MODEL__`,e).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(t)):`import { defineAgent } from "eve";\nimport { chatgpt } from "eve/models/openai";\n\nexport default defineAgent({\n model: chatgpt(${JSON.stringify(n)}),\n${reasoningTemplateLine(t)}});\n`}function reasoningTemplateLine(e){return e===void 0||e===`provider-default`?``:` reasoning: "${e}",\n`}function renderTemplate(e,t){return e===BASE_AGENT_TEMPLATE&&parseChatGptModelSelection(t.model)!==void 0?renderAgentTemplate(t.model,t.reasoning):e.replaceAll(`__EVE_INIT_APP_NAME__`,t.appName).replaceAll(`__EVE_INIT_MODEL__`,t.model).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(t.reasoning)).replaceAll(`__EVE_INIT_BYOK_PROVIDER__`,modelProviderSlug(t.model)).replaceAll(`__EVE_INIT_BYOK_ENV_VAR__`,byokProviderEnvVar(t.model)).replaceAll(`__EVE_INIT_PACKAGE_VERSION__`,formatEveDependencySpecifier(t.eveVersion)).replaceAll(`__EVE_INIT_AI_SDK_VERSION__`,t.aiPackageVersion).replaceAll(`__EVE_INIT_CONNECT_VERSION__`,t.connectPackageVersion).replaceAll(`__EVE_INIT_ZOD_VERSION__`,t.zodPackageVersion).replaceAll(`__EVE_INIT_TYPESCRIPT_VERSION__`,t.typescriptPackageVersion).replaceAll(`__EVE_INIT_TYPES_NODE_VERSION__`,t.nodeTypesVersion).replaceAll(`__EVE_INIT_NODE_ENGINE__`,t.nodeEngine)}function formatEveDependencySpecifier(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/.test(e)?`^${e}`:e}const BASE_AGENT_TEMPLATE=`import { defineAgent } from "eve";
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{DEFAULT_CONNECT_PACKAGE_VERSION,resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_CHANNEL_TEMPLATES}from"./web-template.js";import{AGENT_INSTRUCTIONS_TEMPLATE}from"./instructions-template.js";import{SCAFFOLDED_AGENT_PATHS}from"./agent-paths.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.128`,DEFAULT_ZOD_PACKAGE_VERSION=`4.5.4`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.72.1`,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{[SCAFFOLDED_AGENT_PATHS.config]:renderAgentTemplate(e,t),[SCAFFOLDED_AGENT_PATHS.channel]:WEB_CHANNEL_TEMPLATES.default,[SCAFFOLDED_AGENT_PATHS.instructions]:AGENT_INSTRUCTIONS_TEMPLATE}}function renderAgentTemplate(e,t){let n=parseChatGptModelSelection(e);return n===void 0?BASE_AGENT_TEMPLATE.replaceAll(`__EVE_INIT_MODEL__`,e).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(t)):`import { defineAgent } from "eve";\nimport { chatgpt } from "eve/models/openai";\n\nexport default defineAgent({\n model: chatgpt(${JSON.stringify(n)}),\n${reasoningTemplateLine(t)}});\n`}function reasoningTemplateLine(e){return e===void 0||e===`provider-default`?``:` reasoning: "${e}",\n`}function renderTemplate(e,t){return e===BASE_AGENT_TEMPLATE&&parseChatGptModelSelection(t.model)!==void 0?renderAgentTemplate(t.model,t.reasoning):e.replaceAll(`__EVE_INIT_APP_NAME__`,t.appName).replaceAll(`__EVE_INIT_MODEL__`,t.model).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(t.reasoning)).replaceAll(`__EVE_INIT_BYOK_PROVIDER__`,modelProviderSlug(t.model)).replaceAll(`__EVE_INIT_BYOK_ENV_VAR__`,byokProviderEnvVar(t.model)).replaceAll(`__EVE_INIT_PACKAGE_VERSION__`,formatEveDependencySpecifier(t.eveVersion)).replaceAll(`__EVE_INIT_AI_SDK_VERSION__`,t.aiPackageVersion).replaceAll(`__EVE_INIT_CONNECT_VERSION__`,t.connectPackageVersion).replaceAll(`__EVE_INIT_ZOD_VERSION__`,t.zodPackageVersion).replaceAll(`__EVE_INIT_TYPESCRIPT_VERSION__`,t.typescriptPackageVersion).replaceAll(`__EVE_INIT_TYPES_NODE_VERSION__`,t.nodeTypesVersion).replaceAll(`__EVE_INIT_NODE_ENGINE__`,t.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__",
@@ -1 +1 @@
1
- async function executeAskQuestionTool(e,t){"use workflow";return toAskQuestionOutput(await t.ask(toAskQuestionRequest(e)))}function toAskQuestionRequest(e){let t=e.options?.map(e=>({description:e.description,id:e.label,label:e.label}));return{allowFreeform:!0,display:t===void 0?`text`:`select`,prompt:e.question,...t!==void 0&&{options:t}}}function toAskQuestionOutput(e){switch(e.status){case`answered`:return{answer:e.optionId??e.text??``,status:`answered`};case`cancelled`:return{interrupted:!0};case`unavailable`:return{status:`unavailable`}}}executeAskQuestionTool.workflowId=`workflow//eve@0.72.0//executeAskQuestionTool`;export{executeAskQuestionTool,toAskQuestionOutput,toAskQuestionRequest};
1
+ async function executeAskQuestionTool(e,t){"use workflow";return toAskQuestionOutput(await t.ask(toAskQuestionRequest(e)))}function toAskQuestionRequest(e){let t=e.options?.map(e=>({description:e.description,id:e.label,label:e.label}));return{allowFreeform:!0,display:t===void 0?`text`:`select`,prompt:e.question,...t!==void 0&&{options:t}}}function toAskQuestionOutput(e){switch(e.status){case`answered`:return{answer:e.optionId??e.text??``,status:`answered`};case`cancelled`:return{interrupted:!0};case`unavailable`:return{status:`unavailable`}}}executeAskQuestionTool.workflowId=`workflow//eve@0.72.1//executeAskQuestionTool`;export{executeAskQuestionTool,toAskQuestionOutput,toAskQuestionRequest};
@@ -1 +1 @@
1
- import{sleep}from"#compiled/@workflow/core/index.js";async function executeSleepTool(e,t){"use workflow";let n=new Promise(e=>t.abortSignal.addEventListener(`abort`,()=>e(`interrupted`),{once:!0})),r=sleep(Math.ceil(e.seconds*1e3)).then(()=>`elapsed`);return await Promise.race([r,n])===`elapsed`?{waitedSeconds:e.seconds}:{interrupted:!0}}executeSleepTool.workflowId=`workflow//eve@0.72.0//executeSleepTool`;export{executeSleepTool};
1
+ import{sleep}from"#compiled/@workflow/core/index.js";async function executeSleepTool(e,t){"use workflow";let n=new Promise(e=>t.abortSignal.addEventListener(`abort`,()=>e(`interrupted`),{once:!0})),r=sleep(Math.ceil(e.seconds*1e3)).then(()=>`elapsed`);return await Promise.race([r,n])===`elapsed`?{waitedSeconds:e.seconds}:{interrupted:!0}}executeSleepTool.workflowId=`workflow//eve@0.72.1//executeSleepTool`;export{executeSleepTool};
@@ -298,9 +298,9 @@ export default disableTool();
298
298
 
299
299
  `connection_search` and `connection_execute` give the model every tool from the agent's [connections](../connections) without adding each tool to the model's tool list. eve adds both when the agent has a static connection or a dynamic connection resolver, even when `defaultTools` is `false`, so there is no add command.
300
300
 
301
- - `connection_search({ query?, connection?, signIn?, limit?, offset? })` returns matching tools with their connection, name, description, and a TypeScript signature rendered from the tool's schemas. Omit `query` to list every tool, or pair it with `connection` to list one connection's tools. A plain search never asks the user to sign in. For a connection the user has not signed in to, the result tells the model that sign-in is needed before its tools can be listed: the connection appears under `unavailable` with `requiresSignIn: true` and an error that points to `signIn: true`. Tools from the other connections are still returned.
301
+ - `connection_search({ query?, connection?, signIn?, limit?, offset? })` returns matching tools with their connection, name, description, and a TypeScript signature rendered from the tool's schemas. Omit `query` to list every tool, or pair it with `connection` to list one connection's tools. A plain search never asks the user to sign in. For a connection whose server will not list its tools until the user signs in, the result tells the model that sign-in is needed: the connection appears under `unavailable` with `requiresSignIn: true` and an error that points to `signIn: true`. Tools from the other connections are still returned.
302
302
  - `connection_search({ connection, signIn: true, query? })` asks the user to sign in to that one connection when they have not yet, then returns its matching tools. Without `connection` it fails, so the user is asked about one service at a time.
303
- - `connection_execute({ connection, tool, input })` checks `input` against the tool's input schema, calls the tool, and returns its result. When the connection needs the user's authorization, it also asks the user to sign in and the call parks until sign-in completes. The stream reports the call as a nested action named `<connection>__<tool>`, such as `linear__list_issues`, whose `parentCallId` is the `connection_execute` call id.
303
+ - `connection_execute({ connection, tool, input })` checks `input` against the tool's input schema, calls the tool, and returns its result. When the server asks for the user's authorization, it also asks the user to sign in and the call parks until sign-in completes. The stream reports the call as a nested action named `<connection>__<tool>`, such as `linear__list_issues`, whose `parentCallId` is the `connection_execute` call id.
304
304
 
305
305
  The definitions of both tools never change during a session. eve lists connection names and descriptions in append-only context messages rather than in the system prompt, so finding a tool, signing in, or resolving a dynamic connection keeps the cached prompt prefix.
306
306
 
@@ -44,6 +44,17 @@ For OAuth-backed MCP servers, use the shared [Vercel Connect flow](../connection
44
44
 
45
45
  `connect("...")` is user-scoped by default and requires an authenticated user on the active eve session. Use `connect({ connector, principalType: "app" })` when the server should act as the agent instead. The connections overview covers connector setup, session requirements, app and user scope, callback behavior, and troubleshooting.
46
46
 
47
+ ## When eve asks for sign-in
48
+
49
+ eve asks the user to sign in only when the MCP server asks for it. When a connection has `auth` but no token yet, because its `getToken` throws `ConnectionAuthorizationRequiredError`, eve connects without an `Authorization` header and lists the server's tools. Any other error from `getToken` still fails the connection.
50
+
51
+ - **The server rejects every request without a token.** Most hosted OAuth servers, such as Linear, GitHub, and Notion, answer `initialize` or `tools/list` with HTTP `401`. A plain `connection_search` lists the connection under `unavailable` with `requiresSignIn: true`. Calling `connection_search({ connection, signIn: true })` or any of its tools with `connection_execute` asks the user to sign in.
52
+ - **The server lists tools without a token.** `connection_search` returns its tools with no prompt, and `connection_execute` runs tools the server answers anonymously. Sign-in starts only when a tool call comes back with HTTP `401`, or with an error result that carries a `WWW-Authenticate` challenge in `_meta["mcp/www_authenticate"]`.
53
+
54
+ After the user signs in, the call that asked for it runs again. eve reconnects with the token and reloads the tool list, which may now include tools the server hides from anonymous callers. A connection that already has a token sends it on every request, as before.
55
+
56
+ A server that leaves protected tools out of its anonymous `tools/list` never triggers sign-in, because the model cannot find those tools. Servers that support anonymous use should list every tool and refuse the protected calls.
57
+
47
58
  ## Static tokens and headers
48
59
 
49
60
  MCP connections accept the shared connection `auth` and `headers` options. Use `auth.getToken` for a bearer token, `headers` for another scheme, and resolver functions when credentials or routing depend on the caller. See [Static-token auth](../connections#static-token-auth), [Headers](../connections#headers), and [Per-caller auth and headers](../connections#per-caller-auth-and-headers) for the canonical examples and token-lifecycle behavior.
@@ -227,7 +227,7 @@ export default defineMcpClientConnection({
227
227
 
228
228
  Use the connector UID returned by `vercel connect create`; the display name passed to `--name` is not the UID. `connect("linear/myagent")` is shorthand for a user-scoped interactive OAuth connection: eve resolves a token for the active user before each tool call, emits `authorization.required` when that user has not authorized yet, and resumes the parked turn after the callback completes.
229
229
 
230
- Discovering tools never posts a sign-in prompt for a service the answer does not need. A plain `connection_search` lists connections the user has not authorized yet under `unavailable` with `requiresSignIn: true`. Most OAuth MCP servers reject even tool listing without the user's token, so the model asks for sign-in explicitly, one connection at a time, with `connection_search({ connection, signIn: true })`, which returns that connection's tools once the user signs in. Calling a tool with `connection_execute` on a connection the user has not authorized also asks for sign-in.
230
+ Discovering tools never posts a sign-in prompt for a service the answer does not need. Before the user signs in, eve connects to an MCP server without a token, so a server that lists its tools anonymously is searched like any other connection, and sign-in starts only when one of its tools asks for it (see [When eve asks for sign-in](/docs/connections/mcp#when-eve-asks-for-sign-in)). Most OAuth MCP servers reject even tool listing without the user's token. A plain `connection_search` lists those connections under `unavailable` with `requiresSignIn: true`, and the model asks for sign-in explicitly, one connection at a time, with `connection_search({ connection, signIn: true })`, which returns that connection's tools once the user signs in. Calling a tool with `connection_execute` on such a connection also asks for sign-in.
231
231
 
232
232
  A sign-in holds the turn open until the user connects, the turn is cancelled, or the user sends another message. That message steers the turn: eve cancels the sign-in, reports `authorization.completed` with `outcome: "declined"`, and the model reads the message next. Messages from other people in a shared thread wait until the turn ends, and the completed sign-in resumes the turn as the person who started it.
233
233
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eve",
3
- "version": "0.72.0",
3
+ "version": "0.72.1",
4
4
  "private": false,
5
5
  "description": "Filesystem-first framework for durable backend AI agents that run anywhere.",
6
6
  "keywords": [