| 38 | // the OAuth start flow. These strings are read by the agent resolving the |
| 39 | // failure, so they must name tools that actually exist on the executor. |
| 40 | const authRecovery = (input?: AuthToolFailureInput["recovery"]) => ({ |
| 41 | createConnectionTool: "executor.coreTools.connections.createHandoff", |
| 42 | startOAuthTool: "executor.coreTools.oauth.start", |
| 43 | listConnectionsTool: "executor.coreTools.connections.list", |
| 44 | ...(input?.configureSourceTool ? { configureSourceTool: input.configureSourceTool } : {}), |
| 45 | connectionInstructions: |
| 46 | "For API keys and tokens, call createConnectionTool for the integration to get a browser URL; the user enters the credential there, which creates the bound connection. Do not ask the user to paste secrets into chat. Then call listConnectionsTool to confirm the connection exists before retrying this tool.", |
| 47 | oauthInstructions: |
| 48 | "For OAuth credentials, call startOAuthTool and give the returned authorizationUrl to the user. The completed connection binds automatically, then retry the tool.", |
| 49 | }); |
| 50 | |
| 51 | export const authToolFailure = <T = never>(input: AuthToolFailureInput): ToolResult<T> => { |
| 52 | const error: ToolError = { |